@xchainjs/xchain-thorchain 0.24.0-alpha.1 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- # v0.24.0 (2022-03-15)
1
+ # v0.24.1 (2022-04-23)
2
+
3
+ ## Fix
4
+
5
+ - Increase `DEFAULT_GAS_VALUE` to `4000000` (before `3000000`)
6
+
7
+ # v0.24.0 (2022-03-23)
8
+
9
+ ## Update
10
+
11
+ - upgraded to "@cosmos-client/core": "0.45.1"
12
+ - client now extend BaseXChainClient
2
13
 
3
14
  ## Breaking Changes
4
15
 
package/README.md CHANGED
@@ -11,17 +11,20 @@ yarn add @xchainjs/xchain-thorchain
11
11
  Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-thorchain`.
12
12
 
13
13
  ```
14
- yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @xchainjs/xchain-cosmos axios cosmos-client bech32-buffer
14
+ yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @xchainjs/xchain-cosmos axios @cosmos-client/core bech32-buffer
15
15
  ```
16
16
 
17
17
  Important note: Make sure to install same version of `@cosmos-client/core` as `xchain-thorchain` is using (currently `@cosmos-client/core@0.45.1` ). In other case things might break.
18
18
 
19
- ## Thorchain Client Testing
20
19
 
21
- ```
22
- yarn install
23
- yarn test
24
- ```
20
+ ## Documentation
21
+
22
+ ### [`xchain thorchain`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/)
23
+ [`How xchain-thorchain works`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/how-it-works.html)\
24
+ [`How to use xchain-thorchain`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/how-to-use.html)
25
+
26
+
27
+ For more examples check out tests in `./__tests__/client.test.ts`
25
28
 
26
29
  ## Service Providers
27
30
 
@@ -37,33 +40,7 @@ This package uses the following service providers:
37
40
 
38
41
  Rate limits: No
39
42
 
40
- ## Examples
41
-
42
- ```ts
43
- // import `xchain-thorchain`
44
- import { Client } from '@xchainjs/xchain-thorchain'
45
-
46
- // Create a `Client`
47
- const client = new Client({ network: Network.Testnet, phrase: 'my secret phrase' })
48
-
49
- // get address
50
- const address = client.getAddress()
51
- console.log('address:', client.getAddress()) // address: tthor13gym97tmw3axj3hpewdggy2cr288d3qffr8skg
52
-
53
- // get balances
54
- const balances = await client.getBalance(address)
55
- console.log('balances:', balances[0].amount.amount().toString()) // balance: 6968080395099
56
-
57
- // get transactions
58
- const txs = await client.getTransactions({ address })
59
- console.log('txs total:', txs.total) // txs total: 100
60
-
61
- // get transaction details
62
- const tx = await client.getTransactionData('any-tx-hash', address)
63
- console.log('tx asset:', tx.asset) // tx asset: { chain: 'THOR', symbol: 'RUNE', ticker: 'RUNE' }
64
- ```
65
-
66
- For more examples check out tests in `./__tests__/client.test.ts`
43
+ ## Extras
67
44
 
68
45
  ## Creating protobuffer typescript bindings
69
46
 
package/lib/index.esm.js CHANGED
@@ -5376,7 +5376,7 @@ $root.cosmos = (function() {
5376
5376
  var MsgCompiled = $root;
5377
5377
 
5378
5378
  const DECIMAL = 8;
5379
- const DEFAULT_GAS_VALUE = '3000000';
5379
+ const DEFAULT_GAS_VALUE = '4000000';
5380
5380
  const DEPOSIT_GAS_VALUE = '500000000';
5381
5381
  const MAX_TX_COUNT = 100;
5382
5382
  /**
@@ -5439,21 +5439,17 @@ const getPrefix = (network) => {
5439
5439
  }
5440
5440
  };
5441
5441
  /**
5442
- * Register Codecs based on the prefix.
5443
- *
5444
- * @param {string} prefix
5442
+ * Register type for encoding `MsgDeposit` messages
5445
5443
  */
5446
- const registerDespositCodecs = () => __awaiter(void 0, void 0, void 0, function* () {
5444
+ const registerDepositCodecs = () => {
5447
5445
  cosmosclient.codec.register('/types.MsgDeposit', MsgCompiled.types.MsgDeposit);
5448
- });
5446
+ };
5449
5447
  /**
5450
- * Register Codecs based on the prefix.
5451
- *
5452
- * @param {string} prefix
5448
+ * Register type for encoding `MsgSend` messages
5453
5449
  */
5454
- const registerSendCodecs = () => __awaiter(void 0, void 0, void 0, function* () {
5450
+ const registerSendCodecs = () => {
5455
5451
  cosmosclient.codec.register('/types.MsgSend', MsgCompiled.types.MsgSend);
5456
- });
5452
+ };
5457
5453
  /**
5458
5454
  * Parse transaction data from event logs
5459
5455
  *
@@ -5817,6 +5813,8 @@ class Client extends BaseXChainClient {
5817
5813
  this.clientUrl = clientUrl || getDefaultClientUrl();
5818
5814
  this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
5819
5815
  this.chainIds = chainIds;
5816
+ registerSendCodecs();
5817
+ registerDepositCodecs();
5820
5818
  this.cosmosClient = new CosmosSDKClient({
5821
5819
  server: this.getClientUrl().node,
5822
5820
  chainId: this.getChainId(network),
@@ -6048,7 +6046,6 @@ class Client extends BaseXChainClient {
6048
6046
  deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo }) {
6049
6047
  var _a, _b, _c, _d;
6050
6048
  return __awaiter(this, void 0, void 0, function* () {
6051
- yield registerDespositCodecs();
6052
6049
  const balances = yield this.getBalance(this.getAddress(walletIndex));
6053
6050
  const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0, DECIMAL);
6054
6051
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0, DECIMAL);
@@ -6103,7 +6100,6 @@ class Client extends BaseXChainClient {
6103
6100
  transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo }) {
6104
6101
  var _a, _b, _c, _d;
6105
6102
  return __awaiter(this, void 0, void 0, function* () {
6106
- yield registerSendCodecs();
6107
6103
  const balances = yield this.getBalance(this.getAddress(walletIndex));
6108
6104
  const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : baseAmount(0, DECIMAL);
6109
6105
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => assetToString(assetInList) === assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : baseAmount(0, DECIMAL);
@@ -6226,4 +6222,4 @@ const msgNativeTxFromJson = (value) => {
6226
6222
  return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
6227
6223
  };
6228
6224
 
6229
- export { Client, DECIMAL, DEFAULT_GAS_VALUE, DEPOSIT_GAS_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, getBalance, getChainId, getChainIds, getDefaultClientUrl, getDefaultExplorerUrls, getDefaultFees, getDenom, getDepositTxDataFromLogs, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDespositCodecs, registerSendCodecs };
6225
+ export { Client, DECIMAL, DEFAULT_GAS_VALUE, DEPOSIT_GAS_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, getBalance, getChainId, getChainIds, getDefaultClientUrl, getDefaultExplorerUrls, getDefaultFees, getDenom, getDepositTxDataFromLogs, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
package/lib/index.js CHANGED
@@ -5384,7 +5384,7 @@ $root.cosmos = (function() {
5384
5384
  var MsgCompiled = $root;
5385
5385
 
5386
5386
  const DECIMAL = 8;
5387
- const DEFAULT_GAS_VALUE = '3000000';
5387
+ const DEFAULT_GAS_VALUE = '4000000';
5388
5388
  const DEPOSIT_GAS_VALUE = '500000000';
5389
5389
  const MAX_TX_COUNT = 100;
5390
5390
  /**
@@ -5447,21 +5447,17 @@ const getPrefix = (network) => {
5447
5447
  }
5448
5448
  };
5449
5449
  /**
5450
- * Register Codecs based on the prefix.
5451
- *
5452
- * @param {string} prefix
5450
+ * Register type for encoding `MsgDeposit` messages
5453
5451
  */
5454
- const registerDespositCodecs = () => __awaiter(void 0, void 0, void 0, function* () {
5452
+ const registerDepositCodecs = () => {
5455
5453
  core.cosmosclient.codec.register('/types.MsgDeposit', MsgCompiled.types.MsgDeposit);
5456
- });
5454
+ };
5457
5455
  /**
5458
- * Register Codecs based on the prefix.
5459
- *
5460
- * @param {string} prefix
5456
+ * Register type for encoding `MsgSend` messages
5461
5457
  */
5462
- const registerSendCodecs = () => __awaiter(void 0, void 0, void 0, function* () {
5458
+ const registerSendCodecs = () => {
5463
5459
  core.cosmosclient.codec.register('/types.MsgSend', MsgCompiled.types.MsgSend);
5464
- });
5460
+ };
5465
5461
  /**
5466
5462
  * Parse transaction data from event logs
5467
5463
  *
@@ -5825,6 +5821,8 @@ class Client extends xchainClient.BaseXChainClient {
5825
5821
  this.clientUrl = clientUrl || getDefaultClientUrl();
5826
5822
  this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
5827
5823
  this.chainIds = chainIds;
5824
+ registerSendCodecs();
5825
+ registerDepositCodecs();
5828
5826
  this.cosmosClient = new xchainCosmos.CosmosSDKClient({
5829
5827
  server: this.getClientUrl().node,
5830
5828
  chainId: this.getChainId(network),
@@ -6056,7 +6054,6 @@ class Client extends xchainClient.BaseXChainClient {
6056
6054
  deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo }) {
6057
6055
  var _a, _b, _c, _d;
6058
6056
  return __awaiter(this, void 0, void 0, function* () {
6059
- yield registerDespositCodecs();
6060
6057
  const balances = yield this.getBalance(this.getAddress(walletIndex));
6061
6058
  const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
6062
6059
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => xchainUtil.assetToString(assetInList) === xchainUtil.assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : xchainUtil.baseAmount(0, DECIMAL);
@@ -6111,7 +6108,6 @@ class Client extends xchainClient.BaseXChainClient {
6111
6108
  transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo }) {
6112
6109
  var _a, _b, _c, _d;
6113
6110
  return __awaiter(this, void 0, void 0, function* () {
6114
- yield registerSendCodecs();
6115
6111
  const balances = yield this.getBalance(this.getAddress(walletIndex));
6116
6112
  const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
6117
6113
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => xchainUtil.assetToString(assetInList) === xchainUtil.assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : xchainUtil.baseAmount(0, DECIMAL);
@@ -6260,5 +6256,5 @@ exports.getTxType = getTxType;
6260
6256
  exports.isAssetRuneNative = isAssetRuneNative;
6261
6257
  exports.isBroadcastSuccess = isBroadcastSuccess;
6262
6258
  exports.msgNativeTxFromJson = msgNativeTxFromJson;
6263
- exports.registerDespositCodecs = registerDespositCodecs;
6259
+ exports.registerDepositCodecs = registerDepositCodecs;
6264
6260
  exports.registerSendCodecs = registerSendCodecs;
package/lib/util.d.ts CHANGED
@@ -5,7 +5,7 @@ import { Asset, BaseAmount } from '@xchainjs/xchain-util';
5
5
  import { ChainId, ChainIds, ClientUrl, ExplorerUrls, TxData } from './types';
6
6
  import { MsgNativeTx } from './types/messages';
7
7
  export declare const DECIMAL = 8;
8
- export declare const DEFAULT_GAS_VALUE = "3000000";
8
+ export declare const DEFAULT_GAS_VALUE = "4000000";
9
9
  export declare const DEPOSIT_GAS_VALUE = "500000000";
10
10
  export declare const MAX_TX_COUNT = 100;
11
11
  /**
@@ -45,17 +45,13 @@ export declare const isBroadcastSuccess: (response: unknown) => boolean;
45
45
  **/
46
46
  export declare const getPrefix: (network: Network) => "thor" | "sthor" | "tthor";
47
47
  /**
48
- * Register Codecs based on the prefix.
49
- *
50
- * @param {string} prefix
48
+ * Register type for encoding `MsgDeposit` messages
51
49
  */
52
- export declare const registerDespositCodecs: () => Promise<void>;
50
+ export declare const registerDepositCodecs: () => void;
53
51
  /**
54
- * Register Codecs based on the prefix.
55
- *
56
- * @param {string} prefix
52
+ * Register type for encoding `MsgSend` messages
57
53
  */
58
- export declare const registerSendCodecs: () => Promise<void>;
54
+ export declare const registerSendCodecs: () => void;
59
55
  /**
60
56
  * Parse transaction data from event logs
61
57
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.24.0-alpha.1",
3
+ "version": "0.24.1",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -37,7 +37,7 @@
37
37
  "@cosmos-client/core": "^0.45.1",
38
38
  "@types/big.js": "^6.0.0",
39
39
  "@xchainjs/xchain-client": "^0.11.1",
40
- "@xchainjs/xchain-cosmos": "^0.17.0-alpha.1",
40
+ "@xchainjs/xchain-cosmos": "^0.17.0",
41
41
  "@xchainjs/xchain-crypto": "^0.2.4",
42
42
  "@xchainjs/xchain-util": "^0.5.1",
43
43
  "axios": "^0.25.0",
@@ -56,4 +56,4 @@
56
56
  "axios": "^0.25.0",
57
57
  "bech32-buffer": "^0.2.0"
58
58
  }
59
- }
59
+ }