Documentation ¶
Index ¶
- Constants
- Variables
- func CloseProofInstructionFromBinary(data []byte) (*CloseProofInstructionArgs, *CloseProofInstructionAccounts, error)
- func CloseProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*CloseProofInstructionArgs, *CloseProofInstructionAccounts, error)
- func CloseTokenAccountInstructionFromBinary(data []byte) (*CloseTokenAccountInstructionArgs, *CloseTokenAccountInstructionAccounts, ...)
- func CloseTokenAccountInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*CloseTokenAccountInstructionArgs, *CloseTokenAccountInstructionAccounts, ...)
- func GetCommitmentStateAddress(args *GetCommitmentStateAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetCommitmentVaultAddress(args *GetCommitmentVaultAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetPoolStateAddress(args *GetPoolStateAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetPoolVaultAddress(args *GetPoolVaultAddressArgs) (ed25519.PublicKey, uint8, error)
- func GetProofAddress(args *GetProofAddressArgs) (ed25519.PublicKey, uint8, error)
- func InitializePoolInstructionFromBinary(data []byte) (*InitializePoolInstructionArgs, *InitializePoolInstructionAccounts, error)
- func InitializeProofInstructionFromBinary(data []byte) (*InitializeProofInstructionArgs, *InitializeProofInstructionAccounts, error)
- func InitializeProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*InitializeProofInstructionArgs, *InitializeProofInstructionAccounts, error)
- func OpenTokenAccountInstructionFromBinary(data []byte) (*OpenTokenAccountInstructionArgs, *OpenTokenAccountInstructionAccounts, error)
- func OpenTokenAccountInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*OpenTokenAccountInstructionArgs, *OpenTokenAccountInstructionAccounts, error)
- func SaveRecentRootInstructionFromBinary(data []byte) (*SaveRecentRootInstructionArgs, *SaveRecentRootInstructionAccounts, error)
- func SaveRecentRootInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*SaveRecentRootInstructionArgs, *SaveRecentRootInstructionAccounts, error)
- func TransferWithCommitmentInstructionFromBinary(data []byte) (*TransferWithCommitmentInstructionArgs, ...)
- func TransferWithCommitmentInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*TransferWithCommitmentInstructionArgs, ...)
- func UploadProofInstructionFromBinary(data []byte) (*UploadProofInstructionArgs, *UploadProofInstructionAccounts, error)
- func UploadProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*UploadProofInstructionArgs, *UploadProofInstructionAccounts, error)
- func VerifyProofInstructionFromBinary(data []byte) (*VerifyProofInstructionArgs, *VerifyProofInstructionAccounts, error)
- func VerifyProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*VerifyProofInstructionArgs, *VerifyProofInstructionAccounts, error)
- type AccountMeta
- type CloseProofInstructionAccounts
- type CloseProofInstructionArgs
- type CloseTokenAccountInstructionAccounts
- type CloseTokenAccountInstructionArgs
- type DataVersion
- type GetCommitmentStateAddressArgs
- type GetCommitmentVaultAddressArgs
- type GetPoolStateAddressArgs
- type GetPoolVaultAddressArgs
- type GetProofAddressArgs
- type Hash
- type InitializePoolInstructionAccounts
- type InitializePoolInstructionArgs
- type InitializeProofInstructionAccounts
- type InitializeProofInstructionArgs
- type Instruction
- func NewCloseProofInstruction(accounts *CloseProofInstructionAccounts, args *CloseProofInstructionArgs) Instruction
- func NewCloseTokenAccountInstruction(accounts *CloseTokenAccountInstructionAccounts, ...) Instruction
- func NewInitializePoolInstruction(accounts *InitializePoolInstructionAccounts, ...) Instruction
- func NewInitializeProofInstruction(accounts *InitializeProofInstructionAccounts, ...) Instruction
- func NewOpenTokenAccountInstruction(accounts *OpenTokenAccountInstructionAccounts, ...) Instruction
- func NewSaveRecentRootInstruction(accounts *SaveRecentRootInstructionAccounts, ...) Instruction
- func NewTransferWithCommitmentInstruction(accounts *TransferWithCommitmentInstructionAccounts, ...) Instruction
- func NewUploadProofInstruction(accounts *UploadProofInstructionAccounts, args *UploadProofInstructionArgs) Instruction
- func NewVerifyProofInstruction(accounts *VerifyProofInstructionAccounts, args *VerifyProofInstructionArgs) Instruction
- type MerkleTree
- type OpenTokenAccountInstructionAccounts
- type OpenTokenAccountInstructionArgs
- type PoolAccount
- type ProofAccount
- type SaveRecentRootInstructionAccounts
- type SaveRecentRootInstructionArgs
- type SplitterTokenError
- type TransferWithCommitmentInstructionAccounts
- type TransferWithCommitmentInstructionArgs
- type UploadProofInstructionAccounts
- type UploadProofInstructionArgs
- type VerifyProofInstructionAccounts
- type VerifyProofInstructionArgs
Constants ¶
const ( MaxNameLength = 32 MaxHistory = 32 )
const ( CloseProofInstructionArgsSize = (1 + 1) // proof_bump CloseProofInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32) // rentSysvar CloseProofInstructionSize = (8 + CloseProofInstructionArgsSize + CloseProofInstructionAccountsSize) // accounts )
const ( CloseTokenAccountInstructionArgsSize = (1 + 1 + 1) // vault_bump CloseTokenAccountInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32 + 32 + 32) // systemProgram CloseTokenAccountInstructionSize = (8 + CloseTokenAccountInstructionArgsSize + CloseTokenAccountInstructionAccountsSize) // accounts )
const ( InitializePoolInstructionArgsSize = (MaxNameLength + 1) // Levels InitializePoolInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32 + 32 + 32) // sysvarRent InitializePoolInstructionSize = (8 + InitializePoolInstructionArgsSize + InitializePoolInstructionAccountsSize) // accounts )
const ( InitializeProofInstructionArgsSize = (1 + 32 + 32) // Commitment InitializeProofInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32) // sysvarRent InitializeProofInstructionSize = (8 + InitializeProofInstructionArgsSize + InitializeProofInstructionAccountsSize) // accounts )
const ( OpenTokenAccountInstructionArgsSize = (1 + 1) // ProofBump OpenTokenAccountInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32 + 32 + 32 + 32) // sysvarRent OpenTokenAccountInstructionSize = (8 + OpenTokenAccountInstructionArgsSize + OpenTokenAccountInstructionAccountsSize) // accounts )
const ( SaveRecentRootInstructionArgsSize = 1 // pool_bump SaveRecentRootInstructionAccountsSize = (32 + 32 + 32) // payer SaveRecentRootInstructionSize = (8 + SaveRecentRootInstructionArgsSize + SaveRecentRootInstructionAccountsSize) // accounts )
const ( TransferWithCommitmentInstructionArgsSize = (1 + 8 + 32 + 32) // recent_root TransferWithCommitmentInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32 + 32 + 32) // systemProgram TransferWithCommitmentInstructionSize = (8 + TransferWithCommitmentInstructionArgsSize + TransferWithCommitmentInstructionAccountsSize) // accounts )
const ( UploadProofInstructionArgsSize = (1 + 1 + 1 + 1 + 4) // Data UploadProofInstructionAccountsSize = (32 + 32 + 32 + 32 + 32 + 32 + 32 + 32) // sysvarRent UploadProofInstructionSize = (8 + UploadProofInstructionArgsSize + UploadProofInstructionAccountsSize) // accounts )
const ( VerifyProofInstructionArgsSize = (1 + 1) // proof_bump VerifyProofInstructionAccountsSize = (32 + 32 + 32 + 32) // payer VerifyProofInstructionSize = (8 + VerifyProofInstructionArgsSize + VerifyProofInstructionAccountsSize) // accounts )
const (
// HashSize is the size, in bytes, of SHA256 hashes as used in this package.
HashSize = 32
)
const MerkleTreeSize = (1 + 4 + 4 + 8 + HashSize) // root
The size of the {@link MerkleTree} in bytes for the static portion
const PoolAccountSize = (8 + 1 + 32 + 32 + 32 + 1 + +MaxNameLength + 4 + 1 + 1) // merkletree_levels
const ProofAccountSize = (8 + 1 + 32 + 1 + 32 + 32 + 1 + 1 + 4) // data
Variables ¶
var ( ErrInvalidProgram = errors.New("invalid program id") ErrInvalidAccountData = errors.New("unexpected account data") ErrInvalidInstructionData = errors.New("unexpected instruction data") )
var ( PROGRAM_ADDRESS = mustBase58Decode("spLit2eb13Tz93if6aJM136nUWki5PVUsoEjcUjwpwW") PROGRAM_ID = ed25519.PublicKey(PROGRAM_ADDRESS) )
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")) )
var (
MerkleTreePrefix = []byte("merkletree")
)
Functions ¶
func CloseProofInstructionFromBinary ¶
func CloseProofInstructionFromBinary(data []byte) (*CloseProofInstructionArgs, *CloseProofInstructionAccounts, error)
func CloseProofInstructionFromLegacyInstruction ¶
func CloseProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*CloseProofInstructionArgs, *CloseProofInstructionAccounts, error)
func CloseTokenAccountInstructionFromBinary ¶
func CloseTokenAccountInstructionFromBinary(data []byte) (*CloseTokenAccountInstructionArgs, *CloseTokenAccountInstructionAccounts, error)
func CloseTokenAccountInstructionFromLegacyInstruction ¶
func CloseTokenAccountInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*CloseTokenAccountInstructionArgs, *CloseTokenAccountInstructionAccounts, error)
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)
func InitializePoolInstructionFromBinary ¶
func InitializePoolInstructionFromBinary(data []byte) (*InitializePoolInstructionArgs, *InitializePoolInstructionAccounts, error)
func InitializeProofInstructionFromBinary ¶
func InitializeProofInstructionFromBinary(data []byte) (*InitializeProofInstructionArgs, *InitializeProofInstructionAccounts, error)
func InitializeProofInstructionFromLegacyInstruction ¶
func InitializeProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*InitializeProofInstructionArgs, *InitializeProofInstructionAccounts, error)
func OpenTokenAccountInstructionFromBinary ¶
func OpenTokenAccountInstructionFromBinary(data []byte) (*OpenTokenAccountInstructionArgs, *OpenTokenAccountInstructionAccounts, error)
func OpenTokenAccountInstructionFromLegacyInstruction ¶
func OpenTokenAccountInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*OpenTokenAccountInstructionArgs, *OpenTokenAccountInstructionAccounts, error)
func SaveRecentRootInstructionFromBinary ¶
func SaveRecentRootInstructionFromBinary(data []byte) (*SaveRecentRootInstructionArgs, *SaveRecentRootInstructionAccounts, error)
func SaveRecentRootInstructionFromLegacyInstruction ¶
func SaveRecentRootInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*SaveRecentRootInstructionArgs, *SaveRecentRootInstructionAccounts, error)
func TransferWithCommitmentInstructionFromBinary ¶
func TransferWithCommitmentInstructionFromBinary(data []byte) (*TransferWithCommitmentInstructionArgs, *TransferWithCommitmentInstructionAccounts, error)
func TransferWithCommitmentInstructionFromLegacyInstruction ¶
func TransferWithCommitmentInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*TransferWithCommitmentInstructionArgs, *TransferWithCommitmentInstructionAccounts, error)
func UploadProofInstructionFromBinary ¶
func UploadProofInstructionFromBinary(data []byte) (*UploadProofInstructionArgs, *UploadProofInstructionAccounts, error)
func UploadProofInstructionFromLegacyInstruction ¶
func UploadProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*UploadProofInstructionArgs, *UploadProofInstructionAccounts, error)
func VerifyProofInstructionFromBinary ¶
func VerifyProofInstructionFromBinary(data []byte) (*VerifyProofInstructionArgs, *VerifyProofInstructionAccounts, error)
func VerifyProofInstructionFromLegacyInstruction ¶
func VerifyProofInstructionFromLegacyInstruction(txn solana.Transaction, idx int) (*VerifyProofInstructionArgs, *VerifyProofInstructionAccounts, error)
Types ¶
type AccountMeta ¶
AccountMeta represents the account information required for building transactions.
type DataVersion ¶
type DataVersion uint8
const ( UnknownDataVersion DataVersion = iota DataVersion1 )
type GetPoolStateAddressArgs ¶
type GetPoolVaultAddressArgs ¶
type GetProofAddressArgs ¶
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 NewCloseTokenAccountInstruction ¶
func NewCloseTokenAccountInstruction( accounts *CloseTokenAccountInstructionAccounts, args *CloseTokenAccountInstructionArgs, ) Instruction
func NewInitializePoolInstruction ¶
func NewInitializePoolInstruction( accounts *InitializePoolInstructionAccounts, args *InitializePoolInstructionArgs, ) Instruction
func NewInitializeProofInstruction ¶
func NewInitializeProofInstruction( accounts *InitializeProofInstructionAccounts, args *InitializeProofInstructionArgs, ) Instruction
func NewOpenTokenAccountInstruction ¶
func NewOpenTokenAccountInstruction( accounts *OpenTokenAccountInstructionAccounts, args *OpenTokenAccountInstructionArgs, ) Instruction
func NewSaveRecentRootInstruction ¶
func NewSaveRecentRootInstruction( accounts *SaveRecentRootInstructionAccounts, args *SaveRecentRootInstructionArgs, ) Instruction
func NewTransferWithCommitmentInstruction ¶
func NewTransferWithCommitmentInstruction( accounts *TransferWithCommitmentInstructionAccounts, args *TransferWithCommitmentInstructionArgs, ) 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 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 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 )
Source Files ¶
- accounts_pool.go
- accounts_proof.go
- address.go
- errors.go
- instructions_close_proof.go
- instructions_close_token_account.go
- instructions_initialize_pool.go
- instructions_initialize_proof.go
- instructions_open_token_account.go
- instructions_save_recent_root.go
- instructions_transfer_with_commitment.go
- instructions_update_proof.go
- instructions_verify_proof.go
- legacy.go
- program.go
- types.go
- types_hash.go
- types_merkletree.go
- utils.go