timelock_token

package
v1.10.13 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivateInstructionArgsSize = (1 +
		8) // UnlockDuration

	ActivateInstructionAccountsSize = (32 +
		32 +
		32) // payer

	ActivateInstructionSize = (8 +
		ActivateInstructionArgsSize +
		ActivateInstructionAccountsSize) // accounts
)
View Source
const (
	BurnDustWithAuthorityInstructionArgsSize = (1 +
		8) // max_amount

	BurnDustWithAuthorityInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	BurnDustWithAuthorityInstructionSize = (8 +
		BurnDustWithAuthorityInstructionArgsSize +
		BurnDustWithAuthorityInstructionAccountsSize) // accounts
)
View Source
const (
	CancelLockTimeoutInstructionArgsSize = (1) // TimelockBump

	CancelLockTimeoutInstructionAccountsSize = (32 +
		32 +
		32 +
		32) // systemProgram

	CancelLockTimeoutInstructionSize = (8 +
		CancelLockTimeoutInstructionArgsSize +
		CancelLockTimeoutInstructionAccountsSize) // accounts
)
View Source
const (
	CloseAccountsInstructionArgsSize = (1) // TimelockBump

	CloseAccountsInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	CloseAccountsInstructionSize = (8 +
		CloseAccountsInstructionArgsSize +
		CloseAccountsInstructionAccountsSize) // accounts
)
View Source
const (
	DeactivateInstructionArgsSize = (1) // TimelockBump

	DeactivateInstructionAccountsSize = (32 +
		32 +
		32) // payer

	DeactivateInstructionSize = (8 +
		DeactivateInstructionArgsSize +
		DeactivateInstructionAccountsSize) // accounts
)
View Source
const (
	InitializeInstructionArgsSize = (1) // numDaysLocked

	InitializeInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	InitializeInstructionSize = (8 +
		InitializeInstructionArgsSize +
		InitializeInstructionAccountsSize) // accounts
)
View Source
const (
	RevokeLockWithAuthorityInstructionArgsSize = (1) // TimelockBump

	RevokeLockWithAuthorityInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	RevokeLockWithAuthorityInstructionSize = (8 +
		RevokeLockWithAuthorityInstructionArgsSize +
		RevokeLockWithAuthorityInstructionAccountsSize) // accounts
)
View Source
const (
	RevokeLockWithTimeoutInstructionArgsSize = (1) // TimelockBump

	RevokeLockWithTimeoutInstructionAccountsSize = (32 +
		32 +
		32 +
		32) // payer

	RevokeLockWithTimeoutInstructionSize = (8 +
		RevokeLockWithTimeoutInstructionArgsSize +
		RevokeLockWithTimeoutInstructionAccountsSize) // accounts
)
View Source
const (
	TransferWithAuthorityInstructionArgsSize = (1 +
		8) // amount

	TransferWithAuthorityInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	TransferWithAuthorityInstructionSize = (8 +
		TransferWithAuthorityInstructionArgsSize +
		TransferWithAuthorityInstructionAccountsSize) // accounts
)
View Source
const (
	WithdrawInstructionArgsSize = (1) // TimelockBump

	WithdrawInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	WithdrawInstructionSize = (8 +
		WithdrawInstructionArgsSize +
		WithdrawInstructionAccountsSize) // accounts
)
View Source
const (
	// Need to be very careful changing this value, as it's used in the state
	// address PDA.
	DefaultNumDaysLocked = uint8(21)
)
View Source
const TimelockAccountSize = (8 +
	1 +
	32 +
	32 +
	32 +
	32 +
	1 +
	1 +
	32 +
	9 +

	1) // num_days_locked

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("time2Z2SCnn3qYg3ULKVtdkh8YmZ5jFdKicnA1W2YnJ")
	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"))
)

Functions

func ActivateInstructionFromBinary

func ActivateInstructionFromBinary(data []byte) (*ActivateInstructionArgs, *ActivateInstructionAccounts, error)

func GetStateAddress

func GetStateAddress(args *GetStateAddressArgs) (ed25519.PublicKey, uint8, error)

func GetVaultAddress

func GetVaultAddress(args *GetVaultAddressArgs) (ed25519.PublicKey, uint8, error)

func WithdrawInstructionFromBinary

func WithdrawInstructionFromBinary(data []byte) (*WithdrawInstructionArgs, *WithdrawInstructionAccounts, error)

Types

type AccountMeta

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

AccountMeta represents the account information required for building transactions.

type ActivateInstructionAccounts

type ActivateInstructionAccounts struct {
	Timelock   ed25519.PublicKey
	VaultOwner ed25519.PublicKey
	Payer      ed25519.PublicKey
}

type ActivateInstructionArgs

type ActivateInstructionArgs struct {
	TimelockBump   uint8
	UnlockDuration uint64
}

type BurnDustWithAuthorityInstructionAccounts

type BurnDustWithAuthorityInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Mint          ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type BurnDustWithAuthorityInstructionArgs

type BurnDustWithAuthorityInstructionArgs struct {
	TimelockBump uint8
	MaxAmount    uint64
}

type CancelLockTimeoutInstructionAccounts

type CancelLockTimeoutInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type CancelLockTimeoutInstructionArgs

type CancelLockTimeoutInstructionArgs struct {
	TimelockBump uint8
}

type CloseAccountsInstructionAccounts

type CloseAccountsInstructionAccounts struct {
	Timelock       ed25519.PublicKey
	Vault          ed25519.PublicKey
	CloseAuthority ed25519.PublicKey
	Payer          ed25519.PublicKey
}

type CloseAccountsInstructionArgs

type CloseAccountsInstructionArgs struct {
	TimelockBump uint8
}

