@fuel-ts/account 0.99.0 → 0.100.1

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 (63) hide show
  1. package/dist/account.d.ts +9 -4
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts +7 -6
  4. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  5. package/dist/connectors/types/data-type.d.ts +8 -1
  6. package/dist/connectors/types/data-type.d.ts.map +1 -1
  7. package/dist/index.global.js +4164 -3454
  8. package/dist/index.global.js.map +1 -1
  9. package/dist/index.js +1125 -691
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +1035 -611
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/mnemonic/mnemonic.d.ts +1 -1
  14. package/dist/providers/__generated__/operations.d.ts +98 -3
  15. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  16. package/dist/providers/coin-quantity.d.ts.map +1 -1
  17. package/dist/providers/message.d.ts.map +1 -1
  18. package/dist/providers/provider.d.ts +77 -11
  19. package/dist/providers/provider.d.ts.map +1 -1
  20. package/dist/providers/resource-cache.d.ts +6 -4
  21. package/dist/providers/resource-cache.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/helpers.d.ts +10 -1
  23. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/transaction-request.d.ts +29 -1
  25. package/dist/providers/transaction-request/transaction-request.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-from-serialized.d.ts +7 -0
  29. package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts.map +1 -0
  30. package/dist/providers/transaction-summary/call.d.ts +8 -2
  31. package/dist/providers/transaction-summary/call.d.ts.map +1 -1
  32. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +1 -1
  33. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  34. package/dist/providers/transaction-summary/index.d.ts +1 -0
  35. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  36. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  37. package/dist/providers/transaction-summary/receipt.d.ts +3 -2
  38. package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/types.d.ts +5 -3
  40. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  41. package/dist/providers/utils/handle-gql-error-message.d.ts +0 -4
  42. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  43. package/dist/providers/utils/helpers.d.ts +14 -0
  44. package/dist/providers/utils/helpers.d.ts.map +1 -0
  45. package/dist/providers/utils/index.d.ts +1 -0
  46. package/dist/providers/utils/index.d.ts.map +1 -1
  47. package/dist/providers/utils/receipts.d.ts +4 -3
  48. package/dist/providers/utils/receipts.d.ts.map +1 -1
  49. package/dist/providers/utils/serialization.d.ts +35 -0
  50. package/dist/providers/utils/serialization.d.ts.map +1 -0
  51. package/dist/signer/signer.d.ts +1 -1
  52. package/dist/test-utils.global.js +3879 -3184
  53. package/dist/test-utils.global.js.map +1 -1
  54. package/dist/test-utils.js +1002 -607
  55. package/dist/test-utils.js.map +1 -1
  56. package/dist/test-utils.mjs +922 -527
  57. package/dist/test-utils.mjs.map +1 -1
  58. package/dist/utils/formatTransferToContractScriptData.d.ts +3 -3
  59. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  60. package/dist/utils/predicate-script-loader-instructions.d.ts +2 -2
  61. package/dist/wallet/base-wallet-unlocked.d.ts +2 -1
  62. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  63. package/package.json +21 -21
@@ -435,10 +435,9 @@ var coinQuantityfy = (coinQuantityLike) => {
435
435
  assetId = coinQuantityLike.assetId;
436
436
  max = coinQuantityLike.max ?? void 0;
437
437
  }
438
- const bnAmount = (0, import_math2.bn)(amount);
439
438
  return {
440
439
  assetId: (0, import_utils3.hexlify)(assetId),
441
- amount: bnAmount.lt(1) ? (0, import_math2.bn)(1) : bnAmount,
440
+ amount: (0, import_math2.bn)(amount),
442
441
  max: max ? (0, import_math2.bn)(max) : void 0
443
442
  };
444
443
  };
@@ -456,16 +455,26 @@ var addAmountToCoinQuantities = (params) => {
456
455
 
457
456
  // src/providers/provider.ts
458
457
  var import_address4 = require("@fuel-ts/address");
459
- var import_errors20 = require("@fuel-ts/errors");
458
+ var import_errors21 = require("@fuel-ts/errors");
460
459
  var import_math19 = require("@fuel-ts/math");
461
- var import_transactions22 = require("@fuel-ts/transactions");
460
+ var import_transactions23 = require("@fuel-ts/transactions");
462
461
  var import_utils30 = require("@fuel-ts/utils");
463
462
  var import_versions = require("@fuel-ts/versions");
464
- var import_utils31 = require("@noble/curves/abstract/utils");
465
463
  var import_graphql_request = require("graphql-request");
466
464
  var import_graphql_tag2 = __toESM(require("graphql-tag"));
467
465
  var import_ramda8 = require("ramda");
468
466
 
467
+ // src/connectors/utils/promises.ts
468
+ var import_errors2 = require("@fuel-ts/errors");
469
+ function deferPromise() {
470
+ const defer = {};
471
+ defer.promise = new Promise((resolve, reject) => {
472
+ defer.reject = reject;
473
+ defer.resolve = resolve;
474
+ });
475
+ return defer;
476
+ }
477
+
469
478
  // src/providers/__generated__/operations.ts
470
479
  var import_graphql_tag = __toESM(require("graphql-tag"));
471
480
  var SubmittedStatusFragmentDoc = import_graphql_tag.default`
@@ -1073,6 +1082,16 @@ var EstimatePredicatesDocument = import_graphql_tag.default`
1073
1082
  }
1074
1083
  }
1075
1084
  ${TransactionEstimatePredicatesFragmentDoc}`;
1085
+ var EstimatePredicatesAndGasPriceDocument = import_graphql_tag.default`
1086
+ query estimatePredicatesAndGasPrice($encodedTransaction: HexString!, $blockHorizon: U32!) {
1087
+ estimatePredicates(tx: $encodedTransaction) {
1088
+ ...transactionEstimatePredicatesFragment
1089
+ }
1090
+ estimateGasPrice(blockHorizon: $blockHorizon) {
1091
+ gasPrice
1092
+ }
1093
+ }
1094
+ ${TransactionEstimatePredicatesFragmentDoc}`;
1076
1095
  var GetLatestBlockDocument = import_graphql_tag.default`
1077
1096
  query getLatestBlock {
1078
1097
  chain {
@@ -1188,6 +1207,13 @@ var GetBalanceDocument = import_graphql_tag.default`
1188
1207
  }
1189
1208
  }
1190
1209
  `;
1210
+ var GetBalanceV2Document = import_graphql_tag.default`
1211
+ query getBalanceV2($owner: Address!, $assetId: AssetId!) {
1212
+ balance(owner: $owner, assetId: $assetId) {
1213
+ amountU128
1214
+ }
1215
+ }
1216
+ `;
1191
1217
  var GetLatestGasPriceDocument = import_graphql_tag.default`
1192
1218
  query getLatestGasPrice {
1193
1219
  latestGasPrice {
@@ -1220,6 +1246,27 @@ var GetBalancesDocument = import_graphql_tag.default`
1220
1246
  }
1221
1247
  }
1222
1248
  `;
1249
+ var GetBalancesV2Document = import_graphql_tag.default`
1250
+ query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
1251
+ balances(
1252
+ filter: $filter
1253
+ after: $after
1254
+ before: $before
1255
+ first: $first
1256
+ last: $last
1257
+ ) {
1258
+ pageInfo {
1259
+ ...pageInfoFragment
1260
+ }
1261
+ edges {
1262
+ node {
1263
+ assetId
1264
+ amountU128
1265
+ }
1266
+ }
1267
+ }
1268
+ }
1269
+ ${PageInfoFragmentDoc}`;
1223
1270
  var GetMessagesDocument = import_graphql_tag.default`
1224
1271
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
1225
1272
  messages(
@@ -1274,6 +1321,15 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1274
1321
  }
1275
1322
  }
1276
1323
  ${RelayedTransactionStatusFragmentDoc}`;
1324
+ var GetAssetDetailsDocument = import_graphql_tag.default`
1325
+ query getAssetDetails($assetId: AssetId!) {
1326
+ assetDetails(id: $assetId) {
1327
+ subId
1328
+ contractId
1329
+ totalSupply
1330
+ }
1331
+ }
1332
+ `;
1277
1333
  var DryRunDocument = import_graphql_tag.default`
1278
1334
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
1279
1335
  dryRun(
@@ -1374,6 +1430,9 @@ function getSdk(requester) {
1374
1430
  estimatePredicates(variables, options) {
1375
1431
  return requester(EstimatePredicatesDocument, variables, options);
1376
1432
  },
1433
+ estimatePredicatesAndGasPrice(variables, options) {
1434
+ return requester(EstimatePredicatesAndGasPriceDocument, variables, options);
1435
+ },
1377
1436
  getLatestBlock(variables, options) {
1378
1437
  return requester(GetLatestBlockDocument, variables, options);
1379
1438
  },
@@ -1407,6 +1466,9 @@ function getSdk(requester) {
1407
1466
  getBalance(variables, options) {
1408
1467
  return requester(GetBalanceDocument, variables, options);
1409
1468
  },
1469
+ getBalanceV2(variables, options) {
1470
+ return requester(GetBalanceV2Document, variables, options);
1471
+ },
1410
1472
  getLatestGasPrice(variables, options) {
1411
1473
  return requester(GetLatestGasPriceDocument, variables, options);
1412
1474
  },
@@ -1416,6 +1478,9 @@ function getSdk(requester) {
1416
1478
  getBalances(variables, options) {
1417
1479
  return requester(GetBalancesDocument, variables, options);
1418
1480
  },
1481
+ getBalancesV2(variables, options) {
1482
+ return requester(GetBalancesV2Document, variables, options);
1483
+ },
1419
1484
  getMessages(variables, options) {
1420
1485
  return requester(GetMessagesDocument, variables, options);
1421
1486
  },
@@ -1431,6 +1496,9 @@ function getSdk(requester) {
1431
1496
  getRelayedTransactionStatus(variables, options) {
1432
1497
  return requester(GetRelayedTransactionStatusDocument, variables, options);
1433
1498
  },
1499
+ getAssetDetails(variables, options) {
1500
+ return requester(GetAssetDetailsDocument, variables, options);
1501
+ },
1434
1502
  dryRun(variables, options) {
1435
1503
  return requester(DryRunDocument, variables, options);
1436
1504
  },
@@ -1459,36 +1527,35 @@ function getSdk(requester) {
1459
1527
  }
1460
1528
 
1461
1529
  // src/providers/fuel-graphql-subscriber.ts
1462
- var import_errors3 = require("@fuel-ts/errors");
1530
+ var import_errors4 = require("@fuel-ts/errors");
1463
1531
  var import_graphql = require("graphql");
1464
1532
 
1465
1533
  // src/providers/utils/handle-gql-error-message.ts
1466
- var import_errors2 = require("@fuel-ts/errors");
1534
+ var import_errors3 = require("@fuel-ts/errors");
1467
1535
  var mapGqlErrorMessage = (error) => {
1468
- switch (error.message) {
1469
- case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
1470
- return new import_errors2.FuelError(
1471
- import_errors2.ErrorCode.NOT_ENOUGH_FUNDS,
1472
- `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
1473
- {},
1474
- error
1475
- );
1476
- case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
1477
- return new import_errors2.FuelError(
1478
- import_errors2.ErrorCode.MAX_COINS_REACHED,
1479
- "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
1480
- {},
1481
- error
1482
- );
1483
- default:
1484
- return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1536
+ if (new RegExp("the target cannot be met due to no coins available or exceeding the \\d+ coin limit." /* NOT_ENOUGH_COINS_MAX_COINS */).test(error.message)) {
1537
+ return new import_errors3.FuelError(
1538
+ import_errors3.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
1539
+ `Insufficient funds or too many small value coins. Consider combining UTXOs.`,
1540
+ {},
1541
+ error
1542
+ );
1485
1543
  }
1544
+ if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
1545
+ return new import_errors3.FuelError(
1546
+ import_errors3.ErrorCode.ASSET_NOT_FOUND,
1547
+ `Asset not found for given asset id.`,
1548
+ {},
1549
+ error
1550
+ );
1551
+ }
1552
+ return new import_errors3.FuelError(import_errors3.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1486
1553
  };
1487
1554
  var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
1488
1555
  if (!incompatibleNodeVersionMessage) {
1489
1556
  return error;
1490
1557
  }
1491
- return new import_errors2.FuelError(
1558
+ return new import_errors3.FuelError(
1492
1559
  error.code,
1493
1560
  `${error.message}
1494
1561
 
@@ -1507,7 +1574,7 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
1507
1574
  }
1508
1575
  const errorMessage = mappedErrors.map((err) => err.message).join("\n");
1509
1576
  throw mapGqlErrorWithIncompatibleNodeVersion(
1510
- new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1577
+ new import_errors3.FuelError(import_errors3.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1511
1578
  incompatibleNodeVersionMessage
1512
1579
  );
1513
1580
  };
@@ -1558,8 +1625,8 @@ var _FuelGraphqlSubscriber = class {
1558
1625
  try {
1559
1626
  this.events.push(JSON.parse(match.replace(/^data:/, "")));
1560
1627
  } catch (e) {
1561
- throw new import_errors3.FuelError(
1562
- import_errors3.ErrorCode.STREAM_PARSING_ERROR,
1628
+ throw new import_errors4.FuelError(
1629
+ import_errors4.ErrorCode.STREAM_PARSING_ERROR,
1563
1630
  `Error while parsing stream data response: ${text}`
1564
1631
  );
1565
1632
  }
@@ -1582,66 +1649,8 @@ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
1582
1649
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1583
1650
 
1584
1651
  // src/providers/resource-cache.ts
1585
- var import_errors4 = require("@fuel-ts/errors");
1586
- var import_utils4 = require("@fuel-ts/utils");
1587
- var cache = /* @__PURE__ */ new Map();
1588
- var ResourceCache = class {
1589
- ttl;
1590
- constructor(ttl) {
1591
- this.ttl = ttl;
1592
- if (typeof ttl !== "number" || this.ttl <= 0) {
1593
- throw new import_errors4.FuelError(
1594
- import_errors4.ErrorCode.INVALID_TTL,
1595
- `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
1596
- );
1597
- }
1598
- }
1599
- // Add resources to the cache
1600
- set(transactionId, resources) {
1601
- const currentTime = Date.now();
1602
- const existingResources = cache.get(transactionId) || {
1603
- utxos: /* @__PURE__ */ new Set(),
1604
- messages: /* @__PURE__ */ new Set(),
1605
- timestamp: currentTime
1606
- };
1607
- resources.utxos.forEach((utxo) => existingResources.utxos.add((0, import_utils4.hexlify)(utxo)));
1608
- resources.messages.forEach((message) => existingResources.messages.add((0, import_utils4.hexlify)(message)));
1609
- cache.set(transactionId, existingResources);
1610
- }
1611
- // Remove resources from the cache for a given transaction ID
1612
- unset(transactionId) {
1613
- cache.delete(transactionId);
1614
- }
1615
- // Get all cached resources and remove expired ones
1616
- getActiveData() {
1617
- const allResources = { utxos: [], messages: [] };
1618
- const currentTime = Date.now();
1619
- cache.forEach((resource, transactionId) => {
1620
- if (currentTime - resource.timestamp < this.ttl) {
1621
- allResources.utxos.push(...resource.utxos);
1622
- allResources.messages.push(...resource.messages);
1623
- } else {
1624
- cache.delete(transactionId);
1625
- }
1626
- });
1627
- return allResources;
1628
- }
1629
- // Check if a UTXO ID or message nonce is already cached and not expired
1630
- isCached(key) {
1631
- const currentTime = Date.now();
1632
- for (const [transactionId, resourceData] of cache.entries()) {
1633
- if (currentTime - resourceData.timestamp > this.ttl) {
1634
- cache.delete(transactionId);
1635
- } else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
1636
- return true;
1637
- }
1638
- }
1639
- return false;
1640
- }
1641
- clear() {
1642
- cache.clear();
1643
- }
1644
- };
1652
+ var import_errors15 = require("@fuel-ts/errors");
1653
+ var import_utils23 = require("@fuel-ts/utils");
1645
1654
 
1646
1655
  // src/providers/transaction-request/input.ts
1647
1656
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
@@ -1649,30 +1658,30 @@ var import_configs = require("@fuel-ts/address/configs");
1649
1658
  var import_errors5 = require("@fuel-ts/errors");
1650
1659
  var import_math3 = require("@fuel-ts/math");
1651
1660
  var import_transactions = require("@fuel-ts/transactions");
1652
- var import_utils5 = require("@fuel-ts/utils");
1661
+ var import_utils4 = require("@fuel-ts/utils");
1653
1662
  var inputify = (value) => {
1654
1663
  const { type } = value;
1655
1664
  switch (value.type) {
1656
1665
  case import_transactions.InputType.Coin: {
1657
- const predicate = (0, import_utils5.arrayify)(value.predicate ?? "0x");
1658
- const predicateData = (0, import_utils5.arrayify)(value.predicateData ?? "0x");
1666
+ const predicate = (0, import_utils4.arrayify)(value.predicate ?? "0x");
1667
+ const predicateData = (0, import_utils4.arrayify)(value.predicateData ?? "0x");
1659
1668
  return {
1660
1669
  type: import_transactions.InputType.Coin,
1661
- txID: (0, import_utils5.hexlify)((0, import_utils5.arrayify)(value.id).slice(0, import_abi_coder2.BYTES_32)),
1662
- outputIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.id).slice(import_abi_coder2.BYTES_32, import_abi_coder2.UTXO_ID_LEN)),
1663
- owner: (0, import_utils5.hexlify)(value.owner),
1670
+ txID: (0, import_utils4.hexlify)((0, import_utils4.arrayify)(value.id).slice(0, import_abi_coder2.BYTES_32)),
1671
+ outputIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.id).slice(import_abi_coder2.BYTES_32, import_abi_coder2.UTXO_ID_LEN)),
1672
+ owner: (0, import_utils4.hexlify)(value.owner),
1664
1673
  amount: (0, import_math3.bn)(value.amount),
1665
- assetId: (0, import_utils5.hexlify)(value.assetId),
1674
+ assetId: (0, import_utils4.hexlify)(value.assetId),
1666
1675
  txPointer: {
1667
- blockHeight: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(0, 8)),
1668
- txIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(8, 16))
1676
+ blockHeight: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(0, 8)),
1677
+ txIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(8, 16))
1669
1678
  },
1670
1679
  witnessIndex: value.witnessIndex,
1671
1680
  predicateGasUsed: (0, import_math3.bn)(value.predicateGasUsed),
1672
1681
  predicateLength: (0, import_math3.bn)(predicate.length),
1673
1682
  predicateDataLength: (0, import_math3.bn)(predicateData.length),
1674
- predicate: (0, import_utils5.hexlify)(predicate),
1675
- predicateData: (0, import_utils5.hexlify)(predicateData)
1683
+ predicate: (0, import_utils4.hexlify)(predicate),
1684
+ predicateData: (0, import_utils4.hexlify)(predicateData)
1676
1685
  };
1677
1686
  }
1678
1687
  case import_transactions.InputType.Contract: {
@@ -1683,29 +1692,29 @@ var inputify = (value) => {
1683
1692
  balanceRoot: import_configs.ZeroBytes32,
1684
1693
  stateRoot: import_configs.ZeroBytes32,
1685
1694
  txPointer: {
1686
- blockHeight: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(0, 8)),
1687
- txIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(8, 16))
1695
+ blockHeight: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(0, 8)),
1696
+ txIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(8, 16))
1688
1697
  },
1689
- contractID: (0, import_utils5.hexlify)(value.contractId)
1698
+ contractID: (0, import_utils4.hexlify)(value.contractId)
1690
1699
  };
1691
1700
  }
1692
1701
  case import_transactions.InputType.Message: {
1693
- const predicate = (0, import_utils5.arrayify)(value.predicate ?? "0x");
1694
- const predicateData = (0, import_utils5.arrayify)(value.predicateData ?? "0x");
1695
- const data = (0, import_utils5.arrayify)(value.data ?? "0x");
1702
+ const predicate = (0, import_utils4.arrayify)(value.predicate ?? "0x");
1703
+ const predicateData = (0, import_utils4.arrayify)(value.predicateData ?? "0x");
1704
+ const data = (0, import_utils4.arrayify)(value.data ?? "0x");
1696
1705
  return {
1697
1706
  type: import_transactions.InputType.Message,
1698
- sender: (0, import_utils5.hexlify)(value.sender),
1699
- recipient: (0, import_utils5.hexlify)(value.recipient),
1707
+ sender: (0, import_utils4.hexlify)(value.sender),
1708
+ recipient: (0, import_utils4.hexlify)(value.recipient),
1700
1709
  amount: (0, import_math3.bn)(value.amount),
1701
- nonce: (0, import_utils5.hexlify)(value.nonce),
1710
+ nonce: (0, import_utils4.hexlify)(value.nonce),
1702
1711
  witnessIndex: value.witnessIndex,
1703
1712
  predicateGasUsed: (0, import_math3.bn)(value.predicateGasUsed),
1704
1713
  predicateLength: (0, import_math3.bn)(predicate.length),
1705
1714
  predicateDataLength: (0, import_math3.bn)(predicateData.length),
1706
- predicate: (0, import_utils5.hexlify)(predicate),
1707
- predicateData: (0, import_utils5.hexlify)(predicateData),
1708
- data: (0, import_utils5.hexlify)(data),
1715
+ predicate: (0, import_utils4.hexlify)(predicate),
1716
+ predicateData: (0, import_utils4.hexlify)(predicateData),
1717
+ data: (0, import_utils4.hexlify)(data),
1709
1718
  dataLength: data.length
1710
1719
  };
1711
1720
  }
@@ -1723,16 +1732,16 @@ var import_configs2 = require("@fuel-ts/address/configs");
1723
1732
  var import_errors6 = require("@fuel-ts/errors");
1724
1733
  var import_math4 = require("@fuel-ts/math");
1725
1734
  var import_transactions2 = require("@fuel-ts/transactions");
1726
- var import_utils6 = require("@fuel-ts/utils");
1735
+ var import_utils5 = require("@fuel-ts/utils");
1727
1736
  var outputify = (value) => {
1728
1737
  const { type } = value;
1729
1738
  switch (type) {
1730
1739
  case import_transactions2.OutputType.Coin: {
1731
1740
  return {
1732
1741
  type: import_transactions2.OutputType.Coin,
1733
- to: (0, import_utils6.hexlify)(value.to),
1742
+ to: (0, import_utils5.hexlify)(value.to),
1734
1743
  amount: (0, import_math4.bn)(value.amount),
1735
- assetId: (0, import_utils6.hexlify)(value.assetId)
1744
+ assetId: (0, import_utils5.hexlify)(value.assetId)
1736
1745
  };
1737
1746
  }
1738
1747
  case import_transactions2.OutputType.Contract: {
@@ -1746,9 +1755,9 @@ var outputify = (value) => {
1746
1755
  case import_transactions2.OutputType.Change: {
1747
1756
  return {
1748
1757
  type: import_transactions2.OutputType.Change,
1749
- to: (0, import_utils6.hexlify)(value.to),
1758
+ to: (0, import_utils5.hexlify)(value.to),
1750
1759
  amount: (0, import_math4.bn)(0),
1751
- assetId: (0, import_utils6.hexlify)(value.assetId)
1760
+ assetId: (0, import_utils5.hexlify)(value.assetId)
1752
1761
  };
1753
1762
  }
1754
1763
  case import_transactions2.OutputType.Variable: {
@@ -1762,8 +1771,8 @@ var outputify = (value) => {
1762
1771
  case import_transactions2.OutputType.ContractCreated: {
1763
1772
  return {
1764
1773
  type: import_transactions2.OutputType.ContractCreated,
1765
- contractId: (0, import_utils6.hexlify)(value.contractId),
1766
- stateRoot: (0, import_utils6.hexlify)(value.stateRoot)
1774
+ contractId: (0, import_utils5.hexlify)(value.contractId),
1775
+ stateRoot: (0, import_utils5.hexlify)(value.stateRoot)
1767
1776
  };
1768
1777
  }
1769
1778
  default: {
@@ -1782,7 +1791,7 @@ var import_configs6 = require("@fuel-ts/address/configs");
1782
1791
  var import_crypto3 = require("@fuel-ts/crypto");
1783
1792
  var import_errors11 = require("@fuel-ts/errors");
1784
1793
  var import_math9 = require("@fuel-ts/math");
1785
- var import_transactions7 = require("@fuel-ts/transactions");
1794
+ var import_transactions8 = require("@fuel-ts/transactions");
1786
1795
  var import_utils11 = require("@fuel-ts/utils");
1787
1796
 
1788
1797
  // src/providers/message.ts
@@ -1792,31 +1801,157 @@ var isMessageCoin = (message) => !("data" in message);
1792
1801
  var isCoin = (resource) => "id" in resource;
1793
1802
 
1794
1803
  // src/providers/utils/receipts.ts
1804
+ var import_transactions4 = require("@fuel-ts/transactions");
1805
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1806
+
1807
+ // src/providers/utils/serialization.ts
1795
1808
  var import_configs3 = require("@fuel-ts/address/configs");
1796
1809
  var import_errors7 = require("@fuel-ts/errors");
1797
1810
  var import_math5 = require("@fuel-ts/math");
1798
1811
  var import_transactions3 = require("@fuel-ts/transactions");
1799
- var import_configs4 = require("@fuel-ts/transactions/configs");
1800
- var import_utils7 = require("@fuel-ts/utils");
1801
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1802
- var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1803
- var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1804
- (memo, receipt) => {
1805
- if (doesReceiptHaveMissingOutputVariables(receipt)) {
1806
- memo.missingOutputVariables.push(receipt);
1812
+ var import_utils6 = require("@fuel-ts/utils");
1813
+ var deserializeChain = (chain) => {
1814
+ const { name, daHeight, consensusParameters } = chain;
1815
+ const {
1816
+ contractParams,
1817
+ feeParams,
1818
+ predicateParams,
1819
+ scriptParams,
1820
+ txParams,
1821
+ gasCosts,
1822
+ baseAssetId,
1823
+ chainId,
1824
+ version
1825
+ } = consensusParameters;
1826
+ return {
1827
+ name,
1828
+ baseChainHeight: (0, import_math5.bn)(daHeight),
1829
+ consensusParameters: {
1830
+ version,
1831
+ chainId: (0, import_math5.bn)(chainId),
1832
+ baseAssetId,
1833
+ feeParameters: {
1834
+ version: feeParams.version,
1835
+ gasPerByte: (0, import_math5.bn)(feeParams.gasPerByte),
1836
+ gasPriceFactor: (0, import_math5.bn)(feeParams.gasPriceFactor)
1837
+ },
1838
+ contractParameters: {
1839
+ version: contractParams.version,
1840
+ contractMaxSize: (0, import_math5.bn)(contractParams.contractMaxSize),
1841
+ maxStorageSlots: (0, import_math5.bn)(contractParams.maxStorageSlots)
1842
+ },
1843
+ txParameters: {
1844
+ version: txParams.version,
1845
+ maxInputs: (0, import_math5.bn)(txParams.maxInputs),
1846
+ maxOutputs: (0, import_math5.bn)(txParams.maxOutputs),
1847
+ maxWitnesses: (0, import_math5.bn)(txParams.maxWitnesses),
1848
+ maxGasPerTx: (0, import_math5.bn)(txParams.maxGasPerTx),
1849
+ maxSize: (0, import_math5.bn)(txParams.maxSize),
1850
+ maxBytecodeSubsections: (0, import_math5.bn)(txParams.maxBytecodeSubsections)
1851
+ },
1852
+ predicateParameters: {
1853
+ version: predicateParams.version,
1854
+ maxPredicateLength: (0, import_math5.bn)(predicateParams.maxPredicateLength),
1855
+ maxPredicateDataLength: (0, import_math5.bn)(predicateParams.maxPredicateDataLength),
1856
+ maxGasPerPredicate: (0, import_math5.bn)(predicateParams.maxGasPerPredicate),
1857
+ maxMessageDataLength: (0, import_math5.bn)(predicateParams.maxMessageDataLength)
1858
+ },
1859
+ scriptParameters: {
1860
+ version: scriptParams.version,
1861
+ maxScriptLength: (0, import_math5.bn)(scriptParams.maxScriptLength),
1862
+ maxScriptDataLength: (0, import_math5.bn)(scriptParams.maxScriptDataLength)
1863
+ },
1864
+ gasCosts
1807
1865
  }
1808
- if (doesReceiptHaveMissingContractId(receipt)) {
1809
- memo.missingOutputContractIds.push(receipt);
1866
+ };
1867
+ };
1868
+ var serializeChain = (chain) => {
1869
+ const { name, baseChainHeight, consensusParameters } = chain;
1870
+ const {
1871
+ contractParameters,
1872
+ feeParameters,
1873
+ predicateParameters,
1874
+ scriptParameters,
1875
+ txParameters,
1876
+ gasCosts,
1877
+ baseAssetId,
1878
+ chainId,
1879
+ version
1880
+ } = consensusParameters;
1881
+ return {
1882
+ name,
1883
+ daHeight: baseChainHeight.toString(),
1884
+ consensusParameters: {
1885
+ version,
1886
+ chainId: chainId.toString(),
1887
+ baseAssetId,
1888
+ feeParams: {
1889
+ version: feeParameters.version,
1890
+ gasPerByte: feeParameters.gasPerByte.toString(),
1891
+ gasPriceFactor: feeParameters.gasPriceFactor.toString()
1892
+ },
1893
+ contractParams: {
1894
+ version: contractParameters.version,
1895
+ contractMaxSize: contractParameters.contractMaxSize.toString(),
1896
+ maxStorageSlots: contractParameters.maxStorageSlots.toString()
1897
+ },
1898
+ txParams: {
1899
+ version: txParameters.version,
1900
+ maxInputs: txParameters.maxInputs.toString(),
1901
+ maxOutputs: txParameters.maxOutputs.toString(),
1902
+ maxWitnesses: txParameters.maxWitnesses.toString(),
1903
+ maxGasPerTx: txParameters.maxGasPerTx.toString(),
1904
+ maxSize: txParameters.maxSize.toString(),
1905
+ maxBytecodeSubsections: txParameters.maxBytecodeSubsections.toString()
1906
+ },
1907
+ predicateParams: {
1908
+ version: predicateParameters.version,
1909
+ maxPredicateLength: predicateParameters.maxPredicateLength.toString(),
1910
+ maxPredicateDataLength: predicateParameters.maxPredicateDataLength.toString(),
1911
+ maxGasPerPredicate: predicateParameters.maxGasPerPredicate.toString(),
1912
+ maxMessageDataLength: predicateParameters.maxMessageDataLength.toString()
1913
+ },
1914
+ scriptParams: {
1915
+ version: scriptParameters.version,
1916
+ maxScriptLength: scriptParameters.maxScriptLength.toString(),
1917
+ maxScriptDataLength: scriptParameters.maxScriptDataLength.toString()
1918
+ },
1919
+ gasCosts
1810
1920
  }
1811
- return memo;
1812
- },
1813
- {
1814
- missingOutputVariables: [],
1815
- missingOutputContractIds: []
1816
- }
1817
- );
1921
+ };
1922
+ };
1923
+ var deserializeNodeInfo = (nodeInfo) => {
1924
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
1925
+ return {
1926
+ maxDepth: (0, import_math5.bn)(maxDepth),
1927
+ maxTx: (0, import_math5.bn)(maxTx),
1928
+ nodeVersion,
1929
+ utxoValidation,
1930
+ vmBacktrace
1931
+ };
1932
+ };
1933
+ var serializeNodeInfo = (nodeInfo) => {
1934
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
1935
+ return {
1936
+ maxDepth: maxDepth.toString(),
1937
+ maxTx: maxTx.toString(),
1938
+ nodeVersion,
1939
+ utxoValidation,
1940
+ vmBacktrace
1941
+ };
1942
+ };
1943
+ var deserializeProviderCache = (cache2) => ({
1944
+ consensusParametersTimestamp: cache2.consensusParametersTimestamp,
1945
+ chain: deserializeChain(cache2.chain),
1946
+ nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
1947
+ });
1948
+ var serializeProviderCache = async (provider) => ({
1949
+ consensusParametersTimestamp: provider.consensusParametersTimestamp,
1950
+ chain: serializeChain(await provider.getChain()),
1951
+ nodeInfo: serializeNodeInfo(await provider.getNode())
1952
+ });
1818
1953
  var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1819
- function assembleReceiptByType(receipt) {
1954
+ var deserializeReceipt = (receipt) => {
1820
1955
  const { receiptType } = receipt;
1821
1956
  switch (receiptType) {
1822
1957
  case "CALL" /* Call */: {
@@ -1952,7 +2087,7 @@ function assembleReceiptByType(receipt) {
1952
2087
  const recipient = hexOrZero(receipt.recipient);
1953
2088
  const nonce = hexOrZero(receipt.nonce);
1954
2089
  const amount = (0, import_math5.bn)(receipt.amount);
1955
- const data = receipt.data ? (0, import_utils7.arrayify)(receipt.data) : Uint8Array.from([]);
2090
+ const data = receipt.data ? (0, import_utils6.arrayify)(receipt.data) : Uint8Array.from([]);
1956
2091
  const digest = hexOrZero(receipt.digest);
1957
2092
  const len = (0, import_math5.bn)(receipt.len).toNumber();
1958
2093
  const messageId = import_transactions3.InputMessageCoder.getMessageId({
@@ -1960,7 +2095,7 @@ function assembleReceiptByType(receipt) {
1960
2095
  recipient,
1961
2096
  nonce,
1962
2097
  amount,
1963
- data: (0, import_utils7.hexlify)(data)
2098
+ data: (0, import_utils6.hexlify)(data)
1964
2099
  });
1965
2100
  const receiptMessageOut = {
1966
2101
  type: import_transactions3.ReceiptType.MessageOut,
@@ -2008,18 +2143,37 @@ function assembleReceiptByType(receipt) {
2008
2143
  default:
2009
2144
  throw new import_errors7.FuelError(import_errors7.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2010
2145
  }
2011
- }
2146
+ };
2147
+
2148
+ // src/providers/utils/receipts.ts
2149
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
2150
+ var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
2151
+ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
2152
+ (memo, receipt) => {
2153
+ if (doesReceiptHaveMissingOutputVariables(receipt)) {
2154
+ memo.missingOutputVariables.push(receipt);
2155
+ }
2156
+ if (doesReceiptHaveMissingContractId(receipt)) {
2157
+ memo.missingOutputContractIds.push(receipt);
2158
+ }
2159
+ return memo;
2160
+ },
2161
+ {
2162
+ missingOutputVariables: [],
2163
+ missingOutputContractIds: []
2164
+ }
2165
+ );
2012
2166
 
2013
2167
  // src/providers/utils/block-explorer.ts
2014
2168
  var import_errors8 = require("@fuel-ts/errors");
2015
2169
 
2016
2170
  // src/providers/utils/gas.ts
2017
2171
  var import_math6 = require("@fuel-ts/math");
2018
- var import_transactions4 = require("@fuel-ts/transactions");
2019
- var import_utils8 = require("@fuel-ts/utils");
2172
+ var import_transactions5 = require("@fuel-ts/transactions");
2173
+ var import_utils7 = require("@fuel-ts/utils");
2020
2174
  var getGasUsedFromReceipts = (receipts) => {
2021
2175
  const scriptResult = receipts.filter(
2022
- (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
2176
+ (receipt) => receipt.type === import_transactions5.ReceiptType.ScriptResult
2023
2177
  );
2024
2178
  const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), (0, import_math6.bn)(0));
2025
2179
  return gasUsed;
@@ -2053,7 +2207,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
2053
2207
  const totalGas = chargeableInputs.reduce((total, input) => {
2054
2208
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
2055
2209
  return total.add(
2056
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils8.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math6.bn)(input.predicateGasUsed))
2210
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils7.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math6.bn)(input.predicateGasUsed))
2057
2211
  );
2058
2212
  }
2059
2213
  return total.add(gasCosts.ecr1);
@@ -2152,13 +2306,13 @@ var calculateGasFee = (params) => {
2152
2306
  };
2153
2307
 
2154
2308
  // src/providers/utils/json.ts
2155
- var import_utils9 = require("@fuel-ts/utils");
2309
+ var import_utils8 = require("@fuel-ts/utils");
2156
2310
  var import_ramda = require("ramda");
2157
2311
  function normalize(object) {
2158
2312
  Object.keys(object).forEach((key) => {
2159
2313
  switch (object[key]?.constructor.name) {
2160
2314
  case "Uint8Array":
2161
- object[key] = (0, import_utils9.hexlify)(object[key]);
2315
+ object[key] = (0, import_utils8.hexlify)(object[key]);
2162
2316
  break;
2163
2317
  case "Array":
2164
2318
  object[key] = normalize(object[key]);
@@ -2185,7 +2339,7 @@ function normalizeJSON(root) {
2185
2339
  // src/providers/utils/extract-tx-error.ts
2186
2340
  var import_errors9 = require("@fuel-ts/errors");
2187
2341
  var import_math7 = require("@fuel-ts/math");
2188
- var import_transactions5 = require("@fuel-ts/transactions");
2342
+ var import_transactions6 = require("@fuel-ts/transactions");
2189
2343
  var import_configs5 = require("@fuel-ts/transactions/configs");
2190
2344
  var assemblePanicError = (statusReason, metadata) => {
2191
2345
  let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
@@ -2204,7 +2358,7 @@ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2204
2358
  var stringify = (obj) => JSON.stringify(obj, null, 2);
2205
2359
  var assembleRevertError = (receipts, logs, metadata) => {
2206
2360
  let errorMessage = "The transaction reverted with an unknown reason.";
2207
- const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
2361
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions6.ReceiptType.Revert);
2208
2362
  let reason = "";
2209
2363
  if (revertReceipt) {
2210
2364
  const reasonHex = (0, import_math7.bn)(revertReceipt.val).toHex();
@@ -2217,15 +2371,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
2217
2371
  break;
2218
2372
  }
2219
2373
  case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
2220
- const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2374
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2221
2375
  reason = "assert_eq";
2222
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
2376
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
2223
2377
  break;
2224
2378
  }
2225
2379
  case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
2226
- const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2380
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2227
2381
  reason = "assert_ne";
2228
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
2382
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
2229
2383
  break;
2230
2384
  }
2231
2385
  case import_configs5.FAILED_ASSERT_SIGNAL:
@@ -2233,8 +2387,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2233
2387
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
2234
2388
  break;
2235
2389
  case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
2236
- reason = "MissingOutputChange";
2237
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
2390
+ reason = "MissingOutputVariable";
2391
+ errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2238
2392
  break;
2239
2393
  default:
2240
2394
  throw new import_errors9.FuelError(
@@ -2254,8 +2408,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2254
2408
  };
2255
2409
  var extractTxError = (params) => {
2256
2410
  const { receipts, statusReason, logs } = params;
2257
- const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
2258
- const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
2411
+ const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
2412
+ const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
2259
2413
  const metadata = {
2260
2414
  logs,
2261
2415
  receipts,
@@ -2282,14 +2436,16 @@ var NoWitnessAtIndexError = class extends Error {
2282
2436
  // src/providers/transaction-request/helpers.ts
2283
2437
  var import_errors10 = require("@fuel-ts/errors");
2284
2438
  var import_math8 = require("@fuel-ts/math");
2285
- var import_transactions6 = require("@fuel-ts/transactions");
2286
- var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
2287
- var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
2288
- var isRequestInputMessageWithoutData = (input) => input.type === import_transactions6.InputType.Message && (0, import_math8.bn)(input.data).isZero();
2439
+ var import_transactions7 = require("@fuel-ts/transactions");
2440
+ var import_utils9 = require("@fuel-ts/utils");
2441
+ var isRequestInputCoin = (input) => input.type === import_transactions7.InputType.Coin;
2442
+ var isRequestInputMessage = (input) => input.type === import_transactions7.InputType.Message;
2443
+ var isRequestInputMessageWithoutData = (input) => input.type === import_transactions7.InputType.Message && (0, import_math8.bn)(input.data).isZero();
2289
2444
  var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2290
2445
  var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
2291
2446
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
2292
2447
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
2448
+ var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils9.hexlify)(input.predicate) !== "0x";
2293
2449
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
2294
2450
  if (isRequestInputCoin(input) && input.assetId === assetId) {
2295
2451
  return acc.add(input.amount);
@@ -2320,7 +2476,7 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
2320
2476
  coinInputs.add(baseAssetId);
2321
2477
  }
2322
2478
  const changeOutputs = new Set(
2323
- outputs.filter((output) => output.type === import_transactions6.OutputType.Change).map((output) => output.assetId)
2479
+ outputs.filter((output) => output.type === import_transactions7.OutputType.Change).map((output) => output.assetId)
2324
2480
  );
2325
2481
  const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
2326
2482
  return difference.size;
@@ -2356,6 +2512,8 @@ var BaseTransactionRequest = class {
2356
2512
  tip;
2357
2513
  /** Block until which tx cannot be included */
2358
2514
  maturity;
2515
+ /** The block number after which the transaction is no longer valid. */
2516
+ expiration;
2359
2517
  /** The maximum fee payable by this transaction using BASE_ASSET. */
2360
2518
  maxFee;
2361
2519
  /** The maximum amount of witness data allowed for the transaction */
@@ -2366,6 +2524,12 @@ var BaseTransactionRequest = class {
2366
2524
  outputs = [];
2367
2525
  /** List of witnesses */
2368
2526
  witnesses = [];
2527
+ /**
2528
+ * @hidden
2529
+ *
2530
+ * The current status of the transaction
2531
+ */
2532
+ flag = { state: void 0, transactionId: void 0, summary: void 0 };
2369
2533
  /**
2370
2534
  * Constructor for initializing a base transaction request.
2371
2535
  *
@@ -2374,6 +2538,7 @@ var BaseTransactionRequest = class {
2374
2538
  constructor({
2375
2539
  tip,
2376
2540
  maturity,
2541
+ expiration,
2377
2542
  maxFee,
2378
2543
  witnessLimit,
2379
2544
  inputs,
@@ -2382,6 +2547,7 @@ var BaseTransactionRequest = class {
2382
2547
  } = {}) {
2383
2548
  this.tip = tip ? (0, import_math9.bn)(tip) : void 0;
2384
2549
  this.maturity = maturity && maturity > 0 ? maturity : void 0;
2550
+ this.expiration = expiration && expiration > 0 ? expiration : void 0;
2385
2551
  this.witnessLimit = (0, import_utils11.isDefined)(witnessLimit) ? (0, import_math9.bn)(witnessLimit) : void 0;
2386
2552
  this.maxFee = (0, import_math9.bn)(maxFee);
2387
2553
  this.inputs = inputs ?? [];
@@ -2391,21 +2557,25 @@ var BaseTransactionRequest = class {
2391
2557
  static getPolicyMeta(req) {
2392
2558
  let policyTypes = 0;
2393
2559
  const policies = [];
2394
- const { tip, witnessLimit, maturity } = req;
2560
+ const { tip, witnessLimit, maturity, expiration } = req;
2395
2561
  if ((0, import_math9.bn)(tip).gt(0)) {
2396
- policyTypes += import_transactions7.PolicyType.Tip;
2397
- policies.push({ data: (0, import_math9.bn)(tip), type: import_transactions7.PolicyType.Tip });
2562
+ policyTypes += import_transactions8.PolicyType.Tip;
2563
+ policies.push({ data: (0, import_math9.bn)(tip), type: import_transactions8.PolicyType.Tip });
2398
2564
  }
2399
2565
  if ((0, import_utils11.isDefined)(witnessLimit) && (0, import_math9.bn)(witnessLimit).gte(0)) {
2400
- policyTypes += import_transactions7.PolicyType.WitnessLimit;
2401
- policies.push({ data: (0, import_math9.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
2566
+ policyTypes += import_transactions8.PolicyType.WitnessLimit;
2567
+ policies.push({ data: (0, import_math9.bn)(witnessLimit), type: import_transactions8.PolicyType.WitnessLimit });
2402
2568
  }
2403
2569
  if (maturity && maturity > 0) {
2404
- policyTypes += import_transactions7.PolicyType.Maturity;
2405
- policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
2570
+ policyTypes += import_transactions8.PolicyType.Maturity;
2571
+ policies.push({ data: maturity, type: import_transactions8.PolicyType.Maturity });
2572
+ }
2573
+ policyTypes += import_transactions8.PolicyType.MaxFee;
2574
+ policies.push({ data: req.maxFee, type: import_transactions8.PolicyType.MaxFee });
2575
+ if (expiration && expiration > 0) {
2576
+ policyTypes += import_transactions8.PolicyType.Expiration;
2577
+ policies.push({ data: expiration, type: import_transactions8.PolicyType.Expiration });
2406
2578
  }
2407
- policyTypes += import_transactions7.PolicyType.MaxFee;
2408
- policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
2409
2579
  return {
2410
2580
  policyTypes,
2411
2581
  policies
@@ -2438,7 +2608,7 @@ var BaseTransactionRequest = class {
2438
2608
  * @returns The transaction bytes.
2439
2609
  */
2440
2610
  toTransactionBytes() {
2441
- return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2611
+ return new import_transactions8.TransactionCoder().encode(this.toTransaction());
2442
2612
  }
2443
2613
  /**
2444
2614
  * @hidden
@@ -2478,8 +2648,7 @@ var BaseTransactionRequest = class {
2478
2648
  * @returns The index of the created witness.
2479
2649
  */
2480
2650
  addEmptyWitness() {
2481
- this.addWitness((0, import_utils11.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2482
- return this.witnesses.length - 1;
2651
+ return this.addWitness((0, import_utils11.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2483
2652
  }
2484
2653
  /**
2485
2654
  * Updates the witness for a given owner and signature.
@@ -2529,7 +2698,7 @@ var BaseTransactionRequest = class {
2529
2698
  */
2530
2699
  getCoinInputs() {
2531
2700
  return this.inputs.filter(
2532
- (input) => input.type === import_transactions7.InputType.Coin
2701
+ (input) => input.type === import_transactions8.InputType.Coin
2533
2702
  );
2534
2703
  }
2535
2704
  /**
@@ -2539,7 +2708,7 @@ var BaseTransactionRequest = class {
2539
2708
  */
2540
2709
  getCoinOutputs() {
2541
2710
  return this.outputs.filter(
2542
- (output) => output.type === import_transactions7.OutputType.Coin
2711
+ (output) => output.type === import_transactions8.OutputType.Coin
2543
2712
  );
2544
2713
  }
2545
2714
  /**
@@ -2549,7 +2718,7 @@ var BaseTransactionRequest = class {
2549
2718
  */
2550
2719
  getChangeOutputs() {
2551
2720
  return this.outputs.filter(
2552
- (output) => output.type === import_transactions7.OutputType.Change
2721
+ (output) => output.type === import_transactions8.OutputType.Change
2553
2722
  );
2554
2723
  }
2555
2724
  /**
@@ -2561,9 +2730,9 @@ var BaseTransactionRequest = class {
2561
2730
  const ownerAddress = (0, import_address2.addressify)(owner);
2562
2731
  const found = this.inputs.find((input) => {
2563
2732
  switch (input.type) {
2564
- case import_transactions7.InputType.Coin:
2733
+ case import_transactions8.InputType.Coin:
2565
2734
  return (0, import_utils11.hexlify)(input.owner) === ownerAddress.toB256();
2566
- case import_transactions7.InputType.Message:
2735
+ case import_transactions8.InputType.Message:
2567
2736
  return (0, import_utils11.hexlify)(input.recipient) === ownerAddress.toB256();
2568
2737
  default:
2569
2738
  return false;
@@ -2590,7 +2759,7 @@ var BaseTransactionRequest = class {
2590
2759
  }
2591
2760
  const input = {
2592
2761
  id,
2593
- type: import_transactions7.InputType.Coin,
2762
+ type: import_transactions8.InputType.Coin,
2594
2763
  owner: owner.toB256(),
2595
2764
  amount,
2596
2765
  assetId,
@@ -2621,7 +2790,7 @@ var BaseTransactionRequest = class {
2621
2790
  }
2622
2791
  const input = {
2623
2792
  nonce,
2624
- type: import_transactions7.InputType.Message,
2793
+ type: import_transactions8.InputType.Message,
2625
2794
  sender: sender.toB256(),
2626
2795
  recipient: recipient.toB256(),
2627
2796
  data: isMessageCoin(message) ? "0x" : message.data,
@@ -2670,7 +2839,7 @@ var BaseTransactionRequest = class {
2670
2839
  */
2671
2840
  addCoinOutput(to, amount, assetId) {
2672
2841
  this.pushOutput({
2673
- type: import_transactions7.OutputType.Coin,
2842
+ type: import_transactions8.OutputType.Coin,
2674
2843
  to: (0, import_address2.addressify)(to).toB256(),
2675
2844
  amount,
2676
2845
  assetId
@@ -2686,7 +2855,7 @@ var BaseTransactionRequest = class {
2686
2855
  addCoinOutputs(to, quantities) {
2687
2856
  quantities.map(coinQuantityfy).forEach((quantity) => {
2688
2857
  this.pushOutput({
2689
- type: import_transactions7.OutputType.Coin,
2858
+ type: import_transactions8.OutputType.Coin,
2690
2859
  to: (0, import_address2.addressify)(to).toB256(),
2691
2860
  amount: quantity.amount,
2692
2861
  assetId: quantity.assetId
@@ -2706,7 +2875,7 @@ var BaseTransactionRequest = class {
2706
2875
  );
2707
2876
  if (!changeOutput) {
2708
2877
  this.pushOutput({
2709
- type: import_transactions7.OutputType.Change,
2878
+ type: import_transactions8.OutputType.Change,
2710
2879
  to: (0, import_address2.addressify)(to).toB256(),
2711
2880
  assetId
2712
2881
  });
@@ -2849,6 +3018,21 @@ var BaseTransactionRequest = class {
2849
3018
  byteLength() {
2850
3019
  return this.toTransactionBytes().byteLength;
2851
3020
  }
3021
+ /**
3022
+ * @hidden
3023
+ *
3024
+ * Used internally to update the state of a transaction request.
3025
+ *
3026
+ * @param state - The state to update.
3027
+ */
3028
+ updateState(chainId, state, summary) {
3029
+ if (!state) {
3030
+ this.flag = { state: void 0, transactionId: void 0, summary: void 0 };
3031
+ return;
3032
+ }
3033
+ const transactionId = this.getTransactionId(chainId);
3034
+ this.flag = { state, transactionId, summary };
3035
+ }
2852
3036
  };
2853
3037
 
2854
3038
  // src/providers/transaction-request/blob-transaction-request.ts
@@ -2858,18 +3042,18 @@ var import_ramda3 = require("ramda");
2858
3042
  var import_configs7 = require("@fuel-ts/address/configs");
2859
3043
  var import_hasher2 = require("@fuel-ts/hasher");
2860
3044
  var import_math10 = require("@fuel-ts/math");
2861
- var import_transactions8 = require("@fuel-ts/transactions");
3045
+ var import_transactions9 = require("@fuel-ts/transactions");
2862
3046
  var import_utils13 = require("@fuel-ts/utils");
2863
3047
  var import_ramda2 = require("ramda");
2864
3048
  function hashTransaction(transactionRequest, chainId) {
2865
3049
  const transaction = transactionRequest.toTransaction();
2866
- if (transaction.type === import_transactions8.TransactionType.Script) {
3050
+ if (transaction.type === import_transactions9.TransactionType.Script) {
2867
3051
  transaction.receiptsRoot = import_configs7.ZeroBytes32;
2868
3052
  }
2869
3053
  transaction.inputs = transaction.inputs.map((input) => {
2870
3054
  const inputClone = (0, import_ramda2.clone)(input);
2871
3055
  switch (inputClone.type) {
2872
- case import_transactions8.InputType.Coin: {
3056
+ case import_transactions9.InputType.Coin: {
2873
3057
  inputClone.txPointer = {
2874
3058
  blockHeight: 0,
2875
3059
  txIndex: 0
@@ -2877,11 +3061,11 @@ function hashTransaction(transactionRequest, chainId) {
2877
3061
  inputClone.predicateGasUsed = (0, import_math10.bn)(0);
2878
3062
  return inputClone;
2879
3063
  }
2880
- case import_transactions8.InputType.Message: {
3064
+ case import_transactions9.InputType.Message: {
2881
3065
  inputClone.predicateGasUsed = (0, import_math10.bn)(0);
2882
3066
  return inputClone;
2883
3067
  }
2884
- case import_transactions8.InputType.Contract: {
3068
+ case import_transactions9.InputType.Contract: {
2885
3069
  inputClone.txPointer = {
2886
3070
  blockHeight: 0,
2887
3071
  txIndex: 0
@@ -2899,16 +3083,16 @@ function hashTransaction(transactionRequest, chainId) {
2899
3083
  transaction.outputs = transaction.outputs.map((output) => {
2900
3084
  const outputClone = (0, import_ramda2.clone)(output);
2901
3085
  switch (outputClone.type) {
2902
- case import_transactions8.OutputType.Contract: {
3086
+ case import_transactions9.OutputType.Contract: {
2903
3087
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
2904
3088
  outputClone.stateRoot = import_configs7.ZeroBytes32;
2905
3089
  return outputClone;
2906
3090
  }
2907
- case import_transactions8.OutputType.Change: {
3091
+ case import_transactions9.OutputType.Change: {
2908
3092
  outputClone.amount = (0, import_math10.bn)(0);
2909
3093
  return outputClone;
2910
3094
  }
2911
- case import_transactions8.OutputType.Variable: {
3095
+ case import_transactions9.OutputType.Variable: {
2912
3096
  outputClone.to = import_configs7.ZeroBytes32;
2913
3097
  outputClone.amount = (0, import_math10.bn)(0);
2914
3098
  outputClone.assetId = import_configs7.ZeroBytes32;
@@ -2921,7 +3105,7 @@ function hashTransaction(transactionRequest, chainId) {
2921
3105
  transaction.witnessesCount = 0;
2922
3106
  transaction.witnesses = [];
2923
3107
  const chainIdBytes = (0, import_hasher2.uint64ToBytesBE)(chainId);
2924
- const concatenatedData = (0, import_utils13.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
3108
+ const concatenatedData = (0, import_utils13.concat)([chainIdBytes, new import_transactions9.TransactionCoder().encode(transaction)]);
2925
3109
  return (0, import_hasher2.sha256)(concatenatedData);
2926
3110
  }
2927
3111
 
@@ -2931,7 +3115,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2931
3115
  return new this((0, import_ramda3.clone)(obj));
2932
3116
  }
2933
3117
  /** Type of the transaction */
2934
- type = import_transactions7.TransactionType.Blob;
3118
+ type = import_transactions8.TransactionType.Blob;
2935
3119
  /** Blob ID */
2936
3120
  blobId;
2937
3121
  /** Witness index of the bytecode to create */
@@ -2955,7 +3139,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2955
3139
  const baseTransaction = this.getBaseTransaction();
2956
3140
  const { witnessIndex, blobId } = this;
2957
3141
  return {
2958
- type: import_transactions7.TransactionType.Blob,
3142
+ type: import_transactions8.TransactionType.Blob,
2959
3143
  ...baseTransaction,
2960
3144
  blobId,
2961
3145
  witnessIndex
@@ -2989,7 +3173,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2989
3173
  // src/providers/transaction-request/create-transaction-request.ts
2990
3174
  var import_configs8 = require("@fuel-ts/address/configs");
2991
3175
  var import_math11 = require("@fuel-ts/math");
2992
- var import_transactions9 = require("@fuel-ts/transactions");
3176
+ var import_transactions10 = require("@fuel-ts/transactions");
2993
3177
  var import_utils16 = require("@fuel-ts/utils");
2994
3178
  var import_ramda4 = require("ramda");
2995
3179
 
@@ -3022,7 +3206,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3022
3206
  return new this((0, import_ramda4.clone)(obj));
3023
3207
  }
3024
3208
  /** Type of the transaction */
3025
- type = import_transactions9.TransactionType.Create;
3209
+ type = import_transactions10.TransactionType.Create;
3026
3210
  /** Witness index of contract bytecode to create */
3027
3211
  bytecodeWitnessIndex;
3028
3212
  /** Salt */
@@ -3050,7 +3234,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3050
3234
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
3051
3235
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
3052
3236
  return {
3053
- type: import_transactions9.TransactionType.Create,
3237
+ type: import_transactions10.TransactionType.Create,
3054
3238
  ...baseTransaction,
3055
3239
  bytecodeWitnessIndex,
3056
3240
  storageSlotsCount: (0, import_math11.bn)(storageSlots.length),
@@ -3065,7 +3249,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3065
3249
  */
3066
3250
  getContractCreatedOutputs() {
3067
3251
  return this.outputs.filter(
3068
- (output) => output.type === import_transactions9.OutputType.ContractCreated
3252
+ (output) => output.type === import_transactions10.OutputType.ContractCreated
3069
3253
  );
3070
3254
  }
3071
3255
  /**
@@ -3086,7 +3270,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3086
3270
  */
3087
3271
  addContractCreatedOutput(contractId, stateRoot) {
3088
3272
  this.pushOutput({
3089
- type: import_transactions9.OutputType.ContractCreated,
3273
+ type: import_transactions10.OutputType.ContractCreated,
3090
3274
  contractId,
3091
3275
  stateRoot
3092
3276
  });
@@ -3106,7 +3290,7 @@ var import_abi_coder4 = require("@fuel-ts/abi-coder");
3106
3290
  var import_address3 = require("@fuel-ts/address");
3107
3291
  var import_configs9 = require("@fuel-ts/address/configs");
3108
3292
  var import_math12 = require("@fuel-ts/math");
3109
- var import_transactions10 = require("@fuel-ts/transactions");
3293
+ var import_transactions11 = require("@fuel-ts/transactions");
3110
3294
  var import_utils18 = require("@fuel-ts/utils");
3111
3295
  var import_ramda5 = require("ramda");
3112
3296
 
@@ -3142,7 +3326,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3142
3326
  return new this((0, import_ramda5.clone)(obj));
3143
3327
  }
3144
3328
  /** Type of the transaction */
3145
- type = import_transactions10.TransactionType.Script;
3329
+ type = import_transactions11.TransactionType.Script;
3146
3330
  /** Gas limit for transaction */
3147
3331
  gasLimit;
3148
3332
  /** Script to execute */
@@ -3185,7 +3369,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3185
3369
  const script = (0, import_utils18.arrayify)(this.script ?? "0x");
3186
3370
  const scriptData = (0, import_utils18.arrayify)(this.scriptData ?? "0x");
3187
3371
  return {
3188
- type: import_transactions10.TransactionType.Script,
3372
+ type: import_transactions11.TransactionType.Script,
3189
3373
  scriptGasLimit: this.gasLimit,
3190
3374
  ...super.getBaseTransaction(),
3191
3375
  scriptLength: (0, import_math12.bn)(script.length),
@@ -3202,7 +3386,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3202
3386
  */
3203
3387
  getContractInputs() {
3204
3388
  return this.inputs.filter(
3205
- (input) => input.type === import_transactions10.InputType.Contract
3389
+ (input) => input.type === import_transactions11.InputType.Contract
3206
3390
  );
3207
3391
  }
3208
3392
  /**
@@ -3212,7 +3396,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3212
3396
  */
3213
3397
  getContractOutputs() {
3214
3398
  return this.outputs.filter(
3215
- (output) => output.type === import_transactions10.OutputType.Contract
3399
+ (output) => output.type === import_transactions11.OutputType.Contract
3216
3400
  );
3217
3401
  }
3218
3402
  /**
@@ -3222,7 +3406,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3222
3406
  */
3223
3407
  getVariableOutputs() {
3224
3408
  return this.outputs.filter(
3225
- (output) => output.type === import_transactions10.OutputType.Variable
3409
+ (output) => output.type === import_transactions11.OutputType.Variable
3226
3410
  );
3227
3411
  }
3228
3412
  /**
@@ -3245,7 +3429,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3245
3429
  let outputsNumber = numberOfVariables;
3246
3430
  while (outputsNumber) {
3247
3431
  this.pushOutput({
3248
- type: import_transactions10.OutputType.Variable
3432
+ type: import_transactions11.OutputType.Variable
3249
3433
  });
3250
3434
  outputsNumber -= 1;
3251
3435
  }
@@ -3289,12 +3473,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3289
3473
  return this;
3290
3474
  }
3291
3475
  const inputIndex = super.pushInput({
3292
- type: import_transactions10.InputType.Contract,
3476
+ type: import_transactions11.InputType.Contract,
3293
3477
  contractId: contractAddress.toB256(),
3294
3478
  txPointer: "0x00000000000000000000000000000000"
3295
3479
  });
3296
3480
  this.pushOutput({
3297
- type: import_transactions10.OutputType.Contract,
3481
+ type: import_transactions11.OutputType.Contract,
3298
3482
  inputIndex
3299
3483
  });
3300
3484
  return this;
@@ -3332,7 +3516,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3332
3516
  // src/providers/transaction-request/upgrade-transaction-request.ts
3333
3517
  var import_errors13 = require("@fuel-ts/errors");
3334
3518
  var import_hasher3 = require("@fuel-ts/hasher");
3335
- var import_transactions11 = require("@fuel-ts/transactions");
3519
+ var import_transactions12 = require("@fuel-ts/transactions");
3336
3520
  var import_utils19 = require("@fuel-ts/utils");
3337
3521
  var import_ramda6 = require("ramda");
3338
3522
  var UpgradeTransactionRequest = class extends BaseTransactionRequest {
@@ -3343,7 +3527,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3343
3527
  return new this((0, import_ramda6.clone)(obj));
3344
3528
  }
3345
3529
  /** The type of transaction */
3346
- type = import_transactions11.TransactionType.Upgrade;
3530
+ type = import_transactions12.TransactionType.Upgrade;
3347
3531
  /** The upgrade purpose */
3348
3532
  upgradePurpose;
3349
3533
  /** Witness index of consensus */
@@ -3361,7 +3545,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3361
3545
  super(rest);
3362
3546
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
3363
3547
  this.upgradePurpose = upgradePurpose ?? {
3364
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3548
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3365
3549
  checksum: "0x"
3366
3550
  };
3367
3551
  }
@@ -3375,7 +3559,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3375
3559
  addConsensusParametersUpgradePurpose(consensus) {
3376
3560
  this.bytecodeWitnessIndex = this.addWitness(consensus);
3377
3561
  this.upgradePurpose = {
3378
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3562
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3379
3563
  checksum: (0, import_hasher3.hash)(consensus)
3380
3564
  };
3381
3565
  return this;
@@ -3389,7 +3573,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3389
3573
  */
3390
3574
  addStateTransitionUpgradePurpose(bytecodeRoot) {
3391
3575
  this.upgradePurpose = {
3392
- type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
3576
+ type: import_transactions12.UpgradePurposeTypeEnum.StateTransition,
3393
3577
  data: (0, import_utils19.hexlify)(bytecodeRoot)
3394
3578
  };
3395
3579
  return this;
@@ -3403,10 +3587,10 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3403
3587
  * @returns - The current instance of `UpgradeTransactionRequest`.
3404
3588
  */
3405
3589
  addUpgradePurpose(type, data) {
3406
- if (type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3590
+ if (type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3407
3591
  this.addConsensusParametersUpgradePurpose(data);
3408
3592
  }
3409
- if (type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3593
+ if (type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3410
3594
  this.addStateTransitionUpgradePurpose(data);
3411
3595
  }
3412
3596
  return this;
@@ -3418,17 +3602,17 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3418
3602
  */
3419
3603
  toTransaction() {
3420
3604
  let upgradePurpose;
3421
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3605
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3422
3606
  upgradePurpose = {
3423
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3607
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3424
3608
  data: {
3425
3609
  witnessIndex: this.bytecodeWitnessIndex,
3426
3610
  checksum: this.upgradePurpose.checksum
3427
3611
  }
3428
3612
  };
3429
- } else if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3613
+ } else if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3430
3614
  upgradePurpose = {
3431
- type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
3615
+ type: import_transactions12.UpgradePurposeTypeEnum.StateTransition,
3432
3616
  data: {
3433
3617
  bytecodeRoot: (0, import_utils19.hexlify)(this.upgradePurpose.data)
3434
3618
  }
@@ -3437,7 +3621,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3437
3621
  throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3438
3622
  }
3439
3623
  return {
3440
- type: import_transactions11.TransactionType.Upgrade,
3624
+ type: import_transactions12.TransactionType.Upgrade,
3441
3625
  ...super.getBaseTransaction(),
3442
3626
  upgradePurpose
3443
3627
  };
@@ -3461,7 +3645,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3461
3645
  */
3462
3646
  metadataGas(gasCosts) {
3463
3647
  const txBytesSize = this.byteSize();
3464
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3648
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3465
3649
  const witnessIndex = this.bytecodeWitnessIndex;
3466
3650
  const consensusSize = this.witnesses[witnessIndex].length;
3467
3651
  return calculateMetadataGasForTxUpgrade({
@@ -3470,7 +3654,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3470
3654
  consensusSize
3471
3655
  });
3472
3656
  }
3473
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3657
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3474
3658
  return calculateMetadataGasForTxUpgrade({
3475
3659
  gasCosts,
3476
3660
  txBytesSize
@@ -3482,7 +3666,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3482
3666
 
3483
3667
  // src/providers/transaction-request/upload-transaction-request.ts
3484
3668
  var import_configs10 = require("@fuel-ts/address/configs");
3485
- var import_transactions12 = require("@fuel-ts/transactions");
3669
+ var import_transactions13 = require("@fuel-ts/transactions");
3486
3670
  var import_utils21 = require("@fuel-ts/utils");
3487
3671
  var import_ramda7 = require("ramda");
3488
3672
  var UploadTransactionRequest = class extends BaseTransactionRequest {
@@ -3493,7 +3677,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3493
3677
  return new this((0, import_ramda7.clone)(obj));
3494
3678
  }
3495
3679
  /** Type of the transaction */
3496
- type = import_transactions12.TransactionType.Upload;
3680
+ type = import_transactions13.TransactionType.Upload;
3497
3681
  /** The witness index of the subsection of the bytecode. */
3498
3682
  witnessIndex;
3499
3683
  /** The subsection data. */
@@ -3542,7 +3726,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3542
3726
  const baseTransaction = this.getBaseTransaction();
3543
3727
  const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
3544
3728
  return {
3545
- type: import_transactions12.TransactionType.Upload,
3729
+ type: import_transactions13.TransactionType.Upload,
3546
3730
  ...baseTransaction,
3547
3731
  subsectionIndex,
3548
3732
  subsectionsNumber,
@@ -3588,26 +3772,26 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3588
3772
 
3589
3773
  // src/providers/transaction-request/utils.ts
3590
3774
  var import_errors14 = require("@fuel-ts/errors");
3591
- var import_transactions13 = require("@fuel-ts/transactions");
3775
+ var import_transactions14 = require("@fuel-ts/transactions");
3592
3776
  var transactionRequestify = (obj) => {
3593
3777
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
3594
3778
  return obj;
3595
3779
  }
3596
3780
  const { type } = obj;
3597
3781
  switch (obj.type) {
3598
- case import_transactions13.TransactionType.Script: {
3782
+ case import_transactions14.TransactionType.Script: {
3599
3783
  return ScriptTransactionRequest.from(obj);
3600
3784
  }
3601
- case import_transactions13.TransactionType.Create: {
3785
+ case import_transactions14.TransactionType.Create: {
3602
3786
  return CreateTransactionRequest.from(obj);
3603
3787
  }
3604
- case import_transactions13.TransactionType.Blob: {
3788
+ case import_transactions14.TransactionType.Blob: {
3605
3789
  return BlobTransactionRequest.from(obj);
3606
3790
  }
3607
- case import_transactions13.TransactionType.Upgrade: {
3791
+ case import_transactions14.TransactionType.Upgrade: {
3608
3792
  return UpgradeTransactionRequest.from(obj);
3609
3793
  }
3610
- case import_transactions13.TransactionType.Upload: {
3794
+ case import_transactions14.TransactionType.Upload: {
3611
3795
  return UploadTransactionRequest.from(obj);
3612
3796
  }
3613
3797
  default: {
@@ -3618,24 +3802,115 @@ var transactionRequestify = (obj) => {
3618
3802
  }
3619
3803
  }
3620
3804
  };
3621
- var isTransactionTypeScript = (request) => request.type === import_transactions13.TransactionType.Script;
3622
- var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
3805
+ var isTransactionTypeScript = (request) => request.type === import_transactions14.TransactionType.Script;
3806
+ var isTransactionTypeCreate = (request) => request.type === import_transactions14.TransactionType.Create;
3807
+
3808
+ // src/providers/resource-cache.ts
3809
+ var cache = /* @__PURE__ */ new Map();
3810
+ var ResourceCache = class {
3811
+ ttl;
3812
+ constructor(ttl) {
3813
+ this.ttl = ttl;
3814
+ if (typeof ttl !== "number" || this.ttl <= 0) {
3815
+ throw new import_errors15.FuelError(
3816
+ import_errors15.ErrorCode.INVALID_TTL,
3817
+ `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
3818
+ );
3819
+ }
3820
+ }
3821
+ // Add resources to the cache
3822
+ set(transactionId, inputs) {
3823
+ const transactionResourceCache = this.setupResourcesCache(inputs);
3824
+ cache.set(transactionId, transactionResourceCache);
3825
+ }
3826
+ unset(transactionId) {
3827
+ cache.delete(transactionId);
3828
+ }
3829
+ getActiveData(owner) {
3830
+ const activeData = { utxos: [], messages: [] };
3831
+ const currentTime = Date.now();
3832
+ const expired = [];
3833
+ cache.forEach((resource, transactionId) => {
3834
+ const isActive = currentTime - resource.timestamp < this.ttl;
3835
+ if (isActive) {
3836
+ const resourcesFromOwner = resource.owners.get(owner);
3837
+ if (resourcesFromOwner) {
3838
+ activeData.utxos.push(...resourcesFromOwner.utxos);
3839
+ activeData.messages.push(...resourcesFromOwner.messages);
3840
+ }
3841
+ } else {
3842
+ expired.push(transactionId);
3843
+ }
3844
+ });
3845
+ expired.forEach(this.unset);
3846
+ activeData.utxos.reverse();
3847
+ activeData.messages.reverse();
3848
+ return activeData;
3849
+ }
3850
+ isCached(owner, key) {
3851
+ const currentTime = Date.now();
3852
+ let cached = false;
3853
+ const expired = [];
3854
+ for (const [transactionId, resourceData] of cache.entries()) {
3855
+ const isActive = currentTime - resourceData.timestamp < this.ttl;
3856
+ if (isActive) {
3857
+ const resourcesFromOwner = resourceData.owners.get(owner);
3858
+ if (resourcesFromOwner?.utxos.has(key) || resourcesFromOwner?.messages.has(key)) {
3859
+ cached = true;
3860
+ break;
3861
+ }
3862
+ } else {
3863
+ expired.push(transactionId);
3864
+ }
3865
+ }
3866
+ expired.forEach(this.unset);
3867
+ return cached;
3868
+ }
3869
+ clear() {
3870
+ cache.clear();
3871
+ }
3872
+ setupResourcesCache(inputs) {
3873
+ const currentTime = Date.now();
3874
+ const transactionResourcesCache = {
3875
+ owners: /* @__PURE__ */ new Map(),
3876
+ timestamp: currentTime
3877
+ };
3878
+ inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
3879
+ const { owner, key, type } = this.extractResourceData(input);
3880
+ if (!transactionResourcesCache.owners.has(owner)) {
3881
+ transactionResourcesCache.owners.set(owner, { utxos: /* @__PURE__ */ new Set(), messages: /* @__PURE__ */ new Set() });
3882
+ }
3883
+ if (type === "utxo") {
3884
+ transactionResourcesCache.owners.get(owner)?.utxos.add(key);
3885
+ } else {
3886
+ transactionResourcesCache.owners.get(owner)?.messages.add(key);
3887
+ }
3888
+ });
3889
+ return transactionResourcesCache;
3890
+ }
3891
+ extractResourceData(input) {
3892
+ if (isRequestInputCoin(input)) {
3893
+ return { owner: (0, import_utils23.hexlify)(input.owner), key: (0, import_utils23.hexlify)(input.id), type: "utxo" };
3894
+ }
3895
+ return { owner: (0, import_utils23.hexlify)(input.recipient), key: (0, import_utils23.hexlify)(input.nonce), type: "message" };
3896
+ }
3897
+ };
3623
3898
 
3624
3899
  // src/providers/transaction-response/transaction-response.ts
3625
- var import_errors18 = require("@fuel-ts/errors");
3900
+ var import_errors19 = require("@fuel-ts/errors");
3626
3901
  var import_math18 = require("@fuel-ts/math");
3627
- var import_transactions21 = require("@fuel-ts/transactions");
3902
+ var import_transactions22 = require("@fuel-ts/transactions");
3628
3903
  var import_utils27 = require("@fuel-ts/utils");
3629
3904
 
3630
3905
  // src/providers/transaction-summary/assemble-transaction-summary.ts
3631
3906
  var import_math17 = require("@fuel-ts/math");
3632
- var import_transactions19 = require("@fuel-ts/transactions");
3907
+ var import_transactions20 = require("@fuel-ts/transactions");
3633
3908
  var import_utils25 = require("@fuel-ts/utils");
3634
3909
 
3635
3910
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
3636
3911
  var import_math13 = require("@fuel-ts/math");
3637
- var import_transactions14 = require("@fuel-ts/transactions");
3638
- var import_utils23 = require("@fuel-ts/utils");
3912
+ var import_transactions15 = require("@fuel-ts/transactions");
3913
+ var import_utils24 = require("@fuel-ts/utils");
3639
3914
  var calculateTXFeeForSummary = (params) => {
3640
3915
  const {
3641
3916
  gasPrice,
@@ -3645,17 +3920,17 @@ var calculateTXFeeForSummary = (params) => {
3645
3920
  } = params;
3646
3921
  const gasPerByte = (0, import_math13.bn)(feeParams.gasPerByte);
3647
3922
  const gasPriceFactor = (0, import_math13.bn)(feeParams.gasPriceFactor);
3648
- const transactionBytes = (0, import_utils23.arrayify)(rawPayload);
3649
- const [transaction] = new import_transactions14.TransactionCoder().decode(transactionBytes, 0);
3923
+ const transactionBytes = (0, import_utils24.arrayify)(rawPayload);
3924
+ const [transaction] = new import_transactions15.TransactionCoder().decode(transactionBytes, 0);
3650
3925
  const { type, witnesses, inputs, policies } = transaction;
3651
3926
  let metadataGas = (0, import_math13.bn)(0);
3652
3927
  let gasLimit = (0, import_math13.bn)(0);
3653
- if (type !== import_transactions14.TransactionType.Create && type !== import_transactions14.TransactionType.Script) {
3928
+ if (type !== import_transactions15.TransactionType.Create && type !== import_transactions15.TransactionType.Script) {
3654
3929
  return (0, import_math13.bn)(0);
3655
3930
  }
3656
- if (type === import_transactions14.TransactionType.Create) {
3931
+ if (type === import_transactions15.TransactionType.Create) {
3657
3932
  const { bytecodeWitnessIndex, storageSlots } = transaction;
3658
- const contractBytesSize = (0, import_math13.bn)((0, import_utils23.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
3933
+ const contractBytesSize = (0, import_math13.bn)((0, import_utils24.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
3659
3934
  metadataGas = calculateMetadataGasForTxCreate({
3660
3935
  contractBytesSize,
3661
3936
  gasCosts,
@@ -3679,7 +3954,7 @@ var calculateTXFeeForSummary = (params) => {
3679
3954
  metadataGas,
3680
3955
  txBytesSize: transactionBytes.length
3681
3956
  });
3682
- const witnessLimit = policies.find((policy) => policy.type === import_transactions14.PolicyType.WitnessLimit)?.data;
3957
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions15.PolicyType.WitnessLimit)?.data;
3683
3958
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
3684
3959
  const maxGas = getMaxGas({
3685
3960
  gasPerByte,
@@ -3700,47 +3975,14 @@ var calculateTXFeeForSummary = (params) => {
3700
3975
 
3701
3976
  // src/providers/transaction-summary/operations.ts
3702
3977
  var import_configs11 = require("@fuel-ts/address/configs");
3703
- var import_errors16 = require("@fuel-ts/errors");
3978
+ var import_errors17 = require("@fuel-ts/errors");
3704
3979
  var import_math15 = require("@fuel-ts/math");
3705
- var import_transactions17 = require("@fuel-ts/transactions");
3706
-
3707
- // src/providers/transaction-summary/call.ts
3708
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
3709
- var getFunctionCall = ({ abi, receipt }) => {
3710
- const abiInterface = new import_abi_coder5.Interface(abi);
3711
- const callFunctionSelector = receipt.param1.toHex(8);
3712
- const functionFragment = abiInterface.getFunction(callFunctionSelector);
3713
- const inputs = functionFragment.jsonFn.inputs;
3714
- const encodedArgs = receipt.param2.toHex();
3715
- let argumentsProvided;
3716
- const data = functionFragment.decodeArguments(encodedArgs);
3717
- if (data) {
3718
- argumentsProvided = inputs.reduce((prev, input, index) => {
3719
- const value = data[index];
3720
- const name = input.name;
3721
- if (name) {
3722
- return {
3723
- ...prev,
3724
- // reparse to remove bn
3725
- [name]: JSON.parse(JSON.stringify(value))
3726
- };
3727
- }
3728
- return prev;
3729
- }, {});
3730
- }
3731
- const call = {
3732
- functionSignature: functionFragment.signature,
3733
- functionName: functionFragment.name,
3734
- argumentsProvided,
3735
- ...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
3736
- };
3737
- return call;
3738
- };
3980
+ var import_transactions18 = require("@fuel-ts/transactions");
3739
3981
 
3740
3982
  // src/providers/transaction-summary/input.ts
3741
- var import_errors15 = require("@fuel-ts/errors");
3983
+ var import_errors16 = require("@fuel-ts/errors");
3742
3984
  var import_math14 = require("@fuel-ts/math");
3743
- var import_transactions15 = require("@fuel-ts/transactions");
3985
+ var import_transactions16 = require("@fuel-ts/transactions");
3744
3986
  function getInputsByTypes(inputs, types) {
3745
3987
  return inputs.filter((i) => types.includes(i.type));
3746
3988
  }
@@ -3748,19 +3990,19 @@ function getInputsByType(inputs, type) {
3748
3990
  return inputs.filter((i) => i.type === type);
3749
3991
  }
3750
3992
  function getInputsCoin(inputs) {
3751
- return getInputsByType(inputs, import_transactions15.InputType.Coin);
3993
+ return getInputsByType(inputs, import_transactions16.InputType.Coin);
3752
3994
  }
3753
3995
  function getInputsMessage(inputs) {
3754
- return getInputsByType(inputs, import_transactions15.InputType.Message);
3996
+ return getInputsByType(inputs, import_transactions16.InputType.Message);
3755
3997
  }
3756
3998
  function getInputsCoinAndMessage(inputs) {
3757
- return getInputsByTypes(inputs, [import_transactions15.InputType.Coin, import_transactions15.InputType.Message]);
3999
+ return getInputsByTypes(inputs, [import_transactions16.InputType.Coin, import_transactions16.InputType.Message]);
3758
4000
  }
3759
4001
  function isInputCoin(input) {
3760
- return input.type === import_transactions15.InputType.Coin;
4002
+ return input.type === import_transactions16.InputType.Coin;
3761
4003
  }
3762
4004
  function getInputsContract(inputs) {
3763
- return getInputsByType(inputs, import_transactions15.InputType.Contract);
4005
+ return getInputsByType(inputs, import_transactions16.InputType.Contract);
3764
4006
  }
3765
4007
  function findCoinInput(inputs, assetId) {
3766
4008
  const coinInputs = getInputsCoin(inputs);
@@ -3806,40 +4048,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
3806
4048
  if (!contractInput) {
3807
4049
  return void 0;
3808
4050
  }
3809
- if (contractInput.type !== import_transactions15.InputType.Contract) {
3810
- throw new import_errors15.FuelError(
3811
- import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
4051
+ if (contractInput.type !== import_transactions16.InputType.Contract) {
4052
+ throw new import_errors16.FuelError(
4053
+ import_errors16.ErrorCode.INVALID_TRANSACTION_INPUT,
3812
4054
  `Contract input should be of type 'contract'.`
3813
4055
  );
3814
4056
  }
3815
4057
  return contractInput;
3816
4058
  }
3817
4059
  function getInputAccountAddress(input) {
3818
- if (input.type === import_transactions15.InputType.Coin) {
4060
+ if (input.type === import_transactions16.InputType.Coin) {
3819
4061
  return input.owner.toString();
3820
4062
  }
3821
- if (input.type === import_transactions15.InputType.Message) {
4063
+ if (input.type === import_transactions16.InputType.Message) {
3822
4064
  return input.recipient.toString();
3823
4065
  }
3824
4066
  return "";
3825
4067
  }
3826
4068
 
3827
4069
  // src/providers/transaction-summary/output.ts
3828
- var import_transactions16 = require("@fuel-ts/transactions");
4070
+ var import_transactions17 = require("@fuel-ts/transactions");
3829
4071
  function getOutputsByType(outputs, type) {
3830
4072
  return outputs.filter((o) => o.type === type);
3831
4073
  }
3832
4074
  function getOutputsContractCreated(outputs) {
3833
- return getOutputsByType(outputs, import_transactions16.OutputType.ContractCreated);
4075
+ return getOutputsByType(outputs, import_transactions17.OutputType.ContractCreated);
3834
4076
  }
3835
4077
  function getOutputsCoin(outputs) {
3836
- return getOutputsByType(outputs, import_transactions16.OutputType.Coin);
4078
+ return getOutputsByType(outputs, import_transactions17.OutputType.Coin);
3837
4079
  }
3838
4080
  function getOutputsChange(outputs) {
3839
- return getOutputsByType(outputs, import_transactions16.OutputType.Change);
4081
+ return getOutputsByType(outputs, import_transactions17.OutputType.Change);
3840
4082
  }
3841
4083
  function getOutputsContract(outputs) {
3842
- return getOutputsByType(outputs, import_transactions16.OutputType.Contract);
4084
+ return getOutputsByType(outputs, import_transactions17.OutputType.Contract);
3843
4085
  }
3844
4086
 
3845
4087
  // src/providers/transaction-summary/operations.ts
@@ -3848,21 +4090,21 @@ function getReceiptsByType(receipts, type) {
3848
4090
  }
3849
4091
  function getTransactionTypeName(transactionType) {
3850
4092
  switch (transactionType) {
3851
- case import_transactions17.TransactionType.Mint:
4093
+ case import_transactions18.TransactionType.Mint:
3852
4094
  return "Mint" /* Mint */;
3853
- case import_transactions17.TransactionType.Create:
4095
+ case import_transactions18.TransactionType.Create:
3854
4096
  return "Create" /* Create */;
3855
- case import_transactions17.TransactionType.Script:
4097
+ case import_transactions18.TransactionType.Script:
3856
4098
  return "Script" /* Script */;
3857
- case import_transactions17.TransactionType.Blob:
4099
+ case import_transactions18.TransactionType.Blob:
3858
4100
  return "Blob" /* Blob */;
3859
- case import_transactions17.TransactionType.Upgrade:
4101
+ case import_transactions18.TransactionType.Upgrade:
3860
4102
  return "Upgrade" /* Upgrade */;
3861
- case import_transactions17.TransactionType.Upload:
4103
+ case import_transactions18.TransactionType.Upload:
3862
4104
  return "Upload" /* Upload */;
3863
4105
  default:
3864
- throw new import_errors16.FuelError(
3865
- import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4106
+ throw new import_errors17.FuelError(
4107
+ import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3866
4108
  `Unsupported transaction type: ${transactionType}.`
3867
4109
  );
3868
4110
  }
@@ -3890,10 +4132,10 @@ function isTypeBlob(transactionType) {
3890
4132
  return isType(transactionType, "Blob" /* Blob */);
3891
4133
  }
3892
4134
  function getReceiptsCall(receipts) {
3893
- return getReceiptsByType(receipts, import_transactions17.ReceiptType.Call);
4135
+ return getReceiptsByType(receipts, import_transactions18.ReceiptType.Call);
3894
4136
  }
3895
4137
  function getReceiptsMessageOut(receipts) {
3896
- return getReceiptsByType(receipts, import_transactions17.ReceiptType.MessageOut);
4138
+ return getReceiptsByType(receipts, import_transactions18.ReceiptType.MessageOut);
3897
4139
  }
3898
4140
  function mergeAssets(op1, op2) {
3899
4141
  const assets1 = op1.assetsSent || [];
@@ -3931,7 +4173,11 @@ function mergeOperations(existing, toAdd) {
3931
4173
  return {
3932
4174
  ...existing,
3933
4175
  assetsSent: mergeAssetsSent(existing, toAdd),
3934
- calls: mergeCalls(existing, toAdd)
4176
+ calls: mergeCalls(existing, toAdd),
4177
+ receipts: [
4178
+ ...existing.receipts || [],
4179
+ ...toAdd.receipts?.filter((r) => !existing.receipts?.some((er) => er === r)) || []
4180
+ ]
3935
4181
  };
3936
4182
  }
3937
4183
  function addOperation(operations, toAdd) {
@@ -3968,7 +4214,8 @@ function getWithdrawFromFuelOperations({
3968
4214
  amount: receipt.amount,
3969
4215
  assetId: baseAssetId
3970
4216
  }
3971
- ]
4217
+ ],
4218
+ receipts: [receipt]
3972
4219
  });
3973
4220
  return newWithdrawFromFuelOps;
3974
4221
  }
@@ -3978,19 +4225,12 @@ function getWithdrawFromFuelOperations({
3978
4225
  );
3979
4226
  return withdrawFromFuelOperations;
3980
4227
  }
3981
- function getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs) {
4228
+ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
3982
4229
  const abi = abiMap?.[contractInput.contractID];
3983
4230
  if (!abi) {
3984
4231
  return [];
3985
4232
  }
3986
- return [
3987
- getFunctionCall({
3988
- abi,
3989
- receipt,
3990
- rawPayload,
3991
- maxInputs
3992
- })
3993
- ];
4233
+ return [];
3994
4234
  }
3995
4235
  function getAssetsSent(receipt) {
3996
4236
  return receipt.amount?.isZero() ? void 0 : [
@@ -4020,7 +4260,8 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
4020
4260
  address: receipt.to
4021
4261
  },
4022
4262
  assetsSent: getAssetsSent(receipt),
4023
- calls
4263
+ calls,
4264
+ receipts: [receipt]
4024
4265
  }
4025
4266
  ];
4026
4267
  }
@@ -4077,7 +4318,8 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
4077
4318
  assetId: assetId.toString(),
4078
4319
  amount
4079
4320
  }
4080
- ]
4321
+ ],
4322
+ receipts: [receipt]
4081
4323
  };
4082
4324
  }
4083
4325
  function getTransferOperations({
@@ -4122,11 +4364,11 @@ function getTransferOperations({
4122
4364
  });
4123
4365
  const transferReceipts = getReceiptsByType(
4124
4366
  receipts,
4125
- import_transactions17.ReceiptType.Transfer
4367
+ import_transactions18.ReceiptType.Transfer
4126
4368
  );
4127
4369
  const transferOutReceipts = getReceiptsByType(
4128
4370
  receipts,
4129
- import_transactions17.ReceiptType.TransferOut
4371
+ import_transactions18.ReceiptType.TransferOut
4130
4372
  );
4131
4373
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
4132
4374
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -4210,12 +4452,11 @@ function getOperations({
4210
4452
  }
4211
4453
 
4212
4454
  // src/providers/transaction-summary/receipt.ts
4213
- var import_transactions18 = require("@fuel-ts/transactions");
4214
- var processGqlReceipt = (gqlReceipt) => assembleReceiptByType(gqlReceipt);
4455
+ var import_transactions19 = require("@fuel-ts/transactions");
4215
4456
  var extractMintedAssetsFromReceipts = (receipts) => {
4216
4457
  const mintedAssets = [];
4217
4458
  receipts.forEach((receipt) => {
4218
- if (receipt.type === import_transactions18.ReceiptType.Mint) {
4459
+ if (receipt.type === import_transactions19.ReceiptType.Mint) {
4219
4460
  mintedAssets.push({
4220
4461
  subId: receipt.subId,
4221
4462
  contractId: receipt.contractId,
@@ -4229,7 +4470,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
4229
4470
  var extractBurnedAssetsFromReceipts = (receipts) => {
4230
4471
  const burnedAssets = [];
4231
4472
  receipts.forEach((receipt) => {
4232
- if (receipt.type === import_transactions18.ReceiptType.Burn) {
4473
+ if (receipt.type === import_transactions19.ReceiptType.Burn) {
4233
4474
  burnedAssets.push({
4234
4475
  subId: receipt.subId,
4235
4476
  contractId: receipt.contractId,
@@ -4242,7 +4483,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
4242
4483
  };
4243
4484
 
4244
4485
  // src/providers/transaction-summary/status.ts
4245
- var import_errors17 = require("@fuel-ts/errors");
4486
+ var import_errors18 = require("@fuel-ts/errors");
4246
4487
  var import_math16 = require("@fuel-ts/math");
4247
4488
  var getTransactionStatusName = (gqlStatus) => {
4248
4489
  switch (gqlStatus) {
@@ -4255,8 +4496,8 @@ var getTransactionStatusName = (gqlStatus) => {
4255
4496
  case "SqueezedOutStatus":
4256
4497
  return "squeezedout" /* squeezedout */;
4257
4498
  default:
4258
- throw new import_errors17.FuelError(
4259
- import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
4499
+ throw new import_errors18.FuelError(
4500
+ import_errors18.ErrorCode.INVALID_TRANSACTION_STATUS,
4260
4501
  `Invalid transaction status: ${gqlStatus}.`
4261
4502
  );
4262
4503
  }
@@ -4338,7 +4579,7 @@ function assembleTransactionSummary(params) {
4338
4579
  baseAssetId
4339
4580
  });
4340
4581
  const typeName = getTransactionTypeName(transaction.type);
4341
- const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
4582
+ const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions20.PolicyType.Tip)?.data);
4342
4583
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
4343
4584
  const fee = totalFee ?? calculateTXFeeForSummary({
4344
4585
  gasPrice,
@@ -4388,15 +4629,27 @@ function assembleTransactionSummary(params) {
4388
4629
  }
4389
4630
 
4390
4631
  // src/providers/transaction-response/getDecodedLogs.ts
4391
- var import_abi_coder6 = require("@fuel-ts/abi-coder");
4392
- var import_transactions20 = require("@fuel-ts/transactions");
4632
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
4633
+ var import_configs12 = require("@fuel-ts/address/configs");
4634
+ var import_transactions21 = require("@fuel-ts/transactions");
4393
4635
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4636
+ let mainContract = "";
4637
+ if (mainAbi.programType === "contract") {
4638
+ const firstCallReceipt = receipts.find(
4639
+ (r) => r.type === import_transactions21.ReceiptType.Call && r.id === import_configs12.ZeroBytes32
4640
+ );
4641
+ mainContract = firstCallReceipt.to;
4642
+ }
4394
4643
  return receipts.reduce((logs, receipt) => {
4395
- if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
4396
- const interfaceToUse = new import_abi_coder6.Interface(externalAbis[receipt.id] || mainAbi);
4397
- const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4398
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4399
- logs.push(decodedLog);
4644
+ if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
4645
+ const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
4646
+ const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
4647
+ if (isDecodable) {
4648
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
4649
+ const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4650
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4651
+ logs.push(decodedLog);
4652
+ }
4400
4653
  }
4401
4654
  return logs;
4402
4655
  }, []);
@@ -4408,24 +4661,24 @@ function mapGqlOutputsToTxOutputs(outputs) {
4408
4661
  const obj = "amount" in o ? { ...o, amount: (0, import_math18.bn)(o.amount) } : o;
4409
4662
  switch (obj.type) {
4410
4663
  case "CoinOutput":
4411
- return { ...obj, type: import_transactions21.OutputType.Coin };
4664
+ return { ...obj, type: import_transactions22.OutputType.Coin };
4412
4665
  case "ContractOutput":
4413
4666
  return {
4414
4667
  ...obj,
4415
- type: import_transactions21.OutputType.Contract,
4668
+ type: import_transactions22.OutputType.Contract,
4416
4669
  inputIndex: parseInt(obj.inputIndex, 10)
4417
4670
  };
4418
4671
  case "ChangeOutput":
4419
4672
  return {
4420
4673
  ...obj,
4421
- type: import_transactions21.OutputType.Change
4674
+ type: import_transactions22.OutputType.Change
4422
4675
  };
4423
4676
  case "VariableOutput":
4424
- return { ...obj, type: import_transactions21.OutputType.Variable };
4677
+ return { ...obj, type: import_transactions22.OutputType.Variable };
4425
4678
  case "ContractCreated":
4426
4679
  return {
4427
4680
  ...obj,
4428
- type: import_transactions21.OutputType.ContractCreated,
4681
+ type: import_transactions22.OutputType.ContractCreated,
4429
4682
  contractId: obj.contract
4430
4683
  };
4431
4684
  default:
@@ -4485,7 +4738,7 @@ var TransactionResponse = class {
4485
4738
  const correspondingInput = status.transaction.inputs?.[idx];
4486
4739
  return {
4487
4740
  ...input,
4488
- txPointer: import_transactions21.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
4741
+ txPointer: import_transactions22.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
4489
4742
  };
4490
4743
  }
4491
4744
  return input;
@@ -4516,7 +4769,7 @@ var TransactionResponse = class {
4516
4769
  switch (status?.type) {
4517
4770
  case "SuccessStatus":
4518
4771
  case "FailureStatus":
4519
- return status.receipts.map(processGqlReceipt);
4772
+ return status.receipts.map(deserializeReceipt);
4520
4773
  default:
4521
4774
  return [];
4522
4775
  }
@@ -4552,7 +4805,7 @@ var TransactionResponse = class {
4552
4805
  * @returns The decoded transaction.
4553
4806
  */
4554
4807
  decodeTransaction(transactionWithReceipts) {
4555
- return new import_transactions21.TransactionCoder().decode(
4808
+ return new import_transactions22.TransactionCoder().decode(
4556
4809
  (0, import_utils27.arrayify)(transactionWithReceipts.rawPayload),
4557
4810
  0
4558
4811
  )?.[0];
@@ -4601,8 +4854,8 @@ var TransactionResponse = class {
4601
4854
  this.status = statusChange;
4602
4855
  if (statusChange.type === "SqueezedOutStatus") {
4603
4856
  this.unsetResourceCache();
4604
- throw new import_errors18.FuelError(
4605
- import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4857
+ throw new import_errors19.FuelError(
4858
+ import_errors19.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4606
4859
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4607
4860
  );
4608
4861
  }
@@ -4640,7 +4893,6 @@ var TransactionResponse = class {
4640
4893
  const { receipts } = transactionResult;
4641
4894
  const status = this.status ?? this.gqlTransaction?.status;
4642
4895
  if (status?.type === "FailureStatus") {
4643
- this.unsetResourceCache();
4644
4896
  const { reason } = status;
4645
4897
  throw extractTxError({
4646
4898
  receipts,
@@ -4657,6 +4909,7 @@ var TransactionResponse = class {
4657
4909
  */
4658
4910
  async waitForResult(contractsAbiMap) {
4659
4911
  await this.waitForStatusChange();
4912
+ this.unsetResourceCache();
4660
4913
  return this.assembleResult(contractsAbiMap);
4661
4914
  }
4662
4915
  /**
@@ -4709,32 +4962,48 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4709
4962
  };
4710
4963
  }
4711
4964
 
4965
+ // src/providers/utils/helpers.ts
4966
+ var adjustResourcesToExclude = (params) => {
4967
+ const { userInput, cached, maxInputs } = params;
4968
+ const final = { ...userInput };
4969
+ let total = final.utxos.length + final.messages.length;
4970
+ if (total >= maxInputs) {
4971
+ return final;
4972
+ }
4973
+ final.utxos = [...final.utxos, ...cached.utxos.slice(0, maxInputs - total)];
4974
+ total = final.utxos.length + final.messages.length;
4975
+ if (total < maxInputs) {
4976
+ final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
4977
+ }
4978
+ return final;
4979
+ };
4980
+
4712
4981
  // src/providers/utils/validate-pagination-args.ts
4713
- var import_errors19 = require("@fuel-ts/errors");
4982
+ var import_errors20 = require("@fuel-ts/errors");
4714
4983
  var validatePaginationArgs = (params) => {
4715
4984
  const { paginationLimit, inputArgs = {} } = params;
4716
4985
  const { first, last, after, before } = inputArgs;
4717
4986
  if (after && before) {
4718
- throw new import_errors19.FuelError(
4719
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4987
+ throw new import_errors20.FuelError(
4988
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4720
4989
  'Pagination arguments "after" and "before" cannot be used together'
4721
4990
  );
4722
4991
  }
4723
4992
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4724
- throw new import_errors19.FuelError(
4725
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4993
+ throw new import_errors20.FuelError(
4994
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4726
4995
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
4727
4996
  );
4728
4997
  }
4729
4998
  if (first && before) {
4730
- throw new import_errors19.FuelError(
4731
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4999
+ throw new import_errors20.FuelError(
5000
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4732
5001
  'The use of pagination argument "first" with "before" is not supported'
4733
5002
  );
4734
5003
  }
4735
5004
  if (last && after) {
4736
- throw new import_errors19.FuelError(
4737
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5005
+ throw new import_errors20.FuelError(
5006
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4738
5007
  'The use of pagination argument "last" with "after" is not supported'
4739
5008
  );
4740
5009
  }
@@ -4748,64 +5017,10 @@ var validatePaginationArgs = (params) => {
4748
5017
  var MAX_RETRIES = 10;
4749
5018
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
4750
5019
  var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
5020
+ var BALANCES_PAGE_SIZE_LIMIT = 100;
4751
5021
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
4752
5022
  var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
4753
5023
  var GAS_USED_MODIFIER = 1.2;
4754
- var processGqlChain = (chain) => {
4755
- const { name, daHeight, consensusParameters } = chain;
4756
- const {
4757
- contractParams,
4758
- feeParams,
4759
- predicateParams,
4760
- scriptParams,
4761
- txParams,
4762
- gasCosts,
4763
- baseAssetId,
4764
- chainId,
4765
- version
4766
- } = consensusParameters;
4767
- return {
4768
- name,
4769
- baseChainHeight: (0, import_math19.bn)(daHeight),
4770
- consensusParameters: {
4771
- version,
4772
- chainId: (0, import_math19.bn)(chainId),
4773
- baseAssetId,
4774
- feeParameters: {
4775
- version: feeParams.version,
4776
- gasPerByte: (0, import_math19.bn)(feeParams.gasPerByte),
4777
- gasPriceFactor: (0, import_math19.bn)(feeParams.gasPriceFactor)
4778
- },
4779
- contractParameters: {
4780
- version: contractParams.version,
4781
- contractMaxSize: (0, import_math19.bn)(contractParams.contractMaxSize),
4782
- maxStorageSlots: (0, import_math19.bn)(contractParams.maxStorageSlots)
4783
- },
4784
- txParameters: {
4785
- version: txParams.version,
4786
- maxInputs: (0, import_math19.bn)(txParams.maxInputs),
4787
- maxOutputs: (0, import_math19.bn)(txParams.maxOutputs),
4788
- maxWitnesses: (0, import_math19.bn)(txParams.maxWitnesses),
4789
- maxGasPerTx: (0, import_math19.bn)(txParams.maxGasPerTx),
4790
- maxSize: (0, import_math19.bn)(txParams.maxSize),
4791
- maxBytecodeSubsections: (0, import_math19.bn)(txParams.maxBytecodeSubsections)
4792
- },
4793
- predicateParameters: {
4794
- version: predicateParams.version,
4795
- maxPredicateLength: (0, import_math19.bn)(predicateParams.maxPredicateLength),
4796
- maxPredicateDataLength: (0, import_math19.bn)(predicateParams.maxPredicateDataLength),
4797
- maxGasPerPredicate: (0, import_math19.bn)(predicateParams.maxGasPerPredicate),
4798
- maxMessageDataLength: (0, import_math19.bn)(predicateParams.maxMessageDataLength)
4799
- },
4800
- scriptParameters: {
4801
- version: scriptParams.version,
4802
- maxScriptLength: (0, import_math19.bn)(scriptParams.maxScriptLength),
4803
- maxScriptDataLength: (0, import_math19.bn)(scriptParams.maxScriptDataLength)
4804
- },
4805
- gasCosts
4806
- }
4807
- };
4808
- };
4809
5024
  var _cacheInputs, cacheInputs_fn;
4810
5025
  var _Provider = class {
4811
5026
  /**
@@ -4827,13 +5042,19 @@ var _Provider = class {
4827
5042
  /** @hidden */
4828
5043
  __publicField(this, "urlWithoutAuth");
4829
5044
  /** @hidden */
5045
+ __publicField(this, "features", {
5046
+ balancePagination: false,
5047
+ amount128: false
5048
+ });
5049
+ /** @hidden */
4830
5050
  __publicField(this, "consensusParametersTimestamp");
4831
5051
  __publicField(this, "options", {
4832
5052
  timeout: void 0,
4833
5053
  resourceCacheTTL: void 0,
4834
5054
  fetch: void 0,
4835
5055
  retryOptions: void 0,
4836
- headers: void 0
5056
+ headers: void 0,
5057
+ cache: void 0
4837
5058
  });
4838
5059
  const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
4839
5060
  this.url = rawUrl;
@@ -4847,7 +5068,13 @@ var _Provider = class {
4847
5068
  headers
4848
5069
  };
4849
5070
  this.operations = this.createOperations();
4850
- const { resourceCacheTTL } = this.options;
5071
+ const { resourceCacheTTL, cache: cache2 } = this.options;
5072
+ if (cache2) {
5073
+ const { consensusParametersTimestamp, chain, nodeInfo } = deserializeProviderCache(cache2);
5074
+ this.consensusParametersTimestamp = consensusParametersTimestamp;
5075
+ _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
5076
+ _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
5077
+ }
4851
5078
  if ((0, import_utils30.isDefined)(resourceCacheTTL)) {
4852
5079
  if (resourceCacheTTL !== -1) {
4853
5080
  this.cache = new ResourceCache(resourceCacheTTL);
@@ -4860,6 +5087,7 @@ var _Provider = class {
4860
5087
  }
4861
5088
  /** @hidden */
4862
5089
  static clearChainAndNodeCaches() {
5090
+ _Provider.inflightFetchChainAndNodeInfoRequests = {};
4863
5091
  _Provider.nodeInfoCache = {};
4864
5092
  _Provider.chainInfoCache = {};
4865
5093
  }
@@ -4888,7 +5116,7 @@ var _Provider = class {
4888
5116
  try {
4889
5117
  parsedUrl = new URL(url);
4890
5118
  } catch (error) {
4891
- throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
5119
+ throw new import_errors21.FuelError(import_errors21.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4892
5120
  }
4893
5121
  const username = parsedUrl.username;
4894
5122
  const password = parsedUrl.password;
@@ -4906,7 +5134,8 @@ var _Provider = class {
4906
5134
  * Initialize Provider async stuff
4907
5135
  */
4908
5136
  async init() {
4909
- await this.fetchChainAndNodeInfo();
5137
+ const { nodeInfo } = await this.fetchChainAndNodeInfo();
5138
+ this.setupFeatures(nodeInfo.nodeVersion);
4910
5139
  return this;
4911
5140
  }
4912
5141
  /**
@@ -4976,19 +5205,24 @@ var _Provider = class {
4976
5205
  throw new Error(`Jumps to the catch block and re-fetch`);
4977
5206
  }
4978
5207
  } catch (_err) {
5208
+ const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5209
+ if (inflightRequest) {
5210
+ const now2 = await inflightRequest;
5211
+ this.consensusParametersTimestamp = now2;
5212
+ return this.fetchChainAndNodeInfo();
5213
+ }
5214
+ const { promise, resolve } = deferPromise();
5215
+ _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
4979
5216
  const data = await this.operations.getChainAndNodeInfo();
4980
- nodeInfo = {
4981
- maxDepth: (0, import_math19.bn)(data.nodeInfo.maxDepth),
4982
- maxTx: (0, import_math19.bn)(data.nodeInfo.maxTx),
4983
- nodeVersion: data.nodeInfo.nodeVersion,
4984
- utxoValidation: data.nodeInfo.utxoValidation,
4985
- vmBacktrace: data.nodeInfo.vmBacktrace
4986
- };
5217
+ nodeInfo = deserializeNodeInfo(data.nodeInfo);
5218
+ chain = deserializeChain(data.chain);
4987
5219
  _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
4988
- chain = processGqlChain(data.chain);
4989
5220
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
4990
5221
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
4991
- this.consensusParametersTimestamp = Date.now();
5222
+ const now = Date.now();
5223
+ this.consensusParametersTimestamp = now;
5224
+ resolve(now);
5225
+ delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
4992
5226
  }
4993
5227
  return {
4994
5228
  chain,
@@ -5063,6 +5297,15 @@ var _Provider = class {
5063
5297
  });
5064
5298
  return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
5065
5299
  }
5300
+ /**
5301
+ * @hidden
5302
+ */
5303
+ setupFeatures(nodeVersion) {
5304
+ if ((0, import_versions.gte)(nodeVersion, "0.41.0")) {
5305
+ this.features.balancePagination = true;
5306
+ this.features.amount128 = true;
5307
+ }
5308
+ }
5066
5309
  /**
5067
5310
  * Returns the version of the connected node.
5068
5311
  *
@@ -5094,13 +5337,7 @@ var _Provider = class {
5094
5337
  */
5095
5338
  async fetchNode() {
5096
5339
  const { nodeInfo } = await this.operations.getNodeInfo();
5097
- const processedNodeInfo = {
5098
- maxDepth: (0, import_math19.bn)(nodeInfo.maxDepth),
5099
- maxTx: (0, import_math19.bn)(nodeInfo.maxTx),
5100
- nodeVersion: nodeInfo.nodeVersion,
5101
- utxoValidation: nodeInfo.utxoValidation,
5102
- vmBacktrace: nodeInfo.vmBacktrace
5103
- };
5340
+ const processedNodeInfo = deserializeNodeInfo(nodeInfo);
5104
5341
  _Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
5105
5342
  return processedNodeInfo;
5106
5343
  }
@@ -5111,7 +5348,7 @@ var _Provider = class {
5111
5348
  */
5112
5349
  async fetchChain() {
5113
5350
  const { chain } = await this.operations.getChain();
5114
- const processedChain = processGqlChain(chain);
5351
+ const processedChain = deserializeChain(chain);
5115
5352
  _Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
5116
5353
  return processedChain;
5117
5354
  }
@@ -5138,6 +5375,21 @@ var _Provider = class {
5138
5375
  } = all;
5139
5376
  return baseAssetId;
5140
5377
  }
5378
+ /**
5379
+ * Retrieves the details of an asset given its ID.
5380
+ *
5381
+ * @param assetId - The unique identifier of the asset.
5382
+ * @returns A promise that resolves to an object containing the asset details.
5383
+ */
5384
+ async getAssetDetails(assetId) {
5385
+ const { assetDetails } = await this.operations.getAssetDetails({ assetId });
5386
+ const { contractId, subId, totalSupply } = assetDetails;
5387
+ return {
5388
+ subId,
5389
+ contractId,
5390
+ totalSupply: (0, import_math19.bn)(totalSupply)
5391
+ };
5392
+ }
5141
5393
  /**
5142
5394
  * @hidden
5143
5395
  */
@@ -5148,14 +5400,14 @@ var _Provider = class {
5148
5400
  }
5149
5401
  } = await this.getChain();
5150
5402
  if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
5151
- throw new import_errors20.FuelError(
5152
- import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
5403
+ throw new import_errors21.FuelError(
5404
+ import_errors21.ErrorCode.MAX_INPUTS_EXCEEDED,
5153
5405
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
5154
5406
  );
5155
5407
  }
5156
5408
  if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
5157
- throw new import_errors20.FuelError(
5158
- import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5409
+ throw new import_errors21.FuelError(
5410
+ import_errors21.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5159
5411
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
5160
5412
  );
5161
5413
  }
@@ -5212,22 +5464,20 @@ var _Provider = class {
5212
5464
  utxoValidation: utxoValidation || false
5213
5465
  });
5214
5466
  const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
5215
- const receipts = rawReceipts.map(processGqlReceipt);
5467
+ const receipts = rawReceipts.map(deserializeReceipt);
5216
5468
  return { receipts, dryRunStatus };
5217
5469
  }
5218
5470
  /**
5219
- * Verifies whether enough gas is available to complete transaction.
5471
+ * Estimates the gas usage for predicates in a transaction request.
5220
5472
  *
5221
5473
  * @template T - The type of the transaction request object.
5222
5474
  *
5223
- * @param transactionRequest - The transaction request object.
5224
- * @returns A promise that resolves to the estimated transaction request object.
5475
+ * @param transactionRequest - The transaction request to estimate predicates for.
5476
+ * @returns A promise that resolves to the updated transaction request with estimated gas usage for predicates.
5225
5477
  */
5226
5478
  async estimatePredicates(transactionRequest) {
5227
- const shouldEstimatePredicates = Boolean(
5228
- transactionRequest.inputs.find(
5229
- (input) => "predicate" in input && input.predicate && !(0, import_utils31.equalBytes)((0, import_utils30.arrayify)(input.predicate), (0, import_utils30.arrayify)("0x")) && new import_math19.BN(input.predicateGasUsed).isZero()
5230
- )
5479
+ const shouldEstimatePredicates = transactionRequest.inputs.some(
5480
+ (input) => isPredicate(input) && (0, import_math19.bn)(input.predicateGasUsed).isZero()
5231
5481
  );
5232
5482
  if (!shouldEstimatePredicates) {
5233
5483
  return transactionRequest;
@@ -5236,18 +5486,42 @@ var _Provider = class {
5236
5486
  const response = await this.operations.estimatePredicates({
5237
5487
  encodedTransaction
5238
5488
  });
5239
- const {
5240
- estimatePredicates: { inputs }
5241
- } = response;
5242
- if (inputs) {
5243
- inputs.forEach((input, index) => {
5244
- if ("predicateGasUsed" in input && (0, import_math19.bn)(input.predicateGasUsed).gt(0)) {
5245
- transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
5246
- }
5247
- });
5248
- }
5489
+ const { estimatePredicates } = response;
5490
+ transactionRequest = this.parseEstimatePredicatesResponse(
5491
+ transactionRequest,
5492
+ estimatePredicates
5493
+ );
5249
5494
  return transactionRequest;
5250
5495
  }
5496
+ /**
5497
+ * Estimates the gas price and predicates for a given transaction request and block horizon.
5498
+ *
5499
+ * @param transactionRequest - The transaction request to estimate predicates and gas price for.
5500
+ * @param blockHorizon - The block horizon to use for gas price estimation.
5501
+ * @returns A promise that resolves to an object containing the updated transaction
5502
+ * request and the estimated gas price.
5503
+ */
5504
+ async estimatePredicatesAndGasPrice(transactionRequest, blockHorizon) {
5505
+ const shouldEstimatePredicates = transactionRequest.inputs.some(
5506
+ (input) => isPredicate(input) && (0, import_math19.bn)(input.predicateGasUsed).isZero()
5507
+ );
5508
+ if (!shouldEstimatePredicates) {
5509
+ const gasPrice2 = await this.estimateGasPrice(blockHorizon);
5510
+ return { transactionRequest, gasPrice: gasPrice2 };
5511
+ }
5512
+ const {
5513
+ estimateGasPrice: { gasPrice },
5514
+ estimatePredicates
5515
+ } = await this.operations.estimatePredicatesAndGasPrice({
5516
+ blockHorizon: String(blockHorizon),
5517
+ encodedTransaction: (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())
5518
+ });
5519
+ transactionRequest = this.parseEstimatePredicatesResponse(
5520
+ transactionRequest,
5521
+ estimatePredicates
5522
+ );
5523
+ return { transactionRequest, gasPrice: (0, import_math19.bn)(gasPrice) };
5524
+ }
5251
5525
  /**
5252
5526
  * Will dryRun a transaction and check for missing dependencies.
5253
5527
  *
@@ -5261,11 +5535,13 @@ var _Provider = class {
5261
5535
  async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
5262
5536
  if (isTransactionTypeCreate(transactionRequest)) {
5263
5537
  return {
5538
+ rawReceipts: [],
5264
5539
  receipts: [],
5265
5540
  outputVariables: 0,
5266
5541
  missingContractIds: []
5267
5542
  };
5268
5543
  }
5544
+ let rawReceipts = [];
5269
5545
  let receipts = [];
5270
5546
  const missingContractIds = [];
5271
5547
  let outputVariables = 0;
@@ -5274,13 +5550,14 @@ var _Provider = class {
5274
5550
  const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
5275
5551
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5276
5552
  const {
5277
- dryRun: [{ receipts: rawReceipts, status }]
5553
+ dryRun: [{ receipts: serializedReceipts, status }]
5278
5554
  } = await this.operations.dryRun({
5279
5555
  encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
5280
5556
  utxoValidation: false,
5281
5557
  gasPrice: gasPrice.toString()
5282
5558
  });
5283
- receipts = rawReceipts.map(processGqlReceipt);
5559
+ rawReceipts = serializedReceipts;
5560
+ receipts = serializedReceipts.map(deserializeReceipt);
5284
5561
  dryRunStatus = status;
5285
5562
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
5286
5563
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
@@ -5301,6 +5578,7 @@ var _Provider = class {
5301
5578
  }
5302
5579
  }
5303
5580
  return {
5581
+ rawReceipts,
5304
5582
  receipts,
5305
5583
  outputVariables,
5306
5584
  missingContractIds,
@@ -5319,6 +5597,7 @@ var _Provider = class {
5319
5597
  */
5320
5598
  async estimateMultipleTxDependencies(transactionRequests) {
5321
5599
  const results = transactionRequests.map(() => ({
5600
+ rawReceipts: [],
5322
5601
  receipts: [],
5323
5602
  outputVariables: 0,
5324
5603
  missingContractIds: [],
@@ -5346,7 +5625,7 @@ var _Provider = class {
5346
5625
  const requestIdx = transactionsToProcess[i];
5347
5626
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
5348
5627
  const result = results[requestIdx];
5349
- result.receipts = rawReceipts.map(processGqlReceipt);
5628
+ result.receipts = rawReceipts.map(deserializeReceipt);
5350
5629
  result.dryRunStatus = status;
5351
5630
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
5352
5631
  result.receipts
@@ -5391,7 +5670,7 @@ var _Provider = class {
5391
5670
  utxoValidation: utxoValidation || false
5392
5671
  });
5393
5672
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
5394
- const receipts = rawReceipts.map(processGqlReceipt);
5673
+ const receipts = rawReceipts.map(deserializeReceipt);
5395
5674
  return { receipts, dryRunStatus: status };
5396
5675
  });
5397
5676
  return results;
@@ -5492,7 +5771,7 @@ var _Provider = class {
5492
5771
  });
5493
5772
  const callResult = dryRunStatuses.map((dryRunStatus) => {
5494
5773
  const { id, receipts, status } = dryRunStatus;
5495
- const processedReceipts = receipts.map(processGqlReceipt);
5774
+ const processedReceipts = receipts.map(deserializeReceipt);
5496
5775
  return { id, receipts: processedReceipts, status };
5497
5776
  });
5498
5777
  return { receipts: callResult[0].receipts };
@@ -5523,14 +5802,20 @@ var _Provider = class {
5523
5802
  await signatureCallback(signedRequest);
5524
5803
  addedSignatures = signedRequest.witnesses.length - lengthBefore;
5525
5804
  }
5526
- await this.estimatePredicates(signedRequest);
5805
+ let gasPrice;
5806
+ if (gasPriceParam) {
5807
+ gasPrice = gasPriceParam;
5808
+ await this.estimatePredicates(signedRequest);
5809
+ } else {
5810
+ ({ gasPrice } = await this.estimatePredicatesAndGasPrice(signedRequest, 10));
5811
+ }
5527
5812
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
5528
- const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
5529
5813
  let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
5530
5814
  // Fetches and returns a gas price
5531
5815
  transactionRequest: signedRequest,
5532
5816
  gasPrice
5533
5817
  });
5818
+ let rawReceipts = [];
5534
5819
  let receipts = [];
5535
5820
  let dryRunStatus;
5536
5821
  let missingContractIds = [];
@@ -5542,7 +5827,7 @@ var _Provider = class {
5542
5827
  if (signatureCallback) {
5543
5828
  await signatureCallback(txRequestClone);
5544
5829
  }
5545
- ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
5830
+ ({ rawReceipts, receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
5546
5831
  if (dryRunStatus && "reason" in dryRunStatus) {
5547
5832
  throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
5548
5833
  }
@@ -5555,7 +5840,12 @@ var _Provider = class {
5555
5840
  gasPrice
5556
5841
  }));
5557
5842
  }
5843
+ const transactionSummary = {
5844
+ gasPrice: gasPrice.toString(),
5845
+ receipts: rawReceipts
5846
+ };
5558
5847
  return {
5848
+ rawReceipts,
5559
5849
  receipts,
5560
5850
  gasUsed,
5561
5851
  gasPrice,
@@ -5568,7 +5858,8 @@ var _Provider = class {
5568
5858
  addedSignatures,
5569
5859
  estimatedPredicates: txRequestClone.inputs,
5570
5860
  dryRunStatus,
5571
- updateMaxFee
5861
+ updateMaxFee,
5862
+ transactionSummary
5572
5863
  };
5573
5864
  }
5574
5865
  /**
@@ -5614,23 +5905,33 @@ var _Provider = class {
5614
5905
  */
5615
5906
  async getResourcesToSpend(owner, quantities, excludedIds) {
5616
5907
  const ownerAddress = new import_address4.Address(owner);
5617
- const excludeInput = {
5908
+ let idsToExclude = {
5618
5909
  messages: excludedIds?.messages?.map((nonce) => (0, import_utils30.hexlify)(nonce)) || [],
5619
5910
  utxos: excludedIds?.utxos?.map((id) => (0, import_utils30.hexlify)(id)) || []
5620
5911
  };
5621
5912
  if (this.cache) {
5622
- const cached = this.cache.getActiveData();
5623
- excludeInput.messages.push(...cached.messages);
5624
- excludeInput.utxos.push(...cached.utxos);
5913
+ const cached = this.cache.getActiveData(ownerAddress.toB256());
5914
+ if (cached.utxos.length || cached.messages.length) {
5915
+ const {
5916
+ consensusParameters: {
5917
+ txParameters: { maxInputs }
5918
+ }
5919
+ } = await this.getChain();
5920
+ idsToExclude = adjustResourcesToExclude({
5921
+ userInput: idsToExclude,
5922
+ cached,
5923
+ maxInputs: maxInputs.toNumber()
5924
+ });
5925
+ }
5625
5926
  }
5626
5927
  const coinsQuery = {
5627
5928
  owner: ownerAddress.toB256(),
5628
5929
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
5629
5930
  assetId: (0, import_utils30.hexlify)(assetId),
5630
- amount: amount.toString(10),
5931
+ amount: (amount.eqn(0) ? (0, import_math19.bn)(1) : amount).toString(10),
5631
5932
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
5632
5933
  })),
5633
- excludedIds: excludeInput
5934
+ excludedIds: idsToExclude
5634
5935
  };
5635
5936
  const result = await this.operations.getCoinsToSpend(coinsQuery);
5636
5937
  const coins = result.coinsToSpend.flat().map((coin) => {
@@ -5688,7 +5989,7 @@ var _Provider = class {
5688
5989
  } = await this.operations.getLatestBlock();
5689
5990
  block = latestBlock;
5690
5991
  } else {
5691
- const isblockId = typeof idOrHeight === "string" && idOrHeight.length === 66;
5992
+ const isblockId = typeof idOrHeight === "string" && (0, import_address4.isB256)(idOrHeight);
5692
5993
  const variables = isblockId ? { blockId: idOrHeight } : { height: (0, import_math19.bn)(idOrHeight).toString(10) };
5693
5994
  const response = await this.operations.getBlock(variables);
5694
5995
  block = response.block;
@@ -5759,8 +6060,10 @@ var _Provider = class {
5759
6060
  variables = { blockHeight: (0, import_math19.bn)(idOrHeight).toString(10) };
5760
6061
  } else if (idOrHeight === "latest") {
5761
6062
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
5762
- } else {
6063
+ } else if (typeof idOrHeight === "string" && (0, import_address4.isB256)(idOrHeight)) {
5763
6064
  variables = { blockId: idOrHeight };
6065
+ } else {
6066
+ variables = { blockHeight: (0, import_math19.bn)(idOrHeight).toString() };
5764
6067
  }
5765
6068
  const { block } = await this.operations.getBlockWithTransactions(variables);
5766
6069
  if (!block) {
@@ -5782,7 +6085,7 @@ var _Provider = class {
5782
6085
  },
5783
6086
  transactionIds: block.transactions.map((tx) => tx.id),
5784
6087
  transactions: block.transactions.map(
5785
- (tx) => new import_transactions22.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
6088
+ (tx) => new import_transactions23.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
5786
6089
  )
5787
6090
  };
5788
6091
  }
@@ -5798,12 +6101,12 @@ var _Provider = class {
5798
6101
  return null;
5799
6102
  }
5800
6103
  try {
5801
- return new import_transactions22.TransactionCoder().decode(
6104
+ return new import_transactions23.TransactionCoder().decode(
5802
6105
  (0, import_utils30.arrayify)(transaction.rawPayload),
5803
6106
  0
5804
6107
  )?.[0];
5805
6108
  } catch (error) {
5806
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6109
+ if (error instanceof import_errors21.FuelError && error.code === import_errors21.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5807
6110
  console.warn("Unsupported transaction type encountered");
5808
6111
  return null;
5809
6112
  }
@@ -5824,12 +6127,12 @@ var _Provider = class {
5824
6127
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5825
6128
  })
5826
6129
  });
5827
- const coder = new import_transactions22.TransactionCoder();
6130
+ const coder = new import_transactions23.TransactionCoder();
5828
6131
  const transactions = edges.map(({ node: { rawPayload } }) => {
5829
6132
  try {
5830
6133
  return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
5831
6134
  } catch (error) {
5832
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6135
+ if (error instanceof import_errors21.FuelError && error.code === import_errors21.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5833
6136
  console.warn("Unsupported transaction type encountered");
5834
6137
  return null;
5835
6138
  }
@@ -5888,11 +6191,20 @@ var _Provider = class {
5888
6191
  * @returns A promise that resolves to the balance.
5889
6192
  */
5890
6193
  async getBalance(owner, assetId) {
5891
- const { balance } = await this.operations.getBalance({
5892
- owner: new import_address4.Address(owner).toB256(),
5893
- assetId: (0, import_utils30.hexlify)(assetId)
6194
+ const ownerStr = new import_address4.Address(owner).toB256();
6195
+ const assetIdStr = (0, import_utils30.hexlify)(assetId);
6196
+ if (!this.features.amount128) {
6197
+ const { balance: balance2 } = await this.operations.getBalance({
6198
+ owner: ownerStr,
6199
+ assetId: assetIdStr
6200
+ });
6201
+ return (0, import_math19.bn)(balance2.amount, 10);
6202
+ }
6203
+ const { balance } = await this.operations.getBalanceV2({
6204
+ owner: ownerStr,
6205
+ assetId: assetIdStr
5894
6206
  });
5895
- return (0, import_math19.bn)(balance.amount, 10);
6207
+ return (0, import_math19.bn)(balance.amountU128, 10);
5896
6208
  }
5897
6209
  /**
5898
6210
  * Returns balances for the given owner.
@@ -5901,7 +6213,16 @@ var _Provider = class {
5901
6213
  * @param paginationArgs - Pagination arguments (optional).
5902
6214
  * @returns A promise that resolves to the balances.
5903
6215
  */
5904
- async getBalances(owner) {
6216
+ async getBalances(owner, paginationArgs) {
6217
+ if (!this.features.balancePagination) {
6218
+ return this.getBalancesV1(owner, paginationArgs);
6219
+ }
6220
+ return this.getBalancesV2(owner, paginationArgs);
6221
+ }
6222
+ /**
6223
+ * @hidden
6224
+ */
6225
+ async getBalancesV1(owner, _paginationArgs) {
5905
6226
  const {
5906
6227
  balances: { edges }
5907
6228
  } = await this.operations.getBalances({
@@ -5918,6 +6239,25 @@ var _Provider = class {
5918
6239
  }));
5919
6240
  return { balances };
5920
6241
  }
6242
+ /**
6243
+ * @hidden
6244
+ */
6245
+ async getBalancesV2(owner, paginationArgs) {
6246
+ const {
6247
+ balances: { edges, pageInfo }
6248
+ } = await this.operations.getBalancesV2({
6249
+ ...validatePaginationArgs({
6250
+ inputArgs: paginationArgs,
6251
+ paginationLimit: BALANCES_PAGE_SIZE_LIMIT
6252
+ }),
6253
+ filter: { owner: new import_address4.Address(owner).toB256() }
6254
+ });
6255
+ const balances = edges.map(({ node }) => ({
6256
+ assetId: node.assetId,
6257
+ amount: (0, import_math19.bn)(node.amountU128)
6258
+ }));
6259
+ return { balances, pageInfo };
6260
+ }
5921
6261
  /**
5922
6262
  * Returns message for the given address.
5923
6263
  *
@@ -5936,7 +6276,7 @@ var _Provider = class {
5936
6276
  owner: new import_address4.Address(address).toB256()
5937
6277
  });
5938
6278
  const messages = edges.map(({ node }) => ({
5939
- messageId: import_transactions22.InputMessageCoder.getMessageId({
6279
+ messageId: import_transactions23.InputMessageCoder.getMessageId({
5940
6280
  sender: node.sender,
5941
6281
  recipient: node.recipient,
5942
6282
  nonce: node.nonce,
@@ -5947,7 +6287,7 @@ var _Provider = class {
5947
6287
  recipient: new import_address4.Address(node.recipient),
5948
6288
  nonce: node.nonce,
5949
6289
  amount: (0, import_math19.bn)(node.amount),
5950
- data: import_transactions22.InputMessageCoder.decodeData(node.data),
6290
+ data: import_transactions23.InputMessageCoder.decodeData(node.data),
5951
6291
  daHeight: (0, import_math19.bn)(node.daHeight)
5952
6292
  }));
5953
6293
  return {
@@ -5970,8 +6310,8 @@ var _Provider = class {
5970
6310
  nonce
5971
6311
  };
5972
6312
  if (commitBlockId && commitBlockHeight) {
5973
- throw new import_errors20.FuelError(
5974
- import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
6313
+ throw new import_errors21.FuelError(
6314
+ import_errors21.ErrorCode.INVALID_INPUT_PARAMETERS,
5975
6315
  "commitBlockId and commitBlockHeight cannot be used together"
5976
6316
  );
5977
6317
  }
@@ -5984,15 +6324,12 @@ var _Provider = class {
5984
6324
  if (commitBlockHeight) {
5985
6325
  inputObject = {
5986
6326
  ...inputObject,
5987
- // Conver BN into a number string required on the query
5988
- // This should problably be fixed on the fuel client side
6327
+ // Convert BN into a number string required on the query
6328
+ // This should probably be fixed on the fuel client side
5989
6329
  commitBlockHeight: commitBlockHeight.toNumber().toString()
5990
6330
  };
5991
6331
  }
5992
6332
  const result = await this.operations.getMessageProof(inputObject);
5993
- if (!result.messageProof) {
5994
- return null;
5995
- }
5996
6333
  const {
5997
6334
  messageProof,
5998
6335
  messageBlockHeader,
@@ -6101,16 +6438,15 @@ var _Provider = class {
6101
6438
  * @returns A promise that resolves to the result of the check.
6102
6439
  */
6103
6440
  async isUserAccount(id) {
6104
- const { contract, blob, transaction } = await this.operations.isUserAccount({
6105
- blobId: id,
6106
- contractId: id,
6107
- transactionId: id
6108
- });
6109
- if (contract || blob || transaction) {
6110
- return false;
6111
- }
6112
- return true;
6441
+ const type = await this.getAddressType(id);
6442
+ return type === "Account";
6113
6443
  }
6444
+ /**
6445
+ * Determines the type of address based on the provided ID.
6446
+ *
6447
+ * @param id - The ID to be checked.
6448
+ * @returns A promise that resolves to a string indicating the type of address.
6449
+ */
6114
6450
  async getAddressType(id) {
6115
6451
  const { contract, blob, transaction } = await this.operations.isUserAccount({
6116
6452
  blobId: id,
@@ -6126,6 +6462,13 @@ var _Provider = class {
6126
6462
  if (transaction) {
6127
6463
  return "Transaction";
6128
6464
  }
6465
+ try {
6466
+ const asset = await this.getAssetDetails(id);
6467
+ if (asset) {
6468
+ return "Asset";
6469
+ }
6470
+ } catch (e) {
6471
+ }
6129
6472
  return "Account";
6130
6473
  }
6131
6474
  /**
@@ -6150,7 +6493,7 @@ var _Provider = class {
6150
6493
  return null;
6151
6494
  }
6152
6495
  const message = {
6153
- messageId: import_transactions22.InputMessageCoder.getMessageId({
6496
+ messageId: import_transactions23.InputMessageCoder.getMessageId({
6154
6497
  sender: rawMessage.sender,
6155
6498
  recipient: rawMessage.recipient,
6156
6499
  nonce,
@@ -6161,7 +6504,7 @@ var _Provider = class {
6161
6504
  recipient: new import_address4.Address(rawMessage.recipient),
6162
6505
  nonce,
6163
6506
  amount: (0, import_math19.bn)(rawMessage.amount),
6164
- data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
6507
+ data: import_transactions23.InputMessageCoder.decodeData(rawMessage.data),
6165
6508
  daHeight: (0, import_math19.bn)(rawMessage.daHeight)
6166
6509
  };
6167
6510
  return message;
@@ -6200,6 +6543,19 @@ var _Provider = class {
6200
6543
  statusReason: status.reason
6201
6544
  });
6202
6545
  }
6546
+ /**
6547
+ * @hidden
6548
+ */
6549
+ parseEstimatePredicatesResponse(transactionRequest, { inputs }) {
6550
+ if (inputs) {
6551
+ inputs.forEach((input, i) => {
6552
+ if (input && "predicateGasUsed" in input && (0, import_math19.bn)(input.predicateGasUsed).gt(0)) {
6553
+ transactionRequest.inputs[i].predicateGasUsed = input.predicateGasUsed;
6554
+ }
6555
+ });
6556
+ }
6557
+ return transactionRequest;
6558
+ }
6203
6559
  };
6204
6560
  var Provider = _Provider;
6205
6561
  _cacheInputs = new WeakSet();
@@ -6207,20 +6563,11 @@ cacheInputs_fn = function(inputs, transactionId) {
6207
6563
  if (!this.cache) {
6208
6564
  return;
6209
6565
  }
6210
- const inputsToCache = inputs.reduce(
6211
- (acc, input) => {
6212
- if (input.type === import_transactions22.InputType.Coin) {
6213
- acc.utxos.push(input.id);
6214
- } else if (input.type === import_transactions22.InputType.Message) {
6215
- acc.messages.push(input.nonce);
6216
- }
6217
- return acc;
6218
- },
6219
- { utxos: [], messages: [] }
6220
- );
6221
- this.cache.set(transactionId, inputsToCache);
6566
+ this.cache.set(transactionId, inputs);
6222
6567
  };
6223
6568
  /** @hidden */
6569
+ __publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
6570
+ /** @hidden */
6224
6571
  __publicField(Provider, "chainInfoCache", {});
6225
6572
  /** @hidden */
6226
6573
  __publicField(Provider, "nodeInfoCache", {});
@@ -6228,9 +6575,14 @@ __publicField(Provider, "nodeInfoCache", {});
6228
6575
  __publicField(Provider, "incompatibleNodeVersionMessage", "");
6229
6576
 
6230
6577
  // src/providers/transaction-summary/get-transaction-summary.ts
6231
- var import_errors21 = require("@fuel-ts/errors");
6578
+ var import_errors22 = require("@fuel-ts/errors");
6232
6579
  var import_math20 = require("@fuel-ts/math");
6233
- var import_transactions23 = require("@fuel-ts/transactions");
6580
+ var import_transactions24 = require("@fuel-ts/transactions");
6581
+ var import_utils32 = require("@fuel-ts/utils");
6582
+
6583
+ // src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
6584
+ var import_math21 = require("@fuel-ts/math");
6585
+ var import_transactions25 = require("@fuel-ts/transactions");
6234
6586
  var import_utils33 = require("@fuel-ts/utils");
6235
6587
 
6236
6588
  // src/test-utils/test-asset-id.ts
@@ -6258,8 +6610,8 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6258
6610
 
6259
6611
  // src/test-utils/wallet-config.ts
6260
6612
  var import_crypto9 = require("@fuel-ts/crypto");
6261
- var import_errors27 = require("@fuel-ts/errors");
6262
- var import_math23 = require("@fuel-ts/math");
6613
+ var import_errors28 = require("@fuel-ts/errors");
6614
+ var import_math24 = require("@fuel-ts/math");
6263
6615
  var import_utils43 = require("@fuel-ts/utils");
6264
6616
 
6265
6617
  // src/wallet/base-wallet-unlocked.ts
@@ -6267,12 +6619,12 @@ var import_hasher4 = require("@fuel-ts/hasher");
6267
6619
  var import_utils38 = require("@fuel-ts/utils");
6268
6620
 
6269
6621
  // src/account.ts
6270
- var import_abi_coder8 = require("@fuel-ts/abi-coder");
6622
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
6271
6623
  var import_address6 = require("@fuel-ts/address");
6272
6624
  var import_crypto5 = require("@fuel-ts/crypto");
6273
- var import_errors22 = require("@fuel-ts/errors");
6274
- var import_math21 = require("@fuel-ts/math");
6275
- var import_transactions24 = require("@fuel-ts/transactions");
6625
+ var import_errors23 = require("@fuel-ts/errors");
6626
+ var import_math22 = require("@fuel-ts/math");
6627
+ var import_transactions26 = require("@fuel-ts/transactions");
6276
6628
  var import_utils36 = require("@fuel-ts/utils");
6277
6629
  var import_ramda9 = require("ramda");
6278
6630
 
@@ -6295,12 +6647,12 @@ var AbstractAccount = class {
6295
6647
  };
6296
6648
 
6297
6649
  // src/utils/formatTransferToContractScriptData.ts
6298
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
6650
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
6299
6651
  var import_address5 = require("@fuel-ts/address");
6300
6652
  var import_utils35 = require("@fuel-ts/utils");
6301
6653
  var asm = __toESM(require("@fuels/vm-asm"));
6302
6654
  var formatTransferToContractScriptData = (transferParams) => {
6303
- const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
6655
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
6304
6656
  return transferParams.reduce((acc, transferParam) => {
6305
6657
  const { assetId, amount, contractId } = transferParam;
6306
6658
  const encoded = numberCoder.encode(amount);
@@ -6313,7 +6665,7 @@ var assembleTransferToContractScript = async (transferParams) => {
6313
6665
  await asm.initWasm();
6314
6666
  let script = new Uint8Array();
6315
6667
  transferParams.forEach((_, i) => {
6316
- const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
6668
+ const offset = (import_abi_coder6.CONTRACT_ID_LEN + import_abi_coder6.WORD_SIZE + import_abi_coder6.ASSET_ID_LEN) * i;
6317
6669
  script = (0, import_utils35.concat)([
6318
6670
  script,
6319
6671
  // Load ScriptData into register 0x10.
@@ -6321,11 +6673,11 @@ var assembleTransferToContractScript = async (transferParams) => {
6321
6673
  // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6322
6674
  asm.addi(17, 16, offset).to_bytes(),
6323
6675
  // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6324
- asm.addi(18, 17, import_abi_coder7.CONTRACT_ID_LEN).to_bytes(),
6676
+ asm.addi(18, 17, import_abi_coder6.CONTRACT_ID_LEN).to_bytes(),
6325
6677
  // Load word to the amount at 0x12 into register 0x13.
6326
6678
  asm.lw(19, 18, 0).to_bytes(),
6327
6679
  // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6328
- asm.addi(20, 18, import_abi_coder7.WORD_SIZE).to_bytes(),
6680
+ asm.addi(20, 18, import_abi_coder6.WORD_SIZE).to_bytes(),
6329
6681
  // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6330
6682
  asm.tr(17, 19, 20).to_bytes()
6331
6683
  ]);
@@ -6371,7 +6723,7 @@ var Account = class extends AbstractAccount {
6371
6723
  */
6372
6724
  get provider() {
6373
6725
  if (!this._provider) {
6374
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
6726
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.MISSING_PROVIDER, "Provider not set");
6375
6727
  }
6376
6728
  return this._provider;
6377
6729
  }
@@ -6448,12 +6800,20 @@ var Account = class extends AbstractAccount {
6448
6800
  * @returns A promise that resolves to the funded transaction request.
6449
6801
  */
6450
6802
  async fund(request, params) {
6451
- const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6803
+ const {
6804
+ addedSignatures,
6805
+ estimatedPredicates,
6806
+ requiredQuantities,
6807
+ updateMaxFee,
6808
+ gasPrice,
6809
+ transactionSummary
6810
+ } = params;
6811
+ const chainId = await this.provider.getChainId();
6452
6812
  const fee = request.maxFee;
6453
6813
  const baseAssetId = await this.provider.getBaseAssetId();
6454
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
6814
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math22.bn)(0);
6455
6815
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
6456
- amount: (0, import_math21.bn)(fee),
6816
+ amount: (0, import_math22.bn)(fee),
6457
6817
  assetId: baseAssetId,
6458
6818
  coinQuantities: requiredQuantities
6459
6819
  });
@@ -6461,7 +6821,7 @@ var Account = class extends AbstractAccount {
6461
6821
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
6462
6822
  quantitiesDict[assetId] = {
6463
6823
  required: amount,
6464
- owned: (0, import_math21.bn)(0)
6824
+ owned: (0, import_math22.bn)(0)
6465
6825
  };
6466
6826
  });
6467
6827
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -6522,11 +6882,12 @@ var Account = class extends AbstractAccount {
6522
6882
  fundingAttempts += 1;
6523
6883
  }
6524
6884
  if (needsToBeFunded) {
6525
- throw new import_errors22.FuelError(
6526
- import_errors22.ErrorCode.NOT_ENOUGH_FUNDS,
6885
+ throw new import_errors23.FuelError(
6886
+ import_errors23.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
6527
6887
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6528
6888
  );
6529
6889
  }
6890
+ request.updateState(chainId, "funded", transactionSummary);
6530
6891
  await this.provider.validateTransaction(request);
6531
6892
  request.updatePredicateGasUsed(estimatedPredicates);
6532
6893
  const requestToReestimate = (0, import_ramda9.clone)(request);
@@ -6637,12 +6998,12 @@ var Account = class extends AbstractAccount {
6637
6998
  const quantities = [];
6638
6999
  const defaultAssetId = await this.provider.getBaseAssetId();
6639
7000
  const transferParams = contractTransferParams.map((transferParam) => {
6640
- const amount = (0, import_math21.bn)(transferParam.amount);
7001
+ const amount = (0, import_math22.bn)(transferParam.amount);
6641
7002
  const contractAddress = new import_address6.Address(transferParam.contractId);
6642
7003
  const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
6643
7004
  if (amount.lte(0)) {
6644
- throw new import_errors22.FuelError(
6645
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7005
+ throw new import_errors23.FuelError(
7006
+ import_errors23.ErrorCode.INVALID_TRANSFER_AMOUNT,
6646
7007
  "Transfer amount must be a positive number."
6647
7008
  );
6648
7009
  }
@@ -6674,7 +7035,7 @@ var Account = class extends AbstractAccount {
6674
7035
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
6675
7036
  );
6676
7037
  const amountDataArray = (0, import_utils36.arrayify)(
6677
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7038
+ "0x".concat((0, import_math22.bn)(amount).toHex().substring(2).padStart(16, "0"))
6678
7039
  );
6679
7040
  const script = new Uint8Array([
6680
7041
  ...(0, import_utils36.arrayify)(withdrawScript.bytes),
@@ -6684,7 +7045,7 @@ var Account = class extends AbstractAccount {
6684
7045
  const params = { script, ...txParams };
6685
7046
  const baseAssetId = await this.provider.getBaseAssetId();
6686
7047
  let request = new ScriptTransactionRequest(params);
6687
- const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7048
+ const quantities = [{ amount: (0, import_math22.bn)(amount), assetId: baseAssetId }];
6688
7049
  const txCost = await this.getTransactionCost(request, { quantities });
6689
7050
  request = this.validateGasLimitAndMaxFee({
6690
7051
  transactionRequest: request,
@@ -6710,9 +7071,9 @@ var Account = class extends AbstractAccount {
6710
7071
  const baseAssetId = await this.provider.getBaseAssetId();
6711
7072
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
6712
7073
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
6713
- const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7074
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
6714
7075
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
6715
- if (input.type === import_transactions24.InputType.Coin) {
7076
+ if (input.type === import_transactions26.InputType.Coin) {
6716
7077
  return input.assetId === assetId;
6717
7078
  }
6718
7079
  if (isRequestInputMessageWithoutData(input)) {
@@ -6758,7 +7119,7 @@ var Account = class extends AbstractAccount {
6758
7119
  */
6759
7120
  async signMessage(message) {
6760
7121
  if (!this._connector) {
6761
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7122
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
6762
7123
  }
6763
7124
  return this._connector.signMessage(this.address.toString(), message);
6764
7125
  }
@@ -6770,8 +7131,8 @@ var Account = class extends AbstractAccount {
6770
7131
  */
6771
7132
  async signTransaction(transactionRequestLike) {
6772
7133
  if (!this._connector) {
6773
- throw new import_errors22.FuelError(
6774
- import_errors22.ErrorCode.MISSING_CONNECTOR,
7134
+ throw new import_errors23.FuelError(
7135
+ import_errors23.ErrorCode.MISSING_CONNECTOR,
6775
7136
  "A connector is required to sign transactions."
6776
7137
  );
6777
7138
  }
@@ -6784,16 +7145,28 @@ var Account = class extends AbstractAccount {
6784
7145
  * @param sendTransactionParams - The provider send transaction parameters (optional).
6785
7146
  * @returns A promise that resolves to the transaction response.
6786
7147
  */
6787
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
7148
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
7149
+ let transactionRequest = transactionRequestify(transactionRequestLike);
6788
7150
  if (this._connector) {
6789
- return this.provider.getTransactionResponse(
6790
- await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
6791
- onBeforeSend,
6792
- skipCustomFee
6793
- })
7151
+ const { onBeforeSend, skipCustomFee = false } = connectorOptions;
7152
+ transactionRequest = await this.prepareTransactionForSend(transactionRequest);
7153
+ const params = {
7154
+ onBeforeSend,
7155
+ skipCustomFee,
7156
+ provider: {
7157
+ url: this.provider.url,
7158
+ cache: await serializeProviderCache(this.provider)
7159
+ },
7160
+ transactionState: transactionRequest.flag.state,
7161
+ transactionSummary: await this.prepareTransactionSummary(transactionRequest)
7162
+ };
7163
+ const transaction = await this._connector.sendTransaction(
7164
+ this.address.toString(),
7165
+ transactionRequest,
7166
+ params
6794
7167
  );
7168
+ return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
6795
7169
  }
6796
- const transactionRequest = transactionRequestify(transactionRequestLike);
6797
7170
  if (estimateTxDependencies) {
6798
7171
  await this.provider.estimateTxDependencies(transactionRequest);
6799
7172
  }
@@ -6823,18 +7196,40 @@ var Account = class extends AbstractAccount {
6823
7196
  */
6824
7197
  generateFakeResources(coins) {
6825
7198
  return coins.map((coin) => ({
6826
- id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
7199
+ id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
6827
7200
  owner: this.address,
6828
- blockCreated: (0, import_math21.bn)(1),
6829
- txCreatedIdx: (0, import_math21.bn)(1),
7201
+ blockCreated: (0, import_math22.bn)(1),
7202
+ txCreatedIdx: (0, import_math22.bn)(1),
6830
7203
  ...coin
6831
7204
  }));
6832
7205
  }
7206
+ /** @hidden */
7207
+ async prepareTransactionForSend(request) {
7208
+ const { transactionId } = request.flag;
7209
+ if (!(0, import_utils36.isDefined)(transactionId)) {
7210
+ return request;
7211
+ }
7212
+ const chainId = await this.provider.getChainId();
7213
+ const currentTransactionId = request.getTransactionId(chainId);
7214
+ if (transactionId !== currentTransactionId) {
7215
+ request.updateState(chainId);
7216
+ }
7217
+ return request;
7218
+ }
7219
+ /** @hidden */
7220
+ async prepareTransactionSummary(request) {
7221
+ const chainId = await this.provider.getChainId();
7222
+ return (0, import_utils36.isDefined)(request.flag.summary) ? {
7223
+ ...request.flag.summary,
7224
+ id: request.getTransactionId(chainId),
7225
+ transactionBytes: (0, import_utils36.hexlify)(request.toTransactionBytes())
7226
+ } : void 0;
7227
+ }
6833
7228
  /** @hidden * */
6834
7229
  validateTransferAmount(amount) {
6835
- if ((0, import_math21.bn)(amount).lte(0)) {
6836
- throw new import_errors22.FuelError(
6837
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7230
+ if ((0, import_math22.bn)(amount).lte(0)) {
7231
+ throw new import_errors23.FuelError(
7232
+ import_errors23.ErrorCode.INVALID_TRANSFER_AMOUNT,
6838
7233
  "Transfer amount must be a positive number."
6839
7234
  );
6840
7235
  }
@@ -6863,16 +7258,16 @@ var Account = class extends AbstractAccount {
6863
7258
  if (!(0, import_utils36.isDefined)(setGasLimit)) {
6864
7259
  request.gasLimit = gasUsed;
6865
7260
  } else if (gasUsed.gt(setGasLimit)) {
6866
- throw new import_errors22.FuelError(
6867
- import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
7261
+ throw new import_errors23.FuelError(
7262
+ import_errors23.ErrorCode.GAS_LIMIT_TOO_LOW,
6868
7263
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
6869
7264
  );
6870
7265
  }
6871
7266
  if (!(0, import_utils36.isDefined)(setMaxFee)) {
6872
7267
  request.maxFee = maxFee;
6873
7268
  } else if (maxFee.gt(setMaxFee)) {
6874
- throw new import_errors22.FuelError(
6875
- import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
7269
+ throw new import_errors23.FuelError(
7270
+ import_errors23.ErrorCode.MAX_FEE_TOO_LOW,
6876
7271
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
6877
7272
  );
6878
7273
  }
@@ -6883,7 +7278,7 @@ var Account = class extends AbstractAccount {
6883
7278
  // src/wallet/keystore-wallet.ts
6884
7279
  var import_address7 = require("@fuel-ts/address");
6885
7280
  var import_crypto6 = require("@fuel-ts/crypto");
6886
- var import_errors23 = require("@fuel-ts/errors");
7281
+ var import_errors24 = require("@fuel-ts/errors");
6887
7282
  var import_utils37 = require("@fuel-ts/utils");
6888
7283
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
6889
7284
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -6960,8 +7355,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6960
7355
  const macHashUint8Array = (0, import_crypto6.keccak256)(data);
6961
7356
  const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
6962
7357
  if (mac !== macHash) {
6963
- throw new import_errors23.FuelError(
6964
- import_errors23.ErrorCode.INVALID_PASSWORD,
7358
+ throw new import_errors24.FuelError(
7359
+ import_errors24.ErrorCode.INVALID_PASSWORD,
6965
7360
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
6966
7361
  );
6967
7362
  }
@@ -7096,14 +7491,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7096
7491
 
7097
7492
  // src/hdwallet/hdwallet.ts
7098
7493
  var import_crypto8 = require("@fuel-ts/crypto");
7099
- var import_errors26 = require("@fuel-ts/errors");
7494
+ var import_errors27 = require("@fuel-ts/errors");
7100
7495
  var import_hasher7 = require("@fuel-ts/hasher");
7101
- var import_math22 = require("@fuel-ts/math");
7496
+ var import_math23 = require("@fuel-ts/math");
7102
7497
  var import_utils42 = require("@fuel-ts/utils");
7103
7498
 
7104
7499
  // src/mnemonic/mnemonic.ts
7105
7500
  var import_crypto7 = require("@fuel-ts/crypto");
7106
- var import_errors25 = require("@fuel-ts/errors");
7501
+ var import_errors26 = require("@fuel-ts/errors");
7107
7502
  var import_hasher6 = require("@fuel-ts/hasher");
7108
7503
  var import_utils40 = require("@fuel-ts/utils");
7109
7504
 
@@ -9160,7 +9555,7 @@ var english = [
9160
9555
  ];
9161
9556
 
9162
9557
  // src/mnemonic/utils.ts
9163
- var import_errors24 = require("@fuel-ts/errors");
9558
+ var import_errors25 = require("@fuel-ts/errors");
9164
9559
  var import_hasher5 = require("@fuel-ts/hasher");
9165
9560
  var import_utils39 = require("@fuel-ts/utils");
9166
9561
  function getLowerMask(bits) {
@@ -9209,8 +9604,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9209
9604
  for (let i = 0; i < words.length; i += 1) {
9210
9605
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9211
9606
  if (index === -1) {
9212
- throw new import_errors24.FuelError(
9213
- import_errors24.ErrorCode.INVALID_MNEMONIC,
9607
+ throw new import_errors25.FuelError(
9608
+ import_errors25.ErrorCode.INVALID_MNEMONIC,
9214
9609
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9215
9610
  );
9216
9611
  }
@@ -9226,8 +9621,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9226
9621
  const checksumMask = getUpperMask(checksumBits);
9227
9622
  const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9228
9623
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9229
- throw new import_errors24.FuelError(
9230
- import_errors24.ErrorCode.INVALID_CHECKSUM,
9624
+ throw new import_errors25.FuelError(
9625
+ import_errors25.ErrorCode.INVALID_CHECKSUM,
9231
9626
  "Checksum validation failed for the provided mnemonic."
9232
9627
  );
9233
9628
  }
@@ -9241,16 +9636,16 @@ var TestnetPRV = "0x04358394";
9241
9636
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9242
9637
  function assertWordList(wordlist) {
9243
9638
  if (wordlist.length !== 2048) {
9244
- throw new import_errors25.FuelError(
9245
- import_errors25.ErrorCode.INVALID_WORD_LIST,
9639
+ throw new import_errors26.FuelError(
9640
+ import_errors26.ErrorCode.INVALID_WORD_LIST,
9246
9641
  `Expected word list length of 2048, but got ${wordlist.length}.`
9247
9642
  );
9248
9643
  }
9249
9644
  }
9250
9645
  function assertEntropy(entropy) {
9251
9646
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9252
- throw new import_errors25.FuelError(
9253
- import_errors25.ErrorCode.INVALID_ENTROPY,
9647
+ throw new import_errors26.FuelError(
9648
+ import_errors26.ErrorCode.INVALID_ENTROPY,
9254
9649
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9255
9650
  );
9256
9651
  }
@@ -9260,7 +9655,7 @@ function assertMnemonic(words) {
9260
9655
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9261
9656
  ", "
9262
9657
  )}] words, but got ${words.length}.`;
9263
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
9658
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_MNEMONIC, errorMsg);
9264
9659
  }
9265
9660
  }
9266
9661
  var Mnemonic = class {
@@ -9378,8 +9773,8 @@ var Mnemonic = class {
9378
9773
  static masterKeysFromSeed(seed) {
9379
9774
  const seedArray = (0, import_utils40.arrayify)(seed);
9380
9775
  if (seedArray.length < 16 || seedArray.length > 64) {
9381
- throw new import_errors25.FuelError(
9382
- import_errors25.ErrorCode.INVALID_SEED,
9776
+ throw new import_errors26.FuelError(
9777
+ import_errors26.ErrorCode.INVALID_SEED,
9383
9778
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9384
9779
  );
9385
9780
  }
@@ -9456,7 +9851,7 @@ function isValidExtendedKey(extendedKey) {
9456
9851
  function parsePath(path2, depth = 0) {
9457
9852
  const components = path2.split("/");
9458
9853
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9459
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9854
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9460
9855
  }
9461
9856
  if (components[0] === "m") {
9462
9857
  components.shift();
@@ -9485,8 +9880,8 @@ var HDWallet = class {
9485
9880
  this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
9486
9881
  } else {
9487
9882
  if (!config.publicKey) {
9488
- throw new import_errors26.FuelError(
9489
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9883
+ throw new import_errors27.FuelError(
9884
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9490
9885
  "Both public and private Key cannot be missing. At least one should be provided."
9491
9886
  );
9492
9887
  }
@@ -9515,8 +9910,8 @@ var HDWallet = class {
9515
9910
  const data = new Uint8Array(37);
9516
9911
  if (index & HARDENED_INDEX) {
9517
9912
  if (!privateKey) {
9518
- throw new import_errors26.FuelError(
9519
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9913
+ throw new import_errors27.FuelError(
9914
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9520
9915
  "Cannot derive a hardened index without a private Key."
9521
9916
  );
9522
9917
  }
@@ -9524,13 +9919,13 @@ var HDWallet = class {
9524
9919
  } else {
9525
9920
  data.set((0, import_utils42.arrayify)(this.publicKey));
9526
9921
  }
9527
- data.set((0, import_math22.toBytes)(index, 4), 33);
9922
+ data.set((0, import_math23.toBytes)(index, 4), 33);
9528
9923
  const bytes = (0, import_utils42.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
9529
9924
  const IL = bytes.slice(0, 32);
9530
9925
  const IR = bytes.slice(32);
9531
9926
  if (privateKey) {
9532
9927
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
9533
- const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
9928
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
9534
9929
  return new HDWallet({
9535
9930
  privateKey: ki,
9536
9931
  chainCode: IR,
@@ -9568,15 +9963,15 @@ var HDWallet = class {
9568
9963
  */
9569
9964
  toExtendedKey(isPublic = false, testnet = false) {
9570
9965
  if (this.depth >= 256) {
9571
- throw new import_errors26.FuelError(
9572
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9966
+ throw new import_errors27.FuelError(
9967
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9573
9968
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9574
9969
  );
9575
9970
  }
9576
9971
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
9577
9972
  const depth = (0, import_utils42.hexlify)(Uint8Array.from([this.depth]));
9578
9973
  const parentFingerprint = this.parentFingerprint;
9579
- const index = (0, import_math22.toHex)(this.index, 4);
9974
+ const index = (0, import_math23.toHex)(this.index, 4);
9580
9975
  const chainCode = this.chainCode;
9581
9976
  const key = this.privateKey != null && !isPublic ? (0, import_utils42.concat)(["0x00", this.privateKey]) : this.publicKey;
9582
9977
  const extendedKey = (0, import_utils42.arrayify)((0, import_utils42.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -9596,14 +9991,14 @@ var HDWallet = class {
9596
9991
  });
9597
9992
  }
9598
9993
  static fromExtendedKey(extendedKey) {
9599
- const decoded = (0, import_utils42.hexlify)((0, import_math22.toBytes)((0, import_utils42.decodeBase58)(extendedKey)));
9994
+ const decoded = (0, import_utils42.hexlify)((0, import_math23.toBytes)((0, import_utils42.decodeBase58)(extendedKey)));
9600
9995
  const bytes = (0, import_utils42.arrayify)(decoded);
9601
9996
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
9602
9997
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
9603
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9998
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9604
9999
  }
9605
10000
  if (!validChecksum) {
9606
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10001
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9607
10002
  }
9608
10003
  const depth = bytes[4];
9609
10004
  const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
@@ -9611,14 +10006,14 @@ var HDWallet = class {
9611
10006
  const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
9612
10007
  const key = bytes.slice(45, 78);
9613
10008
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
9614
- throw new import_errors26.FuelError(
9615
- import_errors26.ErrorCode.HD_WALLET_ERROR,
10009
+ throw new import_errors27.FuelError(
10010
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9616
10011
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
9617
10012
  );
9618
10013
  }
9619
10014
  if (isPublicExtendedKey(bytes)) {
9620
10015
  if (key[0] !== 3) {
9621
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10016
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
9622
10017
  }
9623
10018
  return new HDWallet({
9624
10019
  publicKey: key,
@@ -9629,7 +10024,7 @@ var HDWallet = class {
9629
10024
  });
9630
10025
  }
9631
10026
  if (key[0] !== 0) {
9632
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10027
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
9633
10028
  }
9634
10029
  return new HDWallet({
9635
10030
  privateKey: key.slice(1),
@@ -9853,7 +10248,7 @@ var WalletsConfig = class {
9853
10248
  assetIds.forEach((assetId) => {
9854
10249
  for (let index = 0; index < coinsPerAsset; index++) {
9855
10250
  coins.push({
9856
- amount: (0, import_math23.bn)(amountPerCoin).toString(),
10251
+ amount: (0, import_math24.bn)(amountPerCoin).toString(),
9857
10252
  asset_id: assetId,
9858
10253
  owner: walletAddress,
9859
10254
  tx_pointer_block_height: 0,
@@ -9873,26 +10268,26 @@ var WalletsConfig = class {
9873
10268
  amountPerCoin
9874
10269
  }) {
9875
10270
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
9876
- throw new import_errors27.FuelError(
9877
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10271
+ throw new import_errors28.FuelError(
10272
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9878
10273
  "Number of wallets must be greater than zero."
9879
10274
  );
9880
10275
  }
9881
10276
  if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
9882
- throw new import_errors27.FuelError(
9883
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10277
+ throw new import_errors28.FuelError(
10278
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9884
10279
  "Number of assets per wallet must be greater than zero."
9885
10280
  );
9886
10281
  }
9887
10282
  if (coinsPerAsset <= 0) {
9888
- throw new import_errors27.FuelError(
9889
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10283
+ throw new import_errors28.FuelError(
10284
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9890
10285
  "Number of coins per asset must be greater than zero."
9891
10286
  );
9892
10287
  }
9893
- if ((0, import_math23.bn)(amountPerCoin).lt(0)) {
9894
- throw new import_errors27.FuelError(
9895
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10288
+ if ((0, import_math24.bn)(amountPerCoin).lt(0)) {
10289
+ throw new import_errors28.FuelError(
10290
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9896
10291
  "Amount per coin must be greater than or equal to zero."
9897
10292
  );
9898
10293
  }
@@ -9966,7 +10361,7 @@ async function setupTestProviderAndWallets({
9966
10361
  // src/test-utils/test-message.ts
9967
10362
  var import_address8 = require("@fuel-ts/address");
9968
10363
  var import_crypto10 = require("@fuel-ts/crypto");
9969
- var import_math24 = require("@fuel-ts/math");
10364
+ var import_math25 = require("@fuel-ts/math");
9970
10365
  var import_utils45 = require("@fuel-ts/utils");
9971
10366
  var TestMessage = class {
9972
10367
  sender;
@@ -10003,7 +10398,7 @@ var TestMessage = class {
10003
10398
  sender: this.sender.toB256(),
10004
10399
  recipient: recipient?.toB256() ?? this.recipient.toB256(),
10005
10400
  nonce: this.nonce,
10006
- amount: (0, import_math24.bn)(this.amount).toNumber(),
10401
+ amount: (0, import_math25.bn)(this.amount).toNumber(),
10007
10402
  data,
10008
10403
  da_height: this.da_height
10009
10404
  };