token_transfer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TransferEvent = "transfer"
	MintEvent     = "mint"
	BurnEvent     = "burn"
	ClawbackEvent = "clawback"
	FeeEvent      = "fee"
)
View Source
var (
	ErrNoLiquidityPoolEntryFound    = errors.New("no liquidity pool entry found in operation changes")
	ErrNoClaimableBalanceEntryFound = errors.New("no claimable balance entry found in operation changes")
)
View Source
var File_processors_token_transfer_token_transfer_event_proto protoreflect.FileDescriptor

Functions

func ClaimableBalanceIdFromRevocation

func ClaimableBalanceIdFromRevocation(liquidityPoolId xdr.PoolId, asset xdr.Asset, accountSequence xdr.SequenceNumber, accountId xdr.AccountId, opIndex uint32) (xdr.ClaimableBalanceId, error)

Helper function to convert LiquidityPoolId to generate ClaimableBalanceIds in a deterministic way as per https://github.com/stellar/stellar-protocol/blob/master/core/cap-0038.md#settrustlineflagsop-and-allowtrustop Whenever a trustline is revoked for an asset for an account, via setTrustlineFalgs or allowTrust operations, if that account has deposited into a Liquidity Pool, then, claimable balances are created for those assets from the LP

The generated ClaimableBalanceId is derived from: - Liquidity Pool Id from which the pool shares are withdrawn - The asset for which CB is created - the accountSequence number of the transaction account - The transaction accountId - The operationIndex of the setTrustlineFlags or allowTrust operation within the transaction

func VerifyEvents

func VerifyEvents(ledger xdr.LedgerCloseMeta, passphrase string, readFromUnifiedEvents bool) error

Types

type Burn

type Burn struct {
	From   string       `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	Asset  *asset.Asset `protobuf:"bytes,2,opt,name=asset,proto3" json:"asset,omitempty"` // Asset can be native or issued. For custom tokens, it will be absent
	Amount string       `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Burn) Descriptor deprecated

func (*Burn) Descriptor() ([]byte, []int)

Deprecated: Use Burn.ProtoReflect.Descriptor instead.

func (*Burn) GetAmount

func (x *Burn) GetAmount() string

func (*Burn) GetAsset

func (x *Burn) GetAsset() *asset.Asset

func (*Burn) GetFrom

func (x *Burn) GetFrom() string

func (*Burn) ProtoMessage

func (*Burn) ProtoMessage()

func (*Burn) ProtoReflect

func (x *Burn) ProtoReflect() protoreflect.Message

func (*Burn) Reset

func (x *Burn) Reset()

func (*Burn) String

func (x *Burn) String() string

type Clawback

type Clawback struct {
	From   string       `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	Asset  *asset.Asset `protobuf:"bytes,2,opt,name=asset,proto3" json:"asset,omitempty"` // Asset can be native or issued. For custom tokens, it will be absent
	Amount string       `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Clawback) Descriptor deprecated

func (*Clawback) Descriptor() ([]byte, []int)

Deprecated: Use Clawback.ProtoReflect.Descriptor instead.

func (*Clawback) GetAmount

func (x *Clawback) GetAmount() string

func (*Clawback) GetAsset

func (x *Clawback) GetAsset() *asset.Asset

func (*Clawback) GetFrom

func (x *Clawback) GetFrom() string

func (*Clawback) ProtoMessage

func (*Clawback) ProtoMessage()

func (*Clawback) ProtoReflect

func (x *Clawback) ProtoReflect() protoreflect.Message

func (*Clawback) Reset

func (x *Clawback) Reset()

func (*Clawback) String

func (x *Clawback) String() string

type ErrNotSep41TokenEvent

type ErrNotSep41TokenEvent struct {
	Message string
}

func (ErrNotSep41TokenEvent) Error

func (e ErrNotSep41TokenEvent) Error() string

type EventError

type EventError struct {
	Message string
}

func NewEventError

func NewEventError(message string) *EventError

func (*EventError) Error

func (e *EventError) Error() string

type EventMeta

