Skip to content

Commit

Permalink
Merge pull request #35 from GiMa-Maya/Maya
Browse files Browse the repository at this point in the history
Add Mayachain to the docs
  • Loading branch information
Thorian1te authored Jun 21, 2023
2 parents 98e76c5 + 95d6080 commit 1877cf9
Show file tree
Hide file tree
Showing 7 changed files with 787 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xchain-client/xchain-mayachain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sort: 6
---

# XCHAIN MAYAHAIN

Custom Mayachain client and utilities used by XChainJS clients

{% include list.liquid all=true %}
7 changes: 7 additions & 0 deletions xchain-client/xchain-mayachain/available-functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sort: 3
---

# Available Functions

{% include list.liquid all=true %}
290 changes: 290 additions & 0 deletions xchain-client/xchain-mayachain/available-functions/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# Client

**Extends xchain_client_1.BaseXChainClient**

Custom Mayachain Client

## Parameters

- `params` **XChainClientParams**
- `params.network` (optional, default `xchain_client_1.Network.Mainnet`)
- `params.phrase`
- `params.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, default `const_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

- `params` **TxHistoryParams** The options to get transaction history. (optional)

Returns **TxsPage** The transaction history.

## setNetwork

Set/update the current network.

### Parameters

- `network` **Network**


- Throws **`"Network must be provided"`** Thrown if network has not been set before.

Returns **void**

## setClientUrl

Set/update the client URL.

### Parameters

- `clientUrl` **ClientUrl** 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

- `urls` **ExplorerUrls** The explorer urls to be set.

Returns **void**

## getExplorerUrl

Get the explorer url.

Returns **[string][1]** The explorer url for mayachain based on the current network.

## setChainId

Sets chain id

### Parameters

- `chainId` **ChainId** Chain id to update
- `network` **Network** (optional) Network for given chainId. If `network`not set, current network of the client is used

Returns **void**

## getChainId

Gets chain id

### Parameters

- `network` **Network** (optional) Network to get chain id from. If `network`not 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

- `address` **Address**

Returns **[string][1]** The explorer url for the given address.

## getExplorerTxUrl

Get the explorer url for the given transaction id.

### Parameters

- `txID` **[string][1]**

Returns **[string][1]** The explorer url for the given transaction id.

## getPrivateKey

Get private key

### Parameters

- `index` **[number][2]** the HD wallet index (optional) (optional, default `0`)


- 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

- `index` **[number][2]** the HD wallet index (optional) (optional, default `0`)


- 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, default `0`)


- Throws **[Error][3]** 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

- `address` **Address**

Returns **[boolean][4]** `true` or `false`

## getBalance

Get the balance of a given address.

### Parameters

- `address` **Address** By default, it will return the balance of the current wallet. (optional)
- `assets`
- `asset` **Asset** If not set, it will return all assets available. (optional)

Returns **[Array][5]<Balance>** The balance of the address.

## getTransactionData

Get the transaction details of a given transaction id.

### Parameters

- `txId` **[string][1]** 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

- `txId` transaction 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

- `txId` **[string][1]** The transaction id.

Returns **Tx** The transaction details of the given transaction id.

## deposit

Transaction with MsgNativeTx.

### Parameters

- `params` **DepositParam** The transaction options.
- `params.walletIndex` (optional, default `0`)
- `params.asset` (optional, default `const_1.AssetCacao`)
- `params.amount`
- `params.memo`
- `params.gasLimit` (optional, default `new 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

- `params` **TxParams** The transfer options.
- `params.walletIndex` (optional, default `0`)
- `params.asset` (optional, default `const_1.AssetCacao`)
- `params.amount`
- `params.recipient`
- `params.memo`
- `params.gasLimit` (optional, default `new 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

- `params` **TxOfflineParams** The transfer offline options.
- `params.walletIndex` (optional, default `0`)
- `params.asset` (optional, default `const_1.AssetCacao`)
- `params.amount`
- `params.recipient`
- `params.memo`
- `params.fromCacaoBalance`
- `params.fromAssetBalance` (optional, default `xchain_util_1.baseAmount(0,const_1.DECIMAL)`)
- `params.fromAccountNumber` (optional, default `long_1.default.ZERO`)
- `params.fromSequence` (optional, default `long_1.default.ZERO`)
- `params.gasLimit` (optional, default `new bignumber_js_1.default(const_1.DEFAULT_GAS_LIMIT_VALUE)`)

Returns **[string][1]** The signed transaction bytes.

## getFees

Gets fees from Node

Returns **Fees**

[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
27 changes: 27 additions & 0 deletions xchain-client/xchain-mayachain/available-functions/const.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Const

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## MAYAChain

Chain identifier for Mayachain

## AssetCacao

- **See: [https://gitlab.com/mayachain/mayanode/-/blob/develop/common/asset.go#L38]
**

Base "chain" asset for CACAO on Mayachain main net.

Based on definition in Mayachain `common`


## AssetMaya

- **See: [https://gitlab.com/mayachain/mayanode/-/blob/develop/common/asset.go#L39]
**

Maya "chain" asset for MAYA on Mayachain main net.

Based on definition in Mayachain `common`

Loading

0 comments on commit 1877cf9

Please sign in to comment.