transaction_v2

package
v1.10.20 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 101 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisableSubmitIntentConfigEnvName = envConfigPrefix + "DISABLE_SUBMIT_INTENT"

	DisableBlockchainChecksConfigEnvName = envConfigPrefix + "DISABLE_BLOCKCHAIN_CHECKS"

	SubmitIntentTimeoutConfigEnvName = envConfigPrefix + "SUBMIT_INTENT_TIMEOUT"

	SwapTimeoutConfigEnvName = envConfigPrefix + "SWAP_TIMEOUT"

	SwapPriorityFeeMultiple = envConfigPrefix + "SWAP_PRIORITY_FEE_MULTIPLE"

	ClientReceiveTimeoutConfigEnvName = envConfigPrefix + "CLIENT_RECEIVE_TIMEOUT"

	FeeCollectorTokenPublicKeyConfigEnvName = envConfigPrefix + "FEE_COLLECTOR_TOKEN_PUBLIC_KEY"

	EnableAirdropsConfigEnvName = envConfigPrefix + "ENABLE_AIRDROPS"

	AirdropperOwnerPublicKeyEnvName = envConfigPrefix + "AIRDROPPER_OWNER_PUBLIC_KEY"

	SwapSubsidizerOwnerPublicKeyEnvName = envConfigPrefix + "SWAP_SUBSIDIZER_OWNER_PUBLIC_KEY"

	TreasuryPoolOneKinBucketConfigEnvName             = envConfigPrefix + "TREASURY_POOL_1_KIN_BUCKET"
	TreasuryPoolTenKinBucketConfigEnvName             = envConfigPrefix + "TREASURY_POOL_10_KIN_BUCKET"
	TreasuryPoolHundredKinBucketConfigEnvName         = envConfigPrefix + "TREASURY_POOL_100_KIN_BUCKET"
	TreasuryPoolThousandKinBucketConfigEnvName        = envConfigPrefix + "TREASURY_POOL_1_000_KIN_BUCKET"
	TreasuryPoolTenThosandKinBucketConfigEnvName      = envConfigPrefix + "TREASURY_POOL_10_000_KIN_BUCKET"
	TreasuryPoolHundredThousandKinBucketConfigEnvName = envConfigPrefix + "TREASURY_POOL_100_000_KIN_BUCKET"
	TreasuryPoolMillionKinBucketConfigEnvName         = envConfigPrefix + "TREASURY_POOL_1_000_000_KIN_BUCKET"

	TreasuryPoolRecentRootCacheMaxAgeEnvName = envConfigPrefix + "TREASURY_POOL_RECENT_ROOT_CACHE_MAX_AGE"

	TreasuryPoolStatsRefreshIntervalEnvName = envConfigPrefix + "TREASURY_POOL_STATS_REFRESH_INTERVAL"
)

Variables

View Source
var (
	ErrInvalidAirdropTarget          = errors.New("invalid airdrop target owner account")
	ErrInsufficientAirdropperBalance = errors.New("insufficient airdropper balance")
	ErrIneligibleForAirdrop          = errors.New("user isn't eligible for airdrop")
)
View Source
var (
	ErrTimedOutReceivingRequest = errors.New("timed out receiving request")

	ErrNotPhoneVerified         = newIntentDeniedError("not phone verified")
	ErrTooManyPayments          = newIntentDeniedError("too many payments")
	ErrTooManyNewRelationships  = newIntentDeniedError("too many new relationships")
	ErrTransactionLimitExceeded = newIntentDeniedError("dollar value exceeds limit")
	ErrNotManagedByCode         = newIntentDeniedError("at least one account is no longer managed by code")

	ErrInvalidSignature  = errors.New("invalid signature provided")
	ErrMissingSignature  = errors.New("at least one signature is missing")
	ErrTooManySignatures = errors.New("too many signatures provided")

	ErrInvalidActionToUpgrade = errors.New("attempt to upgrade an action that isn't upgradeable")
	ErrPrivacyUpgradeMissed   = errors.New("opportunity to upgrade the private transaction was missed")
	ErrPrivacyAlreadyUpgraded = errors.New("private transaction has already been upgraded")
	ErrWaitForNextBlock       = errors.New("must wait for next block before attempting privacy upgrade")

	ErrNotImplemented = errors.New("feature not implemented")
)

