@xchainjs/xchain-wallet 1.0.11 → 1.1.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/lib/index.esm.js CHANGED
@@ -16,6 +16,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
16
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
17
  PERFORMANCE OF THIS SOFTWARE.
18
18
  ***************************************************************************** */
19
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
+
19
21
 
20
22
  function __awaiter(thisArg, _arguments, P, generator) {
21
23
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -25,7 +27,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
25
27
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
28
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27
29
  });
28
- }
30
+ }
31
+
32
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
33
+ var e = new Error(message);
34
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
35
+ };
29
36
 
30
37
  // Class definition for a Wallet
31
38
  class Wallet {
@@ -362,6 +369,28 @@ class Wallet {
362
369
  return client.getFees();
363
370
  });
364
371
  }
372
+ /**
373
+ * Estimates gas limit for a transaction.
374
+ *
375
+ * @param {TxParams} params The transaction and fees options.
376
+ * @returns {BigNumber} The estimated gas limit.
377
+ */
378
+ estimateGasLimit({ asset, recipient, amount, memo, from, isMemoEncoded, }) {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ const client = this.getClient(asset.chain);
381
+ if (!this.isEvmClient(client)) {
382
+ throw Error(`estimateGasLimit method not supported in ${asset.chain} chain`);
383
+ }
384
+ return client.estimateGasLimit({
385
+ asset,
386
+ recipient,
387
+ amount,
388
+ memo,
389
+ from,
390
+ isMemoEncoded,
391
+ });
392
+ });
393
+ }
365
394
  /**
366
395
  * Make a transaction
367
396
  * @param {UtxoTxParams | EvmTxParams | CosmosTxParams} params txParams - The parameters to make the transfer
package/lib/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var xchainClient = require('@xchainjs/xchain-client');
6
4
  var xchainEvm = require('@xchainjs/xchain-evm');
7
5
  var xchainUtil = require('@xchainjs/xchain-util');
@@ -20,6 +18,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
19
  PERFORMANCE OF THIS SOFTWARE.
22
20
  ***************************************************************************** */
21
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
22
+
23
23
 
24
24
  function __awaiter(thisArg, _arguments, P, generator) {
25
25
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -29,7 +29,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
29
29
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
30
  step((generator = generator.apply(thisArg, _arguments || [])).next());
31
31
  });
32
- }
32
+ }
33
+
34
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
35
+ var e = new Error(message);
36
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
37
+ };
33
38
 
34
39
  // Class definition for a Wallet
35
40
  class Wallet {
@@ -366,6 +371,28 @@ class Wallet {
366
371
  return client.getFees();
367
372
  });
368
373
  }
374
+ /**
375
+ * Estimates gas limit for a transaction.
376
+ *
377
+ * @param {TxParams} params The transaction and fees options.
378
+ * @returns {BigNumber} The estimated gas limit.
379
+ */
380
+ estimateGasLimit({ asset, recipient, amount, memo, from, isMemoEncoded, }) {
381
+ return __awaiter(this, void 0, void 0, function* () {
382
+ const client = this.getClient(asset.chain);
383
+ if (!this.isEvmClient(client)) {
384
+ throw Error(`estimateGasLimit method not supported in ${asset.chain} chain`);
385
+ }
386
+ return client.estimateGasLimit({
387
+ asset,
388
+ recipient,
389
+ amount,
390
+ memo,
391
+ from,
392
+ isMemoEncoded,
393
+ });
394
+ });
395
+ }
369
396
  /**
370
397
  * Make a transaction
371
398
  * @param {UtxoTxParams | EvmTxParams | CosmosTxParams} params txParams - The parameters to make the transfer
package/lib/wallet.d.ts CHANGED
@@ -5,6 +5,7 @@ import { AssetInfo, Balance, FeeOption, Fees, Network, Protocol, Tx, TxHash, Txs
5
5
  import { GasPrices } from '@xchainjs/xchain-evm';
6
6
  import { DepositParam } from '@xchainjs/xchain-mayachain';
7
7
  import { Address, AnyAsset, BaseAmount, Chain, TokenAsset } from '@xchainjs/xchain-util';
8
+ import { BigNumber } from 'ethers';
8
9
  import { ChainBalances, CosmosTxParams, EvmTxParams, RadixTxParams, UtxoTxParams } from './types';
9
10
  export type NodeUrls = Record<Network, string>;
10
11
  export declare class Wallet {
@@ -153,6 +154,15 @@ export declare class Wallet {
153
154
  * @returns {Fees} Estimated fees
154
155
  */
