splitter_token

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNameLength = 32
	MaxHistory    = 32
)
View Source
const (
	CloseProofInstructionArgsSize = (1 +
		1) // proof_bump

	CloseProofInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // rentSysvar

	CloseProofInstructionSize = (8 +
		CloseProofInstructionArgsSize +
		CloseProofInstructionAccountsSize) // accounts
)
View Source
const (
	CloseTokenAccountInstructionArgsSize = (1 +
		1 +
		1) // vault_bump

	CloseTokenAccountInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	CloseTokenAccountInstructionSize = (8 +
		CloseTokenAccountInstructionArgsSize +
		CloseTokenAccountInstructionAccountsSize) // accounts
)
View Source
const (
	InitializePoolInstructionArgsSize = (MaxNameLength +
		1) // Levels

	InitializePoolInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	InitializePoolInstructionSize = (8 +
		InitializePoolInstructionArgsSize +
		InitializePoolInstructionAccountsSize) // accounts
)
View Source
const (
	InitializeProofInstructionArgsSize = (1 +
		32 +
		32) // Commitment

	InitializeProofInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	InitializeProofInstructionSize = (8 +
		InitializeProofInstructionArgsSize +
		InitializeProofInstructionAccountsSize) // accounts
)
View Source
const (
	OpenTokenAccountInstructionArgsSize = (1 +
		1) // ProofBump

	OpenTokenAccountInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	OpenTokenAccountInstructionSize = (8 +
		OpenTokenAccountInstructionArgsSize +
		OpenTokenAccountInstructionAccountsSize) // accounts
)
View Source
const (
	SaveRecentRootInstructionArgsSize = 1 // pool_bump

	SaveRecentRootInstructionAccountsSize = (32 +
		32 +
		32) // payer

	SaveRecentRootInstructionSize = (8 +
		SaveRecentRootInstructionArgsSize +
		SaveRecentRootInstructionAccountsSize) // accounts
)
View Source
const (
	TransferWithCommitmentInstructionArgsSize = (1 +
		8 +
		32 +
		32) // recent_root

	TransferWithCommitmentInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	TransferWithCommitmentInstructionSize = (8 +
		TransferWithCommitmentInstructionArgsSize +
		TransferWithCommitmentInstructionAccountsSize) // accounts
)
View Source
const (
	UploadProofInstructionArgsSize = (1 +
		1 +
		1 +
		1 +
		4) // Data

	UploadProofInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	UploadProofInstructionSize = (8 +
		UploadProofInstructionArgsSize +
		UploadProofInstructionAccountsSize) // accounts
)
View Source
const (
	VerifyProofInstructionArgsSize = (1 +
		1) // proof_bump

	VerifyProofInstructionAccountsSize = (32 +
		32 +
		32 +
		32) // payer

	VerifyProofInstructionSize = (8 +
		VerifyProofInstructionArgsSize +
		VerifyProofInstructionAccountsSize) // accounts
)
View Source
const (
	// HashSize is the size, in bytes, of SHA256 hashes as used in this package.
	HashSize = 32
)
View Source
const MerkleTreeSize = (1 +
	4 +
	4 +
	8 +

	HashSize) // root

The size of the {@link MerkleTree} in bytes for the static portion

View Source
const PoolAccountSize = (8 +
	1 +

	32 +
	32 +

	32 +
	1 +

	+MaxNameLength +

	4 +
	1 +


	1) // merkletree_levels
View Source
const ProofAccountSize = (8 +
	1 +
	32 +
	1 +
	32 +
	32 +
	1 +
	1 +

	4) // data

Variables

