wasm

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeWasmMessage     = "wasm-Message"
	EventTypeWasmCallMessage = "wasm-CallMessage"

	// Attr keys for connection contract events
	EventAttrKeyMsg                  = "msg"
	EventAttrKeyTargetNetwork string = "targetNetwork"
	EventAttrKeyConnSn        string = "connSn"

	// Attr keys for xcall contract events
	EventAttrKeyReqID string = "reqId"
	EventAttrKeyData  string = "data"
	EventAttrKeyTo    string = "to"
	EventAttrKeyFrom  string = "from"
	EventAttrKeySn    string = "sn"

	EventAttrKeyContractAddress string = "_contract_address"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Client

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

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(txBytes []byte) (*sdkTypes.TxResponse, error)

func (*Client) BuildTxFactory

func (c *Client) BuildTxFactory() (tx.Factory, error)

func (*Client) CreateAccount

func (c *Client) CreateAccount(uid, passphrase string) (string, string, error)

Create new AccountI

func (*Client) EstimateGas

func (c *Client) EstimateGas(txf tx.Factory, msgs ...sdkTypes.Msg) (*txTypes.SimulateResponse, uint64, error)

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context, addr string) (sdkTypes.AccountI, error)

func (*Client) GetArmor

func (c *Client) GetArmor(uid, passphrase string) (string, error)

GetPrivateKey returns private key from keyring

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, addr string, denomination string) (*sdkTypes.Coin, error)

func (*Client) GetFee

func (c *Client) GetFee(ctx context.Context, addr string, queryData []byte) (uint64, error)

GetFee returns the fee set for the network

func (*Client) GetKey

func (c *Client) GetKey(uid string) (*keyring.Record, error)

GetKey returns key from keyring

func (*Client) GetKeyByAddr

func (c *Client) GetKeyByAddr(addr sdkTypes.Address) (*keyring.Record, error)

GetAccount returns account from keyring

func (*Client) GetLatestBlockHeight

func (c *Client) GetLatestBlockHeight(ctx context.Context) (uint64, error)

func (*Client) GetTransactionReceipt

func (c *Client) GetTransactionReceipt(ctx context.Context, txHash string) (*txTypes.GetTxResponse, error)

func (*Client) HTTP

func (c *Client) HTTP(rpcUrl string) (*http.HTTP, error)

func (*Client) ImportArmor

func (c *Client) ImportArmor(uid string, armor []byte, passphrase string) error

Load private key from keyring

func (*Client) PrepareTx

func (c *Client) PrepareTx(ctx context.Context, txf tx.Factory, msgs ...sdkTypes.Msg) ([]byte, error)

func (*Client) QuerySmartContract

func (c *Client) QuerySmartContract(ctx context.Context, address string, queryData []byte) (*wasmTypes.QuerySmartContractStateResponse, error)

func (*Client) SetAddress

func (c *Client) SetAddress(addr sdkTypes.AccAddress) sdkTypes.AccAddress

Set the address to be used for the transactions

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, _, query string) (<-chan coretypes.ResultEvent, error)

Subscribe

func (*Client) TxSearch

func (c *Client) TxSearch(ctx context.Context, param types.TxSearchParam) (*coretypes.ResultTxSearch, error)

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ctx context.Context, _, query string) error

Unsubscribe

type CodecConfig

type CodecConfig struct {
	InterfaceRegistry types.InterfaceRegistry
	Codec             codec.Codec
	TxConfig          client.TxConfig
}

func GetCodecConfig

func GetCodecConfig(pc *ProviderConfig) *CodecConfig

type Event

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

type EventsList

type EventsList struct {
	Events []Event `json:"events"`
}

type IClient