type DeactivateInstructionAccounts

type DeactivateInstructionAccounts struct {
	Timelock   ed25519.PublicKey
	VaultOwner ed25519.PublicKey
	Payer      ed25519.PublicKey
}

type DeactivateInstructionArgs

type DeactivateInstructionArgs struct {
	TimelockBump uint8
}

type GetStateAddressArgs

type GetStateAddressArgs struct {
	Mint          ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	NumDaysLocked uint8
}

type GetVaultAddressArgs

type GetVaultAddressArgs struct {
	State       ed25519.PublicKey
	DataVersion TimelockDataVersion
}

type InitializeInstructionAccounts

type InitializeInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	Mint          ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type InitializeInstructionArgs

type InitializeInstructionArgs struct {
	NumDaysLocked uint8
}

type Instruction

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

Instruction represents a transaction instruction.

func NewActivateInstruction

func NewActivateInstruction(
	accounts *ActivateInstructionAccounts,
	args *ActivateInstructionArgs,
) Instruction

func NewDeactivateInstruction

func NewDeactivateInstruction(
	accounts *DeactivateInstructionAccounts,
	args *DeactivateInstructionArgs,
) Instruction

func NewInitializeInstruction

func NewInitializeInstruction(
	accounts *InitializeInstructionAccounts,
	args *InitializeInstructionArgs,
) Instruction

func NewWithdrawInstruction

func NewWithdrawInstruction(
	accounts *WithdrawInstructionAccounts,
	args *WithdrawInstructionArgs,
) Instruction

func (Instruction) ToLegacyInstruction

func (i Instruction) ToLegacyInstruction() solana.Instruction

type RevokeLockWithAuthorityInstructionAccounts

type RevokeLockWithAuthorityInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type RevokeLockWithAuthorityInstructionArgs

type RevokeLockWithAuthorityInstructionArgs struct {
	TimelockBump uint8
}

type RevokeLockWithTimeoutInstructionAccounts

type RevokeLockWithTimeoutInstructionAccounts struct {
	Timelock   ed25519.PublicKey
	Vault      ed25519.PublicKey
	VaultOwner ed25519.PublicKey
	Payer      ed25519.PublicKey
}

type RevokeLockWithTimeoutInstructionArgs

type RevokeLockWithTimeoutInstructionArgs struct {
	TimelockBump uint8
}

type TimeLockTokenError

type TimeLockTokenError uint32
const (
	// Invalid time-lock state for this instruction
	ErrInvalidTimeLockState TimeLockTokenError = iota + 0x1770

	// Invalid time-lock duration provided
	ErrInvalidTimeLockDuration

	// Invalid vault account
	ErrInvalidVaultAccount

	// The time-lock period has not yet been reached
	ErrInsufficientTimeElapsed

	// Insufficient vault funds
	ErrInsufficientVaultBalance

	// Invalid time authority
	ErrInvalidTimeAuthority

	// Invalid vault owner
	ErrInvalidVaultOwner

	// Invalid close authority
	ErrInvalidCloseAuthority

	// Invalid token balance. Token balance must be zero.
	ErrNonZeroTokenBalance

	// Invalid dust burn
	ErrInvalidDustBurn

	// Invalid token mint
	ErrInvalidTokenMint
)

type TimelockAccount

type TimelockAccount struct {
	DataVersion    TimelockDataVersion
	TimeAuthority  ed25519.PublicKey
	CloseAuthority ed25519.PublicKey
	Mint           ed25519.PublicKey
	Vault          ed25519.PublicKey
	VaultBump      uint8
	VaultState     TimelockState
	VaultOwner     ed25519.PublicKey
	UnlockAt       *uint64 // optional
	NumDaysLocked  uint8
}

Arguments used to create {@link TimelockAccount}

func NewTimeLockAccount

func NewTimeLockAccount(
	dataVersion TimelockDataVersion,
	timeAuthority ed25519.PublicKey,
	closeAuthority ed25519.PublicKey,
	mint ed25519.PublicKey,
	vault ed25519.PublicKey,
	vaultBump uint8,
	vaultState TimelockState,
	vaultOwner ed25519.PublicKey,
	unlockAt *uint64,
	numDaysLocked uint8,
) *TimelockAccount

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

func (*TimelockAccount) Clone

func (obj *TimelockAccount) Clone() *TimelockAccount

Clones a {@link TimeLockAccount} instance.

func (*TimelockAccount) Marshal

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

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

func (*TimelockAccount) ToString

func (obj *TimelockAccount) ToString() string

func (*TimelockAccount) Unmarshal

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

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

type TimelockDataVersion

type TimelockDataVersion uint8
const (
	UnknownDataVersion TimelockDataVersion = iota
	DataVersionLegacy
	DataVersionClosed
	DataVersion1
)

type TimelockState

type TimelockState uint8
const (
	StateUnknown TimelockState = iota
	StateUnlocked
	StateWaitingForTimeout
	StateLocked
	StateClosed
)

func (TimelockState) String

func (s TimelockState) String() string

type TransferWithAuthorityInstructionAccounts

type TransferWithAuthorityInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Destination   ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type TransferWithAuthorityInstructionArgs

type TransferWithAuthorityInstructionArgs struct {
	TimelockBump uint8
	Amount       uint64
}

type WithdrawInstructionAccounts

type WithdrawInstructionAccounts struct {
	Timelock    ed25519.PublicKey
	Vault       ed25519.PublicKey
	VaultOwner  ed25519.PublicKey
	Destination ed25519.PublicKey
	Payer       ed25519.PublicKey
}

type WithdrawInstructionArgs

type WithdrawInstructionArgs struct {
	TimelockBump uint8
}

Jump to

Keyboard shortcuts

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