icon

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultRetryPollingRetires                 = 10
	DefaultSendTransactionRetryInterval        = 3 * time.Second
	DefaultGetTransactionResultPollingInterval = 1 * time.Second
	JsonrpcApiVersion                          = 3
)
View Source
const (
	HeaderKeyIconOptions = "Icon-Options"
	IconOptionsDebug     = "debug"
	IconOptionsTimeout   = "timeout"
)
View Source
const (
	EmitMessage = "Message(str,int,bytes)"
	CallMessage = "CallMessage(str,str,int,int,bytes)"
)

All the events

Variables

View Source
var (
	// Connection Methods
	MethodSendMessage   = "sendMessage"
	MethodRecvMessage   = "recvMessage"
	MethodGetReceipts   = "getReceipts"
	MethodSetAdmin      = "setAdmin"
	MethodRevertMessage = "revertMessage"
	MethodGetFee        = "getFee"
	MethodSetFee        = "setFee"
	MethodClaimFees     = "claimFees"

	// XCALL Methods
	MethodExecuteCall     = "executeCall"
	MethodExecuteRollback = "executeRollback"
)

Functions

func Base64ToData

func Base64ToData(encoded string, v interface{}) ([]byte, error)

func MptProve

func MptProve(key types.HexInt, proofs [][]byte, hash []byte) ([]byte, error)

Types

type CallParamOption

type CallParamOption func(*types.CallParam)

type Client

type Client struct {
	*client.JsonRpcClient
	DebugEndPoint string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, uri string, l *zap.Logger) *Client

func (*Client) Call

func (c *Client) Call(p *types.CallParam, r interface{}) error

func (*Client) CloseAllMonitor

func (c *Client) CloseAllMonitor()

func (*Client) CloseMonitor

func (c *Client) CloseMonitor(conn *websocket.Conn)

func (*Client) EstimateStep

func (c *Client) EstimateStep(param types.TransactionParam) (*types.HexInt, error)

func (*Client) GetBalance

func (c *Client) GetBalance(param *types.AddressParam) (*big.Int, error)

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(p *types.BlockHeightParam) (*types.Block, error)

func (*Client) GetBlockHeaderByHeight

func (c *Client) GetBlockHeaderByHeight(height int64) (*types.BlockHeader, error)

func (*Client) GetBlockHeaderBytesByHeight

func (c *Client) GetBlockHeaderBytesByHeight(p *types.BlockHeightParam) ([]byte, error)

func (*Client) GetDataByHash

func (c *Client) GetDataByHash(p *types.DataHashParam) ([]byte, error)

func (*Client) GetLastBlock

func (c *Client) GetLastBlock() (*types.Block, error)

func (*Client) GetProofForEvents

func (c *Client) GetProofForEvents(p *types.ProofEventsParam) ([][][]byte, error)

func (*Client) GetProofForResult

func (c *Client) GetProofForResult(p *types.ProofResultParam) ([][]byte, error)

func (*Client) GetTransactionResult

func (c *Client) GetTransactionResult(p *types.TransactionHashParam) (*types.TransactionResult, error)

func (*Client) GetValidatorsByHash

func (c *Client) GetValidatorsByHash(hash common.HexHash) ([]common.Address, error)

func (*Client) GetVotesByHeight

func (c *Client) GetVotesByHeight(p *types.BlockHeightParam) ([]byte, error)

func (*Client) Monitor

func (c *Client) Monitor(ctx context.Context, reqUrl string, reqPtr, respPtr interface{}, cb types.WsReadCallback) error

func (*Client) MonitorBlock

func (c *Client) MonitorBlock(ctx context.Context, p *types.BlockRequest, cb func(conn *websocket.Conn, v *types.BlockNotification) error, scb func(conn *websocket.Conn), errCb func(*websocket.Conn, error)) error

func (*Client) MonitorEvent

func (c *Client) MonitorEvent(ctx context.Context, p *types.EventRequest, cb func(conn *websocket.Conn, v *types.EventNotification) error, errCb func(*websocket.Conn, error)) error

func (*Client) SendTransaction

func (c *Client) SendTransaction(p *types.TransactionParam) (*types.HexBytes, error)

func (*Client) SendTransactionAndWait

func (c *Client) SendTransactionAndWait(p *types.TransactionParam) (*types.HexBytes, error)