type IClient interface {
	HTTP(rpcUrl string) (*http.HTTP, error)
	GetLatestBlockHeight(ctx context.Context) (uint64, error)
	GetTransactionReceipt(ctx context.Context, txHash string) (*txTypes.GetTxResponse, error)
	GetBalance(ctx context.Context, addr string, denomination string) (*sdkTypes.Coin, error)
	BuildTxFactory() (tx.Factory, error)
	EstimateGas(txf tx.Factory, msgs ...sdkTypes.Msg) (*txTypes.SimulateResponse, uint64, error)
	PrepareTx(ctx context.Context, txf tx.Factory, msgs ...sdkTypes.Msg) ([]byte, error)
	BroadcastTx(txBytes []byte) (*sdkTypes.TxResponse, error)
	TxSearch(ctx context.Context, param types.TxSearchParam) (*coretypes.ResultTxSearch, error)
	GetAccountInfo(ctx context.Context, addr string) (sdkTypes.AccountI, error)
	QuerySmartContract(ctx context.Context, address string, queryData []byte) (*wasmTypes.QuerySmartContractStateResponse, error)
	CreateAccount(name, pass string) (string, string, error)
	ImportArmor(uid string, armor []byte, passphrase string) error
	GetArmor(uid, passphrase string) (string, error)
	GetKey(uid string) (*keyring.Record, error)
	GetKeyByAddr(addr sdkTypes.Address) (*keyring.Record, error)
	SetAddress(account sdkTypes.AccAddress) sdkTypes.AccAddress
	Subscribe(ctx context.Context, _, query string) (<-chan coretypes.ResultEvent, error)
	Unsubscribe(ctx context.Context, _, query string) error
	GetFee(ctx context.Context, addr string, queryData []byte) (uint64, error)
}

type Provider

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

func (*Provider) ClaimFee

func (p *Provider) ClaimFee(ctx context.Context) error

ClaimFee

func (*Provider) Config

func (p *Provider) Config() provider.Config

func (*Provider) ExecuteRollback

func (p *Provider) ExecuteRollback(ctx context.Context, sn *big.Int) error

ExecuteRollback

func (*Provider) FinalityBlock

func (p *Provider) FinalityBlock(ctx context.Context) uint64

func (*Provider) GenerateMessages

func (p *Provider) GenerateMessages(ctx context.Context, messageKey *relayTypes.MessageKeyWithMessageHeight) ([]*relayTypes.Message, error)

func (*Provider) GetAddressByEventType

func (p *Provider) GetAddressByEventType(eventType string) string

GetAddressNyEventType returns the address of the contract by event type

func (*Provider) GetEventName

func (p *Provider) GetEventName(addr string) string

func (*Provider) GetFee

func (p *Provider) GetFee(ctx context.Context, networkID string, responseFee bool) (uint64, error)

GetFee returns the fee for the given networkID responseFee is used to determine if the fee should be returned

func (*Provider) ImportKeystore

func (p *Provider) ImportKeystore(ctx context.Context, keyPath, passphrase string) (string, error)

ImportKeystore imports a keystore from a file

func (*Provider) Init

func (p *Provider) Init(ctx context.Context, homePath string, kms kms.KMS) error

func (*Provider) Listener

func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockInfoChan chan *relayTypes.BlockInfo) error

func (*Provider) MessageReceived

func (p *Provider) MessageReceived(ctx context.Context, key *relayTypes.MessageKey) (bool, error)

func (*Provider) NID

func (p *Provider) NID() string

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) NewKeystore

func (p *Provider) NewKeystore(passphrase string) (string, error)

func (*Provider) ParseMessageFromEvents

func (p *Provider) ParseMessageFromEvents(eventsList []Event) ([]*relayerTypes.Message, error)

func (*Provider) QueryBalance

func (p *Provider) QueryBalance(ctx context.Context, addr string) (*relayTypes.Coin, error)

func (*Provider) QueryLatestHeight

func (p *Provider) QueryLatestHeight(ctx context.Context) (uint64, error)

func (*Provider) QueryTransactionReceipt

func (p *Provider) QueryTransactionReceipt(ctx context.Context, txHash string) (*relayTypes.Receipt, error)

