@xchainjs/xchain-thorchain 0.21.2 → 0.22.0

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,3 +1,15 @@
1
+ # v0.22.0 (2022-02-06)
2
+
3
+ ## Add
4
+
5
+ - Option to pass `ChainIds` into constructor
6
+ - getter / setter for `chainId` in `Client`
7
+
8
+ ## Breaking change
9
+
10
+ - `buildDepositTx` needs `chainId` to be passed - all params are set as object
11
+ - Remove `enum ChainId` + `getChainId` + `isChainId` from `utils`
12
+
1
13
  # v0.21.2 (2022-02-04)
2
14
 
3
15
  ## Fix
package/lib/client.d.ts CHANGED
@@ -3,7 +3,7 @@ import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
3
3
  import { Asset } from '@xchainjs/xchain-util';
4
4
  import { PrivKey, PubKey } from 'cosmos-client';
5
5
  import { StdTx } from 'cosmos-client/x/auth';
6
- import { ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams, TxOfflineParams } from './types';
6
+ import { ChainId, ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams, TxOfflineParams } from './types';
7
7
  /**
8
8
  * Interface for custom Thorchain client
9
9
  */
@@ -21,6 +21,7 @@ declare class Client implements ThorchainClient, XChainClient {
21
21
  private network;
22
22
  private clientUrl;
23
23
  private explorerUrls;
24
+ private chainIds;
24
25
  private phrase;
25
26
  private rootDerivationPaths;
26
27
  private cosmosClient;
@@ -34,7 +35,7 @@ declare class Client implements ThorchainClient, XChainClient {
34
35
  *
35
36
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
36
37
  */
37
- constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, }: XChainClientParams & ThorchainClientParams);
38
+ constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
38
39
  /**
39
40
  * Purge client.
40
41
  *
@@ -83,6 +84,23 @@ declare class Client implements ThorchainClient, XChainClient {
83
84
  * @returns {string} The explorer url for thorchain based on the current network.
84
85
  */
85
86
  getExplorerUrl(): string;
87
+ /**
88
+ * Sets chain id
89
+ *
90
+ * @param {ChainId} chainId Chain id to update
91
+ * @param {Network} network (optional) Network for given chainId. If `network`not set, current network of the client is used
92
+ *
93
+ * @returns {void}
94
+ */
95
+ setChainId(chainId: ChainId, network?: Network): void;
96
+ /**
97
+ * Gets chain id
98
+ *
99
+ * @param {Network} network (optional) Network to get chain id from. If `network`not set, current network of the client is used
100
+ *
101
+ * @returns {ChainId} Chain id based on the current network.
102
+ */
103
+ getChainId(network?: Network): ChainId;
86
104
  /**
87
105
  * Get cosmos client
88
106
  * @returns {CosmosSDKClient} current cosmos client
package/lib/index.esm.js CHANGED
@@ -198,36 +198,6 @@ var getPrefix = function (network) {
198
198
  return 'tthor';
199
199
  }
200
200
  };
201
- var ChainId;
202
- (function (ChainId) {
203
- ChainId["Mainnet"] = "thorchain";
204
- ChainId["Stagenet"] = "thorchain-stagenet";
205
- ChainId["Testnet"] = "thorchain-v1";
206
- })(ChainId || (ChainId = {}));
207
- /**
208
- * Type guard to check whether string is a valid `ChainId`
209
- *
210
- * @param {string} id Chain id.
211
- * @returns {boolean} `true` or `false`
212
- */
213
- var isChainId = function (id) { return Object.values(ChainId).includes(id); };
214
- /**
215
- * Get the chain id.
216
- *
217
- * @param {Network} network
218
- * @returns {string} The chain id based on the network.
219
- *
220
- */
221
- var getChainId = function (network) {
222
- switch (network) {
223
- case Network.Mainnet:
224
- return ChainId.Mainnet;
225
- case Network.Stagenet:
226
- return ChainId.Stagenet;
227
- case Network.Testnet:
228
- return ChainId.Testnet;
229
- }
230
- };
231
201
  /**
232
202
  * Register Codecs based on the prefix.
233
203
  *
@@ -305,46 +275,52 @@ var getTxType = function (txData, encoding) {
305
275
  /**
306
276
  * Structure StdTx from MsgNativeTx.
307
277
  *
308
- * @param {string} txId The transaction id.
278
+ * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
279
+ * @param {string} nodeUrl Node url
280
+ * @param {chainId} ChainId Chain id of the network
281
+ *
309
282
  * @returns {Tx} The transaction details of the given transaction id.
310
283
  *
311
284
  * @throws {"Invalid client url"} Thrown if the client url is an invalid one.
312
285
  */
