@fuel-ts/account 0.0.0-rc-1889-20240322122653 → 0.0.0-rc-1815-20240322131329

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (212) hide show
  1. package/dist/account.d.ts +184 -0
  2. package/dist/account.d.ts.map +1 -0
  3. package/dist/configs.d.ts +2 -3
  4. package/dist/configs.d.ts.map +1 -0
  5. package/dist/connectors/fuel-connector.d.ts +198 -0
  6. package/dist/connectors/fuel-connector.d.ts.map +1 -0
  7. package/dist/connectors/fuel.d.ts +133 -0
  8. package/dist/connectors/fuel.d.ts.map +1 -0
  9. package/dist/connectors/index.d.ts +5 -0
  10. package/dist/connectors/index.d.ts.map +1 -0
  11. package/dist/connectors/types/connector-metadata.d.ts +12 -0
  12. package/dist/connectors/types/connector-metadata.d.ts.map +1 -0
  13. package/dist/connectors/types/connector-types.d.ts +34 -0
  14. package/dist/connectors/types/connector-types.d.ts.map +1 -0
  15. package/dist/connectors/types/data-type.d.ts +34 -0
  16. package/dist/connectors/types/data-type.d.ts.map +1 -0
  17. package/dist/connectors/types/events.d.ts +111 -0
  18. package/dist/connectors/types/events.d.ts.map +1 -0
  19. package/dist/connectors/types/index.d.ts +7 -0
  20. package/dist/connectors/types/index.d.ts.map +1 -0
  21. package/dist/connectors/types/local-storage.d.ts +11 -0
  22. package/dist/connectors/types/local-storage.d.ts.map +1 -0
  23. package/dist/connectors/types/target-object.d.ts +14 -0
  24. package/dist/connectors/types/target-object.d.ts.map +1 -0
  25. package/dist/connectors/utils/cache.d.ts +14 -0
  26. package/dist/connectors/utils/cache.d.ts.map +1 -0
  27. package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts +7 -0
  28. package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts.map +1 -0
  29. package/dist/connectors/utils/index.d.ts +4 -0
  30. package/dist/connectors/utils/index.d.ts.map +1 -0
  31. package/dist/connectors/utils/promises.d.ts +8 -0
  32. package/dist/connectors/utils/promises.d.ts.map +1 -0
  33. package/dist/hdwallet/hdwallet.d.ts +58 -0
  34. package/dist/hdwallet/hdwallet.d.ts.map +1 -0
  35. package/dist/hdwallet/index.d.ts +2 -0
  36. package/dist/hdwallet/index.d.ts.map +1 -0
  37. package/dist/index.d.ts +13 -904
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.global.js +520 -391
  40. package/dist/index.global.js.map +1 -1
  41. package/dist/index.js +314 -208
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +316 -208
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/mnemonic/index.d.ts +3 -0
  46. package/dist/mnemonic/index.d.ts.map +1 -0
  47. package/dist/mnemonic/mnemonic.d.ts +85 -0
  48. package/dist/mnemonic/mnemonic.d.ts.map +1 -0
  49. package/dist/mnemonic/utils.d.ts +8 -0
  50. package/dist/mnemonic/utils.d.ts.map +1 -0
  51. package/dist/predicate/index.d.ts +3 -0
  52. package/dist/predicate/index.d.ts.map +1 -0
  53. package/dist/predicate/predicate.d.ts +94 -0
  54. package/dist/predicate/predicate.d.ts.map +1 -0
  55. package/dist/predicate/utils/getPredicateRoot.d.ts +12 -0
  56. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -0
  57. package/dist/predicate/utils/index.d.ts +2 -0
  58. package/dist/predicate/utils/index.d.ts.map +1 -0
  59. package/dist/providers/__generated__/operations.d.ts +3477 -0
  60. package/dist/providers/__generated__/operations.d.ts.map +1 -0
  61. package/dist/providers/assets/index.d.ts +5 -0
  62. package/dist/providers/assets/index.d.ts.map +1 -0
  63. package/dist/providers/assets/types.d.ts +36 -0
  64. package/dist/providers/assets/types.d.ts.map +1 -0
  65. package/dist/providers/assets/utils/index.d.ts +4 -0
  66. package/dist/providers/assets/utils/index.d.ts.map +1 -0
  67. package/dist/providers/assets/utils/network.d.ts +33 -0
  68. package/dist/providers/assets/utils/network.d.ts.map +1 -0
  69. package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
  70. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
  71. package/dist/providers/assets/utils/url.d.ts +2 -0
  72. package/dist/providers/assets/utils/url.d.ts.map +1 -0
  73. package/dist/providers/chains.d.ts +11 -0
  74. package/dist/providers/chains.d.ts.map +1 -0
  75. package/dist/providers/coin-quantity.d.ts +21 -0
  76. package/dist/providers/coin-quantity.d.ts.map +1 -0
  77. package/dist/providers/coin.d.ts +15 -0
  78. package/dist/providers/coin.d.ts.map +1 -0
  79. package/dist/providers/fuel-graphql-subscriber.d.ts +23 -0
  80. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -0
  81. package/dist/providers/index.d.ts +13 -0
  82. package/dist/providers/index.d.ts.map +1 -0
  83. package/dist/providers/memory-cache.d.ts +11 -0
  84. package/dist/providers/memory-cache.d.ts.map +1 -0
  85. package/dist/providers/message.d.ts +60 -0
  86. package/dist/providers/message.d.ts.map +1 -0
  87. package/dist/providers/provider.d.ts +523 -0
  88. package/dist/providers/provider.d.ts.map +1 -0
  89. package/dist/providers/resource.d.ts +37 -0
  90. package/dist/providers/resource.d.ts.map +1 -0
  91. package/dist/providers/transaction-request/create-transaction-request.d.ts +73 -0
  92. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -0
  93. package/dist/providers/transaction-request/errors.d.ts +25 -0
  94. package/dist/providers/transaction-request/errors.d.ts.map +1 -0
  95. package/dist/providers/transaction-request/hash-transaction.d.ts +9 -0
  96. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -0
  97. package/dist/providers/transaction-request/index.d.ts +10 -0
  98. package/dist/providers/transaction-request/index.d.ts.map +1 -0
  99. package/dist/providers/transaction-request/input.d.ts +59 -0
  100. package/dist/providers/transaction-request/input.d.ts.map +1 -0
  101. package/dist/providers/transaction-request/output.d.ts +39 -0
  102. package/dist/providers/transaction-request/output.d.ts.map +1 -0
  103. package/dist/providers/transaction-request/script-transaction-request.d.ts +106 -0
  104. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -0
  105. package/dist/providers/transaction-request/scripts.d.ts +6 -0
  106. package/dist/providers/transaction-request/scripts.d.ts.map +1 -0
  107. package/dist/providers/transaction-request/storage-slot.d.ts +10 -0
  108. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -0
  109. package/dist/providers/transaction-request/transaction-request.d.ts +278 -0
  110. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -0
  111. package/dist/providers/transaction-request/types.d.ts +10 -0
  112. package/dist/providers/transaction-request/types.d.ts.map +1 -0
  113. package/dist/providers/transaction-request/utils.d.ts +4 -0
  114. package/dist/providers/transaction-request/utils.d.ts.map +1 -0
  115. package/dist/providers/transaction-request/witness.d.ts +5 -0
  116. package/dist/providers/transaction-request/witness.d.ts.map +1 -0
  117. package/dist/providers/transaction-response/getDecodedLogs.d.ts +5 -0
  118. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -0
  119. package/dist/providers/transaction-response/index.d.ts +3 -0
  120. package/dist/providers/transaction-response/index.d.ts.map +1 -0
  121. package/dist/providers/transaction-response/transaction-response.d.ts +106 -0
  122. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -0
  123. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +20 -0
  124. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -0
  125. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +21 -0
  126. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -0
  127. package/dist/providers/transaction-summary/call.d.ts +18 -0
  128. package/dist/providers/transaction-summary/call.d.ts.map +1 -0
  129. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +31 -0
  130. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -0
  131. package/dist/providers/transaction-summary/index.d.ts +10 -0
  132. package/dist/providers/transaction-summary/index.d.ts.map +1 -0
  133. package/dist/providers/transaction-summary/input.d.ts +21 -0
  134. package/dist/providers/transaction-summary/input.d.ts.map +1 -0
  135. package/dist/providers/transaction-summary/operations.d.ts +40 -0
  136. package/dist/providers/transaction-summary/operations.d.ts.map +1 -0
  137. package/dist/providers/transaction-summary/output.d.ts +15 -0
  138. package/dist/providers/transaction-summary/output.d.ts.map +1 -0
  139. package/dist/providers/transaction-summary/receipt.d.ts +7 -0
  140. package/dist/providers/transaction-summary/receipt.d.ts.map +1 -0
  141. package/dist/providers/transaction-summary/status.d.ts +9 -0
  142. package/dist/providers/transaction-summary/status.d.ts.map +1 -0
  143. package/dist/providers/transaction-summary/types.d.ts +146 -0
  144. package/dist/providers/transaction-summary/types.d.ts.map +1 -0
  145. package/dist/providers/utils/auto-retry-fetch.d.ts +36 -0
  146. package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -0
  147. package/dist/providers/utils/block-explorer.d.ts +14 -0
  148. package/dist/providers/utils/block-explorer.d.ts.map +1 -0
  149. package/dist/providers/utils/gas.d.ts +38 -0
  150. package/dist/providers/utils/gas.d.ts.map +1 -0
  151. package/dist/providers/utils/index.d.ts +6 -0
  152. package/dist/providers/utils/index.d.ts.map +1 -0
  153. package/dist/providers/utils/json.d.ts +7 -0
  154. package/dist/providers/utils/json.d.ts.map +1 -0
  155. package/dist/providers/utils/merge-quantities.d.ts +3 -0
  156. package/dist/providers/utils/merge-quantities.d.ts.map +1 -0
  157. package/dist/providers/utils/receipts.d.ts +10 -0
  158. package/dist/providers/utils/receipts.d.ts.map +1 -0
  159. package/dist/providers/utils/sleep.d.ts +3 -0
  160. package/dist/providers/utils/sleep.d.ts.map +1 -0
  161. package/dist/signer/index.d.ts +2 -0
  162. package/dist/signer/index.d.ts.map +1 -0
  163. package/dist/signer/signer.d.ts +64 -0
  164. package/dist/signer/signer.d.ts.map +1 -0
  165. package/dist/test-utils/generateTestWallet.d.ts +4 -0
  166. package/dist/test-utils/generateTestWallet.d.ts.map +1 -0
  167. package/dist/test-utils/index.d.ts +4 -0
  168. package/dist/test-utils/index.d.ts.map +1 -0
  169. package/dist/{test-utils.d.ts → test-utils/launchNode.d.ts} +12 -24
  170. package/dist/test-utils/launchNode.d.ts.map +1 -0
  171. package/dist/test-utils/seedTestWallet.d.ts +4 -0
  172. package/dist/test-utils/seedTestWallet.d.ts.map +1 -0
  173. package/dist/test-utils.global.js +386 -295
  174. package/dist/test-utils.global.js.map +1 -1
  175. package/dist/test-utils.js +179 -108
  176. package/dist/test-utils.js.map +1 -1
  177. package/dist/test-utils.mjs +181 -108
  178. package/dist/test-utils.mjs.map +1 -1
  179. package/dist/utils/formatTransferToContractScriptData.d.ts +14 -0
  180. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -0
  181. package/dist/wallet/base-wallet-unlocked.d.ts +73 -0
  182. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -0
  183. package/dist/wallet/index.d.ts +4 -0
  184. package/dist/wallet/index.d.ts.map +1 -0
  185. package/dist/wallet/keystore-wallet.d.ts +38 -0
  186. package/dist/wallet/keystore-wallet.d.ts.map +1 -0
  187. package/dist/wallet/wallet.d.ts +68 -0
  188. package/dist/wallet/wallet.d.ts.map +1 -0
  189. package/dist/wallet/wallets.d.ts +76 -0
  190. package/dist/wallet/wallets.d.ts.map +1 -0
  191. package/dist/wallet-manager/index.d.ts +6 -0
  192. package/dist/wallet-manager/index.d.ts.map +1 -0
  193. package/dist/wallet-manager/storages/memory-storage.d.ts +9 -0
  194. package/dist/wallet-manager/storages/memory-storage.d.ts.map +1 -0
  195. package/dist/wallet-manager/types.d.ts +42 -0
  196. package/dist/wallet-manager/types.d.ts.map +1 -0
  197. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +29 -0
  198. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -0
  199. package/dist/wallet-manager/vaults/privatekey-vault.d.ts +29 -0
  200. package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -0
  201. package/dist/wallet-manager/wallet-manager.d.ts +104 -0
  202. package/dist/wallet-manager/wallet-manager.d.ts.map +1 -0
  203. package/dist/wordlists/index.d.ts +5 -0
  204. package/dist/wordlists/index.d.ts.map +1 -0
  205. package/dist/wordlists/words/english.d.ts +2 -0
  206. package/dist/wordlists/words/english.d.ts.map +1 -0
  207. package/package.json +25 -21
  208. package/dist/account-E9nGNf5X.d.mts +0 -3837
  209. package/dist/account-E9nGNf5X.d.ts +0 -3837
  210. package/dist/configs.d.mts +0 -3
  211. package/dist/index.d.mts +0 -904
  212. package/dist/test-utils.d.mts +0 -66