Functions

func GetNewAirdropIntentId

func GetNewAirdropIntentId(airdropType AirdropType, reference string) string

Consistent intent ID that maps to a 32 byte buffer

func GetOldAirdropIntentId

func GetOldAirdropIntentId(airdropType AirdropType, reference string) string

func NewTransactionServer

func NewTransactionServer(
	data code_data.Provider,
	pusher push_lib.Provider,
	jupiterClient *jupiter.Client,
	messagingClient messaging.InternalMessageClient,
	maxmind *maxminddb.Reader,
	antispamGuard *antispam.Guard,
	configProvider ConfigProvider,
) transactionpb.TransactionServer

Types

type AirdropType

type AirdropType uint8
const (
	AirdropTypeUnknown AirdropType = iota
	AirdropTypeGiveFirstKin
	AirdropTypeGetFirstKin
)

func (AirdropType) String

func (t AirdropType) String() string

type BaseActionHandler

type BaseActionHandler interface {
	// GetServerParameter gets the server parameter for the action within the context
	// of the intent.
	GetServerParameter() *transactionpb.ServerParameter

	// OnSaveToDB is a callback when the action is being saved to the DB
	// within the scope of a DB transaction. Additional supporting DB records
	// (ie. not the action or fulfillment records) relevant to the action should
	// be saved here.
	OnSaveToDB(ctx context.Context) error
}

BaseActionHandler is a base interface for operation-specific action handlers

Note: Action handlers should load all required state on initialization to avoid duplicated work across interface method calls.

type CloseDormantAccountActionHandler

type CloseDormantAccountActionHandler struct {
	// contains filtered or unexported fields
}

func (*CloseDormantAccountActionHandler) GetServerParameter

func (*CloseDormantAccountActionHandler) MakeNewSolanaTransaction

func (h *CloseDormantAccountActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*CloseDormantAccountActionHandler) OnSaveToDB

func (*CloseDormantAccountActionHandler) PopulateMetadata

func (h *CloseDormantAccountActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*CloseDormantAccountActionHandler) RequiresNonce

func (h *CloseDormantAccountActionHandler) RequiresNonce(index int) bool

func (*CloseDormantAccountActionHandler) TransactionCount

func (h *CloseDormantAccountActionHandler) TransactionCount() int

type CloseEmptyAccountActionHandler

type CloseEmptyAccountActionHandler struct {
	// contains filtered or unexported fields
}

func (*CloseEmptyAccountActionHandler) GetServerParameter

func (*CloseEmptyAccountActionHandler) MakeNewSolanaTransaction

func (h *CloseEmptyAccountActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*CloseEmptyAccountActionHandler) OnSaveToDB

func (*CloseEmptyAccountActionHandler) PopulateMetadata

func (h *CloseEmptyAccountActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*CloseEmptyAccountActionHandler) RequiresNonce

func (h *CloseEmptyAccountActionHandler) RequiresNonce(index int) bool

func (*CloseEmptyAccountActionHandler) TransactionCount

func (h *CloseEmptyAccountActionHandler) TransactionCount() int

type ConfigProvider

type ConfigProvider func() *conf

ConfigProvider defines how config values are pulled

func WithEnvConfigs

func WithEnvConfigs() ConfigProvider

WithEnvConfigs returns configuration pulled from environment variables

type CreateActionHandler

type CreateActionHandler interface {
	BaseActionHandler

	// TransactionCount returns the total number of transactions that will be created
	// for the action.
	TransactionCount() int

	// PopulateMetadata populates action metadata into the provided record
	PopulateMetadata(actionRecord *action.Record) error

	// RequiresNonce determines whether a nonce should be acquired for the
	// transaction being created. This should only be false in cases where
	// client signatures are not required and transaction construction can
	// be deferred to scheduling time. The nonce and bh parameters of
	// MakeNewSolanaTransaction will be null.
	RequiresNonce(transactionIndex int) bool

	// MakeNewSolanaTransaction makes a new Solana transaction. Implementations
	// can choose to defer creation until scheduling time. This may be done in
	// cases where the client signature is not required.
	MakeNewSolanaTransaction(
		index int,
		nonce *common.Account,
		bh solana.Blockhash,
	) (*makeSolanaTransactionResult, error)
}