313
- var buildDepositTx = function (msgNativeTx, nodeUrl) { return __awaiter(void 0, void 0, void 0, function () {
314
- var data, chainId, response, fee, unsignedStdTx;
315
- var _a, _b;
316
- return __generator(this, function (_c) {
317
- switch (_c.label) {
318
- case 0: return [4 /*yield*/, axios.get(nodeUrl + "/cosmos/base/tendermint/v1beta1/node_info")];
319
- case 1:
320
- data = (_c.sent()).data;
321
- chainId = data.default_node_info.network;
322
- if (!chainId || !isChainId(chainId))
323
- throw new Error('invalid network');
324
- return [4 /*yield*/, axios.post(nodeUrl + "/thorchain/deposit", {
325
- coins: msgNativeTx.coins,
326
- memo: msgNativeTx.memo,
327
- base_req: {
328
- chain_id: chainId,
329
- from: msgNativeTx.signer,
330
- },
331
- })];
332
- case 2:
333
- response = (_c.sent()).data;
334
- if (!response || !response.value)
335
- throw new Error('Invalid client url');
336
- fee = (_b = (_a = response.value) === null || _a === void 0 ? void 0 : _a.fee) !== null && _b !== void 0 ? _b : { amount: [] };
337
- unsignedStdTx = StdTx.fromJSON({
338
- msg: response.value.msg,
339
- // override fee
340
- fee: __assign(__assign({}, fee), { gas: DEPOSIT_GAS_VALUE }),
341
- signatures: [],
342
- memo: '',
343
- });
344
- return [2 /*return*/, unsignedStdTx];
345
- }
286
+ var buildDepositTx = function (_a) {
287
+ var msgNativeTx = _a.msgNativeTx, nodeUrl = _a.nodeUrl, chainId = _a.chainId;
288
+ return __awaiter(void 0, void 0, void 0, function () {
289
+ var data, networkChainId, response, fee, unsignedStdTx;
290
+ var _b, _c;
291
+ return __generator(this, function (_d) {
292
+ switch (_d.label) {
293
+ case 0: return [4 /*yield*/, axios.get(nodeUrl + "/cosmos/base/tendermint/v1beta1/node_info")];
294
+ case 1:
295
+ data = (_d.sent()).data;
296
+ networkChainId = data.default_node_info.network;
297
+ if (!networkChainId || chainId !== networkChainId)
298
+ throw new Error("Invalid network (asked: " + chainId + " / returned: " + networkChainId);
299
+ return [4 /*yield*/, axios.post(nodeUrl + "/thorchain/deposit", {
300
+ coins: msgNativeTx.coins,
301
+ memo: msgNativeTx.memo,
302
+ base_req: {
303
+ chain_id: chainId,
304
+ from: msgNativeTx.signer,
305
+ },
306
+ })];
307
+ case 2:
308
+ response = (_d.sent()).data;
309
+ if (!response || !response.value)
310
+ throw new Error('Invalid client url');
311
+ fee = (_c = (_b = response.value) === null || _b === void 0 ? void 0 : _b.fee) !== null && _c !== void 0 ? _c : { amount: [] };
312
+ unsignedStdTx = StdTx.fromJSON({
313
+ msg: response.value.msg,
314
+ // override fee
315
+ fee: __assign(__assign({}, fee), { gas: DEPOSIT_GAS_VALUE }),
316
+ signatures: [],
317
+ memo: '',
318
+ });
319
+ return [2 /*return*/, unsignedStdTx];
320
+ }
321
+ });
346
322
  });
347
- }); };
323
+ };
348
324
  /**
349
325
  * Get the balance of a given address.
350
326
  *
@@ -493,13 +469,17 @@ var Client = /** @class */ (function () {
493
469
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
494
470
  */
495
471
  function Client(_a) {
496
- var _b;
472
+ var _b, _c;
497
473
  var _this = this;
498
- var _c = _a.network, network = _c === void 0 ? Network.Testnet : _c, phrase = _a.phrase, clientUrl = _a.clientUrl, explorerUrls = _a.explorerUrls, _d = _a.rootDerivationPaths, rootDerivationPaths = _d === void 0 ? (_b = {},
474
+ var _d = _a.network, network = _d === void 0 ? Network.Testnet : _d, phrase = _a.phrase, clientUrl = _a.clientUrl, explorerUrls = _a.explorerUrls, _e = _a.rootDerivationPaths, rootDerivationPaths = _e === void 0 ? (_b = {},
499
475
  _b[Network.Mainnet] = "44'/931'/0'/0/",
500
476
  _b[Network.Stagenet] = "44'/931'/0'/0/",
501
477
  _b[Network.Testnet] = "44'/931'/0'/0/",
502
- _b) : _d;
478
+ _b) : _e, _f = _a.chainIds, chainIds = _f === void 0 ? (_c = {},
479
+ _c[Network.Mainnet] = 'thorchain',
480
+ _c[Network.Stagenet] = 'thorchain-stagenet',
481
+ _c[Network.Testnet] = 'thorchain-v1',
482
+ _c) : _f;
503
483
  this.phrase = '';
504
484
  /**
505
485
  * Get transaction history of a given address with pagination options.
@@ -569,10 +549,11 @@ var Client = /** @class */ (function () {
569
549
  this.network = network;
570
550
  this.clientUrl = clientUrl || getDefaultClientUrl();
571
551
  this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
552
+ this.chainIds = chainIds;
572
553
  this.rootDerivationPaths = rootDerivationPaths;
573
554
  this.cosmosClient = new CosmosSDKClient({
574
555
  server: this.getClientUrl().node,
575
- chainId: getChainId(this.network),
556
+ chainId: this.getChainId(this.network),
576
557
  prefix: getPrefix(this.network),
577
558
  });
578
559
  if (phrase)
@@ -644,6 +625,28 @@ var Client = /** @class */ (function () {
644
625
  Client.prototype.getExplorerUrl = function () {
645
626
  return this.explorerUrls.root[this.network];
646
627
  };
628
+ /**
629
+ * Sets chain id
630
+ *
631
+ * @param {ChainId} chainId Chain id to update
632
+ * @param {Network} network (optional) Network for given chainId. If `network`not set, current network of the client is used
633
+ *
634
+ * @returns {void}
635
+ */
636
+ Client.prototype.setChainId = function (chainId, network) {
637
+ var _a;
638
+ this.chainIds = __assign(__assign({}, this.chainIds), (_a = {}, _a[network || this.network] = chainId, _a));
639
+ };
640
+ /**
641
+ * Gets chain id
642
+ *
643
+ * @param {Network} network (optional) Network to get chain id from. If `network`not set, current network of the client is used
644
+ *
645
+ * @returns {ChainId} Chain id based on the current network.
646
+ */
647
+ Client.prototype.getChainId = function (network) {
648
+ return this.chainIds[network || this.network];
649
+ };
647
650
  /**
648
651
  * Get cosmos client
649
652
  * @returns {CosmosSDKClient} current cosmos client
@@ -885,7 +888,11 @@ var Client = /** @class */ (function () {
885
888
  memo: memo,
886
889
  signer: signer,
887
890
  });
888
- return [4 /*yield*/, buildDepositTx(msgNativeTx, this.getClientUrl().node)];
891
+ return [4 /*yield*/, buildDepositTx({
892
+ msgNativeTx: msgNativeTx,
893
+ nodeUrl: this.getClientUrl().node,
894
+ chainId: this.getChainId(),
895
+ })];
889
896
  case 2:
890
897
  unsignedStdTx = _k.sent();
891
898
  privateKey = this.getPrivKey(walletIndex);
@@ -1024,4 +1031,4 @@ var Client = /** @class */ (function () {
1024
1031
  return Client;
1025
1032
  }());
1026
1033
 
1027
- export { ChainId, Client, DECIMAL, DEFAULT_GAS_VALUE, DEPOSIT_GAS_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, getBalance, getChainId, getDefaultClientUrl, getDefaultExplorerUrls, getDefaultFees, getDenom, getDepositTxDataFromLogs, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isAssetRuneNative, isBroadcastSuccess, isChainId, isMsgMultiSend, isMsgSend, msgNativeTxFromJson, registerCodecs };
1034
+ export { Client, DECIMAL, DEFAULT_GAS_VALUE, DEPOSIT_GAS_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, getBalance, getDefaultClientUrl, getDefaultExplorerUrls, getDefaultFees, getDenom, getDepositTxDataFromLogs, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isAssetRuneNative, isBroadcastSuccess, isMsgMultiSend, isMsgSend, msgNativeTxFromJson, registerCodecs };
package/lib/index.js CHANGED
@@ -206,35 +206,6 @@ var getPrefix = function (network) {
206
206
  return 'tthor';
207
207
  }
208
208
  };
209
- (function (ChainId) {
210
- ChainId["Mainnet"] = "thorchain";
211
- ChainId["Stagenet"] = "thorchain-stagenet";
212
- ChainId["Testnet"] = "thorchain-v1";
213
- })(exports.ChainId || (exports.ChainId = {}));
214
- /**
215
- * Type guard to check whether string is a valid `ChainId`
216
- *
217
- * @param {string} id Chain id.
218
- * @returns {boolean} `true` or `false`
219
- */
220
- var isChainId = function (id) { return Object.values(exports.ChainId).includes(id); };
221
- /**
222
- * Get the chain id.
223
- *
224
- * @param {Network} network
225
- * @returns {string} The chain id based on the network.
226
- *
227
- */
228
- var getChainId = function (network) {
229
- switch (network) {
230
- case xchainClient.Network.Mainnet:
231
- return exports.ChainId.Mainnet;
232
- case xchainClient.Network.Stagenet:
233
- return exports.ChainId.Stagenet;
234
- case xchainClient.Network.Testnet:
235
- return exports.ChainId.Testnet;
236
- }
237
- };
238
209
  /**
239
210
  * Register Codecs based on the prefix.
240
211
  *
@@ -312,46 +283,52 @@ var getTxType = function (txData, encoding) {
312
283
  /**
313
284
  * Structure StdTx from MsgNativeTx.
314
285
  *
315
- * @param {string} txId The transaction id.
286
+ * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
287
+ * @param {string} nodeUrl Node url
288
+ * @param {chainId} ChainId Chain id of the network
289
+ *
316
290
  * @returns {Tx} The transaction details of the given transaction id.
317
291
  *
318
292
  * @throws {"Invalid client url"} Thrown if the client url is an invalid one.
319
293
  */
320
- var buildDepositTx = function (msgNativeTx, nodeUrl) { return __awaiter(void 0, void 0, void 0, function () {
321
- var data, chainId, response, fee, unsignedStdTx;
322
- var _a, _b;
323
- return __generator(this, function (_c) {
324
- switch (_c.label) {
325
- case 0: return [4 /*yield*/, axios__default['default'].get(nodeUrl + "/cosmos/base/tendermint/v1beta1/node_info")];
326
- case 1:
327
- data = (_c.sent()).data;
328
- chainId = data.default_node_info.network;
329
- if (!chainId || !isChainId(chainId))
330
- throw new Error('invalid network');
331
- return [4 /*yield*/, axios__default['default'].post(nodeUrl + "/thorchain/deposit", {
332
- coins: msgNativeTx.coins,
333
- memo: msgNativeTx.memo,
334
- base_req: {
335
- chain_id: chainId,
336
- from: msgNativeTx.signer,
337
- },
338
- })];
339
- case 2:
340
- response = (_c.sent()).data;
341
- if (!response || !response.value)
342
- throw new Error('Invalid client url');
343
- fee = (_b = (_a = response.value) === null || _a === void 0 ? void 0 : _a.fee) !== null && _b !== void 0 ? _b : { amount: [] };
344
- unsignedStdTx = auth.StdTx.fromJSON({
345
- msg: response.value.msg,
346
- // override fee
347
- fee: __assign(__assign({}, fee), { gas: DEPOSIT_GAS_VALUE }),
348
- signatures: [],
349
- memo: '',
350
- });
351
- return [2 /*return*/, unsignedStdTx];
352
- }
294
+ var buildDepositTx = function (_a) {
295
+ var msgNativeTx = _a.msgNativeTx, nodeUrl = _a.nodeUrl, chainId = _a.chainId;
296
+ return __awaiter(void 0, void 0, void 0, function () {
297
+ var data, networkChainId, response, fee, unsignedStdTx;
298
+ var _b, _c;
299
+ return __generator(this, function (_d) {
300
+ switch (_d.label) {
301
+ case 0: return [4 /*yield*/, axios__default['default'].get(nodeUrl + "/cosmos/base/tendermint/v1beta1/node_info")];
302
+ case 1:
303
+ data = (_d.sent()).data;
304
+ networkChainId = data.default_node_info.network;
305
+ if (!networkChainId || chainId !== networkChainId)
306
+ throw new Error("Invalid network (asked: " + chainId + " / returned: " + networkChainId);
307
+ return [4 /*yield*/, axios__default['default'].post(nodeUrl + "/thorchain/deposit", {
308
+ coins: msgNativeTx.coins,
309
+ memo: msgNativeTx.memo,
310
+ base_req: {
311
+ chain_id: chainId,
312
+ from: msgNativeTx.signer,
313
+ },
314
+ })];
315
+ case 2:
316
+ response = (_d.sent()).data;
317
+ if (!response || !response.value)
318
+ throw new Error('Invalid client url');
319
+ fee = (_c = (_b = response.value) === null || _b === void 0 ? void 0 : _b.fee) !== null && _c !== void 0 ? _c : { amount: [] };
320
+ unsignedStdTx = auth.StdTx.fromJSON({
321
+ msg: response.value.msg,
322
+ // override fee
323
+ fee: __assign(__assign({}, fee), { gas: DEPOSIT_GAS_VALUE }),
324
+ signatures: [],
325
+ memo: '',
326
+ });
327
+ return [2 /*return*/, unsignedStdTx];
328
+ }
329
+ });
353
330
  });
354
- }); };
331
+ };
355
332
  /**
356
333
  * Get the balance of a given address.
357
334
  *
@@ -500,13 +477,17 @@ var Client = /** @class */ (function () {
500
477
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
501
478
  */
502
479
  function Client(_a) {
503
- var _b;
480
+ var _b, _c;
504
481
  var _this = this;
505
- var _c = _a.network, network = _c === void 0 ? xchainClient.Network.Testnet : _c, phrase = _a.phrase, clientUrl = _a.clientUrl, explorerUrls = _a.explorerUrls, _d = _a.rootDerivationPaths, rootDerivationPaths = _d === void 0 ? (_b = {},
482
+ var _d = _a.network, network = _d === void 0 ? xchainClient.Network.Testnet : _d, phrase = _a.phrase, clientUrl = _a.clientUrl, explorerUrls = _a.explorerUrls, _e = _a.rootDerivationPaths, rootDerivationPaths = _e === void 0 ? (_b = {},
506
483
  _b[xchainClient.Network.Mainnet] = "44'/931'/0'/0/",
507
484
  _b[xchainClient.Network.Stagenet] = "44'/931'/0'/0/",
508
485
  _b[xchainClient.Network.Testnet] = "44'/931'/0'/0/",
509
- _b) : _d;
486
+ _b) : _e, _f = _a.chainIds, chainIds = _f === void 0 ? (_c = {},
487
+ _c[xchainClient.Network.Mainnet] = 'thorchain',
488
+ _c[xchainClient.Network.Stagenet] = 'thorchain-stagenet',
489
+ _c[xchainClient.Network.Testnet] = 'thorchain-v1',
490
+ _c) : _f;
510
491
  this.phrase = '';
511
492
  /**
512
493
  * Get transaction history of a given address with pagination options.
@@ -576,10 +557,11 @@ var Client = /** @class */ (function () {
576
557
  this.network = network;
577
558
  this.clientUrl = clientUrl || getDefaultClientUrl();
578
559
  this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
560
+ this.chainIds = chainIds;
579
561
  this.rootDerivationPaths = rootDerivationPaths;
580
562
  this.cosmosClient = new xchainCosmos.CosmosSDKClient({
581
563
  server: this.getClientUrl().node,
582
- chainId: getChainId(this.network),
564
+ chainId: this.getChainId(this.network),
583
565
  prefix: getPrefix(this.network),
584
566
  });
585
567
  if (phrase)
@@ -651,6 +633,28 @@ var Client = /** @class */ (function () {
651
633
  Client.prototype.getExplorerUrl = function () {
652
634
  return this.explorerUrls.root[this.network];
653
635
  };
636
+ /**
637
+ * Sets chain id
638
+ *
639
+ * @param {ChainId} chainId Chain id to update
640
+ * @param {Network} network (optional) Network for given chainId. If `network`not set, current network of the client is used
641
+ *
642
+ * @returns {void}
643
+ */
644
+ Client.prototype.setChainId = function (chainId, network) {
645
+ var _a;
646
+ this.chainIds = __assign(__assign({}, this.chainIds), (_a = {}, _a[network || this.network] = chainId, _a));
647
+ };
648
+ /**
649
+ * Gets chain id
650
+ *
651
+ * @param {Network} network (optional) Network to get chain id from. If `network`not set, current network of the client is used
652
+ *
653
+ * @returns {ChainId} Chain id based on the current network.
654
+ */
655
+ Client.prototype.getChainId = function (network) {
656
+ return this.chainIds[network || this.network];
657
+ };
654
658
  /**
655
659
  * Get cosmos client
656
660
  * @returns {CosmosSDKClient} current cosmos client
@@ -892,7 +896,11 @@ var Client = /** @class */ (function () {
892
896
  memo: memo,
893
897
  signer: signer,
894
898
  });
895
- return [4 /*yield*/, buildDepositTx(msgNativeTx, this.getClientUrl().node)];
899
+ return [4 /*yield*/, buildDepositTx({
900
+ msgNativeTx: msgNativeTx,
901
+ nodeUrl: this.getClientUrl().node,
902
+ chainId: this.getChainId(),
903
+ })];
896
904
  case 2:
897
905
  unsignedStdTx = _k.sent();
898
906
  privateKey = this.getPrivKey(walletIndex);
@@ -1040,7 +1048,6 @@ exports.MsgNativeTx = MsgNativeTx;
1040
1048
  exports.assetFromDenom = assetFromDenom;
1041
1049
  exports.buildDepositTx = buildDepositTx;
1042
1050
  exports.getBalance = getBalance;
1043
- exports.getChainId = getChainId;
1044
1051
  exports.getDefaultClientUrl = getDefaultClientUrl;
1045
1052
  exports.getDefaultExplorerUrls = getDefaultExplorerUrls;
1046
1053
  exports.getDefaultFees = getDefaultFees;
@@ -1053,7 +1060,6 @@ exports.getPrefix = getPrefix;
1053
1060
  exports.getTxType = getTxType;
1054
1061
  exports.isAssetRuneNative = isAssetRuneNative;
1055
1062
  exports.isBroadcastSuccess = isBroadcastSuccess;
1056
- exports.isChainId = isChainId;
1057
1063
  exports.isMsgMultiSend = isMsgMultiSend;
1058
1064
  exports.isMsgSend = isMsgSend;
1059
1065
  exports.msgNativeTxFromJson = msgNativeTxFromJson;
@@ -11,9 +11,12 @@ export declare type ExplorerUrls = {
11
11
  address: ExplorerUrl;
12
12
  };
13
13
  export declare type ExplorerUrl = Record<Network, string>;
14
+ export declare type ChainId = string;
15
+ export declare type ChainIds = Record<Network, ChainId>;
14
16
  export declare type ThorchainClientParams = {
15
17
  clientUrl?: ClientUrl;
16
18
  explorerUrls?: ExplorerUrls;
19
+ chainIds?: ChainIds;
17
20
  };
18
21
  export declare type DepositParam = {
19
22
  walletIndex?: number;
package/lib/util.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Asset } from '@xchainjs/xchain-util';
4
4
  import { Msg } from 'cosmos-client';
5
5
  import { StdTx } from 'cosmos-client/x/auth';
6
6
  import { MsgMultiSend, MsgSend } from 'cosmos-client/x/bank';
7
- import { ClientUrl, ExplorerUrls, TxData } from './types';
7
+ import { ChainId, ClientUrl, ExplorerUrls, TxData } from './types';
8
8
  import { MsgNativeTx } from './types/messages';
9
9
  export declare const DECIMAL = 8;
10
10
  export declare const DEFAULT_GAS_VALUE = "2000000";
@@ -60,26 +60,6 @@ export declare const isBroadcastSuccess: (response: unknown) => boolean;
60
60
  *
61
61
  **/
62
62
  export declare const getPrefix: (network: Network) => "thor" | "sthor" | "tthor";
63
- export declare enum ChainId {
64
- Mainnet = "thorchain",
65
- Stagenet = "thorchain-stagenet",
66
- Testnet = "thorchain-v1"
67
- }
68
- /**
69
- * Type guard to check whether string is a valid `ChainId`
70
- *
71
- * @param {string} id Chain id.
72
- * @returns {boolean} `true` or `false`
73
- */
74
- export declare const isChainId: (id: string) => id is ChainId;
75
- /**
76
- * Get the chain id.
77
- *
78
- * @param {Network} network
79
- * @returns {string} The chain id based on the network.
80
- *
81
- */
82
- export declare const getChainId: (network: Network) => ChainId;
83
63
  /**
84
64
  * Register Codecs based on the prefix.
85
65
  *
@@ -111,12 +91,19 @@ export declare const getTxType: (txData: string, encoding: 'base64' | 'hex') =>
111
91
  /**
112
92
  * Structure StdTx from MsgNativeTx.
113
93
  *
114
- * @param {string} txId The transaction id.
94
+ * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
95
+ * @param {string} nodeUrl Node url
96
+ * @param {chainId} ChainId Chain id of the network
97
+ *
115
98
  * @returns {Tx} The transaction details of the given transaction id.
116
99
  *
117
100
  * @throws {"Invalid client url"} Thrown if the client url is an invalid one.
118
101
  */
119
- export declare const buildDepositTx: (msgNativeTx: MsgNativeTx, nodeUrl: string) => Promise<StdTx>;
102
+ export declare const buildDepositTx: ({ msgNativeTx, nodeUrl, chainId, }: {
103
+ msgNativeTx: MsgNativeTx;
104
+ nodeUrl: string;
105
+ chainId: ChainId;
106
+ }) => Promise<StdTx>;
120
107
  /**
121
108
  * Get the balance of a given address.
122
109
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",