type EventMeta struct {
	LedgerSequence uint32                 `protobuf:"varint,1,opt,name=ledger_sequence,json=ledgerSequence,proto3" json:"ledger_sequence,omitempty"`
	ClosedAt       *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=closed_at,json=closedAt,proto3" json:"closed_at,omitempty"`
	TxHash         string                 `protobuf:"bytes,3,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"`
	// Index of transaction within this ledger. This is 1-indexed as per SEP-35
	TransactionIndex uint32 `protobuf:"varint,4,opt,name=transaction_index,json=transactionIndex,proto3" json:"transaction_index,omitempty"`
	// Index of operation within the transaction, if it is not a fee event. This is 1-indexed as per SEP-35
	OperationIndex *uint32 `protobuf:"varint,5,opt,name=operation_index,json=operationIndex,proto3,oneof" json:"operation_index,omitempty"`
	// For a classic operation, this contract_address is the ContractID as derived from asset
	// For a smart contract event, this contractId is the id of the contract emiting the core event
	ContractAddress string `protobuf:"bytes,6,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
	// The to_muxed_info follows the spec outlined in section in CAP-67 - https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md#multiplexing-support
	ToMuxedInfo *MuxedInfo `protobuf:"bytes,7,opt,name=to_muxed_info,json=toMuxedInfo,proto3" json:"to_muxed_info,omitempty"`
	// contains filtered or unexported fields
}

EventMeta message

func NewEventMetaFromTx

func NewEventMetaFromTx(tx ingest.LedgerTransaction, operationIndex *uint32, contractAddress string) *EventMeta

func (*EventMeta) Descriptor deprecated

func (*EventMeta) Descriptor() ([]byte, []int)

Deprecated: Use EventMeta.ProtoReflect.Descriptor instead.

func (*EventMeta) GetClosedAt

func (x *EventMeta) GetClosedAt() *timestamppb.Timestamp

func (*EventMeta) GetContractAddress

func (x *EventMeta) GetContractAddress() string

func (*EventMeta) GetLedgerSequence

func (x *EventMeta) GetLedgerSequence() uint32

func (*EventMeta) GetOperationIndex

func (x *EventMeta) GetOperationIndex() uint32

func (*EventMeta) GetToMuxedInfo

func (x *EventMeta) GetToMuxedInfo() *MuxedInfo

func (*EventMeta) GetTransactionIndex

func (x *EventMeta) GetTransactionIndex() uint32

func (*EventMeta) GetTxHash

func (x *EventMeta) GetTxHash() string

func (*EventMeta) ProtoMessage

func (*EventMeta) ProtoMessage()

func (*EventMeta) ProtoReflect

func (x *EventMeta) ProtoReflect() protoreflect.Message

func (*EventMeta) Reset

func (x *EventMeta) Reset()

func (*EventMeta) String

func (x *EventMeta) String() string

type EventsProcessor

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

func NewEventsProcessor

func NewEventsProcessor(networkPassphrase string, options ...EventsProcessorOption) *EventsProcessor

func NewEventsProcessorForUnifiedEvents

func NewEventsProcessorForUnifiedEvents(passphrase string) *EventsProcessor

Use this constructor if you know that the ledgers you pass to EventsFromLedger() have unified events

func (*EventsProcessor) EventsFromLedger

func (p *EventsProcessor) EventsFromLedger(lcm xdr.LedgerCloseMeta) ([]*TokenTransferEvent, error)

EventsFromLedger processes token transfer events for all transactions in a given ledger. This function operates at the ledger level, iterating over all transactions in the ledger. it calls EventsFromTransaction to process token transfer events from each transaction within the ledger.

func (*EventsProcessor) EventsFromOperation

func (p *EventsProcessor) EventsFromOperation(tx ingest.LedgerTransaction, opIndex uint32, op xdr.Operation, opResult xdr.OperationResult) ([]*TokenTransferEvent, error)

EventsFromOperation processes token transfer events for a given operation within a transaction. It operates at the operation level, analyzing the operation type and generating corresponding token transfer events. If the operation is successful, it processes the event based on the operation type (e.g., payment, account creation, etc.). It handles various operation types like payments, account merges, trust line modifications, and more. There is a separate private function to derive events for each classic operation. It is implicitly assumed that the operation is successful, and thus will contribute towards generating events. which is why we don't check for the success code in the OperationResult

func (*EventsProcessor) EventsFromTransaction

func (p *EventsProcessor) EventsFromTransaction(tx ingest.LedgerTransaction) (TransactionEvents, error)

EventsFromTransaction processes token transfer events for all operations within a given transaction.

First, it generates a FeeEvent for the transaction
If the transaction was successful, it processes all operations in the transaction by calling EventsFromOperation for each operation in the transaction.

If the transaction is unsuccessful, it only generates events for transaction fees.

type EventsProcessorOption

type EventsProcessorOption func(*EventsProcessor)

func WithUnifiedEventsStreamEnabled

func WithUnifiedEventsStreamEnabled() EventsProcessorOption

type Fee

type Fee struct {
	From   string       `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	Asset  *asset.Asset `protobuf:"bytes,2,opt,name=asset,proto3" json:"asset,omitempty"` // Asset can be native or issued. For custom tokens, it will be absent
	Amount string       `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Fee) Descriptor deprecated

func (*Fee) Descriptor() ([]byte, []int)

Deprecated: Use Fee.ProtoReflect.Descriptor instead.

func (*Fee) GetAmount

func (x *Fee) GetAmount() string

func (*Fee) GetAsset

func (x *Fee) GetAsset() *asset.Asset

func (*Fee) GetFrom

func (x *Fee) GetFrom() string

func (*Fee) ProtoMessage

func (*Fee) ProtoMessage()

func (*Fee) ProtoReflect

func (x *Fee) ProtoReflect() protoreflect.Message

func (*Fee) Reset

func (x *Fee) Reset()

func (*Fee) String

func (x *Fee) String() string

type InvalidFeeEvent

type InvalidFeeEvent struct {
	Message string
}

func (InvalidFeeEvent) Error

func (e InvalidFeeEvent) Error() string

type Mint

type Mint struct {
	To     string       `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"`
	Asset  *asset.Asset `protobuf:"bytes,2,opt,name=asset,proto3" json:"asset,omitempty"` // Asset can be native or issued. For custom tokens, it will be absent
	Amount string       `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Mint) Descriptor deprecated

func (*Mint) Descriptor() ([]byte, []int)

Deprecated: Use Mint.ProtoReflect.Descriptor instead.

func (*Mint) GetAmount

func (x *Mint) GetAmount() string

func (*Mint) GetAsset

func (x *Mint) GetAsset() *asset.Asset

func (*Mint) GetTo

func (x *Mint) GetTo() string

func (*Mint) ProtoMessage

func (*Mint) ProtoMessage()

func (*Mint) ProtoReflect

func (x *Mint) ProtoReflect() protoreflect.Message

func (*Mint) Reset

func (x *Mint) Reset()

func (*Mint) String

func (x *Mint) String() string

type MuxedInfo

type MuxedInfo struct {

	// Types that are valid to be assigned to Content:
	//
	//	*MuxedInfo_Text
	//	*MuxedInfo_Id
	//	*MuxedInfo_Hash
	Content isMuxedInfo_Content `protobuf_oneof:"content"`
	// contains filtered or unexported fields
}

func NewMuxedInfoFromId

func NewMuxedInfoFromId(id uint64) *MuxedInfo

func NewMuxedInfoFromMemo

func NewMuxedInfoFromMemo(m xdr.Memo) *MuxedInfo

func NewMuxedInfoFromText

func NewMuxedInfoFromText(text string) *MuxedInfo

func (*MuxedInfo) Descriptor deprecated

func (*MuxedInfo) Descriptor() ([]byte, []int)

Deprecated: Use MuxedInfo.ProtoReflect.Descriptor instead.

func (*MuxedInfo) GetContent

func (x *MuxedInfo) GetContent() isMuxedInfo_Content

func (*MuxedInfo) GetHash

func (x *MuxedInfo) GetHash() []byte

func (*MuxedInfo) GetId

func (x *MuxedInfo) GetId() uint64

func (*MuxedInfo) GetText

func (x *MuxedInfo) GetText() string

func (*MuxedInfo) ProtoMessage

func (*MuxedInfo) ProtoMessage()

func (*MuxedInfo) ProtoReflect

func (x *MuxedInfo) ProtoReflect() protoreflect.Message

func (*MuxedInfo) Reset

func (x *MuxedInfo) Reset()

func (*MuxedInfo) String

func (x *MuxedInfo) String() string

type MuxedInfo_Hash

type MuxedInfo_Hash struct {
	Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3,oneof"`
}