View Source
var (
	ErrInvalidProgram         = errors.New("invalid program id")
	ErrInvalidAccountData     = errors.New("unexpected account data")
	ErrInvalidInstructionData = errors.New("unexpected instruction data")
)
View Source
var (
	PROGRAM_ADDRESS = mustBase58Decode("spLit2eb13Tz93if6aJM136nUWki5PVUsoEjcUjwpwW")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
var (
	SYSTEM_PROGRAM_ID               = ed25519.PublicKey(mustBase58Decode("11111111111111111111111111111111"))
	SPL_TOKEN_PROGRAM_ID            = ed25519.PublicKey(mustBase58Decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"))
	SPL_ASSOCIATED_TOKEN_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))

	SYSVAR_CLOCK_PUBKEY = ed25519.PublicKey(mustBase58Decode("SysvarC1ock11111111111111111111111111111111"))
	SYSVAR_RENT_PUBKEY  = ed25519.PublicKey(mustBase58Decode("SysvarRent111111111111111111111111111111111"))
)
View Source
var (
	MerkleTreePrefix = []byte("merkletree")
)

Functions

func GetCommitmentStateAddress

func GetCommitmentStateAddress(args *GetCommitmentStateAddressArgs) (ed25519.PublicKey, uint8, error)

func GetCommitmentVaultAddress

func GetCommitmentVaultAddress(args *GetCommitmentVaultAddressArgs) (ed25519.PublicKey, uint8, error)

func GetPoolStateAddress

func GetPoolStateAddress(args *GetPoolStateAddressArgs) (ed25519.PublicKey, uint8, error)

func GetPoolVaultAddress

func GetPoolVaultAddress(args *GetPoolVaultAddressArgs) (ed25519.PublicKey, uint8, error)

func GetProofAddress

func GetProofAddress(args *GetProofAddressArgs) (ed25519.PublicKey, uint8, error)

Types

type AccountMeta

type AccountMeta struct {
	PublicKey  ed25519.PublicKey
	IsWritable bool
	IsSigner   bool
}

AccountMeta represents the account information required for building transactions.

type CloseProofInstructionAccounts

type CloseProofInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Proof     ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type CloseProofInstructionArgs

type CloseProofInstructionArgs struct {
	PoolBump  uint8
	ProofBump uint8
}

type CloseTokenAccountInstructionAccounts

type CloseTokenAccountInstructionAccounts struct {
	Pool            ed25519.PublicKey
	Proof           ed25519.PublicKey
	CommitmentVault ed25519.PublicKey
	PoolVault       ed25519.PublicKey
	Authority       ed25519.PublicKey
	Payer           ed25519.PublicKey
}

type CloseTokenAccountInstructionArgs

type CloseTokenAccountInstructionArgs struct {
	PoolBump  uint8
	ProofBump uint8
	VaultBump uint8
}

type DataVersion

type DataVersion uint8
const (
	UnknownDataVersion DataVersion = iota
	DataVersion1
)

type GetCommitmentStateAddressArgs

type GetCommitmentStateAddressArgs struct {
	Pool        ed25519.PublicKey
	RecentRoot  Hash
	Transcript  Hash
	Destination ed25519.PublicKey
	Amount      uint64
}

type GetCommitmentVaultAddressArgs

type GetCommitmentVaultAddressArgs struct {
	Pool       ed25519.PublicKey
	Commitment ed25519.PublicKey
}

type GetPoolStateAddressArgs

type GetPoolStateAddressArgs struct {
	Mint      ed25519.PublicKey
	Authority ed25519.PublicKey
	Name      string
}

type GetPoolVaultAddressArgs

type GetPoolVaultAddressArgs struct {
	Pool ed25519.PublicKey
}

type GetProofAddressArgs

type GetProofAddressArgs struct {
	Pool       ed25519.PublicKey
	MerkleRoot Hash
	Commitment ed25519.PublicKey
}

type Hash

type Hash []byte

func (Hash) ToString

func (h Hash) ToString() string

type InitializePoolInstructionAccounts

type InitializePoolInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Vault     ed25519.PublicKey
	Mint      ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type InitializePoolInstructionArgs

type InitializePoolInstructionArgs struct {
	Name   string
	Levels uint8
}

type InitializeProofInstructionAccounts

type InitializeProofInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Proof     ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type InitializeProofInstructionArgs

type InitializeProofInstructionArgs struct {
	PoolBump   uint8
	MerkleRoot Hash
	Commitment ed25519.PublicKey
}

type Instruction

type Instruction struct {
	Program  ed25519.PublicKey
	Accounts []AccountMeta
	Data     []byte
}

Instruction represents a transaction instruction.

func NewCloseProofInstruction

func NewCloseProofInstruction(
	accounts *CloseProofInstructionAccounts,
	args *CloseProofInstructionArgs,
) Instruction

func NewUploadProofInstruction

func NewUploadProofInstruction(
	accounts *UploadProofInstructionAccounts,
	args *UploadProofInstructionArgs,
) Instruction

func NewVerifyProofInstruction

func NewVerifyProofInstruction(
	accounts *VerifyProofInstructionAccounts,
	args *VerifyProofInstructionArgs,
) Instruction

func (Instruction) ToLegacyInstruction

func (i Instruction) ToLegacyInstruction() solana.Instruction

type MerkleTree

type MerkleTree struct {
	Levels         uint8
	NextIndex      uint64
	Root           Hash
	FilledSubtrees []Hash
	ZeroValues     []Hash
}

On-chain MerkleTree, which does not include leaves.

func NewMerkleTree

func NewMerkleTree(
	levels uint8,
	nextIndex uint64,
	root Hash,
	filledSubtrees []Hash,
	zeroValues []Hash,
) *MerkleTree

Holds the data for the {@link MerkleTree} and provides de/serialization functionality for that data

func (*MerkleTree) Clone

func (obj *MerkleTree) Clone() *MerkleTree

Clones a {@link MerkleTree} instance.

func (*MerkleTree) Marshal

func (obj *MerkleTree) Marshal() []byte

Serializes the {@link MerkleTree} into a Buffer. @returns the created []byte buffer

func (*MerkleTree) ToString

func (obj *MerkleTree) ToString() string

func (*MerkleTree) Unmarshal

func (obj *MerkleTree) Unmarshal(data []byte) error

Deserializes the {@link MerkleTree} from the provided data Buffer. @returns an error if the deserialize operation was unsuccessful.

type OpenTokenAccountInstructionAccounts

type OpenTokenAccountInstructionAccounts struct {
	Pool            ed25519.PublicKey
	Proof           ed25519.PublicKey
	CommitmentVault ed25519.PublicKey
	Mint            ed25519.PublicKey
	Authority       ed25519.PublicKey
	Payer           ed25519.PublicKey
}

type OpenTokenAccountInstructionArgs

type OpenTokenAccountInstructionArgs struct {
	PoolBump  uint8
	ProofBump uint8
}

type PoolAccount

type PoolAccount struct {
	DataVersion DataVersion

	Authority ed25519.PublicKey
	Mint      ed25519.PublicKey
	Vault     ed25519.PublicKey
	VaultBump uint8
	Name      string

	HistoryList  []Hash
	CurrentIndex uint8

	MerkleTree *MerkleTree
}

Arguments used to create {@link PoolAccount}

func NewPoolAccount

func NewPoolAccount(
	dataVersion DataVersion,
	authority ed25519.PublicKey,
	mint ed25519.PublicKey,
	vault ed25519.PublicKey,
	vaultBump uint8,
	name string,
	historyList []Hash,
	currentIndex uint8,
	merkleTree *MerkleTree,
) *PoolAccount

Holds the data for the {@link PoolAccount} Account and provides de/serialization functionality for that data

func (*PoolAccount) Clone

func (obj *PoolAccount) Clone() *PoolAccount

Clones a {@link PoolAccount} instance.

func (*PoolAccount) Marshal

func (obj *PoolAccount) Marshal() []byte

Serializes the {@link PoolAccount} into a Buffer. @returns the created []byte buffer

func (*PoolAccount) String

func (obj *PoolAccount) String() string