CreateActionHandler is an interface for creating new actions

func NewCloseDormantAccountActionHandler

func NewCloseDormantAccountActionHandler(protoAction *transactionpb.CloseDormantAccountAction) (CreateActionHandler, error)

func NewCloseEmptyAccountActionHandler

func NewCloseEmptyAccountActionHandler(intentType intent.Type, protoAction *transactionpb.CloseEmptyAccountAction) (CreateActionHandler, error)

func NewFeePaymentActionHandler

func NewFeePaymentActionHandler(protoAction *transactionpb.FeePaymentAction, feeCollector *common.Account) (CreateActionHandler, error)

func NewNoPrivacyTransferActionHandler

func NewNoPrivacyTransferActionHandler(protoAction *transactionpb.NoPrivacyTransferAction) (CreateActionHandler, error)

func NewNoPrivacyWithdrawActionHandler

func NewNoPrivacyWithdrawActionHandler(intentRecord *intent.Record, protoAction *transactionpb.NoPrivacyWithdrawAction) (CreateActionHandler, error)

func NewOpenAccountActionHandler

func NewOpenAccountActionHandler(data code_data.Provider, protoAction *transactionpb.OpenAccountAction, protoMetadata *transactionpb.Metadata) (CreateActionHandler, error)

func NewTemporaryPrivacyTransferActionHandler

func NewTemporaryPrivacyTransferActionHandler(
	ctx context.Context,
	conf *conf,
	data code_data.Provider,
	intentRecord *intent.Record,
	untypedAction *transactionpb.Action,
	isExchange bool,
	treasuryPoolSelector func(context.Context, uint64) (string, error),
) (CreateActionHandler, error)

type CreateIntentHandler

type CreateIntentHandler interface {
	// PopulateMetadata adds intent metadata to the provided intent record
	// using the client-provided protobuf variant. No other fields in the
	// intent should be modified.
	PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

	// IsNoop determines whether the intent is a no-op operation. SubmitIntent will
	// simply return OK and stop any further intent processing.
	//
	// Note: This occurs before validation, so if anything appears out-of-order, then
	// the recommendation is to return false and have the verification logic catch the
	// error.
	IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

	// GetAdditionalAccountsToLock gets additional accounts to apply distributed
	// locking on that are specific to an intent.
	//
	// Note: Assumes relevant information is contained in the intent record after
	// calling PopulateMetadata.
	GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

	// AllowCreation determines whether the new intent creation should be allowed.
	AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

	// OnSaveToDB is a callback when the intent is being saved to the DB
	// within the scope of a DB transaction. Additional supporting DB records
	// (ie. not the intent record) relevant to the intent should be saved here.
	OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

	// OnCommittedToDB is a callback when the intent has been committed to the
	// DB. Any instant side-effects should called here, and can be done async
	// in a new goroutine to not affect SubmitIntent latency.
	//
	// Note: Any errors generated here have no effect on rolling back the intent.
	//       This is all best-effort up to this point. Use a worker for things
	//       requiring retries!
	OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error
}

CreateIntentHandler is an interface for handling new intent creations

func NewEstablishRelationshipIntentHandler

func NewEstablishRelationshipIntentHandler(conf *conf, data code_data.Provider, antispamGuard *antispam.Guard) CreateIntentHandler

func NewMigrateToPrivacy2022IntentHandler

func NewMigrateToPrivacy2022IntentHandler(conf *conf, data code_data.Provider) CreateIntentHandler

func NewOpenAccountsIntentHandler

func NewOpenAccountsIntentHandler(conf *conf, data code_data.Provider, antispamGuard *antispam.Guard, maxmind *maxminddb.Reader) CreateIntentHandler