func (*Provider) RestoreKeystore

func (p *Provider) RestoreKeystore(ctx context.Context) error

func (*Provider) RevertMessage

func (p *Provider) RevertMessage(ctx context.Context, sn *big.Int) error

func (*Provider) Route

func (p *Provider) Route(ctx context.Context, message *relayTypes.Message, callback relayTypes.TxResponseFunc) error

func (*Provider) SetAdmin

func (p *Provider) SetAdmin(ctx context.Context, address string) error

func (*Provider) SetFee

func (p *Provider) SetFee(ctx context.Context, networkdID string, msgFee, resFee uint64) error

SetFee

func (*Provider) ShouldReceiveMessage

func (p *Provider) ShouldReceiveMessage(ctx context.Context, message *relayTypes.Message) (bool, error)

func (*Provider) ShouldSendMessage

func (p *Provider) ShouldSendMessage(ctx context.Context, message *relayTypes.Message) (bool, error)

func (*Provider) SubscribeMessageEvents

func (p *Provider) SubscribeMessageEvents(ctx context.Context, blockInfoChan chan *relayTypes.BlockInfo, opts *types.SubscribeOpts) error

SubscribeMessageEvents subscribes to the message events Expermental: Allows to subscribe to the message events realtime without fully syncing the chain

func (*Provider) Type

func (p *Provider) Type() string

func (*Provider) Wallet

func (p *Provider) Wallet() sdkTypes.AccAddress

Wallet returns the wallet of the provider

type ProviderConfig

type ProviderConfig struct {
	RpcUrl  string `json:"rpc-url" yaml:"rpc-url"`
	GrpcUrl string `json:"grpc-url" yaml:"grpc-url"`
	ChainID string `json:"chain-id" yaml:"chain-id"`
	NID     string `json:"nid" yaml:"nid"`

	HomeDir string `json:"home-dir" yaml:"home-dir"`

	KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"`
	KeyringDir     string `json:"keyring-dir" yaml:"keyring-dir"`
	AccountPrefix  string `json:"account-prefix" yaml:"account-prefix"`

	Contracts providerTypes.ContractConfigMap `json:"contracts" yaml:"contracts"`
	Address   string                          `json:"address" yaml:"address"`

	Denomination string `json:"denomination" yaml:"denomination"`

	GasPrices     string  `json:"gas-prices" yaml:"gas-prices"`
	GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"`
	MinGasAmount  uint64  `json:"min-gas-amount" yaml:"min-gas-amount"`
	MaxGasAmount  uint64  `json:"max-gas-amount" yaml:"max-gas-amount"`

	BlockInterval          time.Duration `json:"block-interval" yaml:"block-interval"`
	TxConfirmationInterval time.Duration `json:"tx-confirmation-interval" yaml:"tx-confirmation-interval"`

	BroadcastMode string `json:"broadcast-mode" yaml:"broadcast-mode"` // sync, async and block. Recommended: sync
	SignModeStr   string `json:"sign-mode" yaml:"sign-mode"`

	Simulate bool `json:"simulate" yaml:"simulate"`

	StartHeight uint64 `json:"start-height" yaml:"start-height"`

	FinalityBlock uint64 `json:"finality-block" yaml:"finality-block"`

	ChainName string `json:"-" yaml:"-"`
}

func (*ProviderConfig) GetMonitorEventFilters

func (p *ProviderConfig) GetMonitorEventFilters(eventMap map[string]relayerTypes.EventMap) []sdkTypes.Event

func (*ProviderConfig) GetWallet

func (pc *ProviderConfig) GetWallet() string

func (*ProviderConfig) NewProvider

func (pc *ProviderConfig) NewProvider(ctx context.Context, log *zap.Logger, homePath string, _ bool, chainName string) (provider.ChainProvider, error)

func (*ProviderConfig) SetWallet

func (pc *ProviderConfig) SetWallet(addr string)

func (*ProviderConfig) Validate

func (pc *ProviderConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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