tx

package
v0.0.90 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EventAttributeAmount = "amount"

Variables

View Source
var ErrUnknownMessage = errors.New("no message handler for message type")

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 BlockData

type BlockData struct {
	Txs []string `json:"txs"`
}

type BlockHeader

type BlockHeader struct {
	Height string `json:"height"`
}

type BlockID

type BlockID struct {
	Hash string `json:"hash"`
}

type BlockResponse

type BlockResponse struct {
	BlockData   BlockData   `json:"data"`
	BlockHeader BlockHeader `json:"header"`
}

type Body

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

type CosmosMessage

type CosmosMessage interface {
	HandleMsg(string, sdk.Msg, *LogMessage) error
	ParseRelevantData() []parsingTypes.MessageRelevantInformation
	GetType() string
	String() string
}

CosmosMessage represents a Cosmos blockchain Message (part of a transaction). CosmUnmarshal() unmarshals the specific cosmos message type (e.g. MsgSend). First arg must always be the message type itself, as this won't be parsed in CosmUnmarshal.

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 GetBlockByHeightResponse

type GetBlockByHeightResponse struct {
	BlockID BlockID       `json:"block_id"`
	Block   BlockResponse `json:"block"`
}

type GetLatestBlockResponse

type GetLatestBlockResponse struct {
	BlockID BlockID       `json:"block_id"`
	Block   BlockResponse `json:"block"`
}

type GetTxByBlockHeightResponse

type GetTxByBlockHeightResponse struct {
	Txs         []IndexerTx `json:"txs"`
	TxResponses []Response  `json:"tx_responses"`
	Pagination  Pagination  `json:"pagination"`
}

type GetTxsEventResponseWrapper

type GetTxsEventResponseWrapper struct {
	CosmosGetTxsEventResponse *cosmTx.GetTxsEventResponse
	Height                    int64
}

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 Message

type Message struct {
	Type string `json:"@type"`
}

func (*Message) GetType

func (sf *Message) GetType() string

type MessageLogFormatError

type MessageLogFormatError struct {
	Log         string
	MessageType string
}

func (*MessageLogFormatError) Error

func (e *MessageLogFormatError) Error() string

type Pagination

type Pagination struct {
	NextKey string `json:"next_key"`
	Total   string `json:"total"`
}

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    []byte       `json:"raw_log"`
	Log       []LogMessage `json:"logs"`
	GasUsed   int64        `json:"gas_used"`
	GasWanted int64        `json:"gas_wanted"`
	Codespace string       `json:"codespace"`
	Info      string       `json:"info"`
	Data      string       `json:"data"`
}

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