tx

package
v0.0.0-...-a43c887 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EventAttributeAmount = "amount"

Variables

This section is empty.

Functions

func GetCoinsReceived

func GetCoinsReceived(receiver string, evts []LogMessageEvent) []string

func GetCoinsSpent

func GetCoinsSpent(spender string, evts []LogMessageEvent) []string

func GetLastValueForAttribute

func GetLastValueForAttribute(key string, evt *LogMessageEvent) string

func GetNthValueForAttribute

func GetNthValueForAttribute(key string, n int, evt *LogMessageEvent) string

Get the Nth value for the given key (starting at 1)

func GetValueForAttribute

func GetValueForAttribute(key string, evt *LogMessageEvent) (string, error)

If order is reversed, the last attribute containing the given key will be returned otherwise the first attribute will be returned

func IsMessageActionEquals

func IsMessageActionEquals(msgType string, msg *LogMessage) bool

Types

type Attribute

type Attribute struct {
	Key   string
	Value string
}

type AuthInfo

type AuthInfo struct {
	TxFee         Fee          `json:"fee"`
	TxSignerInfos []SignerInfo `json:"signer_infos"` // this is used in REST but not RPC parsers
}

type Body

type Body struct {
	Messages []sdk.Msg `json:"messages"`
}

type Fee

type Fee struct {
	TxFeeAmount []FeeAmount `json:"amount"`
	GasLimit    string      `json:"gas_limit"`
}

type FeeAmount

type FeeAmount struct {
	Denom  string `json:"denom"`
	Amount string `json:"amount"`
}

type IndexerTx

type IndexerTx struct {
	Body     Body `json:"body"`
	AuthInfo cosmTx.AuthInfo
}

type LogMessage

type LogMessage struct {
	MessageIndex int               `json:"msg_index"`
	Events       []LogMessageEvent `json:"events"`
}

TxLogMessage: Cosmos blockchains return Transactions with an array of "logs" e.g.

"logs": [

{
	"msg_index": 0,
	"events": [
	  {
		"type": "coin_received",
		"attributes": [
		  {
			"key": "receiver",
			"value": "juno128taw6wkhfq29u83lmh5qyfv8nff6h0w577vsy"
		  }, ...
		]
	  } ...

The individual log always has a msg_index corresponding to the Message from the Transaction. But the events are specific to each Message type, for example MsgSend might be different from any other message type.

This struct just parses the KNOWN fields and leaves the other fields as raw JSON. More specific type parsers for each message type can parse those fields if they choose to.

func GetMessageLogForIndex

func GetMessageLogForIndex(logs []LogMessage, index int) *LogMessage

type LogMessageEvent

type LogMessageEvent struct {
	Type       string      `json:"type"`
	Attributes []Attribute `json:"attributes"`
}

func GetAllEventsWithType

func GetAllEventsWithType(eventType string, msg *LogMessage) []LogMessageEvent

func GetEventWithType

func GetEventWithType(eventType string, msg *LogMessage) *LogMessageEvent

func GetEventsWithType

func GetEventsWithType(eventType string, msg *LogMessage) []LogMessageEvent

type MergedTx

type MergedTx struct {
	Tx         IndexerTx
	TxResponse Response
}

In the json, TX data is split into 2 arrays, used to merge the full dataset

type PublicKey

type PublicKey struct {
	Type string `json:"@type"`
	Key  string `json:"key"`
}

type Response

type Response struct {
	TxHash    string       `json:"txhash"`
	Height    string       `json:"height"`
	TimeStamp string       `json:"timestamp"`
	Code      uint32       `json:"code"`
	RawLog    string       `json:"raw_log"`
	Log       []LogMessage `json:"logs"`
}

type SignerInfo

type SignerInfo struct {
	PublicKey PublicKey `json:"public_key"`
}

type TransferEvent

type TransferEvent struct {
	Recipient string
	Sender    string
	Amount    string
}

func ParseTransferEvent

func ParseTransferEvent(evt LogMessageEvent) ([]TransferEvent, error)

Transfer events should have attributes in the order recipient, sender, amount.

Jump to

Keyboard shortcuts

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