Client
Extends xchain_client_1.BaseXChainClient
Custom Mayachain Client
Parameters
paramsXChainClientParamsparams.network(optional, defaultxchain_client_1.Network.Mainnet)params.phraseparams.clientUrl(optional, default{[xchain_client_1.Network.Testnet]:{node:'deprecated',rpc:'deprecated'},[xchain_client_1.Network.Stagenet]:{node:'https://stagenet.mayanode.mayachain.info',rpc:'https://stagenet.tendermint.mayachain.info'},[xchain_client_1.Network.Mainnet]:{node:'https://mayanode.mayachain.info',rpc:'https://tendermint.mayachain.info'}})params.explorerUrls(optional, defaultconst_1.defaultExplorerUrls)params.rootDerivationPaths(optional, default{[xchain_client_1.Network.Mainnet]:"44'/931'/0'/0/",[xchain_client_1.Network.Stagenet]:"44'/931'/0'/0/",[xchain_client_1.Network.Testnet]:"44'/931'/0'/0/"})params.chainIds(optional, default{[xchain_client_1.Network.Mainnet]:'mayachain-mainnet-v1',[xchain_client_1.Network.Stagenet]:'mayachain-stagenet-v1',[xchain_client_1.Network.Testnet]:'deprecated'})
getTransactions
Get transaction history of a given address with pagination options. By default it will return the transaction history of the current wallet.
Parameters
paramsTxHistoryParams The options to get transaction history. (optional)
Returns TxsPage The transaction history.
setNetwork
Set/update the current network.
Parameters
-
networkNetwork -
Throws
"Network must be provided"Thrown if network has not been set before.
Returns void
setClientUrl
Set/update the client URL.
Parameters
clientUrlClientUrl The client url to be set.
Returns void
getClientUrl
Get the client url.
Returns NodeUrl The client url for mayachain based on the current network.
setExplorerUrls
Set/update the explorer URLs.
Parameters
urlsExplorerUrls The explorer urls to be set.
Returns void
getExplorerUrl
Get the explorer url.
Returns string The explorer url for mayachain based on the current network.
setChainId
Sets chain id
Parameters
chainIdChainId Chain id to updatenetworkNetwork (optional) Network for given chainId. Ifnetworknot set, current network of the client is used
Returns void
getChainId
Gets chain id
Parameters
networkNetwork (optional) Network to get chain id from. Ifnetworknot set, current network of the client is used
Returns ChainId Chain id based on the current network.
getCosmosClient
Get cosmos client
Returns CosmosSDKClient current cosmos client
getExplorerAddressUrl
Get the explorer url for the given address.
Parameters
addressAddress
Returns string The explorer url for the given address.
getExplorerTxUrl
Get the explorer url for the given transaction id.
Parameters
txIDstring
Returns string The explorer url for the given transaction id.
getPrivateKey
Get private key
Parameters
-
indexnumber the HD wallet index (optional) (optional, default0) -
Throws
"Phrase not set"Throws an error if phrase has not been set before
Returns PrivKey The private key generated from the given phrase
getPubKey
Get public key
Parameters
-
indexnumber the HD wallet index (optional) (optional, default0) -
Throws
"Phrase not set"Throws an error if phrase has not been set before *
Returns PubKey The public key generated from the given phrase
getAddress
Get the current address.
Parameters
-
index(optional, default0) -
Throws Error Thrown if phrase has not been set before. A phrase is needed to create a wallet and to derive an address from it.
Returns Address The current address.
validateAddress
Validate the given address.
Parameters
addressAddress
Returns boolean true or false
getBalance
Get the balance of a given address.
Parameters
addressAddress By default, it will return the balance of the current wallet. (optional)assetsassetAsset If not set, it will return all assets available. (optional)
Returns Array<Balance> The balance of the address.
getTransactionData
Get the transaction details of a given transaction id.
Parameters
txIdstring The transaction id.address
Returns Tx The transaction details of the given transaction id.
getTransactionDataMayanode
This function is used when in bound or outbound tx is not of mayachain
Parameters
txIdtransaction hash
Returns any Tx object
getDepositTransaction
Get the transaction details of a given transaction id. (from /mayachain/txs/hash)
Node: /mayachain/txs/hash response doesn't have timestamp field.
Parameters
txIdstring The transaction id.
Returns Tx The transaction details of the given transaction id.
deposit
Transaction with MsgNativeTx.
Parameters
paramsDepositParam The transaction options.params.walletIndex(optional, default0)params.asset(optional, defaultconst_1.AssetCacao)params.amountparams.memoparams.gasLimit(optional, defaultnew bignumber_js_1.default(const_1.DEPOSIT_GAS_LIMIT_VALUE))params.sequence
- Throws
"insufficient funds"Thrown if the wallet has insufficient funds. - Throws
"Invalid transaction hash"Thrown by missing tx hash
Returns TxHash The transaction hash.
transfer
Transfer balances with MsgSend
Parameters
paramsTxParams The transfer options.params.walletIndex(optional, default0)params.asset(optional, defaultconst_1.AssetCacao)params.amountparams.recipientparams.memoparams.gasLimit(optional, defaultnew bignumber_js_1.default(const_1.DEFAULT_GAS_LIMIT_VALUE))params.sequence
- Throws
"insufficient funds"Thrown if the wallet has insufficient funds. - Throws
"Invalid transaction hash"Thrown by missing tx hash
Returns TxHash The transaction hash.
transferOffline
Transfer without broadcast balances with MsgSend
Parameters
paramsTxOfflineParams The transfer offline options.params.walletIndex(optional, default0)params.asset(optional, defaultconst_1.AssetCacao)params.amountparams.recipientparams.memoparams.fromCacaoBalanceparams.fromAssetBalance(optional, defaultxchain_util_1.baseAmount(0,const_1.DECIMAL))params.fromAccountNumber(optional, defaultlong_1.default.ZERO)params.fromSequence(optional, defaultlong_1.default.ZERO)params.gasLimit(optional, defaultnew bignumber_js_1.default(const_1.DEFAULT_GAS_LIMIT_VALUE))
Returns string The signed transaction bytes.
getFees
Gets fees from Node
Returns Fees