contractevents

package
v0.0.0-...-21075cb Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	STELLAR_ASSET_CONTRACT_TOPICS = map[xdr.ScSymbol]EventType{
		xdr.ScSymbol("transfer"): EventTypeTransfer,
		xdr.ScSymbol("mint"):     EventTypeMint,
		xdr.ScSymbol("clawback"): EventTypeClawback,
		xdr.ScSymbol("burn"):     EventTypeBurn,
	}

	ErrNotStellarAssetContract = errors.New("event was not from a Stellar Asset Contract")
	ErrEventUnsupported        = errors.New("this type of Stellar Asset Contract event is unsupported")
	ErrEventIntegrity          = errors.New("contract ID doesn't match asset + passphrase")
)
View Source
var ErrNotBalanceChangeEvent = errors.New("event doesn't represent a balance change")
View Source
var ErrNotBurnEvent = errors.New("event is not a valid 'burn' event")
View Source
var ErrNotClawbackEvent = errors.New("event is not a valid 'clawback' event")
View Source
var ErrNotMintEvent = errors.New("event is not a valid 'mint' event")
View Source
var ErrNotTransferEvent = errors.New("event is not a valid 'transfer' event")

Functions

func GenerateEvent

func GenerateEvent(
	type_ EventType,
	from, to, admin string,
	asset xdr.Asset,
	amount *big.Int,
	passphrase string,
) xdr.ContractEvent

GenerateEvent is a utility function to be used by testing frameworks in order to generate Stellar Asset Contract events.

To provide a generic interface, there are more arguments than apply to the type, but you should only expect the relevant ones to be set (for example, transfer events have no admin, so it will be ignored). This means you can always pass your set of testing parameters, modify the type, and get the event filled out with the details you expect.

Types

type BurnEvent

type BurnEvent struct {
	From   string
	Amount xdr.Int128Parts
	// contains filtered or unexported fields
}

func (BurnEvent) GetAsset

func (e BurnEvent) GetAsset() xdr.Asset

func (BurnEvent) GetType

func (e BurnEvent) GetType() EventType

type ClawbackEvent

type ClawbackEvent struct {
	Admin  string
	From   string
	Amount xdr.Int128Parts
	// contains filtered or unexported fields
}

func (ClawbackEvent) GetAsset

func (e ClawbackEvent) GetAsset() xdr.Asset

func (ClawbackEvent) GetType

func (e ClawbackEvent) GetType() EventType

type Event

type Event = xdr.ContractEvent

type EventType

type EventType int
const (
	// Implemented
	EventTypeTransfer EventType = iota
	EventTypeMint
	EventTypeClawback
	EventTypeBurn
	// TODO: Not implemented
	EventTypeIncrAllow
	EventTypeDecrAllow
	EventTypeSetAuthorized
	EventTypeSetAdmin
)

type MintEvent

type MintEvent struct {
	Admin  string
	To     string
	Amount xdr.Int128Parts
	// contains filtered or unexported fields
}

func (MintEvent) GetAsset

func (e MintEvent) GetAsset() xdr.Asset

func (MintEvent) GetType

func (e MintEvent) GetType() EventType

type StellarAssetContractEvent

type StellarAssetContractEvent interface {
	GetType() EventType
	GetAsset() xdr.Asset
}

func NewStellarAssetContractEvent

func NewStellarAssetContractEvent(event *Event, networkPassphrase string) (StellarAssetContractEvent, error)

type TransferEvent

type TransferEvent struct {
	From   string
	To     string
	Amount xdr.Int128Parts
	// contains filtered or unexported fields
}

func (TransferEvent) GetAsset

func (e TransferEvent) GetAsset() xdr.Asset

func (TransferEvent) GetType

func (e TransferEvent) GetType() EventType

Jump to

Keyboard shortcuts

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