@fuel-ts/account 0.97.1 → 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 (112) 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 +2923 -1250
  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 +4 -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-coin.d.ts +1 -0
  83. package/dist/test-utils/test-coin.d.ts.map +1 -0
  84. package/dist/test-utils/test-message.d.ts +6 -6
  85. package/dist/test-utils/test-message.d.ts.map +1 -1
  86. package/dist/test-utils.global.js +3033 -1799
  87. package/dist/test-utils.global.js.map +1 -1
  88. package/dist/test-utils.js +294 -223
  89. package/dist/test-utils.js.map +1 -1
  90. package/dist/test-utils.mjs +323 -252
  91. package/dist/test-utils.mjs.map +1 -1
  92. package/dist/types.d.ts +11 -0
  93. package/dist/types.d.ts.map +1 -0
  94. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
  95. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  96. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  97. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  98. package/dist/wallet/keystore-wallet.d.ts +2 -2
  99. package/dist/wallet/keystore-wallet.d.ts.map +1 -1
  100. package/dist/wallet/wallet.d.ts +3 -2
  101. package/dist/wallet/wallet.d.ts.map +1 -1
  102. package/dist/wallet/wallets.d.ts +1 -1
  103. package/dist/wallet/wallets.d.ts.map +1 -1
  104. package/dist/wallet-manager/types.d.ts +4 -4
  105. package/dist/wallet-manager/types.d.ts.map +1 -1
  106. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +5 -5
  107. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
  108. package/dist/wallet-manager/vaults/privatekey-vault.d.ts +5 -5
  109. package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
  110. package/dist/wallet-manager/wallet-manager.d.ts +3 -3
  111. package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
  112. package/package.json +27 -28
package/dist/index.mjs CHANGED
@@ -31,8 +31,7 @@ var __privateMethod = (obj, member, method) => {
31
31
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
32
32
  import { Address as Address4 } from "@fuel-ts/address";
33
33
  import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
34
- import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
35
- import { AbstractAccount } from "@fuel-ts/interfaces";
34
+ import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
36
35
  import { bn as bn19 } from "@fuel-ts/math";
37
36
  import { InputType as InputType8 } from "@fuel-ts/transactions";
38
37
  import { arrayify as arrayify15, hexlify as hexlify16, isDefined as isDefined3 } from "@fuel-ts/utils";
@@ -75,7 +74,7 @@ var addAmountToCoinQuantities = (params) => {
75
74
 
76
75
  // src/providers/provider.ts
77
76
  import { Address as Address2 } from "@fuel-ts/address";
78
- import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
77
+ import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
79
78
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
80
79
  import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
81
80
  import { arrayify as arrayify12, hexlify as hexlify15, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
@@ -946,13 +945,6 @@ var GetConsensusParametersVersionDocument = gql`
946
945
  }
947
946
  }
948
947
  `;
949
- var SubmitAndAwaitDocument = gql`
950
- subscription submitAndAwait($encodedTransaction: HexString!) {
951
- submitAndAwait(tx: $encodedTransaction) {
952
- ...transactionStatusSubscriptionFragment
953
- }
954
- }
955
- ${TransactionStatusSubscriptionFragmentDoc}`;
956
948
  var SubmitAndAwaitStatusDocument = gql`
957
949
  subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
958
950
  submitAndAwaitStatus(tx: $encodedTransaction) {
@@ -1068,9 +1060,6 @@ function getSdk(requester) {
1068
1060
  getConsensusParametersVersion(variables, options) {
1069
1061
  return requester(GetConsensusParametersVersionDocument, variables, options);
1070
1062
  },
1071
- submitAndAwait(variables, options) {
1072
- return requester(SubmitAndAwaitDocument, variables, options);
1073
- },
1074
1063
  submitAndAwaitStatus(variables, options) {
1075
1064
  return requester(SubmitAndAwaitStatusDocument, variables, options);
1076
1065
  },
@@ -1354,13 +1343,13 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1354
1343
  import { Address, addressify } from "@fuel-ts/address";
1355
1344
  import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1356
1345
  import { randomBytes } from "@fuel-ts/crypto";
1357
- import { FuelError as FuelError8 } from "@fuel-ts/errors";
1346
+ import { FuelError as FuelError9 } from "@fuel-ts/errors";
1358
1347
  import { bn as bn8 } from "@fuel-ts/math";
1359
1348
  import {
1360
1349
  PolicyType,
1361
1350
  TransactionCoder,
1362
1351
  InputType as InputType3,
1363
- OutputType as OutputType2,
1352
+ OutputType as OutputType3,
1364
1353
  TransactionType
1365
1354
  } from "@fuel-ts/transactions";
1366
1355
  import { concat, hexlify as hexlify8, isDefined } from "@fuel-ts/utils";
@@ -1407,7 +1396,6 @@ function assembleReceiptByType(receipt) {
1407
1396
  const callReceipt = {
1408
1397
  type: ReceiptType.Call,
1409
1398
  id,
1410
- from: id,
1411
1399
  to: hexOrZero(receipt?.to),
1412
1400
  amount: bn4(receipt.amount),
1413
1401
  assetId: hexOrZero(receipt.assetId),
@@ -1475,10 +1463,6 @@ function assembleReceiptByType(receipt) {
1475
1463
  rb,
1476
1464
  rc,
1477
1465
  rd,
1478
- val0: ra,
1479
- val1: rb,
1480
- val2: rc,
1481
- val3: rd,
1482
1466
  pc: bn4(receipt.pc),
1483
1467
  is: bn4(receipt.is)
1484
1468
  };
@@ -1492,8 +1476,6 @@ function assembleReceiptByType(receipt) {
1492
1476
  id: hexOrZero(receipt.id || receipt.contractId),
1493
1477
  ra,
1494
1478
  rb,
1495
- val0: ra,
1496
- val1: rb,
1497
1479
  ptr: bn4(receipt.ptr),
1498
1480
  len: bn4(receipt.len),
1499
1481
  digest: hexOrZero(receipt.digest),
@@ -1508,7 +1490,6 @@ function assembleReceiptByType(receipt) {
1508
1490
  const transferReceipt = {
1509
1491
  type: ReceiptType.Transfer,
1510
1492
  id,
1511
- from: id,
1512
1493
  to: hexOrZero(receipt.toAddress || receipt?.to),
1513
1494
  amount: bn4(receipt.amount),
1514
1495
  assetId: hexOrZero(receipt.assetId),
@@ -1522,7 +1503,6 @@ function assembleReceiptByType(receipt) {
1522
1503
  const transferOutReceipt = {
1523
1504
  type: ReceiptType.TransferOut,
1524
1505
  id,
1525
- from: id,
1526
1506
  to: hexOrZero(receipt.toAddress || receipt.to),
1527
1507
  amount: bn4(receipt.amount),
1528
1508
  assetId: hexOrZero(receipt.assetId),
@@ -1951,8 +1931,9 @@ var NoWitnessByOwnerError = class extends Error {
1951
1931
  };
1952
1932
 
1953
1933
  // src/providers/transaction-request/helpers.ts
1934
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
1954
1935
  import { bn as bn7 } from "@fuel-ts/math";
1955
- import { InputType as InputType2 } from "@fuel-ts/transactions";
1936
+ import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
1956
1937
  var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1957
1938
  var isRequestInputMessage = (input) => input.type === InputType2.Message;
1958
1939
  var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
@@ -1997,6 +1978,32 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
1997
1978
  messages: []
1998
1979
  }
1999
1980
  );
1981
+ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
1982
+ const { inputs, outputs } = transactionRequest;
1983
+ const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
1984
+ if (inputs.some((i) => isRequestInputMessage(i) && bn7(i.amount).gt(0))) {
1985
+ coinInputs.add(baseAssetId);
1986
+ }
1987
+ const changeOutputs = new Set(
1988
+ outputs.filter((output) => output.type === OutputType2.Change).map((output) => output.assetId)
1989
+ );
1990
+ const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
1991
+ return difference.size;
1992
+ };
1993
+ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
1994
+ if (enableAssetBurn === true) {
1995
+ return;
1996
+ }
1997
+ if (getBurnableAssetCount(baseAssetId, transactionRequest) <= 0) {
1998
+ return;
1999
+ }
2000
+ const message = [
2001
+ "Asset burn detected.",
2002
+ "Add the relevant change outputs to the transaction to avoid burning assets.",
2003
+ "Or enable asset burn, upon sending the transaction."
2004
+ ].join("\n");
2005
+ throw new FuelError8(ErrorCode8.ASSET_BURN_DETECTED, message);
2006
+ };
2000
2007
 
2001
2008
  // src/providers/transaction-request/witness.ts
2002
2009
  import { arrayify as arrayify4, hexlify as hexlify7 } from "@fuel-ts/utils";
@@ -2197,7 +2204,7 @@ var BaseTransactionRequest = class {
2197
2204
  */
2198
2205
  getCoinOutputs() {
2199
2206
  return this.outputs.filter(
2200
- (output) => output.type === OutputType2.Coin
2207
+ (output) => output.type === OutputType3.Coin
2201
2208
  );
2202
2209
  }
2203
2210
  /**
@@ -2207,7 +2214,7 @@ var BaseTransactionRequest = class {
2207
2214
  */
2208
2215
  getChangeOutputs() {
2209
2216
  return this.outputs.filter(
2210
- (output) => output.type === OutputType2.Change
2217
+ (output) => output.type === OutputType3.Change
2211
2218
  );
2212
2219
  }
2213
2220
  /**
@@ -2328,7 +2335,7 @@ var BaseTransactionRequest = class {
2328
2335
  */
2329
2336
  addCoinOutput(to, amount, assetId) {
2330
2337
  this.pushOutput({
2331
- type: OutputType2.Coin,
2338
+ type: OutputType3.Coin,
2332
2339
  to: addressify(to).toB256(),
2333
2340
  amount,
2334
2341
  assetId
@@ -2344,7 +2351,7 @@ var BaseTransactionRequest = class {
2344
2351
  addCoinOutputs(to, quantities) {
2345
2352
  quantities.map(coinQuantityfy).forEach((quantity) => {
2346
2353
  this.pushOutput({
2347
- type: OutputType2.Coin,
2354
+ type: OutputType3.Coin,
2348
2355
  to: addressify(to).toB256(),
2349
2356
  amount: quantity.amount,
2350
2357
  assetId: quantity.assetId
@@ -2364,7 +2371,7 @@ var BaseTransactionRequest = class {
2364
2371
  );
2365
2372
  if (!changeOutput) {
2366
2373
  this.pushOutput({
2367
- type: OutputType2.Change,
2374
+ type: OutputType3.Change,
2368
2375
  to: addressify(to).toB256(),
2369
2376
  assetId
2370
2377
  });
@@ -2380,7 +2387,7 @@ var BaseTransactionRequest = class {
2380
2387
  * @hidden
2381
2388
  */
2382
2389
  metadataGas(_gasCosts) {
2383
- throw new FuelError8(FuelError8.CODES.NOT_IMPLEMENTED, "Not implemented");
2390
+ throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Not implemented");
2384
2391
  }
2385
2392
  /**
2386
2393
  * @hidden
@@ -2516,7 +2523,7 @@ import { clone as clone3 } from "ramda";
2516
2523
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2517
2524
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2518
2525
  import { bn as bn9 } from "@fuel-ts/math";
2519
- import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2526
+ import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType4, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2520
2527
  import { concat as concat2 } from "@fuel-ts/utils";
2521
2528
  import { clone as clone2 } from "ramda";
2522
2529
  function hashTransaction(transactionRequest, chainId) {
@@ -2557,16 +2564,16 @@ function hashTransaction(transactionRequest, chainId) {
2557
2564
  transaction.outputs = transaction.outputs.map((output) => {
2558
2565
  const outputClone = clone2(output);
2559
2566
  switch (outputClone.type) {
2560
- case OutputType3.Contract: {
2567
+ case OutputType4.Contract: {
2561
2568
  outputClone.balanceRoot = ZeroBytes325;
2562
2569
  outputClone.stateRoot = ZeroBytes325;
2563
2570
  return outputClone;
2564
2571
  }
2565
- case OutputType3.Change: {
2572
+ case OutputType4.Change: {
2566
2573
  outputClone.amount = bn9(0);
2567
2574
  return outputClone;
2568
2575
  }
2569
- case OutputType3.Variable: {
2576
+ case OutputType4.Variable: {
2570
2577
  outputClone.to = ZeroBytes325;
2571
2578
  outputClone.amount = bn9(0);
2572
2579
  outputClone.assetId = ZeroBytes325;
@@ -2647,7 +2654,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2647
2654
  // src/providers/transaction-request/create-transaction-request.ts
2648
2655
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2649
2656
  import { bn as bn10 } from "@fuel-ts/math";
2650
- import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2657
+ import { TransactionType as TransactionType3, OutputType as OutputType5 } from "@fuel-ts/transactions";
2651
2658
  import { arrayify as arrayify6, hexlify as hexlify10 } from "@fuel-ts/utils";
2652
2659
  import { clone as clone4 } from "ramda";
2653
2660
 
@@ -2723,7 +2730,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2723
2730
  */
2724
2731
  getContractCreatedOutputs() {
2725
2732
  return this.outputs.filter(
2726
- (output) => output.type === OutputType4.ContractCreated
2733
+ (output) => output.type === OutputType5.ContractCreated
2727
2734
  );
2728
2735
  }
2729
2736
  /**
@@ -2744,7 +2751,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2744
2751
  */
2745
2752
  addContractCreatedOutput(contractId, stateRoot) {
2746
2753
  this.pushOutput({
2747
- type: OutputType4.ContractCreated,
2754
+ type: OutputType5.ContractCreated,
2748
2755
  contractId,
2749
2756
  stateRoot
2750
2757
  });
@@ -2764,7 +2771,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2764
2771
  import { addressify as addressify2 } from "@fuel-ts/address";
2765
2772
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2766
2773
  import { bn as bn11 } from "@fuel-ts/math";
2767
- import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2774
+ import { InputType as InputType5, OutputType as OutputType6, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2768
2775
  import { arrayify as arrayify8, hexlify as hexlify11 } from "@fuel-ts/utils";
2769
2776
  import { clone as clone5 } from "ramda";
2770
2777
 
@@ -2820,6 +2827,20 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2820
2827
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2821
2828
  this.abis = rest.abis;
2822
2829
  }
2830
+ /**
2831
+ * Helper function to estimate and fund the transaction request with a specified account.
2832
+ *
2833
+ * @param account - The account to fund the transaction.
2834
+ * @param params - The parameters for the transaction cost.
2835
+ * @returns The current instance of the `ScriptTransactionRequest` funded.
2836
+ */
2837
+ async estimateAndFund(account, { signatureCallback, quantities = [] } = {}) {
2838
+ const txCost = await account.getTransactionCost(this, { signatureCallback, quantities });
2839
+ this.maxFee = txCost.maxFee;
2840
+ this.gasLimit = txCost.gasUsed;
2841
+ await account.fund(this, txCost);
2842
+ return this;
2843
+ }
2823
2844
  /**
2824
2845
  * Converts the transaction request to a `TransactionScript`.
2825
2846
  *
@@ -2856,7 +2877,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2856
2877
  */
2857
2878
  getContractOutputs() {
2858
2879
  return this.outputs.filter(
2859
- (output) => output.type === OutputType5.Contract
2880
+ (output) => output.type === OutputType6.Contract
2860
2881
  );
2861
2882
  }
2862
2883
  /**
@@ -2866,7 +2887,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2866
2887
  */
2867
2888
  getVariableOutputs() {
2868
2889
  return this.outputs.filter(
2869
- (output) => output.type === OutputType5.Variable
2890
+ (output) => output.type === OutputType6.Variable
2870
2891
  );
2871
2892
  }
2872
2893
  /**
@@ -2889,7 +2910,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2889
2910
  let outputsNumber = numberOfVariables;
2890
2911
  while (outputsNumber) {
2891
2912
  this.pushOutput({
2892
- type: OutputType5.Variable
2913
+ type: OutputType6.Variable
2893
2914
  });
2894
2915
  outputsNumber -= 1;
2895
2916
  }
@@ -2938,7 +2959,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2938
2959
  txPointer: "0x00000000000000000000000000000000"
2939
2960
  });
2940
2961
  this.pushOutput({
2941
- type: OutputType5.Contract,
2962
+ type: OutputType6.Contract,
2942
2963
  inputIndex
2943
2964
  });
2944
2965
  return this;
@@ -2974,7 +2995,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2974
2995
  };
2975
2996
 
2976
2997
  // src/providers/transaction-request/upgrade-transaction-request.ts
2977
- import { FuelError as FuelError9 } from "@fuel-ts/errors";
2998
+ import { FuelError as FuelError10 } from "@fuel-ts/errors";
2978
2999
  import { hash } from "@fuel-ts/hasher";
2979
3000
  import {
2980
3001
  TransactionType as TransactionType5,
@@ -3081,7 +3102,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3081
3102
  }
3082
3103
  };
3083
3104
  } else {
3084
- throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3105
+ throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3085
3106
  }
3086
3107
  return {
3087
3108
  type: TransactionType5.Upgrade,
@@ -3123,7 +3144,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3123
3144
  txBytesSize
3124
3145
  });
3125
3146
  }
3126
- throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3147
+ throw new FuelError10(FuelError10.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3127
3148
  }
3128
3149
  };
3129
3150
 
@@ -3233,8 +3254,12 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3233
3254
  }
3234
3255
  };
3235
3256
 
3257
+ // src/providers/transaction-request/types.ts
3258
+ var AbstractScriptRequest = class {
3259
+ };
3260
+
3236
3261
  // src/providers/transaction-request/utils.ts
3237
- import { ErrorCode as ErrorCode8, FuelError as FuelError10 } from "@fuel-ts/errors";
3262
+ import { ErrorCode as ErrorCode9, FuelError as FuelError11 } from "@fuel-ts/errors";
3238
3263
  import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
3239
3264
  var transactionRequestify = (obj) => {
3240
3265
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
@@ -3258,8 +3283,8 @@ var transactionRequestify = (obj) => {
3258
3283
  return UploadTransactionRequest.from(obj);
3259
3284
  }
3260
3285
  default: {
3261
- throw new FuelError10(
3262
- ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
3286
+ throw new FuelError11(
3287
+ ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
3263
3288
  `Unsupported transaction type: ${type}.`
3264
3289
  );
3265
3290
  }
@@ -3272,9 +3297,9 @@ var isTransactionTypeUpgrade = (request) => request.type === TransactionType7.Up
3272
3297
  var isTransactionTypeUpload = (request) => request.type === TransactionType7.Upload;
3273
3298
 
3274
3299
  // src/providers/transaction-response/transaction-response.ts
3275
- import { ErrorCode as ErrorCode12, FuelError as FuelError14 } from "@fuel-ts/errors";
3300
+ import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
3276
3301
  import { bn as bn16 } from "@fuel-ts/math";
3277
- import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
3302
+ import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
3278
3303
  import { arrayify as arrayify11, assertUnreachable } from "@fuel-ts/utils";
3279
3304
 
3280
3305
  // src/providers/transaction-summary/assemble-transaction-summary.ts
@@ -3291,12 +3316,8 @@ var calculateTXFeeForSummary = (params) => {
3291
3316
  gasPrice,
3292
3317
  rawPayload,
3293
3318
  tip,
3294
- totalFee,
3295
3319
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
3296
3320
  } = params;
3297
- if (totalFee) {
3298
- return totalFee;
3299
- }
3300
3321
  const gasPerByte = bn12(feeParams.gasPerByte);
3301
3322
  const gasPriceFactor = bn12(feeParams.gasPriceFactor);
3302
3323
  const transactionBytes = arrayify10(rawPayload);
@@ -3354,7 +3375,7 @@ var calculateTXFeeForSummary = (params) => {
3354
3375
 
3355
3376
  // src/providers/transaction-summary/operations.ts
3356
3377
  import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
3357
- import { ErrorCode as ErrorCode10, FuelError as FuelError12 } from "@fuel-ts/errors";
3378
+ import { ErrorCode as ErrorCode11, FuelError as FuelError13 } from "@fuel-ts/errors";
3358
3379
  import { bn as bn13 } from "@fuel-ts/math";
3359
3380
  import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
3360
3381
 
@@ -3392,7 +3413,7 @@ var getFunctionCall = ({ abi, receipt }) => {
3392
3413
  };
3393
3414
 
3394
3415
  // src/providers/transaction-summary/input.ts
3395
- import { ErrorCode as ErrorCode9, FuelError as FuelError11 } from "@fuel-ts/errors";
3416
+ import { ErrorCode as ErrorCode10, FuelError as FuelError12 } from "@fuel-ts/errors";
3396
3417
  import { BN } from "@fuel-ts/math";
3397
3418
  import { InputType as InputType6 } from "@fuel-ts/transactions";
3398
3419
  function getInputsByTypes(inputs, types) {
@@ -3420,10 +3441,10 @@ function findCoinInput(inputs, assetId) {
3420
3441
  const coinInputs = getInputsCoin(inputs);
3421
3442
  return coinInputs.find((i) => i.assetId === assetId);
3422
3443
  }
3423
- function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
3444
+ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
3424
3445
  const aggregated = /* @__PURE__ */ new Map();
3425
3446
  getInputsCoinAndMessage(inputs).forEach((input) => {
3426
- const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
3447
+ const assetId = isInputCoin(input) ? input.assetId : baseAssetId;
3427
3448
  const owner = isInputCoin(input) ? input.owner : input.recipient;
3428
3449
  let ownersMap = aggregated.get(assetId);
3429
3450
  if (!ownersMap) {
@@ -3461,8 +3482,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
3461
3482
  return void 0;
3462
3483
  }
3463
3484
  if (contractInput.type !== InputType6.Contract) {
3464
- throw new FuelError11(
3465
- ErrorCode9.INVALID_TRANSACTION_INPUT,
3485
+ throw new FuelError12(
3486
+ ErrorCode10.INVALID_TRANSACTION_INPUT,
3466
3487
  `Contract input should be of type 'contract'.`
3467
3488
  );
3468
3489
  }
@@ -3479,24 +3500,24 @@ function getInputAccountAddress(input) {
3479
3500
  }
3480
3501
 
3481
3502
  // src/providers/transaction-summary/output.ts
3482
- import { OutputType as OutputType6 } from "@fuel-ts/transactions";
3503
+ import { OutputType as OutputType7 } from "@fuel-ts/transactions";
3483
3504
  function getOutputsByType(outputs, type) {
3484
3505
  return outputs.filter((o) => o.type === type);
3485
3506
  }
3486
3507
  function getOutputsContractCreated(outputs) {
3487
- return getOutputsByType(outputs, OutputType6.ContractCreated);
3508
+ return getOutputsByType(outputs, OutputType7.ContractCreated);
3488
3509
  }
3489
3510
  function getOutputsCoin(outputs) {
3490
- return getOutputsByType(outputs, OutputType6.Coin);
3511
+ return getOutputsByType(outputs, OutputType7.Coin);
3491
3512
  }
3492
3513
  function getOutputsChange(outputs) {
3493
- return getOutputsByType(outputs, OutputType6.Change);
3514
+ return getOutputsByType(outputs, OutputType7.Change);
3494
3515
  }
3495
3516
  function getOutputsContract(outputs) {
3496
- return getOutputsByType(outputs, OutputType6.Contract);
3517
+ return getOutputsByType(outputs, OutputType7.Contract);
3497
3518
  }
3498
3519
  function getOutputsVariable(outputs) {
3499
- return getOutputsByType(outputs, OutputType6.Variable);
3520
+ return getOutputsByType(outputs, OutputType7.Variable);
3500
3521
  }
3501
3522
 
3502
3523
  // src/providers/transaction-summary/types.ts
@@ -3522,10 +3543,6 @@ var OperationName = /* @__PURE__ */ ((OperationName2) => {
3522
3543
  OperationName2["transfer"] = "Transfer asset";
3523
3544
  OperationName2["contractCall"] = "Contract call";
3524
3545
  OperationName2["receive"] = "Receive asset";
3525
- OperationName2["mint"] = "Mint asset";
3526
- OperationName2["predicatecall"] = "Predicate call";
3527
- OperationName2["script"] = "Script";
3528
- OperationName2["sent"] = "Sent asset";
3529
3546
  OperationName2["withdrawFromFuel"] = "Withdraw from Fuel";
3530
3547
  return OperationName2;
3531
3548
  })(OperationName || {});
@@ -3559,8 +3576,8 @@ function getTransactionTypeName(transactionType) {
3559
3576
  case TransactionType9.Upload:
3560
3577
  return "Upload" /* Upload */;
3561
3578
  default:
3562
- throw new FuelError12(
3563
- ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
3579
+ throw new FuelError13(
3580
+ ErrorCode11.UNSUPPORTED_TRANSACTION_TYPE,
3564
3581
  `Unsupported transaction type: ${transactionType}.`
3565
3582
  );
3566
3583
  }
@@ -3759,7 +3776,7 @@ function getContractCallOperations({
3759
3776
  }
3760
3777
  function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
3761
3778
  const { to: toAddress, assetId, amount } = receipt;
3762
- let { from: fromAddress } = receipt;
3779
+ let { id: fromAddress } = receipt;
3763
3780
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3764
3781
  if (ZeroBytes329 === fromAddress) {
3765
3782
  const change = changeOutputs.find((output) => output.assetId === assetId);
@@ -3946,7 +3963,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3946
3963
  };
3947
3964
 
3948
3965
  // src/providers/transaction-summary/status.ts
3949
- import { ErrorCode as ErrorCode11, FuelError as FuelError13 } from "@fuel-ts/errors";
3966
+ import { ErrorCode as ErrorCode12, FuelError as FuelError14 } from "@fuel-ts/errors";
3950
3967
  import { bn as bn14 } from "@fuel-ts/math";
3951
3968
  var getTransactionStatusName = (gqlStatus) => {
3952
3969
  switch (gqlStatus) {
@@ -3959,8 +3976,8 @@ var getTransactionStatusName = (gqlStatus) => {
3959
3976
  case "SqueezedOutStatus":
3960
3977
  return "squeezedout" /* squeezedout */;
3961
3978
  default:
3962
- throw new FuelError13(
3963
- ErrorCode11.INVALID_TRANSACTION_STATUS,
3979
+ throw new FuelError14(
3980
+ ErrorCode12.INVALID_TRANSACTION_STATUS,
3964
3981
  `Invalid transaction status: ${gqlStatus}.`
3965
3982
  );
3966
3983
  }
@@ -4010,6 +4027,7 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4010
4027
  };
4011
4028
  return processedGraphqlStatus;
4012
4029
  };
4030
+ var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? bn14(status.totalFee) : void 0;
4013
4031
 
4014
4032
  // src/providers/transaction-summary/assemble-transaction-summary.ts
4015
4033
  function assembleTransactionSummary(params) {
@@ -4043,8 +4061,7 @@ function assembleTransactionSummary(params) {
4043
4061
  const typeName = getTransactionTypeName(transaction.type);
4044
4062
  const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
4045
4063
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
4046
- const fee = calculateTXFeeForSummary({
4047
- totalFee,
4064
+ const fee = totalFee ?? calculateTXFeeForSummary({
4048
4065
  gasPrice,
4049
4066
  rawPayload,
4050
4067
  tip,
@@ -4098,8 +4115,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4098
4115
  return receipts.reduce((logs, receipt) => {
4099
4116
  if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
4100
4117
  const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
4101
- const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
4102
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
4118
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4119
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4103
4120
  logs.push(decodedLog);
4104
4121
  }
4105
4122
  return logs;
@@ -4112,24 +4129,24 @@ function mapGqlOutputsToTxOutputs(outputs) {
4112
4129
  const obj = "amount" in o ? { ...o, amount: bn16(o.amount) } : o;
4113
4130
  switch (obj.type) {
4114
4131
  case "CoinOutput":
4115
- return { ...obj, type: OutputType7.Coin };
4132
+ return { ...obj, type: OutputType8.Coin };
4116
4133
  case "ContractOutput":
4117
4134
  return {
4118
4135
  ...obj,
4119
- type: OutputType7.Contract,
4136
+ type: OutputType8.Contract,
4120
4137
  inputIndex: parseInt(obj.inputIndex, 10)
4121
4138
  };
4122
4139
  case "ChangeOutput":
4123
4140
  return {
4124
4141
  ...obj,
4125
- type: OutputType7.Change
4142
+ type: OutputType8.Change
4126
4143
  };
4127
4144
  case "VariableOutput":
4128
- return { ...obj, type: OutputType7.Variable };
4145
+ return { ...obj, type: OutputType8.Variable };
4129
4146
  case "ContractCreated":
4130
4147
  return {
4131
4148
  ...obj,
4132
- type: OutputType7.ContractCreated,
4149
+ type: OutputType8.ContractCreated,
4133
4150
  contractId: obj.contract
4134
4151
  };
4135
4152
  default:
@@ -4144,9 +4161,9 @@ var TransactionResponse = class {
4144
4161
  * @param tx - The transaction ID or TransactionRequest.
4145
4162
  * @param provider - The provider.
4146
4163
  */
4147
- constructor(tx, provider, abis, submitTxSubscription) {
4164
+ constructor(tx, provider, chainId, abis, submitTxSubscription) {
4148
4165
  this.submitTxSubscription = submitTxSubscription;
4149
- this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
4166
+ this.id = typeof tx === "string" ? tx : tx.getTransactionId(chainId);
4150
4167
  this.provider = provider;
4151
4168
  this.abis = abis;
4152
4169
  this.request = typeof tx === "string" ? void 0 : tx;
@@ -4171,7 +4188,8 @@ var TransactionResponse = class {
4171
4188
  * @param provider - The provider.
4172
4189
  */
4173
4190
  static async create(id, provider, abis) {
4174
- const response = new TransactionResponse(id, provider, abis);
4191
+ const chainId = await provider.getChainId();
4192
+ const response = new TransactionResponse(id, provider, chainId, abis);
4175
4193
  await response.fetch();
4176
4194
  return response;
4177
4195
  }
@@ -4268,10 +4286,11 @@ var TransactionResponse = class {
4268
4286
  */
4269
4287
  async getTransactionSummary(contractsAbiMap) {
4270
4288
  const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
4271
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
4272
- const gasPrice = await this.provider.getLatestGasPrice();
4273
- const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
4274
- const baseAssetId = this.provider.getBaseAssetId();
4289
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig();
4290
+ const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status);
4291
+ const gasPrice = totalFee ? bn16(0) : await this.provider.getLatestGasPrice();
4292
+ const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs;
4293
+ const baseAssetId = await this.provider.getBaseAssetId();
4275
4294
  const transactionSummary = assembleTransactionSummary({
4276
4295
  id: this.id,
4277
4296
  receipts: this.getReceipts(),
@@ -4302,8 +4321,8 @@ var TransactionResponse = class {
4302
4321
  this.status = statusChange;
4303
4322
  if (statusChange.type === "SqueezedOutStatus") {
4304
4323
  this.unsetResourceCache();
4305
- throw new FuelError14(
4306
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
4324
+ throw new FuelError15(
4325
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
4307
4326
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4308
4327
  );
4309
4328
  }
@@ -4411,54 +4430,54 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4411
4430
  }
4412
4431
 
4413
4432
  // src/providers/utils/handle-gql-error-message.ts
4414
- import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
4433
+ import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
4415
4434
  var handleGqlErrorMessage = (errorMessage, rawError) => {
4416
4435
  switch (errorMessage) {
4417
4436
  case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4418
- throw new FuelError15(
4419
- ErrorCode13.NOT_ENOUGH_FUNDS,
4437
+ throw new FuelError16(
4438
+ ErrorCode14.NOT_ENOUGH_FUNDS,
4420
4439
  `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4421
4440
  {},
4422
4441
  rawError
4423
4442
  );
4424
4443
  case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4425
- throw new FuelError15(
4426
- ErrorCode13.MAX_COINS_REACHED,
4444
+ throw new FuelError16(
4445
+ ErrorCode14.MAX_COINS_REACHED,
4427
4446
  "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4428
4447
  {},
4429
4448
  rawError
4430
4449
  );
4431
4450
  default:
4432
- throw new FuelError15(ErrorCode13.INVALID_REQUEST, errorMessage);
4451
+ throw new FuelError16(ErrorCode14.INVALID_REQUEST, errorMessage);
4433
4452
  }
4434
4453
  };
4435
4454
 
4436
4455
  // src/providers/utils/validate-pagination-args.ts
4437
- import { FuelError as FuelError16, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
4456
+ import { FuelError as FuelError17, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
4438
4457
  var validatePaginationArgs = (params) => {
4439
4458
  const { paginationLimit, inputArgs = {} } = params;
4440
4459
  const { first, last, after, before } = inputArgs;
4441
4460
  if (after && before) {
4442
- throw new FuelError16(
4443
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4461
+ throw new FuelError17(
4462
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4444
4463
  'Pagination arguments "after" and "before" cannot be used together'
4445
4464
  );
4446
4465
  }
4447
4466
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4448
- throw new FuelError16(
4449
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4467
+ throw new FuelError17(
4468
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4450
4469
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
4451
4470
  );
4452
4471
  }
4453
4472
  if (first && before) {
4454
- throw new FuelError16(
4455
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4473
+ throw new FuelError17(
4474
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4456
4475
  'The use of pagination argument "first" with "before" is not supported'
4457
4476
  );
4458
4477
  }
4459
4478
  if (last && after) {
4460
- throw new FuelError16(
4461
- ErrorCode14.INVALID_INPUT_PARAMETERS,
4479
+ throw new FuelError17(
4480
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
4462
4481
  'The use of pagination argument "last" with "after" is not supported'
4463
4482
  );
4464
4483
  }
@@ -4612,7 +4631,7 @@ var _Provider = class {
4612
4631
  try {
4613
4632
  parsedUrl = new URL(url);
4614
4633
  } catch (error) {
4615
- throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4634
+ throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4616
4635
  }
4617
4636
  const username = parsedUrl.username;
4618
4637
  const password = parsedUrl.password;
@@ -4627,58 +4646,40 @@ var _Provider = class {
4627
4646
  };
4628
4647
  }
4629
4648
  /**
4630
- * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4631
- *
4632
- * @param url - GraphQL endpoint of the Fuel node
4633
- * @param options - Additional options for the provider
4634
- *
4635
- * @returns A promise that resolves to a Provider instance.
4649
+ * Initialize Provider async stuff
4636
4650
  */
4637
- static async create(url, options = {}) {
4638
- const provider = new _Provider(url, options);
4639
- await provider.fetchChainAndNodeInfo();
4640
- return provider;
4651
+ async init() {
4652
+ await this.fetchChainAndNodeInfo();
4653
+ return this;
4641
4654
  }
4642
4655
  /**
4643
- * Returns the cached chainInfo for the current URL.
4656
+ * Returns the `chainInfo` for the current network.
4644
4657
  *
4645
4658
  * @returns the chain information configuration.
4646
4659
  */
4647
- getChain() {
4648
- const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4649
- if (!chain) {
4650
- throw new FuelError17(
4651
- ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
4652
- "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4653
- );
4654
- }
4655
- return chain;
4660
+ async getChain() {
4661
+ await this.init();
4662
+ return _Provider.chainInfoCache[this.urlWithoutAuth];
4656
4663
  }
4657
4664
  /**
4658
- * Returns the cached nodeInfo for the current URL.
4665
+ * Returns the `nodeInfo` for the current network.
4659
4666
  *
4660
4667
  * @returns the node information configuration.
4661
4668
  */
4662
- getNode() {
4663
- const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4664
- if (!node) {
4665
- throw new FuelError17(
4666
- ErrorCode15.NODE_INFO_CACHE_EMPTY,
4667
- "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4668
- );
4669
- }
4670
- return node;
4669
+ async getNode() {
4670
+ await this.init();
4671
+ return _Provider.nodeInfoCache[this.urlWithoutAuth];
4671
4672
  }
4672
4673
  /**
4673
4674
  * Returns some helpful parameters related to gas fees.
4674
4675
  */
4675
- getGasConfig() {
4676
+ async getGasConfig() {
4676
4677
  const {
4677
4678
  txParameters: { maxGasPerTx },
4678
4679
  predicateParameters: { maxGasPerPredicate },
4679
4680
  feeParameters: { gasPriceFactor, gasPerByte },
4680
4681
  gasCosts
4681
- } = this.getChain().consensusParameters;
4682
+ } = (await this.getChain()).consensusParameters;
4682
4683
  return {
4683
4684
  maxGasPerTx,
4684
4685
  maxGasPerPredicate,
@@ -4700,7 +4701,7 @@ var _Provider = class {
4700
4701
  this.options = options ?? this.options;
4701
4702
  this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
4702
4703
  this.operations = this.createOperations();
4703
- await this.fetchChainAndNodeInfo();
4704
+ await this.init();
4704
4705
  }
4705
4706
  /**
4706
4707
  * Return the chain and node information.
@@ -4711,11 +4712,12 @@ var _Provider = class {
4711
4712
  let nodeInfo;
4712
4713
  let chain;
4713
4714
  try {
4714
- if (ignoreCache) {
4715
- throw new Error(`Jumps to the catch block andre-fetch`);
4715
+ nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
4716
+ chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4717
+ const noCache = !nodeInfo || !chain;
4718
+ if (ignoreCache || noCache) {
4719
+ throw new Error(`Jumps to the catch block and re-fetch`);
4716
4720
  }
4717
- nodeInfo = this.getNode();
4718
- chain = this.getChain();
4719
4721
  } catch (_err) {
4720
4722
  const data = await this.operations.getChainAndNodeInfo();
4721
4723
  nodeInfo = {
@@ -4862,10 +4864,10 @@ Supported fuel-core version: ${supportedVersion}.`
4862
4864
  *
4863
4865
  * @returns A promise that resolves to the chain ID number.
4864
4866
  */
4865
- getChainId() {
4867
+ async getChainId() {
4866
4868
  const {
4867
4869
  consensusParameters: { chainId }
4868
- } = this.getChain();
4870
+ } = await this.getChain();
4869
4871
  return chainId.toNumber();
4870
4872
  }
4871
4873
  /**
@@ -4873,30 +4875,31 @@ Supported fuel-core version: ${supportedVersion}.`
4873
4875
  *
4874
4876
  * @returns the base asset ID.
4875
4877
  */
4876
- getBaseAssetId() {
4878
+ async getBaseAssetId() {
4879
+ const all = await this.getChain();
4877
4880
  const {
4878
4881
  consensusParameters: { baseAssetId }
4879
- } = this.getChain();
4882
+ } = all;
4880
4883
  return baseAssetId;
4881
4884
  }
4882
4885
  /**
4883
4886
  * @hidden
4884
4887
  */
4885
- validateTransaction(tx) {
4888
+ async validateTransaction(tx) {
4886
4889
  const {
4887
4890
  consensusParameters: {
4888
4891
  txParameters: { maxInputs, maxOutputs }
4889
4892
  }
4890
- } = this.getChain();
4893
+ } = await this.getChain();
4891
4894
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4892
- throw new FuelError17(
4893
- ErrorCode15.MAX_INPUTS_EXCEEDED,
4895
+ throw new FuelError18(
4896
+ ErrorCode16.MAX_INPUTS_EXCEEDED,
4894
4897
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
4895
4898
  );
4896
4899
  }
4897
4900
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4898
- throw new FuelError17(
4899
- ErrorCode15.MAX_OUTPUTS_EXCEEDED,
4901
+ throw new FuelError18(
4902
+ ErrorCode16.MAX_OUTPUTS_EXCEEDED,
4900
4903
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
4901
4904
  );
4902
4905
  }
@@ -4911,20 +4914,26 @@ Supported fuel-core version: ${supportedVersion}.`
4911
4914
  * @param sendTransactionParams - The provider send transaction parameters (optional).
4912
4915
  * @returns A promise that resolves to the transaction response object.
4913
4916
  */
4914
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4917
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, enableAssetBurn } = {}) {
4915
4918
  const transactionRequest = transactionRequestify(transactionRequestLike);
4919
+ validateTransactionForAssetBurn(
4920
+ await this.getBaseAssetId(),
4921
+ transactionRequest,
4922
+ enableAssetBurn
4923
+ );
4916
4924
  if (estimateTxDependencies) {
4917
4925
  await this.estimateTxDependencies(transactionRequest);
4918
4926
  }
4919
- this.validateTransaction(transactionRequest);
4927
+ await this.validateTransaction(transactionRequest);
4920
4928
  const encodedTransaction = hexlify15(transactionRequest.toTransactionBytes());
4921
4929
  let abis;
4922
4930
  if (isTransactionTypeScript(transactionRequest)) {
4923
4931
  abis = transactionRequest.abis;
4924
4932
  }
4925
4933
  const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
4926
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
4927
- return new TransactionResponse(transactionRequest, this, abis, subscription);
4934
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
4935
+ const chainId = await this.getChainId();
4936
+ return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
4928
4937
  }
4929
4938
  /**
4930
4939
  * Executes a transaction without actually submitting it to the chain.
@@ -5004,7 +5013,7 @@ Supported fuel-core version: ${supportedVersion}.`
5004
5013
  const missingContractIds = [];
5005
5014
  let outputVariables = 0;
5006
5015
  let dryRunStatus;
5007
- this.validateTransaction(transactionRequest);
5016
+ await this.validateTransaction(transactionRequest);
5008
5017
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5009
5018
  const {
5010
5019
  dryRun: [{ receipts: rawReceipts, status }]
@@ -5135,7 +5144,11 @@ Supported fuel-core version: ${supportedVersion}.`
5135
5144
  if (diff < 6e4) {
5136
5145
  return;
5137
5146
  }
5138
- const chainInfo = this.getChain();
5147
+ if (!_Provider.chainInfoCache?.[this.urlWithoutAuth]) {
5148
+ await this.fetchChainAndNodeInfo(true);
5149
+ return;
5150
+ }
5151
+ const chainInfo = _Provider.chainInfoCache[this.urlWithoutAuth];
5139
5152
  const {
5140
5153
  consensusParameters: { version: previous }
5141
5154
  } = chainInfo;
@@ -5159,8 +5172,8 @@ Supported fuel-core version: ${supportedVersion}.`
5159
5172
  const { transactionRequest } = params;
5160
5173
  let { gasPrice } = params;
5161
5174
  await this.autoRefetchConfigs();
5162
- const chainInfo = this.getChain();
5163
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5175
+ const chainInfo = await this.getChain();
5176
+ const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
5164
5177
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5165
5178
  if (!isDefined2(gasPrice)) {
5166
5179
  gasPrice = await this.estimateGasPrice(10);
@@ -5272,7 +5285,7 @@ Supported fuel-core version: ${supportedVersion}.`
5272
5285
  if (dryRunStatus && "reason" in dryRunStatus) {
5273
5286
  throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
5274
5287
  }
5275
- const { maxGasPerTx } = this.getGasConfig();
5288
+ const { maxGasPerTx } = await this.getGasConfig();
5276
5289
  const pristineGasUsed = getGasUsedFromReceipts(receipts);
5277
5290
  gasUsed = bn17(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
5278
5291
  txRequestClone.gasLimit = gasUsed;
@@ -5529,7 +5542,7 @@ Supported fuel-core version: ${supportedVersion}.`
5529
5542
  0
5530
5543
  )?.[0];
5531
5544
  } catch (error) {
5532
- if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5545
+ if (error instanceof FuelError18 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
5533
5546
  console.warn("Unsupported transaction type encountered");
5534
5547
  return null;
5535
5548
  }
@@ -5555,7 +5568,7 @@ Supported fuel-core version: ${supportedVersion}.`
5555
5568
  try {
5556
5569
  return coder.decode(arrayify12(rawPayload), 0)[0];
5557
5570
  } catch (error) {
5558
- if (error instanceof FuelError17 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5571
+ if (error instanceof FuelError18 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
5559
5572
  console.warn("Unsupported transaction type encountered");
5560
5573
  return null;
5561
5574
  }
@@ -5681,8 +5694,8 @@ Supported fuel-core version: ${supportedVersion}.`
5681
5694
  nonce
5682
5695
  };
5683
5696
  if (commitBlockId && commitBlockHeight) {
5684
- throw new FuelError17(
5685
- ErrorCode15.INVALID_INPUT_PARAMETERS,
5697
+ throw new FuelError18(
5698
+ ErrorCode16.INVALID_INPUT_PARAMETERS,
5686
5699
  "commitBlockId and commitBlockHeight cannot be used together"
5687
5700
  );
5688
5701
  }
@@ -5845,9 +5858,9 @@ Supported fuel-core version: ${supportedVersion}.`
5845
5858
  * @param transactionId - The transaction ID to get the response for.
5846
5859
  * @returns A promise that resolves to the transaction response.
5847
5860
  */
5848
- // eslint-disable-next-line @typescript-eslint/require-await
5849
5861
  async getTransactionResponse(transactionId) {
5850
- return new TransactionResponse(transactionId, this);
5862
+ const chainId = await this.getChainId();
5863
+ return new TransactionResponse(transactionId, this, chainId);
5851
5864
  }
5852
5865
  /**
5853
5866
  * Returns Message for given nonce.
@@ -5937,7 +5950,7 @@ __publicField(Provider, "chainInfoCache", {});
5937
5950
  __publicField(Provider, "nodeInfoCache", {});
5938
5951
 
5939
5952
  // src/providers/transaction-summary/get-transaction-summary.ts
5940
- import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
5953
+ import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
5941
5954
  import { bn as bn18 } from "@fuel-ts/math";
5942
5955
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5943
5956
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
@@ -5947,8 +5960,8 @@ async function getTransactionSummary(params) {
5947
5960
  transactionId: id
5948
5961
  });
5949
5962
  if (!gqlTransaction) {
5950
- throw new FuelError18(
5951
- ErrorCode16.TRANSACTION_NOT_FOUND,
5963
+ throw new FuelError19(
5964
+ ErrorCode17.TRANSACTION_NOT_FOUND,
5952
5965
  `Transaction not found for given id: ${id}.`
5953
5966
  );
5954
5967
  }
@@ -5967,9 +5980,10 @@ async function getTransactionSummary(params) {
5967
5980
  txParameters: { maxInputs, maxGasPerTx },
5968
5981
  gasCosts
5969
5982
  }
5970
- } = provider.getChain();
5971
- const gasPrice = await provider.getLatestGasPrice();
5972
- const baseAssetId = provider.getBaseAssetId();
5983
+ } = await provider.getChain();
5984
+ const totalFee = getTotalFeeFromStatus(gqlTransaction.status);
5985
+ const gasPrice = totalFee ? bn18(0) : await provider.getLatestGasPrice();
5986
+ const baseAssetId = await provider.getBaseAssetId();
5973
5987
  const transactionInfo = assembleTransactionSummary({
5974
5988
  id: gqlTransaction.id,
5975
5989
  receipts,
@@ -5992,14 +6006,14 @@ async function getTransactionSummary(params) {
5992
6006
  async function getTransactionSummaryFromRequest(params) {
5993
6007
  const { provider, transactionRequest, abiMap } = params;
5994
6008
  const { receipts } = await provider.dryRun(transactionRequest);
5995
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
5996
- const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
6009
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await provider.getGasConfig();
6010
+ const maxInputs = (await provider.getChain()).consensusParameters.txParameters.maxInputs;
5997
6011
  const transaction = transactionRequest.toTransaction();
5998
6012
  const transactionBytes = transactionRequest.toTransactionBytes();
5999
6013
  const gasPrice = await provider.getLatestGasPrice();
6000
- const baseAssetId = provider.getBaseAssetId();
6014
+ const baseAssetId = await provider.getBaseAssetId();
6001
6015
  const transactionSummary = assembleTransactionSummary({
6002
- id: transactionRequest.getTransactionId(provider.getChainId()),
6016
+ id: transactionRequest.getTransactionId(await provider.getChainId()),
6003
6017
  receipts,
6004
6018
  transaction,
6005
6019
  transactionBytes,
@@ -6032,9 +6046,9 @@ async function getTransactionsSummaries(params) {
6032
6046
  txParameters: { maxInputs, maxGasPerTx },
6033
6047
  gasCosts
6034
6048
  }
6035
- } = provider.getChain();
6049
+ } = await provider.getChain();
6036
6050
  const gasPrice = await provider.getLatestGasPrice();
6037
- const baseAssetId = provider.getBaseAssetId();
6051
+ const baseAssetId = await provider.getBaseAssetId();
6038
6052
  const transactions = edges.map((edge) => {
6039
6053
  const { node: gqlTransaction } = edge;
6040
6054
  const { id, rawPayload, status } = gqlTransaction;
@@ -6742,6 +6756,10 @@ var mergeQuantities = (...coinQuantities) => {
6742
6756
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
6743
6757
  };
6744
6758
 
6759
+ // src/types.ts
6760
+ var AbstractAccount = class {
6761
+ };
6762
+
6745
6763
  // src/utils/formatTransferToContractScriptData.ts
6746
6764
  import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6747
6765
  import { Address as Address3 } from "@fuel-ts/address";
@@ -6823,7 +6841,7 @@ var Account = class extends AbstractAccount {
6823
6841
  */
6824
6842
  get provider() {
6825
6843
  if (!this._provider) {
6826
- throw new FuelError19(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6844
+ throw new FuelError20(ErrorCode18.MISSING_PROVIDER, "Provider not set");
6827
6845
  }
6828
6846
  return this._provider;
6829
6847
  }
@@ -6879,7 +6897,7 @@ var Account = class extends AbstractAccount {
6879
6897
  * @returns A promise that resolves to the balance amount.
6880
6898
  */
6881
6899
  async getBalance(assetId) {
6882
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
6900
+ const assetIdToFetch = assetId ?? await this.provider.getBaseAssetId();
6883
6901
  const amount = await this.provider.getBalance(this.address, assetIdToFetch);
6884
6902
  return amount;
6885
6903
  }
@@ -6902,7 +6920,7 @@ var Account = class extends AbstractAccount {
6902
6920
  async fund(request, params) {
6903
6921
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6904
6922
  const fee = request.maxFee;
6905
- const baseAssetId = this.provider.getBaseAssetId();
6923
+ const baseAssetId = await this.provider.getBaseAssetId();
6906
6924
  const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
6907
6925
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
6908
6926
  amount: bn19(fee),
@@ -6974,12 +6992,12 @@ var Account = class extends AbstractAccount {
6974
6992
  fundingAttempts += 1;
6975
6993
  }
6976
6994
  if (needsToBeFunded) {
6977
- throw new FuelError19(
6978
- ErrorCode17.NOT_ENOUGH_FUNDS,
6995
+ throw new FuelError20(
6996
+ ErrorCode18.NOT_ENOUGH_FUNDS,
6979
6997
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6980
6998
  );
6981
6999
  }
6982
- this.provider.validateTransaction(request);
7000
+ await this.provider.validateTransaction(request);
6983
7001
  request.updatePredicateGasUsed(estimatedPredicates);
6984
7002
  const requestToReestimate = clone9(request);
6985
7003
  if (addedSignatures) {
@@ -7006,7 +7024,11 @@ var Account = class extends AbstractAccount {
7006
7024
  */
7007
7025
  async createTransfer(destination, amount, assetId, txParams = {}) {
7008
7026
  let request = new ScriptTransactionRequest(txParams);
7009
- request = this.addTransfer(request, { destination, amount, assetId });
7027
+ request = this.addTransfer(request, {
7028
+ destination,
7029
+ amount,
7030
+ assetId: assetId || await this.provider.getBaseAssetId()
7031
+ });
7010
7032
  request = await this.estimateAndFundTransaction(request, txParams);
7011
7033
  return request;
7012
7034
  }
@@ -7046,11 +7068,7 @@ var Account = class extends AbstractAccount {
7046
7068
  addTransfer(request, transferParams) {
7047
7069
  const { destination, amount, assetId } = transferParams;
7048
7070
  this.validateTransferAmount(amount);
7049
- request.addCoinOutput(
7050
- Address4.fromAddressOrString(destination),
7051
- amount,
7052
- assetId ?? this.provider.getBaseAssetId()
7053
- );
7071
+ request.addCoinOutput(Address4.fromAddressOrString(destination), amount, assetId);
7054
7072
  return request;
7055
7073
  }
7056
7074
  /**
@@ -7061,12 +7079,11 @@ var Account = class extends AbstractAccount {
7061
7079
  * @returns The updated script transaction request.
7062
7080
  */
7063
7081
  addBatchTransfer(request, transferParams) {
7064
- const baseAssetId = this.provider.getBaseAssetId();
7065
7082
  transferParams.forEach(({ destination, amount, assetId }) => {
7066
7083
  this.addTransfer(request, {
7067
7084
  destination,
7068
7085
  amount,
7069
- assetId: assetId ?? baseAssetId
7086
+ assetId
7070
7087
  });
7071
7088
  });
7072
7089
  return request;
@@ -7088,13 +7105,14 @@ var Account = class extends AbstractAccount {
7088
7105
  ...txParams
7089
7106
  });
7090
7107
  const quantities = [];
7108
+ const defaultAssetId = await this.provider.getBaseAssetId();
7091
7109
  const transferParams = contractTransferParams.map((transferParam) => {
7092
7110
  const amount = bn19(transferParam.amount);
7093
7111
  const contractAddress = Address4.fromAddressOrString(transferParam.contractId);
7094
- const assetId = transferParam.assetId ? hexlify16(transferParam.assetId) : this.provider.getBaseAssetId();
7112
+ const assetId = transferParam.assetId ? hexlify16(transferParam.assetId) : defaultAssetId;
7095
7113
  if (amount.lte(0)) {
7096
- throw new FuelError19(
7097
- ErrorCode17.INVALID_TRANSFER_AMOUNT,
7114
+ throw new FuelError20(
7115
+ ErrorCode18.INVALID_TRANSFER_AMOUNT,
7098
7116
  "Transfer amount must be a positive number."
7099
7117
  );
7100
7118
  }
@@ -7134,7 +7152,7 @@ var Account = class extends AbstractAccount {
7134
7152
  ...amountDataArray
7135
7153
  ]);
7136
7154
  const params = { script, ...txParams };
7137
- const baseAssetId = this.provider.getBaseAssetId();
7155
+ const baseAssetId = await this.provider.getBaseAssetId();
7138
7156
  let request = new ScriptTransactionRequest(params);
7139
7157
  const quantities = [{ amount: bn19(amount), assetId: baseAssetId }];
7140
7158
  const txCost = await this.getTransactionCost(request, { quantities });
@@ -7159,7 +7177,7 @@ var Account = class extends AbstractAccount {
7159
7177
  */
7160
7178
  async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
7161
7179
  const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
7162
- const baseAssetId = this.provider.getBaseAssetId();
7180
+ const baseAssetId = await this.provider.getBaseAssetId();
7163
7181
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7164
7182
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7165
7183
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
@@ -7209,7 +7227,7 @@ var Account = class extends AbstractAccount {
7209
7227
  */
7210
7228
  async signMessage(message) {
7211
7229
  if (!this._connector) {
7212
- throw new FuelError19(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7230
+ throw new FuelError20(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
7213
7231
  }
7214
7232
  return this._connector.signMessage(this.address.toString(), message);
7215
7233
  }
@@ -7221,8 +7239,8 @@ var Account = class extends AbstractAccount {
7221
7239
  */
7222
7240
  async signTransaction(transactionRequestLike) {
7223
7241
  if (!this._connector) {
7224
- throw new FuelError19(
7225
- ErrorCode17.MISSING_CONNECTOR,
7242
+ throw new FuelError20(
7243
+ ErrorCode18.MISSING_CONNECTOR,
7226
7244
  "A connector is required to sign transactions."
7227
7245
  );
7228
7246
  }
@@ -7235,10 +7253,13 @@ var Account = class extends AbstractAccount {
7235
7253
  * @param sendTransactionParams - The provider send transaction parameters (optional).
7236
7254
  * @returns A promise that resolves to the transaction response.
7237
7255
  */
7238
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
7256
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
7239
7257
  if (this._connector) {
7240
7258
  return this.provider.getTransactionResponse(
7241
- await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
7259
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
7260
+ onBeforeSend,
7261
+ skipCustomFee
7262
+ })
7242
7263
  );
7243
7264
  }
7244
7265
  const transactionRequest = transactionRequestify(transactionRequestLike);
@@ -7281,8 +7302,8 @@ var Account = class extends AbstractAccount {
7281
7302
  /** @hidden * */
7282
7303
  validateTransferAmount(amount) {
7283
7304
  if (bn19(amount).lte(0)) {
7284
- throw new FuelError19(
7285
- ErrorCode17.INVALID_TRANSFER_AMOUNT,
7305
+ throw new FuelError20(
7306
+ ErrorCode18.INVALID_TRANSFER_AMOUNT,
7286
7307
  "Transfer amount must be a positive number."
7287
7308
  );
7288
7309
  }
@@ -7311,16 +7332,16 @@ var Account = class extends AbstractAccount {
7311
7332
  if (!isDefined3(setGasLimit)) {
7312
7333
  request.gasLimit = gasUsed;
7313
7334
  } else if (gasUsed.gt(setGasLimit)) {
7314
- throw new FuelError19(
7315
- ErrorCode17.GAS_LIMIT_TOO_LOW,
7335
+ throw new FuelError20(
7336
+ ErrorCode18.GAS_LIMIT_TOO_LOW,
7316
7337
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7317
7338
  );
7318
7339
  }
7319
7340
  if (!isDefined3(setMaxFee)) {
7320
7341
  request.maxFee = maxFee;
7321
7342
  } else if (maxFee.gt(setMaxFee)) {
7322
- throw new FuelError19(
7323
- ErrorCode17.MAX_FEE_TOO_LOW,
7343
+ throw new FuelError20(
7344
+ ErrorCode18.MAX_FEE_TOO_LOW,
7324
7345
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7325
7346
  );
7326
7347
  }
@@ -7453,7 +7474,7 @@ import {
7453
7474
  encryptJsonWalletData,
7454
7475
  randomUUID
7455
7476
  } from "@fuel-ts/crypto";
7456
- import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
7477
+ import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
7457
7478
  import { hexlify as hexlify18 } from "@fuel-ts/utils";
7458
7479
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7459
7480
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7530,8 +7551,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7530
7551
  const macHashUint8Array = keccak256(data);
7531
7552
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7532
7553
  if (mac !== macHash) {
7533
- throw new FuelError20(
7534
- ErrorCode18.INVALID_PASSWORD,
7554
+ throw new FuelError21(
7555
+ ErrorCode19.INVALID_PASSWORD,
7535
7556
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7536
7557
  );
7537
7558
  }
@@ -7591,7 +7612,7 @@ var BaseWalletUnlocked = class extends Account {
7591
7612
  */
7592
7613
  async signTransaction(transactionRequestLike) {
7593
7614
  const transactionRequest = transactionRequestify(transactionRequestLike);
7594
- const chainId = this.provider.getChainId();
7615
+ const chainId = await this.provider.getChainId();
7595
7616
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
7596
7617
  const signature = await this.signer().sign(hashedTransaction);
7597
7618
  return hexlify19(signature);
@@ -7615,14 +7636,19 @@ var BaseWalletUnlocked = class extends Account {
7615
7636
  * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
7616
7637
  * @returns A promise that resolves to the TransactionResponse object.
7617
7638
  */
7618
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
7639
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, enableAssetBurn } = {}) {
7619
7640
  const transactionRequest = transactionRequestify(transactionRequestLike);
7641
+ validateTransactionForAssetBurn(
7642
+ await this.provider.getBaseAssetId(),
7643
+ transactionRequest,
7644
+ enableAssetBurn
7645
+ );
7620
7646
  if (estimateTxDependencies) {
7621
7647
  await this.provider.estimateTxDependencies(transactionRequest);
7622
7648
  }
7623
7649
  return this.provider.sendTransaction(
7624
7650
  await this.populateTransactionWitnessesSignature(transactionRequest),
7625
- { estimateTxDependencies: false }
7651
+ { estimateTxDependencies: false, enableAssetBurn }
7626
7652
  );
7627
7653
  }
7628
7654
  /**
@@ -7661,14 +7687,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7661
7687
 
7662
7688
  // src/hdwallet/hdwallet.ts
7663
7689
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7664
- import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
7690
+ import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
7665
7691
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7666
7692
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
7667
7693
  import { arrayify as arrayify19, hexlify as hexlify21, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7668
7694
 
7669
7695
  // src/mnemonic/mnemonic.ts
7670
7696
  import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7671
- import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
7697
+ import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
7672
7698
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
7673
7699
  import { arrayify as arrayify18, hexlify as hexlify20, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7674
7700
 
@@ -9731,7 +9757,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
9731
9757
  })(Language || {});
9732
9758
 
9733
9759
  // src/mnemonic/utils.ts
9734
- import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
9760
+ import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
9735
9761
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9736
9762
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9737
9763
  function getLowerMask(bits) {
@@ -9780,8 +9806,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9780
9806
  for (let i = 0; i < words.length; i += 1) {
9781
9807
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9782
9808
  if (index === -1) {
9783
- throw new FuelError21(
9784
- ErrorCode19.INVALID_MNEMONIC,
9809
+ throw new FuelError22(
9810
+ ErrorCode20.INVALID_MNEMONIC,
9785
9811
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9786
9812
  );
9787
9813
  }
@@ -9797,8 +9823,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9797
9823
  const checksumMask = getUpperMask(checksumBits);
9798
9824
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9799
9825
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9800
- throw new FuelError21(
9801
- ErrorCode19.INVALID_CHECKSUM,
9826
+ throw new FuelError22(
9827
+ ErrorCode20.INVALID_CHECKSUM,
9802
9828
  "Checksum validation failed for the provided mnemonic."
9803
9829
  );
9804
9830
  }
@@ -9812,16 +9838,16 @@ var TestnetPRV = "0x04358394";
9812
9838
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9813
9839
  function assertWordList(wordlist) {
9814
9840
  if (wordlist.length !== 2048) {
9815
- throw new FuelError22(
9816
- ErrorCode20.INVALID_WORD_LIST,
9841
+ throw new FuelError23(
9842
+ ErrorCode21.INVALID_WORD_LIST,
9817
9843
  `Expected word list length of 2048, but got ${wordlist.length}.`
9818
9844
  );
9819
9845
  }
9820
9846
  }
9821
9847
  function assertEntropy(entropy) {
9822
9848
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9823
- throw new FuelError22(
9824
- ErrorCode20.INVALID_ENTROPY,
9849
+ throw new FuelError23(
9850
+ ErrorCode21.INVALID_ENTROPY,
9825
9851
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9826
9852
  );
9827
9853
  }
@@ -9831,7 +9857,7 @@ function assertMnemonic(words) {
9831
9857
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9832
9858
  ", "
9833
9859
  )}] words, but got ${words.length}.`;
9834
- throw new FuelError22(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9860
+ throw new FuelError23(ErrorCode21.INVALID_MNEMONIC, errorMsg);
9835
9861
  }
9836
9862
  }
9837
9863
  var Mnemonic = class {
@@ -9949,8 +9975,8 @@ var Mnemonic = class {
9949
9975
  static masterKeysFromSeed(seed) {
9950
9976
  const seedArray = arrayify18(seed);
9951
9977
  if (seedArray.length < 16 || seedArray.length > 64) {
9952
- throw new FuelError22(
9953
- ErrorCode20.INVALID_SEED,
9978
+ throw new FuelError23(
9979
+ ErrorCode21.INVALID_SEED,
9954
9980
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9955
9981
  );
9956
9982
  }
@@ -10027,7 +10053,7 @@ function isValidExtendedKey(extendedKey) {
10027
10053
  function parsePath(path, depth = 0) {
10028
10054
  const components = path.split("/");
10029
10055
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
10030
- throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path}`);
10056
+ throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path}`);
10031
10057
  }
10032
10058
  if (components[0] === "m") {
10033
10059
  components.shift();
@@ -10056,8 +10082,8 @@ var HDWallet = class {
10056
10082
  this.privateKey = hexlify21(config.privateKey);
10057
10083
  } else {
10058
10084
  if (!config.publicKey) {
10059
- throw new FuelError23(
10060
- ErrorCode21.HD_WALLET_ERROR,
10085
+ throw new FuelError24(
10086
+ ErrorCode22.HD_WALLET_ERROR,
10061
10087
  "Both public and private Key cannot be missing. At least one should be provided."
10062
10088
  );
10063
10089
  }
@@ -10086,8 +10112,8 @@ var HDWallet = class {
10086
10112
  const data = new Uint8Array(37);
10087
10113
  if (index & HARDENED_INDEX) {
10088
10114
  if (!privateKey) {
10089
- throw new FuelError23(
10090
- ErrorCode21.HD_WALLET_ERROR,
10115
+ throw new FuelError24(
10116
+ ErrorCode22.HD_WALLET_ERROR,
10091
10117
  "Cannot derive a hardened index without a private Key."
10092
10118
  );
10093
10119
  }
@@ -10139,8 +10165,8 @@ var HDWallet = class {
10139
10165
  */
10140
10166
  toExtendedKey(isPublic = false, testnet = false) {
10141
10167
  if (this.depth >= 256) {
10142
- throw new FuelError23(
10143
- ErrorCode21.HD_WALLET_ERROR,
10168
+ throw new FuelError24(
10169
+ ErrorCode22.HD_WALLET_ERROR,
10144
10170
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10145
10171
  );
10146
10172
  }
@@ -10171,10 +10197,10 @@ var HDWallet = class {
10171
10197
  const bytes = arrayify19(decoded);
10172
10198
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10173
10199
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10174
- throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10200
+ throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10175
10201
  }
10176
10202
  if (!validChecksum) {
10177
- throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10203
+ throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10178
10204
  }
10179
10205
  const depth = bytes[4];
10180
10206
  const parentFingerprint = hexlify21(bytes.slice(5, 9));
@@ -10182,14 +10208,14 @@ var HDWallet = class {
10182
10208
  const chainCode = hexlify21(bytes.slice(13, 45));
10183
10209
  const key = bytes.slice(45, 78);
10184
10210
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10185
- throw new FuelError23(
10186
- ErrorCode21.HD_WALLET_ERROR,
10211
+ throw new FuelError24(
10212
+ ErrorCode22.HD_WALLET_ERROR,
10187
10213
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10188
10214
  );
10189
10215
  }
10190
10216
  if (isPublicExtendedKey(bytes)) {
10191
10217
  if (key[0] !== 3) {
10192
- throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10218
+ throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
10193
10219
  }
10194
10220
  return new HDWallet({
10195
10221
  publicKey: key,
@@ -10200,7 +10226,7 @@ var HDWallet = class {
10200
10226
  });
10201
10227
  }
10202
10228
  if (key[0] !== 0) {
10203
- throw new FuelError23(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10229
+ throw new FuelError24(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
10204
10230
  }
10205
10231
  return new HDWallet({
10206
10232
  privateKey: key.slice(1),
@@ -10368,7 +10394,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
10368
10394
  // src/wallet-manager/wallet-manager.ts
10369
10395
  import { Address as Address9 } from "@fuel-ts/address";
10370
10396
  import { encrypt, decrypt } from "@fuel-ts/crypto";
10371
- import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10397
+ import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
10372
10398
  import { EventEmitter } from "events";
10373
10399
 
10374
10400
  // src/wallet-manager/storages/memory-storage.ts
@@ -10391,7 +10417,7 @@ var MemoryStorage = class {
10391
10417
 
10392
10418
  // src/wallet-manager/vaults/mnemonic-vault.ts
10393
10419
  import { Address as Address7 } from "@fuel-ts/address";
10394
- import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
10420
+ import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10395
10421
  var _secret;
10396
10422
  var MnemonicVault = class {
10397
10423
  constructor(options) {
@@ -10447,8 +10473,8 @@ var MnemonicVault = class {
10447
10473
  }
10448
10474
  numberOfAccounts += 1;
10449
10475
  } while (numberOfAccounts < this.numberOfAccounts);
10450
- throw new FuelError24(
10451
- ErrorCode22.WALLET_MANAGER_ERROR,
10476
+ throw new FuelError25(
10477
+ ErrorCode23.WALLET_MANAGER_ERROR,
10452
10478
  `Account with address '${address}' not found in derived wallets.`
10453
10479
  );
10454
10480
  }
@@ -10462,7 +10488,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
10462
10488
 
10463
10489
  // src/wallet-manager/vaults/privatekey-vault.ts
10464
10490
  import { Address as Address8 } from "@fuel-ts/address";
10465
- import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
10491
+ import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
10466
10492
  var _privateKeys;
10467
10493
  var PrivateKeyVault = class {
10468
10494
  /**
@@ -10503,8 +10529,8 @@ var PrivateKeyVault = class {
10503
10529
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
10504
10530
  );
10505
10531
  if (!privateKey) {
10506
- throw new FuelError25(
10507
- ErrorCode23.WALLET_MANAGER_ERROR,
10532
+ throw new FuelError26(
10533
+ ErrorCode24.WALLET_MANAGER_ERROR,
10508
10534
  `No private key found for address '${address}'.`
10509
10535
  );
10510
10536
  }
@@ -10528,7 +10554,7 @@ var ERROR_MESSAGES = {
10528
10554
  };
10529
10555
  function assert(condition, message) {
10530
10556
  if (!condition) {
10531
- throw new FuelError26(ErrorCode24.WALLET_MANAGER_ERROR, message);
10557
+ throw new FuelError27(ErrorCode25.WALLET_MANAGER_ERROR, message);
10532
10558
  }
10533
10559
  }
10534
10560
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -10754,25 +10780,25 @@ deserializeVaults_fn = function(vaults) {
10754
10780
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
10755
10781
 
10756
10782
  // src/wallet-manager/types.ts
10757
- import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
10783
+ import { ErrorCode as ErrorCode26, FuelError as FuelError28 } from "@fuel-ts/errors";
10758
10784
  var Vault = class {
10759
10785
  constructor(_options) {
10760
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10786
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10761
10787
  }
10762
10788
  serialize() {
10763
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10789
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10764
10790
  }
10765
10791
  getAccounts() {
10766
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10792
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10767
10793
  }
10768
10794
  addAccount() {
10769
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10795
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10770
10796
  }
10771
10797
  exportAccount(_address) {
10772
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10798
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10773
10799
  }
10774
10800
  getWallet(_address) {
10775
- throw new FuelError27(ErrorCode25.NOT_IMPLEMENTED, "Not implemented.");
10801
+ throw new FuelError28(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
10776
10802
  }
10777
10803
  };
10778
10804
  __publicField(Vault, "type");
@@ -10782,11 +10808,11 @@ var StorageAbstract = class {
10782
10808
  // src/predicate/predicate.ts
10783
10809
  import { Interface as Interface4 } from "@fuel-ts/abi-coder";
10784
10810
  import { Address as Address10 } from "@fuel-ts/address";
10785
- import { ErrorCode as ErrorCode27, FuelError as FuelError29 } from "@fuel-ts/errors";
10811
+ import { ErrorCode as ErrorCode28, FuelError as FuelError30 } from "@fuel-ts/errors";
10786
10812
  import { arrayify as arrayify22, hexlify as hexlify23 } from "@fuel-ts/utils";
10787
10813
 
10788
10814
  // src/utils/deployScriptOrPredicate.ts
10789
- import { FuelError as FuelError28, ErrorCode as ErrorCode26 } from "@fuel-ts/errors";
10815
+ import { FuelError as FuelError29, ErrorCode as ErrorCode27 } from "@fuel-ts/errors";
10790
10816
  import { hash as hash3 } from "@fuel-ts/hasher";
10791
10817
  import { bn as bn21 } from "@fuel-ts/math";
10792
10818
  import { arrayify as arrayify20 } from "@fuel-ts/utils";
@@ -10921,7 +10947,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
10921
10947
  // src/utils/deployScriptOrPredicate.ts
10922
10948
  async function fundBlobTx(deployer, blobTxRequest) {
10923
10949
  let totalCost = bn21(0);
10924
- const chainInfo = deployer.provider.getChain();
10950
+ const chainInfo = await deployer.provider.getChain();
10925
10951
  const gasPrice = await deployer.provider.estimateGasPrice(10);
10926
10952
  const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
10927
10953
  const minGas = blobTxRequest.calculateMinGas(chainInfo);
@@ -10933,7 +10959,7 @@ async function fundBlobTx(deployer, blobTxRequest) {
10933
10959
  }).add(1);
10934
10960
  totalCost = totalCost.add(minFee);
10935
10961
  if (totalCost.gt(await deployer.getBalance())) {
10936
- throw new FuelError28(ErrorCode26.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
10962
+ throw new FuelError29(ErrorCode27.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
10937
10963
  }
10938
10964
  const txCost = await deployer.getTransactionCost(blobTxRequest);
10939
10965
  blobTxRequest.maxFee = txCost.maxFee;
@@ -10984,7 +11010,7 @@ async function deployScriptOrPredicate({
10984
11010
  throw new Error();
10985
11011
  }
10986
11012
  } catch (err) {
10987
- throw new FuelError28(ErrorCode26.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
11013
+ throw new FuelError29(ErrorCode27.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
10988
11014
  }
10989
11015
  return loaderInstance;
10990
11016
  };
@@ -11012,6 +11038,8 @@ var Predicate = class extends Account {
11012
11038
  bytes;
11013
11039
  predicateData = [];
11014
11040
  interface;
11041
+ initialBytecode;
11042
+ configurableConstants;
11015
11043
  /**
11016
11044
  * Creates an instance of the Predicate class.
11017
11045
  *
@@ -11035,8 +11063,10 @@ var Predicate = class extends Account {
11035
11063
  );
11036
11064
  const address = Address10.fromB256(getPredicateRoot(predicateBytes));
11037
11065
  super(address, provider);
11066
+ this.initialBytecode = arrayify22(bytecode);
11038
11067
  this.bytes = predicateBytes;
11039
11068
  this.interface = predicateInterface;
11069
+ this.configurableConstants = configurableConstants;
11040
11070
  if (data !== void 0 && data.length > 0) {
11041
11071
  this.predicateData = data;
11042
11072
  }
@@ -11089,6 +11119,20 @@ var Predicate = class extends Account {
11089
11119
  const mainFn = this.interface?.functions.main;
11090
11120
  return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
11091
11121
  }
11122
+ /**
11123
+ * Creates a new Predicate instance from an existing Predicate instance.
11124
+ * @param overrides - The data and configurable constants to override.
11125
+ * @returns A new Predicate instance with the same bytecode, ABI and provider but with the ability to set the data and configurable constants.
11126
+ */
11127
+ toNewInstance(overrides = {}) {
11128
+ return new Predicate({
11129
+ bytecode: this.initialBytecode,
11130
+ abi: this.interface.jsonAbi,
11131
+ provider: this.provider,
11132
+ data: overrides.data ?? this.predicateData,
11133
+ configurableConstants: overrides.configurableConstants ?? this.configurableConstants
11134
+ });
11135
+ }
11092
11136
  /**
11093
11137
  * Processes the predicate data and returns the altered bytecode and interface.
11094
11138
  *
@@ -11101,8 +11145,8 @@ var Predicate = class extends Account {
11101
11145
  let predicateBytes = arrayify22(bytes);
11102
11146
  const abiInterface = new Interface4(jsonAbi);
11103
11147
  if (abiInterface.functions.main === void 0) {
11104
- throw new FuelError29(
11105
- ErrorCode27.ABI_MAIN_METHOD_MISSING,
11148
+ throw new FuelError30(
11149
+ ErrorCode28.ABI_MAIN_METHOD_MISSING,
11106
11150
  'Cannot use ABI without "main" function.'
11107
11151
  );
11108
11152
  }
@@ -11162,15 +11206,15 @@ var Predicate = class extends Account {
11162
11206
  const mutatedBytes = bytes;
11163
11207
  try {
11164
11208
  if (Object.keys(abiInterface.configurables).length === 0) {
11165
- throw new FuelError29(
11166
- ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
11209
+ throw new FuelError30(
11210
+ ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
11167
11211
  "Predicate has no configurable constants to be set"
11168
11212
  );
11169
11213
  }
11170
11214
  Object.entries(configurableConstants).forEach(([key, value]) => {
11171
11215
  if (!abiInterface?.configurables[key]) {
11172
- throw new FuelError29(
11173
- ErrorCode27.CONFIGURABLE_NOT_FOUND,
11216
+ throw new FuelError30(
11217
+ ErrorCode28.CONFIGURABLE_NOT_FOUND,
11174
11218
  `No configurable constant named '${key}' found in the Predicate`
11175
11219
  );
11176
11220
  }
@@ -11179,8 +11223,8 @@ var Predicate = class extends Account {
11179
11223
  mutatedBytes.set(encoded, offset);
11180
11224
  });
11181
11225
  } catch (err) {
11182
- throw new FuelError29(
11183
- ErrorCode27.INVALID_CONFIGURABLE_CONSTANTS,
11226
+ throw new FuelError30(
11227
+ ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
11184
11228
  `Error setting configurable constants: ${err.message}.`
11185
11229
  );
11186
11230
  }
@@ -11233,10 +11277,10 @@ var Predicate = class extends Account {
11233
11277
  };
11234
11278
 
11235
11279
  // src/connectors/fuel.ts
11236
- import { ErrorCode as ErrorCode28, FuelError as FuelError32 } from "@fuel-ts/errors";
11280
+ import { ErrorCode as ErrorCode29, FuelError as FuelError33 } from "@fuel-ts/errors";
11237
11281
 
11238
11282
  // src/connectors/fuel-connector.ts
11239
- import { FuelError as FuelError30 } from "@fuel-ts/errors";
11283
+ import { FuelError as FuelError31 } from "@fuel-ts/errors";
11240
11284
  import { EventEmitter as EventEmitter2 } from "events";
11241
11285
 
11242
11286
  // src/connectors/types/connector-types.ts
@@ -11311,7 +11355,7 @@ var FuelConnector = class extends EventEmitter2 {
11311
11355
  * @returns Always true.
11312
11356
  */
11313
11357
  async ping() {
11314
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11358
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11315
11359
  }
11316
11360
  /**
11317
11361
  * Should return the current version of the connector
@@ -11320,7 +11364,7 @@ var FuelConnector = class extends EventEmitter2 {
11320
11364
  * @returns boolean - connection status.
11321
11365
  */
11322
11366
  async version() {
11323
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11367
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11324
11368
  }
11325
11369
  /**
11326
11370
  * Should return true if the connector is connected
@@ -11329,7 +11373,7 @@ var FuelConnector = class extends EventEmitter2 {
11329
11373
  * @returns The connection status.
11330
11374
  */
11331
11375
  async isConnected() {
11332
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11376
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11333
11377
  }
11334
11378
  /**
11335
11379
  * Should return all the accounts authorized for the
@@ -11338,7 +11382,7 @@ var FuelConnector = class extends EventEmitter2 {
11338
11382
  * @returns The accounts addresses strings
11339
11383
  */
11340
11384
  async accounts() {
11341
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11385
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11342
11386
  }
11343
11387
  /**
11344
11388
  * Should start the connection process and return
@@ -11350,7 +11394,7 @@ var FuelConnector = class extends EventEmitter2 {
11350
11394
  * @returns boolean - connection status.
11351
11395
  */
11352
11396
  async connect() {
11353
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11397
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11354
11398
  }
11355
11399
  /**
11356
11400
  * Should disconnect the current connection and
@@ -11360,7 +11404,7 @@ var FuelConnector = class extends EventEmitter2 {
11360
11404
  * @returns The connection status.
11361
11405
  */
11362
11406
  async disconnect() {
11363
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11407
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11364
11408
  }
11365
11409
  /**
11366
11410
  * Should start the sign message process and return
@@ -11372,7 +11416,7 @@ var FuelConnector = class extends EventEmitter2 {
11372
11416
  * @returns Message signature
11373
11417
  */
11374
11418
  async signMessage(_address, _message) {
11375
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11419
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11376
11420
  }
11377
11421
  /**
11378
11422
  * Should start the sign transaction process and return
@@ -11384,7 +11428,7 @@ var FuelConnector = class extends EventEmitter2 {
11384
11428
  * @returns Transaction signature
11385
11429
  */
11386
11430
  async signTransaction(_address, _transaction) {
11387
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11431
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11388
11432
  }
11389
11433
  /**
11390
11434
  * Should start the send transaction process and return
@@ -11396,11 +11440,11 @@ var FuelConnector = class extends EventEmitter2 {
11396
11440
  *
11397
11441
  * @param address - The address to sign the transaction
11398
11442
  * @param transaction - The transaction to send
11399
- *
11443
+ * @param params - Optional parameters to send the transaction
11400
11444
  * @returns The transaction id
11401
11445
  */
11402
- async sendTransaction(_address, _transaction) {
11403
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11446
+ async sendTransaction(_address, _transaction, _params) {
11447
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11404
11448
  }
11405
11449
  /**
11406
11450
  * Should return the current account selected inside the connector, if the account
@@ -11411,7 +11455,7 @@ var FuelConnector = class extends EventEmitter2 {
11411
11455
  * @returns The current account selected otherwise null.
11412
11456
  */
11413
11457
  async currentAccount() {
11414
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11458
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11415
11459
  }
11416
11460
  /**
11417
11461
  * Should add the assets metadata to the connector and return true if the asset
@@ -11425,7 +11469,7 @@ var FuelConnector = class extends EventEmitter2 {
11425
11469
  * @returns True if the asset was added successfully
11426
11470
  */
11427
11471
  async addAssets(_assets) {
11428
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11472
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11429
11473
  }
11430
11474
  /**
11431
11475
  * Should add the asset metadata to the connector and return true if the asset
@@ -11439,7 +11483,7 @@ var FuelConnector = class extends EventEmitter2 {
11439
11483
  * @returns True if the asset was added successfully
11440
11484
  */
11441
11485
  async addAsset(_asset) {
11442
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11486
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11443
11487
  }
11444
11488
  /**
11445
11489
  * Should return all the assets added to the connector. If a connection is already established.
@@ -11447,7 +11491,7 @@ var FuelConnector = class extends EventEmitter2 {
11447
11491
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
11448
11492
  */
11449
11493
  async assets() {
11450
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11494
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11451
11495
  }
11452
11496
  /**
11453
11497
  * Should start the add network process and return true if the network was added successfully.
@@ -11458,7 +11502,7 @@ var FuelConnector = class extends EventEmitter2 {
11458
11502
  * @returns Return true if the network was added successfully
11459
11503
  */
11460
11504
  async addNetwork(_networkUrl) {
11461
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11505
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11462
11506
  }
11463
11507
  /**
11464
11508
  * Should start the select network process and return true if the network has change successfully.
@@ -11469,7 +11513,7 @@ var FuelConnector = class extends EventEmitter2 {
11469
11513
  * @returns Return true if the network was added successfully
11470
11514
  */
11471
11515
  async selectNetwork(_network) {
11472
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11516
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11473
11517
  }
11474
11518
  /**
11475
11519
  * Should return all the networks available from the connector. If the connection is already established.
@@ -11477,7 +11521,7 @@ var FuelConnector = class extends EventEmitter2 {
11477
11521
  * @returns Return all the networks added to the connector.
11478
11522
  */
11479
11523
  async networks() {
11480
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11524
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11481
11525
  }
11482
11526
  /**
11483
11527
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -11485,7 +11529,7 @@ var FuelConnector = class extends EventEmitter2 {
11485
11529
  * @returns Return the current network selected inside the connector.
11486
11530
  */
11487
11531
  async currentNetwork() {
11488
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11532
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11489
11533
  }
11490
11534
  /**
11491
11535
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -11495,7 +11539,7 @@ var FuelConnector = class extends EventEmitter2 {
11495
11539
  * @returns Return true if the ABI was added successfully.
11496
11540
  */
11497
11541
  async addABI(_contractId, _abi) {
11498
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11542
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11499
11543
  }
11500
11544
  /**
11501
11545
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -11504,7 +11548,7 @@ var FuelConnector = class extends EventEmitter2 {
11504
11548
  * @returns The ABI if it exists, otherwise return null.
11505
11549
  */
11506
11550
  async getABI(_id) {
11507
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11551
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11508
11552
  }
11509
11553
  /**
11510
11554
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -11513,7 +11557,7 @@ var FuelConnector = class extends EventEmitter2 {
11513
11557
  * @returns Returns true if the abi exists or false if not.
11514
11558
  */
11515
11559
  async hasABI(_id) {
11516
- throw new FuelError30(FuelError30.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11560
+ throw new FuelError31(FuelError31.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11517
11561
  }
11518
11562
  /**
11519
11563
  * Event listener for the connector.
@@ -11557,7 +11601,7 @@ function dispatchFuelConnectorEvent(connector) {
11557
11601
  }
11558
11602
 
11559
11603
  // src/connectors/utils/promises.ts
11560
- import { FuelError as FuelError31 } from "@fuel-ts/errors";
11604
+ import { FuelError as FuelError32 } from "@fuel-ts/errors";
11561
11605
  function deferPromise() {
11562
11606
  const defer = {};
11563
11607
  defer.promise = new Promise((resolve, reject) => {
@@ -11569,7 +11613,7 @@ function deferPromise() {
11569
11613
  async function withTimeout(promise, timeout = 1050) {
11570
11614
  const timeoutPromise = new Promise((resolve, reject) => {
11571
11615
  setTimeout(() => {
11572
- reject(new FuelError31(FuelError31.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11616
+ reject(new FuelError32(FuelError32.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11573
11617
  }, timeout);
11574
11618
  });
11575
11619
  return Promise.race([timeoutPromise, promise]);
@@ -11604,7 +11648,7 @@ var _Fuel = class extends FuelConnector {
11604
11648
  this._targetUnsubscribe = this.setupConnectorListener();
11605
11649
  await connectResponse;
11606
11650
  } catch (error) {
11607
- throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Error initializing Fuel Connector");
11651
+ throw new FuelError33(ErrorCode29.INVALID_PROVIDER, "Error initializing Fuel Connector");
11608
11652
  }
11609
11653
  }
11610
11654
  async init() {
@@ -11670,8 +11714,8 @@ var _Fuel = class extends FuelConnector {
11670
11714
  const hasConnector = await this.hasConnector();
11671
11715
  await this.pingConnector();
11672
11716
  if (!this._currentConnector || !hasConnector) {
11673
- throw new FuelError32(
11674
- ErrorCode28.MISSING_CONNECTOR,
11717
+ throw new FuelError33(
11718
+ ErrorCode29.MISSING_CONNECTOR,
11675
11719
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
11676
11720
  );
11677
11721
  }
@@ -11735,7 +11779,7 @@ var _Fuel = class extends FuelConnector {
11735
11779
  cacheTime: PING_CACHE_TIME
11736
11780
  })();
11737
11781
  } catch {
11738
- throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Current connector is not available.");
11782
+ throw new FuelError33(ErrorCode29.INVALID_PROVIDER, "Current connector is not available.");
11739
11783
  }
11740
11784
  }
11741
11785
  /**
@@ -11879,12 +11923,12 @@ var _Fuel = class extends FuelConnector {
11879
11923
  if (providerOrNetwork && "getTransactionResponse" in providerOrNetwork) {
11880
11924
  provider = providerOrNetwork;
11881
11925
  } else if (providerOrNetwork && "chainId" in providerOrNetwork && "url" in providerOrNetwork) {
11882
- provider = await Provider.create(providerOrNetwork.url);
11926
+ provider = new Provider(providerOrNetwork.url);
11883
11927
  } else if (!providerOrNetwork) {
11884
11928
  const currentNetwork = await this.currentNetwork();
11885
- provider = await Provider.create(currentNetwork.url);
11929
+ provider = new Provider(currentNetwork.url);
11886
11930
  } else {
11887
- throw new FuelError32(ErrorCode28.INVALID_PROVIDER, "Provider is not valid.");
11931
+ throw new FuelError33(ErrorCode29.INVALID_PROVIDER, "Provider is not valid.");
11888
11932
  }
11889
11933
  return provider;
11890
11934
  }
@@ -11923,6 +11967,8 @@ var Fuel = _Fuel;
11923
11967
  __publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
11924
11968
  __publicField(Fuel, "defaultConfig", {});
11925
11969
  export {
11970
+ AbstractAccount,
11971
+ AbstractScriptRequest,
11926
11972
  Account,
11927
11973
  AddressType,
11928
11974
  BLOCKS_PAGE_SIZE_LIMIT,
@@ -12004,6 +12050,7 @@ export {
12004
12050
  getAssetFuel,
12005
12051
  getAssetNetwork,
12006
12052
  getAssetWithNetwork,
12053
+ getBurnableAssetCount,
12007
12054
  getContractCallOperations,
12008
12055
  getContractCreatedOperations,
12009
12056
  getDecodedLogs,
@@ -12035,6 +12082,7 @@ export {
12035
12082
  getReceiptsTransferOut,
12036
12083
  getReceiptsWithMissingData,
12037
12084
  getRequestInputResourceOwner,
12085
+ getTotalFeeFromStatus,
12038
12086
  getTransactionStatusName,
12039
12087
  getTransactionSummary,
12040
12088
  getTransactionSummaryFromRequest,
@@ -12078,6 +12126,7 @@ export {
12078
12126
  returnZeroScript,
12079
12127
  transactionRequestify,
12080
12128
  urlJoin,
12129
+ validateTransactionForAssetBurn,
12081
12130
  withTimeout,
12082
12131
  withdrawScript
12083
12132
  };