Documentation ¶
Index ¶
- Variables
- func EnforceMinimumSubsidizerBalance(ctx context.Context, data code_data.Provider) error
- func EstimateUsedSubsidizerBalance(ctx context.Context, data code_data.Provider) (uint64, error)
- func GetCurrentSubsidizerBalance(ctx context.Context, data code_data.Provider) (uint64, error)
- func GetLatestCodeTimelockAccountRecordsForOwner(ctx context.Context, data code_data.Provider, owner *Account) (map[commonpb.AccountType][]*AccountRecords, error)
- func GetLatestTokenAccountRecordsForOwner(ctx context.Context, data code_data.Provider, owner *Account) (map[commonpb.AccountType][]*AccountRecords, error)
- func InjectTestSubsidizer(ctx context.Context, data code_data.Provider, testAccount *Account) error
- func IsManagedByCode(ctx context.Context, timelockRecord *timelock.Record) bool
- func LoadProductionSubsidizer(ctx context.Context, data code_data.Provider) error
- func ValidateExternalKinTokenAccount(ctx context.Context, data code_data.Provider, tokenAccount *Account) (bool, string, error)
- type Account
- func GetSubsidizer() *Account
- func NewAccountFromPrivateKey(privateKey *Key) (*Account, error)
- func NewAccountFromPrivateKeyBytes(publicKey []byte) (*Account, error)
- func NewAccountFromPrivateKeyString(privateKey string) (*Account, error)
- func NewAccountFromProto(proto *commonpb.SolanaAccountId) (*Account, error)
- func NewAccountFromPublicKey(publicKey *Key) (*Account, error)
- func NewAccountFromPublicKeyBytes(publicKey []byte) (*Account, error)
- func NewAccountFromPublicKeyString(publicKey string) (*Account, error)
- func NewRandomAccount() (*Account, error)
- func (a *Account) GetTimelockAccounts(dataVersion timelock_token_v1.TimelockDataVersion, mint *Account) (*TimelockAccounts, error)
- func (a *Account) IsManagedByCode(ctx context.Context, data code_data.Provider) (bool, error)
- func (a *Account) PrivateKey() *Key
- func (a *Account) PublicKey() *Key
- func (a *Account) Sign(message []byte) ([]byte, error)
- func (a *Account) String() string
- func (a *Account) ToAssociatedTokenAccount(mint *Account) (*Account, error)
- func (a *Account) ToProto() *commonpb.SolanaAccountId
- func (a *Account) ToTimelockVault(dataVersion timelock_token_v1.TimelockDataVersion, mint *Account) (*Account, error)
- func (a *Account) Validate() error
- type AccountRecords
- type Key
- type OwnerManagementState
- type OwnerMetadata
- type OwnerType
- type TimelockAccounts
- func (a *TimelockAccounts) GetBurnDustWithAuthorityInstruction(maxQuarks uint64) (solana.Instruction, error)
- func (a *TimelockAccounts) GetCloseAccountsInstruction() (solana.Instruction, error)
- func (a *TimelockAccounts) GetDBRecord(ctx context.Context, data code_data.Provider) (*timelock.Record, error)
- func (a *TimelockAccounts) GetDeactivateInstruction() (solana.Instruction, error)
- func (a *TimelockAccounts) GetInitializeInstruction() (solana.Instruction, error)
- func (a *TimelockAccounts) GetRevokeLockWithAuthorityInstruction() (solana.Instruction, error)
- func (a *TimelockAccounts) GetTransferWithAuthorityInstruction(destination *Account, quarks uint64) (solana.Instruction, error)
- func (a *TimelockAccounts) GetWithdrawInstruction(destination *Account) (solana.Instruction, error)
- func (a *TimelockAccounts) ToDBRecord() *timelock.Record
Constants ¶
This section is empty.
Variables ¶
var (
KinMintAccount, _ = NewAccountFromPublicKeyBytes(kin.TokenMint)
UsdcMintAccount, _ = NewAccountFromPublicKeyBytes(usdc.TokenMint)
)
var (
ErrNoPrivacyMigration2022 = errors.New("no privacy migration 2022 for owner")
)
var (
ErrOwnerNotFound = errors.New("owner account not found")
)
var (
ErrSubsidizerRequiresFunding = errors.New("subsidizer requires funding")
)
Functions ¶
func EnforceMinimumSubsidizerBalance ¶
EnforceMinimumSubsidizerBalance returns ErrSubsidizerRequiresFunding if the subsidizer's estimated available balance breaks a given threshold.
func EstimateUsedSubsidizerBalance ¶
EstimateUsedSubsidizerBalance estimates the number of lamports that will be used by in flight fulfillments.
todo: This assumes fees are constant, which might not be the case in the future.
func GetCurrentSubsidizerBalance ¶
GetCurrentSubsidizerBalance returns the subsidizer's current balance in lamports.
func GetLatestCodeTimelockAccountRecordsForOwner ¶ added in v1.3.0
func GetLatestCodeTimelockAccountRecordsForOwner(ctx context.Context, data code_data.Provider, owner *Account) (map[commonpb.AccountType][]*AccountRecords, error)
GetLatestCodeTimelockAccountRecordsForOwner is a utility wrapper over GetLatestTokenAccountRecordsForOwner that filters for Code Timelock accounts.
func GetLatestTokenAccountRecordsForOwner ¶
func GetLatestTokenAccountRecordsForOwner(ctx context.Context, data code_data.Provider, owner *Account) (map[commonpb.AccountType][]*AccountRecords, error)
GetLatestTokenAccountRecordsForOwner gets DB records for the latest set of token accounts for an owner account.
func InjectTestSubsidizer ¶
InjectTestSubsidizer injects a provided account as a subsidizer for testing purposes. Do not call this in a production setting.
func IsManagedByCode ¶
func LoadProductionSubsidizer ¶
LoadProductionSubsidizer loads the production subsidizer account by it's public key over the provided data provider. This should be done exactly once on app launch. Use GetSubsidizer to get the Account struct.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func GetSubsidizer ¶
func GetSubsidizer() *Account
GetSubsidizer gets the subsidizer account, as initially loaded in LoadSubsidizer
func NewAccountFromProto ¶
func NewAccountFromProto(proto *commonpb.SolanaAccountId) (*Account, error)
func NewAccountFromPublicKey ¶
func NewRandomAccount ¶
func (*Account) GetTimelockAccounts ¶
func (a *Account) GetTimelockAccounts(dataVersion timelock_token_v1.TimelockDataVersion, mint *Account) (*TimelockAccounts, error)
func (*Account) IsManagedByCode ¶
func (*Account) PrivateKey ¶
func (*Account) ToAssociatedTokenAccount ¶
func (*Account) ToProto ¶
func (a *Account) ToProto() *commonpb.SolanaAccountId
func (*Account) ToTimelockVault ¶
func (a *Account) ToTimelockVault(dataVersion timelock_token_v1.TimelockDataVersion, mint *Account) (*Account, error)
type AccountRecords ¶
func GetLegacyPrimary2022AccountRecordsIfNotMigrated ¶
func GetLegacyPrimary2022AccountRecordsIfNotMigrated(ctx context.Context, data code_data.Provider, owner *Account) (*AccountRecords, error)
GetLegacyPrimary2022AccountRecordsIfNotMigrated gets a faked AccountRecords for the LEGACY_PRIMARY_2022 account associated with the provided owner. If the account doesn't exist, or was migrated, then ErrNoPrivacyMigration2022 is returned.
Note: Legacy Timelock accounts were always Kin accounts
todo: Needs tests here, but most already exist in account service
func (*AccountRecords) IsManagedByCode ¶
func (r *AccountRecords) IsManagedByCode(ctx context.Context) bool
func (*AccountRecords) IsTimelock ¶ added in v1.3.0
func (r *AccountRecords) IsTimelock() bool
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func NewKeyFromBytes ¶
func NewKeyFromString ¶
func NewRandomKey ¶
type OwnerManagementState ¶
type OwnerManagementState uint8
const ( OwnerManagementStateUnknown OwnerManagementState = iota OwnerManagementStateCodeAccount OwnerManagementStateNotFound OwnerManagementStateUnlocked )
func GetOwnerManagementState ¶
func GetOwnerManagementState(ctx context.Context, data code_data.Provider, owner *Account) (OwnerManagementState, error)
GetOwnerManagementState returns an aggregate management state for an owner account based on the set of sub accounts it owns.
todo: Needs tests here, but most already exist in account service
func (OwnerManagementState) String ¶
func (t OwnerManagementState) String() string
type OwnerMetadata ¶
type OwnerMetadata struct { Type OwnerType Account *Account VerificationRecord *phone.Verification State OwnerManagementState }
func GetOwnerMetadata ¶
func GetOwnerMetadata(ctx context.Context, data code_data.Provider, owner *Account) (*OwnerMetadata, error)
GetOwnerMetadata gets metadata about an owner account
type TimelockAccounts ¶
type TimelockAccounts struct { DataVersion timelock_token_v1.TimelockDataVersion State *Account StateBump uint8 Vault *Account VaultBump uint8 VaultOwner *Account TimeAuthority *Account CloseAuthority *Account Mint *Account }
func (*TimelockAccounts) GetBurnDustWithAuthorityInstruction ¶
func (a *TimelockAccounts) GetBurnDustWithAuthorityInstruction(maxQuarks uint64) (solana.Instruction, error)
GetBurnDustWithAuthorityInstruction gets a BurnDustWithAuthority instruction for a timelock account
func (*TimelockAccounts) GetCloseAccountsInstruction ¶
func (a *TimelockAccounts) GetCloseAccountsInstruction() (solana.Instruction, error)
GetCloseAccountsInstruction gets a CloseAccounts instruction for a timelock account
func (*TimelockAccounts) GetDBRecord ¶
func (a *TimelockAccounts) GetDBRecord(ctx context.Context, data code_data.Provider) (*timelock.Record, error)
GetDBRecord fetches the equivalent timelock.Record for a TimelockAccounts from the DB
func (*TimelockAccounts) GetDeactivateInstruction ¶
func (a *TimelockAccounts) GetDeactivateInstruction() (solana.Instruction, error)
GetDeactivateInstruction gets a Deactivate instruction for a timelock account
func (*TimelockAccounts) GetInitializeInstruction ¶
func (a *TimelockAccounts) GetInitializeInstruction() (solana.Instruction, error)
GetInitializeInstruction gets an Initialize instruction for a timelock account
func (*TimelockAccounts) GetRevokeLockWithAuthorityInstruction ¶
func (a *TimelockAccounts) GetRevokeLockWithAuthorityInstruction() (solana.Instruction, error)
GetRevokeLockWithAuthorityInstruction gets a RevokeLockWithAuthority instruction for a timelock account
func (*TimelockAccounts) GetTransferWithAuthorityInstruction ¶
func (a *TimelockAccounts) GetTransferWithAuthorityInstruction(destination *Account, quarks uint64) (solana.Instruction, error)
GetTransferWithAuthorityInstruction gets a TransferWithAuthority instruction for a timelock account
func (*TimelockAccounts) GetWithdrawInstruction ¶
func (a *TimelockAccounts) GetWithdrawInstruction(destination *Account) (solana.Instruction, error)
GetWithdrawInstruction gets a Withdraw instruction for a timelock account
func (*TimelockAccounts) ToDBRecord ¶
func (a *TimelockAccounts) ToDBRecord() *timelock.Record
ToDBRecord transforms the TimelockAccounts struct to a default timelock.Record