type MuxedInfo_Id

type MuxedInfo_Id struct {
	Id uint64 `protobuf:"varint,2,opt,name=id,proto3,oneof"`
}

type MuxedInfo_Text

type MuxedInfo_Text struct {
	Text string `protobuf:"bytes,1,opt,name=text,proto3,oneof"`
}

type TokenTransferEvent

type TokenTransferEvent struct {
	Meta *EventMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"`
	// Types that are valid to be assigned to Event:
	//
	//	*TokenTransferEvent_Transfer
	//	*TokenTransferEvent_Mint
	//	*TokenTransferEvent_Burn
	//	*TokenTransferEvent_Clawback
	//	*TokenTransferEvent_Fee
	Event isTokenTransferEvent_Event `protobuf_oneof:"event"`
	// contains filtered or unexported fields
}

func NewBurnEvent

func NewBurnEvent(meta *EventMeta, from string, amount string, token *assetProto.Asset) *TokenTransferEvent

func NewClawbackEvent

func NewClawbackEvent(meta *EventMeta, from string, amount string, token *assetProto.Asset) *TokenTransferEvent

func NewFeeEvent

func NewFeeEvent(meta *EventMeta, from string, amount string, token *assetProto.Asset) *TokenTransferEvent

func NewMintEvent

func NewMintEvent(meta *EventMeta, to string, amount string, token *assetProto.Asset) *TokenTransferEvent

