From f1dd237e62240c07d7cfa987b55ba31d25f2e100 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 14:09:09 +0200 Subject: [PATCH 01/11] xchain-midgard-query docs --- xchain-midgard-query/README.md | 9 ++++ .../available-functions/README.md | 7 +++ .../available-functions/midgard-cache.md | 31 +++++++++++ .../available-functions/midgard-query.md | 54 +++++++++++++++++++ xchain-midgard-query/how-it-works.md | 21 ++++++++ xchain-midgard-query/how-to-use.md | 42 +++++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 xchain-midgard-query/README.md create mode 100644 xchain-midgard-query/available-functions/README.md create mode 100644 xchain-midgard-query/available-functions/midgard-cache.md create mode 100644 xchain-midgard-query/available-functions/midgard-query.md create mode 100644 xchain-midgard-query/how-it-works.md create mode 100644 xchain-midgard-query/how-to-use.md diff --git a/xchain-midgard-query/README.md b/xchain-midgard-query/README.md new file mode 100644 index 00000000..07ec4df7 --- /dev/null +++ b/xchain-midgard-query/README.md @@ -0,0 +1,9 @@ +--- +sort: 3 +--- + +# MIDGARD-QUERY + +Custom midgard query package + +{% include list.liquid all=true %} diff --git a/xchain-midgard-query/available-functions/README.md b/xchain-midgard-query/available-functions/README.md new file mode 100644 index 00000000..5d8cb49f --- /dev/null +++ b/xchain-midgard-query/available-functions/README.md @@ -0,0 +1,7 @@ +--- +sort: 3 +--- + +# Available Functions + +{% include list.liquid all=true %} diff --git a/xchain-midgard-query/available-functions/midgard-cache.md b/xchain-midgard-query/available-functions/midgard-cache.md new file mode 100644 index 00000000..4de3591a --- /dev/null +++ b/xchain-midgard-query/available-functions/midgard-cache.md @@ -0,0 +1,31 @@ +# Midgard Cache + + + +## MidgardCache + +This class retrieves raw information from Midgard API and cached it + +### Parameters + +- `midgard` **Midgard** an instance of the midgard API (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultMidgard`) + +### getPools + +Get info about existing pools in the protocol from Midgard API + +Returns **[Array][1]<PoolDetail>** Array of pools + +### getSavers + +Returns the information of all the positions of a set of addresses in the THORChain savers product. + +#### Parameters + +- `address` **[String][2]** Comma separated list of addresses + +Returns **SaverDetails** Array of savers positions + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String diff --git a/xchain-midgard-query/available-functions/midgard-query.md b/xchain-midgard-query/available-functions/midgard-query.md new file mode 100644 index 00000000..b23d9fc7 --- /dev/null +++ b/xchain-midgard-query/available-functions/midgard-query.md @@ -0,0 +1,54 @@ +# Midgard Query + + + +## MidgardQuery + +Class for getting data and process from Midgard API using MidgardCache for optimize request number (THORChain L2 Api). + +### Parameters + +- `midgardCache` an instance of the midgardCache (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultCache`) + +### getPool + +Get pool by asset + +#### Parameters + +- `asset` **[string][1]** In example: BTC.BTC + + +- Throws **[Error][2]** Can't find pool for asset + +Returns **PoolDetail** Details of selected pool + +### getSaverPositions + +Get saver positions by array of saver descriptions + +#### Parameters + +- `params` **[Array][3]<getSaver>** array of search conditions + +Returns **[Array][3]<SaversPosition>** Information on the positions found + +### getDecimalForAsset + +Returns number of decimals by asset + +#### Parameters + +- `asset` **Asset** asset for getting decimals + +Returns **[number][4]** Number of decimals from Midgard [https://gitlab.com/thorchain/midgard#refresh-native-decimals][5] + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[5]: https://gitlab.com/thorchain/midgard#refresh-native-decimals diff --git a/xchain-midgard-query/how-it-works.md b/xchain-midgard-query/how-it-works.md new file mode 100644 index 00000000..d729d31a --- /dev/null +++ b/xchain-midgard-query/how-it-works.md @@ -0,0 +1,21 @@ +--- +sort: 1 +--- + +# How it works + +Midgard-query module use Midgard Api's to query [Midgard API]. + +Midgard is a layer 2 REST API that provides *front-end consumers with semi real-time* rolled up data +and analytics of the THORChain network. Most requests to the network will come through Midgard. This +daemon is here to keep the chain itself from fielding large quantities of requests. You can think of +it as a “read-only slave” to the chain. This keeps the resources of the network focused on +processing transactions. + +## Dependencies + +* [`@xchainjs/xchain-client`](http://docs.xchainjs.org/xchain-client/interface.html) +* [`@xchainjs/xchain-util`](http://docs.xchainjs.org/xchain-util/how-to-use.html) +* [`@xchainjs/xchain-midgard`](http://docs.xchainjs.org/xchain-midgard-query/how-to-use.html) + +[Midgard API]: https://gitlab.com/thorchain/midgard/-/tree/develop?ref_type=heads \ No newline at end of file diff --git a/xchain-midgard-query/how-to-use.md b/xchain-midgard-query/how-to-use.md new file mode 100644 index 00000000..79084823 --- /dev/null +++ b/xchain-midgard-query/how-to-use.md @@ -0,0 +1,42 @@ +--- +sort: 2 +--- + +# How to use + +## Installation + +``` +yarn add @xchainjs/xchain-midgard-query +``` + +Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-midgard-query`. + +``` +yarn add @xchainjs/xchain-client @xchainjs/xchain-util @xchainjs/xchain-midgard axios axios-retry bignumber.js +``` + +## Basic usage examples +```ts +import { AssetBTC } from '@xchainjs/xchain-bitcoin' +import { AssetATOM } from '@xchainjs/xchain-cosmos' +import { Midgard, MidgardCache, MidgardQuery, SaversPosition } from '@xchainjs/xchain-midgard-query' +import { Network } from '@xchainjs/xchain-client' + +const saverBtc: getSaver = { + asset: AssetBTC, + address: '', +} +const saverAtom: getSaver = { + asset: AssetATOM, + address: '', +} + +const midgardCache = new MidgardCache(new Midgard(Network.Testnet)) +const midgardQuery = new MidgardQuery(midgardCache) +// Get saver positions (cached) +const getSavers: SaversPosition[] = await midgardQuery.getSaverPositions([saverAtom, saverBtc]) +// Get thorname info (no cached) +const thorname = await midgardQuery.midgardCache.midgard.getTHORNameDetails('gx') +``` + From 1e7c040316e4c9863104e422ca653d002fcb3604 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 14:10:07 +0200 Subject: [PATCH 02/11] Docs xchain-evm-providers --- gulpfile.js | 4 ++ xchain-evm-providers/README.md | 8 ++++ xchain-evm-providers/how-it-works.md | 40 ++++++++++++++++++ xchain-evm-providers/how-to-use.md | 62 ++++++++++++++++++++++++++++ xchain-utxo-providers/README.md | 2 +- 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 xchain-evm-providers/README.md create mode 100644 xchain-evm-providers/how-it-works.md create mode 100644 xchain-evm-providers/how-to-use.md diff --git a/gulpfile.js b/gulpfile.js index 0862be8f..be6c151d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -35,6 +35,10 @@ var packages = [ module: 'xchain-thorchain-query', path: 'xchain-thorchain-query/available-functions', }, + { + module: 'xchain-midgard-query', + path: 'xchain-midgard-query/available-functions', + }, { module: 'xchain-midgard', path: 'xchain-midgard/available-functions', diff --git a/xchain-evm-providers/README.md b/xchain-evm-providers/README.md new file mode 100644 index 00000000..18d0cbd3 --- /dev/null +++ b/xchain-evm-providers/README.md @@ -0,0 +1,8 @@ +--- +sort: 3 +--- + +# XCHAIN EVM PROVIDERS + +Client implementation of several data provider APIs that can be complemented to obtain greater resilience when working with EVM chains. + diff --git a/xchain-evm-providers/how-it-works.md b/xchain-evm-providers/how-it-works.md new file mode 100644 index 00000000..5012b555 --- /dev/null +++ b/xchain-evm-providers/how-it-works.md @@ -0,0 +1,40 @@ +--- +sort: 1 +--- + +# How it works + +## Design + +```typescript +import { Address, Asset } from '@xchainjs/xchain-util' + +import { ExplorerProvider } from './explorer-provider' +import { Balance, Network, Tx, TxHash, TxHistoryParams, TxsPage } from './types' + +export interface OnlineDataProvider { + getBalance(address: Address, assets?: Asset[]): Promise + getTransactions(params: TxHistoryParams): Promise + getTransactionData(txId: string, assetAddress?: Address): Promise +} +``` + +## Implementations + +### Etherscan / bscscan / snowtrace + +``` +Websites: https://snowtrace.io/ , https://bscscan.com/ , https://etherscan.io/ +Status: Complete +FreeTier: Yes +Chains supported: ETH, BSC, ETH +``` + +### Covalent + +``` +Website: https://www.covalenthq.com/ +Status: Complete +FreeTier: Yes +Chains supported: ETH, BSC, ETH +``` diff --git a/xchain-evm-providers/how-to-use.md b/xchain-evm-providers/how-to-use.md new file mode 100644 index 00000000..f7c33126 --- /dev/null +++ b/xchain-evm-providers/how-to-use.md @@ -0,0 +1,62 @@ +--- +sort: 2 +--- + +# How to use + +## Installation + +```bash +yarn add @xchainjs/xchain-evm-providers +``` + +## Example + +```typescript + import { AssetETH, ETHChain } from '@xchainjs/xchain-ethereum' + import { Client as EthClient } from '@xchainjs/xchain-ethereum' + + // Chain ids list: https://www.covalenthq.com/docs/networks/ + const COVALENT_ONLINE_PROVIDER_MAINNET = new CovalentProvider(process.env.COVALENT_API_KEY as string, ETHChain, 1, AssetETH, 18) + + const covalentProviders = { + [Network.Mainnet]: COVALENT_ONLINE_PROVIDER_MAINNET, + [Network.Testnet]: COVALENT_ONLINE_PROVIDER_MAINNET, + [Network.Stagenet]: COVALENT_ONLINE_PROVIDER_MAINNET, + } + + const ETHERSCAN_ONLINE_PROVIDER_MAINNET = new EtherscanProvider( + ETH_MAINNET_ETHERS_PROVIDER, + 'https://api.etherscan.io/', + process.env['ETHERSCAN_API'] || '', + ETHChain, + AssetETH, + ETH_GAS_ASSET_DECIMAL, + ) + + const ethscanProviders = { + [Network.Mainnet]: ETHERSCAN_ONLINE_PROVIDER_MAINNET, + [Network.Testnet]: ETHERSCAN_ONLINE_PROVIDER_MAINNET, + [Network.Stagenet]: ETHERSCAN_ONLINE_PROVIDER_MAINNET, + } + + export const defaultEthParams: EVMClientParams = { + chain: ETHChain, + gasAsset: AssetETH, + gasAssetDecimals: ETH_GAS_ASSET_DECIMAL, + defaults, + providers: ethersJSProviders, + explorerProviders: ethExplorerProviders, + dataProviders: [ethscanProviders, covalentProviders], + network: Network.Testnet, + feeBounds: { + lower: LOWER_FEE_BOUND, + upper: UPPER_FEE_BOUND, + }, + rootDerivationPaths: ethRootDerivationPaths, + } + + const client = new EthClient({ ...defaultEthParams, network: settings.network, phrase }), +``` + + diff --git a/xchain-utxo-providers/README.md b/xchain-utxo-providers/README.md index f36c85f1..65a78109 100644 --- a/xchain-utxo-providers/README.md +++ b/xchain-utxo-providers/README.md @@ -4,5 +4,5 @@ sort: 3 # XCHAIN UTXO PROVIDERS -A specification for a generalised interface for api providers, to be used by XChainJS implementations. The providers should not have any functionality to generate a key, instead, the `asgardex-crypto` library should be used to ensure cross-chain compatible keystores are handled. The providers is only ever passed a master BIP39 phrase, from which a temporary key and address is decoded. +A specification for a generalised interface for api providers, to be used by XChainJS implementations. The providers should not have any functionality to generate a key, instead, the `xchain-crypto` library should be used to ensure cross-chain compatible keystores are handled. The providers is only ever passed a master BIP39 phrase, from which a temporary key and address is decoded. From 1920349b89b24a762c0f3b1bb31dffe2c1ca8a1d Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 16:56:03 +0200 Subject: [PATCH 03/11] Create docs xchain-cosmos-sdk --- xchain-cosmos-sdk/README.md | 9 +++ .../available-functions/README.md | 7 ++ .../available-functions/client.md | 81 +++++++++++++++++++ xchain-cosmos-sdk/how-to-use.md | 28 +++++++ .../available-functions/types.md | 3 + 5 files changed, 128 insertions(+) create mode 100644 xchain-cosmos-sdk/README.md create mode 100644 xchain-cosmos-sdk/available-functions/README.md create mode 100644 xchain-cosmos-sdk/available-functions/client.md create mode 100644 xchain-cosmos-sdk/how-to-use.md create mode 100644 xchain-midgard-query/available-functions/types.md diff --git a/xchain-cosmos-sdk/README.md b/xchain-cosmos-sdk/README.md new file mode 100644 index 00000000..d3c6f452 --- /dev/null +++ b/xchain-cosmos-sdk/README.md @@ -0,0 +1,9 @@ +--- +sort: 3 +--- + +# XCHAIN COSMOS SDK + +Generic implementation of the `XChainClient` interface to work with strings built with [cosmos-sdk] using the dependencies of the official cosmjs monorepo. + +[cosmos-sdk]: https://docs.cosmos.network/ \ No newline at end of file diff --git a/xchain-cosmos-sdk/available-functions/README.md b/xchain-cosmos-sdk/available-functions/README.md new file mode 100644 index 00000000..1f125142 --- /dev/null +++ b/xchain-cosmos-sdk/available-functions/README.md @@ -0,0 +1,7 @@ +--- +sort: 2 +--- + +# Available Functions + +{% include list.liquid all=true %} diff --git a/xchain-cosmos-sdk/available-functions/client.md b/xchain-cosmos-sdk/available-functions/client.md new file mode 100644 index 00000000..b4d1b014 --- /dev/null +++ b/xchain-cosmos-sdk/available-functions/client.md @@ -0,0 +1,81 @@ +# Client + +**Extends xchain_client_1.BaseXChainClient** + +Generic implementation of the XChainClient interface to work with strings built with cosmos-sdk ([https://docs.cosmos.network/][1]) using the dependencies of the official @cosmjs monorepo. + +## Parameters + +- `params` **CosmosSdkClientParams** client configuration (prefix, decimal, fees, urls...) + +## getFees + +This function returns the fee object in a generalised way for a simple transfer function. In this case this funcion use the default fee +defined in the constructor. + +Returns **Fees** fees estimation for average, fast and fastests scenarios. + +## getAddress + +Get an address derived from the phrase defined in the constructor. + +### Parameters + +- `walletIndex` **([number][2] \| [undefined][3])** derivation path index of address that will be generated + +Returns **[string][4]** user address at index defined on walletIndex + +## validateAddress + +Validate the address format. + +### Parameters + +- `address` **[string][4]** address to be validated + +Returns **[boolean][5]** represents whether the address is valid or invalid + +## getBalance + +Obtains all the balances of the address passed as parameter for all the assets of the network. For the moment for this client the assets parameter is ignored. +Do not hesitate to open a PR if you need it and it is not yet available. + +### Parameters + +- `address` **[string][4]** address to be validated +- `_assets` **([Array][6]<Asset> \| [undefined][3])** IGNORED FOR THIS IMPLEMENTATION + +Returns **[Array][6]<Balance>** array of balances + +## getTransactions + +Get transactions filtered using params + +### Parameters + +- `params` **(TxHistoryParams \| [undefined][3])** Only param address IS SUPPORTED FOR THIS CLIENT, new feature will be added in the future + +Returns **TxsPage** array of balances + +## getTransactionData + +Get transaction info using txId + +### Parameters + +- `txId` **[string][4]** Idetifier of transaction +- `_assetAddress` + +Returns **Tx** Transaction data + +[1]: https://docs.cosmos.network/ + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean + +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array diff --git a/xchain-cosmos-sdk/how-to-use.md b/xchain-cosmos-sdk/how-to-use.md new file mode 100644 index 00000000..faf480e9 --- /dev/null +++ b/xchain-cosmos-sdk/how-to-use.md @@ -0,0 +1,28 @@ +--- +sort: 1 +--- + +# How to use + +## Installation + +```bash +yarn add @xchainjs/xchain-cosmos-sdk +``` + +The following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-cosmos-sdk`. + +```bash +yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util +``` + +## Basic example usage + +This package is perfect if you need support for a chain built on top of Cosmos-sdk that is not yet supported within Xchain. You may need to override some methods if the chain in question has specific behaviors. + +If you do so, don't forget to leave it in PR so that other community members can use your work. + +You can check [here] an example of usage + +[here]: https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-kujira/src/client.ts + diff --git a/xchain-midgard-query/available-functions/types.md b/xchain-midgard-query/available-functions/types.md new file mode 100644 index 00000000..74310221 --- /dev/null +++ b/xchain-midgard-query/available-functions/types.md @@ -0,0 +1,3 @@ +# Types + + From 37124ded501055d47a88836935a536c1820af237 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:22:01 +0200 Subject: [PATCH 04/11] Add clients Kujira and BSC --- xchain-client/xchain-bsc/README.md | 9 +++ xchain-client/xchain-bsc/how-it-works.md | 25 +++++++++ xchain-client/xchain-bsc/how-to-use.md | 62 +++++++++++++++++++++ xchain-client/xchain-ethereum/how-to-use.md | 2 +- xchain-client/xchain-kuji/README.md | 9 +++ xchain-client/xchain-kuji/how-it-works.md | 22 ++++++++ xchain-client/xchain-kuji/how-to-use.md | 32 +++++++++++ 7 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 xchain-client/xchain-bsc/README.md create mode 100644 xchain-client/xchain-bsc/how-it-works.md create mode 100644 xchain-client/xchain-bsc/how-to-use.md create mode 100644 xchain-client/xchain-kuji/README.md create mode 100644 xchain-client/xchain-kuji/how-it-works.md create mode 100644 xchain-client/xchain-kuji/how-to-use.md diff --git a/xchain-client/xchain-bsc/README.md b/xchain-client/xchain-bsc/README.md new file mode 100644 index 00000000..0d8b2c01 --- /dev/null +++ b/xchain-client/xchain-bsc/README.md @@ -0,0 +1,9 @@ +--- +sort: 3 +--- + +# XCHAIN BSC + +Custom Binance smart chain client and utilities used by XChainJS clients + +{% include list.liquid all=true %} diff --git a/xchain-client/xchain-bsc/how-it-works.md b/xchain-client/xchain-bsc/how-it-works.md new file mode 100644 index 00000000..931284ad --- /dev/null +++ b/xchain-client/xchain-bsc/how-it-works.md @@ -0,0 +1,25 @@ +--- +sort: 1 +--- + +# How it works + +This package uses etherjs library, by default it uses several providers. (https://docs.ethers.io/v5/api-keys/) + +### Explorer URL +* Mainnet:[`https://bscscan.com`](https://bscscan.com) +* Testnet:[`https://testnet.bscscan.com`](https://testnet.bscscan.com) + +## RPC Ethers Providers +* Mainnet:[`https://rpc.ankr.com/bsc`](https://rpc.ankr.com/bsc) +* Testnet:[`https://bsc-testnet.public.blastapi.io`](https://bsc-testnet.public.blastapi.io) + +## Dependencies + +* [`@xchainjs/xchain-client`](http://docs.xchainjs.org/xchain-client/interface.html) +* [`@xchainjs/xchain-crypto`](http://docs.xchainjs.org/xchain-crypto/how-to-use.html) +* [`@xchainjs/xchain-util`](http://docs.xchainjs.org/xchain-util/how-to-use.html) +* [`@xchainjs/xchain-evm-providers`](http://docs.xchainjs.org/@xchainjs/xchain-evm-providers/how-to-use.html) +* [`@xchainjs/xchain-evm-providers`](http://docs.xchainjs.org/@xchainjs/xchain-evm-providers/how-to-use.html) +* @xchainjs/xchain-evm + diff --git a/xchain-client/xchain-bsc/how-to-use.md b/xchain-client/xchain-bsc/how-to-use.md new file mode 100644 index 00000000..d757dfe4 --- /dev/null +++ b/xchain-client/xchain-bsc/how-to-use.md @@ -0,0 +1,62 @@ +--- +sort: 2 +--- + +# How to use + +## Installation + +``` +yarn add @xchainjs/xchain-bsc +``` + +Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-bsc`. + +``` +yarn add @xchainjs/xchain-evm @xchainjs/xchain-evm-providers @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers +``` + +## Client Testing + +``` +yarn install +yarn test +``` + +## Basic Usage Example +###Imports +```ts +import { Client, defaultBscParams, AssetBSC } from "@xchainjs/xchain-bsc" +import { FeeOption } from "@xchainjs/xchain-client" +import { assetToBase, baseToAsset, assetAmount, Asset, Chain } from "@xchainjs/xchain-util" +``` + +### Connect wallet to new Bsc Chain Client +Network default is Mainnet +```ts +// Create new Bsc Asset +const assetRIP: Asset = { + chain: AssetBSC.chain, + symbol: `RIP-0x224695ba2a98e4a096a519b503336e06d9116e48`, + ticker: `RIP`, + synth: false, + } +// Create new Bsc Client Instance +const connectWallet =async () => { + defaultBscParams.phrase = "phrase" + const bscClient = new Client(defaultBscParams) + let address = bscClient.getAddress() + console.log(`Address: ${address}`) + let isValid = bscClient.validateAddress(address) + if( isValid === true ){ + try { + const balance = await bscClient.getBalance(address) + let assetAmount = (baseToAsset(balance[1].amount)).amount() + console.log(`With balance: ${assetAmount}`) + + } catch (error) { + console.log(`Caught: ${error}`) + } + } +} +``` \ No newline at end of file diff --git a/xchain-client/xchain-ethereum/how-to-use.md b/xchain-client/xchain-ethereum/how-to-use.md index bee492a1..0362e5e3 100644 --- a/xchain-client/xchain-ethereum/how-to-use.md +++ b/xchain-client/xchain-ethereum/how-to-use.md @@ -13,7 +13,7 @@ yarn add @xchainjs/xchain-ethereum Following peer dependencies have to be installed into your project. These are not included in `ethers`. ```bash -yarn add axios ethers +yarn add @xchainjs/xchain-evm @xchainjs/xchain-evm-providers @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers ``` ## Ethereum Client Testing diff --git a/xchain-client/xchain-kuji/README.md b/xchain-client/xchain-kuji/README.md new file mode 100644 index 00000000..778f209b --- /dev/null +++ b/xchain-client/xchain-kuji/README.md @@ -0,0 +1,9 @@ +--- +sort: 3 +--- + +# XCHAIN KUJI + +Custom Kuji client and utilities used by XChainJS clients + +{% include list.liquid all=true %} diff --git a/xchain-client/xchain-kuji/how-it-works.md b/xchain-client/xchain-kuji/how-it-works.md new file mode 100644 index 00000000..d516b7ea --- /dev/null +++ b/xchain-client/xchain-kuji/how-it-works.md @@ -0,0 +1,22 @@ +--- +sort: 1 +--- + +# How it works + +This package uses cosmjs libraries, to interact with Kujira blockchain. + +### Explorer URL +* Mainnet:[`https://rpc.cosmos.directory/kujira/`](https://rpc.cosmos.directory/kujira/) +* Testnet:[`https://test-rpc-kujira.mintthemoon.xyz`](https://test-rpc-kujira.mintthemoon.xyz) + +## RPC Ethers Providers +* Mainnet:[`https://finder.kujira.network/kaiyo-1`](https://finder.kujira.network/kaiyo-1) +* Testnet:[`https://finder.kujira.network/harpoon-4`](https://finder.kujira.network/harpoon-4) + +## Dependencies + +* [`@xchainjs/xchain-client`](http://docs.xchainjs.org/xchain-client/interface.html) +* [`@xchainjs/xchain-crypto`](http://docs.xchainjs.org/xchain-crypto/how-to-use.html) +* [`@xchainjs/xchain-util`](http://docs.xchainjs.org/xchain-util/how-to-use.html) + diff --git a/xchain-client/xchain-kuji/how-to-use.md b/xchain-client/xchain-kuji/how-to-use.md new file mode 100644 index 00000000..09113190 --- /dev/null +++ b/xchain-client/xchain-kuji/how-to-use.md @@ -0,0 +1,32 @@ +--- +sort: 2 +--- + +# How to use + +## Installation + +``` +yarn add @xchainjs/xchain-kuji +``` + +Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-kuji`. + +``` +yarn add @xchainjs/xchain-cosmos-sdk @xchainjs/xchain-client @xchainjs/xchain-util +``` + +## Basic Usage Example +###Imports +```ts +import { Client } from "@xchainjs/xchain-kuji" +``` + +### Initialize Kuji client +Network default is Mainnet +```ts +kujiClientWithDefaultParams = new KujiraClient({ + network: Network.Testnet, + phrase: phraseOne, +}) +``` From 304f9e20c3df7be638bd56949ee33b96bf340d93 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:22:12 +0200 Subject: [PATCH 05/11] Update gulpfile --- gulpfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index be6c151d..125c6a8e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,6 +39,10 @@ var packages = [ module: 'xchain-midgard-query', path: 'xchain-midgard-query/available-functions', }, + { + module: 'xchain-cosmos-sdk', + path: 'xchain-cosmos-sdk/available-functions', + }, { module: 'xchain-midgard', path: 'xchain-midgard/available-functions', From 840bdbbaa4d707042247ea00cb2c8c17b17a2651 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:35:40 +0200 Subject: [PATCH 06/11] Update xchain-thorchain-query and document utility cached-value --- gulpfile.js | 4 - .../available-functions/etherscan-api.md | 99 ------ .../available-functions/ethplorer-api.md | 80 ----- .../available-functions/utils.md | 291 ------------------ xchain-midgard/available-functions/config.md | 3 - .../available-functions/README.md | 0 .../available-functions/liquidity-pool.md | 1 - .../available-functions/thorchain-cache.md | 39 +-- .../available-functions/thorchain-query.md | 146 ++++----- xchain-thorchain-query/how-it-works.md | 9 +- .../available-functions/cached-value.md | 24 ++ .../available-functions/crypto-amount.md | 26 ++ 12 files changed, 132 insertions(+), 590 deletions(-) delete mode 100644 xchain-client/xchain-ethereum/available-functions/etherscan-api.md delete mode 100644 xchain-client/xchain-ethereum/available-functions/ethplorer-api.md delete mode 100644 xchain-client/xchain-ethereum/available-functions/utils.md delete mode 100644 xchain-midgard/available-functions/config.md rename {xchain-midgard => xchain-thorchain-query}/available-functions/README.md (100%) create mode 100644 xchain-util/available-functions/cached-value.md create mode 100644 xchain-util/available-functions/crypto-amount.md diff --git a/gulpfile.js b/gulpfile.js index 125c6a8e..c178227e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,10 +43,6 @@ var packages = [ module: 'xchain-cosmos-sdk', path: 'xchain-cosmos-sdk/available-functions', }, - { - module: 'xchain-midgard', - path: 'xchain-midgard/available-functions', - }, { module: 'xchain-thornode', path: 'xchain-thornode/available-functions', diff --git a/xchain-client/xchain-ethereum/available-functions/etherscan-api.md b/xchain-client/xchain-ethereum/available-functions/etherscan-api.md deleted file mode 100644 index 2a2a0487..00000000 --- a/xchain-client/xchain-ethereum/available-functions/etherscan-api.md +++ /dev/null @@ -1,99 +0,0 @@ -# Etherscan Api - - - -## getGasOracle - -- **See: [https://etherscan.io/apis#gastracker][1] - ** - -SafeGasPrice, ProposeGasPrice And FastGasPrice returned in string-Gwei - -### Parameters - -- `baseUrl` **[string][2]** The etherscan node url. -- `apiKey` **[string][2]** The etherscan API key. (optional) - -Returns **GasOracleResponse** LastBlock, SafeGasPrice, ProposeGasPrice, FastGasPrice - -## getTokenBalance - -- **See: [https://etherscan.io/apis#tokens][3] - ** - -Get token balance - -### Parameters - -- `$0` **[Object][4]** - - `$0.baseUrl` - - `$0.address` - - `$0.assetAddress` - - `$0.apiKey` -- `baseUrl` **[string][2]** The etherscan node url. -- `address` **[string][2]** The address. -- `assetAddress` **[string][2]** The token contract address. -- `apiKey` **[string][2]** The etherscan API key. (optional) - -Returns **BigNumberish** The token balance - -## getETHTransactionHistory - -- **See: [https://etherscan.io/apis#accounts][5] - ** - -Get ETH transaction history - -### Parameters - -- `$0` **[Object][4]** - - `$0.baseUrl` - - `$0.address` - - `$0.page` - - `$0.offset` - - `$0.startblock` - - `$0.endblock` - - `$0.apiKey` -- `baseUrl` **[string][2]** The etherscan node url. -- `address` **[string][2]** The address. -- `params` **TransactionHistoryParam** The search options. -- `apiKey` **[string][2]** The etherscan API key. (optional) - -Returns **[Array][6]<ETHTransactionInfo>** The ETH transaction history - -## getTokenTransactionHistory - -- **See: [https://etherscan.io/apis#accounts][5] - ** - -Get token transaction history - -### Parameters - -- `$0` **[Object][4]** - - `$0.baseUrl` - - `$0.address` - - `$0.assetAddress` - - `$0.page` - - `$0.offset` - - `$0.startblock` - - `$0.endblock` - - `$0.apiKey` -- `baseUrl` **[string][2]** The etherscan node url. -- `address` **[string][2]** The address. -- `params` **TransactionHistoryParam** The search options. -- `apiKey` **[string][2]** The etherscan API key. (optional) - -Returns **[Array][6]<Tx>** The token transaction history - -[1]: https://etherscan.io/apis#gastracker - -[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[3]: https://etherscan.io/apis#tokens - -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - -[5]: https://etherscan.io/apis#accounts - -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array diff --git a/xchain-client/xchain-ethereum/available-functions/ethplorer-api.md b/xchain-client/xchain-ethereum/available-functions/ethplorer-api.md deleted file mode 100644 index 3a97b10d..00000000 --- a/xchain-client/xchain-ethereum/available-functions/ethplorer-api.md +++ /dev/null @@ -1,80 +0,0 @@ -# Ethplorer Api - - - -## getAddress - -- **See: [https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-address-info][1] - ** - -Get address information. - -### Parameters - -- `baseUrl` **[string][2]** The ethplorer api url. -- `address` **[string][2]** -- `apiKey` **[string][2]** The ethplorer API key. (optional) - -Returns **AddressInfo** The address information. - -## getTxInfo - -- **See: [https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-transaction-info][3] - ** - -Get transaction by hash. - -### Parameters - -- `baseUrl` **[string][2]** The ethplorer api url. -- `hash` **[string][2]** The transaction hash. -- `apiKey` **[string][2]** The ethplorer API key. (optional) - -Returns **Transactions** The transaction result. - -## getAddressTransactions - -- **See: [https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-address-transactions][4] - ** - -Get ETH transactions. - -### Parameters - -- `baseUrl` **[string][2]** The ethplorer api url. -- `address` **[string][2]** The transaction hash. -- `limit` **[number][5]** The maximum number of transactions. -- `timestamp` **[number][5]** The start timestamp. -- `apiKey` **[string][2]** The ethplorer API key. (optional) - -Returns **Transactions** The transaction result. - -## getAddressHistory - -- **See: [https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-last-address-operations][6] - ** - -Get token transactions. - -### Parameters - -- `baseUrl` **[string][2]** The ethplorer api url. -- `address` **[string][2]** The transaction hash. -- `token` **[string][2]** The token address. -- `limit` **[number][5]** The maximum number of transactions. -- `timestamp` **[number][5]** The start timestamp. -- `apiKey` **[string][2]** The ethplorer API key. (optional) - -Returns **Transactions** The transaction result. - -[1]: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-address-info - -[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[3]: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-transaction-info - -[4]: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-address-transactions - -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number - -[6]: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API#get-last-address-operations diff --git a/xchain-client/xchain-ethereum/available-functions/utils.md b/xchain-client/xchain-ethereum/available-functions/utils.md deleted file mode 100644 index 7081b92f..00000000 --- a/xchain-client/xchain-ethereum/available-functions/utils.md +++ /dev/null @@ -1,291 +0,0 @@ -# Utils - - - -## xchainNetworkToEths - -Network -> EthNetwork - -### Parameters - -- `network` **Network** - -Returns **EthNetwork** - -## ethNetworkToXchains - -EthNetwork -> Network - -### Parameters - -- `network` **EthNetwork** - -Returns **Network** - -## validateAddress - -Validate the given address. - -### Parameters - -- `address` **Address** - -Returns **[boolean][1]** `true` or `false` - -## getTokenAddress - -Get token address from asset. - -### Parameters - -- `asset` **Asset** - -Returns **(Address \| null)** The token address. - -## isEthAsset - -Checks whether an `Asset` is `AssetETH` or not - -### Parameters - -- `asset` **Asset** - -Returns **[boolean][1]** Result of check if an asset is ETH or not - -## getAssetAddress - -Parses asset address from `Asset` - -### Parameters - -- `asset` **Asset** - -Returns **(Address \| null)** Asset address - -## validateSymbol - -Check if the symbol is valid. - -### Parameters - -- `symbol` **([string][2] \| null \| [undefined][3])** - -Returns **[boolean][1]** `true` or `false`. - -## getTxFromTokenTransaction - -Get transactions from token tx - -### Parameters - -- `tx` **TokenTransactionInfo** - -Returns **(Tx \| null)** The parsed transaction. - -## getTxFromEthTransaction - -Get transactions from ETH transaction - -### Parameters - -- `tx` **ETHTransactionInfo** - -Returns **Tx** The parsed transaction. - -## getTxFromEthplorerTokenOperation - -Get transactions from operation - -### Parameters - -- `operation` **TransactionOperation** - -Returns **(Tx \| null)** The parsed transaction. - -## getTxFromEthplorerEthTransaction - -Get transactions from ETH transaction - -### Parameters - -- `txInfo` **TransactionInfo** - -Returns **Tx** The parsed transaction. - -## getFee - -Calculate fees by multiplying . - -### Parameters - -- `$0` **[Object][4]** - - `$0.gasPrice` - - `$0.gasLimit` - -Returns **Fees** The default gas price. - -## getDefaultFees - -Get the default fees. - -### Parameters - -- `asset` - -Returns **Fees** The default gas price. - -## getDefaultGasPrices - -Get the default gas price. - -### Parameters - -- `asset` - -Returns **Fees** The default gas prices. - -## getPrefix - -Get address prefix based on the network. - -Returns **[string][2]** The address prefix based on the network.\* - -## filterSelfTxs - -Filter self txs - -### Parameters - -- `txs` - -Returns **[Array][5]<T>** \* - -## getApprovalAmount - -Returns approval amount - -If given amount is not set or zero, `MAX_APPROVAL` amount is used - -### Parameters - -- `amount` - -## estimateCall - -Call a contract function. - -### Parameters - -- `$0` **[Object][4]** - - `$0.provider` - - `$0.contractAddress` - - `$0.abi` - - `$0.funcName` - - `$0.funcParams` (optional, default `[]`) -- `provider` **Provider** Provider to interact with the contract. -- `contractAddress` **Address** The contract address. -- `abi` **ContractInterface** The contract ABI json. -- `funcName` **[string][2]** The function to be called. -- `funcParams` **[Array][5]<unknown>** The parameters of the function. - -Returns **BigNumber** The result of the contract function call. - -## call - -Calls a contract function. - -### Parameters - -- `$0` **[Object][4]** - - `$0.provider` - - `$0.signer` - - `$0.contractAddress` - - `$0.abi` - - `$0.funcName` - - `$0.funcParams` (optional, default `[]`) -- `provider` **Provider** Provider to interact with the contract. -- `Signer` **signer** of the transaction (optional - needed for sending transactions only) -- `contractAddress` **Address** The contract address. -- `abi` **ContractInterface** The contract ABI json. -- `funcName` **[string][2]** The function to be called. -- `funcParams` **[Array][5]<unknow>** (optional) The parameters of the function. - -Returns **T** The result of the contract function call. - -## estimateApprove - -Estimate gas for calling `approve`. - -### Parameters - -- `$0` **[Object][4]** - - `$0.provider` - - `$0.contractAddress` - - `$0.spenderAddress` - - `$0.fromAddress` - - `$0.abi` - - `$0.amount` -- `provider` **Provider** Provider to interact with the contract. -- `contractAddress` **Address** The contract address. -- `spenderAddress` **Address** The spender address. -- `fromAddress` **Address** The address a transaction is sent from. -- `amount` **BaseAmount** (optional) The amount of token. By default, it will be unlimited token allowance. - -Returns **BigNumber** Estimated gas - -## getDecimal - -Get Decimals - -### Parameters - -- `asset` **Asset** -- `provider` - - -- Throws **`"Invalid asset"`** Thrown if the given asset is invalid - -Returns **[Number][6]** the decimal of a given asset - -## isApproved - -Check allowance. - -### Parameters - -- `$0` **[Object][4]** - - `$0.provider` - - `$0.contractAddress` - - `$0.spenderAddress` - - `$0.fromAddress` - - `$0.amount` -- `provider` **Provider** Provider to interact with the contract. -- `contractAddress` **Address** The contract (ERC20 token) address. -- `spenderAddress` **Address** The spender address (router). -- `fromAddress` **Address** The address a transaction is sent from. -- `amount` **BaseAmount** The amount to check if it's allowed to spend or not (optional). -- `walletIndex` **[number][6]** (optional) HD wallet index - -Returns **[boolean][1]** `true` or `false`. - -## getTokenBalances - -Get Token Balances - -### Parameters - -- `tokenBalances` **[Array][5]<TokenBalance>** - -Returns **[Array][5]<Balance>** the parsed balances - -[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean - -[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - -[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined - -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array - -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/xchain-midgard/available-functions/config.md b/xchain-midgard/available-functions/config.md deleted file mode 100644 index 3eca330f..00000000 --- a/xchain-midgard/available-functions/config.md +++ /dev/null @@ -1,3 +0,0 @@ -# Config - - diff --git a/xchain-midgard/available-functions/README.md b/xchain-thorchain-query/available-functions/README.md similarity index 100% rename from xchain-midgard/available-functions/README.md rename to xchain-thorchain-query/available-functions/README.md diff --git a/xchain-thorchain-query/available-functions/liquidity-pool.md b/xchain-thorchain-query/available-functions/liquidity-pool.md index 162b4853..cfebe5fd 100644 --- a/xchain-thorchain-query/available-functions/liquidity-pool.md +++ b/xchain-thorchain-query/available-functions/liquidity-pool.md @@ -8,5 +8,4 @@ Represent a Liquidity Pool in Thorchain ### Parameters -- `pool` - `thornodeDetails` diff --git a/xchain-thorchain-query/available-functions/thorchain-cache.md b/xchain-thorchain-query/available-functions/thorchain-cache.md index 6177ac92..f2fedc1e 100644 --- a/xchain-thorchain-query/available-functions/thorchain-cache.md +++ b/xchain-thorchain-query/available-functions/thorchain-cache.md @@ -8,12 +8,11 @@ This class manages retrieving information from up to date Thorchain ### Parameters -- `midgard` an instance of the midgard API (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultMidgard`) -- `thornode` (optional, default `defaultThornode`) +- `thornode` an instance of the thornode API (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultThornode`) +- `midgardQuery` an instance of the midgard query class (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultMidgardQuery`) - `expirePoolCacheMillis` how long should the pools be cached before expiry (optional, default `6000`) - `expireInboundDetailsCacheMillis` how long should the InboundDetails be cached before expiry (optional, default `6000`) - `expireNetworkValuesCacheMillis` how long should the Mimir/Constants be cached before expiry (optional, default `TEN_MINUTES`) -- `expireAsgardCacheMillis` how long should the inboundAsgard Addresses be cached before expiry ### getExchangeRate @@ -40,46 +39,18 @@ Returns **any** Promise ### getPools Get all the Liquidity Pools currently cached. -if the cache is expired, the pools wioll be re-fetched from midgard +if the cache is expired, the pools wioll be re-fetched from thornode Returns **any** Promise<Record<string, LiquidityPool>> -### refereshPoolCache +### refreshPoolCache Refreshes the Pool Cache -NOTE: do not call refereshPoolCache() directly, call getPools() instead -which will refresh the cache if it's expired - -### refereshInboundDetailCache +### refreshInboundDetailCache Refreshes the InboundDetailCache Cache -NOTE: do not call refereshInboundDetailCache() directly, call getInboundDetails() instead -which will refresh the cache if it's expired - -### refereshNetworkValuesCache - -Refreshes the NetworkValuesCache Cache - -NOTE: do not call refereshNetworkValuesCache() directly, call getNetworkValuess() instead -which will refresh the cache if it's expired - -### getExpectedSwapOutput - -Calcuate the expected slip, output & swapFee given the current pool depths - - swapFee - the amount of asset lost according to slip calculations - slip - the percent (0-1) of original amount lost to slipfees - output - the amount of asset expected from the swap \* - -#### Parameters - -- `inputAmount` CryptoAmount amount to swap from -- `destinationAsset` destimation Asset to swap to - -Returns **any** SwapOutput - swap output object - output - fee - slip - ### convert Returns the exchange of a CryptoAmount to a different Asset diff --git a/xchain-thorchain-query/available-functions/thorchain-query.md b/xchain-thorchain-query/available-functions/thorchain-query.md index c5658d54..81d6410a 100644 --- a/xchain-thorchain-query/available-functions/thorchain-query.md +++ b/xchain-thorchain-query/available-functions/thorchain-query.md @@ -13,72 +13,35 @@ Has access to Midgard and THORNode data - `thorchainCache` an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet) (optional, default `defaultCache`) - `chainAttributes` atrributes used to calculate waitTime & conf counting (optional, default `chain_defaults_1.DefaultChainAttributes`) -### estimateSwap - -Provides a swap estimate for the given swap detail. Will check the params for errors before trying to get the estimate. -Uses current pool data, works out inbound and outboud fee, affiliate fees and works out the expected wait time for the swap (in and out) - -#### Parameters - -- `params` **[Object][1]** amount to swap - - `params.input` - - `params.destinationAsset` - - `params.destinationAddress` - - `params.slipLimit` (optional, default `new bignumber_js_1.BigNumber('0.03')`) - - `params.interfaceID` (optional, default `'555'`) - - `params.affiliateAddress` (optional, default `''`) - - `params.affiliateFeeBasisPoints` (optional, default `0`) - -Returns **any** The SwapEstimate - -### isValidSwap - -Basic Checks for swap information - -#### Parameters - -- `params` - -### calcSwapEstimate - -Does the calculations for the swap. -Used by estimateSwap - -#### Parameters - -- `params` -- `sourceInboundDetails` -- `destinationInboundDetails` -- `sourcePool` -- `destinationPool` - -### constructSwapMemo +### quoteSwap #### Parameters -- `params` swap object +- `quoteSwapParams` **[Object][1]** input params + - `quoteSwapParams.fromAsset` + - `quoteSwapParams.destinationAsset` + - `quoteSwapParams.amount` + - `quoteSwapParams.destinationAddress` + - `quoteSwapParams.streamingInterval` + - `quoteSwapParams.streamingQuantity` + - `quoteSwapParams.fromAddress` + - `quoteSwapParams.toleranceBps` + - `quoteSwapParams.affiliateBps` + - `quoteSwapParams.affiliateAddress` + - `quoteSwapParams.height` -Returns **any** constructed memo string +### outboundDelay -### getSwapEstimateErrors +- **See: [https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L548][2] + ** -Looks for errors or issues within swap prams before doing the swap. +Works out how long an outbound Tx will be held by THORChain before sending. #### Parameters -- `params` -- `estimate` -- `sourceInboundDetails` -- `destinationInboundDetails` -- `sourcePool` -- `destinationPool` - -### checkCoverFees - -#### Parameters +- `outboundAmount` : CryptoAmount being sent. -- `params` -- `estimate` +Returns **any** required delay in seconds ### getFeesIn @@ -110,7 +73,7 @@ Returns **any** CryptoAmount of input ### confCounting -- **See: [https://docs.thorchain.org/chain-clients/overview][2] +- **See: [https://docs.thorchain.org/chain-clients/overview][3] ** Finds the required confCount required for an inbound or outbound Tx to THORChain. Estimate based on Midgard data only. @@ -124,19 +87,6 @@ ConfCount is then times by 6 seconds. Returns **any** time in seconds before a Tx is confirmed by THORChain -### outboundDelay - -- **See: [https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L548][3] - ** - -Works out how long an outbound Tx will be held by THORChain before sending. - -#### Parameters - -- `outboundAmount` : CryptoAmount being sent. - -Returns **any** required delay in seconds - ### estimateAddLP Estimates a liquidity position for given crypto amount value, both asymmetrical and symetrical @@ -200,8 +150,60 @@ Returns **any** savers withdrawal quote with extras Returns **any** Savers position object +### getLoanQuoteOpen + +#### Parameters + +- `loanOpenParams` **[Object][1]** params needed for the end Point + - `loanOpenParams.asset` + - `loanOpenParams.amount` + - `loanOpenParams.targetAsset` + - `loanOpenParams.destination` + - `loanOpenParams.minOut` + - `loanOpenParams.affiliateBps` + - `loanOpenParams.affiliate` + - `loanOpenParams.height` + +### getLoanQuoteClose + +#### Parameters + +- `loanOpenParams` **[Object][1]** params needed for the end Point + - `loanOpenParams.asset` + - `loanOpenParams.amount` + - `loanOpenParams.loanAsset` + - `loanOpenParams.loanOwner` + - `loanOpenParams.minOut` + - `loanOpenParams.height` + +### getThornameDetails + +#### Parameters + +- `thorname` input param +- `height` + +Returns **any** retrieves details for a thorname + +### estimateThorname + +Generate the memo and estimate the cost of register or update a THORName + +#### Parameters + +- `params` +- `thorname` Name to register +- `chain` Chain to update / register +- `chainAddress` Address to add to chain alias +- `owner` Owner address (rune address) +- `preferredAsset` referred asset +- `expirity` expirity of the domain in MILLISECONDS +- `isUpdate` true only if the domain is already register and you want to update its data + +Returns **any** memo and value of deposit + [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[2]: https://docs.thorchain.org/chain-clients/overview +[2]: https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L548 -[3]: https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/manager_txout_current.go#L548 +[3]: https://docs.thorchain.org/chain-clients/overview diff --git a/xchain-thorchain-query/how-it-works.md b/xchain-thorchain-query/how-it-works.md index 01950488..6bcc87db 100644 --- a/xchain-thorchain-query/how-it-works.md +++ b/xchain-thorchain-query/how-it-works.md @@ -4,17 +4,14 @@ sort: 1 # How it works -Thorchain-query module use midgard and thornode Api's to query thorchain for estimation of swaps. +Thorchain-query module use `xchain-midgard-query` and thornode Api's to query thorchain for estimation of swaps. Function returns a TxDetail object with all the required information needed to conduct a swap. +The dependency between `xchain-midgard-query` and this package is residual and we plan to remove it completely in future releases. ## Dependencies * [`@xchainjs/xchain-client`](http://docs.xchainjs.org/xchain-client/interface.html) * [`@xchainjs/xchain-util`](http://docs.xchainjs.org/xchain-util/how-to-use.html) -* [`@xchainjs/xchain-midgard`](http://docs.xchainjs.org/xchain-midgard/how-to-use.html) +* [`@xchainjs/xchain-midgard-query`](http://docs.xchainjs.org/xchain-midgard-query/how-to-use.html) * [`@xchainjs/xchain-thornode`](http://docs.xchainjs.org/xchain-thornode/how-to-use.html) - -## Blockchain-specific functions - -It doesn't have any blockchain-specific functions. \ No newline at end of file diff --git a/xchain-util/available-functions/cached-value.md b/xchain-util/available-functions/cached-value.md new file mode 100644 index 00000000..d81d1a23 --- /dev/null +++ b/xchain-util/available-functions/cached-value.md @@ -0,0 +1,24 @@ +# Cached Value + + + +## CachedValue + +Utility class for caching stable data + +### Parameters + +- `refreshData` function that refresh and return the data +- `cacheMaxAge` **([number][1] \| [undefined][2])** time in millisecond to expire cache + +### getValue + +Returns cached data if valid or request fresh data if cache is invalid + +#### Parameters + +- `params` use this params to request data if cache is expired + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined diff --git a/xchain-util/available-functions/crypto-amount.md b/xchain-util/available-functions/crypto-amount.md new file mode 100644 index 00000000..b800c852 --- /dev/null +++ b/xchain-util/available-functions/crypto-amount.md @@ -0,0 +1,26 @@ +# Crypto Amount + + + +## CryptoAmount + +Utility Class to combine an amount (asset/base) with the Asset + +### Parameters + +- `amount` +- `asset` + +### check + +This guard protects against trying to perform math with different assets + +Example. +const x = new CryptoAmount(assetAmount(1),AssetBTC) +const y = new CryptoAmount(assetAmount(1),AssetETH) + +x.plus(y) <- will throw error "cannot perform math on 2 diff assets BTC.BTC ETH.ETH + +#### Parameters + +- `v` CryptoNumeric From 91cdfc68410940be6b240575b29a19d4c4d4fe64 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:36:51 +0200 Subject: [PATCH 07/11] Update xchain-thorchain-amm with thorname functions --- xchain-client/xchain-avax/how-to-use.md | 2 +- .../available-functions/thorchain-amm.md | 66 ++++++++++++++++++- .../available-functions/wallet.md | 44 +++++++++++-- 3 files changed, 102 insertions(+), 10 deletions(-) diff --git a/xchain-client/xchain-avax/how-to-use.md b/xchain-client/xchain-avax/how-to-use.md index 68da1820..8c103c7f 100644 --- a/xchain-client/xchain-avax/how-to-use.md +++ b/xchain-client/xchain-avax/how-to-use.md @@ -13,7 +13,7 @@ yarn add @xchainjs/xchain-avax Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-avax`. ``` -yarn add @xchainjs/xchain-evm @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers +yarn add @xchainjs/xchain-evm @xchainjs/xchain-evm-providers @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers ``` ## Client Testing diff --git a/xchain-thorchain-amm/available-functions/thorchain-amm.md b/xchain-thorchain-amm/available-functions/thorchain-amm.md index 1e53e9e6..dde98203 100644 --- a/xchain-thorchain-amm/available-functions/thorchain-amm.md +++ b/xchain-thorchain-amm/available-functions/thorchain-amm.md @@ -20,13 +20,17 @@ Uses current pool data, works out inbound and outboud fee, affiliate fees and wo #### Parameters - `params` **[Object][1]** amount to swap - - `params.input` + - `params.fromAsset` + - `params.amount` + - `params.fromAddress` - `params.destinationAsset` - `params.destinationAddress` - `params.affiliateAddress` (optional, default `''`) - `params.interfaceID` (optional, default `` `555` ``) - - `params.affiliateFeeBasisPoints` (optional, default `0`) - - `params.slipLimit` + - `params.affiliateBps` (optional, default `0`) + - `params.toleranceBps` + - `params.wallet` + - `params.walletIndex` Returns **any** The SwapEstimate @@ -75,6 +79,24 @@ Returns **any** Estimate withdraw lp object - `wallet` wallet needed to perform tx - `params` liquidity parameters +### estimateAddSaver + +#### Parameters + +- `addAssetAmount` + +### estimateWithdrawSaver + +#### Parameters + +- `withdrawParams` + +### getSaverPosition + +#### Parameters + +- `getsaver` + ### addSaver #### Parameters @@ -91,4 +113,42 @@ Returns **any** submitted tx - `wallet` wallet to execute the transaction - `withdrawParams` params needed for withdraw +### getLoanQuoteOpen + +#### Parameters + +- `loanOpenParams` + +### getLoanQuoteClose + +#### Parameters + +- `loanCloseParams` + +### addLoan + +#### Parameters + +- `wallet` wallet needed to execute transaction +- `loanOpenParams` params needed to open the loan + +Returns **any** submitted tx + +### withdrawLoan + +#### Parameters + +- `wallet` wallet to execute the transaction +- `loanCloseParams` params needed for withdrawing the loan + +### getThornamesByAddress + +Get all Thornames and its data associated owned by an address + +#### Parameters + +- `address` address + +Returns **any** thornames data + [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/xchain-thorchain-amm/available-functions/wallet.md b/xchain-thorchain-amm/available-functions/wallet.md index b129abc0..63582648 100644 --- a/xchain-thorchain-amm/available-functions/wallet.md +++ b/xchain-thorchain-amm/available-functions/wallet.md @@ -93,11 +93,45 @@ Returns **any** object with tx response, url and wait time in seconds #### Parameters -- `dustAssetAmount` +- `assetAmount` amount to withdraw - `memo` memo required - `toAddress` - `waitTimeSeconds` expected wait for the transaction to be processed -- `assetAmount` amount to withdraw + +### registerThorname + +Register a THORName with a default expirity of one year. By default chain and chainAddress is getting from wallet instance and is BTC. +By default owner is getting from wallet + +#### Parameters + +- `params` +- `thorname` Name to register +- `chain` Chain to add alias +- `chainAddress` Address to add to chain alias +- `owner` Owner address (rune address) +- `preferredAsset` referred asset +- `expirity` expirity of the domain in MILLISECONDS +- `isUpdate` true only if the domain is already register and you want to update its data + +Returns **any** memo and value of deposit + +### updateThorname + +Register a THORName with a default expirity of one year. By default chain and chainAddress is getting from wallet instance and is BTC. +By default owner is getting from wallet + +#### Parameters + +- `params` +- `thorname` Name to register +- `chain` Chain to add alias +- `chainAddress` Address to add to chain alias +- `owner` Owner address (rune address) +- `preferredAsset` referred asset +- `expirity` expirity of the domain in MILLISECONDS + +Returns **any** memo and value of deposit ### addAssetLP @@ -108,8 +142,8 @@ Function handles liquidity add for all non rune assets - `params` parameters for add liquidity - `constructedMemo` memo needed for thorchain - `assetClient` passing XchainClient -- `waitTimeSeconds` wait time for the tx to be confirmed - `inboundAsgard` inbound Asgard address for the LP +- `waitTimeSeconds` wait time for the tx to be confirmed Returns **any** tx object @@ -122,8 +156,8 @@ Function handles liquidity Withdraw for Non rune assets - `params` parameters for withdraw liquidity - `constructedMemo` memo needed for thorchain execution - `assetClient` asset client to call transfer -- `waitTimeSeconds` return back estimated wait - `inboundAsgard` destination address +- `waitTimeSeconds` return back estimated wait Returns **any** tx object @@ -136,7 +170,6 @@ Function handles liquidity Add for Rune only - `params` deposit parameters - `memo` memo needed to withdraw lp - `thorchainClient` -- `waitTimeSeconds` Returns **any** tx object @@ -149,7 +182,6 @@ Function handles liquidity Withdraw for Rune only - `params` withdraw parameters - `memo` memo needed to withdraw lp - `thorchainClient` -- `waitTimeSeconds` Returns **any** tx object From 31e31de9eef590f86cda5339762605b152ca1891 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:38:30 +0200 Subject: [PATCH 08/11] Add getAssetInfo function and update ethereum for migration to xchain-evm --- .../available-functions/client.md | 4 + .../available-functions/const.md | 4 + .../available-functions/client.md | 6 +- .../available-functions/client.md | 4 + .../xchain-doge/available-functions/client.md | 4 + .../available-functions/client.md | 386 +----------------- .../available-functions/const.md | 15 - .../available-functions/client.md | 6 +- .../available-functions/client.md | 14 +- .../available-functions/const.md | 4 + 10 files changed, 44 insertions(+), 403 deletions(-) diff --git a/xchain-client/xchain-binance/available-functions/client.md b/xchain-client/xchain-binance/available-functions/client.md index 5d147f2f..164caca7 100644 --- a/xchain-client/xchain-binance/available-functions/client.md +++ b/xchain-client/xchain-binance/available-functions/client.md @@ -94,6 +94,10 @@ Validate the given address. Returns **[boolean][4]** `true` or `false` +## getAssetInfo + +Returns **any** asset info + ## getAccount Get account data of wallets or by given address. diff --git a/xchain-client/xchain-binance/available-functions/const.md b/xchain-client/xchain-binance/available-functions/const.md index e7cb1cf5..79a5cac8 100644 --- a/xchain-client/xchain-binance/available-functions/const.md +++ b/xchain-client/xchain-binance/available-functions/const.md @@ -9,3 +9,7 @@ Chain identifier for BNB. ## AssetBNB Base "chain" asset of Binance chain. + +## BNB_DECIMAL + +Asset Decimal diff --git a/xchain-client/xchain-bitcoincash/available-functions/client.md b/xchain-client/xchain-bitcoincash/available-functions/client.md index 52f3c1cd..9361dbe5 100644 --- a/xchain-client/xchain-bitcoincash/available-functions/client.md +++ b/xchain-client/xchain-bitcoincash/available-functions/client.md @@ -6,7 +6,7 @@ Custom Bitcoin Cash client ## Parameters -- `params` **UtxoClientParams** (optional, default `exports.defaultBCHParams`) +- `params` **UtxoClientParams** (optional, default `exports.defaultBchParams`) ## getAddress @@ -25,6 +25,10 @@ The address is then decoded into type P2WPKH and returned. Returns **Address** The current address. +## getAssetInfo + +Returns **any** BCH asset info + ## validateAddress Validate the given address. diff --git a/xchain-client/xchain-cosmos/available-functions/client.md b/xchain-client/xchain-cosmos/available-functions/client.md index 0a196ddc..d5beaff6 100644 --- a/xchain-client/xchain-cosmos/available-functions/client.md +++ b/xchain-client/xchain-cosmos/available-functions/client.md @@ -84,6 +84,10 @@ Get the balance of a given address. Returns **[Array][4]<Balance>** The balance of the address. +## getAssetInfo + +Returns **any** asset info + ## getTransactions Get transaction history of a given address and asset with pagination options. diff --git a/xchain-client/xchain-doge/available-functions/client.md b/xchain-client/xchain-doge/available-functions/client.md index 964e8f25..16f7e4f1 100644 --- a/xchain-client/xchain-doge/available-functions/client.md +++ b/xchain-client/xchain-doge/available-functions/client.md @@ -40,6 +40,10 @@ The address is then decoded into type P2WPKH and returned. Returns **Address** The current address. +## getAssetInfo + +Returns **any** Doge asset info + ## validateAddress Validate the given address. diff --git a/xchain-client/xchain-ethereum/available-functions/client.md b/xchain-client/xchain-ethereum/available-functions/client.md index 5626bf71..1fcb902b 100644 --- a/xchain-client/xchain-ethereum/available-functions/client.md +++ b/xchain-client/xchain-ethereum/available-functions/client.md @@ -1,385 +1 @@ -# Client - -**Extends xchain_client_1.BaseXChainClient** - -Custom Ethereum client - -## Parameters - -- `params` **EthereumClientParams** - - `params.network` (optional, default `xchain_client_1.Network.Mainnet`) - - `params.feeBounds` (optional, default `{lower:const_1.LOWER_FEE_BOUND,upper:const_1.UPPER_FEE_BOUND}`) - - `params.ethplorerUrl` (optional, default `'https://api.ethplorer.io'`) - - `params.ethplorerApiKey` (optional, default `'freekey'`) - - `params.explorerUrl` - - `params.phrase` (optional, default `''`) - - `params.rootDerivationPaths` (optional, default ``{[xchain_client_1.Network.Mainnet]:`m/44'/60'/0'/0/`,[xchain_client_1.Network.Testnet]:`m/44'/60'/0'/0/`,[xchain_client_1.Network.Stagenet]:`m/44'/60'/0'/0/`}``) - - `params.etherscanApiKey` - - `params.infuraCreds` - -## purgeClient - -Purge client. - -Returns **void** - -## setExplorerURL - -Set/Update the explorer url. - -### Parameters - -- `url` **[string][1]** The explorer url. - -Returns **void** - -## getAddress - -Get the current address. - -### Parameters - -- `walletIndex` **[number][2]** (optional) HD wallet index (optional, default `0`) - - -- Throws **any** Error - Thrown if HDNode is not defined. Note: A phrase is needed to create a wallet and to derive an address from it. -- Throws **any** Error - Thrown if wallet index < 0. - -Returns **Address** The current address. - -## getWallet - -Get etherjs wallet interface. - -### Parameters - -- `walletIndex` **[number][2]** (optional) HD wallet index (optional, default `0`) - - -- Throws **any** Error - Thrown if HDNode is not defined. Note: A phrase is needed to create a wallet and to derive an address from it. - -Returns **Wallet** The current etherjs wallet interface. - -## getProvider - -Get etherjs Provider interface. - -Returns **Provider** The current etherjs Provider interface. - -## getEtherscanProvider - -Get etherjs EtherscanProvider interface. - -Returns **EtherscanProvider** The current etherjs EtherscanProvider interface. - -## getExplorerUrl - -Get the explorer url. - -Returns **[string][1]** The explorer url for ethereum based on the current network. - -## getDefaultExplorerURL - -Get the explorer url. - -Returns **ExplorerUrl** The explorer url (both mainnet and testnet) for ethereum. - -## getExplorerUrlByNetwork - -Get the explorer url. - -### Parameters - -- `network` **Network** - -Returns **[string][1]** The explorer url for ethereum based on the network. - -## 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. - -## setNetwork - -Set/update the current network. - -### Parameters - -- `network` **Network** - - -- Throws **`"Network must be provided"`** Thrown if network has not been set before. - -Returns **void** - -## setPhrase - -Set/update a new phrase (Eg. If user wants to change wallet) - -### Parameters - -- `phrase` **[string][1]** A new phrase. -- `walletIndex` **[number][2]** (optional) HD wallet index (optional, default `0`) - - -- Throws **`"Invalid phrase"`** Thrown if the given phase is invalid. - -Returns **Address** The address from the given phrase - -## validateAddress - -Validate the given address. - -### Parameters - -- `address` **Address** - -Returns **[boolean][3]** `true` or `false` - -## getBalance - -Get the ETH balance of a given address. - -### Parameters - -- `address` **Address** By default, it will return the balance of the current wallet. (optional) -- `assets` - - -- Throws **`"Invalid asset"`** throws when the give asset is an invalid one - -Returns **[Array][4]<Balance>** The all balance of the address. - -## 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. - -## getTransactionData - -Get the transaction details of a given transaction id. - -### Parameters - -- `txId` **[string][1]** The transaction id. -- `assetAddress` **[string][1]** The asset address. (optional) - - -- Throws **`"Need to provide valid txId"`** Thrown if the given txId is invalid. - -Returns **Tx** The transaction details of the given transaction id. - -## call - -Call a contract function. - -### Parameters - -- `$0` **[Object][5]** - - `$0.signer` - - `$0.contractAddress` - - `$0.walletIndex` (optional, default `0`) - - `$0.abi` - - `$0.funcName` - - `$0.funcParams` (optional, default `[]`) -- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` -- `contractAddress` **Address** The contract address. -- `walletIndex` **[number][2]** (optional) HD wallet index -- `abi` **ContractInterface** The contract ABI json. -- `funcName` **[string][1]** The function to be called. -- `funcParams` **[Array][4]<unknown>** (optional) The parameters of the function. - -Returns **T** The result of the contract function call. - -## estimateCall - -Call a contract function. - -### Parameters - -- `$0` **[Object][5]** - - `$0.contractAddress` - - `$0.abi` - - `$0.funcName` - - `$0.funcParams` (optional, default `[]`) -- `contractAddress` **Address** The contract address. -- `abi` **ContractInterface** The contract ABI json. -- `funcName` **[string][1]** The function to be called. -- `funcParams` **[Array][4]<any>** The parameters of the function. -- `walletIndex` **[number][2]** (optional) HD wallet index - -Returns **BigNumber** The result of the contract function call. - -## isApproved - -Check allowance. - -### Parameters - -- `$0` **[Object][5]** - - `$0.contractAddress` - - `$0.spenderAddress` - - `$0.amount` - - `$0.walletIndex` -- `contractAddress` **Address** The contract address. -- `spenderAddress` **Address** The spender address. -- `amount` **BaseAmount** The amount to check if it's allowed to spend or not (optional). -- `walletIndex` **[number][2]** (optional) HD wallet index - -Returns **[boolean][3]** `true` or `false`. - -## approve - -Check allowance. - -### Parameters - -- `$0` **[Object][5]** - - `$0.contractAddress` - - `$0.spenderAddress` - - `$0.feeOption` (optional, default `xchain_client_1.FeeOption.Fastest`) - - `$0.amount` - - `$0.walletIndex` (optional, default `0`) - - `$0.signer` - - `$0.gasLimitFallback` -- `contractAddress` **Address** The contract address. -- `spenderAddress` **Address** The spender address. -- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` -- `FeeOption` **feeOption** Fee option (optional) -- `amount` **BaseAmount** The amount of token. By default, it will be unlimited token allowance. (optional) -- `walletIndex` **[number][2]** (optional) HD wallet index - - -- Throws **any** Error If gas could not been estimated - -Returns **TransactionResponse** The transaction result. - -## estimateApprove - -Estimate gas for calling `approve`. - -### Parameters - -- `$0` **[Object][5]** - - `$0.fromAddress` - - `$0.contractAddress` - - `$0.spenderAddress` - - `$0.amount` -- `contractAddress` **Address** The contract address. -- `spenderAddress` **Address** The spender address. -- `fromAddress` **Address** The address the approve transaction is sent from. -- `amount` **BaseAmount** The amount of token. By default, it will be unlimited token allowance. (optional) - -Returns **BigNumber** Estimated gas - -## transfer - -Transfers ETH or ERC20 token - -Note: A given `feeOption` wins over `gasPrice` and `gasLimit` - -### Parameters - -- `$0` **[Object][5]** - - `$0.walletIndex` (optional, default `0`) - - `$0.signer` - - `$0.asset` (optional, default `const_1.AssetETH`) - - `$0.memo` - - `$0.amount` - - `$0.recipient` - - `$0.feeOption` (optional, default `xchain_client_1.FeeOption.Fast`) - - `$0.gasPrice` - - `$0.gasLimit` -- `params` **TxParams** The transfer options. -- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` -- `FeeOption` **feeOption** Fee option (optional) -- `BaseAmount` **gasPrice** Gas price (optional) -- `BigNumber` **gasLimit** Gas limit (optional) - - -- Throws **any** Error Thrown if address of given `Asset` could not be parsed - -Returns **TxHash** The transaction hash. - -## estimateGasPrices - -- **See: [https://etherscan.io/apis#gastracker][6] - ** - -Estimate gas price. - -Returns **GasPrices** The gas prices (average, fast, fastest) in `Wei` (`BaseAmount`) - -## estimateGasPricesFromEtherscan - -- **See: [https://etherscan.io/apis#gastracker][6] - ** - -Estimate gas price. - -- Throws **`"Failed to estimate gas price"`** Thrown if failed to estimate gas price. - -Returns **GasPrices** The gas prices (average, fast, fastest) in `Wei` (`BaseAmount`) - -## estimateGasLimit - -Estimate gas. - -### Parameters - -- `params` **TxParams** The transaction and fees options. - - `params.asset` (optional, default `const_1.AssetETH`) - - `params.recipient` - - `params.amount` - - `params.memo` - - -- Throws **any** Error Thrown if address could not parsed from given ERC20 asset - -Returns **BaseAmount** The estimated gas fee. - -## estimateFeesWithGasPricesAndLimits - -Estimate gas prices/limits (average, fast fastest). - -### Parameters - -- `params` **TxParams** - -Returns **FeesWithGasPricesAndLimits** The estimated gas prices/limits. - -[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/Boolean - -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array - -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - -[6]: https://etherscan.io/apis#gastracker + diff --git a/xchain-client/xchain-ethereum/available-functions/const.md b/xchain-client/xchain-ethereum/available-functions/const.md index 600cca2d..8ae5dbdc 100644 --- a/xchain-client/xchain-ethereum/available-functions/const.md +++ b/xchain-client/xchain-ethereum/available-functions/const.md @@ -1,18 +1,3 @@ # Const - -## ETHChain - -Chain identifier for Ethereum mainnet - -## AssetETH - -- **See: [https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24][1] - ** - -Base "chain" asset on ethereum main net. - -Based on definition in Thorchain `common` - -[1]: https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 diff --git a/xchain-client/xchain-litecoin/available-functions/client.md b/xchain-client/xchain-litecoin/available-functions/client.md index 1c9aceb5..1e5894a7 100644 --- a/xchain-client/xchain-litecoin/available-functions/client.md +++ b/xchain-client/xchain-litecoin/available-functions/client.md @@ -6,7 +6,7 @@ Custom Litecoin client ## Parameters -- `params` **UtxoClientParams** (optional, default `exports.defaultLTCParams`) +- `params` **UtxoClientParams** (optional, default `exports.defaultLtcParams`) ## getAddress @@ -25,6 +25,10 @@ The address is then decoded into type P2WPKH and returned. Returns **Address** The current address. +## getAssetInfo + +Returns **any** asset info + ## validateAddress Validate the given address. diff --git a/xchain-client/xchain-thorchain/available-functions/client.md b/xchain-client/xchain-thorchain/available-functions/client.md index 3ce31bce..910f842d 100644 --- a/xchain-client/xchain-thorchain/available-functions/client.md +++ b/xchain-client/xchain-thorchain/available-functions/client.md @@ -179,6 +179,18 @@ Get the balance of a given address. Returns **[Array][5]<Balance>** The balance of the address. +## getAssetInfo + +Returns **any** asset info + +## fetchTransaction + +### Parameters + +- `txId` tx hash + +Returns **any** txResponse + ## getTransactionData Get the transaction details of a given transaction id. @@ -266,7 +278,7 @@ Transfer without broadcast balances with MsgSend - `params.recipient` - `params.memo` - `params.fromRuneBalance` - - `params.fromAssetBalance` (optional, default `xchain_util_1.baseAmount(0,const_1.DECIMAL)`) + - `params.fromAssetBalance` (optional, default `xchain_util_1.baseAmount(0,const_1.RUNE_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)`) diff --git a/xchain-client/xchain-thorchain/available-functions/const.md b/xchain-client/xchain-thorchain/available-functions/const.md index 2a5e7d95..9683422d 100644 --- a/xchain-client/xchain-thorchain/available-functions/const.md +++ b/xchain-client/xchain-thorchain/available-functions/const.md @@ -51,4 +51,8 @@ Base "chain" asset for RUNE on ethereum main net. Based on definition in Thorchain `common` +## FallBackUrls + +Fall back node's and rpc's + [1]: https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 From a46febfb947fafcc486b0dbea7bc667640d869ab Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:47:39 +0200 Subject: [PATCH 09/11] Add docs for xchain-evm --- gulpfile.js | 4 + xchain-cosmos-sdk/README.md | 2 +- .../available-functions/client.md | 2 +- xchain-evm/README.md | 7 + xchain-evm/available-functions/README.md | 7 + xchain-evm/available-functions/client.md | 347 ++++++++++++++++++ xchain-evm/available-functions/utils.md | 190 ++++++++++ xchain-evm/how-to-use.md | 28 ++ 8 files changed, 585 insertions(+), 2 deletions(-) create mode 100644 xchain-evm/README.md create mode 100644 xchain-evm/available-functions/README.md create mode 100644 xchain-evm/available-functions/client.md create mode 100644 xchain-evm/available-functions/utils.md create mode 100644 xchain-evm/how-to-use.md diff --git a/gulpfile.js b/gulpfile.js index c178227e..ab3114ea 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,6 +43,10 @@ var packages = [ module: 'xchain-cosmos-sdk', path: 'xchain-cosmos-sdk/available-functions', }, + { + module: 'xchain-evm', + path: 'xchain-evm/available-functions', + }, { module: 'xchain-thornode', path: 'xchain-thornode/available-functions', diff --git a/xchain-cosmos-sdk/README.md b/xchain-cosmos-sdk/README.md index d3c6f452..de55b8d8 100644 --- a/xchain-cosmos-sdk/README.md +++ b/xchain-cosmos-sdk/README.md @@ -4,6 +4,6 @@ sort: 3 # XCHAIN COSMOS SDK -Generic implementation of the `XChainClient` interface to work with strings built with [cosmos-sdk] using the dependencies of the official cosmjs monorepo. +Generic implementation of the `XChainClient` interface to work with chains built with [cosmos-sdk] using the dependencies of the official cosmjs monorepo. [cosmos-sdk]: https://docs.cosmos.network/ \ No newline at end of file diff --git a/xchain-cosmos-sdk/available-functions/client.md b/xchain-cosmos-sdk/available-functions/client.md index b4d1b014..f58faed5 100644 --- a/xchain-cosmos-sdk/available-functions/client.md +++ b/xchain-cosmos-sdk/available-functions/client.md @@ -2,7 +2,7 @@ **Extends xchain_client_1.BaseXChainClient** -Generic implementation of the XChainClient interface to work with strings built with cosmos-sdk ([https://docs.cosmos.network/][1]) using the dependencies of the official @cosmjs monorepo. +Generic implementation of the XChainClient interface chains built with cosmos-sdk ([https://docs.cosmos.network/][1]) using the dependencies of the official @cosmjs monorepo. ## Parameters diff --git a/xchain-evm/README.md b/xchain-evm/README.md new file mode 100644 index 00000000..76cd9550 --- /dev/null +++ b/xchain-evm/README.md @@ -0,0 +1,7 @@ +--- +sort: 3 +--- + +# XCHAIN EVM + +Generic implementation of the `XChainClient` interface to work with EVM chains \ No newline at end of file diff --git a/xchain-evm/available-functions/README.md b/xchain-evm/available-functions/README.md new file mode 100644 index 00000000..1f125142 --- /dev/null +++ b/xchain-evm/available-functions/README.md @@ -0,0 +1,7 @@ +--- +sort: 2 +--- + +# Available Functions + +{% include list.liquid all=true %} diff --git a/xchain-evm/available-functions/client.md b/xchain-evm/available-functions/client.md new file mode 100644 index 00000000..69269cd0 --- /dev/null +++ b/xchain-evm/available-functions/client.md @@ -0,0 +1,347 @@ +# Client + +**Extends xchain_client_1.BaseXChainClient** + +Custom EVM client + +## Parameters + +- `params` **EVMClientParams** + - `params.chain` + - `params.gasAsset` + - `params.gasAssetDecimals` + - `params.defaults` + - `params.network` (optional, default `xchain_client_1.Network.Mainnet`) + - `params.feeBounds` + - `params.providers` + - `params.phrase` (optional, default `''`) + - `params.rootDerivationPaths` + - `params.explorerProviders` + - `params.dataProviders` + +## purgeClient + +Purge client. + +Returns **void** + +## getAddress + +Get the current address. + +### Parameters + +- `walletIndex` **[number][1]** (optional) HD wallet index (optional, default `0`) + + +- Throws **any** Error + Thrown if HDNode is not defined. Note: A phrase is needed to create a wallet and to derive an address from it. +- Throws **any** Error + Thrown if wallet index < 0. + +Returns **Address** The current address. + +## getWallet + +Get etherjs wallet interface. + +### Parameters + +- `walletIndex` **[number][1]** (optional) HD wallet index (optional, default `0`) + + +- Throws **any** Error + Thrown if HDNode is not defined. Note: A phrase is needed to create a wallet and to derive an address from it. + +Returns **Wallet** The current etherjs wallet interface. + +## getProvider + +Get etherjs Provider interface. + +Returns **Provider** The current etherjs Provider interface. + +## getExplorerUrl + +Get the explorer url. + +Returns **[string][2]** The explorer url for ethereum based on the current network. + +## getAssetInfo + +Returns **any** asset info + +## getExplorerAddressUrl + +Get the explorer url for the given address. + +### Parameters + +- `address` **Address** + +Returns **[string][2]** The explorer url for the given address. + +## getExplorerTxUrl + +Get the explorer url for the given transaction id. + +### Parameters + +- `txID` **[string][2]** + +Returns **[string][2]** The explorer url for the given transaction id. + +## setNetwork + +Set/update the current network. + +### Parameters + +- `network` **Network** + + +- Throws **`"Network must be provided"`** Thrown if network has not been set before. + +Returns **void** + +## setPhrase + +Set/update a new phrase (Eg. If user wants to change wallet) + +### Parameters + +- `phrase` **[string][2]** A new phrase. +- `walletIndex` **[number][1]** (optional) HD wallet index (optional, default `0`) + + +- Throws **`"Invalid phrase"`** Thrown if the given phase is invalid. + +Returns **Address** The address from the given phrase + +## validateAddress + +Validate the given address. + +### Parameters + +- `address` **Address** + +Returns **[boolean][3]** `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` + + +- Throws **`"Invalid asset"`** throws when the give asset is an invalid one + +Returns **[Array][4]<Balance>** The all balance of the address. + +## 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. + +## getTransactionData + +Get the transaction details of a given transaction id. + +### Parameters + +- `txId` **[string][2]** The transaction id. +- `assetAddress` **[string][2]** The asset address. (optional) + + +- Throws **`"Need to provide valid txId"`** Thrown if the given txId is invalid. + +Returns **Tx** The transaction details of the given transaction id. + +## call + +Call a contract function. + +### Parameters + +- `$0` **[Object][5]** + - `$0.signer` + - `$0.contractAddress` + - `$0.walletIndex` (optional, default `0`) + - `$0.abi` + - `$0.funcName` + - `$0.funcParams` (optional, default `[]`) +- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` +- `contractAddress` **Address** The contract address. +- `walletIndex` **[number][1]** (optional) HD wallet index +- `abi` **ContractInterface** The contract ABI json. +- `funcName` **[string][2]** The function to be called. +- `funcParams` **[Array][4]<unknown>** (optional) The parameters of the function. + +Returns **T** The result of the contract function call. + +## estimateCall + +Call a contract function. + +### Parameters + +- `$0` **[Object][5]** + - `$0.contractAddress` + - `$0.abi` + - `$0.funcName` + - `$0.funcParams` (optional, default `[]`) +- `contractAddress` **Address** The contract address. +- `abi` **ContractInterface** The contract ABI json. +- `funcName` **[string][2]** The function to be called. +- `funcParams` **[Array][4]<any>** The parameters of the function. +- `walletIndex` **[number][1]** (optional) HD wallet index + +Returns **BigNumber** The result of the contract function call. + +## isApproved + +Check allowance. + +### Parameters + +- `$0` **[Object][5]** + - `$0.contractAddress` + - `$0.spenderAddress` + - `$0.amount` + - `$0.walletIndex` +- `contractAddress` **Address** The contract address. +- `spenderAddress` **Address** The spender address. +- `amount` **BaseAmount** The amount to check if it's allowed to spend or not (optional). +- `walletIndex` **[number][1]** (optional) HD wallet index + +Returns **[boolean][3]** `true` or `false`. + +## approve + +Check allowance. + +### Parameters + +- `$0` **[Object][5]** + - `$0.contractAddress` + - `$0.spenderAddress` + - `$0.feeOption` (optional, default `xchain_client_1.FeeOption.Fastest`) + - `$0.amount` + - `$0.walletIndex` (optional, default `0`) + - `$0.signer` +- `contractAddress` **Address** The contract address. +- `spenderAddress` **Address** The spender address. +- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` +- `FeeOption` **feeOption** Fee option (optional) +- `amount` **BaseAmount** The amount of token. By default, it will be unlimited token allowance. (optional) +- `walletIndex` **[number][1]** (optional) HD wallet index + + +- Throws **any** Error If gas could not been estimated + +Returns **TransactionResponse** The transaction result. + +## estimateApprove + +Estimate gas for calling `approve`. + +### Parameters + +- `$0` **[Object][5]** + - `$0.fromAddress` + - `$0.contractAddress` + - `$0.spenderAddress` + - `$0.amount` +- `contractAddress` **Address** The contract address. +- `spenderAddress` **Address** The spender address. +- `fromAddress` **Address** The address the approve transaction is sent from. +- `amount` **BaseAmount** The amount of token. By default, it will be unlimited token allowance. (optional) + +Returns **BigNumber** Estimated gas + +## transfer + +Transfers ETH or ERC20 token + +Note: A given `feeOption` wins over `gasPrice` and `gasLimit` + +### Parameters + +- `$0` **[Object][5]** + - `$0.walletIndex` (optional, default `0`) + - `$0.signer` + - `$0.asset` (optional, default `this.gasAsset`) + - `$0.memo` + - `$0.amount` + - `$0.recipient` + - `$0.feeOption` (optional, default `xchain_client_1.FeeOption.Fast`) + - `$0.gasPrice` + - `$0.gasLimit` +- `params` **TxParams** The transfer options. +- `Signer` **signer** (optional) The address a transaction is send from. If not set, signer will be defined based on `walletIndex` +- `FeeOption` **feeOption** Fee option (optional) +- `BaseAmount` **gasPrice** Gas price (optional) +- `BigNumber` **gasLimit** Gas limit (optional) + + +- Throws **any** Error Thrown if address of given `Asset` could not be parsed + +Returns **TxHash** The transaction hash. + +## estimateGasPrices + +- **See: [https://etherscan.io/apis#gastracker][6] + ** + +Estimate gas price. + +Returns **GasPrices** The gas prices (average, fast, fastest) in `Wei` (`BaseAmount`) + +## estimateGasLimit + +Estimate gas. + +### Parameters + +- `params` **TxParams** The transaction and fees options. + - `params.asset` + - `params.recipient` + - `params.amount` + - `params.memo` + + +- Throws **any** Error Thrown if address could not parsed from given ERC20 asset + +Returns **BaseAmount** The estimated gas fee. + +## estimateFeesWithGasPricesAndLimits + +Estimate gas prices/limits (average, fast fastest). + +### Parameters + +- `params` **TxParams** + +Returns **FeesWithGasPricesAndLimits** The estimated gas prices/limits. + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object + +[6]: https://etherscan.io/apis#gastracker diff --git a/xchain-evm/available-functions/utils.md b/xchain-evm/available-functions/utils.md new file mode 100644 index 00000000..d9ef76c4 --- /dev/null +++ b/xchain-evm/available-functions/utils.md @@ -0,0 +1,190 @@ +# Utils + + + +## validateAddress + +Validate the given address. + +### Parameters + +- `address` **Address** + +Returns **[boolean][1]** `true` or `false` + +## getTokenAddress + +Get token address from asset. + +### Parameters + +- `asset` **Asset** + +Returns **(Address \| null)** The token address. + +## validateSymbol + +Check if the symbol is valid. + +### Parameters + +- `symbol` **([string][2] \| null \| [undefined][3])** + +Returns **[boolean][1]** `true` or `false`. + +## getFee + +Calculate fees by multiplying . + +### Parameters + +- `$0` **[Object][4]** + - `$0.gasPrice` + - `$0.gasLimit` + - `$0.decimals` + +Returns **Fees** The default gas price. + +## getPrefix + +Get address prefix based on the network. + +Returns **[string][2]** The address prefix based on the network.\* + +## filterSelfTxs + +Filter self txs + +### Parameters + +- `txs` + +Returns **[Array][5]<T>** \* + +## getApprovalAmount + +Returns approval amount + +If given amount is not set or zero, `MAX_APPROVAL` amount is used + +### Parameters + +- `amount` + +## estimateCall + +Call a contract function. + +### Parameters + +- `$0` **[Object][4]** + - `$0.provider` + - `$0.contractAddress` + - `$0.abi` + - `$0.funcName` + - `$0.funcParams` (optional, default `[]`) +- `provider` **Provider** Provider to interact with the contract. +- `contractAddress` **Address** The contract address. +- `abi` **ContractInterface** The contract ABI json. +- `funcName` **[string][2]** The function to be called. +- `funcParams` **[Array][5]<unknown>** The parameters of the function. + +Returns **BigNumber** The result of the contract function call. + +## call + +Calls a contract function. + +### Parameters + +- `$0` **[Object][4]** + - `$0.provider` + - `$0.signer` + - `$0.contractAddress` + - `$0.abi` + - `$0.funcName` + - `$0.funcParams` (optional, default `[]`) +- `provider` **Provider** Provider to interact with the contract. +- `Signer` **signer** of the transaction (optional - needed for sending transactions only) +- `contractAddress` **Address** The contract address. +- `abi` **ContractInterface** The contract ABI json. +- `funcName` **[string][2]** The function to be called. +- `funcParams` **[Array][5]<unknow>** (optional) The parameters of the function. + +Returns **T** The result of the contract function call. + +## getContract + +Load a contract. + +### Parameters + +- `$0` **[Object][4]** + - `$0.provider` + - `$0.contractAddress` + - `$0.abi` +- `provider` **Provider** Provider to interact with the contract. +- `contractAddress` **Address** The contract address. +- `abi` **ContractInterface** The contract ABI json. + +## estimateApprove + +Estimate gas for calling `approve`. + +### Parameters + +- `$0` **[Object][4]** + - `$0.provider` + - `$0.contractAddress` + - `$0.spenderAddress` + - `$0.fromAddress` + - `$0.abi` + - `$0.amount` +- `provider` **Provider** Provider to interact with the contract. +- `contractAddress` **Address** The contract address. +- `spenderAddress` **Address** The spender address. +- `fromAddress` **Address** The address a transaction is sent from. +- `amount` **BaseAmount** (optional) The amount of token. By default, it will be unlimited token allowance. + +Returns **BigNumber** Estimated gas + +## isApproved + +Check allowance. + +### Parameters + +- `$0` **[Object][4]** + - `$0.provider` + - `$0.contractAddress` + - `$0.spenderAddress` + - `$0.fromAddress` + - `$0.amount` +- `provider` **Provider** Provider to interact with the contract. +- `contractAddress` **Address** The contract (ERC20 token) address. +- `spenderAddress` **Address** The spender address (router). +- `fromAddress` **Address** The address a transaction is sent from. +- `amount` **BaseAmount** The amount to check if it's allowed to spend or not (optional). +- `walletIndex` **[number][6]** (optional) HD wallet index + +Returns **[boolean][1]** `true` or `false`. + +## strip0x + +Removes `0x` or `0X` from address + +### Parameters + +- `addr` + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object + +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/xchain-evm/how-to-use.md b/xchain-evm/how-to-use.md new file mode 100644 index 00000000..c9537592 --- /dev/null +++ b/xchain-evm/how-to-use.md @@ -0,0 +1,28 @@ +--- +sort: 1 +--- + +# How to use + +## Installation + +```bash +yarn add @xchainjs/xchain-evm +``` + +The following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-evm`. + +```bash +yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios ethers +``` + +## Basic example usage + +This package is perfect if you need support for a EVM chain compatible with ethersjs that is not yet supported within Xchain. You may need to override some methods if the chain in question has specific behaviors. + +If you do so, don't forget to leave it in PR so that other community members can use your work. + +You can check [here] an example of usage + +[here]: https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-ethereum/src/client.ts + From ad8e0324269c6232f03e1b551b270a9949c3f295 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sat, 30 Sep 2023 17:48:51 +0200 Subject: [PATCH 10/11] Minor fix --- xchain-thorchain-amm/how-it-works.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xchain-thorchain-amm/how-it-works.md b/xchain-thorchain-amm/how-it-works.md index 3c056ad8..35320e6a 100644 --- a/xchain-thorchain-amm/how-it-works.md +++ b/xchain-thorchain-amm/how-it-works.md @@ -5,4 +5,4 @@ sort: 1 # How it works Thorchain AMM module that uses Xchainjs Clients to estimate swaps and conduct swaps -on Thorchain. Using Xchainjs Modules Midgard APi for pool data retrieval \ No newline at end of file +on Thorchain. \ No newline at end of file From bb095c4825012cda47877e50d1b262874c7e33ac Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Wed, 4 Oct 2023 14:01:47 +0200 Subject: [PATCH 11/11] Update submodule --- xchainjs-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xchainjs-lib b/xchainjs-lib index dc3617e8..4860de13 160000 --- a/xchainjs-lib +++ b/xchainjs-lib @@ -1 +1 @@ -Subproject commit dc3617e8a69376cbc82239d56c39826ef485dbdf +Subproject commit 4860de136791b490b36c1df81b63e4ca0de57589