@@ -1,3 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ var __accessCheck = (obj, member, msg) => {
8
+ if (!member.has(obj))
9
+ throw TypeError("Cannot " + msg);
10
+ };
11
+ var __privateAdd = (obj, member, value) => {
12
+ if (member.has(obj))
13
+ throw TypeError("Cannot add the same private member more than once");
14
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
+ };
16
+ var __privateMethod = (obj, member, method) => {
17
+ __accessCheck(obj, member, "access private method");
18
+ return method;
19
+ };
20
+
1
21
  // src/wallet/base-wallet-unlocked.ts
2
22
  import { hashMessage } from "@fuel-ts/hasher";
3
23
  import { hexlify as hexlify15 } from "@fuel-ts/utils";
@@ -871,12 +891,11 @@ function getSdk(requester) {
871
891
  // src/providers/fuel-graphql-subscriber.ts
872
892
  import { ErrorCode, FuelError } from "@fuel-ts/errors";
873
893
  import { print } from "graphql";
874
- var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
894
+ var _FuelGraphqlSubscriber = class {
875
895
  constructor(options) {
876
896
  this.options = options;
877
897
  }
878
898
  stream;
879
- static textDecoder = new TextDecoder();
880
899
  async setStream() {
881
900
  const { url, query, variables, fetchFn } = this.options;
882
901
  const response = await fetchFn(`${url}-sub`, {
@@ -936,6 +955,8 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
936
955
  return this;
937
956
  }
938
957
  };
958
+ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
959
+ __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
939
960
 
940
961
  // src/providers/memory-cache.ts
941
962
  import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
@@ -1495,7 +1516,7 @@ var witnessify = (value) => {
1495
1516
  };
1496
1517
 
1497
1518
  // src/providers/transaction-request/transaction-request.ts
1498
- var BaseTransactionRequest = class _BaseTransactionRequest {
1519
+ var BaseTransactionRequest = class {
1499
1520
  /** Gas price for transaction */
1500
1521
  gasPrice;
1501
1522
  /** Block until which tx cannot be included */
@@ -1565,7 +1586,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
1565
1586
  const inputs = this.inputs?.map(inputify) ?? [];
1566
1587
  const outputs = this.outputs?.map(outputify) ?? [];
1567
1588
  const witnesses = this.witnesses?.map(witnessify) ?? [];
1568
- const { policyTypes, policies } = _BaseTransactionRequest.getPolicyMeta(this);
1589
+ const { policyTypes, policies } = BaseTransactionRequest.getPolicyMeta(this);
1569
1590
  return {
1570
1591
  policyTypes,
1571
1592
  inputs,
@@ -1603,13 +1624,27 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
1603
1624
  this.outputs.push(output);
1604
1625
  return this.outputs.length - 1;
1605
1626
  }
1627
+ /**
1628
+ * @hidden
1629
+ *
1630
+ * Pushes a witness to the list and returns the index
1631
+ *
1632
+ * @param signature - The signature to add to the witness.
1633
+ * @returns The index of the created witness.
1634
+ */
1635
+ addWitness(signature) {
1636
+ this.witnesses.push(signature);
1637
+ return this.witnesses.length - 1;
1638
+ }
1606
1639
  /**
1607
1640
  * @hidden
1608
1641
  *
1609
1642
  * Creates an empty witness without any side effects and returns the index
1643
+ *
1644
+ * @returns The index of the created witness.
1610
1645
  */
1611
- createWitness() {
1612
- this.witnesses.push(concat([ZeroBytes324, ZeroBytes324]));
1646
+ addEmptyWitness() {
1647
+ this.addWitness(concat([ZeroBytes324, ZeroBytes324]));
1613
1648
  return this.witnesses.length - 1;
1614
1649
  }
1615
1650
  /**
@@ -1638,6 +1673,21 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
1638
1673
  }
1639
1674
  this.witnesses[index] = witness;
1640
1675
  }
1676
+ /**
1677
+ * Helper function to add an external signature to the transaction.
1678
+ *
1679
+ * @param account - The account/s to sign to the transaction.
1680
+ * @returns The transaction with the signature witness added.
1681
+ */
1682
+ async addAccountWitnesses(account) {
1683
+ const accounts = Array.isArray(account) ? account : [account];
1684
+ await Promise.all(
1685
+ accounts.map(async (acc) => {
1686
+ this.addWitness(await acc.signTransaction(this));
1687
+ })
1688
+ );
1689
+ return this;
1690
+ }
1641
1691
  /**
1642
1692
  * Gets the coin inputs for a transaction.
1643
1693
  *
@@ -1703,7 +1753,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
1703
1753
  } else {
1704
1754
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
1705
1755
  if (typeof witnessIndex !== "number") {
1706
- witnessIndex = this.createWitness();
1756
+ witnessIndex = this.addEmptyWitness();
1707
1757
  }
1708
1758
  }
1709
1759
  const input = {
@@ -1737,7 +1787,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
1737
1787
  } else {
1738
1788
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
1739
1789
  if (typeof witnessIndex !== "number") {
1740
- witnessIndex = this.createWitness();
1790
+ witnessIndex = this.addEmptyWitness();
1741
1791
  }
1742
1792
  }
1743
1793
  const input = {
@@ -3103,7 +3153,7 @@ function assembleTransactionSummary(params) {
3103
3153
  }
3104
3154
 
3105
3155
  // src/providers/transaction-response/transaction-response.ts
3106
- var TransactionResponse = class _TransactionResponse {
3156
+ var TransactionResponse = class {
3107
3157
  /** Transaction ID */
3108
3158
  id;
3109
3159
  /** Current provider */
@@ -3131,7 +3181,7 @@ var TransactionResponse = class _TransactionResponse {
3131
3181
  * @param provider - The provider.
3132
3182
  */
3133
3183
  static async create(id, provider) {
3134
- const response = new _TransactionResponse(id, provider);
3184
+ const response = new TransactionResponse(id, provider);
3135
3185
  await response.fetch();
3136
3186
  return response;
3137
3187
  }
@@ -3346,7 +3396,8 @@ var processGqlChain = (chain) => {
3346
3396
  }
3347
3397
  };
3348
3398
  };
3349
- var Provider = class _Provider {
3399
+ var _cacheInputs, cacheInputs_fn;
3400
+ var _Provider = class {
3350
3401
  /**
3351
3402
  * Constructor to initialize a Provider.
3352
3403
  *
@@ -3357,25 +3408,27 @@ var Provider = class _Provider {
3357
3408
  */
3358
3409
  constructor(url, options = {}) {
3359
3410
  this.url = url;
3411
+ /**
3412
+ * @hidden
3413
+ */
3414
+ __privateAdd(this, _cacheInputs);
3415
+ __publicField(this, "operations");
3416
+ __publicField(this, "cache");
3417
+ __publicField(this, "options", {
3418
+ timeout: void 0,
3419
+ cacheUtxo: void 0,
3420
+ fetch: void 0,
3421
+ retryOptions: void 0
3422
+ });
3360
3423
  this.options = { ...this.options, ...options };
3361
3424
  this.url = url;
3362
3425
  this.operations = this.createOperations();
3363
3426
  this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
3364
3427
  }
3365
- operations;
3366
- cache;
3367
3428
  static clearChainAndNodeCaches() {
3368
3429
  _Provider.nodeInfoCache = {};
3369
3430
  _Provider.chainInfoCache = {};
3370
3431
  }
3371
- static chainInfoCache = {};
3372
- static nodeInfoCache = {};
3373
- options = {
3374
- timeout: void 0,
3375
- cacheUtxo: void 0,
3376
- fetch: void 0,
3377
- retryOptions: void 0
3378
- };
3379
3432
  static getFetchFn(options) {
3380
3433
  const { retryOptions, timeout } = options;
3381
3434
  return autoRetryFetch(async (...args) => {
@@ -3572,19 +3625,6 @@ var Provider = class _Provider {
3572
3625
  } = this.getChain();
3573
3626
  return chainId.toNumber();
3574
3627
  }
3575
- /**
3576
- * @hidden
3577
- */
3578
- #cacheInputs(inputs) {
3579
- if (!this.cache) {
3580
- return;
3581
- }
3582
- inputs.forEach((input) => {
3583
- if (input.type === InputType6.Coin) {
3584
- this.cache?.set(input.id);
3585
- }
3586
- });
3587
- }
3588
3628
  /**
3589
3629
  * Submits a transaction to the chain to be executed.
3590
3630
  *
@@ -3597,7 +3637,7 @@ var Provider = class _Provider {
3597
3637
  // #region Provider-sendTransaction
3598
3638
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
3599
3639
  const transactionRequest = transactionRequestify(transactionRequestLike);
3600
- this.#cacheInputs(transactionRequest.inputs);
3640
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
3601
3641
  if (estimateTxDependencies) {
3602
3642
  await this.estimateTxDependencies(transactionRequest);
3603
3643
  }
@@ -3774,7 +3814,8 @@ var Provider = class _Provider {
3774
3814
  async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3775
3815
  estimateTxDependencies = true,
3776
3816
  estimatePredicates = true,
3777
- resourcesOwner
3817
+ resourcesOwner,
3818
+ signatureCallback
3778
3819
  } = {}) {
3779
3820
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3780
3821
  const chainInfo = this.getChain();
@@ -3793,6 +3834,9 @@ var Provider = class _Provider {
3793
3834
  }
3794
3835
  await this.estimatePredicates(txRequestClone);
3795
3836
  }
3837
+ if (signatureCallback && isScriptTransaction) {
3838
+ await signatureCallback(txRequestClone);
3839
+ }
3796
3840
  const minGas = txRequestClone.calculateMinGas(chainInfo);
3797
3841
  const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3798
3842
  let receipts = [];
@@ -4222,6 +4266,20 @@ var Provider = class _Provider {
4222
4266
  return new TransactionResponse(transactionId, this);
4223
4267
  }
4224
4268
  };
4269
+ var Provider = _Provider;
4270
+ _cacheInputs = new WeakSet();
4271
+ cacheInputs_fn = function(inputs) {
4272
+ if (!this.cache) {
4273
+ return;
4274
+ }
4275
+ inputs.forEach((input) => {
4276
+ if (input.type === InputType6.Coin) {
4277
+ this.cache?.set(input.id);
4278
+ }
4279
+ });
4280
+ };
4281
+ __publicField(Provider, "chainInfoCache", {});
4282
+ __publicField(Provider, "nodeInfoCache", {});
4225
4283
 
4226
4284
  // src/providers/transaction-summary/get-transaction-summary.ts
4227
4285
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
@@ -4660,6 +4718,21 @@ var Account = class extends AbstractAccount {
4660
4718
  }
4661
4719
  return this._connector.signMessage(this.address.toString(), message);
4662
4720
  }
4721
+ /**
4722
+ * Signs a transaction with the wallet's private key.
4723
+ *
4724
+ * @param transactionRequestLike - The transaction request to sign.
4725
+ * @returns A promise that resolves to the signature of the transaction.
4726
+ */
4727
+ async signTransaction(transactionRequestLike) {
4728
+ if (!this._connector) {
4729
+ throw new FuelError14(
4730
+ ErrorCode14.MISSING_CONNECTOR,
4731
+ "A connector is required to sign transactions."
4732
+ );
4733
+ }
4734
+ return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
4735
+ }
4663
4736
  /**
4664
4737
  * Sends a transaction to the network.
4665
4738
  *
@@ -4722,7 +4795,7 @@ import { hash } from "@fuel-ts/hasher";
4722
4795
  import { toBytes } from "@fuel-ts/math";
4723
4796
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
4724
4797
  import { secp256k1 } from "@noble/curves/secp256k1";
4725
- var Signer = class _Signer {
4798
+ var Signer = class {
4726
4799
  address;
4727
4800
  publicKey;
4728
4801
  compressedPublicKey;
@@ -4801,7 +4874,7 @@ var Signer = class _Signer {
4801
4874
  * @returns Address from signature
4802
4875
  */
4803
4876
  static recoverAddress(data, signature) {
4804
- return Address4.fromPublicKey(_Signer.recoverPublicKey(data, signature));
4877
+ return Address4.fromPublicKey(Signer.recoverPublicKey(data, signature));
4805
4878
  }
4806
4879
  /**
4807
4880
  * Generate a random privateKey
@@ -4925,10 +4998,6 @@ async function decryptKeystoreWallet(jsonWallet, password) {
4925
4998
 
4926
4999
  // src/wallet/base-wallet-unlocked.ts
4927
5000
  var BaseWalletUnlocked = class extends Account {
4928
- /**
4929
- * Default HDWallet path.
4930
- */
4931
- static defaultPath = "m/44'/1179993420'/0'/0/0";
4932
5001
  /**
4933
5002
  * A function that returns the wallet's signer.
4934
5003
  */
@@ -4978,7 +5047,7 @@ var BaseWalletUnlocked = class extends Account {
4978
5047
  */
4979
5048
  async signTransaction(transactionRequestLike) {
4980
5049
  const transactionRequest = transactionRequestify(transactionRequestLike);
4981
- const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
5050
+ const chainId = this.provider.getChainId();
4982
5051
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
4983
5052
  const signature = await this.signer().sign(hashedTransaction);
4984
5053
  return hexlify15(signature);
@@ -5034,6 +5103,10 @@ var BaseWalletUnlocked = class extends Account {
5034
5103
  return encryptKeystoreWallet(this.privateKey, this.address, password);
5035
5104
  }
5036
5105
  };
5106
+ /**
5107
+ * Default HDWallet path.
5108
+ */
5109
+ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5037
5110
 
5038
5111
  // src/hdwallet/hdwallet.ts
5039
5112
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
@@ -7237,7 +7310,7 @@ function assertMnemonic(words) {
7237
7310
  throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7238
7311
  }
7239
7312
  }
7240
- var Mnemonic = class _Mnemonic {
7313
+ var Mnemonic = class {
7241
7314
  wordlist;
7242
7315
  /**
7243
7316
  *
@@ -7254,7 +7327,7 @@ var Mnemonic = class _Mnemonic {
7254
7327
  * @returns Entropy hash
7255
7328
  */
7256
7329
  mnemonicToEntropy(phrase) {
7257
- return _Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
7330
+ return Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
7258
7331
  }
7259
7332
  /**
7260
7333
  *
@@ -7262,7 +7335,7 @@ var Mnemonic = class _Mnemonic {
7262
7335
  * @returns Mnemonic phrase
7263
7336
  */
7264
7337
  entropyToMnemonic(entropy) {
7265
- return _Mnemonic.entropyToMnemonic(entropy, this.wordlist);
7338
+ return Mnemonic.entropyToMnemonic(entropy, this.wordlist);
7266
7339
  }
7267
7340
  /**
7268
7341
  *
@@ -7303,8 +7376,8 @@ var Mnemonic = class _Mnemonic {
7303
7376
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7304
7377
  */
7305
7378
  static mnemonicToMasterKeys(phrase, passphrase = "") {
7306
- const seed = _Mnemonic.mnemonicToSeed(phrase, passphrase);
7307
- return _Mnemonic.masterKeysFromSeed(seed);
7379
+ const seed = Mnemonic.mnemonicToSeed(phrase, passphrase);
7380
+ return Mnemonic.masterKeysFromSeed(seed);
7308
7381
  }
7309
7382
  /**
7310
7383
  * Validates if given mnemonic is valid
@@ -7320,7 +7393,7 @@ var Mnemonic = class _Mnemonic {
7320
7393
  return false;
7321
7394
  }
7322
7395
  while (i < words.length) {
7323
- if (_Mnemonic.binarySearch(words[i]) === false) {
7396
+ if (Mnemonic.binarySearch(words[i]) === false) {
7324
7397
  return false;
7325
7398
  }
7326
7399
  i += 1;
@@ -7367,7 +7440,7 @@ var Mnemonic = class _Mnemonic {
7367
7440
  * @returns BIP-32 extended private key
7368
7441
  */
7369
7442
  static seedToExtendedKey(seed, testnet = false) {
7370
- const masterKey = _Mnemonic.masterKeysFromSeed(seed);
7443
+ const masterKey = Mnemonic.masterKeysFromSeed(seed);
7371
7444
  const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
7372
7445
  const depth = "0x00";
7373
7446
  const fingerprint = "0x00000000";
@@ -7399,7 +7472,7 @@ var Mnemonic = class _Mnemonic {
7399
7472
  */
7400
7473
  static generate(size = 32, extraEntropy = "") {
7401
7474
  const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7402
- return _Mnemonic.entropyToMnemonic(entropy);
7475
+ return Mnemonic.entropyToMnemonic(entropy);
7403
7476
  }
7404
7477
  };
7405
7478
  var mnemonic_default = Mnemonic;
@@ -7439,7 +7512,7 @@ function parsePath(path2, depth = 0) {
7439
7512
  (p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
7440
7513
  );
7441
7514
  }
7442
- var HDWallet = class _HDWallet {
7515
+ var HDWallet = class {
7443
7516
  depth = 0;
7444
7517
  index = 0;
7445
7518
  fingerprint = hexlify17("0x00000000");
@@ -7505,7 +7578,7 @@ var HDWallet = class _HDWallet {
7505
7578
  if (privateKey) {
7506
7579
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7507
7580
  const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
7508
- return new _HDWallet({
7581
+ return new HDWallet({
7509
7582
  privateKey: ki,
7510
7583
  chainCode: IR,
7511
7584
  index,
@@ -7515,7 +7588,7 @@ var HDWallet = class _HDWallet {
7515
7588
  }
7516
7589
  const signer = new Signer(hexlify17(IL));
7517
7590
  const Ki = signer.addPoint(publicKey);
7518
- return new _HDWallet({
7591
+ return new HDWallet({
7519
7592
  publicKey: Ki,
7520
7593
  chainCode: IR,
7521
7594
  index,
@@ -7564,7 +7637,7 @@ var HDWallet = class _HDWallet {
7564
7637
  */
7565
7638
  static fromSeed(seed) {
7566
7639
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7567
- return new _HDWallet({
7640
+ return new HDWallet({
7568
7641
  chainCode: arrayify18(masterKey.slice(32)),
7569
7642
  privateKey: arrayify18(masterKey.slice(0, 32))
7570
7643
  });
@@ -7594,7 +7667,7 @@ var HDWallet = class _HDWallet {
7594
7667
  if (key[0] !== 3) {
7595
7668
  throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
7596
7669
  }
7597
- return new _HDWallet({
7670
+ return new HDWallet({
7598
7671
  publicKey: key,
7599
7672
  chainCode,
7600
7673
  index,
@@ -7605,7 +7678,7 @@ var HDWallet = class _HDWallet {
7605
7678
  if (key[0] !== 0) {
7606
7679
  throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
7607
7680
  }
7608
- return new _HDWallet({
7681
+ return new HDWallet({
7609
7682
  privateKey: key.slice(1),
7610
7683
  chainCode,
7611
7684
  index,
@@ -7628,7 +7701,7 @@ var WalletLocked = class extends Account {
7628
7701
  return new WalletUnlocked(privateKey, this._provider);
7629
7702
  }
7630
7703
  };
7631
- var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7704
+ var WalletUnlocked = class extends BaseWalletUnlocked {
7632
7705
  /**
7633
7706
  * Locks the wallet and returns an instance of WalletLocked.
7634
7707
  *
@@ -7646,7 +7719,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7646
7719
  */
7647
7720
  static generate(generateOptions) {
7648
7721
  const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
7649
- return new _WalletUnlocked(privateKey, generateOptions?.provider);
7722
+ return new WalletUnlocked(privateKey, generateOptions?.provider);
7650
7723
  }
7651
7724
  /**
7652
7725
  * Create a Wallet Unlocked from a seed.
@@ -7658,8 +7731,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7658
7731
  */
7659
7732
  static fromSeed(seed, path2, provider) {
7660
7733
  const hdWallet = hdwallet_default.fromSeed(seed);
7661
- const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
7662
- return new _WalletUnlocked(childWallet.privateKey, provider);
7734
+ const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
7735
+ return new WalletUnlocked(childWallet.privateKey, provider);
7663
7736
  }
7664
7737
  /**
7665
7738
  * Create a Wallet Unlocked from a mnemonic phrase.
@@ -7673,8 +7746,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7673
7746
  static fromMnemonic(mnemonic, path2, passphrase, provider) {
7674
7747
  const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
7675
7748
  const hdWallet = hdwallet_default.fromSeed(seed);
7676
- const childWallet = hdWallet.derivePath(path2 || _WalletUnlocked.defaultPath);
7677
- return new _WalletUnlocked(childWallet.privateKey, provider);
7749
+ const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
7750
+ return new WalletUnlocked(childWallet.privateKey, provider);
7678
7751
  }
7679
7752
  /**
7680
7753
  * Create a Wallet Unlocked from an extended key.
@@ -7685,7 +7758,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7685
7758
  */
7686
7759
  static fromExtendedKey(extendedKey, provider) {
7687
7760
  const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
7688
- return new _WalletUnlocked(hdWallet.privateKey, provider);
7761
+ return new WalletUnlocked(hdWallet.privateKey, provider);
7689
7762
  }
7690
7763
  /**
7691
7764
  * Create a Wallet Unlocked from an encrypted JSON.
@@ -7697,7 +7770,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
7697
7770
  */
7698
7771
  static async fromEncryptedJson(jsonWallet, password, provider) {
7699
7772
  const privateKey = await decryptKeystoreWallet(jsonWallet, password);
7700
- return new _WalletUnlocked(privateKey, provider);
7773
+ return new WalletUnlocked(privateKey, provider);
7701
7774
  }
7702
7775
  };
7703
7776
 
@@ -7723,50 +7796,50 @@ var Wallet = class {
7723
7796
  static fromPrivateKey(privateKey, provider) {
7724
7797
  return new WalletUnlocked(privateKey, provider);
7725
7798
  }
7726
- /**
7727
- * Generate a new Wallet Unlocked with a random key pair.
7728
- *
7729
- * @param generateOptions - Options to customize the generation process (optional).
7730
- * @returns An unlocked wallet instance.
7731
- */
7732
- static generate = WalletUnlocked.generate;
7733
- /**
7734
- * Create a Wallet Unlocked from a seed.
7735
- *
7736
- * @param seed - The seed phrase.
7737
- * @param provider - A Provider instance (optional).
7738
- * @param path - The derivation path (optional).
7739
- * @returns An unlocked wallet instance.
7740
- */
7741
- static fromSeed = WalletUnlocked.fromSeed;
7742
- /**
7743
- * Create a Wallet Unlocked from a mnemonic phrase.
7744
- *
7745
- * @param mnemonic - The mnemonic phrase.
7746
- * @param provider - A Provider instance (optional).
7747
- * @param path - The derivation path (optional).
7748
- * @param passphrase - The passphrase for the mnemonic (optional).
7749
- * @returns An unlocked wallet instance.
7750
- */
7751
- static fromMnemonic = WalletUnlocked.fromMnemonic;
7752
- /**
7753
- * Create a Wallet Unlocked from an extended key.
7754
- *
7755
- * @param extendedKey - The extended key.
7756
- * @param provider - A Provider instance (optional).
7757
- * @returns An unlocked wallet instance.
7758
- */
7759
- static fromExtendedKey = WalletUnlocked.fromExtendedKey;
7760
- /**
7761
- * Create a Wallet Unlocked from an encrypted JSON.
7762
- *
7763
- * @param jsonWallet - The encrypted JSON keystore.
7764
- * @param password - The password to decrypt the JSON.
7765
- * @param provider - A Provider instance (optional).
7766
- * @returns An unlocked wallet instance.
7767
- */
7768
- static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
7769
7799
  };
7800
+ /**
7801
+ * Generate a new Wallet Unlocked with a random key pair.
7802
+ *
7803
+ * @param generateOptions - Options to customize the generation process (optional).
7804
+ * @returns An unlocked wallet instance.
7805
+ */
7806
+ __publicField(Wallet, "generate", WalletUnlocked.generate);
7807
+ /**
7808
+ * Create a Wallet Unlocked from a seed.
7809
+ *
7810
+ * @param seed - The seed phrase.
7811
+ * @param provider - A Provider instance (optional).
7812
+ * @param path - The derivation path (optional).
7813
+ * @returns An unlocked wallet instance.
7814
+ */
7815
+ __publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
7816
+ /**
7817
+ * Create a Wallet Unlocked from a mnemonic phrase.
7818
+ *
7819
+ * @param mnemonic - The mnemonic phrase.
7820
+ * @param provider - A Provider instance (optional).
7821
+ * @param path - The derivation path (optional).
7822
+ * @param passphrase - The passphrase for the mnemonic (optional).
7823
+ * @returns An unlocked wallet instance.
7824
+ */
7825
+ __publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
7826
+ /**
7827
+ * Create a Wallet Unlocked from an extended key.
7828
+ *
7829
+ * @param extendedKey - The extended key.
7830
+ * @param provider - A Provider instance (optional).
7831
+ * @returns An unlocked wallet instance.
7832
+ */
7833
+ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7834
+ /**
7835
+ * Create a Wallet Unlocked from an encrypted JSON.
7836
+ *
7837
+ * @param jsonWallet - The encrypted JSON keystore.
7838
+ * @param password - The password to decrypt the JSON.
7839
+ * @param provider - A Provider instance (optional).
7840
+ * @returns An unlocked wallet instance.
7841
+ */
7842
+ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7770
7843
 
7771
7844
  // src/test-utils/seedTestWallet.ts
7772
7845
  import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";