Documentation ¶
Index ¶
- Constants
- Variables
- func BuildSendMsg(from, to, unit string, amount *big.Int) *bankTypes.MsgSend
- func BuildSignatures(publicKey cryptoTypes.PubKey, sequence uint64, signature []byte) signingTypes.SignatureV2
- func BuildSignerData(chainID string, accountNumber, sequence uint64) signing.SignerData
- func GetStubChainID(chainName, network string) *big.Int
- func IsSupportedCosmosSubChain(chainName string) bool
- func IsValidAddress(prefix, address string) bool
- func NewClientContext() cosmosClient.Context
- func ParseCoinsFee(amount string) (sdk.Coins, error)
- func ParseCoinsNormalized(coinStr string) (sdk.Coins, error)
- func ParseMemo(swapInfo *tokens.SwapTxInfo, memo string) error
- func PubKeyFromBytes(pubKeyBytes []byte) (cryptoTypes.PubKey, error)
- func PubKeyFromStr(pubKeyHex string) (cryptoTypes.PubKey, error)
- func PublicKeyToAddress(prefix, pubKeyHex string) (string, error)
- func Sha256Sum(data []byte) []byte
- func SupportsChainID(chainID *big.Int) bool
- func VerifyPubKey(address, prefix, pubkey string) error
- type BaseAccount
- type Block
- type Bridge
- func (b *Bridge) BroadcastTx(req *BroadcastTxRequest) (string, error)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) BuildTx(args *tokens.BuildTxArgs, to, denom, memo, publicKey string, amount *big.Int) (cosmosClient.TxBuilder, error)
- func (b *Bridge) GRPCBroadcastTx(req *BroadcastTxRequest) (res *sdk.TxResponse, err error)
- func (b *Bridge) GRPCGetBaseAccount(address string) (res *QueryAccountResponse, err error)
- func (b *Bridge) GRPCGetChainID() (res string, err error)
- func (b *Bridge) GRPCGetDenomBalance(address, denom string) (res sdk.Int, err error)
- func (b *Bridge) GRPCGetLatestBlockNumber() (res uint64, err error)
- func (b *Bridge) GRPCGetLatestBlockNumberOf(url string) (res uint64, err error)
- func (b *Bridge) GRPCGetTransactionByHash(txHash string) (res *GetTxResponse, err error)
- func (b *Bridge) GRPCSimulateTx(simulateReq *SimulateRequest) (res *sdktx.SimulateResponse, err error)
- func (b *Bridge) GetAccountNum(account string) (uint64, error)
- func (b *Bridge) GetBaseAccount(address string) (*QueryAccountResponse, error)
- func (b *Bridge) GetChainID() (string, error)
- func (b *Bridge) GetDenomBalance(address, denom string) (sdk.Int, error)
- func (b *Bridge) GetLatestBlockNumber() (uint64, error)
- func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, error)
- func (b *Bridge) GetPoolNonce(address, _height string) (uint64, error)
- func (b *Bridge) GetSeq(args *tokens.BuildTxArgs) (nonceptr *uint64, err error)
- func (b *Bridge) GetSignBytes(tx *BuildRawTx) ([]byte, error)
- func (b *Bridge) GetSignTx(tx signing.Tx) (signedTx []byte, txHash string, err error)
- func (b *Bridge) GetTransaction(txHash string) (tx interface{}, err error)
- func (b *Bridge) GetTransactionByHash(txHash string) (*GetTxResponse, error)
- func (b *Bridge) GetTransactionStatus(txHash string) (status *tokens.TxStatus, err error)
- func (b *Bridge) InitAfterConfig()
- func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)
- func (b *Bridge) IsValidAddress(address string) bool
- func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) NewSignModeHandler() signing.SignModeHandler
- func (b *Bridge) ParseAmountTotal(messageLog sdk.ABCIMessageLog, swapInfo *tokens.SwapTxInfo) error
- func (b *Bridge) ParseCoinAmount(value *big.Int, swapInfo *tokens.SwapTxInfo, ...)
- func (b *Bridge) PublicKeyToAddress(pubKeyHex string) (string, error)
- func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
- func (b *Bridge) SendTransaction(signedTx interface{}) (string, error)
- func (b *Bridge) SetGatewayConfig(gatewayCfg *tokens.GatewayConfig)
- func (b *Bridge) SetPrefixAndDenom(prefix, denom string)
- func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
- func (b *Bridge) SignTransactionWithPrivateKey(buildRawTx *BuildRawTx, privKey string) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) SimulateTx(simulateReq *SimulateRequest) (string, error)
- func (b *Bridge) VerifyMsgHash(tx interface{}, msgHashes []string) (err error)
- func (b *Bridge) VerifyPubKey(address, pubkey string) error
- func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
- type BroadcastTxRequest
- type BroadcastTxResponse
- type BuildRawTx
- type GasInfo
- type GetLatestBlockResponse
- type GetTxResponse
- type Header
- type QueryAccountResponse
- type QueryAllBalancesResponse
- type SimulateRequest
- type SimulateResponse
- type Tx
- type TxBody
- type TxResponse
Constants ¶
const ( LatestBlock = "/cosmos/base/tendermint/v1beta1/blocks/latest" TxByHash = "/cosmos/tx/v1beta1/txs/" AccountInfo = "/cosmos/auth/v1beta1/accounts/" Balances = "/cosmos/bank/v1beta1/balances/" SimulateTx = "/cosmos/tx/v1beta1/simulate" BroadTx = "/cosmos/tx/v1beta1/txs" )
const (
TransferType = "transfer"
)
Variables ¶
var ( DefaultGasLimit uint64 = 150000 DefaultFee = "500" )
var (
ChainsList = []string{"COSMOSHUB", "OSMOSIS", "COREUM", "SEI"}
)
Functions ¶
func BuildSignatures ¶
func BuildSignatures(publicKey cryptoTypes.PubKey, sequence uint64, signature []byte) signingTypes.SignatureV2
func BuildSignerData ¶
func BuildSignerData(chainID string, accountNumber, sequence uint64) signing.SignerData
func GetStubChainID ¶
GetStubChainID get stub chainID
func IsSupportedCosmosSubChain ¶
IsSupportedCosmosSubChain is supported
func IsValidAddress ¶
func NewClientContext ¶
func NewClientContext() cosmosClient.Context
func PubKeyFromBytes ¶
func PubKeyFromBytes(pubKeyBytes []byte) (cryptoTypes.PubKey, error)
PubKeyFromBytes get public key from bytes
func PubKeyFromStr ¶
func PubKeyFromStr(pubKeyHex string) (cryptoTypes.PubKey, error)
PubKeyFromStr get public key from hex string
func PublicKeyToAddress ¶
func VerifyPubKey ¶
Types ¶
type BaseAccount ¶
type BaseAccount struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` AccountNumber string `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` Sequence string `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` }
BaseAccount base account
type Block ¶
type Block struct {
Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"`
}
type Bridge ¶
type Bridge struct { *base.NonceSetterBase cosmosClient.TxConfig grpc.ClientContext Prefix string Denom string }
Bridge base bridge
func (*Bridge) BroadcastTx ¶
func (b *Bridge) BroadcastTx(req *BroadcastTxRequest) (string, error)
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) BuildTx ¶
func (b *Bridge) BuildTx( args *tokens.BuildTxArgs, to, denom, memo, publicKey string, amount *big.Int, ) (cosmosClient.TxBuilder, error)
func (*Bridge) GRPCBroadcastTx ¶
func (b *Bridge) GRPCBroadcastTx(req *BroadcastTxRequest) (res *sdk.TxResponse, err error)
func (*Bridge) GRPCGetBaseAccount ¶
func (b *Bridge) GRPCGetBaseAccount(address string) (res *QueryAccountResponse, err error)
func (*Bridge) GRPCGetChainID ¶
func (*Bridge) GRPCGetDenomBalance ¶
func (*Bridge) GRPCGetLatestBlockNumber ¶
func (*Bridge) GRPCGetLatestBlockNumberOf ¶
func (*Bridge) GRPCGetTransactionByHash ¶
func (b *Bridge) GRPCGetTransactionByHash(txHash string) (res *GetTxResponse, err error)
func (*Bridge) GRPCSimulateTx ¶
func (b *Bridge) GRPCSimulateTx(simulateReq *SimulateRequest) (res *sdktx.SimulateResponse, err error)
func (*Bridge) GetAccountNum ¶
GetAccountNum get account number
func (*Bridge) GetBaseAccount ¶
func (b *Bridge) GetBaseAccount(address string) (*QueryAccountResponse, error)
func (*Bridge) GetChainID ¶
func (*Bridge) GetDenomBalance ¶
func (*Bridge) GetLatestBlockNumber ¶
func (*Bridge) GetLatestBlockNumberOf ¶
func (*Bridge) GetPoolNonce ¶
GetPoolNonce impl NonceSetter interface
func (*Bridge) GetSeq ¶
func (b *Bridge) GetSeq(args *tokens.BuildTxArgs) (nonceptr *uint64, err error)
GetSeq returns account tx sequence
func (*Bridge) GetSignBytes ¶
func (b *Bridge) GetSignBytes(tx *BuildRawTx) ([]byte, error)
func (*Bridge) GetTransaction ¶
GetTransaction impl
func (*Bridge) GetTransactionByHash ¶
func (b *Bridge) GetTransactionByHash(txHash string) (*GetTxResponse, error)
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus impl
func (*Bridge) InitAfterConfig ¶
func (b *Bridge) InitAfterConfig()
InitAfterConfig init variables (ie. extra members) after loading config
func (*Bridge) InitRouterInfo ¶
InitRouterInfo init router info
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
func (*Bridge) MPCSignTransaction ¶
func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
MPCSignTransaction mpc sign raw tx
func (*Bridge) NewSignModeHandler ¶
func (b *Bridge) NewSignModeHandler() signing.SignModeHandler
func (*Bridge) ParseAmountTotal ¶
func (b *Bridge) ParseAmountTotal(messageLog sdk.ABCIMessageLog, swapInfo *tokens.SwapTxInfo) error
func (*Bridge) ParseCoinAmount ¶
func (*Bridge) PublicKeyToAddress ¶
PublicKeyToAddress public key hex string (may be uncompressed) to address
func (*Bridge) RegisterSwap ¶
func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
RegisterSwap api
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SetGatewayConfig ¶
func (b *Bridge) SetGatewayConfig(gatewayCfg *tokens.GatewayConfig)
SetGatewayConfig set gateway config
func (*Bridge) SetPrefixAndDenom ¶
func (*Bridge) SetTokenConfig ¶
func (b *Bridge) SetTokenConfig(tokenAddr string, tokenCfg *tokens.TokenConfig)
SetTokenConfig set and verify token config
func (*Bridge) SignTransactionWithPrivateKey ¶
func (b *Bridge) SignTransactionWithPrivateKey(buildRawTx *BuildRawTx, privKey string) (signedTx interface{}, txHash string, err error)
SignTransactionWithPrivateKey sign tx with ECDSA private key
func (*Bridge) SimulateTx ¶
func (b *Bridge) SimulateTx(simulateReq *SimulateRequest) (string, error)
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyPubKey ¶
func (*Bridge) VerifyTransaction ¶
func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
VerifyTransaction impl
type BroadcastTxRequest ¶
type BroadcastTxResponse ¶
type BroadcastTxResponse struct {
TxResponse *TxResponse `protobuf:"bytes,1,opt,name=tx_response,json=txResponse,proto3" json:"tx_response,omitempty"`
}
type BuildRawTx ¶
type BuildRawTx struct { TxBuilder cosmosClient.TxBuilder `json:"tx_builder,omitempty"` AccountNumber uint64 `json:"account_number,omitempty"` Sequence uint64 `json:"sequence,omitempty"` }
type GasInfo ¶
type GasInfo struct { // GasUsed is the amount of gas actually consumed. GasUsed string `protobuf:"varint,2,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` }
GasInfo defines tx execution gas context.
type GetLatestBlockResponse ¶
type GetLatestBlockResponse struct { // Deprecated: please use `sdk_block` instead Block *Block `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` }
GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method.
type GetTxResponse ¶
type GetTxResponse struct { // The request transaction bytes. Tx *Tx `protobuf:"bytes,11,opt,name=tx,proto3" json:"tx,omitempty"` // tx_response is the queried TxResponses. TxResponse *TxResponse `protobuf:"bytes,2,opt,name=tx_response,json=txResponse,proto3" json:"tx_response,omitempty"` }
type Header ¶
type Header struct { // basic block info ChainID string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Height string `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` }
Header defines the structure of a Tendermint block header.
type QueryAccountResponse ¶
type QueryAccountResponse struct { // account defines the account of the corresponding address. Account *BaseAccount `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` }
QueryAccountResponse is the response type for the Query/Account RPC method.
type QueryAllBalancesResponse ¶
type QueryAllBalancesResponse struct { // balances is the balances of all the coins. Balances sdk.Coins `protobuf:"bytes,1,rep,name=balances,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balances"` }
QueryAllBalancesResponse balances
type SimulateRequest ¶
type SimulateRequest struct {
TxBytes string `json:"tx_bytes"`
}
SimulateRequest is the request type for the Service.Simulate RPC method.
type SimulateResponse ¶
type SimulateResponse struct { // gas_info is the information about gas used in the simulation. GasInfo *GasInfo `protobuf:"bytes,1,opt,name=gas_info,json=gasInfo,proto3" json:"gas_info,omitempty"` }
SimulateResponse is the response type for the Service.SimulateRPC method.
type Tx ¶
type Tx struct {
Body TxBody `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
}
Tx tx
type TxBody ¶
type TxBody struct { // memo is any arbitrary note/comment to be added to the transaction. // WARNING: in clients, any publicly exposed text should not be called memo, // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` }
type TxResponse ¶
type TxResponse struct { // The block height Height string `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` // The transaction hash. TxHash string `protobuf:"bytes,2,opt,name=txhash,proto3" json:"txhash,omitempty"` // Response code. Code uint32 `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"` // The output of the application's logger (typed). May be non-deterministic. Logs sdk.ABCIMessageLogs `protobuf:"bytes,7,rep,name=logs,proto3,castrepeated=ABCIMessageLogs" json:"logs"` }
TxResponse defines a structure containing relevant tx data and metadata. The tags are stringified and the log is JSON decoded.