Utils
isAssetCacao or isAssetMaya
Checks whether an asset is AssetCacao or AssetMaya
Parameters
assetAsset
Returns boolean true or false
getDenom
Get denomination from Asset
Parameters
assetAsset
Returns string The denomination of the given asset.
assetFromDenom
Get Asset from denomination
Parameters
denomstring
Returns (Asset | null) The asset of the given denomination.
isBroadcastSuccess
Response guard for transaction broadcast
Parameters
responseany The response from the node.
Returns boolean true or false.
getPrefix
Get address prefix based on the network.
Parameters
networkNetwork
Returns string The address prefix based on the network.*
registerDepositCodecs
Register type for encoding MsgDeposit messages
registerSendCodecs
Register type for encoding MsgSend messages
getDepositTxDataFromLogs
Parse transaction data from event logs
Parameters
logsArray<TxLog> List of tx logsaddressAddress Address to get transaction data forsenderAssetreceiverAsset
Returns TxData Parsed transaction data
getDefaultFees
Get the default fee.
Returns Fees The default fee.
getTxType
Get transaction type.
Parameters
Returns string the transaction type.
getChainId
Helper to get MAYAChain's chain id
Parameters
nodeUrlstring MAYANode url
buildUnsignedTx
Builds final unsigned TX
Parameters
$0Object$0.cosmosSdk$0.txBody$0.signerPubkey$0.sequence$0.gasLimit
cosmosSdkCosmosSDKtxBodytxBody with encoded MsgssignerPubkeysignerPubkey stringsequenceaccount sequencegasLimittransaction gas limit
getEstimatedGas
Estimates usage of gas
Note: Be careful by using this helper function, it's still experimental and result might be incorrect. Change multiplier to get a valid estimation of gas.
Parameters
$0Object$0.cosmosSDKClient$0.txBody$0.privKey$0.accountNumber$0.accountSequence$0.multiplier
buildDepositTx
Structure a MsgDeposit
Parameters
$0Object$0.msgNativeTx$0.nodeUrl$0.chainId
msgNativeTxMsgNativeTx Msg of typeMsgNativeTx.nodeUrlstring Node url-
ChainIdchainId Chain id of the network - Throws
"Invalid client url"Thrown if the client url is an invalid one.
Returns Tx The transaction details of the given transaction id.
buildTransferTx
Structure a MsgSend
Parameters
$0Object$0.fromAddress$0.toAddress$0.assetAmount$0.assetDenom$0.memo(optional, default'')$0.nodeUrl$0.chainId
fromAddressrequired, from address stringtoAddressrequired, to address stringassetAmountrequired, asset amount string (e.g. "10000")assetDenomrequired, asset denom string (e.g. "cacao")memooptional, memo string
getBalance
Get the balance of a given address.
Parameters
$0Object$0.address$0.assets$0.cosmosClient
addressAddress By default, it will return the balance of the current wallet. (optional)assetAsset If not set, it will return all assets available. (optional)CosmosSDKClientcosmosClient
Returns Array<Balance> The balance of the address.
getExplorerUrl
Get the explorer url.
Parameters
networkNetworknetwork.root
networkNetworknetwork.root
ExplorerExplorerUrls urls
Returns string The explorer url for mayachain based on the given network.
getExplorerAddressUrl
Get explorer address url.
Parameters
$0Object$0.urls$0.network$0.address
ExplorerExplorerUrls urlsnetworkNetworkaddressAddress
Returns string The explorer url for the given address.
getExplorerTxUrl
Get transaction url.
Parameters
$0Object$0.urls$0.network$0.txID
ExplorerExplorerUrls urlsnetworkNetworktxIDTxHash
Returns string The explorer url for the given transaction id.