@xchainjs/xchain-thorchain 0.19.4 → 0.19.5

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,9 @@
1
+ # v.0.19.5 (2021-11-22)
2
+
3
+ ## Add
4
+
5
+ - Provide `transferOffline` method
6
+
1
7
  # v.0.19.4 (2021-11-22)
2
8
 
3
9
  ## Add
package/lib/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Address, Balance, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
2
- import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
2
+ import { CosmosSDKClient, RPCTxResult, TxOfflineParams } from '@xchainjs/xchain-cosmos';
3
3
  import { Asset } from '@xchainjs/xchain-util';
4
4
  import { PrivKey, PubKey } from 'cosmos-client';
5
+ import { StdTx } from 'cosmos-client/x/auth';
5
6
  import { ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams } from './types';
6
7
  /**
7
8
  * Interface for custom Thorchain client
@@ -205,6 +206,13 @@ declare class Client implements ThorchainClient, XChainClient {
205
206
  * @returns {TxHash} The transaction hash.
206
207
  */
207
208
  transfer({ walletIndex, asset, amount, recipient, memo }: TxParams): Promise<TxHash>;
209
+ /**
210
+ * Transfer without broadcast balances with MsgSend
211
+ *
212
+ * @param {TxOfflineParams} params The transfer offline options.
213
+ * @returns {StdTx} The signed transaction.
214
+ */
215
+ transferOffline({ walletIndex, asset, amount, recipient, memo, from_balance, from_account_number, from_sequence, }: TxOfflineParams): Promise<StdTx>;
208
216
  /**
209
217
  * Get the fees.
210
218
  *
package/lib/index.esm.js CHANGED
@@ -879,6 +879,48 @@ var Client = /** @class */ (function () {
879
879
  });
880
880
  });
881
881
  };
882
+ /**
883
+ * Transfer without broadcast balances with MsgSend
884
+ *
885
+ * @param {TxOfflineParams} params The transfer offline options.
886
+ * @returns {StdTx} The signed transaction.
887
+ */
888
+ Client.prototype.transferOffline = function (_a) {
889
+ var _b = _a.walletIndex, walletIndex = _b === void 0 ? 0 : _b, _c = _a.asset, asset = _c === void 0 ? AssetRuneNative : _c, amount = _a.amount, recipient = _a.recipient, memo = _a.memo, _d = _a.from_balance, from_balance = _d === void 0 ? baseAmount('0', DECIMAL) : _d, _e = _a.from_account_number, from_account_number = _e === void 0 ? '0' : _e, _f = _a.from_sequence, from_sequence = _f === void 0 ? '0' : _f;
890
+ return __awaiter(this, void 0, void 0, function () {
891
+ var fee, result;
892
+ return __generator(this, function (_g) {
893
+ switch (_g.label) {
894
+ case 0:
895
+ registerCodecs(getPrefix(this.network));
896
+ return [4 /*yield*/, this.getFees()];
897
+ case 1:
898
+ fee = _g.sent();
899
+ if (from_balance === baseAmount('0', DECIMAL) ||
900
+ from_balance.amount().lt(amount.amount().plus(fee[FeeOption.Average].amount()))) {
901
+ throw new Error('insufficient funds');
902
+ }
903
+ return [4 /*yield*/, this.cosmosClient.transferSignedOffline({
904
+ privkey: this.getPrivKey(walletIndex),
905
+ from: this.getAddress(walletIndex),
906
+ from_account_number: from_account_number,
907
+ from_sequence: from_sequence,
908
+ to: recipient,
909
+ amount: amount.amount().toString(),
910
+ asset: getDenom(asset),
911
+ memo: memo,
912
+ fee: {
913
+ amount: [],
914
+ gas: DEFAULT_GAS_VALUE,
915
+ },
916
+ })];
917
+ case 2:
918
+ result = _g.sent();
919
+ return [2 /*return*/, JSON.parse(codec.toJSONString(result)).value];
920
+ }
921
+ });
922
+ });
923
+ };
882
924
  /**
883
925
  * Get the fees.
884
926
  *
package/lib/index.js CHANGED
@@ -887,6 +887,48 @@ var Client = /** @class */ (function () {
887
887
  });
888
888
  });
889
889
  };
890
+ /**
891
+ * Transfer without broadcast balances with MsgSend
892
+ *
893
+ * @param {TxOfflineParams} params The transfer offline options.
894
+ * @returns {StdTx} The signed transaction.
895
+ */
896
+ Client.prototype.transferOffline = function (_a) {
897
+ var _b = _a.walletIndex, walletIndex = _b === void 0 ? 0 : _b, _c = _a.asset, asset = _c === void 0 ? xchainUtil.AssetRuneNative : _c, amount = _a.amount, recipient = _a.recipient, memo = _a.memo, _d = _a.from_balance, from_balance = _d === void 0 ? xchainUtil.baseAmount('0', DECIMAL) : _d, _e = _a.from_account_number, from_account_number = _e === void 0 ? '0' : _e, _f = _a.from_sequence, from_sequence = _f === void 0 ? '0' : _f;
898
+ return __awaiter(this, void 0, void 0, function () {
899
+ var fee, result;
900
+ return __generator(this, function (_g) {
901
+ switch (_g.label) {
902
+ case 0:
903
+ registerCodecs(getPrefix(this.network));
904
+ return [4 /*yield*/, this.getFees()];
905
+ case 1:
906
+ fee = _g.sent();
907
+ if (from_balance === xchainUtil.baseAmount('0', DECIMAL) ||
908
+ from_balance.amount().lt(amount.amount().plus(fee[xchainClient.FeeOption.Average].amount()))) {
909
+ throw new Error('insufficient funds');
910
+ }
911
+ return [4 /*yield*/, this.cosmosClient.transferSignedOffline({
912
+ privkey: this.getPrivKey(walletIndex),
913
+ from: this.getAddress(walletIndex),
914
+ from_account_number: from_account_number,
915
+ from_sequence: from_sequence,
916
+ to: recipient,
917
+ amount: amount.amount().toString(),
918
+ asset: getDenom(asset),
919
+ memo: memo,
920
+ fee: {
921
+ amount: [],
922
+ gas: DEFAULT_GAS_VALUE,
923
+ },
924
+ })];
925
+ case 2:
926
+ result = _g.sent();
927
+ return [2 /*return*/, JSON.parse(cosmosClient.codec.toJSONString(result)).value];
928
+ }
929
+ });
930
+ });
931
+ };
890
932
  /**
891
933
  * Get the fees.
892
934
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.19.4",
3
+ "version": "0.19.5",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/big.js": "^6.0.0",
36
- "@xchainjs/xchain-client": "^0.10.1",
37
- "@xchainjs/xchain-cosmos": "^0.13.7",
36
+ "@xchainjs/xchain-client": "0.10.3",
37
+ "@xchainjs/xchain-cosmos": "0.14.0",
38
38
  "@xchainjs/xchain-crypto": "^0.2.4",
39
39
  "@xchainjs/xchain-util": "^0.3.0",
40
40
  "axios": "^0.21.0",
@@ -45,8 +45,8 @@
45
45
  "access": "public"
46
46
  },
47
47
  "peerDependencies": {
48
- "@xchainjs/xchain-client": "^0.10.1",
49
- "@xchainjs/xchain-cosmos": "^0.13.8",
48
+ "@xchainjs/xchain-client": "0.10.3",
49
+ "@xchainjs/xchain-cosmos": "0.14.0",
50
50
  "@xchainjs/xchain-crypto": "^0.2.4",
51
51
  "@xchainjs/xchain-util": "^0.3.0",
52
52
  "axios": "^0.21.0",