func (*Client) SignTransaction

func (c *Client) SignTransaction(w module.Wallet, p *types.TransactionParam) error

func (*Client) WaitForResults

func (*Client) WaitTransactionResult

func (c *Client) WaitTransactionResult(p *types.TransactionHashParam) (*types.TransactionResult, error)

type Config added in v1.1.0

type Config struct {
	ChainName     string                         `json:"-" yaml:"-"`
	RPCUrl        string                         `json:"rpc-url" yaml:"rpc-url"`
	Address       string                         `json:"address" yaml:"address"`
	StartHeight   uint64                         `json:"start-height" yaml:"start-height"` // would be of highest priority
	BlockInterval string                         `json:"block-interval" yaml:"block-interval"`
	Contracts     relayerTypes.ContractConfigMap `json:"contracts" yaml:"contracts"`
	NetworkID     int64                          `json:"network-id" yaml:"network-id"`
	FinalityBlock uint64                         `json:"finality-block" yaml:"finality-block"`
	NID           string                         `json:"nid" yaml:"nid"`
	StepMin       int64                          `json:"step-min" yaml:"step-min"`
	StepLimit     int64                          `json:"step-limit" yaml:"step-limit"`
	HomeDir       string                         `json:"-" yaml:"-"`
}

func (*Config) GetWallet added in v1.1.0

func (p *Config) GetWallet() string

func (*Config) NewProvider added in v1.1.0

func (c *Config) NewProvider(ctx context.Context, log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error)

NewProvider returns new Icon provider

func (*Config) SetWallet added in v1.1.0

func (p *Config) SetWallet(addr string)

func (*Config) Validate added in v1.1.0

func (c *Config) Validate() error

type IClient

type IClient interface {
	Call(p *types.CallParam, r interface{}) error
	GetBalance(param *types.AddressParam) (*big.Int, error)
	GetBlockByHeight(p *types.BlockHeightParam) (*types.Block, error)
	GetBlockHeaderBytesByHeight(p *types.BlockHeightParam) ([]byte, error)
	GetVotesByHeight(p *types.BlockHeightParam) ([]byte, error)
	GetDataByHash(p *types.DataHashParam) ([]byte, error)
	GetProofForResult(p *types.ProofResultParam) ([][]byte, error)
	GetProofForEvents(p *types.ProofEventsParam) ([][][]byte, error)
	EstimateStep(param *types.TransactionParam) (*types.HexInt, error)

	MonitorBlock(ctx context.Context, p *types.BlockRequest, cb func(conn *websocket.Conn, v *types.BlockNotification) error, scb func(conn *websocket.Conn), errCb func(*websocket.Conn, error)) error
	MonitorEvent(ctx context.Context, p *types.EventRequest, cb func(conn *websocket.Conn, v *types.EventNotification) error, errCb func(*websocket.Conn, error)) error
	Monitor(ctx context.Context, reqUrl string, reqPtr, respPtr interface{}, cb types.WsReadCallback) error
	CloseAllMonitor()
	CloseMonitor(conn *websocket.Conn)

	GetLastBlock() (*types.Block, error)
	GetBlockHeaderByHeight(height int64) (*types.BlockHeader, error)
	GetValidatorsByHash(hash common.HexHash) ([]common.Address, error)
}

type IconMessage

type IconMessage struct {
	Address types.Address
	Params  interface{}
	Method  string
}

func (*IconMessage) MsgBytes

func (m *IconMessage) MsgBytes() ([]byte, error)

func (*IconMessage) Type

func (m *IconMessage) Type() string

type IconOptions

type IconOptions map[string]string

func NewIconOptionsByHeader

func NewIconOptionsByHeader(h http.Header) IconOptions

func (IconOptions) Del

func (opts IconOptions) Del(key string)

func (IconOptions) Get

func (opts IconOptions) Get(key string) string

func (*IconOptions) GetBool

func (opts *IconOptions) GetBool(key string) (bool, error)

func (*IconOptions) GetInt

func (opts *IconOptions) GetInt(key string) (int64, error)

func (IconOptions) Set

func (opts IconOptions) Set(key, value string)

func (*IconOptions) SetBool

func (opts *IconOptions) SetBool(key string, value bool)

func (*IconOptions) SetInt

func (opts *IconOptions) SetInt(key string, v int64)

