Utils
isAssetCacao or isAssetMaya
Checks whether an asset is AssetCacao
or AssetMaya
Parameters
asset
Asset
Returns boolean true
or false
getDenom
Get denomination from Asset
Parameters
asset
Asset
Returns string The denomination of the given asset.
assetFromDenom
Get Asset from denomination
Parameters
denom
string
Returns (Asset | null) The asset of the given denomination.
isBroadcastSuccess
Response guard for transaction broadcast
Parameters
response
any The response from the node.
Returns boolean true
or false
.
getPrefix
Get address prefix based on the network.
Parameters
network
Network
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
logs
Array<TxLog> List of tx logsaddress
Address Address to get transaction data forsenderAsset
receiverAsset
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
nodeUrl
string MAYANode url
buildUnsignedTx
Builds final unsigned TX
Parameters
$0
Object$0.cosmosSdk
$0.txBody
$0.signerPubkey
$0.sequence
$0.gasLimit
cosmosSdk
CosmosSDKtxBody
txBody with encoded MsgssignerPubkey
signerPubkey stringsequence
account sequencegasLimit
transaction 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
$0
Object$0.cosmosSDKClient
$0.txBody
$0.privKey
$0.accountNumber
$0.accountSequence
$0.multiplier
buildDepositTx
Structure a MsgDeposit
Parameters
$0
Object$0.msgNativeTx
$0.nodeUrl
$0.chainId
msgNativeTx
MsgNativeTx Msg of typeMsgNativeTx
.nodeUrl
string Node url-
ChainId
chainId 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
$0
Object$0.fromAddress
$0.toAddress
$0.assetAmount
$0.assetDenom
$0.memo
(optional, default''
)$0.nodeUrl
$0.chainId
fromAddress
required, from address stringtoAddress
required, to address stringassetAmount
required, asset amount string (e.g. "10000")assetDenom
required, asset denom string (e.g. "cacao")memo
optional, memo string
getBalance
Get the balance of a given address.
Parameters
$0
Object$0.address
$0.assets
$0.cosmosClient
address
Address By default, it will return the balance of the current wallet. (optional)asset
Asset If not set, it will return all assets available. (optional)CosmosSDKClient
cosmosClient
Returns Array<Balance> The balance of the address.
getExplorerUrl
Get the explorer url.
Parameters
network
Networknetwork.root
network
Networknetwork.root
Explorer
ExplorerUrls urls
Returns string The explorer url for mayachain based on the given network.
getExplorerAddressUrl
Get explorer address url.
Parameters
$0
Object$0.urls
$0.network
$0.address
Explorer
ExplorerUrls urlsnetwork
Networkaddress
Address
Returns string The explorer url for the given address.
getExplorerTxUrl
Get transaction url.
Parameters
$0
Object$0.urls
$0.network
$0.txID
Explorer
ExplorerUrls urlsnetwork
NetworktxID
TxHash
Returns string The explorer url for the given transaction id.