func (*PoolAccount) Unmarshal

func (obj *PoolAccount) Unmarshal(data []byte) error

Deserializes the {@link PoolAccount} from the provided data Buffer. @returns an error if the deserialize operation was unsuccessful.

type ProofAccount

type ProofAccount struct {
	DataVersion DataVersion
	Pool        ed25519.PublicKey
	PoolBump    uint8

	MerkleRoot Hash
	Commitment ed25519.PublicKey
	Verified   bool

	Size uint8
	Data []Hash
}

Arguments used to create {@link ProofAccount}

func NewProofAccount

func NewProofAccount(
	dataVersion DataVersion,
	pool ed25519.PublicKey,
	poolBump uint8,
	merkleRoot Hash,
	commitment ed25519.PublicKey,
	verified bool,
	size uint8,
	data []Hash,
) *ProofAccount

Holds the data for the {@link ProofAccount} Account and provides de/serialization functionality for that data

func (*ProofAccount) Clone

func (obj *ProofAccount) Clone() *ProofAccount

Clones a {@link ProofAccount} instance.

func (*ProofAccount) Marshal

func (obj *ProofAccount) Marshal() []byte

Serializes the {@link ProofAccount} into a Buffer. @returns the created []byte buffer

func (*ProofAccount) ToString

func (obj *ProofAccount) ToString() string

func (*ProofAccount) Unmarshal

func (obj *ProofAccount) Unmarshal(data []byte) error

Deserializes the {@link ProofAccount} from the provided data Buffer. @returns an error if the deserialize operation was unsuccessful.

type SaveRecentRootInstructionAccounts

type SaveRecentRootInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type SaveRecentRootInstructionArgs

type SaveRecentRootInstructionArgs struct {
	PoolBump uint8
}

type SplitterTokenError

type SplitterTokenError uint32
const (
	// Invalid pool state for this instruction
	ErrInvalidPoolState SplitterTokenError = iota + 0x1770

	//Invalid commitment state for this instruction
	ErrInvalidCommitmentState

	//Invalid recent root value
	ErrInvalidRecentRoot

	//Invalid token account
	ErrInvalidVaultAccount

	//Insufficient vault funds
	ErrInsufficientVaultBalance

	//Invalid authority
	ErrInvalidAuthority

	//Invalid vault owner
	ErrInvalidVaultOwner

	//Merkle tree full
	ErrMerkleTreeFull

	//Invalid merkle tree depth
	ErrInvalidMerkleTreeDepth

	//Proof already verified
	ErrProofAlreadyVerified

	//Proof not verified
	ErrProofNotVerified

	//Invalid proof size
	ErrInvalidProofSize

	//Invalid proof
	ErrInvalidProof
)

type TransferWithCommitmentInstructionAccounts

type TransferWithCommitmentInstructionAccounts struct {
	Pool        ed25519.PublicKey
	Vault       ed25519.PublicKey
	Destination ed25519.PublicKey
	Commitment  ed25519.PublicKey
	Authority   ed25519.PublicKey
	Payer       ed25519.PublicKey
}

type TransferWithCommitmentInstructionArgs

type TransferWithCommitmentInstructionArgs struct {
	PoolBump   uint8
	Amount     uint64
	Transcript Hash
	RecentRoot Hash
}

type UploadProofInstructionAccounts

type UploadProofInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Proof     ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type UploadProofInstructionArgs

type UploadProofInstructionArgs struct {
	PoolBump    uint8
	ProofBump   uint8
	CurrentSize uint8
	DataSize    uint8
	Data        []Hash
}

type VerifyProofInstructionAccounts

type VerifyProofInstructionAccounts struct {
	Pool      ed25519.PublicKey
	Proof     ed25519.PublicKey
	Authority ed25519.PublicKey
	Payer     ed25519.PublicKey
}

type VerifyProofInstructionArgs

type VerifyProofInstructionArgs struct {
	PoolBump  uint8
	ProofBump uint8
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL