@fuel-ts/account 0.97.2 → 0.98.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.
Files changed (110) hide show
  1. package/dist/account.d.ts +19 -16
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts +4 -4
  4. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  5. package/dist/connectors/fuel.d.ts +3 -3
  6. package/dist/connectors/fuel.d.ts.map +1 -1
  7. package/dist/connectors/types/data-type.d.ts +8 -0
  8. package/dist/connectors/types/data-type.d.ts.map +1 -1
  9. package/dist/hdwallet/hdwallet.d.ts +1 -1
  10. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.global.js +2922 -1249
  14. package/dist/index.global.js.map +1 -1
  15. package/dist/index.js +333 -279
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +358 -309
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/mnemonic/mnemonic.d.ts +1 -1
  20. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  21. package/dist/mnemonic/utils.d.ts +1 -1
  22. package/dist/mnemonic/utils.d.ts.map +1 -1
  23. package/dist/predicate/predicate.d.ts +9 -1
  24. package/dist/predicate/predicate.d.ts.map +1 -1
  25. package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
  26. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
  27. package/dist/providers/__generated__/operations.d.ts +0 -169
  28. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  29. package/dist/providers/coin-quantity.d.ts +1 -1
  30. package/dist/providers/coin-quantity.d.ts.map +1 -1
  31. package/dist/providers/coin.d.ts +3 -2
  32. package/dist/providers/coin.d.ts.map +1 -1
  33. package/dist/providers/message.d.ts +8 -7
  34. package/dist/providers/message.d.ts.map +1 -1
  35. package/dist/providers/provider.d.ts +27 -34
  36. package/dist/providers/provider.d.ts.map +1 -1
  37. package/dist/providers/resource.d.ts +1 -1
  38. package/dist/providers/resource.d.ts.map +1 -1
  39. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  40. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  41. package/dist/providers/transaction-request/errors.d.ts +3 -3
  42. package/dist/providers/transaction-request/errors.d.ts.map +1 -1
  43. package/dist/providers/transaction-request/helpers.d.ts +26 -4
  44. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  45. package/dist/providers/transaction-request/input.d.ts +1 -1
  46. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  47. package/dist/providers/transaction-request/output.d.ts +1 -1
  48. package/dist/providers/transaction-request/output.d.ts.map +1 -1
  49. package/dist/providers/transaction-request/script-transaction-request.d.ts +13 -3
  50. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  51. package/dist/providers/transaction-request/scripts.d.ts +1 -1
  52. package/dist/providers/transaction-request/scripts.d.ts.map +1 -1
  53. package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
  54. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
  55. package/dist/providers/transaction-request/transaction-request.d.ts +5 -3
  56. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  57. package/dist/providers/transaction-request/types.d.ts +7 -0
  58. package/dist/providers/transaction-request/types.d.ts.map +1 -1
  59. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +1 -1
  60. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
  61. package/dist/providers/transaction-request/upload-transaction-request.d.ts +1 -1
  62. package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
  63. package/dist/providers/transaction-request/witness.d.ts +1 -1
  64. package/dist/providers/transaction-request/witness.d.ts.map +1 -1
  65. package/dist/providers/transaction-response/transaction-response.d.ts +1 -1
  66. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  67. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  68. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +0 -1
  69. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -1
  70. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  71. package/dist/providers/transaction-summary/input.d.ts +1 -1
  72. package/dist/providers/transaction-summary/status.d.ts +9 -2
  73. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  74. package/dist/providers/transaction-summary/types.d.ts +1 -21
  75. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  76. package/dist/providers/utils/receipts.d.ts.map +1 -1
  77. package/dist/signer/signer.d.ts +1 -1
  78. package/dist/signer/signer.d.ts.map +1 -1
  79. package/dist/test-utils/launchNode.d.ts +2 -1
  80. package/dist/test-utils/launchNode.d.ts.map +1 -1
  81. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
  82. package/dist/test-utils/test-message.d.ts +6 -6
  83. package/dist/test-utils/test-message.d.ts.map +1 -1
  84. package/dist/test-utils.global.js +2908 -1240
  85. package/dist/test-utils.global.js.map +1 -1
  86. package/dist/test-utils.js +258 -219
  87. package/dist/test-utils.js.map +1 -1
  88. package/dist/test-utils.mjs +287 -248
  89. package/dist/test-utils.mjs.map +1 -1
  90. package/dist/types.d.ts +11 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
  93. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  94. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  95. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  96. package/dist/wallet/keystore-wallet.d.ts +2 -2
  97. package/dist/wallet/keystore-wallet.d.ts.map +1 -1
  98. package/dist/wallet/wallet.d.ts +3 -2
  99. package/dist/wallet/wallet.d.ts.map +1 -1
  100. package/dist/wallet/wallets.d.ts +1 -1
  101. package/dist/wallet/wallets.d.ts.map +1 -1
  102. package/dist/wallet-manager/types.d.ts +4 -4
  103. package/dist/wallet-manager/types.d.ts.map +1 -1
  104. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +5 -5
  105. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
  106. package/dist/wallet-manager/vaults/privatekey-vault.d.ts +5 -5
  107. package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
  108. package/dist/wallet-manager/wallet-manager.d.ts +3 -3
  109. package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
  110. package/package.json +28 -29
@@ -220,7 +220,8 @@ var launchNode = async ({
220
220
  loggingEnabled = true,
221
221
  basePath,
222
222
  snapshotConfig = defaultSnapshotConfigs,
223
- includeInitialState = false
223
+ includeInitialState = false,
224
+ killProcessOnExit = false
224
225
  } = {}) => (
225
226
  // eslint-disable-next-line no-async-promise-executor
226
227
  new Promise(async (resolve, reject) => {
@@ -297,14 +298,14 @@ var launchNode = async ({
297
298
  console.log(chunk.toString());
298
299
  });
299
300
  }
300
- const removeSideffects = () => {
301
+ const removeChildListeners = () => {
301
302
  child.stderr.removeAllListeners();
303
+ };
304
+ const removeTempDir = () => {
302
305
  if (existsSync(tempDir)) {
303
306
  rmSync(tempDir, { recursive: true });
304
307
  }
305
308
  };
306
- child.on("error", removeSideffects);
307
- child.on("exit", removeSideffects);
308
309
  const childState = {
309
310
  isDead: false
310
311
  };
@@ -313,7 +314,7 @@ var launchNode = async ({
313
314
  return;
314
315
  }
315
316
  childState.isDead = true;
316
- removeSideffects();
317
+ removeChildListeners();
317
318
  if (child.pid !== void 0) {
318
319
  try {
319
320
  process.kill(-child.pid);
@@ -332,6 +333,7 @@ var launchNode = async ({
332
333
  } else {
333
334
  console.error("No PID available for the child process, unable to kill launched node");
334
335
  }
336
+ removeTempDir();
335
337
  };
336
338
  child.stderr.on("data", (chunk) => {
337
339
  const text = typeof chunk === "string" ? chunk : chunk.toString();
@@ -360,7 +362,18 @@ var launchNode = async ({
360
362
  process.on("SIGUSR2", cleanup);
361
363
  process.on("beforeExit", cleanup);
362
364
  process.on("uncaughtException", cleanup);
363
- child.on("error", reject);
365
+ child.on("exit", (code, _signal) => {
366
+ removeChildListeners();
367
+ removeTempDir();
368
+ if (killProcessOnExit) {
369
+ process.exit(code);
370
+ }
371
+ });
372
+ child.on("error", (err) => {
373
+ removeChildListeners();
374
+ removeTempDir();
375
+ reject(err);
376
+ });
364
377
  })
365
378
  );
366
379
 
@@ -405,7 +418,7 @@ var addAmountToCoinQuantities = (params) => {
405
418
 
406
419
  // src/providers/provider.ts
407
420
  import { Address as Address3 } from "@fuel-ts/address";
408
- import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
421
+ import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
409
422
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
410
423
  import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
411
424
  import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
@@ -1276,13 +1289,6 @@ var GetConsensusParametersVersionDocument = gql`
1276
1289
  }
1277
1290
  }
1278
1291
  `;
1279
- var SubmitAndAwaitDocument = gql`
1280
- subscription submitAndAwait($encodedTransaction: HexString!) {
1281
- submitAndAwait(tx: $encodedTransaction) {
1282
- ...transactionStatusSubscriptionFragment
1283
- }
1284
- }
1285
- ${TransactionStatusSubscriptionFragmentDoc}`;
1286
1292
  var SubmitAndAwaitStatusDocument = gql`
1287
1293
  subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
1288
1294
  submitAndAwaitStatus(tx: $encodedTransaction) {
@@ -1398,9 +1404,6 @@ function getSdk(requester) {
1398
1404
  getConsensusParametersVersion(variables, options) {
1399
1405
  return requester(GetConsensusParametersVersionDocument, variables, options);
1400
1406
  },
1401
- submitAndAwait(variables, options) {
1402
- return requester(SubmitAndAwaitDocument, variables, options);
1403
- },
1404
1407
  submitAndAwaitStatus(variables, options) {
1405
1408
  return requester(SubmitAndAwaitStatusDocument, variables, options);
1406
1409
  },
@@ -1684,13 +1687,13 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1684
1687
  import { Address as Address2, addressify } from "@fuel-ts/address";
1685
1688
  import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1686
1689
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
1687
- import { FuelError as FuelError9 } from "@fuel-ts/errors";
1690
+ import { FuelError as FuelError10 } from "@fuel-ts/errors";
1688
1691
  import { bn as bn8 } from "@fuel-ts/math";
1689
1692
  import {
1690
1693
  PolicyType,
1691
1694
  TransactionCoder,
1692
1695
  InputType as InputType3,
1693
- OutputType as OutputType2,
1696
+ OutputType as OutputType3,
1694
1697
  TransactionType
1695
1698
  } from "@fuel-ts/transactions";
1696
1699
  import { concat as concat2, hexlify as hexlify10, isDefined } from "@fuel-ts/utils";
@@ -1734,7 +1737,6 @@ function assembleReceiptByType(receipt) {
1734
1737
  const callReceipt = {
1735
1738
  type: ReceiptType.Call,
1736
1739
  id,
1737
- from: id,
1738
1740
  to: hexOrZero(receipt?.to),
1739
1741
  amount: bn4(receipt.amount),
1740
1742
  assetId: hexOrZero(receipt.assetId),
@@ -1802,10 +1804,6 @@ function assembleReceiptByType(receipt) {
1802
1804
  rb,
1803
1805
  rc,
1804
1806
  rd,
1805
- val0: ra,
1806
- val1: rb,
1807
- val2: rc,
1808
- val3: rd,
1809
1807
  pc: bn4(receipt.pc),
1810
1808
  is: bn4(receipt.is)
1811
1809
  };
@@ -1819,8 +1817,6 @@ function assembleReceiptByType(receipt) {
1819
1817
  id: hexOrZero(receipt.id || receipt.contractId),
1820
1818
  ra,
1821
1819
  rb,
1822
- val0: ra,
1823
- val1: rb,
1824
1820
  ptr: bn4(receipt.ptr),
1825
1821
  len: bn4(receipt.len),
1826
1822
  digest: hexOrZero(receipt.digest),
@@ -1835,7 +1831,6 @@ function assembleReceiptByType(receipt) {
1835
1831
  const transferReceipt = {
1836
1832
  type: ReceiptType.Transfer,
1837
1833
  id,
1838
- from: id,
1839
1834
  to: hexOrZero(receipt.toAddress || receipt?.to),
1840
1835
  amount: bn4(receipt.amount),
1841
1836
  assetId: hexOrZero(receipt.assetId),
@@ -1849,7 +1844,6 @@ function assembleReceiptByType(receipt) {
1849
1844
  const transferOutReceipt = {
1850
1845
  type: ReceiptType.TransferOut,
1851
1846
  id,
1852
- from: id,
1853
1847
  to: hexOrZero(receipt.toAddress || receipt.to),
1854
1848
  amount: bn4(receipt.amount),
1855
1849
  assetId: hexOrZero(receipt.assetId),
@@ -2207,8 +2201,9 @@ var NoWitnessAtIndexError = class extends Error {
2207
2201
  };
2208
2202
 
2209
2203
  // src/providers/transaction-request/helpers.ts
2204
+ import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
2210
2205
  import { bn as bn7 } from "@fuel-ts/math";
2211
- import { InputType as InputType2 } from "@fuel-ts/transactions";
2206
+ import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
2212
2207
  var isRequestInputCoin = (input) => input.type === InputType2.Coin;
2213
2208
  var isRequestInputMessage = (input) => input.type === InputType2.Message;
2214
2209
  var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
@@ -2239,6 +2234,32 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
2239
2234
  messages: []
2240
2235
  }
2241
2236
  );
2237
+ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
2238
+ const { inputs, outputs } = transactionRequest;
2239
+ const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
2240
+ if (inputs.some((i) => isRequestInputMessage(i) && bn7(i.amount).gt(0))) {
2241
+ coinInputs.add(baseAssetId);
2242
+ }
2243
+ const changeOutputs = new Set(
2244
+ outputs.filter((output) => output.type === OutputType2.Change).map((output) => output.assetId)
2245
+ );
2246
+ const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
2247
+ return difference.size;
2248
+ };
2249
+ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
2250
+ if (enableAssetBurn === true) {
2251
+ return;
2252
+ }
2253
+ if (getBurnableAssetCount(baseAssetId, transactionRequest) <= 0) {
2254
+ return;
2255
+ }
2256
+ const message = [
2257
+ "Asset burn detected.",
2258
+ "Add the relevant change outputs to the transaction to avoid burning assets.",
2259
+ "Or enable asset burn, upon sending the transaction."
2260
+ ].join("\n");
2261
+ throw new FuelError9(ErrorCode8.ASSET_BURN_DETECTED, message);
2262
+ };
2242
2263
 
2243
2264
  // src/providers/transaction-request/witness.ts
2244
2265
  import { arrayify as arrayify5, hexlify as hexlify9 } from "@fuel-ts/utils";
@@ -2439,7 +2460,7 @@ var BaseTransactionRequest = class {
2439
2460
  */
2440
2461
  getCoinOutputs() {
2441
2462
  return this.outputs.filter(
2442
- (output) => output.type === OutputType2.Coin
2463
+ (output) => output.type === OutputType3.Coin
2443
2464
  );
2444
2465
  }
2445
2466
  /**
@@ -2449,7 +2470,7 @@ var BaseTransactionRequest = class {
2449
2470
  */
2450
2471
  getChangeOutputs() {
2451
2472
  return this.outputs.filter(
2452
- (output) => output.type === OutputType2.Change
2473
+ (output) => output.type === OutputType3.Change
2453
2474
  );
2454
2475
  }
2455
2476
  /**
@@ -2570,7 +2591,7 @@ var BaseTransactionRequest = class {
2570
2591
  */
2571
2592
  addCoinOutput(to, amount, assetId) {
2572
2593
  this.pushOutput({
2573
- type: OutputType2.Coin,
2594
+ type: OutputType3.Coin,
2574
2595
  to: addressify(to).toB256(),
2575
2596
  amount,
2576
2597
  assetId
@@ -2586,7 +2607,7 @@ var BaseTransactionRequest = class {
2586
2607
  addCoinOutputs(to, quantities) {
2587
2608
  quantities.map(coinQuantityfy).forEach((quantity) => {
2588
2609
  this.pushOutput({
2589
- type: OutputType2.Coin,
2610
+ type: OutputType3.Coin,
2590
2611
  to: addressify(to).toB256(),
2591
2612
  amount: quantity.amount,
2592
2613
  assetId: quantity.assetId
@@ -2606,7 +2627,7 @@ var BaseTransactionRequest = class {
2606
2627
  );
2607
2628
  if (!changeOutput) {
2608
2629
  this.pushOutput({
2609
- type: OutputType2.Change,
2630
+ type: OutputType3.Change,
2610
2631
  to: addressify(to).toB256(),
2611
2632
  assetId
2612
2633
  });
@@ -2622,7 +2643,7 @@ var BaseTransactionRequest = class {
2622
2643
  * @hidden
2623
2644
  */
2624
2645
  metadataGas(_gasCosts) {
2625
- throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Not implemented");
2646
+ throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Not implemented");
2626
2647
  }
2627
2648
  /**
2628
2649
  * @hidden
@@ -2758,7 +2779,7 @@ import { clone as clone3 } from "ramda";
2758
2779
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2759
2780
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2760
2781
  import { bn as bn9 } from "@fuel-ts/math";
2761
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2782
+ import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType4, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2762
2783
  import { concat as concat3 } from "@fuel-ts/utils";
2763
2784
  import { clone as clone2 } from "ramda";
2764
2785
  function hashTransaction(transactionRequest, chainId) {
@@ -2799,16 +2820,16 @@ function hashTransaction(transactionRequest, chainId) {
2799
2820
  transaction.outputs = transaction.outputs.map((output) => {
2800
2821
  const outputClone = clone2(output);
2801
2822
  switch (outputClone.type) {
2802
- case OutputType3.Contract: {
2823
+ case OutputType4.Contract: {
2803
2824
  outputClone.balanceRoot = ZeroBytes325;
2804
2825
  outputClone.stateRoot = ZeroBytes325;
2805
2826
  return outputClone;
2806
2827
  }
2807
- case OutputType3.Change: {
2828
+ case OutputType4.Change: {
2808
2829
  outputClone.amount = bn9(0);
2809
2830
  return outputClone;
2810
2831
  }
2811
- case OutputType3.Variable: {
2832
+ case OutputType4.Variable: {
2812
2833
  outputClone.to = ZeroBytes325;
2813
2834
  outputClone.amount = bn9(0);
2814
2835
  outputClone.assetId = ZeroBytes325;
@@ -2889,7 +2910,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2889
2910
  // src/providers/transaction-request/create-transaction-request.ts
2890
2911
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2891
2912
  import { bn as bn10 } from "@fuel-ts/math";
2892
- import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2913
+ import { TransactionType as TransactionType3, OutputType as OutputType5 } from "@fuel-ts/transactions";
2893
2914
  import { arrayify as arrayify7, hexlify as hexlify12 } from "@fuel-ts/utils";
2894
2915
  import { clone as clone4 } from "ramda";
2895
2916
 
@@ -2965,7 +2986,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2965
2986
  */
2966
2987
  getContractCreatedOutputs() {
2967
2988
  return this.outputs.filter(
2968
- (output) => output.type === OutputType4.ContractCreated
2989
+ (output) => output.type === OutputType5.ContractCreated
2969
2990
  );
2970
2991
  }
2971
2992
  /**
@@ -2986,7 +3007,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2986
3007
  */
2987
3008
  addContractCreatedOutput(contractId, stateRoot) {
2988
3009
  this.pushOutput({
2989
- type: OutputType4.ContractCreated,
3010
+ type: OutputType5.ContractCreated,
2990
3011
  contractId,
2991
3012
  stateRoot
2992
3013
  });
@@ -3006,7 +3027,7 @@ import { Interface } from "@fuel-ts/abi-coder";
3006
3027
  import { addressify as addressify2 } from "@fuel-ts/address";
3007
3028
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
3008
3029
  import { bn as bn11 } from "@fuel-ts/math";
3009
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
3030
+ import { InputType as InputType5, OutputType as OutputType6, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
3010
3031
  import { arrayify as arrayify9, hexlify as hexlify13 } from "@fuel-ts/utils";
3011
3032
  import { clone as clone5 } from "ramda";
3012
3033
 
@@ -3062,6 +3083,20 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3062
3083
  this.scriptData = arrayify9(scriptData ?? returnZeroScript.encodeScriptData());
3063
3084
  this.abis = rest.abis;
3064
3085
  }
3086
+ /**
3087
+ * Helper function to estimate and fund the transaction request with a specified account.
3088
+ *
3089
+ * @param account - The account to fund the transaction.
3090
+ * @param params - The parameters for the transaction cost.
3091
+ * @returns The current instance of the `ScriptTransactionRequest` funded.
3092
+ */
3093
+ async estimateAndFund(account, { signatureCallback, quantities = [] } = {}) {
3094
+ const txCost = await account.getTransactionCost(this, { signatureCallback, quantities });
3095
+ this.maxFee = txCost.maxFee;
3096
+ this.gasLimit = txCost.gasUsed;
3097
+ await account.fund(this, txCost);
3098
+ return this;
3099
+ }
3065
3100
  /**
3066
3101
  * Converts the transaction request to a `TransactionScript`.
3067
3102
  *
@@ -3098,7 +3133,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3098
3133
  */
3099
3134
  getContractOutputs() {
3100
3135
  return this.outputs.filter(
3101
- (output) => output.type === OutputType5.Contract
3136
+ (output) => output.type === OutputType6.Contract
3102
3137
  );
3103
3138
  }
3104
3139
  /**
@@ -3108,7 +3143,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3108
3143
  */
3109
3144
  getVariableOutputs() {
3110
3145
  return this.outputs.filter(
3111
- (output) => output.type === OutputType5.Variable
3146
+ (output) => output.type === OutputType6.Variable
3112
3147
  );
3113
3148
  }
3114
3149
  /**
@@ -3131,7 +3166,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3131
3166
  let outputsNumber = numberOfVariables;
3132
3167
  while (outputsNumber) {
3133
3168
  this.pushOutput({
3134
- type: OutputType5.Variable
3169
+ type: OutputType6.Variable
3135
3170
  });
3136
3171
  outputsNumber -= 1;
3137
3172
  }
@@ -3180,7 +3215,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3180
3215
  txPointer: "0x00000000000000000000000000000000"
3181
3216
  });
3182
3217
  this.pushOutput({
3183
- type: OutputType5.Contract,
3218
+ type: OutputType6.Contract,
3184
3219
  inputIndex
3185
3220
  });
3186
3221
  return this;
@@ -3216,7 +3251,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3216
3251
  };
3217
3252
 
3218
3253
  // src/providers/transaction-request/upgrade-transaction-request.ts
3219
- import { FuelError as FuelError10 } from "@fuel-ts/errors";
3254
+ import { FuelError as FuelError11 } from "@fuel-ts/errors";
3220
3255
  import { hash as hash2 } from "@fuel-ts/hasher";
3221
3256
  import {
3222
3257
  TransactionType as TransactionType5,
@@ -3323,7 +3358,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3323
3358
  }
3324
3359
  };
3325
3360
  } else {
3326
- throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3361
+ throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3327
3362
  }
3328
3363
  return {
3329
3364
  type: TransactionType5.Upgrade,
@@ -3365,7 +3400,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3365
3400
  txBytesSize
3366
3401
  });
3367
3402
  }
3368
- throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3403
+ throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3369
3404
  }
3370
3405
  };
3371
3406
 
@@ -3476,7 +3511,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3476
3511
  };
3477
3512
 
3478
3513
  // src/providers/transaction-request/utils.ts
3479
- import { ErrorCode as ErrorCode8, FuelError as FuelError11 } from "@fuel-ts/errors";
3514
+ import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
3480
3515
  import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
3481
3516
  var transactionRequestify = (obj) => {
3482
3517
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
@@ -3500,8 +3535,8 @@ var transactionRequestify = (obj) => {
3500
3535
  return UploadTransactionRequest.from(obj);
3501
3536
  }
3502
3537
  default: {
3503
- throw new FuelError11(
3504
- ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
3538
+ throw new FuelError12(
3539
+ ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
3505
3540
  `Unsupported transaction type: ${type}.`
3506
3541
  );
3507
3542
  }
@@ -3511,9 +3546,9 @@ var isTransactionTypeScript = (request) => request.type === TransactionType7.Scr
3511
3546
  var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
3512
3547
 
3513
3548
  // src/providers/transaction-response/transaction-response.ts
3514
- import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
3549
+ import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
3515
3550
  import { bn as bn16 } from "@fuel-ts/math";
3516
- import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
3551
+ import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
3517
3552
  import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
3518
3553
 
3519
3554
  // src/providers/transaction-summary/assemble-transaction-summary.ts
@@ -3530,12 +3565,8 @@ var calculateTXFeeForSummary = (params) => {
3530
3565
  gasPrice,
3531
3566
  rawPayload,
3532
3567
  tip,
3533
- totalFee,
3534
3568
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
3535
3569
  } = params;
3536
- if (totalFee) {
3537
- return totalFee;
3538
- }
3539
3570
  const gasPerByte = bn12(feeParams.gasPerByte);
3540
3571
  const gasPriceFactor = bn12(feeParams.gasPriceFactor);
3541
3572
  const transactionBytes = arrayify11(rawPayload);
@@ -3593,7 +3624,7 @@ var calculateTXFeeForSummary = (params) => {
3593
3624
 
3594
3625
  // src/providers/transaction-summary/operations.ts
3595
3626
  import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
3596
- import { ErrorCode as ErrorCode10, FuelError as FuelError13 } from "@fuel-ts/errors";
3627
+ import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
3597
3628
  import { bn as bn13 } from "@fuel-ts/math";
3598
3629
  import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
3599
3630
 
@@ -3631,7 +3662,7 @@ var getFunctionCall = ({ abi, receipt }) => {
3631
3662
  };
3632
3663
 
3633
3664
  // src/providers/transaction-summary/input.ts
3634
- import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
3665
+ import { ErrorCode as ErrorCode10, FuelError as FuelError13 } from "@fuel-ts/errors";
3635
3666
  import { BN } from "@fuel-ts/math";
3636
3667
  import { InputType as InputType6 } from "@fuel-ts/transactions";
3637
3668
  function getInputsByTypes(inputs, types) {
@@ -3659,10 +3690,10 @@ function findCoinInput(inputs, assetId) {
3659
3690
  const coinInputs = getInputsCoin(inputs);
3660
3691
  return coinInputs.find((i) => i.assetId === assetId);
3661
3692
  }
3662
- function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
3693
+ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
3663
3694
  const aggregated = /* @__PURE__ */ new Map();
3664
3695
  getInputsCoinAndMessage(inputs).forEach((input) => {
3665
- const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
3696
+ const assetId = isInputCoin(input) ? input.assetId : baseAssetId;
3666
3697
  const owner = isInputCoin(input) ? input.owner : input.recipient;
3667
3698
  let ownersMap = aggregated.get(assetId);
3668
3699
  if (!ownersMap) {
@@ -3700,8 +3731,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
3700
3731
  return void 0;
3701
3732
  }
3702
3733
  if (contractInput.type !== InputType6.Contract) {
3703
- throw new FuelError12(
3704
- ErrorCode9.INVALID_TRANSACTION_INPUT,
3734
+ throw new FuelError13(
3735
+ ErrorCode10.INVALID_TRANSACTION_INPUT,
3705
3736
  `Contract input should be of type 'contract'.`
3706
3737
  );
3707
3738
  }
@@ -3718,21 +3749,21 @@ function getInputAccountAddress(input) {
3718
3749
  }
3719
3750
 
3720
3751
  // src/providers/transaction-summary/output.ts
3721
- import { OutputType as OutputType6 } from "@fuel-ts/transactions";
3752
+ import { OutputType as OutputType7 } from "@fuel-ts/transactions";
3722
3753
  function getOutputsByType(outputs, type) {
3723
3754
  return outputs.filter((o) => o.type === type);
3724
3755
  }
3725
3756
  function getOutputsContractCreated(outputs) {
3726
- return getOutputsByType(outputs, OutputType6.ContractCreated);
3757
+ return getOutputsByType(outputs, OutputType7.ContractCreated);
3727
3758
  }
3728
3759
  function getOutputsCoin(outputs) {
3729
- return getOutputsByType(outputs, OutputType6.Coin);
3760
+ return getOutputsByType(outputs, OutputType7.Coin);
3730
3761
  }
3731
3762
  function getOutputsChange(outputs) {
3732
- return getOutputsByType(outputs, OutputType6.Change);
3763
+ return getOutputsByType(outputs, OutputType7.Change);
3733
3764
  }
3734
3765
  function getOutputsContract(outputs) {
3735
- return getOutputsByType(outputs, OutputType6.Contract);
3766
+ return getOutputsByType(outputs, OutputType7.Contract);
3736
3767
  }
3737
3768
 
3738
3769
  // src/providers/transaction-summary/operations.ts
@@ -3754,8 +3785,8 @@ function getTransactionTypeName(transactionType) {
3754
3785
  case TransactionType9.Upload:
3755
3786
  return "Upload" /* Upload */;
3756
3787
  default:
3757
- throw new FuelError13(
3758
- ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
3788
+ throw new FuelError14(
3789
+ ErrorCode11.UNSUPPORTED_TRANSACTION_TYPE,
3759
3790
  `Unsupported transaction type: ${transactionType}.`
3760
3791
  );
3761
3792
  }
@@ -3948,7 +3979,7 @@ function getContractCallOperations({
3948
3979
  }
3949
3980
  function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
3950
3981
  const { to: toAddress, assetId, amount } = receipt;
3951
- let { from: fromAddress } = receipt;
3982
+ let { id: fromAddress } = receipt;
3952
3983
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3953
3984
  if (ZeroBytes329 === fromAddress) {
3954
3985
  const change = changeOutputs.find((output) => output.assetId === assetId);
@@ -4135,7 +4166,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
4135
4166
  };
4136
4167
 
4137
4168
  // src/providers/transaction-summary/status.ts
4138
- import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
4169
+ import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
4139
4170
  import { bn as bn14 } from "@fuel-ts/math";
4140
4171
  var getTransactionStatusName = (gqlStatus) => {
4141
4172
  switch (gqlStatus) {
@@ -4148,8 +4179,8 @@ var getTransactionStatusName = (gqlStatus) => {
4148
4179
  case "SqueezedOutStatus":
4149
4180
  return "squeezedout" /* squeezedout */;
4150
4181
  default:
4151
- throw new FuelError14(
4152
- ErrorCode11.INVALID_TRANSACTION_STATUS,
4182
+ throw new FuelError15(
4183
+ ErrorCode12.INVALID_TRANSACTION_STATUS,
4153
4184
  `Invalid transaction status: ${gqlStatus}.`
4154
4185
  );
4155
4186
  }
@@ -4199,6 +4230,7 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4199
4230
  };
4200
4231
  return processedGraphqlStatus;
4201
4232
  };
4233
+ var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? bn14(status.totalFee) : void 0;
4202
4234
 
4203
4235
  // src/providers/transaction-summary/assemble-transaction-summary.ts
4204
4236
  function assembleTransactionSummary(params) {
@@ -4232,8 +4264,7 @@ function assembleTransactionSummary(params) {
4232
4264
  const typeName = getTransactionTypeName(transaction.type);
4233
4265
  const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
4234
4266
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
4235
- const fee = calculateTXFeeForSummary({
4236
- totalFee,
4267
+ const fee = totalFee ?? calculateTXFeeForSummary({
4237
4268
  gasPrice,
4238
4269
  rawPayload,
4239
4270
  tip,
@@ -4287,8 +4318,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4287
4318
  return receipts.reduce((logs, receipt) => {
4288
4319
  if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
4289
4320
  const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
4290
- const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
4291
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
4321
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4322
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4292
4323
  logs.push(decodedLog);
4293
4324
  }
4294
4325
  return logs;
@@ -4301,24 +4332,24 @@ function mapGqlOutputsToTxOutputs(outputs) {
4301
4332
  const obj = "amount" in o ? { ...o, amount: bn16(o.amount) } : o;
4302
4333
  switch (obj.type) {
4303
4334
  case "CoinOutput":
4304
- return { ...obj, type: OutputType7.Coin };
4335
+ return { ...obj, type: OutputType8.Coin };
4305
4336
  case "ContractOutput":
4306
4337
  return {
4307
4338
  ...obj,
4308
- type: OutputType7.Contract,
4339
+ type: OutputType8.Contract,
4309
4340
  inputIndex: parseInt(obj.inputIndex, 10)
4310
4341
  };
4311
4342
  case "ChangeOutput":
4312
4343
  return {
4313
4344
  ...obj,
4314
- type: OutputType7.Change
4345
+ type: OutputType8.Change
4315
4346
  };
4316
4347
  case "VariableOutput":
4317
- return { ...obj, type: OutputType7.Variable };
4348
+ return { ...obj, type: OutputType8.Variable };
4318
4349
  case "ContractCreated":
4319
4350
  return {
4320
4351
  ...obj,
4321
- type: OutputType7.ContractCreated,
4352
+ type: OutputType8.ContractCreated,
4322
4353
  contractId: obj.contract
4323
4354
  };
4324
4355
  default:
@@ -4333,9 +4364,9 @@ var TransactionResponse = class {
4333
4364
  * @param tx - The transaction ID or TransactionRequest.
4334
4365
  * @param provider - The provider.
4335
4366
  */
4336
- constructor(tx, provider, abis, submitTxSubscription) {
4367
+ constructor(tx, provider, chainId, abis, submitTxSubscription) {
4337
4368
  this.submitTxSubscription = submitTxSubscription;
4338
- this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
4369
+ this.id = typeof tx === "string" ? tx : tx.getTransactionId(chainId);
4339
4370
  this.provider = provider;
4340
4371
  this.abis = abis;
4341
4372
  this.request = typeof tx === "string" ? void 0 : tx;
@@ -4360,7 +4391,8 @@ var TransactionResponse = class {
4360
4391
  * @param provider - The provider.
4361
4392
  */
4362
4393
  static async create(id, provider, abis) {
4363
- const response = new TransactionResponse(id, provider, abis);
4394
+ const chainId = await provider.getChainId();
4395
+ const response = new TransactionResponse(id, provider, chainId, abis);
4364
4396
  await response.fetch();
4365
4397
  return response;
4366
4398
  }
@@ -4457,10 +4489,11 @@ var TransactionResponse = class {
4457
4489
  */
4458
4490
  async getTransactionSummary(contractsAbiMap) {
4459
4491
  const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
4460
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
4461
- const gasPrice = await this.provider.getLatestGasPrice();
4462
- const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
4463
- const baseAssetId = this.provider.getBaseAssetId();
4492
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig();
4493
+ const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status);
4494
+ const gasPrice = totalFee ? bn16(0) : await this.provider.getLatestGasPrice();
4495
+ const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs;
4496
+ const baseAssetId = await this.provider.getBaseAssetId();
4464
4497
  const transactionSummary = assembleTransactionSummary({
4465
4498
  id: this.id,
4466
4499
  receipts: this.getReceipts(),
@@ -4491,8 +4524,8 @@ var TransactionResponse = class {
4491
4524
  this.status = statusChange;
4492
4525
  if (statusChange.type === "SqueezedOutStatus") {
4493
4526
  this.unsetResourceCache();
4494
- throw new FuelError15(
4495
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
4527
+ throw new FuelError16(
4528
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
4496
4529
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4497
4530
  );
4498
4531
  }
@@ -4600,54 +4633,54 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4600
4633
  }
4601
4634
 
4602
4635
  // src/providers/utils/handle-gql-error-message.ts
4603
- import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
4636
+ import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
4604
4637
  var handleGqlErrorMessage = (errorMessage, rawError) => {
4605
4638
  switch (errorMessage) {
4606
4639
  case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4607
- throw new FuelError16(
4608
- ErrorCode13.NOT_ENOUGH_FUNDS,
4640
+ throw new FuelError17(
4641
+ ErrorCode14.NOT_ENOUGH_FUNDS,
4609
4642
  `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4610
4643
  {},
4611
4644
  rawError
4612
4645
  );
4613
4646
  case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4614
- throw new FuelError16(
4615
- ErrorCode13.MAX_COINS_REACHED,
4647
+ throw new FuelError17(
4648
+ ErrorCode14.MAX_COINS_REACHED,
4616
4649
  "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4617
4650
  {},
4618
4651
  rawError
4619
4652
  );
4620
4653
  default:
4621
- throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
4654
+ throw new FuelError17(ErrorCode14.INVALID_REQUEST, errorMessage);
4622
4655
  }
4623
4656
  };
4624
4657
 
4625
4658
  // src/providers/utils/validate-pagination-args.ts
4626
- import { FuelError as FuelError17, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
4659
+ import { FuelError as FuelError18, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
4627
4660
  var validatePaginationArgs = (params) => {
4628
4661
  const { paginationLimit, inputArgs = {} } = params;
4629
4662
  const { first, last, after, before } = inputArgs;
4630
4663
  if (after && before) {
4631
- throw new FuelError17(
4632
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4664
+ throw new FuelError18(
4665
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4633
4666
  'Pagination arguments "after" and "before" cannot be used together'
4634
4667
  );
4635
4668
  }
4636
4669
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4637
- throw new FuelError17(
4638
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4670
+ throw new FuelError18(
4671
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4639
4672
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
4640
4673
  );
4641
4674
  }
4642
4675
  if (first && before) {
4643
- throw new FuelError17(
4644
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4676
+ throw new FuelError18(
4677
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4645
4678
  'The use of pagination argument "first" with "before" is not supported'
4646
4679
  );
4647
4680
  }
4648
4681
  if (last && after) {
4649
- throw new FuelError17(
4650
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4682
+ throw new FuelError18(
4683
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4651
4684
  'The use of pagination argument "last" with "after" is not supported'
4652
4685
  );
4653
4686
  }
@@ -4801,7 +4834,7 @@ var _Provider = class {
4801
4834
  try {
4802
4835
  parsedUrl = new URL(url);
4803
4836
  } catch (error) {
4804
- throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4837
+ throw new FuelError19(FuelError19.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4805
4838
  }
4806
4839
  const username = parsedUrl.username;
4807
4840
  const password = parsedUrl.password;
@@ -4816,58 +4849,40 @@ var _Provider = class {
4816
4849
  };
4817
4850
  }
4818
4851
  /**
4819
- * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4820
- *
4821
- * @param url - GraphQL endpoint of the Fuel node
4822
- * @param options - Additional options for the provider
4823
- *
4824
- * @returns A promise that resolves to a Provider instance.
4852
+ * Initialize Provider async stuff
4825
4853
  */
4826
- static async create(url, options = {}) {
4827
- const provider = new _Provider(url, options);
4828
- await provider.fetchChainAndNodeInfo();
4829
- return provider;
4854
+ async init() {
4855
+ await this.fetchChainAndNodeInfo();
4856
+ return this;
4830
4857
  }
4831
4858
  /**
4832
- * Returns the cached chainInfo for the current URL.
4859
+ * Returns the `chainInfo` for the current network.
4833
4860
  *
4834
4861
  * @returns the chain information configuration.
4835
4862
  */
4836
- getChain() {
4837
- const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4838
- if (!chain) {
4839
- throw new FuelError18(
4840
- ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
4841
- "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4842
- );
4843
- }
4844
- return chain;
4863
+ async getChain() {
4864
+ await this.init();
4865
+ return _Provider.chainInfoCache[this.urlWithoutAuth];
4845
4866
  }
4846
4867
  /**
4847
- * Returns the cached nodeInfo for the current URL.
4868
+ * Returns the `nodeInfo` for the current network.
4848
4869
  *
4849
4870
  * @returns the node information configuration.
4850
4871
  */
4851
- getNode() {
4852
- const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4853
- if (!node) {
4854
- throw new FuelError18(
4855
- ErrorCode15.NODE_INFO_CACHE_EMPTY,
4856
- "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4857
- );
4858
- }
4859
- return node;
4872
+ async getNode() {
4873
+ await this.init();
4874
+ return _Provider.nodeInfoCache[this.urlWithoutAuth];
4860
4875
  }
4861
4876
  /**
4862
4877
  * Returns some helpful parameters related to gas fees.
4863
4878
  */
4864
- getGasConfig() {
4879
+ async getGasConfig() {
4865
4880
  const {
4866
4881
  txParameters: { maxGasPerTx },
4867
4882
  predicateParameters: { maxGasPerPredicate },
4868
4883
  feeParameters: { gasPriceFactor, gasPerByte },
4869
4884
  gasCosts
4870
- } = this.getChain().consensusParameters;
4885
+ } = (await this.getChain()).consensusParameters;
4871
4886
  return {
4872
4887
  maxGasPerTx,
4873
4888
  maxGasPerPredicate,
@@ -4889,7 +4904,7 @@ var _Provider = class {
4889
4904
  this.options = options ?? this.options;
4890
4905
  this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
4891
4906
  this.operations = this.createOperations();
4892
- await this.fetchChainAndNodeInfo();
4907
+ await this.init();
4893
4908
  }
4894
4909
  /**
4895
4910
  * Return the chain and node information.
@@ -4900,11 +4915,12 @@ var _Provider = class {
4900
4915
  let nodeInfo;
4901
4916
  let chain;
4902
4917
  try {
4903
- if (ignoreCache) {
4904
- throw new Error(`Jumps to the catch block andre-fetch`);
4918
+ nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
4919
+ chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4920
+ const noCache = !nodeInfo || !chain;
4921
+ if (ignoreCache || noCache) {
4922
+ throw new Error(`Jumps to the catch block and re-fetch`);
4905
4923
  }
4906
- nodeInfo = this.getNode();
4907
- chain = this.getChain();
4908
4924
  } catch (_err) {
4909
4925
  const data = await this.operations.getChainAndNodeInfo();
4910
4926
  nodeInfo = {
@@ -5051,10 +5067,10 @@ Supported fuel-core version: ${supportedVersion}.`
5051
5067
  *
5052
5068
  * @returns A promise that resolves to the chain ID number.
5053
5069
  */
5054
- getChainId() {
5070
+ async getChainId() {
5055
5071
  const {
5056
5072
  consensusParameters: { chainId }
5057
- } = this.getChain();
5073
+ } = await this.getChain();
5058
5074
  return chainId.toNumber();
5059
5075
  }
5060
5076
  /**
@@ -5062,30 +5078,31 @@ Supported fuel-core version: ${supportedVersion}.`
5062
5078
  *
5063
5079
  * @returns the base asset ID.
5064
5080
  */
5065
- getBaseAssetId() {
5081
+ async getBaseAssetId() {
5082
+ const all = await this.getChain();
5066
5083
  const {
5067
5084
  consensusParameters: { baseAssetId }
5068
- } = this.getChain();
5085
+ } = all;
5069
5086
  return baseAssetId;
5070
5087
  }
5071
5088
  /**
5072
5089
  * @hidden
5073
5090
  */
5074
- validateTransaction(tx) {
5091
+ async validateTransaction(tx) {
5075
5092
  const {
5076
5093
  consensusParameters: {
5077
5094
  txParameters: { maxInputs, maxOutputs }
5078
5095
  }
5079
- } = this.getChain();
5096
+ } = await this.getChain();
5080
5097
  if (bn17(tx.inputs.length).gt(maxInputs)) {
5081
- throw new FuelError18(
5082
- ErrorCode15.MAX_INPUTS_EXCEEDED,
5098
+ throw new FuelError19(
5099
+ ErrorCode16.MAX_INPUTS_EXCEEDED,
5083
5100
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
5084
5101
  );
5085
5102
  }
5086
5103
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
5087
- throw new FuelError18(
5088
- ErrorCode15.MAX_OUTPUTS_EXCEEDED,
5104
+ throw new FuelError19(
5105
+ ErrorCode16.MAX_OUTPUTS_EXCEEDED,
5089
5106
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
5090
5107
  );
5091
5108
  }
@@ -5100,20 +5117,26 @@ Supported fuel-core version: ${supportedVersion}.`
5100
5117
  * @param sendTransactionParams - The provider send transaction parameters (optional).
5101
5118
  * @returns A promise that resolves to the transaction response object.
5102
5119
  */
5103
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
5120
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, enableAssetBurn } = {}) {
5104
5121
  const transactionRequest = transactionRequestify(transactionRequestLike);
5122
+ validateTransactionForAssetBurn(
5123
+ await this.getBaseAssetId(),
5124
+ transactionRequest,
5125
+ enableAssetBurn
5126
+ );
5105
5127
  if (estimateTxDependencies) {
5106
5128
  await this.estimateTxDependencies(transactionRequest);
5107
5129
  }
5108
- this.validateTransaction(transactionRequest);
5130
+ await this.validateTransaction(transactionRequest);
5109
5131
  const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
5110
5132
  let abis;
5111
5133
  if (isTransactionTypeScript(transactionRequest)) {
5112
5134
  abis = transactionRequest.abis;
5113
5135
  }
5114
5136
  const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
5115
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
5116
- return new TransactionResponse(transactionRequest, this, abis, subscription);
5137
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
5138
+ const chainId = await this.getChainId();
5139
+ return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
5117
5140
  }
5118
5141
  /**
5119
5142
  * Executes a transaction without actually submitting it to the chain.
@@ -5193,7 +5216,7 @@ Supported fuel-core version: ${supportedVersion}.`
5193
5216
  const missingContractIds = [];
5194
5217
  let outputVariables = 0;
5195
5218
  let dryRunStatus;
5196
- this.validateTransaction(transactionRequest);
5219
+ await this.validateTransaction(transactionRequest);
5197
5220
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5198
5221
  const {
5199
5222
  dryRun: [{ receipts: rawReceipts, status }]
@@ -5324,7 +5347,11 @@ Supported fuel-core version: ${supportedVersion}.`
5324
5347
  if (diff < 6e4) {
5325
5348
  return;
5326
5349
  }
5327
- const chainInfo = this.getChain();
5350
+ if (!_Provider.chainInfoCache?.[this.urlWithoutAuth]) {
5351
+ await this.fetchChainAndNodeInfo(true);
5352
+ return;
5353
+ }
5354
+ const chainInfo = _Provider.chainInfoCache[this.urlWithoutAuth];
5328
5355
  const {
5329
5356
  consensusParameters: { version: previous }
5330
5357
  } = chainInfo;
@@ -5348,8 +5375,8 @@ Supported fuel-core version: ${supportedVersion}.`
5348
5375
  const { transactionRequest } = params;
5349
5376
  let { gasPrice } = params;
5350
5377
  await this.autoRefetchConfigs();
5351
- const chainInfo = this.getChain();
5352
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5378
+ const chainInfo = await this.getChain();
5379
+ const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
5353
5380
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5354
5381
  if (!isDefined2(gasPrice)) {
5355
5382
  gasPrice = await this.estimateGasPrice(10);
@@ -5461,7 +5488,7 @@ Supported fuel-core version: ${supportedVersion}.`
5461
5488
  if (dryRunStatus && "reason" in dryRunStatus) {
5462
5489
  throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
5463
5490
  }
5464
- const { maxGasPerTx } = this.getGasConfig();
5491
+ const { maxGasPerTx } = await this.getGasConfig();
5465
5492
  const pristineGasUsed = getGasUsedFromReceipts(receipts);
5466
5493
  gasUsed = bn17(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
5467
5494
  txRequestClone.gasLimit = gasUsed;
@@ -5718,7 +5745,7 @@ Supported fuel-core version: ${supportedVersion}.`
5718
5745
  0
5719
5746
  )?.[0];
5720
5747
  } catch (error) {
5721
- if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5748
+ if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
5722
5749
  console.warn("Unsupported transaction type encountered");
5723
5750
  return null;
5724
5751
  }
@@ -5744,7 +5771,7 @@ Supported fuel-core version: ${supportedVersion}.`
5744
5771
  try {
5745
5772
  return coder.decode(arrayify13(rawPayload), 0)[0];
5746
5773
  } catch (error) {
5747
- if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5774
+ if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
5748
5775
  console.warn("Unsupported transaction type encountered");
5749
5776
  return null;
5750
5777
  }
@@ -5870,8 +5897,8 @@ Supported fuel-core version: ${supportedVersion}.`
5870
5897
  nonce
5871
5898
  };
5872
5899
  if (commitBlockId && commitBlockHeight) {
5873
- throw new FuelError18(
5874
- ErrorCode15.INVALID_INPUT_PARAMETERS,
5900
+ throw new FuelError19(
5901
+ ErrorCode16.INVALID_INPUT_PARAMETERS,
5875
5902
  "commitBlockId and commitBlockHeight cannot be used together"
5876
5903
  );
5877
5904
  }
@@ -6034,9 +6061,9 @@ Supported fuel-core version: ${supportedVersion}.`
6034
6061
  * @param transactionId - The transaction ID to get the response for.
6035
6062
  * @returns A promise that resolves to the transaction response.
6036
6063
  */
6037
- // eslint-disable-next-line @typescript-eslint/require-await
6038
6064
  async getTransactionResponse(transactionId) {
6039
- return new TransactionResponse(transactionId, this);
6065
+ const chainId = await this.getChainId();
6066
+ return new TransactionResponse(transactionId, this, chainId);
6040
6067
  }
6041
6068
  /**
6042
6069
  * Returns Message for given nonce.
@@ -6126,7 +6153,7 @@ __publicField(Provider, "chainInfoCache", {});
6126
6153
  __publicField(Provider, "nodeInfoCache", {});
6127
6154
 
6128
6155
  // src/providers/transaction-summary/get-transaction-summary.ts
6129
- import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
6156
+ import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
6130
6157
  import { bn as bn18 } from "@fuel-ts/math";
6131
6158
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
6132
6159
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
@@ -6760,7 +6787,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6760
6787
 
6761
6788
  // src/test-utils/wallet-config.ts
6762
6789
  import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
6763
- import { FuelError as FuelError25 } from "@fuel-ts/errors";
6790
+ import { FuelError as FuelError26 } from "@fuel-ts/errors";
6764
6791
  import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
6765
6792
 
6766
6793
  // src/wallet/base-wallet-unlocked.ts
@@ -6771,8 +6798,7 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
6771
6798
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
6772
6799
  import { Address as Address5 } from "@fuel-ts/address";
6773
6800
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
6774
- import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
6775
- import { AbstractAccount } from "@fuel-ts/interfaces";
6801
+ import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
6776
6802
  import { bn as bn19 } from "@fuel-ts/math";
6777
6803
  import { InputType as InputType8 } from "@fuel-ts/transactions";
6778
6804
  import { arrayify as arrayify16, hexlify as hexlify19, isDefined as isDefined3 } from "@fuel-ts/utils";
@@ -6792,6 +6818,10 @@ var mergeQuantities = (...coinQuantities) => {
6792
6818
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
6793
6819
  };
6794
6820
 
6821
+ // src/types.ts
6822
+ var AbstractAccount = class {
6823
+ };
6824
+
6795
6825
  // src/utils/formatTransferToContractScriptData.ts
6796
6826
  import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6797
6827
  import { Address as Address4 } from "@fuel-ts/address";
@@ -6873,7 +6903,7 @@ var Account = class extends AbstractAccount {
6873
6903
  */
6874
6904
  get provider() {
6875
6905
  if (!this._provider) {
6876
- throw new FuelError20(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6906
+ throw new FuelError21(ErrorCode18.MISSING_PROVIDER, "Provider not set");
6877
6907
  }
6878
6908
  return this._provider;
6879
6909
  }
@@ -6929,7 +6959,7 @@ var Account = class extends AbstractAccount {
6929
6959
  * @returns A promise that resolves to the balance amount.
6930
6960
  */
6931
6961
  async getBalance(assetId) {
6932
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
6962
+ const assetIdToFetch = assetId ?? await this.provider.getBaseAssetId();
6933
6963
  const amount = await this.provider.getBalance(this.address, assetIdToFetch);
6934
6964
  return amount;
6935
6965
  }
@@ -6952,7 +6982,7 @@ var Account = class extends AbstractAccount {
6952
6982
  async fund(request, params) {
6953
6983
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6954
6984
  const fee = request.maxFee;
6955
- const baseAssetId = this.provider.getBaseAssetId();
6985
+ const baseAssetId = await this.provider.getBaseAssetId();
6956
6986
  const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
6957
6987
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
6958
6988
  amount: bn19(fee),
@@ -7024,12 +7054,12 @@ var Account = class extends AbstractAccount {
7024
7054
  fundingAttempts += 1;
7025
7055
  }
7026
7056
  if (needsToBeFunded) {
7027
- throw new FuelError20(
7028
- ErrorCode17.NOT_ENOUGH_FUNDS,
7057
+ throw new FuelError21(
7058
+ ErrorCode18.NOT_ENOUGH_FUNDS,
7029
7059
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
7030
7060
  );
7031
7061
  }
7032
- this.provider.validateTransaction(request);
7062
+ await this.provider.validateTransaction(request);
7033
7063
  request.updatePredicateGasUsed(estimatedPredicates);
7034
7064
  const requestToReestimate = clone9(request);
7035
7065
  if (addedSignatures) {
@@ -7056,7 +7086,11 @@ var Account = class extends AbstractAccount {
7056
7086
  */
7057
7087
  async createTransfer(destination, amount, assetId, txParams = {}) {
7058
7088
  let request = new ScriptTransactionRequest(txParams);
7059
- request = this.addTransfer(request, { destination, amount, assetId });
7089
+ request = this.addTransfer(request, {
7090
+ destination,
7091
+ amount,
7092
+ assetId: assetId || await this.provider.getBaseAssetId()
7093
+ });
7060
7094
  request = await this.estimateAndFundTransaction(request, txParams);
7061
7095
  return request;
7062
7096
  }
@@ -7096,11 +7130,7 @@ var Account = class extends AbstractAccount {
7096
7130
  addTransfer(request, transferParams) {
7097
7131
  const { destination, amount, assetId } = transferParams;
7098
7132
  this.validateTransferAmount(amount);
7099
- request.addCoinOutput(
7100
- Address5.fromAddressOrString(destination),
7101
- amount,
7102
- assetId ?? this.provider.getBaseAssetId()
7103
- );
7133
+ request.addCoinOutput(Address5.fromAddressOrString(destination), amount, assetId);
7104
7134
  return request;
7105
7135
  }
7106
7136
  /**
@@ -7111,12 +7141,11 @@ var Account = class extends AbstractAccount {
7111
7141
  * @returns The updated script transaction request.
7112
7142
  */
7113
7143
  addBatchTransfer(request, transferParams) {
7114
- const baseAssetId = this.provider.getBaseAssetId();
7115
7144
  transferParams.forEach(({ destination, amount, assetId }) => {
7116
7145
  this.addTransfer(request, {
7117
7146
  destination,
7118
7147
  amount,
7119
- assetId: assetId ?? baseAssetId
7148
+ assetId
7120
7149
  });
7121
7150
  });
7122
7151
  return request;
@@ -7138,13 +7167,14 @@ var Account = class extends AbstractAccount {
7138
7167
  ...txParams
7139
7168
  });
7140
7169
  const quantities = [];
7170
+ const defaultAssetId = await this.provider.getBaseAssetId();
7141
7171
  const transferParams = contractTransferParams.map((transferParam) => {
7142
7172
  const amount = bn19(transferParam.amount);
7143
7173
  const contractAddress = Address5.fromAddressOrString(transferParam.contractId);
7144
- const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : this.provider.getBaseAssetId();
7174
+ const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : defaultAssetId;
7145
7175
  if (amount.lte(0)) {
7146
- throw new FuelError20(
7147
- ErrorCode17.INVALID_TRANSFER_AMOUNT,
7176
+ throw new FuelError21(
7177
+ ErrorCode18.INVALID_TRANSFER_AMOUNT,
7148
7178
  "Transfer amount must be a positive number."
7149
7179
  );
7150
7180
  }
@@ -7184,7 +7214,7 @@ var Account = class extends AbstractAccount {
7184
7214
  ...amountDataArray
7185
7215
  ]);
7186
7216
  const params = { script, ...txParams };
7187
- const baseAssetId = this.provider.getBaseAssetId();
7217
+ const baseAssetId = await this.provider.getBaseAssetId();
7188
7218
  let request = new ScriptTransactionRequest(params);
7189
7219
  const quantities = [{ amount: bn19(amount), assetId: baseAssetId }];
7190
7220
  const txCost = await this.getTransactionCost(request, { quantities });
@@ -7209,7 +7239,7 @@ var Account = class extends AbstractAccount {
7209
7239
  */
7210
7240
  async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
7211
7241
  const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
7212
- const baseAssetId = this.provider.getBaseAssetId();
7242
+ const baseAssetId = await this.provider.getBaseAssetId();
7213
7243
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7214
7244
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7215
7245
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
@@ -7259,7 +7289,7 @@ var Account = class extends AbstractAccount {
7259
7289
  */
7260
7290
  async signMessage(message) {
7261
7291
  if (!this._connector) {
7262
- throw new FuelError20(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7292
+ throw new FuelError21(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
7263
7293
  }
7264
7294
  return this._connector.signMessage(this.address.toString(), message);
7265
7295
  }
@@ -7271,8 +7301,8 @@ var Account = class extends AbstractAccount {
7271
7301
  */
7272
7302
  async signTransaction(transactionRequestLike) {
7273
7303
  if (!this._connector) {
7274
- throw new FuelError20(
7275
- ErrorCode17.MISSING_CONNECTOR,
7304
+ throw new FuelError21(
7305
+ ErrorCode18.MISSING_CONNECTOR,
7276
7306
  "A connector is required to sign transactions."
7277
7307
  );
7278
7308
  }
@@ -7285,10 +7315,13 @@ var Account = class extends AbstractAccount {
7285
7315
  * @param sendTransactionParams - The provider send transaction parameters (optional).
7286
7316
  * @returns A promise that resolves to the transaction response.
7287
7317
  */
7288
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
7318
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
7289
7319
  if (this._connector) {
7290
7320
  return this.provider.getTransactionResponse(
7291
- await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
7321
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
7322
+ onBeforeSend,
7323
+ skipCustomFee
7324
+ })
7292
7325
  );
7293
7326
  }
7294
7327
  const transactionRequest = transactionRequestify(transactionRequestLike);
@@ -7331,8 +7364,8 @@ var Account = class extends AbstractAccount {
7331
7364
  /** @hidden * */
7332
7365
  validateTransferAmount(amount) {
7333
7366
  if (bn19(amount).lte(0)) {
7334
- throw new FuelError20(
7335
- ErrorCode17.INVALID_TRANSFER_AMOUNT,
7367
+ throw new FuelError21(
7368
+ ErrorCode18.INVALID_TRANSFER_AMOUNT,
7336
7369
  "Transfer amount must be a positive number."
7337
7370
  );
7338
7371
  }
@@ -7361,16 +7394,16 @@ var Account = class extends AbstractAccount {
7361
7394
  if (!isDefined3(setGasLimit)) {
7362
7395
  request.gasLimit = gasUsed;
7363
7396
  } else if (gasUsed.gt(setGasLimit)) {
7364
- throw new FuelError20(
7365
- ErrorCode17.GAS_LIMIT_TOO_LOW,
7397
+ throw new FuelError21(
7398
+ ErrorCode18.GAS_LIMIT_TOO_LOW,
7366
7399
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7367
7400
  );
7368
7401
  }
7369
7402
  if (!isDefined3(setMaxFee)) {
7370
7403
  request.maxFee = maxFee;
7371
7404
  } else if (maxFee.gt(setMaxFee)) {
7372
- throw new FuelError20(
7373
- ErrorCode17.MAX_FEE_TOO_LOW,
7405
+ throw new FuelError21(
7406
+ ErrorCode18.MAX_FEE_TOO_LOW,
7374
7407
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7375
7408
  );
7376
7409
  }
@@ -7390,7 +7423,7 @@ import {
7390
7423
  encryptJsonWalletData,
7391
7424
  randomUUID as randomUUID2
7392
7425
  } from "@fuel-ts/crypto";
7393
- import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
7426
+ import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
7394
7427
  import { hexlify as hexlify20 } from "@fuel-ts/utils";
7395
7428
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7396
7429
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7467,8 +7500,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7467
7500
  const macHashUint8Array = keccak256(data);
7468
7501
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7469
7502
  if (mac !== macHash) {
7470
- throw new FuelError21(
7471
- ErrorCode18.INVALID_PASSWORD,
7503
+ throw new FuelError22(
7504
+ ErrorCode19.INVALID_PASSWORD,
7472
7505
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7473
7506
  );
7474
7507
  }
@@ -7528,7 +7561,7 @@ var BaseWalletUnlocked = class extends Account {
7528
7561
  */
7529
7562
  async signTransaction(transactionRequestLike) {
7530
7563
  const transactionRequest = transactionRequestify(transactionRequestLike);
7531
- const chainId = this.provider.getChainId();
7564
+ const chainId = await this.provider.getChainId();
7532
7565
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
7533
7566
  const signature = await this.signer().sign(hashedTransaction);
7534
7567
  return hexlify21(signature);
@@ -7552,14 +7585,19 @@ var BaseWalletUnlocked = class extends Account {
7552
7585
  * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
7553
7586
  * @returns A promise that resolves to the TransactionResponse object.
7554
7587
  */
7555
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
7588
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, enableAssetBurn } = {}) {
7556
7589
  const transactionRequest = transactionRequestify(transactionRequestLike);
7590
+ validateTransactionForAssetBurn(
7591
+ await this.provider.getBaseAssetId(),
7592
+ transactionRequest,
7593
+ enableAssetBurn
7594
+ );
7557
7595
  if (estimateTxDependencies) {
7558
7596
  await this.provider.estimateTxDependencies(transactionRequest);
7559
7597
  }
7560
7598
  return this.provider.sendTransaction(
7561
7599
  await this.populateTransactionWitnessesSignature(transactionRequest),
7562
- { estimateTxDependencies: false }
7600
+ { estimateTxDependencies: false, enableAssetBurn }
7563
7601
  );
7564
7602
  }
7565
7603
  /**
@@ -7598,14 +7636,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7598
7636
 
7599
7637
  // src/hdwallet/hdwallet.ts
7600
7638
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7601
- import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
7639
+ import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
7602
7640
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7603
7641
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
7604
7642
  import { arrayify as arrayify19, hexlify as hexlify23, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7605
7643
 
7606
7644
  // src/mnemonic/mnemonic.ts
7607
7645
  import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7608
- import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
7646
+ import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
7609
7647
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
7610
7648
  import { arrayify as arrayify18, hexlify as hexlify22, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7611
7649
 
@@ -9662,7 +9700,7 @@ var english = [
9662
9700
  ];
9663
9701
 
9664
9702
  // src/mnemonic/utils.ts
9665
- import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
9703
+ import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
9666
9704
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9667
9705
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9668
9706
  function getLowerMask(bits) {
@@ -9711,8 +9749,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9711
9749
  for (let i = 0; i < words.length; i += 1) {
9712
9750
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9713
9751
  if (index === -1) {
9714
- throw new FuelError22(
9715
- ErrorCode19.INVALID_MNEMONIC,
9752
+ throw new FuelError23(
9753
+ ErrorCode20.INVALID_MNEMONIC,
9716
9754
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9717
9755
  );
9718
9756
  }
@@ -9728,8 +9766,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9728
9766
  const checksumMask = getUpperMask(checksumBits);
9729
9767
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9730
9768
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9731
- throw new FuelError22(
9732
- ErrorCode19.INVALID_CHECKSUM,
9769
+ throw new FuelError23(
9770
+ ErrorCode20.INVALID_CHECKSUM,
9733
9771
  "Checksum validation failed for the provided mnemonic."
9734
9772
  );
9735
9773
  }
@@ -9743,16 +9781,16 @@ var TestnetPRV = "0x04358394";
9743
9781
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9744
9782
  function assertWordList(wordlist) {
9745
9783
  if (wordlist.length !== 2048) {
9746
- throw new FuelError23(
9747
- ErrorCode20.INVALID_WORD_LIST,
9784
+ throw new FuelError24(
9785
+ ErrorCode21.INVALID_WORD_LIST,
9748
9786
  `Expected word list length of 2048, but got ${wordlist.length}.`
9749
9787
  );
9750
9788
  }
9751
9789
  }
9752
9790
  function assertEntropy(entropy) {
9753
9791
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9754
- throw new FuelError23(
9755
- ErrorCode20.INVALID_ENTROPY,
9792
+ throw new FuelError24(
9793
+ ErrorCode21.INVALID_ENTROPY,
9756
9794
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9757
9795
  );
9758
9796
  }
@@ -9762,7 +9800,7 @@ function assertMnemonic(words) {
9762
9800
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9763
9801
  ", "
9764
9802
  )}] words, but got ${words.length}.`;
9765
- throw new FuelError23(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9803
+ throw new FuelError24(ErrorCode21.INVALID_MNEMONIC, errorMsg);
9766
9804
  }
9767
9805
  }
9768
9806
  var Mnemonic = class {
@@ -9880,8 +9918,8 @@ var Mnemonic = class {
9880
9918
  static masterKeysFromSeed(seed) {
9881
9919
  const seedArray = arrayify18(seed);
9882
9920
  if (seedArray.length < 16 || seedArray.length > 64) {
9883
- throw new FuelError23(
9884
- ErrorCode20.INVALID_SEED,
9921
+ throw new FuelError24(
9922
+ ErrorCode21.INVALID_SEED,
9885
9923
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9886
9924
  );
9887
9925
  }
@@ -9958,7 +9996,7 @@ function isValidExtendedKey(extendedKey) {
9958
9996
  function parsePath(path2, depth = 0) {
9959
9997
  const components = path2.split("/");
9960
9998
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9961
- throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path2}`);
9999
+ throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path2}`);
9962
10000
  }
9963
10001
  if (components[0] === "m") {
9964
10002
  components.shift();
@@ -9987,8 +10025,8 @@ var HDWallet = class {
9987
10025
  this.privateKey = hexlify23(config.privateKey);
9988
10026
  } else {
9989
10027
  if (!config.publicKey) {
9990
- throw new FuelError24(
9991
- ErrorCode21.HD_WALLET_ERROR,
10028
+ throw new FuelError25(
10029
+ ErrorCode22.HD_WALLET_ERROR,
9992
10030
  "Both public and private Key cannot be missing. At least one should be provided."
9993
10031
  );
9994
10032
  }
@@ -10017,8 +10055,8 @@ var HDWallet = class {
10017
10055
  const data = new Uint8Array(37);
10018
10056
  if (index & HARDENED_INDEX) {
10019
10057
  if (!privateKey) {
10020
- throw new FuelError24(
10021
- ErrorCode21.HD_WALLET_ERROR,
10058
+ throw new FuelError25(
10059
+ ErrorCode22.HD_WALLET_ERROR,
10022
10060
  "Cannot derive a hardened index without a private Key."
10023
10061
  );
10024
10062
  }
@@ -10070,8 +10108,8 @@ var HDWallet = class {
10070
10108
  */
10071
10109
  toExtendedKey(isPublic = false, testnet = false) {
10072
10110
  if (this.depth >= 256) {
10073
- throw new FuelError24(
10074
- ErrorCode21.HD_WALLET_ERROR,
10111
+ throw new FuelError25(
10112
+ ErrorCode22.HD_WALLET_ERROR,
10075
10113
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10076
10114
  );
10077
10115
  }
@@ -10102,10 +10140,10 @@ var HDWallet = class {
10102
10140
  const bytes = arrayify19(decoded);
10103
10141
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10104
10142
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10105
- throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10143
+ throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10106
10144
  }
10107
10145
  if (!validChecksum) {
10108
- throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10146
+ throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10109
10147
  }
10110
10148
  const depth = bytes[4];
10111
10149
  const parentFingerprint = hexlify23(bytes.slice(5, 9));
@@ -10113,14 +10151,14 @@ var HDWallet = class {
10113
10151
  const chainCode = hexlify23(bytes.slice(13, 45));
10114
10152
  const key = bytes.slice(45, 78);
10115
10153
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10116
- throw new FuelError24(
10117
- ErrorCode21.HD_WALLET_ERROR,
10154
+ throw new FuelError25(
10155
+ ErrorCode22.HD_WALLET_ERROR,
10118
10156
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10119
10157
  );
10120
10158
  }
10121
10159
  if (isPublicExtendedKey(bytes)) {
10122
10160
  if (key[0] !== 3) {
10123
- throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10161
+ throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
10124
10162
  }
10125
10163
  return new HDWallet({
10126
10164
  publicKey: key,
@@ -10131,7 +10169,7 @@ var HDWallet = class {
10131
10169
  });
10132
10170
  }
10133
10171
  if (key[0] !== 0) {
10134
- throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10172
+ throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
10135
10173
  }
10136
10174
  return new HDWallet({
10137
10175
  privateKey: key.slice(1),
@@ -10375,26 +10413,26 @@ var WalletsConfig = class {
10375
10413
  amountPerCoin
10376
10414
  }) {
10377
10415
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
10378
- throw new FuelError25(
10379
- FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10416
+ throw new FuelError26(
10417
+ FuelError26.CODES.INVALID_INPUT_PARAMETERS,
10380
10418
  "Number of wallets must be greater than zero."
10381
10419
  );
10382
10420
  }
10383
10421
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
10384
- throw new FuelError25(
10385
- FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10422
+ throw new FuelError26(
10423
+ FuelError26.CODES.INVALID_INPUT_PARAMETERS,
10386
10424
  "Number of assets per wallet must be greater than zero."
10387
10425
  );
10388
10426
  }
10389
10427
  if (coinsPerAsset <= 0) {
10390
- throw new FuelError25(
10391
- FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10428
+ throw new FuelError26(
10429
+ FuelError26.CODES.INVALID_INPUT_PARAMETERS,
10392
10430
  "Number of coins per asset must be greater than zero."
10393
10431
  );
10394
10432
  }
10395
10433
  if (amountPerCoin < 0) {
10396
- throw new FuelError25(
10397
- FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10434
+ throw new FuelError26(
10435
+ FuelError26.CODES.INVALID_INPUT_PARAMETERS,
10398
10436
  "Amount per coin must be greater than or equal to zero."
10399
10437
  );
10400
10438
  }
@@ -10447,7 +10485,8 @@ async function setupTestProviderAndWallets({
10447
10485
  }
10448
10486
  let provider;
10449
10487
  try {
10450
- provider = await Provider.create(url, providerOptions);
10488
+ provider = new Provider(url, providerOptions);
10489
+ await provider.init();
10451
10490
  } catch (err) {
10452
10491
  cleanup();
10453
10492
  throw err;