func (IconOptions) ToHeaderValue

func (opts IconOptions) ToHeaderValue() string

type Provider added in v1.1.0

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

func (*Provider) ClaimFee added in v1.1.0

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

ClaimFees

func (*Provider) Config added in v1.1.0

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

func (*Provider) ExecuteRollback added in v1.1.0

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

ExecuteRollback

func (*Provider) FinalityBlock added in v1.1.0

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

func (*Provider) GenerateMessages added in v1.1.0

func (*Provider) GetAddressByEventType added in v1.1.0

func (p *Provider) GetAddressByEventType(eventType string) types.Address

GetAddressNyEventType returns the address of the contract by event type

func (*Provider) GetEventName added in v1.1.0

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

func (*Provider) GetFee added in v1.1.0

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

GetFee

func (*Provider) GetMonitorEventFilters added in v1.1.0

func (p *Provider) GetMonitorEventFilters() []*types.EventFilter

func (*Provider) ImportKeystore added in v1.1.0

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

func (*Provider) Init added in v1.1.0

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

func (*Provider) Listener added in v1.1.0

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

TODO: check for balance and if the balance is low show info balance is low starting listener

func (*Provider) LogFailedTx added in v1.1.0

func (p *Provider) LogFailedTx(method string, result *types.TransactionResult, err error)

func (*Provider) LogSuccessTx added in v1.1.0

func (p *Provider) LogSuccessTx(method string, result *types.TransactionResult)

func (*Provider) MakeIconMessage added in v1.1.0

func (p *Provider) MakeIconMessage(message *providerTypes.Message) (*IconMessage, error)

func (*Provider) MessageReceived added in v1.1.0

func (p *Provider) MessageReceived(ctx context.Context, messageKey *providerTypes.MessageKey) (bool, error)

MessageReceived checks if the message is received

func (*Provider) NID added in v1.1.0

func (p *Provider) NID() string

func (*Provider) Name added in v1.1.0

func (p *Provider) Name() string

func (*Provider) NewIconMessage added in v1.1.0

func (p *Provider) NewIconMessage(address types.Address, msg interface{}, method string) *IconMessage

func (*Provider) NewKeystore added in v1.1.0

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

func (*Provider) QueryBalance added in v1.1.0

func (ip *Provider) QueryBalance(ctx context.Context, addr string) (*providerTypes.Coin, error)

func (*Provider) QueryLatestHeight added in v1.1.0

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

func (*Provider) QueryTransactionReceipt added in v1.1.0

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

QueryTransactionReceipt -> TxHash should be in hex string

func (*Provider) RestoreKeystore added in v1.1.0

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

func (*Provider) RevertMessage added in v1.1.0

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

ReverseMessage reverts a message

func (*Provider) Route added in v1.1.0

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

func (*Provider) SendTransaction added in v1.1.0

func (p *Provider) SendTransaction(ctx context.Context, msg *IconMessage) ([]byte, error)

func (*Provider) SetAdmin added in v1.1.0

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

SetAdmin sets the admin address of the bridge contract

func (*Provider) SetFee added in v1.1.0

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

SetFees

func (*Provider) ShouldReceiveMessage added in v1.1.0

func (ip *Provider) ShouldReceiveMessage(ctx context.Context, messagekey *providerTypes.Message) (bool, error)

func (*Provider) ShouldSendMessage added in v1.1.0

func (ip *Provider) ShouldSendMessage(ctx context.Context, messageKey *providerTypes.Message) (bool, error)

func (*Provider) StartFromHeight added in v1.1.0

func (p *Provider) StartFromHeight(ctx context.Context, lastSavedHeight uint64) (int64, error)

func (*Provider) Type added in v1.1.0

func (p *Provider) Type() string

func (*Provider) WaitForTxResult added in v1.1.0

func (p *Provider) WaitForTxResult(
	ctx context.Context,
	txHash []byte,
	messageKey *providerTypes.MessageKey,
	method string,
	callback providerTypes.TxResponseFunc,
)

TODO: review try to remove wait for Tx from packet-transfer and only use this for client and connection creation

func (*Provider) Wallet added in v1.1.0

func (p *Provider) Wallet() (module.Wallet, error)

type Wallet

type Wallet interface {
	Sign(data []byte) ([]byte, error)
	Address() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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