func NewTransferEvent

func NewTransferEvent(meta *EventMeta, from, to string, amount string, token *assetProto.Asset) *TokenTransferEvent

func (*TokenTransferEvent) Descriptor deprecated

func (*TokenTransferEvent) Descriptor() ([]byte, []int)

Deprecated: Use TokenTransferEvent.ProtoReflect.Descriptor instead.

func (*TokenTransferEvent) GetAmount

func (event *TokenTransferEvent) GetAmount() string

func (*TokenTransferEvent) GetAsset

func (event *TokenTransferEvent) GetAsset() *assetProto.Asset

func (*TokenTransferEvent) GetBurn

func (x *TokenTransferEvent) GetBurn() *Burn

func (*TokenTransferEvent) GetClawback

func (x *TokenTransferEvent) GetClawback() *Clawback

func (*TokenTransferEvent) GetEvent

func (x *TokenTransferEvent) GetEvent() isTokenTransferEvent_Event

func (*TokenTransferEvent) GetEventType

func (event *TokenTransferEvent) GetEventType() string

func (*TokenTransferEvent) GetFee

func (x *TokenTransferEvent) GetFee() *Fee

func (*TokenTransferEvent) GetMeta

func (x *TokenTransferEvent) GetMeta() *EventMeta

func (*TokenTransferEvent) GetMint

func (x *TokenTransferEvent) GetMint() *Mint

func (*TokenTransferEvent) GetTransfer

func (x *TokenTransferEvent) GetTransfer() *Transfer

func (*TokenTransferEvent) ProtoMessage

func (*TokenTransferEvent) ProtoMessage()

func (*TokenTransferEvent) ProtoReflect

func (x *TokenTransferEvent) ProtoReflect() protoreflect.Message

func (*TokenTransferEvent) Reset

func (x *TokenTransferEvent) Reset()

func (*TokenTransferEvent) SetAsset

func (event *TokenTransferEvent) SetAsset(asset xdr.Asset)

func (*TokenTransferEvent) String

func (x *TokenTransferEvent) String() string

type TokenTransferEvent_Burn

type TokenTransferEvent_Burn struct {
	Burn *Burn `protobuf:"bytes,4,opt,name=burn,proto3,oneof"`
}

type TokenTransferEvent_Clawback

type TokenTransferEvent_Clawback struct {
	Clawback *Clawback `protobuf:"bytes,5,opt,name=clawback,proto3,oneof"`
}

type TokenTransferEvent_Fee

type TokenTransferEvent_Fee struct {
	Fee *Fee `protobuf:"bytes,6,opt,name=fee,proto3,oneof"`
}

type TokenTransferEvent_Mint

type TokenTransferEvent_Mint struct {
	Mint *Mint `protobuf:"bytes,3,opt,name=mint,proto3,oneof"`
}

type TokenTransferEvent_Transfer

type TokenTransferEvent_Transfer struct {
	Transfer *Transfer `protobuf:"bytes,2,opt,name=transfer,proto3,oneof"`
}

type TransactionEvents

type TransactionEvents struct {
	FeeEvents       []*TokenTransferEvent
	OperationEvents []*TokenTransferEvent
}

type Transfer

type Transfer struct {
	From   string       `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	To     string       `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
	Asset  *asset.Asset `protobuf:"bytes,3,opt,name=asset,proto3" json:"asset,omitempty"` // Asset can be native or issued. For custom tokens, it will be absent
	Amount string       `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Transfer) Descriptor deprecated

func (*Transfer) Descriptor() ([]byte, []int)

Deprecated: Use Transfer.ProtoReflect.Descriptor instead.

func (*Transfer) GetAmount

func (x *Transfer) GetAmount() string

func (*Transfer) GetAsset

func (x *Transfer) GetAsset() *asset.Asset

func (*Transfer) GetFrom

func (x *Transfer) GetFrom() string

func (*Transfer) GetTo

func (x *Transfer) GetTo() string

func (*Transfer) ProtoMessage

func (*Transfer) ProtoMessage()

func (*Transfer) ProtoReflect

func (x *Transfer) ProtoReflect() protoreflect.Message

func (*Transfer) Reset

func (x *Transfer) Reset()

func (*Transfer) String

func (x *Transfer) String() string

Jump to

Keyboard shortcuts

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