func NewReceivePaymentsPrivatelyIntentHandler

func NewReceivePaymentsPrivatelyIntentHandler(conf *conf, data code_data.Provider, antispamGuard *antispam.Guard, amlGuard *lawenforcement.AntiMoneyLaunderingGuard) CreateIntentHandler

func NewReceivePaymentsPubliclyIntentHandler

func NewReceivePaymentsPubliclyIntentHandler(conf *conf, data code_data.Provider, antispamGuard *antispam.Guard, maxmind *maxminddb.Reader) CreateIntentHandler

func NewSendPrivatePaymentIntentHandler

func NewSendPrivatePaymentIntentHandler(
	conf *conf,
	data code_data.Provider,
	pusher push_lib.Provider,
	antispamGuard *antispam.Guard,
	amlGuard *lawenforcement.AntiMoneyLaunderingGuard,
	maxmind *maxminddb.Reader,
) CreateIntentHandler

func NewSendPublicPaymentIntentHandler

func NewSendPublicPaymentIntentHandler(
	conf *conf,
	data code_data.Provider,
	pusher push_lib.Provider,
	antispamGuard *antispam.Guard,
	maxmind *maxminddb.Reader,
) CreateIntentHandler

type EstablishRelationshipIntentHandler

type EstablishRelationshipIntentHandler struct {
	// contains filtered or unexported fields
}

func (*EstablishRelationshipIntentHandler) AllowCreation

func (h *EstablishRelationshipIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*EstablishRelationshipIntentHandler) GetAdditionalAccountsToLock

func (h *EstablishRelationshipIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*EstablishRelationshipIntentHandler) IsNoop

func (h *EstablishRelationshipIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*EstablishRelationshipIntentHandler) OnCommittedToDB

func (h *EstablishRelationshipIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*EstablishRelationshipIntentHandler) OnSaveToDB

func (h *EstablishRelationshipIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*EstablishRelationshipIntentHandler) PopulateMetadata