155
156
  estimateTransferFees(params: UtxoTxParams | EvmTxParams | CosmosTxParams | RadixTxParams): Promise<Fees>;
157
+ /**
158
+ * Estimates gas limit for a transaction.
159
+ *
160
+ * @param {TxParams} params The transaction and fees options.
161
+ * @returns {BigNumber} The estimated gas limit.
162
+ */
163
+ estimateGasLimit({ asset, recipient, amount, memo, from, isMemoEncoded, }: EvmTxParams & {
164
+ from?: Address;
165
+ }): Promise<BigNumber>;
156
166
  /**
157
167
  * Make a transaction
158
168
  * @param {UtxoTxParams | EvmTxParams | CosmosTxParams} params txParams - The parameters to make the transfer
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-wallet",
3
3
  "description": "XChainjs clients wrapper to work with several chains at the same time",
4
- "version": "1.0.11",
4
+ "version": "1.1.0",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "module": "lib/index.esm.js",
@@ -18,7 +18,7 @@
18
18
  "url": "git@github.com:xchainjs/xchainjs-lib.git"
19
19
  },
20
20
  "scripts": {
21
- "build": "yarn clean && rollup -c",
21
+ "build": "yarn clean && rollup -c --bundleConfigAsCjs",
22
22
  "build:release": "yarn exec rm -rf release && yarn pack && yarn exec \"mkdir release && tar zxvf package.tgz --directory release && rm package.tgz\"",
23
23
  "clean": "rm -rf .turbo && rm -rf lib",
24
24
  "e2e": "jest --config jest.config.e2e.js",
@@ -29,17 +29,18 @@
29
29
  "directory": "release/package"
30
30
  },
31
31
  "dependencies": {
32
- "@xchainjs/xchain-client": "1.0.5",
33
- "@xchainjs/xchain-evm": "1.0.9",
34
- "@xchainjs/xchain-mayachain": "2.0.6",
35
- "@xchainjs/xchain-radix": "1.1.3",
36
- "@xchainjs/xchain-thorchain": "2.0.7",
37
- "@xchainjs/xchain-util": "1.0.4",
38
- "@xchainjs/xchain-utxo": "1.0.5"
32
+ "@xchainjs/xchain-client": "1.0.6",
33
+ "@xchainjs/xchain-evm": "1.0.10",
34
+ "@xchainjs/xchain-mayachain": "2.0.7",
35
+ "@xchainjs/xchain-radix": "1.1.4",
36
+ "@xchainjs/xchain-thorchain": "2.0.8",
37
+ "@xchainjs/xchain-util": "1.0.5",
38
+ "@xchainjs/xchain-utxo": "1.0.6",
39
+ "ethers": "5.7.2"
39
40
  },
40
41
  "devDependencies": {
41
- "@xchainjs/xchain-bitcoin": "1.1.1",
42
- "@xchainjs/xchain-bitcoincash": "1.0.5",
43
- "@xchainjs/xchain-ethereum": "1.0.9"
42
+ "@xchainjs/xchain-bitcoin": "1.1.2",
43
+ "@xchainjs/xchain-bitcoincash": "1.0.6",
44
+ "@xchainjs/xchain-ethereum": "1.0.10"
44
45
  }
45
46
  }