contractevents

package
v0.0.0-...-095633c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

	ErrNotHcnetAssetContract = errors.New("event was not from a Hcnet Asset Contract")
	ErrEventUnsupported      = errors.New("this type of Hcnet 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 Hcnet 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 HcnetAssetContractEvent

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

func NewHcnetAssetContractEvent

func NewHcnetAssetContractEvent(event *Event, networkPassphrase string) (HcnetAssetContractEvent, error)

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 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