func (h *EstablishRelationshipIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type IntentDeniedError

type IntentDeniedError struct {
	// contains filtered or unexported fields
}

func (IntentDeniedError) Error

func (e IntentDeniedError) Error() string

type IntentValidationError

type IntentValidationError struct {
	// contains filtered or unexported fields
}

func (IntentValidationError) Error

func (e IntentValidationError) Error() string

type LocalSimulationResult

type LocalSimulationResult struct {
	SimulationsByAccount map[string]TokenAccountSimulation
}

func LocalSimulation

func LocalSimulation(ctx context.Context, data code_data.Provider, actions []*transactionpb.Action) (*LocalSimulationResult, error)

LocalSimulation simulates actions as if they were executed on the blockchain taking into account cached Code DB state.

Note: This doesn't currently incoporate accounts being closed by us. This is fine because we only close temporary accounts during rotation. We already have good validation for this, so it's fine for now.

func (LocalSimulationResult) CountFeePayments

func (s LocalSimulationResult) CountFeePayments() int

func (LocalSimulationResult) GetClosedAccounts

func (s LocalSimulationResult) GetClosedAccounts() []TokenAccountSimulation

func (LocalSimulationResult) GetFeePayments

func (s LocalSimulationResult) GetFeePayments() []TransferSimulation

func (LocalSimulationResult) GetOpenedAccounts

func (s LocalSimulationResult) GetOpenedAccounts() []TokenAccountSimulation

func (LocalSimulationResult) HasAnyFeePayments

func (s LocalSimulationResult) HasAnyFeePayments() bool

type MigrateToPrivacy2022IntentHandler

type MigrateToPrivacy2022IntentHandler struct {
	// contains filtered or unexported fields
}

func (*MigrateToPrivacy2022IntentHandler) AllowCreation

func (h *MigrateToPrivacy2022IntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

Note: Most validation helper functions (eg. LocalSimulation) assume DataVersion1 timelock accounts and aren't used. That should be fine given there's only one action and validation is trivial. Migration of old timelock accounts is completely scoped to this intent type.

func (*MigrateToPrivacy2022IntentHandler) GetAdditionalAccountsToLock

func (h *MigrateToPrivacy2022IntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*MigrateToPrivacy2022IntentHandler) IsNoop

func (h *MigrateToPrivacy2022IntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*MigrateToPrivacy2022IntentHandler) OnCommittedToDB

func (h *MigrateToPrivacy2022IntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*MigrateToPrivacy2022IntentHandler) OnSaveToDB

func (h *MigrateToPrivacy2022IntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*MigrateToPrivacy2022IntentHandler) PopulateMetadata

func (h *MigrateToPrivacy2022IntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type NoPrivacyTransferActionHandler

type NoPrivacyTransferActionHandler struct {
	// contains filtered or unexported fields
}

func (*NoPrivacyTransferActionHandler) GetServerParameter

func (*NoPrivacyTransferActionHandler) MakeNewSolanaTransaction

func (h *NoPrivacyTransferActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*NoPrivacyTransferActionHandler) OnSaveToDB

func (*NoPrivacyTransferActionHandler) PopulateMetadata

func (h *NoPrivacyTransferActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*NoPrivacyTransferActionHandler) RequiresNonce

func (h *NoPrivacyTransferActionHandler) RequiresNonce(index int) bool

func (*NoPrivacyTransferActionHandler) TransactionCount

func (h *NoPrivacyTransferActionHandler) TransactionCount() int

type NoPrivacyWithdrawActionHandler

type NoPrivacyWithdrawActionHandler struct {
	// contains filtered or unexported fields
}

func (*NoPrivacyWithdrawActionHandler) GetServerParameter

func (*NoPrivacyWithdrawActionHandler) MakeNewSolanaTransaction

func (h *NoPrivacyWithdrawActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*NoPrivacyWithdrawActionHandler) OnSaveToDB

func (*NoPrivacyWithdrawActionHandler) PopulateMetadata

func (h *NoPrivacyWithdrawActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*NoPrivacyWithdrawActionHandler) RequiresNonce

func (h *NoPrivacyWithdrawActionHandler) RequiresNonce(index int) bool

func (*NoPrivacyWithdrawActionHandler) TransactionCount

func (h *NoPrivacyWithdrawActionHandler) TransactionCount() int

type OpenAccountActionHandler

type OpenAccountActionHandler struct {
	// contains filtered or unexported fields
}

func (*OpenAccountActionHandler) GetServerParameter

func (h *OpenAccountActionHandler) GetServerParameter() *transactionpb.ServerParameter

func (*OpenAccountActionHandler) MakeNewSolanaTransaction

func (h *OpenAccountActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*OpenAccountActionHandler) OnSaveToDB

func (h *OpenAccountActionHandler) OnSaveToDB(ctx context.Context) error

func (*OpenAccountActionHandler) PopulateMetadata

func (h *OpenAccountActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*OpenAccountActionHandler) RequiresNonce

func (h *OpenAccountActionHandler) RequiresNonce(index int) bool

func (*OpenAccountActionHandler) TransactionCount

func (h *OpenAccountActionHandler) TransactionCount() int

type OpenAccountsIntentHandler

type OpenAccountsIntentHandler struct {
	// contains filtered or unexported fields
}

func (*OpenAccountsIntentHandler) AllowCreation

func (h *OpenAccountsIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*OpenAccountsIntentHandler) GetAdditionalAccountsToLock

func (h *OpenAccountsIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*OpenAccountsIntentHandler) IsNoop

func (h *OpenAccountsIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*OpenAccountsIntentHandler) OnCommittedToDB

func (h *OpenAccountsIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*OpenAccountsIntentHandler) OnSaveToDB

func (h *OpenAccountsIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*OpenAccountsIntentHandler) PopulateMetadata

func (h *OpenAccountsIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type PermanentPrivacyUpgradeActionHandler

type PermanentPrivacyUpgradeActionHandler struct {
	// contains filtered or unexported fields
}

Handles both of the equivalent client transfer and exchange actions. The server-defined action only defines the private movement of funds between accounts and it's all treated the same by backend processes. The client definitions are merely metadata to tell us more about the reasoning of the movement of funds.

func (*PermanentPrivacyUpgradeActionHandler) GetFulfillmentBeingUpgraded

func (h *PermanentPrivacyUpgradeActionHandler) GetFulfillmentBeingUpgraded() *fulfillment.Record

func (*PermanentPrivacyUpgradeActionHandler) GetServerParameter

func (*PermanentPrivacyUpgradeActionHandler) MakeUpgradedSolanaTransaction

func (h *PermanentPrivacyUpgradeActionHandler) MakeUpgradedSolanaTransaction(
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*PermanentPrivacyUpgradeActionHandler) OnSaveToDB

type ReceivePaymentsPrivatelyIntentHandler

type ReceivePaymentsPrivatelyIntentHandler struct {
	// contains filtered or unexported fields
}

func (*ReceivePaymentsPrivatelyIntentHandler) AllowCreation

func (h *ReceivePaymentsPrivatelyIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, untypedMetadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*ReceivePaymentsPrivatelyIntentHandler) GetAdditionalAccountsToLock

func (h *ReceivePaymentsPrivatelyIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*ReceivePaymentsPrivatelyIntentHandler) IsNoop

func (h *ReceivePaymentsPrivatelyIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*ReceivePaymentsPrivatelyIntentHandler) OnCommittedToDB

func (h *ReceivePaymentsPrivatelyIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*ReceivePaymentsPrivatelyIntentHandler) OnSaveToDB

func (h *ReceivePaymentsPrivatelyIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*ReceivePaymentsPrivatelyIntentHandler) PopulateMetadata

func (h *ReceivePaymentsPrivatelyIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type ReceivePaymentsPubliclyIntentHandler

type ReceivePaymentsPubliclyIntentHandler struct {
	// contains filtered or unexported fields
}

func (*ReceivePaymentsPubliclyIntentHandler) AllowCreation

func (h *ReceivePaymentsPubliclyIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, untypedMetadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*ReceivePaymentsPubliclyIntentHandler) GetAdditionalAccountsToLock

func (h *ReceivePaymentsPubliclyIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*ReceivePaymentsPubliclyIntentHandler) IsNoop

func (h *ReceivePaymentsPubliclyIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*ReceivePaymentsPubliclyIntentHandler) OnCommittedToDB

func (h *ReceivePaymentsPubliclyIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*ReceivePaymentsPubliclyIntentHandler) OnSaveToDB

func (h *ReceivePaymentsPubliclyIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*ReceivePaymentsPubliclyIntentHandler) PopulateMetadata

func (h *ReceivePaymentsPubliclyIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type SendPrivatePaymentIntentHandler

type SendPrivatePaymentIntentHandler struct {
	// contains filtered or unexported fields
}

func (*SendPrivatePaymentIntentHandler) AllowCreation

func (h *SendPrivatePaymentIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, untypedMetadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*SendPrivatePaymentIntentHandler) GetAdditionalAccountsToLock

func (h *SendPrivatePaymentIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*SendPrivatePaymentIntentHandler) IsNoop

func (h *SendPrivatePaymentIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*SendPrivatePaymentIntentHandler) OnCommittedToDB

func (h *SendPrivatePaymentIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*SendPrivatePaymentIntentHandler) OnSaveToDB

func (h *SendPrivatePaymentIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*SendPrivatePaymentIntentHandler) PopulateMetadata

func (h *SendPrivatePaymentIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type SendPublicPaymentIntentHandler

type SendPublicPaymentIntentHandler struct {
	// contains filtered or unexported fields
}

func (*SendPublicPaymentIntentHandler) AllowCreation

func (h *SendPublicPaymentIntentHandler) AllowCreation(ctx context.Context, intentRecord *intent.Record, untypedMetadata *transactionpb.Metadata, actions []*transactionpb.Action, deviceToken *string) error

func (*SendPublicPaymentIntentHandler) GetAdditionalAccountsToLock

func (h *SendPublicPaymentIntentHandler) GetAdditionalAccountsToLock(ctx context.Context, intentRecord *intent.Record) (*lockableAccounts, error)

func (*SendPublicPaymentIntentHandler) IsNoop

func (h *SendPublicPaymentIntentHandler) IsNoop(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) (bool, error)

func (*SendPublicPaymentIntentHandler) OnCommittedToDB

func (h *SendPublicPaymentIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error

func (*SendPublicPaymentIntentHandler) OnSaveToDB

func (h *SendPublicPaymentIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error

func (*SendPublicPaymentIntentHandler) PopulateMetadata

func (h *SendPublicPaymentIntentHandler) PopulateMetadata(ctx context.Context, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata) error

type StaleStateError

type StaleStateError struct {
	// contains filtered or unexported fields
}

func (StaleStateError) Error

func (e StaleStateError) Error() string

type SwapDeniedError added in v1.3.0

type SwapDeniedError struct {
	// contains filtered or unexported fields
}

func (SwapDeniedError) Error added in v1.3.0

func (e SwapDeniedError) Error() string

type SwapValidationError added in v1.3.0

type SwapValidationError struct {
	// contains filtered or unexported fields
}

func (SwapValidationError) Error added in v1.3.0

func (e SwapValidationError) Error() string

type TemporaryPrivacyTransferActionHandler

type TemporaryPrivacyTransferActionHandler struct {
	// contains filtered or unexported fields
}

Handles both of the equivalent client transfer and exchange actions. The server-defined action only defines the private movement of funds between accounts and it's all treated the same by backend processes. The client definitions are merely metadata to tell us more about the reasoning of the movement of funds.

func (*TemporaryPrivacyTransferActionHandler) GetServerParameter

func (*TemporaryPrivacyTransferActionHandler) MakeNewSolanaTransaction

func (h *TemporaryPrivacyTransferActionHandler) MakeNewSolanaTransaction(
	index int,
	nonce *common.Account,
	bh solana.Blockhash,
) (*makeSolanaTransactionResult, error)

func (*TemporaryPrivacyTransferActionHandler) OnSaveToDB

func (*TemporaryPrivacyTransferActionHandler) PopulateMetadata

func (h *TemporaryPrivacyTransferActionHandler) PopulateMetadata(actionRecord *action.Record) error

func (*TemporaryPrivacyTransferActionHandler) RequiresNonce

func (h *TemporaryPrivacyTransferActionHandler) RequiresNonce(index int) bool

func (*TemporaryPrivacyTransferActionHandler) TransactionCount

func (h *TemporaryPrivacyTransferActionHandler) TransactionCount() int

type TokenAccountSimulation

type TokenAccountSimulation struct {
	TokenAccount *common.Account

	Transfers []TransferSimulation

	Opened     bool
	OpenAction *transactionpb.Action

	// todo: We need to handle CloseDormantAccount actions better. They're closed later,
	//       but there's no indication here in simulation that we could close it at our
	//       discretion.
	Closed      bool
	CloseAction *transactionpb.Action
}

func (TokenAccountSimulation) CountIncomingTransfers

func (s TokenAccountSimulation) CountIncomingTransfers() int

func (TokenAccountSimulation) CountOutgoingTransfers

func (s TokenAccountSimulation) CountOutgoingTransfers() int

func (TokenAccountSimulation) CountPrivateTransfers

func (s TokenAccountSimulation) CountPrivateTransfers() int

func (TokenAccountSimulation) CountPublicTransfers

func (s TokenAccountSimulation) CountPublicTransfers() int

func (TokenAccountSimulation) CountWithdrawals

func (s TokenAccountSimulation) CountWithdrawals() int

func (TokenAccountSimulation) EnforceBalances

func (s TokenAccountSimulation) EnforceBalances(ctx context.Context, data code_data.Provider, currentBalance uint64) error

func (TokenAccountSimulation) GetDeltaQuarks

func (s TokenAccountSimulation) GetDeltaQuarks() int64

func (TokenAccountSimulation) GetIncomingTransfers

func (s TokenAccountSimulation) GetIncomingTransfers() []TransferSimulation

func (TokenAccountSimulation) GetOutgoingTransfers

func (s TokenAccountSimulation) GetOutgoingTransfers() []TransferSimulation

func (TokenAccountSimulation) GetPrivateTransfers

func (s TokenAccountSimulation) GetPrivateTransfers() []TransferSimulation

func (TokenAccountSimulation) GetPublicTransfers

func (s TokenAccountSimulation) GetPublicTransfers() []TransferSimulation

func (TokenAccountSimulation) GetWithdraws

func (s TokenAccountSimulation) GetWithdraws() []TransferSimulation

func (TokenAccountSimulation) HasAnyPrivateTransfers

func (s TokenAccountSimulation) HasAnyPrivateTransfers() bool

func (TokenAccountSimulation) HasAnyPublicTransfers

func (s TokenAccountSimulation) HasAnyPublicTransfers() bool

func (TokenAccountSimulation) HasAnyWithdraws

func (s TokenAccountSimulation) HasAnyWithdraws() bool

func (TokenAccountSimulation) HasIncomingTransfer

func (s TokenAccountSimulation) HasIncomingTransfer() bool

func (TokenAccountSimulation) HasOutgoingTransfer

func (s TokenAccountSimulation) HasOutgoingTransfer() bool

func (TokenAccountSimulation) RequiresBalanceCheck

func (s TokenAccountSimulation) RequiresBalanceCheck() bool

func (TokenAccountSimulation) RequiresBalanceFetch

func (s TokenAccountSimulation) RequiresBalanceFetch() bool

type TransferSimulation

type TransferSimulation struct {
	Action      *transactionpb.Action
	IsPrivate   bool
	IsWithdraw  bool
	IsFee       bool
	DeltaQuarks int64
}

todo: Make it easier to extract accounts from a TransferSimulation (see some fee payment validation logic)

type UpdateIntentHandler

type UpdateIntentHandler interface {
	// AllowUpdate determines whether an intent update should be allowed.
	AllowUpdate(ctx context.Context, existingIntent *intent.Record, metdata *transactionpb.Metadata, actions []*transactionpb.Action) error
}

UpdateIntentHandler is an interface for handling updates to an existing intent

func NewUpgradePrivacyIntentHandler

func NewUpgradePrivacyIntentHandler(conf *conf, data code_data.Provider) UpdateIntentHandler

type UpgradeActionHandler

type UpgradeActionHandler interface {
	BaseActionHandler

	// GetFulfillmentBeingUpgraded gets the original fulfillment that's being
	// upgraded.
	GetFulfillmentBeingUpgraded() *fulfillment.Record

	// MakeUpgradedSolanaTransaction makes an upgraded Solana transaction
	MakeUpgradedSolanaTransaction(
		nonce *common.Account,
		bh solana.Blockhash,
	) (*makeSolanaTransactionResult, error)
}

UpgradeActionHandler is an interface for upgrading existing actions. It's assumed we'll only be upgrading a single fulfillment.

func NewPermanentPrivacyUpgradeActionHandler

func NewPermanentPrivacyUpgradeActionHandler(
	ctx context.Context,
	data code_data.Provider,
	intentRecord *intent.Record,
	protoAction *transactionpb.PermanentPrivacyUpgradeAction,
	cachedUpgradeTarget *privacyUpgradeCandidate,
) (UpgradeActionHandler, error)

type UpgradePrivacyIntentHandler

type UpgradePrivacyIntentHandler struct {
	// contains filtered or unexported fields
}

func (*UpgradePrivacyIntentHandler) AllowUpdate

func (h *UpgradePrivacyIntentHandler) AllowUpdate(ctx context.Context, existingIntent *intent.Record, untypedMetadata *transactionpb.Metadata, actions []*transactionpb.Action) error

func (*UpgradePrivacyIntentHandler) GetCachedUpgradeTarget

func (h *UpgradePrivacyIntentHandler) GetCachedUpgradeTarget(protoAction *transactionpb.PermanentPrivacyUpgradeAction) (*privacyUpgradeCandidate, bool)

Jump to

Keyboard shortcuts

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