@fuel-ts/account 0.75.0 → 0.77.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.

Potentially problematic release.


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

Files changed (43) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  3. package/dist/index.global.js +1002 -2498
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +92 -72
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +156 -140
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  10. package/dist/mnemonic/utils.d.ts.map +1 -1
  11. package/dist/predicate/predicate.d.ts +16 -15
  12. package/dist/predicate/predicate.d.ts.map +1 -1
  13. package/dist/providers/__generated__/operations.d.ts +47 -38
  14. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  15. package/dist/providers/assets/index.d.ts +1 -0
  16. package/dist/providers/assets/index.d.ts.map +1 -1
  17. package/dist/providers/assets/types.d.ts +5 -5
  18. package/dist/providers/assets/types.d.ts.map +1 -1
  19. package/dist/providers/assets/utils/network.d.ts +4 -4
  20. package/dist/providers/assets/utils/network.d.ts.map +1 -1
  21. package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
  22. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  23. package/dist/providers/provider.d.ts +24 -15
  24. package/dist/providers/provider.d.ts.map +1 -1
  25. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  26. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  27. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  28. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  29. package/dist/providers/transaction-summary/index.d.ts +0 -1
  30. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  31. package/dist/providers/utils/index.d.ts +0 -1
  32. package/dist/providers/utils/index.d.ts.map +1 -1
  33. package/dist/test-utils.global.js +976 -2469
  34. package/dist/test-utils.global.js.map +1 -1
  35. package/dist/test-utils.js +68 -40
  36. package/dist/test-utils.js.map +1 -1
  37. package/dist/test-utils.mjs +113 -93
  38. package/dist/test-utils.mjs.map +1 -1
  39. package/package.json +16 -16
  40. package/dist/providers/transaction-summary/date.d.ts +0 -3
  41. package/dist/providers/transaction-summary/date.d.ts.map +0 -1
  42. package/dist/providers/utils/time.d.ts +0 -40
  43. package/dist/providers/utils/time.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -30,7 +30,7 @@ var __privateMethod = (obj, member, method) => {
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
- import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
33
+ import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
35
  import { bn as bn16 } from "@fuel-ts/math";
36
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
@@ -73,7 +73,7 @@ var addAmountToAsset = (params) => {
73
73
 
74
74
  // src/providers/provider.ts
75
75
  import { Address as Address2 } from "@fuel-ts/address";
76
- import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
76
+ import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
77
77
  import { BN, bn as bn14, max } from "@fuel-ts/math";
78
78
  import {
79
79
  InputType as InputType6,
@@ -81,7 +81,7 @@ import {
81
81
  InputMessageCoder,
82
82
  TransactionCoder as TransactionCoder5
83
83
  } from "@fuel-ts/transactions";
84
- import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
84
+ import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
85
85
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
86
86
  import { equalBytes } from "@noble/curves/abstract/utils";
87
87
  import { Network } from "ethers";
@@ -149,6 +149,9 @@ var TransactionStatusFragmentFragmentDoc = gql`
149
149
  time
150
150
  reason
151
151
  }
152
+ ... on SqueezedOutStatus {
153
+ reason
154
+ }
152
155
  }
153
156
  `;
154
157
  var TransactionFragmentFragmentDoc = gql`
@@ -891,7 +894,7 @@ function getSdk(requester) {
891
894
  }
892
895
 
893
896
  // src/providers/fuel-graphql-subscriber.ts
894
- import { FuelError } from "@fuel-ts/errors";
897
+ import { ErrorCode, FuelError } from "@fuel-ts/errors";
895
898
  import { print } from "graphql";
896
899
  var _FuelGraphqlSubscriber = class {
897
900
  constructor(options) {
@@ -926,7 +929,16 @@ var _FuelGraphqlSubscriber = class {
926
929
  if (!text.startsWith("data:")) {
927
930
  continue;
928
931
  }
929
- const { data, errors } = JSON.parse(text.split("data:")[1]);
932
+ let data;
933
+ let errors;
934
+ try {
935
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
936
+ } catch (e) {
937
+ throw new FuelError(
938
+ ErrorCode.STREAM_PARSING_ERROR,
939
+ `Error while parsing stream data response: ${text}`
940
+ );
941
+ }
930
942
  if (Array.isArray(errors)) {
931
943
  throw new FuelError(
932
944
  FuelError.CODES.INVALID_REQUEST,
@@ -952,7 +964,7 @@ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
952
964
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
953
965
 
954
966
  // src/providers/memory-cache.ts
955
- import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
967
+ import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
956
968
  import { hexlify as hexlify2 } from "@fuel-ts/utils";
957
969
  var cache = {};
958
970
  var DEFAULT_TTL_IN_MS = 30 * 1e3;
@@ -962,7 +974,7 @@ var MemoryCache = class {
962
974
  this.ttl = ttlInMs;
963
975
  if (typeof ttlInMs !== "number" || this.ttl <= 0) {
964
976
  throw new FuelError2(
965
- ErrorCode.INVALID_TTL,
977
+ ErrorCode2.INVALID_TTL,
966
978
  `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
967
979
  );
968
980
  }
@@ -1012,7 +1024,7 @@ var MemoryCache = class {
1012
1024
 
1013
1025
  // src/providers/transaction-request/input.ts
1014
1026
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1015
- import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
1027
+ import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1016
1028
  import { bn as bn2, toNumber } from "@fuel-ts/math";
1017
1029
  import { InputType } from "@fuel-ts/transactions";
1018
1030
  import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
@@ -1078,7 +1090,7 @@ var inputify = (value) => {
1078
1090
  }
1079
1091
  default: {
1080
1092
  throw new FuelError3(
1081
- ErrorCode2.INVALID_TRANSACTION_INPUT,
1093
+ ErrorCode3.INVALID_TRANSACTION_INPUT,
1082
1094
  `Invalid transaction input type: ${type}.`
1083
1095
  );
1084
1096
  }
@@ -1087,7 +1099,7 @@ var inputify = (value) => {
1087
1099
 
1088
1100
  // src/providers/transaction-request/output.ts
1089
1101
  import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
1090
- import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
1102
+ import { ErrorCode as ErrorCode4, FuelError as FuelError4 } from "@fuel-ts/errors";
1091
1103
  import { bn as bn3 } from "@fuel-ts/math";
1092
1104
  import { OutputType } from "@fuel-ts/transactions";
1093
1105
  import { hexlify as hexlify4 } from "@fuel-ts/utils";
@@ -1135,7 +1147,7 @@ var outputify = (value) => {
1135
1147
  }
1136
1148
  default: {
1137
1149
  throw new FuelError4(
1138
- ErrorCode3.INVALID_TRANSACTION_INPUT,
1150
+ ErrorCode4.INVALID_TRANSACTION_INPUT,
1139
1151
  `Invalid transaction output type: ${type}.`
1140
1152
  );
1141
1153
  }
@@ -1163,7 +1175,7 @@ var isMessage = (resource) => "recipient" in resource;
1163
1175
 
1164
1176
  // src/providers/utils/receipts.ts
1165
1177
  import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
1166
- import { ErrorCode as ErrorCode4, FuelError as FuelError5 } from "@fuel-ts/errors";
1178
+ import { ErrorCode as ErrorCode5, FuelError as FuelError5 } from "@fuel-ts/errors";
1167
1179
  import { bn as bn4 } from "@fuel-ts/math";
1168
1180
  import {
1169
1181
  ReceiptBurnCoder,
@@ -1368,12 +1380,12 @@ function assembleReceiptByType(receipt) {
1368
1380
  return burnReceipt;
1369
1381
  }
1370
1382
  default:
1371
- throw new FuelError5(ErrorCode4.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
1383
+ throw new FuelError5(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
1372
1384
  }
1373
1385
  }
1374
1386
 
1375
1387
  // src/providers/utils/block-explorer.ts
1376
- import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/errors";
1388
+ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/errors";
1377
1389
  var DEFAULT_BLOCK_EXPLORER_URL = "https://fuellabs.github.io/block-explorer-v2";
1378
1390
  var getPathFromInput = (key, value) => {
1379
1391
  const pathMap = {
@@ -1408,14 +1420,14 @@ var buildBlockExplorerUrl = (options = {}) => {
1408
1420
  const hasAnyDefinedValues = definedValues.length > 0;
1409
1421
  if (definedValues.length > 1) {
1410
1422
  throw new FuelError6(
1411
- ErrorCode5.ERROR_BUILDING_BLOCK_EXPLORER_URL,
1423
+ ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
1412
1424
  `Only one of the following can be passed in to buildBlockExplorerUrl: ${customInputParams.map((param) => param.key).join(", ")}.`
1413
1425
  );
1414
1426
  }
1415
1427
  if (path && definedValues.length > 0) {
1416
1428
  const inputKeys = customInputParams.map(({ key }) => key).join(", ");
1417
1429
  throw new FuelError6(
1418
- ErrorCode5.ERROR_BUILDING_BLOCK_EXPLORER_URL,
1430
+ ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
1419
1431
  `You cannot pass in a path to 'buildBlockExplorerUrl' along with any of the following: ${inputKeys}.`
1420
1432
  );
1421
1433
  }
@@ -1550,10 +1562,6 @@ function sleep(time) {
1550
1562
  });
1551
1563
  }
1552
1564
 
1553
- // src/providers/utils/time.ts
1554
- var fromTai64ToUnix = (tai64Timestamp) => Number(BigInt(tai64Timestamp) - BigInt(2 ** 62) - BigInt(10));
1555
- var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
1556
-
1557
1565
  // src/providers/transaction-request/errors.ts
1558
1566
  var ChangeOutputCollisionError = class extends Error {
1559
1567
  name = "ChangeOutputCollisionError";
@@ -1807,7 +1815,7 @@ var BaseTransactionRequest = class {
1807
1815
  txPointer: "0x00000000000000000000000000000000",
1808
1816
  witnessIndex,
1809
1817
  predicate: predicate?.bytes,
1810
- predicateData: predicate?.predicateData
1818
+ predicateData: predicate?.predicateDataBytes
1811
1819
  };
1812
1820
  this.pushInput(input);
1813
1821
  this.addChangeOutput(owner, assetId);
@@ -1840,7 +1848,7 @@ var BaseTransactionRequest = class {
1840
1848
  amount,
1841
1849
  witnessIndex,
1842
1850
  predicate: predicate?.bytes,
1843
- predicateData: predicate?.predicateData
1851
+ predicateData: predicate?.predicateDataBytes
1844
1852
  };
1845
1853
  this.pushInput(input);
1846
1854
  this.addChangeOutput(recipient, assetId);
@@ -2083,11 +2091,10 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2083
2091
 
2084
2092
  // src/providers/transaction-request/hash-transaction.ts
2085
2093
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2086
- import { uint64ToBytesBE } from "@fuel-ts/hasher";
2094
+ import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2087
2095
  import { bn as bn7 } from "@fuel-ts/math";
2088
2096
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2089
2097
  import { concat as concat2 } from "@fuel-ts/utils";
2090
- import { sha256 } from "ethers";
2091
2098
  import { clone as clone2 } from "ramda";
2092
2099
  function hashTransaction(transactionRequest, chainId) {
2093
2100
  const transaction = transactionRequest.toTransaction();
@@ -2474,7 +2481,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2474
2481
  };
2475
2482
 
2476
2483
  // src/providers/transaction-request/utils.ts
2477
- import { ErrorCode as ErrorCode6, FuelError as FuelError7 } from "@fuel-ts/errors";
2484
+ import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
2478
2485
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2479
2486
  var transactionRequestify = (obj) => {
2480
2487
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
@@ -2489,19 +2496,19 @@ var transactionRequestify = (obj) => {
2489
2496
  return CreateTransactionRequest.from(obj);
2490
2497
  }
2491
2498
  default: {
2492
- throw new FuelError7(ErrorCode6.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2499
+ throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2493
2500
  }
2494
2501
  }
2495
2502
  };
2496
2503
 
2497
2504
  // src/providers/transaction-response/transaction-response.ts
2498
- import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2505
+ import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
2499
2506
  import { bn as bn13 } from "@fuel-ts/math";
2500
2507
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2501
2508
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2502
2509
 
2503
2510
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2504
- import { hexlify as hexlify11 } from "@fuel-ts/utils";
2511
+ import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2505
2512
 
2506
2513
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2507
2514
  import { bn as bn10 } from "@fuel-ts/math";
@@ -2576,17 +2583,9 @@ var calculateTransactionFee = (params) => {
2576
2583
  };
2577
2584
  };
2578
2585
 
2579
- // src/providers/transaction-summary/date.ts
2580
- import { TAI64 } from "tai64";
2581
- var fromTai64ToDate = (tai64Timestamp) => {
2582
- const timestamp = TAI64.fromString(tai64Timestamp, 10).toUnix();
2583
- return new Date(timestamp * 1e3);
2584
- };
2585
- var fromDateToTai64 = (date) => TAI64.fromUnix(Math.floor(date.getTime() / 1e3)).toString(10);
2586
-
2587
2586
  // src/providers/transaction-summary/operations.ts
2588
2587
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2589
- import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
2588
+ import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2590
2589
  import { bn as bn12 } from "@fuel-ts/math";
2591
2590
  import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2592
2591
 
@@ -2635,7 +2634,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2635
2634
  };
2636
2635
 
2637
2636
  // src/providers/transaction-summary/input.ts
2638
- import { ErrorCode as ErrorCode7, FuelError as FuelError8 } from "@fuel-ts/errors";
2637
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2639
2638
  import { InputType as InputType5 } from "@fuel-ts/transactions";
2640
2639
  function getInputsByTypes(inputs, types) {
2641
2640
  return inputs.filter((i) => types.includes(i.type));
@@ -2674,7 +2673,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2674
2673
  }
2675
2674
  if (contractInput.type !== InputType5.Contract) {
2676
2675
  throw new FuelError8(
2677
- ErrorCode7.INVALID_TRANSACTION_INPUT,
2676
+ ErrorCode8.INVALID_TRANSACTION_INPUT,
2678
2677
  `Contract input should be of type 'contract'.`
2679
2678
  );
2680
2679
  }
@@ -2763,7 +2762,7 @@ function getTransactionTypeName(transactionType) {
2763
2762
  return "Script" /* Script */;
2764
2763
  default:
2765
2764
  throw new FuelError9(
2766
- ErrorCode8.INVALID_TRANSACTION_TYPE,
2765
+ ErrorCode9.INVALID_TRANSACTION_TYPE,
2767
2766
  `Invalid transaction type: ${transactionType}.`
2768
2767
  );
2769
2768
  }
@@ -3126,7 +3125,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3126
3125
  };
3127
3126
 
3128
3127
  // src/providers/transaction-summary/status.ts
3129
- import { ErrorCode as ErrorCode9, FuelError as FuelError10 } from "@fuel-ts/errors";
3128
+ import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3130
3129
  var getTransactionStatusName = (gqlStatus) => {
3131
3130
  switch (gqlStatus) {
3132
3131
  case "FailureStatus":
@@ -3139,7 +3138,7 @@ var getTransactionStatusName = (gqlStatus) => {
3139
3138
  return "squeezedout" /* squeezedout */;
3140
3139
  default:
3141
3140
  throw new FuelError10(
3142
- ErrorCode9.INVALID_TRANSACTION_STATUS,
3141
+ ErrorCode10.INVALID_TRANSACTION_STATUS,
3143
3142
  `Invalid transaction status: ${gqlStatus}.`
3144
3143
  );
3145
3144
  }
@@ -3224,7 +3223,7 @@ function assembleTransactionSummary(params) {
3224
3223
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3225
3224
  let date;
3226
3225
  if (time) {
3227
- date = fromTai64ToDate(time);
3226
+ date = DateTime.fromTai64(time);
3228
3227
  }
3229
3228
  const transactionSummary = {
3230
3229
  id,
@@ -3359,6 +3358,12 @@ var TransactionResponse = class {
3359
3358
  transactionId: this.id
3360
3359
  });
3361
3360
  for await (const { statusChange } of subscription) {
3361
+ if (statusChange.type === "SqueezedOutStatus") {
3362
+ throw new FuelError11(
3363
+ ErrorCode11.TRANSACTION_SQUEEZED_OUT,
3364
+ `Transaction Squeezed Out with reason: ${statusChange.reason}`
3365
+ );
3366
+ }
3362
3367
  if (statusChange.type !== "SubmittedStatus") {
3363
3368
  break;
3364
3369
  }
@@ -3388,7 +3393,7 @@ var TransactionResponse = class {
3388
3393
  const result = await this.waitForResult(contractsAbiMap);
3389
3394
  if (result.isStatusFailure) {
3390
3395
  throw new FuelError11(
3391
- ErrorCode10.TRANSACTION_FAILED,
3396
+ ErrorCode11.TRANSACTION_FAILED,
3392
3397
  `Transaction failed: ${result.gqlTransaction.status.reason}`
3393
3398
  );
3394
3399
  }
@@ -3397,7 +3402,7 @@ var TransactionResponse = class {
3397
3402
  };
3398
3403
 
3399
3404
  // src/providers/transaction-response/getDecodedLogs.ts
3400
- import { U64Coder } from "@fuel-ts/abi-coder";
3405
+ import { BigNumberCoder } from "@fuel-ts/abi-coder";
3401
3406
  import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3402
3407
  function getDecodedLogs(receipts, abiInterface) {
3403
3408
  return receipts.reduce((logs, r) => {
@@ -3405,7 +3410,9 @@ function getDecodedLogs(receipts, abiInterface) {
3405
3410
  logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3406
3411
  }
3407
3412
  if (r.type === ReceiptType5.Log) {
3408
- logs.push(abiInterface.decodeLog(new U64Coder().encode(r.val0), r.val1.toNumber(), r.id)[0]);
3413
+ logs.push(
3414
+ abiInterface.decodeLog(new BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3415
+ );
3409
3416
  }
3410
3417
  return logs;
3411
3418
  }, []);
@@ -3534,14 +3541,15 @@ var _Provider = class {
3534
3541
  }
3535
3542
  static getFetchFn(options) {
3536
3543
  const { retryOptions, timeout } = options;
3537
- return autoRetryFetch((...args) => {
3538
- if (options.fetch) {
3539
- return options.fetch(...args);
3540
- }
3544
+ return autoRetryFetch(async (...args) => {
3541
3545
  const url = args[0];
3542
3546
  const request = args[1];
3543
3547
  const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
3544
- return fetch(url, { ...request, signal });
3548
+ let fullRequest = { ...request, signal };
3549
+ if (options.requestMiddleware) {
3550
+ fullRequest = await options.requestMiddleware(fullRequest);
3551
+ }
3552
+ return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
3545
3553
  }, retryOptions);
3546
3554
  }
3547
3555
  /**
@@ -3561,7 +3569,7 @@ var _Provider = class {
3561
3569
  const chain = _Provider.chainInfoCache[this.url];
3562
3570
  if (!chain) {
3563
3571
  throw new FuelError12(
3564
- ErrorCode11.CHAIN_INFO_CACHE_EMPTY,
3572
+ ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
3565
3573
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3566
3574
  );
3567
3575
  }
@@ -3574,7 +3582,7 @@ var _Provider = class {
3574
3582
  const node = _Provider.nodeInfoCache[this.url];
3575
3583
  if (!node) {
3576
3584
  throw new FuelError12(
3577
- ErrorCode11.NODE_INFO_CACHE_EMPTY,
3585
+ ErrorCode12.NODE_INFO_CACHE_EMPTY,
3578
3586
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3579
3587
  );
3580
3588
  }
@@ -3747,6 +3755,12 @@ var _Provider = class {
3747
3755
  if (awaitExecution) {
3748
3756
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3749
3757
  for await (const { submitAndAwait } of subscription) {
3758
+ if (submitAndAwait.type === "SqueezedOutStatus") {
3759
+ throw new FuelError12(
3760
+ ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3761
+ `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3762
+ );
3763
+ }
3750
3764
  if (submitAndAwait.type !== "SubmittedStatus") {
3751
3765
  break;
3752
3766
  }
@@ -4257,7 +4271,7 @@ var _Provider = class {
4257
4271
  };
4258
4272
  if (commitBlockId && commitBlockHeight) {
4259
4273
  throw new FuelError12(
4260
- ErrorCode11.INVALID_INPUT_PARAMETERS,
4274
+ ErrorCode12.INVALID_INPUT_PARAMETERS,
4261
4275
  "commitBlockId and commitBlockHeight cannot be used together"
4262
4276
  );
4263
4277
  }
@@ -4343,13 +4357,13 @@ var _Provider = class {
4343
4357
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4344
4358
  *
4345
4359
  * @param amount - The amount of blocks to produce
4346
- * @param startTime - The UNIX timestamp to set for the first produced block
4360
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4347
4361
  * @returns A promise that resolves to the block number of the last produced block.
4348
4362
  */
4349
4363
  async produceBlocks(amount, startTime) {
4350
4364
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4351
4365
  blocksToProduce: bn14(amount).toString(10),
4352
- startTimestamp: startTime ? fromUnixToTai64(startTime) : void 0
4366
+ startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4353
4367
  });
4354
4368
  return bn14(latestBlockHeight);
4355
4369
  }
@@ -4374,7 +4388,7 @@ __publicField(Provider, "chainInfoCache", {});
4374
4388
  __publicField(Provider, "nodeInfoCache", {});
4375
4389
 
4376
4390
  // src/providers/transaction-summary/get-transaction-summary.ts
4377
- import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
4391
+ import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
4378
4392
  import { bn as bn15 } from "@fuel-ts/math";
4379
4393
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4380
4394
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
@@ -4385,7 +4399,7 @@ async function getTransactionSummary(params) {
4385
4399
  });
4386
4400
  if (!gqlTransaction) {
4387
4401
  throw new FuelError13(
4388
- ErrorCode12.TRANSACTION_NOT_FOUND,
4402
+ ErrorCode13.TRANSACTION_NOT_FOUND,
4389
4403
  `Transaction not found for given id: ${id}.`
4390
4404
  );
4391
4405
  }
@@ -4591,13 +4605,13 @@ var assets = [
4591
4605
  ];
4592
4606
 
4593
4607
  // src/utils/formatTransferToContractScriptData.ts
4594
- import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
4608
+ import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
4595
4609
  import { BN as BN2 } from "@fuel-ts/math";
4596
4610
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
4597
4611
  import * as asm from "@fuels/vm-asm";
4598
4612
  var formatTransferToContractScriptData = (params) => {
4599
4613
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4600
- const numberCoder = new U64Coder2();
4614
+ const numberCoder = new BigNumberCoder2("u64");
4601
4615
  const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
4602
4616
  const scriptData = Uint8Array.from([
4603
4617
  ...arrayify13(hexlifiedContractId),
@@ -4658,7 +4672,7 @@ var Account = class extends AbstractAccount {
4658
4672
  */
4659
4673
  get provider() {
4660
4674
  if (!this._provider) {
4661
- throw new FuelError14(ErrorCode13.MISSING_PROVIDER, "Provider not set");
4675
+ throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
4662
4676
  }
4663
4677
  return this._provider;
4664
4678
  }
@@ -4711,7 +4725,7 @@ var Account = class extends AbstractAccount {
4711
4725
  break;
4712
4726
  }
4713
4727
  throw new FuelError14(
4714
- ErrorCode13.NOT_SUPPORTED,
4728
+ ErrorCode14.NOT_SUPPORTED,
4715
4729
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4716
4730
  );
4717
4731
  }
@@ -4737,7 +4751,7 @@ var Account = class extends AbstractAccount {
4737
4751
  break;
4738
4752
  }
4739
4753
  throw new FuelError14(
4740
- ErrorCode13.NOT_SUPPORTED,
4754
+ ErrorCode14.NOT_SUPPORTED,
4741
4755
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4742
4756
  );
4743
4757
  }
@@ -4773,7 +4787,7 @@ var Account = class extends AbstractAccount {
4773
4787
  break;
4774
4788
  }
4775
4789
  throw new FuelError14(
4776
- ErrorCode13.NOT_SUPPORTED,
4790
+ ErrorCode14.NOT_SUPPORTED,
4777
4791
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4778
4792
  );
4779
4793
  }
@@ -4878,6 +4892,12 @@ var Account = class extends AbstractAccount {
4878
4892
  * @returns A promise that resolves to the transaction response.
4879
4893
  */
4880
4894
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4895
+ if (bn16(amount).lte(0)) {
4896
+ throw new FuelError14(
4897
+ ErrorCode14.INVALID_TRANSFER_AMOUNT,
4898
+ "Transfer amount must be a positive number."
4899
+ );
4900
+ }
4881
4901
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4882
4902
  return this.sendTransaction(request, { estimateTxDependencies: false });
4883
4903
  }
@@ -4891,6 +4911,12 @@ var Account = class extends AbstractAccount {
4891
4911
  * @returns A promise that resolves to the transaction response.
4892
4912
  */
4893
4913
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4914
+ if (bn16(amount).lte(0)) {
4915
+ throw new FuelError14(
4916
+ ErrorCode14.INVALID_TRANSFER_AMOUNT,
4917
+ "Transfer amount must be a positive number."
4918
+ );
4919
+ }
4894
4920
  const contractAddress = Address3.fromAddressOrString(contractId);
4895
4921
  const { minGasPrice } = this.provider.getGasConfig();
4896
4922
  const params = { gasPrice: minGasPrice, ...txParams };
@@ -4960,7 +4986,7 @@ var Account = class extends AbstractAccount {
4960
4986
  }
4961
4987
  async signMessage(message) {
4962
4988
  if (!this._connector) {
4963
- throw new FuelError14(ErrorCode13.MISSING_CONNECTOR, "A connector is required to sign messages.");
4989
+ throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
4964
4990
  }
4965
4991
  return this._connector.signMessage(this.address.toString(), message);
4966
4992
  }
@@ -5006,13 +5032,13 @@ var Account = class extends AbstractAccount {
5006
5032
  }) {
5007
5033
  if (minGasPrice.gt(gasPrice)) {
5008
5034
  throw new FuelError14(
5009
- ErrorCode13.GAS_PRICE_TOO_LOW,
5035
+ ErrorCode14.GAS_PRICE_TOO_LOW,
5010
5036
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5011
5037
  );
5012
5038
  }
5013
5039
  if (gasUsed.gt(gasLimit)) {
5014
5040
  throw new FuelError14(
5015
- ErrorCode13.GAS_LIMIT_TOO_LOW,
5041
+ ErrorCode14.GAS_LIMIT_TOO_LOW,
5016
5042
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5017
5043
  );
5018
5044
  }
@@ -5143,7 +5169,7 @@ import {
5143
5169
  decryptJsonWalletData,
5144
5170
  encryptJsonWalletData
5145
5171
  } from "@fuel-ts/crypto";
5146
- import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
5172
+ import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
5147
5173
  import { hexlify as hexlify14 } from "@fuel-ts/utils";
5148
5174
  import { v4 as uuidv4 } from "uuid";
5149
5175
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
@@ -5222,7 +5248,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5222
5248
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
5223
5249
  if (mac !== macHash) {
5224
5250
  throw new FuelError15(
5225
- ErrorCode14.INVALID_PASSWORD,
5251
+ ErrorCode15.INVALID_PASSWORD,
5226
5252
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5227
5253
  );
5228
5254
  }
@@ -5344,24 +5370,18 @@ var BaseWalletUnlocked = class extends Account {
5344
5370
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5345
5371
 
5346
5372
  // src/hdwallet/hdwallet.ts
5347
- import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
5373
+ import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5374
+ import { sha256 as sha2564 } from "@fuel-ts/hasher";
5348
5375
  import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5349
5376
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5350
- import {
5351
- toBeHex,
5352
- dataSlice as dataSlice2,
5353
- encodeBase58 as encodeBase582,
5354
- decodeBase58,
5355
- sha256 as sha2564,
5356
- computeHmac as computeHmac2,
5357
- ripemd160
5358
- } from "ethers";
5377
+ import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5359
5378
 
5360
5379
  // src/mnemonic/mnemonic.ts
5361
5380
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5362
- import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
5381
+ import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
5382
+ import { sha256 as sha2563 } from "@fuel-ts/hasher";
5363
5383
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5364
- import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
5384
+ import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
5365
5385
 
5366
5386
  // src/wordlists/words/english.ts
5367
5387
  var english = [
@@ -7422,9 +7442,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7422
7442
  })(Language || {});
7423
7443
 
7424
7444
  // src/mnemonic/utils.ts
7425
- import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
7445
+ import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
7446
+ import { sha256 as sha2562 } from "@fuel-ts/hasher";
7426
7447
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
7427
- import { sha256 as sha2562 } from "ethers";
7428
7448
  function toUtf8Bytes(stri) {
7429
7449
  const str = stri.normalize("NFKD");
7430
7450
  const result = [];
@@ -7440,7 +7460,7 @@ function toUtf8Bytes(stri) {
7440
7460
  const c2 = str.charCodeAt(i);
7441
7461
  if (i >= str.length || (c2 & 64512) !== 56320) {
7442
7462
  throw new FuelError16(
7443
- ErrorCode15.INVALID_INPUT_PARAMETERS,
7463
+ ErrorCode16.INVALID_INPUT_PARAMETERS,
7444
7464
  "Invalid UTF-8 in the input string."
7445
7465
  );
7446
7466
  }
@@ -7504,7 +7524,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7504
7524
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7505
7525
  if (index === -1) {
7506
7526
  throw new FuelError16(
7507
- ErrorCode15.INVALID_MNEMONIC,
7527
+ ErrorCode16.INVALID_MNEMONIC,
7508
7528
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7509
7529
  );
7510
7530
  }
@@ -7521,7 +7541,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7521
7541
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7522
7542
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7523
7543
  throw new FuelError16(
7524
- ErrorCode15.INVALID_CHECKSUM,
7544
+ ErrorCode16.INVALID_CHECKSUM,
7525
7545
  "Checksum validation failed for the provided mnemonic."
7526
7546
  );
7527
7547
  }
@@ -7536,7 +7556,7 @@ var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7536
7556
  function assertWordList(wordlist) {
7537
7557
  if (wordlist.length !== 2048) {
7538
7558
  throw new FuelError17(
7539
- ErrorCode16.INVALID_WORD_LIST,
7559
+ ErrorCode17.INVALID_WORD_LIST,
7540
7560
  `Expected word list length of 2048, but got ${wordlist.length}.`
7541
7561
  );
7542
7562
  }
@@ -7544,7 +7564,7 @@ function assertWordList(wordlist) {
7544
7564
  function assertEntropy(entropy) {
7545
7565
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7546
7566
  throw new FuelError17(
7547
- ErrorCode16.INVALID_ENTROPY,
7567
+ ErrorCode17.INVALID_ENTROPY,
7548
7568
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7549
7569
  );
7550
7570
  }
@@ -7554,7 +7574,7 @@ function assertMnemonic(words) {
7554
7574
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7555
7575
  ", "
7556
7576
  )}] words, but got ${words.length}.`;
7557
- throw new FuelError17(ErrorCode16.INVALID_MNEMONIC, errorMsg);
7577
+ throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7558
7578
  }
7559
7579
  }
7560
7580
  var Mnemonic = class {
@@ -7673,7 +7693,7 @@ var Mnemonic = class {
7673
7693
  const seedArray = arrayify17(seed);
7674
7694
  if (seedArray.length < 16 || seedArray.length > 64) {
7675
7695
  throw new FuelError17(
7676
- ErrorCode16.INVALID_SEED,
7696
+ ErrorCode17.INVALID_SEED,
7677
7697
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7678
7698
  );
7679
7699
  }
@@ -7750,7 +7770,7 @@ function isValidExtendedKey(extendedKey) {
7750
7770
  function parsePath(path, depth = 0) {
7751
7771
  const components = path.split("/");
7752
7772
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7753
- throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, `invalid path - ${path}`);
7773
+ throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path}`);
7754
7774
  }
7755
7775
  if (components[0] === "m") {
7756
7776
  components.shift();
@@ -7780,7 +7800,7 @@ var HDWallet = class {
7780
7800
  } else {
7781
7801
  if (!config.publicKey) {
7782
7802
  throw new FuelError18(
7783
- ErrorCode17.HD_WALLET_ERROR,
7803
+ ErrorCode18.HD_WALLET_ERROR,
7784
7804
  "Both public and private Key cannot be missing. At least one should be provided."
7785
7805
  );
7786
7806
  }
@@ -7810,7 +7830,7 @@ var HDWallet = class {
7810
7830
  if (index & HARDENED_INDEX) {
7811
7831
  if (!privateKey) {
7812
7832
  throw new FuelError18(
7813
- ErrorCode17.HD_WALLET_ERROR,
7833
+ ErrorCode18.HD_WALLET_ERROR,
7814
7834
  "Cannot derive a hardened index without a private Key."
7815
7835
  );
7816
7836
  }
@@ -7863,7 +7883,7 @@ var HDWallet = class {
7863
7883
  toExtendedKey(isPublic = false, testnet = false) {
7864
7884
  if (this.depth >= 256) {
7865
7885
  throw new FuelError18(
7866
- ErrorCode17.HD_WALLET_ERROR,
7886
+ ErrorCode18.HD_WALLET_ERROR,
7867
7887
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7868
7888
  );
7869
7889
  }
@@ -7894,10 +7914,10 @@ var HDWallet = class {
7894
7914
  const bytes = arrayify18(decoded);
7895
7915
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7896
7916
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7897
- throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7917
+ throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7898
7918
  }
7899
7919
  if (!validChecksum) {
7900
- throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7920
+ throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7901
7921
  }
7902
7922
  const depth = bytes[4];
7903
7923
  const parentFingerprint = hexlify17(bytes.slice(5, 9));
@@ -7906,13 +7926,13 @@ var HDWallet = class {
7906
7926
  const key = bytes.slice(45, 78);
7907
7927
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7908
7928
  throw new FuelError18(
7909
- ErrorCode17.HD_WALLET_ERROR,
7929
+ ErrorCode18.HD_WALLET_ERROR,
7910
7930
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7911
7931
  );
7912
7932
  }
7913
7933
  if (isPublicExtendedKey(bytes)) {
7914
7934
  if (key[0] !== 3) {
7915
- throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Invalid public extended key.");
7935
+ throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
7916
7936
  }
7917
7937
  return new HDWallet({
7918
7938
  publicKey: key,
@@ -7923,7 +7943,7 @@ var HDWallet = class {
7923
7943
  });
7924
7944
  }
7925
7945
  if (key[0] !== 0) {
7926
- throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Invalid private extended key.");
7946
+ throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
7927
7947
  }
7928
7948
  return new HDWallet({
7929
7949
  privateKey: key.slice(1),
@@ -8091,7 +8111,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8091
8111
  // src/wallet-manager/wallet-manager.ts
8092
8112
  import { Address as Address8 } from "@fuel-ts/address";
8093
8113
  import { encrypt, decrypt } from "@fuel-ts/crypto";
8094
- import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
8114
+ import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
8095
8115
  import { EventEmitter } from "events";
8096
8116
 
8097
8117
  // src/wallet-manager/storages/memory-storage.ts
@@ -8114,7 +8134,7 @@ var MemoryStorage = class {
8114
8134
 
8115
8135
  // src/wallet-manager/vaults/mnemonic-vault.ts
8116
8136
  import { Address as Address6 } from "@fuel-ts/address";
8117
- import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
8137
+ import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
8118
8138
  var _secret;
8119
8139
  var MnemonicVault = class {
8120
8140
  constructor(options) {
@@ -8171,7 +8191,7 @@ var MnemonicVault = class {
8171
8191
  numberOfAccounts += 1;
8172
8192
  } while (numberOfAccounts < this.numberOfAccounts);
8173
8193
  throw new FuelError19(
8174
- ErrorCode18.WALLET_MANAGER_ERROR,
8194
+ ErrorCode19.WALLET_MANAGER_ERROR,
8175
8195
  `Account with address '${address}' not found in derived wallets.`
8176
8196
  );
8177
8197
  }
@@ -8185,7 +8205,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8185
8205
 
8186
8206
  // src/wallet-manager/vaults/privatekey-vault.ts
8187
8207
  import { Address as Address7 } from "@fuel-ts/address";
8188
- import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
8208
+ import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
8189
8209
  var _privateKeys;
8190
8210
  var PrivateKeyVault = class {
8191
8211
  /**
@@ -8227,7 +8247,7 @@ var PrivateKeyVault = class {
8227
8247
  );
8228
8248
  if (!privateKey) {
8229
8249
  throw new FuelError20(
8230
- ErrorCode19.WALLET_MANAGER_ERROR,
8250
+ ErrorCode20.WALLET_MANAGER_ERROR,
8231
8251
  `No private key found for address '${address}'.`
8232
8252
  );
8233
8253
  }
@@ -8251,7 +8271,7 @@ var ERROR_MESSAGES = {
8251
8271
  };
8252
8272
  function assert(condition, message) {
8253
8273
  if (!condition) {
8254
- throw new FuelError21(ErrorCode20.WALLET_MANAGER_ERROR, message);
8274
+ throw new FuelError21(ErrorCode21.WALLET_MANAGER_ERROR, message);
8255
8275
  }
8256
8276
  }
8257
8277
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8477,25 +8497,25 @@ deserializeVaults_fn = function(vaults) {
8477
8497
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8478
8498
 
8479
8499
  // src/wallet-manager/types.ts
8480
- import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
8500
+ import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
8481
8501
  var Vault = class {
8482
8502
  constructor(_options) {
8483
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8503
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8484
8504
  }
8485
8505
  serialize() {
8486
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8506
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8487
8507
  }
8488
8508
  getAccounts() {
8489
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8509
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8490
8510
  }
8491
8511
  addAccount() {
8492
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8512
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8493
8513
  }
8494
8514
  exportAccount(_address) {
8495
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8515
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8496
8516
  }
8497
8517
  getWallet(_address) {
8498
- throw new FuelError22(ErrorCode21.NOT_IMPLEMENTED, "Not implemented.");
8518
+ throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8499
8519
  }
8500
8520
  };
8501
8521
  __publicField(Vault, "type");
@@ -8512,7 +8532,7 @@ import {
8512
8532
  } from "@fuel-ts/abi-coder";
8513
8533
  import { Address as Address9 } from "@fuel-ts/address";
8514
8534
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8515
- import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
8535
+ import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
8516
8536
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8517
8537
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8518
8538
 
@@ -8532,27 +8552,37 @@ var getPredicateRoot = (bytecode) => {
8532
8552
  // src/predicate/predicate.ts
8533
8553
  var Predicate = class extends Account {
8534
8554
  bytes;
8535
- predicateData = Uint8Array.from([]);
8536
- predicateArgs = [];
8555
+ predicateDataBytes = Uint8Array.from([]);
8556
+ predicateData = [];
8537
8557
  interface;
8538
8558
  /**
8539
8559
  * Creates an instance of the Predicate class.
8540
8560
  *
8541
- * @param bytes - The bytes of the predicate.
8561
+ * @param bytecode - The bytecode of the predicate.
8562
+ * @param abi - The JSON ABI of the predicate.
8542
8563
  * @param provider - The provider used to interact with the blockchain.
8543
- * @param jsonAbi - The JSON ABI of the predicate.
8564
+ * @param inputData - The predicate input data (optional).
8544
8565
  * @param configurableConstants - Optional configurable constants for the predicate.
8545
8566
  */
8546
- constructor(bytes, provider, jsonAbi, configurableConstants) {
8567
+ constructor({
8568
+ bytecode,
8569
+ abi,
8570
+ provider,
8571
+ inputData,
8572
+ configurableConstants
8573
+ }) {
8547
8574
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
8548
- bytes,
8549
- jsonAbi,
8575
+ bytecode,
8576
+ abi,
8550
8577
  configurableConstants
8551
8578
  );
8552
8579
  const address = Address9.fromB256(getPredicateRoot(predicateBytes));
8553
8580
  super(address, provider);
8554
8581
  this.bytes = predicateBytes;
8555
8582
  this.interface = predicateInterface;
8583
+ if (inputData !== void 0 && inputData.length > 0) {
8584
+ this.predicateData = inputData;
8585
+ }
8556
8586
  }
8557
8587
  /**
8558
8588
  * Populates the transaction data with predicate data.
@@ -8604,18 +8634,8 @@ var Predicate = class extends Account {
8604
8634
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8605
8635
  return super.simulateTransaction(transactionRequest);
8606
8636
  }
8607
- /**
8608
- * Sets data for the predicate.
8609
- *
8610
- * @param args - Arguments for the predicate function.
8611
- * @returns The Predicate instance with updated predicate data.
8612
- */
8613
- setData(...args) {
8614
- this.predicateArgs = args;
8615
- return this;
8616
- }
8617
8637
  getPredicateData(policiesLength) {
8618
- if (!this.predicateArgs.length) {
8638
+ if (!this.predicateData.length) {
8619
8639
  return new Uint8Array();
8620
8640
  }
8621
8641
  const mainFn = this.interface?.functions.main;
@@ -8624,7 +8644,7 @@ var Predicate = class extends Account {
8624
8644
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8625
8645
  });
8626
8646
  const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
8627
- return mainFn?.encodeArguments(this.predicateArgs, OFFSET) || new Uint8Array();
8647
+ return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8628
8648
  }
8629
8649
  /**
8630
8650
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -8641,7 +8661,7 @@ var Predicate = class extends Account {
8641
8661
  abiInterface = new Interface3(jsonAbi);
8642
8662
  if (abiInterface.functions.main === void 0) {
8643
8663
  throw new FuelError23(
8644
- ErrorCode22.ABI_MAIN_METHOD_MISSING,
8664
+ ErrorCode23.ABI_MAIN_METHOD_MISSING,
8645
8665
  'Cannot use ABI without "main" function.'
8646
8666
  );
8647
8667
  }
@@ -8687,7 +8707,7 @@ var Predicate = class extends Account {
8687
8707
  });
8688
8708
  } catch (err) {
8689
8709
  throw new FuelError23(
8690
- ErrorCode22.INVALID_CONFIGURABLE_CONSTANTS,
8710
+ ErrorCode23.INVALID_CONFIGURABLE_CONSTANTS,
8691
8711
  `Error setting configurable constants: ${err.message}.`
8692
8712
  );
8693
8713
  }
@@ -8696,7 +8716,7 @@ var Predicate = class extends Account {
8696
8716
  };
8697
8717
 
8698
8718
  // src/connectors/fuel.ts
8699
- import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
8719
+ import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8700
8720
 
8701
8721
  // src/connectors/fuel-connector.ts
8702
8722
  import { EventEmitter as EventEmitter2 } from "events";
@@ -9317,7 +9337,7 @@ var _Fuel = class extends FuelConnector {
9317
9337
  const currentNetwork = await this.currentNetwork();
9318
9338
  provider = await Provider.create(currentNetwork.url);
9319
9339
  } else {
9320
- throw new FuelError24(ErrorCode23.INVALID_PROVIDER, "Provider is not valid.");
9340
+ throw new FuelError24(ErrorCode24.INVALID_PROVIDER, "Provider is not valid.");
9321
9341
  }
9322
9342
  return provider;
9323
9343
  }
@@ -9411,10 +9431,6 @@ export {
9411
9431
  english,
9412
9432
  extractBurnedAssetsFromReceipts,
9413
9433
  extractMintedAssetsFromReceipts,
9414
- fromDateToTai64,
9415
- fromTai64ToDate,
9416
- fromTai64ToUnix,
9417
- fromUnixToTai64,
9418
9434
  gasUsedByInputs,
9419
9435
  getAssetEth,
9420
9436
  getAssetFuel,