@fuel-ts/account 0.98.0 → 0.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/account.d.ts +13 -8
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/assets/asset-api.d.ts +69 -0
  4. package/dist/assets/asset-api.d.ts.map +1 -0
  5. package/dist/assets/assets.d.ts.map +1 -0
  6. package/dist/{providers/assets → assets}/index.d.ts +1 -0
  7. package/dist/assets/index.d.ts.map +1 -0
  8. package/dist/assets/types.d.ts.map +1 -0
  9. package/dist/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
  10. package/dist/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
  11. package/dist/assets/utils/index.d.ts.map +1 -0
  12. package/dist/{providers/assets → assets}/utils/network.d.ts +6 -6
  13. package/dist/assets/utils/network.d.ts.map +1 -0
  14. package/dist/assets/utils/resolveIconPaths.d.ts.map +1 -0
  15. package/dist/assets/utils/url.d.ts.map +1 -0
  16. package/dist/configs.d.ts +2 -2
  17. package/dist/configs.global.js.map +1 -1
  18. package/dist/configs.js.map +1 -1
  19. package/dist/configs.mjs.map +1 -1
  20. package/dist/connectors/fuel-connector.d.ts +8 -7
  21. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  22. package/dist/connectors/types/data-type.d.ts +8 -1
  23. package/dist/connectors/types/data-type.d.ts.map +1 -1
  24. package/dist/connectors/types/events.d.ts +1 -1
  25. package/dist/connectors/types/events.d.ts.map +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.global.js +17708 -16898
  29. package/dist/index.global.js.map +1 -1
  30. package/dist/index.js +6877 -6349
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +6960 -6448
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/mnemonic/mnemonic.d.ts +1 -1
  35. package/dist/providers/__generated__/operations.d.ts +121 -4
  36. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  37. package/dist/providers/coin-quantity.d.ts.map +1 -1
  38. package/dist/providers/fuel-graphql-subscriber.d.ts +1 -0
  39. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  40. package/dist/providers/index.d.ts +0 -1
  41. package/dist/providers/index.d.ts.map +1 -1
  42. package/dist/providers/message.d.ts.map +1 -1
  43. package/dist/providers/provider.d.ts +117 -23
  44. package/dist/providers/provider.d.ts.map +1 -1
  45. package/dist/providers/resource-cache.d.ts +6 -4
  46. package/dist/providers/resource-cache.d.ts.map +1 -1
  47. package/dist/providers/transaction-request/helpers.d.ts +10 -1
  48. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  49. package/dist/providers/transaction-request/transaction-request.d.ts +31 -3
  50. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  51. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  52. package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts +7 -0
  53. package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts.map +1 -0
  54. package/dist/providers/transaction-summary/call.d.ts +8 -2
  55. package/dist/providers/transaction-summary/call.d.ts.map +1 -1
  56. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +1 -1
  57. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  58. package/dist/providers/transaction-summary/index.d.ts +1 -0
  59. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  60. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  61. package/dist/providers/transaction-summary/receipt.d.ts +3 -2
  62. package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
  63. package/dist/providers/transaction-summary/types.d.ts +5 -3
  64. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  65. package/dist/providers/utils/handle-gql-error-message.d.ts +5 -5
  66. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  67. package/dist/providers/utils/helpers.d.ts +14 -0
  68. package/dist/providers/utils/helpers.d.ts.map +1 -0
  69. package/dist/providers/utils/index.d.ts +1 -0
  70. package/dist/providers/utils/index.d.ts.map +1 -1
  71. package/dist/providers/utils/receipts.d.ts +4 -3
  72. package/dist/providers/utils/receipts.d.ts.map +1 -1
  73. package/dist/providers/utils/serialization.d.ts +35 -0
  74. package/dist/providers/utils/serialization.d.ts.map +1 -0
  75. package/dist/signer/signer.d.ts +1 -1
  76. package/dist/test-utils/wallet-config.d.ts +2 -1
  77. package/dist/test-utils/wallet-config.d.ts.map +1 -1
  78. package/dist/test-utils.global.js +4015 -3890
  79. package/dist/test-utils.global.js.map +1 -1
  80. package/dist/test-utils.js +1270 -1464
  81. package/dist/test-utils.js.map +1 -1
  82. package/dist/test-utils.mjs +969 -1163
  83. package/dist/test-utils.mjs.map +1 -1
  84. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -1
  85. package/dist/utils/formatTransferToContractScriptData.d.ts +3 -3
  86. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  87. package/dist/utils/predicate-script-loader-instructions.d.ts +38 -3
  88. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -1
  89. package/dist/wallet/base-wallet-unlocked.d.ts +2 -1
  90. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  91. package/dist/wallet/keystore-wallet.d.ts +2 -2
  92. package/dist/wallet/keystore-wallet.d.ts.map +1 -1
  93. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +3 -2
  94. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
  95. package/dist/wallet-manager/vaults/privatekey-vault.d.ts +2 -1
  96. package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
  97. package/dist/wallet-manager/wallet-manager.d.ts +3 -3
  98. package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
  99. package/package.json +22 -23
  100. package/dist/providers/assets/assets.d.ts.map +0 -1
  101. package/dist/providers/assets/index.d.ts.map +0 -1
  102. package/dist/providers/assets/types.d.ts.map +0 -1
  103. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +0 -2
  104. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +0 -1
  105. package/dist/providers/assets/utils/index.d.ts.map +0 -1
  106. package/dist/providers/assets/utils/network.d.ts.map +0 -1
  107. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
  108. package/dist/providers/assets/utils/url.d.ts.map +0 -1
  109. /package/dist/{providers/assets → assets}/assets.d.ts +0 -0
  110. /package/dist/{providers/assets → assets}/types.d.ts +0 -0
  111. /package/dist/{providers/assets → assets}/utils/index.d.ts +0 -0
  112. /package/dist/{providers/assets → assets}/utils/resolveIconPaths.d.ts +0 -0
  113. /package/dist/{providers/assets → assets}/utils/url.d.ts +0 -0
@@ -93,7 +93,7 @@ var Signer = class {
93
93
  this.privateKey = (0, import_utils.hexlify)(privateKeyBytes);
94
94
  this.publicKey = (0, import_utils.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
95
95
  this.compressedPublicKey = (0, import_utils.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
96
- this.address = import_address.Address.fromPublicKey(this.publicKey);
96
+ this.address = new import_address.Address(this.publicKey);
97
97
  }
98
98
  /**
99
99
  * Sign data using the Signer instance
@@ -151,7 +151,7 @@ var Signer = class {
151
151
  * @returns Address from signature
152
152
  */
153
153
  static recoverAddress(data, signature) {
154
- return import_address.Address.fromPublicKey(Signer.recoverPublicKey(data, signature));
154
+ return new import_address.Address(Signer.recoverPublicKey(data, signature));
155
155
  }
156
156
  /**
157
157
  * Generate a random privateKey
@@ -416,7 +416,7 @@ var launchNode = async ({
416
416
  );
417
417
 
418
418
  // src/test-utils/setup-test-provider-and-wallets.ts
419
- var import_utils45 = require("@fuel-ts/utils");
419
+ var import_utils44 = require("@fuel-ts/utils");
420
420
  var import_ramda10 = require("ramda");
421
421
 
422
422
  // src/providers/coin-quantity.ts
@@ -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
  };
@@ -458,10 +457,9 @@ var addAmountToCoinQuantities = (params) => {
458
457
  var import_address4 = require("@fuel-ts/address");
459
458
  var import_errors20 = 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");
@@ -1073,6 +1071,16 @@ var EstimatePredicatesDocument = import_graphql_tag.default`
1073
1071
  }
1074
1072
  }
1075
1073
  ${TransactionEstimatePredicatesFragmentDoc}`;
1074
+ var EstimatePredicatesAndGasPriceDocument = import_graphql_tag.default`
1075
+ query estimatePredicatesAndGasPrice($encodedTransaction: HexString!, $blockHorizon: U32!) {
1076
+ estimatePredicates(tx: $encodedTransaction) {
1077
+ ...transactionEstimatePredicatesFragment
1078
+ }
1079
+ estimateGasPrice(blockHorizon: $blockHorizon) {
1080
+ gasPrice
1081
+ }
1082
+ }
1083
+ ${TransactionEstimatePredicatesFragmentDoc}`;
1076
1084
  var GetLatestBlockDocument = import_graphql_tag.default`
1077
1085
  query getLatestBlock {
1078
1086
  chain {
@@ -1188,6 +1196,13 @@ var GetBalanceDocument = import_graphql_tag.default`
1188
1196
  }
1189
1197
  }
1190
1198
  `;
1199
+ var GetBalanceV2Document = import_graphql_tag.default`
1200
+ query getBalanceV2($owner: Address!, $assetId: AssetId!) {
1201
+ balance(owner: $owner, assetId: $assetId) {
1202
+ amountU128
1203
+ }
1204
+ }
1205
+ `;
1191
1206
  var GetLatestGasPriceDocument = import_graphql_tag.default`
1192
1207
  query getLatestGasPrice {
1193
1208
  latestGasPrice {
@@ -1210,6 +1225,24 @@ var GetBalancesDocument = import_graphql_tag.default`
1210
1225
  before: $before
1211
1226
  first: $first
1212
1227
  last: $last
1228
+ ) {
1229
+ edges {
1230
+ node {
1231
+ assetId
1232
+ amount
1233
+ }
1234
+ }
1235
+ }
1236
+ }
1237
+ `;
1238
+ var GetBalancesV2Document = import_graphql_tag.default`
1239
+ query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
1240
+ balances(
1241
+ filter: $filter
1242
+ after: $after
1243
+ before: $before
1244
+ first: $first
1245
+ last: $last
1213
1246
  ) {
1214
1247
  pageInfo {
1215
1248
  ...pageInfoFragment
@@ -1217,7 +1250,7 @@ var GetBalancesDocument = import_graphql_tag.default`
1217
1250
  edges {
1218
1251
  node {
1219
1252
  assetId
1220
- amount
1253
+ amountU128
1221
1254
  }
1222
1255
  }
1223
1256
  }
@@ -1244,6 +1277,13 @@ var GetMessagesDocument = import_graphql_tag.default`
1244
1277
  }
1245
1278
  ${PageInfoFragmentDoc}
1246
1279
  ${GetMessageFragmentDoc}`;
1280
+ var DaCompressedBlockDocument = import_graphql_tag.default`
1281
+ query daCompressedBlock($height: U32!) {
1282
+ daCompressedBlock(height: $height) {
1283
+ bytes
1284
+ }
1285
+ }
1286
+ `;
1247
1287
  var GetMessageProofDocument = import_graphql_tag.default`
1248
1288
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
1249
1289
  messageProof(
@@ -1270,6 +1310,15 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1270
1310
  }
1271
1311
  }
1272
1312
  ${RelayedTransactionStatusFragmentDoc}`;
1313
+ var GetAssetDetailsDocument = import_graphql_tag.default`
1314
+ query getAssetDetails($assetId: AssetId!) {
1315
+ assetDetails(id: $assetId) {
1316
+ subId
1317
+ contractId
1318
+ totalSupply
1319
+ }
1320
+ }
1321
+ `;
1273
1322
  var DryRunDocument = import_graphql_tag.default`
1274
1323
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
1275
1324
  dryRun(
@@ -1370,6 +1419,9 @@ function getSdk(requester) {
1370
1419
  estimatePredicates(variables, options) {
1371
1420
  return requester(EstimatePredicatesDocument, variables, options);
1372
1421
  },
1422
+ estimatePredicatesAndGasPrice(variables, options) {
1423
+ return requester(EstimatePredicatesAndGasPriceDocument, variables, options);
1424
+ },
1373
1425
  getLatestBlock(variables, options) {
1374
1426
  return requester(GetLatestBlockDocument, variables, options);
1375
1427
  },
@@ -1403,6 +1455,9 @@ function getSdk(requester) {
1403
1455
  getBalance(variables, options) {
1404
1456
  return requester(GetBalanceDocument, variables, options);
1405
1457
  },
1458
+ getBalanceV2(variables, options) {
1459
+ return requester(GetBalanceV2Document, variables, options);
1460
+ },
1406
1461
  getLatestGasPrice(variables, options) {
1407
1462
  return requester(GetLatestGasPriceDocument, variables, options);
1408
1463
  },
@@ -1412,9 +1467,15 @@ function getSdk(requester) {
1412
1467
  getBalances(variables, options) {
1413
1468
  return requester(GetBalancesDocument, variables, options);
1414
1469
  },
1470
+ getBalancesV2(variables, options) {
1471
+ return requester(GetBalancesV2Document, variables, options);
1472
+ },
1415
1473
  getMessages(variables, options) {
1416
1474
  return requester(GetMessagesDocument, variables, options);
1417
1475
  },
1476
+ daCompressedBlock(variables, options) {
1477
+ return requester(DaCompressedBlockDocument, variables, options);
1478
+ },
1418
1479
  getMessageProof(variables, options) {
1419
1480
  return requester(GetMessageProofDocument, variables, options);
1420
1481
  },
@@ -1424,6 +1485,9 @@ function getSdk(requester) {
1424
1485
  getRelayedTransactionStatus(variables, options) {
1425
1486
  return requester(GetRelayedTransactionStatusDocument, variables, options);
1426
1487
  },
1488
+ getAssetDetails(variables, options) {
1489
+ return requester(GetAssetDetailsDocument, variables, options);
1490
+ },
1427
1491
  dryRun(variables, options) {
1428
1492
  return requester(DryRunDocument, variables, options);
1429
1493
  },
@@ -1452,8 +1516,59 @@ function getSdk(requester) {
1452
1516
  }
1453
1517
 
1454
1518
  // src/providers/fuel-graphql-subscriber.ts
1455
- var import_errors2 = require("@fuel-ts/errors");
1519
+ var import_errors3 = require("@fuel-ts/errors");
1456
1520
  var import_graphql = require("graphql");
1521
+
1522
+ // src/providers/utils/handle-gql-error-message.ts
1523
+ var import_errors2 = require("@fuel-ts/errors");
1524
+ var mapGqlErrorMessage = (error) => {
1525
+ 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)) {
1526
+ return new import_errors2.FuelError(
1527
+ import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
1528
+ `Insufficient funds or too many small value coins. Consider combining UTXOs.`,
1529
+ {},
1530
+ error
1531
+ );
1532
+ }
1533
+ if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
1534
+ return new import_errors2.FuelError(
1535
+ import_errors2.ErrorCode.ASSET_NOT_FOUND,
1536
+ `Asset not found for given asset id.`,
1537
+ {},
1538
+ error
1539
+ );
1540
+ }
1541
+ return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1542
+ };
1543
+ var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
1544
+ if (!incompatibleNodeVersionMessage) {
1545
+ return error;
1546
+ }
1547
+ return new import_errors2.FuelError(
1548
+ error.code,
1549
+ `${error.message}
1550
+
1551
+ ${incompatibleNodeVersionMessage}`,
1552
+ error.metadata,
1553
+ error.rawError
1554
+ );
1555
+ };
1556
+ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
1557
+ if (!Array.isArray(errors)) {
1558
+ return;
1559
+ }
1560
+ const mappedErrors = errors.map(mapGqlErrorMessage);
1561
+ if (mappedErrors.length === 1) {
1562
+ throw mapGqlErrorWithIncompatibleNodeVersion(mappedErrors[0], incompatibleNodeVersionMessage);
1563
+ }
1564
+ const errorMessage = mappedErrors.map((err) => err.message).join("\n");
1565
+ throw mapGqlErrorWithIncompatibleNodeVersion(
1566
+ new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1567
+ incompatibleNodeVersionMessage
1568
+ );
1569
+ };
1570
+
1571
+ // src/providers/fuel-graphql-subscriber.ts
1457
1572
  var _FuelGraphqlSubscriber = class {
1458
1573
  constructor(stream) {
1459
1574
  this.stream = stream;
@@ -1481,12 +1596,7 @@ var _FuelGraphqlSubscriber = class {
1481
1596
  while (true) {
1482
1597
  if (this.events.length > 0) {
1483
1598
  const { data, errors } = this.events.shift();
1484
- if (Array.isArray(errors)) {
1485
- throw new import_errors2.FuelError(
1486
- import_errors2.FuelError.CODES.INVALID_REQUEST,
1487
- errors.map((err) => err.message).join("\n\n")
1488
- );
1489
- }
1599
+ assertGqlResponseHasNoErrors(errors, _FuelGraphqlSubscriber.incompatibleNodeVersionMessage);
1490
1600
  return { value: data, done: false };
1491
1601
  }
1492
1602
  const { value, done } = await this.stream.read();
@@ -1504,8 +1614,8 @@ var _FuelGraphqlSubscriber = class {
1504
1614
  try {
1505
1615
  this.events.push(JSON.parse(match.replace(/^data:/, "")));
1506
1616
  } catch (e) {
1507
- throw new import_errors2.FuelError(
1508
- import_errors2.ErrorCode.STREAM_PARSING_ERROR,
1617
+ throw new import_errors3.FuelError(
1618
+ import_errors3.ErrorCode.STREAM_PARSING_ERROR,
1509
1619
  `Error while parsing stream data response: ${text}`
1510
1620
  );
1511
1621
  }
@@ -1524,69 +1634,12 @@ var _FuelGraphqlSubscriber = class {
1524
1634
  }
1525
1635
  };
1526
1636
  var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
1637
+ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
1527
1638
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1528
1639
 
1529
1640
  // src/providers/resource-cache.ts
1530
- var import_errors3 = require("@fuel-ts/errors");
1531
- var import_utils4 = require("@fuel-ts/utils");
1532
- var cache = /* @__PURE__ */ new Map();
1533
- var ResourceCache = class {
1534
- ttl;
1535
- constructor(ttl) {
1536
- this.ttl = ttl;
1537
- if (typeof ttl !== "number" || this.ttl <= 0) {
1538
- throw new import_errors3.FuelError(
1539
- import_errors3.ErrorCode.INVALID_TTL,
1540
- `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
1541
- );
1542
- }
1543
- }
1544
- // Add resources to the cache
1545
- set(transactionId, resources) {
1546
- const currentTime = Date.now();
1547
- const existingResources = cache.get(transactionId) || {
1548
- utxos: /* @__PURE__ */ new Set(),
1549
- messages: /* @__PURE__ */ new Set(),
1550
- timestamp: currentTime
1551
- };
1552
- resources.utxos.forEach((utxo) => existingResources.utxos.add((0, import_utils4.hexlify)(utxo)));
1553
- resources.messages.forEach((message) => existingResources.messages.add((0, import_utils4.hexlify)(message)));
1554
- cache.set(transactionId, existingResources);
1555
- }
1556
- // Remove resources from the cache for a given transaction ID
1557
- unset(transactionId) {
1558
- cache.delete(transactionId);
1559
- }
1560
- // Get all cached resources and remove expired ones
1561
- getActiveData() {
1562
- const allResources = { utxos: [], messages: [] };
1563
- const currentTime = Date.now();
1564
- cache.forEach((resource, transactionId) => {
1565
- if (currentTime - resource.timestamp < this.ttl) {
1566
- allResources.utxos.push(...resource.utxos);
1567
- allResources.messages.push(...resource.messages);
1568
- } else {
1569
- cache.delete(transactionId);
1570
- }
1571
- });
1572
- return allResources;
1573
- }
1574
- // Check if a UTXO ID or message nonce is already cached and not expired
1575
- isCached(key) {
1576
- const currentTime = Date.now();
1577
- for (const [transactionId, resourceData] of cache.entries()) {
1578
- if (currentTime - resourceData.timestamp > this.ttl) {
1579
- cache.delete(transactionId);
1580
- } else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
1581
- return true;
1582
- }
1583
- }
1584
- return false;
1585
- }
1586
- clear() {
1587
- cache.clear();
1588
- }
1589
- };
1641
+ var import_errors14 = require("@fuel-ts/errors");
1642
+ var import_utils23 = require("@fuel-ts/utils");
1590
1643
 
1591
1644
  // src/providers/transaction-request/input.ts
1592
1645
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
@@ -1594,30 +1647,30 @@ var import_configs = require("@fuel-ts/address/configs");
1594
1647
  var import_errors4 = require("@fuel-ts/errors");
1595
1648
  var import_math3 = require("@fuel-ts/math");
1596
1649
  var import_transactions = require("@fuel-ts/transactions");
1597
- var import_utils5 = require("@fuel-ts/utils");
1650
+ var import_utils4 = require("@fuel-ts/utils");
1598
1651
  var inputify = (value) => {
1599
1652
  const { type } = value;
1600
1653
  switch (value.type) {
1601
1654
  case import_transactions.InputType.Coin: {
1602
- const predicate = (0, import_utils5.arrayify)(value.predicate ?? "0x");
1603
- const predicateData = (0, import_utils5.arrayify)(value.predicateData ?? "0x");
1655
+ const predicate = (0, import_utils4.arrayify)(value.predicate ?? "0x");
1656
+ const predicateData = (0, import_utils4.arrayify)(value.predicateData ?? "0x");
1604
1657
  return {
1605
1658
  type: import_transactions.InputType.Coin,
1606
- txID: (0, import_utils5.hexlify)((0, import_utils5.arrayify)(value.id).slice(0, import_abi_coder2.BYTES_32)),
1607
- outputIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.id).slice(import_abi_coder2.BYTES_32, import_abi_coder2.UTXO_ID_LEN)),
1608
- owner: (0, import_utils5.hexlify)(value.owner),
1659
+ txID: (0, import_utils4.hexlify)((0, import_utils4.arrayify)(value.id).slice(0, import_abi_coder2.BYTES_32)),
1660
+ outputIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.id).slice(import_abi_coder2.BYTES_32, import_abi_coder2.UTXO_ID_LEN)),
1661
+ owner: (0, import_utils4.hexlify)(value.owner),
1609
1662
  amount: (0, import_math3.bn)(value.amount),
1610
- assetId: (0, import_utils5.hexlify)(value.assetId),
1663
+ assetId: (0, import_utils4.hexlify)(value.assetId),
1611
1664
  txPointer: {
1612
- blockHeight: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(0, 8)),
1613
- txIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(8, 16))
1665
+ blockHeight: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(0, 8)),
1666
+ txIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(8, 16))
1614
1667
  },
1615
1668
  witnessIndex: value.witnessIndex,
1616
1669
  predicateGasUsed: (0, import_math3.bn)(value.predicateGasUsed),
1617
1670
  predicateLength: (0, import_math3.bn)(predicate.length),
1618
1671
  predicateDataLength: (0, import_math3.bn)(predicateData.length),
1619
- predicate: (0, import_utils5.hexlify)(predicate),
1620
- predicateData: (0, import_utils5.hexlify)(predicateData)
1672
+ predicate: (0, import_utils4.hexlify)(predicate),
1673
+ predicateData: (0, import_utils4.hexlify)(predicateData)
1621
1674
  };
1622
1675
  }
1623
1676
  case import_transactions.InputType.Contract: {
@@ -1628,29 +1681,29 @@ var inputify = (value) => {
1628
1681
  balanceRoot: import_configs.ZeroBytes32,
1629
1682
  stateRoot: import_configs.ZeroBytes32,
1630
1683
  txPointer: {
1631
- blockHeight: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(0, 8)),
1632
- txIndex: (0, import_math3.toNumber)((0, import_utils5.arrayify)(value.txPointer).slice(8, 16))
1684
+ blockHeight: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(0, 8)),
1685
+ txIndex: (0, import_math3.toNumber)((0, import_utils4.arrayify)(value.txPointer).slice(8, 16))
1633
1686
  },
1634
- contractID: (0, import_utils5.hexlify)(value.contractId)
1687
+ contractID: (0, import_utils4.hexlify)(value.contractId)
1635
1688
  };
1636
1689
  }
1637
1690
  case import_transactions.InputType.Message: {
1638
- const predicate = (0, import_utils5.arrayify)(value.predicate ?? "0x");
1639
- const predicateData = (0, import_utils5.arrayify)(value.predicateData ?? "0x");
1640
- const data = (0, import_utils5.arrayify)(value.data ?? "0x");
1691
+ const predicate = (0, import_utils4.arrayify)(value.predicate ?? "0x");
1692
+ const predicateData = (0, import_utils4.arrayify)(value.predicateData ?? "0x");
1693
+ const data = (0, import_utils4.arrayify)(value.data ?? "0x");
1641
1694
  return {
1642
1695
  type: import_transactions.InputType.Message,
1643
- sender: (0, import_utils5.hexlify)(value.sender),
1644
- recipient: (0, import_utils5.hexlify)(value.recipient),
1696
+ sender: (0, import_utils4.hexlify)(value.sender),
1697
+ recipient: (0, import_utils4.hexlify)(value.recipient),
1645
1698
  amount: (0, import_math3.bn)(value.amount),
1646
- nonce: (0, import_utils5.hexlify)(value.nonce),
1699
+ nonce: (0, import_utils4.hexlify)(value.nonce),
1647
1700
  witnessIndex: value.witnessIndex,
1648
1701
  predicateGasUsed: (0, import_math3.bn)(value.predicateGasUsed),
1649
1702
  predicateLength: (0, import_math3.bn)(predicate.length),
1650
1703
  predicateDataLength: (0, import_math3.bn)(predicateData.length),
1651
- predicate: (0, import_utils5.hexlify)(predicate),
1652
- predicateData: (0, import_utils5.hexlify)(predicateData),
1653
- data: (0, import_utils5.hexlify)(data),
1704
+ predicate: (0, import_utils4.hexlify)(predicate),
1705
+ predicateData: (0, import_utils4.hexlify)(predicateData),
1706
+ data: (0, import_utils4.hexlify)(data),
1654
1707
  dataLength: data.length
1655
1708
  };
1656
1709
  }
@@ -1668,16 +1721,16 @@ var import_configs2 = require("@fuel-ts/address/configs");
1668
1721
  var import_errors5 = require("@fuel-ts/errors");
1669
1722
  var import_math4 = require("@fuel-ts/math");
1670
1723
  var import_transactions2 = require("@fuel-ts/transactions");
1671
- var import_utils6 = require("@fuel-ts/utils");
1724
+ var import_utils5 = require("@fuel-ts/utils");
1672
1725
  var outputify = (value) => {
1673
1726
  const { type } = value;
1674
1727
  switch (type) {
1675
1728
  case import_transactions2.OutputType.Coin: {
1676
1729
  return {
1677
1730
  type: import_transactions2.OutputType.Coin,
1678
- to: (0, import_utils6.hexlify)(value.to),
1731
+ to: (0, import_utils5.hexlify)(value.to),
1679
1732
  amount: (0, import_math4.bn)(value.amount),
1680
- assetId: (0, import_utils6.hexlify)(value.assetId)
1733
+ assetId: (0, import_utils5.hexlify)(value.assetId)
1681
1734
  };
1682
1735
  }
1683
1736
  case import_transactions2.OutputType.Contract: {
@@ -1691,9 +1744,9 @@ var outputify = (value) => {
1691
1744
  case import_transactions2.OutputType.Change: {
1692
1745
  return {
1693
1746
  type: import_transactions2.OutputType.Change,
1694
- to: (0, import_utils6.hexlify)(value.to),
1747
+ to: (0, import_utils5.hexlify)(value.to),
1695
1748
  amount: (0, import_math4.bn)(0),
1696
- assetId: (0, import_utils6.hexlify)(value.assetId)
1749
+ assetId: (0, import_utils5.hexlify)(value.assetId)
1697
1750
  };
1698
1751
  }
1699
1752
  case import_transactions2.OutputType.Variable: {
@@ -1707,8 +1760,8 @@ var outputify = (value) => {
1707
1760
  case import_transactions2.OutputType.ContractCreated: {
1708
1761
  return {
1709
1762
  type: import_transactions2.OutputType.ContractCreated,
1710
- contractId: (0, import_utils6.hexlify)(value.contractId),
1711
- stateRoot: (0, import_utils6.hexlify)(value.stateRoot)
1763
+ contractId: (0, import_utils5.hexlify)(value.contractId),
1764
+ stateRoot: (0, import_utils5.hexlify)(value.stateRoot)
1712
1765
  };
1713
1766
  }
1714
1767
  default: {
@@ -1727,7 +1780,7 @@ var import_configs6 = require("@fuel-ts/address/configs");
1727
1780
  var import_crypto3 = require("@fuel-ts/crypto");
1728
1781
  var import_errors10 = require("@fuel-ts/errors");
1729
1782
  var import_math9 = require("@fuel-ts/math");
1730
- var import_transactions7 = require("@fuel-ts/transactions");
1783
+ var import_transactions8 = require("@fuel-ts/transactions");
1731
1784
  var import_utils11 = require("@fuel-ts/utils");
1732
1785
 
1733
1786
  // src/providers/message.ts
@@ -1737,31 +1790,157 @@ var isMessageCoin = (message) => !("data" in message);
1737
1790
  var isCoin = (resource) => "id" in resource;
1738
1791
 
1739
1792
  // src/providers/utils/receipts.ts
1793
+ var import_transactions4 = require("@fuel-ts/transactions");
1794
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1795
+
1796
+ // src/providers/utils/serialization.ts
1740
1797
  var import_configs3 = require("@fuel-ts/address/configs");
1741
1798
  var import_errors6 = require("@fuel-ts/errors");
1742
1799
  var import_math5 = require("@fuel-ts/math");
1743
1800
  var import_transactions3 = require("@fuel-ts/transactions");
1744
- var import_configs4 = require("@fuel-ts/transactions/configs");
1745
- var import_utils7 = require("@fuel-ts/utils");
1746
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1747
- var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1748
- var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1749
- (memo, receipt) => {
1750
- if (doesReceiptHaveMissingOutputVariables(receipt)) {
1751
- memo.missingOutputVariables.push(receipt);
1801
+ var import_utils6 = require("@fuel-ts/utils");
1802
+ var deserializeChain = (chain) => {
1803
+ const { name, daHeight, consensusParameters } = chain;
1804
+ const {
1805
+ contractParams,
1806
+ feeParams,
1807
+ predicateParams,
1808
+ scriptParams,
1809
+ txParams,
1810
+ gasCosts,
1811
+ baseAssetId,
1812
+ chainId,
1813
+ version
1814
+ } = consensusParameters;
1815
+ return {
1816
+ name,
1817
+ baseChainHeight: (0, import_math5.bn)(daHeight),
1818
+ consensusParameters: {
1819
+ version,
1820
+ chainId: (0, import_math5.bn)(chainId),
1821
+ baseAssetId,
1822
+ feeParameters: {
1823
+ version: feeParams.version,
1824
+ gasPerByte: (0, import_math5.bn)(feeParams.gasPerByte),
1825
+ gasPriceFactor: (0, import_math5.bn)(feeParams.gasPriceFactor)
1826
+ },
1827
+ contractParameters: {
1828
+ version: contractParams.version,
1829
+ contractMaxSize: (0, import_math5.bn)(contractParams.contractMaxSize),
1830
+ maxStorageSlots: (0, import_math5.bn)(contractParams.maxStorageSlots)
1831
+ },
1832
+ txParameters: {
1833
+ version: txParams.version,
1834
+ maxInputs: (0, import_math5.bn)(txParams.maxInputs),
1835
+ maxOutputs: (0, import_math5.bn)(txParams.maxOutputs),
1836
+ maxWitnesses: (0, import_math5.bn)(txParams.maxWitnesses),
1837
+ maxGasPerTx: (0, import_math5.bn)(txParams.maxGasPerTx),
1838
+ maxSize: (0, import_math5.bn)(txParams.maxSize),
1839
+ maxBytecodeSubsections: (0, import_math5.bn)(txParams.maxBytecodeSubsections)
1840
+ },
1841
+ predicateParameters: {
1842
+ version: predicateParams.version,
1843
+ maxPredicateLength: (0, import_math5.bn)(predicateParams.maxPredicateLength),
1844
+ maxPredicateDataLength: (0, import_math5.bn)(predicateParams.maxPredicateDataLength),
1845
+ maxGasPerPredicate: (0, import_math5.bn)(predicateParams.maxGasPerPredicate),
1846
+ maxMessageDataLength: (0, import_math5.bn)(predicateParams.maxMessageDataLength)
1847
+ },
1848
+ scriptParameters: {
1849
+ version: scriptParams.version,
1850
+ maxScriptLength: (0, import_math5.bn)(scriptParams.maxScriptLength),
1851
+ maxScriptDataLength: (0, import_math5.bn)(scriptParams.maxScriptDataLength)
1852
+ },
1853
+ gasCosts
1752
1854
  }
1753
- if (doesReceiptHaveMissingContractId(receipt)) {
1754
- memo.missingOutputContractIds.push(receipt);
1855
+ };
1856
+ };
1857
+ var serializeChain = (chain) => {
1858
+ const { name, baseChainHeight, consensusParameters } = chain;
1859
+ const {
1860
+ contractParameters,
1861
+ feeParameters,
1862
+ predicateParameters,
1863
+ scriptParameters,
1864
+ txParameters,
1865
+ gasCosts,
1866
+ baseAssetId,
1867
+ chainId,
1868
+ version
1869
+ } = consensusParameters;
1870
+ return {
1871
+ name,
1872
+ daHeight: baseChainHeight.toString(),
1873
+ consensusParameters: {
1874
+ version,
1875
+ chainId: chainId.toString(),
1876
+ baseAssetId,
1877
+ feeParams: {
1878
+ version: feeParameters.version,
1879
+ gasPerByte: feeParameters.gasPerByte.toString(),
1880
+ gasPriceFactor: feeParameters.gasPriceFactor.toString()
1881
+ },
1882
+ contractParams: {
1883
+ version: contractParameters.version,
1884
+ contractMaxSize: contractParameters.contractMaxSize.toString(),
1885
+ maxStorageSlots: contractParameters.maxStorageSlots.toString()
1886
+ },
1887
+ txParams: {
1888
+ version: txParameters.version,
1889
+ maxInputs: txParameters.maxInputs.toString(),
1890
+ maxOutputs: txParameters.maxOutputs.toString(),
1891
+ maxWitnesses: txParameters.maxWitnesses.toString(),
1892
+ maxGasPerTx: txParameters.maxGasPerTx.toString(),
1893
+ maxSize: txParameters.maxSize.toString(),
1894
+ maxBytecodeSubsections: txParameters.maxBytecodeSubsections.toString()
1895
+ },
1896
+ predicateParams: {
1897
+ version: predicateParameters.version,
1898
+ maxPredicateLength: predicateParameters.maxPredicateLength.toString(),
1899
+ maxPredicateDataLength: predicateParameters.maxPredicateDataLength.toString(),
1900
+ maxGasPerPredicate: predicateParameters.maxGasPerPredicate.toString(),
1901
+ maxMessageDataLength: predicateParameters.maxMessageDataLength.toString()
1902
+ },
1903
+ scriptParams: {
1904
+ version: scriptParameters.version,
1905
+ maxScriptLength: scriptParameters.maxScriptLength.toString(),
1906
+ maxScriptDataLength: scriptParameters.maxScriptDataLength.toString()
1907
+ },
1908
+ gasCosts
1755
1909
  }
1756
- return memo;
1757
- },
1758
- {
1759
- missingOutputVariables: [],
1760
- missingOutputContractIds: []
1761
- }
1762
- );
1910
+ };
1911
+ };
1912
+ var deserializeNodeInfo = (nodeInfo) => {
1913
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
1914
+ return {
1915
+ maxDepth: (0, import_math5.bn)(maxDepth),
1916
+ maxTx: (0, import_math5.bn)(maxTx),
1917
+ nodeVersion,
1918
+ utxoValidation,
1919
+ vmBacktrace
1920
+ };
1921
+ };
1922
+ var serializeNodeInfo = (nodeInfo) => {
1923
+ const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
1924
+ return {
1925
+ maxDepth: maxDepth.toString(),
1926
+ maxTx: maxTx.toString(),
1927
+ nodeVersion,
1928
+ utxoValidation,
1929
+ vmBacktrace
1930
+ };
1931
+ };
1932
+ var deserializeProviderCache = (cache2) => ({
1933
+ consensusParametersTimestamp: cache2.consensusParametersTimestamp,
1934
+ chain: deserializeChain(cache2.chain),
1935
+ nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
1936
+ });
1937
+ var serializeProviderCache = async (provider) => ({
1938
+ consensusParametersTimestamp: provider.consensusParametersTimestamp,
1939
+ chain: serializeChain(await provider.getChain()),
1940
+ nodeInfo: serializeNodeInfo(await provider.getNode())
1941
+ });
1763
1942
  var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1764
- function assembleReceiptByType(receipt) {
1943
+ var deserializeReceipt = (receipt) => {
1765
1944
  const { receiptType } = receipt;
1766
1945
  switch (receiptType) {
1767
1946
  case "CALL" /* Call */: {
@@ -1897,7 +2076,7 @@ function assembleReceiptByType(receipt) {
1897
2076
  const recipient = hexOrZero(receipt.recipient);
1898
2077
  const nonce = hexOrZero(receipt.nonce);
1899
2078
  const amount = (0, import_math5.bn)(receipt.amount);
1900
- const data = receipt.data ? (0, import_utils7.arrayify)(receipt.data) : Uint8Array.from([]);
2079
+ const data = receipt.data ? (0, import_utils6.arrayify)(receipt.data) : Uint8Array.from([]);
1901
2080
  const digest = hexOrZero(receipt.digest);
1902
2081
  const len = (0, import_math5.bn)(receipt.len).toNumber();
1903
2082
  const messageId = import_transactions3.InputMessageCoder.getMessageId({
@@ -1905,7 +2084,7 @@ function assembleReceiptByType(receipt) {
1905
2084
  recipient,
1906
2085
  nonce,
1907
2086
  amount,
1908
- data: (0, import_utils7.hexlify)(data)
2087
+ data: (0, import_utils6.hexlify)(data)
1909
2088
  });
1910
2089
  const receiptMessageOut = {
1911
2090
  type: import_transactions3.ReceiptType.MessageOut,
@@ -1953,18 +2132,37 @@ function assembleReceiptByType(receipt) {
1953
2132
  default:
1954
2133
  throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
1955
2134
  }
1956
- }
2135
+ };
2136
+
2137
+ // src/providers/utils/receipts.ts
2138
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions4.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
2139
+ var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions4.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
2140
+ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
2141
+ (memo, receipt) => {
2142
+ if (doesReceiptHaveMissingOutputVariables(receipt)) {
2143
+ memo.missingOutputVariables.push(receipt);
2144
+ }
2145
+ if (doesReceiptHaveMissingContractId(receipt)) {
2146
+ memo.missingOutputContractIds.push(receipt);
2147
+ }
2148
+ return memo;
2149
+ },
2150
+ {
2151
+ missingOutputVariables: [],
2152
+ missingOutputContractIds: []
2153
+ }
2154
+ );
1957
2155
 
1958
2156
  // src/providers/utils/block-explorer.ts
1959
2157
  var import_errors7 = require("@fuel-ts/errors");
1960
2158
 
1961
2159
  // src/providers/utils/gas.ts
1962
2160
  var import_math6 = require("@fuel-ts/math");
1963
- var import_transactions4 = require("@fuel-ts/transactions");
1964
- var import_utils8 = require("@fuel-ts/utils");
2161
+ var import_transactions5 = require("@fuel-ts/transactions");
2162
+ var import_utils7 = require("@fuel-ts/utils");
1965
2163
  var getGasUsedFromReceipts = (receipts) => {
1966
2164
  const scriptResult = receipts.filter(
1967
- (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
2165
+ (receipt) => receipt.type === import_transactions5.ReceiptType.ScriptResult
1968
2166
  );
1969
2167
  const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), (0, import_math6.bn)(0));
1970
2168
  return gasUsed;
@@ -1998,7 +2196,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1998
2196
  const totalGas = chargeableInputs.reduce((total, input) => {
1999
2197
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
2000
2198
  return total.add(
2001
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils8.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math6.bn)(input.predicateGasUsed))
2199
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils7.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math6.bn)(input.predicateGasUsed))
2002
2200
  );
2003
2201
  }
2004
2202
  return total.add(gasCosts.ecr1);
@@ -2097,13 +2295,13 @@ var calculateGasFee = (params) => {
2097
2295
  };
2098
2296
 
2099
2297
  // src/providers/utils/json.ts
2100
- var import_utils9 = require("@fuel-ts/utils");
2298
+ var import_utils8 = require("@fuel-ts/utils");
2101
2299
  var import_ramda = require("ramda");
2102
2300
  function normalize(object) {
2103
2301
  Object.keys(object).forEach((key) => {
2104
2302
  switch (object[key]?.constructor.name) {
2105
2303
  case "Uint8Array":
2106
- object[key] = (0, import_utils9.hexlify)(object[key]);
2304
+ object[key] = (0, import_utils8.hexlify)(object[key]);
2107
2305
  break;
2108
2306
  case "Array":
2109
2307
  object[key] = normalize(object[key]);
@@ -2130,7 +2328,7 @@ function normalizeJSON(root) {
2130
2328
  // src/providers/utils/extract-tx-error.ts
2131
2329
  var import_errors8 = require("@fuel-ts/errors");
2132
2330
  var import_math7 = require("@fuel-ts/math");
2133
- var import_transactions5 = require("@fuel-ts/transactions");
2331
+ var import_transactions6 = require("@fuel-ts/transactions");
2134
2332
  var import_configs5 = require("@fuel-ts/transactions/configs");
2135
2333
  var assemblePanicError = (statusReason, metadata) => {
2136
2334
  let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
@@ -2149,7 +2347,7 @@ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2149
2347
  var stringify = (obj) => JSON.stringify(obj, null, 2);
2150
2348
  var assembleRevertError = (receipts, logs, metadata) => {
2151
2349
  let errorMessage = "The transaction reverted with an unknown reason.";
2152
- const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
2350
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions6.ReceiptType.Revert);
2153
2351
  let reason = "";
2154
2352
  if (revertReceipt) {
2155
2353
  const reasonHex = (0, import_math7.bn)(revertReceipt.val).toHex();
@@ -2162,15 +2360,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
2162
2360
  break;
2163
2361
  }
2164
2362
  case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
2165
- const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2363
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2166
2364
  reason = "assert_eq";
2167
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
2365
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
2168
2366
  break;
2169
2367
  }
2170
2368
  case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
2171
- const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2369
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2172
2370
  reason = "assert_ne";
2173
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
2371
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
2174
2372
  break;
2175
2373
  }
2176
2374
  case import_configs5.FAILED_ASSERT_SIGNAL:
@@ -2178,8 +2376,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2178
2376
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
2179
2377
  break;
2180
2378
  case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
2181
- reason = "MissingOutputChange";
2182
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
2379
+ reason = "MissingOutputVariable";
2380
+ errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2183
2381
  break;
2184
2382
  default:
2185
2383
  throw new import_errors8.FuelError(
@@ -2199,8 +2397,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2199
2397
  };
2200
2398
  var extractTxError = (params) => {
2201
2399
  const { receipts, statusReason, logs } = params;
2202
- const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
2203
- const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
2400
+ const isPanic = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Panic);
2401
+ const isRevert = receipts.some(({ type }) => type === import_transactions6.ReceiptType.Revert);
2204
2402
  const metadata = {
2205
2403
  logs,
2206
2404
  receipts,
@@ -2227,14 +2425,16 @@ var NoWitnessAtIndexError = class extends Error {
2227
2425
  // src/providers/transaction-request/helpers.ts
2228
2426
  var import_errors9 = require("@fuel-ts/errors");
2229
2427
  var import_math8 = require("@fuel-ts/math");
2230
- var import_transactions6 = require("@fuel-ts/transactions");
2231
- var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
2232
- var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
2233
- var isRequestInputMessageWithoutData = (input) => input.type === import_transactions6.InputType.Message && (0, import_math8.bn)(input.data).isZero();
2428
+ var import_transactions7 = require("@fuel-ts/transactions");
2429
+ var import_utils9 = require("@fuel-ts/utils");
2430
+ var isRequestInputCoin = (input) => input.type === import_transactions7.InputType.Coin;
2431
+ var isRequestInputMessage = (input) => input.type === import_transactions7.InputType.Message;
2432
+ var isRequestInputMessageWithoutData = (input) => input.type === import_transactions7.InputType.Message && (0, import_math8.bn)(input.data).isZero();
2234
2433
  var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2235
2434
  var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
2236
2435
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
2237
2436
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
2437
+ var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && (0, import_utils9.hexlify)(input.predicate) !== "0x";
2238
2438
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
2239
2439
  if (isRequestInputCoin(input) && input.assetId === assetId) {
2240
2440
  return acc.add(input.amount);
@@ -2265,7 +2465,7 @@ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
2265
2465
  coinInputs.add(baseAssetId);
2266
2466
  }
2267
2467
  const changeOutputs = new Set(
2268
- outputs.filter((output) => output.type === import_transactions6.OutputType.Change).map((output) => output.assetId)
2468
+ outputs.filter((output) => output.type === import_transactions7.OutputType.Change).map((output) => output.assetId)
2269
2469
  );
2270
2470
  const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
2271
2471
  return difference.size;
@@ -2301,6 +2501,8 @@ var BaseTransactionRequest = class {
2301
2501
  tip;
2302
2502
  /** Block until which tx cannot be included */
2303
2503
  maturity;
2504
+ /** The block number after which the transaction is no longer valid. */
2505
+ expiration;
2304
2506
  /** The maximum fee payable by this transaction using BASE_ASSET. */
2305
2507
  maxFee;
2306
2508
  /** The maximum amount of witness data allowed for the transaction */
@@ -2311,6 +2513,12 @@ var BaseTransactionRequest = class {
2311
2513
  outputs = [];
2312
2514
  /** List of witnesses */
2313
2515
  witnesses = [];
2516
+ /**
2517
+ * @hidden
2518
+ *
2519
+ * The current status of the transaction
2520
+ */
2521
+ flag = { state: void 0, transactionId: void 0, summary: void 0 };
2314
2522
  /**
2315
2523
  * Constructor for initializing a base transaction request.
2316
2524
  *
@@ -2319,6 +2527,7 @@ var BaseTransactionRequest = class {
2319
2527
  constructor({
2320
2528
  tip,
2321
2529
  maturity,
2530
+ expiration,
2322
2531
  maxFee,
2323
2532
  witnessLimit,
2324
2533
  inputs,
@@ -2327,6 +2536,7 @@ var BaseTransactionRequest = class {
2327
2536
  } = {}) {
2328
2537
  this.tip = tip ? (0, import_math9.bn)(tip) : void 0;
2329
2538
  this.maturity = maturity && maturity > 0 ? maturity : void 0;
2539
+ this.expiration = expiration && expiration > 0 ? expiration : void 0;
2330
2540
  this.witnessLimit = (0, import_utils11.isDefined)(witnessLimit) ? (0, import_math9.bn)(witnessLimit) : void 0;
2331
2541
  this.maxFee = (0, import_math9.bn)(maxFee);
2332
2542
  this.inputs = inputs ?? [];
@@ -2336,21 +2546,25 @@ var BaseTransactionRequest = class {
2336
2546
  static getPolicyMeta(req) {
2337
2547
  let policyTypes = 0;
2338
2548
  const policies = [];
2339
- const { tip, witnessLimit, maturity } = req;
2549
+ const { tip, witnessLimit, maturity, expiration } = req;
2340
2550
  if ((0, import_math9.bn)(tip).gt(0)) {
2341
- policyTypes += import_transactions7.PolicyType.Tip;
2342
- policies.push({ data: (0, import_math9.bn)(tip), type: import_transactions7.PolicyType.Tip });
2551
+ policyTypes += import_transactions8.PolicyType.Tip;
2552
+ policies.push({ data: (0, import_math9.bn)(tip), type: import_transactions8.PolicyType.Tip });
2343
2553
  }
2344
2554
  if ((0, import_utils11.isDefined)(witnessLimit) && (0, import_math9.bn)(witnessLimit).gte(0)) {
2345
- policyTypes += import_transactions7.PolicyType.WitnessLimit;
2346
- policies.push({ data: (0, import_math9.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
2555
+ policyTypes += import_transactions8.PolicyType.WitnessLimit;
2556
+ policies.push({ data: (0, import_math9.bn)(witnessLimit), type: import_transactions8.PolicyType.WitnessLimit });
2347
2557
  }
2348
2558
  if (maturity && maturity > 0) {
2349
- policyTypes += import_transactions7.PolicyType.Maturity;
2350
- policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
2559
+ policyTypes += import_transactions8.PolicyType.Maturity;
2560
+ policies.push({ data: maturity, type: import_transactions8.PolicyType.Maturity });
2561
+ }
2562
+ policyTypes += import_transactions8.PolicyType.MaxFee;
2563
+ policies.push({ data: req.maxFee, type: import_transactions8.PolicyType.MaxFee });
2564
+ if (expiration && expiration > 0) {
2565
+ policyTypes += import_transactions8.PolicyType.Expiration;
2566
+ policies.push({ data: expiration, type: import_transactions8.PolicyType.Expiration });
2351
2567
  }
2352
- policyTypes += import_transactions7.PolicyType.MaxFee;
2353
- policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
2354
2568
  return {
2355
2569
  policyTypes,
2356
2570
  policies
@@ -2383,7 +2597,7 @@ var BaseTransactionRequest = class {
2383
2597
  * @returns The transaction bytes.
2384
2598
  */
2385
2599
  toTransactionBytes() {
2386
- return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2600
+ return new import_transactions8.TransactionCoder().encode(this.toTransaction());
2387
2601
  }
2388
2602
  /**
2389
2603
  * @hidden
@@ -2423,8 +2637,7 @@ var BaseTransactionRequest = class {
2423
2637
  * @returns The index of the created witness.
2424
2638
  */
2425
2639
  addEmptyWitness() {
2426
- this.addWitness((0, import_utils11.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2427
- return this.witnesses.length - 1;
2640
+ return this.addWitness((0, import_utils11.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
2428
2641
  }
2429
2642
  /**
2430
2643
  * Updates the witness for a given owner and signature.
@@ -2433,7 +2646,7 @@ var BaseTransactionRequest = class {
2433
2646
  * @param signature - The signature to update the witness with.
2434
2647
  */
2435
2648
  updateWitnessByOwner(address, signature) {
2436
- const ownerAddress = import_address2.Address.fromAddressOrString(address);
2649
+ const ownerAddress = new import_address2.Address(address);
2437
2650
  const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress);
2438
2651
  if (typeof witnessIndex === "number") {
2439
2652
  this.updateWitness(witnessIndex, signature);
@@ -2474,7 +2687,7 @@ var BaseTransactionRequest = class {
2474
2687
  */
2475
2688
  getCoinInputs() {
2476
2689
  return this.inputs.filter(
2477
- (input) => input.type === import_transactions7.InputType.Coin
2690
+ (input) => input.type === import_transactions8.InputType.Coin
2478
2691
  );
2479
2692
  }
2480
2693
  /**
@@ -2484,7 +2697,7 @@ var BaseTransactionRequest = class {
2484
2697
  */
2485
2698
  getCoinOutputs() {
2486
2699
  return this.outputs.filter(
2487
- (output) => output.type === import_transactions7.OutputType.Coin
2700
+ (output) => output.type === import_transactions8.OutputType.Coin
2488
2701
  );
2489
2702
  }
2490
2703
  /**
@@ -2494,7 +2707,7 @@ var BaseTransactionRequest = class {
2494
2707
  */
2495
2708
  getChangeOutputs() {
2496
2709
  return this.outputs.filter(
2497
- (output) => output.type === import_transactions7.OutputType.Change
2710
+ (output) => output.type === import_transactions8.OutputType.Change
2498
2711
  );
2499
2712
  }
2500
2713
  /**
@@ -2506,9 +2719,9 @@ var BaseTransactionRequest = class {
2506
2719
  const ownerAddress = (0, import_address2.addressify)(owner);
2507
2720
  const found = this.inputs.find((input) => {
2508
2721
  switch (input.type) {
2509
- case import_transactions7.InputType.Coin:
2722
+ case import_transactions8.InputType.Coin:
2510
2723
  return (0, import_utils11.hexlify)(input.owner) === ownerAddress.toB256();
2511
- case import_transactions7.InputType.Message:
2724
+ case import_transactions8.InputType.Message:
2512
2725
  return (0, import_utils11.hexlify)(input.recipient) === ownerAddress.toB256();
2513
2726
  default:
2514
2727
  return false;
@@ -2535,7 +2748,7 @@ var BaseTransactionRequest = class {
2535
2748
  }
2536
2749
  const input = {
2537
2750
  id,
2538
- type: import_transactions7.InputType.Coin,
2751
+ type: import_transactions8.InputType.Coin,
2539
2752
  owner: owner.toB256(),
2540
2753
  amount,
2541
2754
  assetId,
@@ -2566,7 +2779,7 @@ var BaseTransactionRequest = class {
2566
2779
  }
2567
2780
  const input = {
2568
2781
  nonce,
2569
- type: import_transactions7.InputType.Message,
2782
+ type: import_transactions8.InputType.Message,
2570
2783
  sender: sender.toB256(),
2571
2784
  recipient: recipient.toB256(),
2572
2785
  data: isMessageCoin(message) ? "0x" : message.data,
@@ -2615,7 +2828,7 @@ var BaseTransactionRequest = class {
2615
2828
  */
2616
2829
  addCoinOutput(to, amount, assetId) {
2617
2830
  this.pushOutput({
2618
- type: import_transactions7.OutputType.Coin,
2831
+ type: import_transactions8.OutputType.Coin,
2619
2832
  to: (0, import_address2.addressify)(to).toB256(),
2620
2833
  amount,
2621
2834
  assetId
@@ -2631,7 +2844,7 @@ var BaseTransactionRequest = class {
2631
2844
  addCoinOutputs(to, quantities) {
2632
2845
  quantities.map(coinQuantityfy).forEach((quantity) => {
2633
2846
  this.pushOutput({
2634
- type: import_transactions7.OutputType.Coin,
2847
+ type: import_transactions8.OutputType.Coin,
2635
2848
  to: (0, import_address2.addressify)(to).toB256(),
2636
2849
  amount: quantity.amount,
2637
2850
  assetId: quantity.assetId
@@ -2651,7 +2864,7 @@ var BaseTransactionRequest = class {
2651
2864
  );
2652
2865
  if (!changeOutput) {
2653
2866
  this.pushOutput({
2654
- type: import_transactions7.OutputType.Change,
2867
+ type: import_transactions8.OutputType.Change,
2655
2868
  to: (0, import_address2.addressify)(to).toB256(),
2656
2869
  assetId
2657
2870
  });
@@ -2784,7 +2997,7 @@ var BaseTransactionRequest = class {
2784
2997
  this.inputs.filter(isRequestInputResource).forEach((i) => {
2785
2998
  const owner = getRequestInputResourceOwner(i);
2786
2999
  const correspondingInput = inputsToExtractGasUsed.find(
2787
- (x) => isRequestInputResourceFromOwner(x, import_address2.Address.fromString(String(owner)))
3000
+ (x) => isRequestInputResourceFromOwner(x, new import_address2.Address(String(owner)))
2788
3001
  );
2789
3002
  if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math9.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2790
3003
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2794,6 +3007,21 @@ var BaseTransactionRequest = class {
2794
3007
  byteLength() {
2795
3008
  return this.toTransactionBytes().byteLength;
2796
3009
  }
3010
+ /**
3011
+ * @hidden
3012
+ *
3013
+ * Used internally to update the state of a transaction request.
3014
+ *
3015
+ * @param state - The state to update.
3016
+ */
3017
+ updateState(chainId, state, summary) {
3018
+ if (!state) {
3019
+ this.flag = { state: void 0, transactionId: void 0, summary: void 0 };
3020
+ return;
3021
+ }
3022
+ const transactionId = this.getTransactionId(chainId);
3023
+ this.flag = { state, transactionId, summary };
3024
+ }
2797
3025
  };
2798
3026
 
2799
3027
  // src/providers/transaction-request/blob-transaction-request.ts
@@ -2803,18 +3031,18 @@ var import_ramda3 = require("ramda");
2803
3031
  var import_configs7 = require("@fuel-ts/address/configs");
2804
3032
  var import_hasher2 = require("@fuel-ts/hasher");
2805
3033
  var import_math10 = require("@fuel-ts/math");
2806
- var import_transactions8 = require("@fuel-ts/transactions");
3034
+ var import_transactions9 = require("@fuel-ts/transactions");
2807
3035
  var import_utils13 = require("@fuel-ts/utils");
2808
3036
  var import_ramda2 = require("ramda");
2809
3037
  function hashTransaction(transactionRequest, chainId) {
2810
3038
  const transaction = transactionRequest.toTransaction();
2811
- if (transaction.type === import_transactions8.TransactionType.Script) {
3039
+ if (transaction.type === import_transactions9.TransactionType.Script) {
2812
3040
  transaction.receiptsRoot = import_configs7.ZeroBytes32;
2813
3041
  }
2814
3042
  transaction.inputs = transaction.inputs.map((input) => {
2815
3043
  const inputClone = (0, import_ramda2.clone)(input);
2816
3044
  switch (inputClone.type) {
2817
- case import_transactions8.InputType.Coin: {
3045
+ case import_transactions9.InputType.Coin: {
2818
3046
  inputClone.txPointer = {
2819
3047
  blockHeight: 0,
2820
3048
  txIndex: 0
@@ -2822,11 +3050,11 @@ function hashTransaction(transactionRequest, chainId) {
2822
3050
  inputClone.predicateGasUsed = (0, import_math10.bn)(0);
2823
3051
  return inputClone;
2824
3052
  }
2825
- case import_transactions8.InputType.Message: {
3053
+ case import_transactions9.InputType.Message: {
2826
3054
  inputClone.predicateGasUsed = (0, import_math10.bn)(0);
2827
3055
  return inputClone;
2828
3056
  }
2829
- case import_transactions8.InputType.Contract: {
3057
+ case import_transactions9.InputType.Contract: {
2830
3058
  inputClone.txPointer = {
2831
3059
  blockHeight: 0,
2832
3060
  txIndex: 0
@@ -2844,16 +3072,16 @@ function hashTransaction(transactionRequest, chainId) {
2844
3072
  transaction.outputs = transaction.outputs.map((output) => {
2845
3073
  const outputClone = (0, import_ramda2.clone)(output);
2846
3074
  switch (outputClone.type) {
2847
- case import_transactions8.OutputType.Contract: {
3075
+ case import_transactions9.OutputType.Contract: {
2848
3076
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
2849
3077
  outputClone.stateRoot = import_configs7.ZeroBytes32;
2850
3078
  return outputClone;
2851
3079
  }
2852
- case import_transactions8.OutputType.Change: {
3080
+ case import_transactions9.OutputType.Change: {
2853
3081
  outputClone.amount = (0, import_math10.bn)(0);
2854
3082
  return outputClone;
2855
3083
  }
2856
- case import_transactions8.OutputType.Variable: {
3084
+ case import_transactions9.OutputType.Variable: {
2857
3085
  outputClone.to = import_configs7.ZeroBytes32;
2858
3086
  outputClone.amount = (0, import_math10.bn)(0);
2859
3087
  outputClone.assetId = import_configs7.ZeroBytes32;
@@ -2866,7 +3094,7 @@ function hashTransaction(transactionRequest, chainId) {
2866
3094
  transaction.witnessesCount = 0;
2867
3095
  transaction.witnesses = [];
2868
3096
  const chainIdBytes = (0, import_hasher2.uint64ToBytesBE)(chainId);
2869
- const concatenatedData = (0, import_utils13.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
3097
+ const concatenatedData = (0, import_utils13.concat)([chainIdBytes, new import_transactions9.TransactionCoder().encode(transaction)]);
2870
3098
  return (0, import_hasher2.sha256)(concatenatedData);
2871
3099
  }
2872
3100
 
@@ -2876,7 +3104,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2876
3104
  return new this((0, import_ramda3.clone)(obj));
2877
3105
  }
2878
3106
  /** Type of the transaction */
2879
- type = import_transactions7.TransactionType.Blob;
3107
+ type = import_transactions8.TransactionType.Blob;
2880
3108
  /** Blob ID */
2881
3109
  blobId;
2882
3110
  /** Witness index of the bytecode to create */
@@ -2900,7 +3128,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2900
3128
  const baseTransaction = this.getBaseTransaction();
2901
3129
  const { witnessIndex, blobId } = this;
2902
3130
  return {
2903
- type: import_transactions7.TransactionType.Blob,
3131
+ type: import_transactions8.TransactionType.Blob,
2904
3132
  ...baseTransaction,
2905
3133
  blobId,
2906
3134
  witnessIndex
@@ -2934,7 +3162,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2934
3162
  // src/providers/transaction-request/create-transaction-request.ts
2935
3163
  var import_configs8 = require("@fuel-ts/address/configs");
2936
3164
  var import_math11 = require("@fuel-ts/math");
2937
- var import_transactions9 = require("@fuel-ts/transactions");
3165
+ var import_transactions10 = require("@fuel-ts/transactions");
2938
3166
  var import_utils16 = require("@fuel-ts/utils");
2939
3167
  var import_ramda4 = require("ramda");
2940
3168
 
@@ -2967,7 +3195,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2967
3195
  return new this((0, import_ramda4.clone)(obj));
2968
3196
  }
2969
3197
  /** Type of the transaction */
2970
- type = import_transactions9.TransactionType.Create;
3198
+ type = import_transactions10.TransactionType.Create;
2971
3199
  /** Witness index of contract bytecode to create */
2972
3200
  bytecodeWitnessIndex;
2973
3201
  /** Salt */
@@ -2995,7 +3223,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2995
3223
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2996
3224
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2997
3225
  return {
2998
- type: import_transactions9.TransactionType.Create,
3226
+ type: import_transactions10.TransactionType.Create,
2999
3227
  ...baseTransaction,
3000
3228
  bytecodeWitnessIndex,
3001
3229
  storageSlotsCount: (0, import_math11.bn)(storageSlots.length),
@@ -3010,7 +3238,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3010
3238
  */
3011
3239
  getContractCreatedOutputs() {
3012
3240
  return this.outputs.filter(
3013
- (output) => output.type === import_transactions9.OutputType.ContractCreated
3241
+ (output) => output.type === import_transactions10.OutputType.ContractCreated
3014
3242
  );
3015
3243
  }
3016
3244
  /**
@@ -3031,7 +3259,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
3031
3259
  */
3032
3260
  addContractCreatedOutput(contractId, stateRoot) {
3033
3261
  this.pushOutput({
3034
- type: import_transactions9.OutputType.ContractCreated,
3262
+ type: import_transactions10.OutputType.ContractCreated,
3035
3263
  contractId,
3036
3264
  stateRoot
3037
3265
  });
@@ -3051,7 +3279,7 @@ var import_abi_coder4 = require("@fuel-ts/abi-coder");
3051
3279
  var import_address3 = require("@fuel-ts/address");
3052
3280
  var import_configs9 = require("@fuel-ts/address/configs");
3053
3281
  var import_math12 = require("@fuel-ts/math");
3054
- var import_transactions10 = require("@fuel-ts/transactions");
3282
+ var import_transactions11 = require("@fuel-ts/transactions");
3055
3283
  var import_utils18 = require("@fuel-ts/utils");
3056
3284
  var import_ramda5 = require("ramda");
3057
3285
 
@@ -3087,7 +3315,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3087
3315
  return new this((0, import_ramda5.clone)(obj));
3088
3316
  }
3089
3317
  /** Type of the transaction */
3090
- type = import_transactions10.TransactionType.Script;
3318
+ type = import_transactions11.TransactionType.Script;
3091
3319
  /** Gas limit for transaction */
3092
3320
  gasLimit;
3093
3321
  /** Script to execute */
@@ -3130,7 +3358,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3130
3358
  const script = (0, import_utils18.arrayify)(this.script ?? "0x");
3131
3359
  const scriptData = (0, import_utils18.arrayify)(this.scriptData ?? "0x");
3132
3360
  return {
3133
- type: import_transactions10.TransactionType.Script,
3361
+ type: import_transactions11.TransactionType.Script,
3134
3362
  scriptGasLimit: this.gasLimit,
3135
3363
  ...super.getBaseTransaction(),
3136
3364
  scriptLength: (0, import_math12.bn)(script.length),
@@ -3147,7 +3375,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3147
3375
  */
3148
3376
  getContractInputs() {
3149
3377
  return this.inputs.filter(
3150
- (input) => input.type === import_transactions10.InputType.Contract
3378
+ (input) => input.type === import_transactions11.InputType.Contract
3151
3379
  );
3152
3380
  }
3153
3381
  /**
@@ -3157,7 +3385,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3157
3385
  */
3158
3386
  getContractOutputs() {
3159
3387
  return this.outputs.filter(
3160
- (output) => output.type === import_transactions10.OutputType.Contract
3388
+ (output) => output.type === import_transactions11.OutputType.Contract
3161
3389
  );
3162
3390
  }
3163
3391
  /**
@@ -3167,7 +3395,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3167
3395
  */
3168
3396
  getVariableOutputs() {
3169
3397
  return this.outputs.filter(
3170
- (output) => output.type === import_transactions10.OutputType.Variable
3398
+ (output) => output.type === import_transactions11.OutputType.Variable
3171
3399
  );
3172
3400
  }
3173
3401
  /**
@@ -3190,7 +3418,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3190
3418
  let outputsNumber = numberOfVariables;
3191
3419
  while (outputsNumber) {
3192
3420
  this.pushOutput({
3193
- type: import_transactions10.OutputType.Variable
3421
+ type: import_transactions11.OutputType.Variable
3194
3422
  });
3195
3423
  outputsNumber -= 1;
3196
3424
  }
@@ -3234,12 +3462,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3234
3462
  return this;
3235
3463
  }
3236
3464
  const inputIndex = super.pushInput({
3237
- type: import_transactions10.InputType.Contract,
3465
+ type: import_transactions11.InputType.Contract,
3238
3466
  contractId: contractAddress.toB256(),
3239
3467
  txPointer: "0x00000000000000000000000000000000"
3240
3468
  });
3241
3469
  this.pushOutput({
3242
- type: import_transactions10.OutputType.Contract,
3470
+ type: import_transactions11.OutputType.Contract,
3243
3471
  inputIndex
3244
3472
  });
3245
3473
  return this;
@@ -3277,7 +3505,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3277
3505
  // src/providers/transaction-request/upgrade-transaction-request.ts
3278
3506
  var import_errors12 = require("@fuel-ts/errors");
3279
3507
  var import_hasher3 = require("@fuel-ts/hasher");
3280
- var import_transactions11 = require("@fuel-ts/transactions");
3508
+ var import_transactions12 = require("@fuel-ts/transactions");
3281
3509
  var import_utils19 = require("@fuel-ts/utils");
3282
3510
  var import_ramda6 = require("ramda");
3283
3511
  var UpgradeTransactionRequest = class extends BaseTransactionRequest {
@@ -3288,7 +3516,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3288
3516
  return new this((0, import_ramda6.clone)(obj));
3289
3517
  }
3290
3518
  /** The type of transaction */
3291
- type = import_transactions11.TransactionType.Upgrade;
3519
+ type = import_transactions12.TransactionType.Upgrade;
3292
3520
  /** The upgrade purpose */
3293
3521
  upgradePurpose;
3294
3522
  /** Witness index of consensus */
@@ -3306,7 +3534,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3306
3534
  super(rest);
3307
3535
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
3308
3536
  this.upgradePurpose = upgradePurpose ?? {
3309
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3537
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3310
3538
  checksum: "0x"
3311
3539
  };
3312
3540
  }
@@ -3320,7 +3548,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3320
3548
  addConsensusParametersUpgradePurpose(consensus) {
3321
3549
  this.bytecodeWitnessIndex = this.addWitness(consensus);
3322
3550
  this.upgradePurpose = {
3323
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3551
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3324
3552
  checksum: (0, import_hasher3.hash)(consensus)
3325
3553
  };
3326
3554
  return this;
@@ -3334,7 +3562,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3334
3562
  */
3335
3563
  addStateTransitionUpgradePurpose(bytecodeRoot) {
3336
3564
  this.upgradePurpose = {
3337
- type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
3565
+ type: import_transactions12.UpgradePurposeTypeEnum.StateTransition,
3338
3566
  data: (0, import_utils19.hexlify)(bytecodeRoot)
3339
3567
  };
3340
3568
  return this;
@@ -3348,10 +3576,10 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3348
3576
  * @returns - The current instance of `UpgradeTransactionRequest`.
3349
3577
  */
3350
3578
  addUpgradePurpose(type, data) {
3351
- if (type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3579
+ if (type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3352
3580
  this.addConsensusParametersUpgradePurpose(data);
3353
3581
  }
3354
- if (type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3582
+ if (type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3355
3583
  this.addStateTransitionUpgradePurpose(data);
3356
3584
  }
3357
3585
  return this;
@@ -3363,17 +3591,17 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3363
3591
  */
3364
3592
  toTransaction() {
3365
3593
  let upgradePurpose;
3366
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3594
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3367
3595
  upgradePurpose = {
3368
- type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
3596
+ type: import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters,
3369
3597
  data: {
3370
3598
  witnessIndex: this.bytecodeWitnessIndex,
3371
3599
  checksum: this.upgradePurpose.checksum
3372
3600
  }
3373
3601
  };
3374
- } else if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3602
+ } else if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3375
3603
  upgradePurpose = {
3376
- type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
3604
+ type: import_transactions12.UpgradePurposeTypeEnum.StateTransition,
3377
3605
  data: {
3378
3606
  bytecodeRoot: (0, import_utils19.hexlify)(this.upgradePurpose.data)
3379
3607
  }
@@ -3382,7 +3610,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3382
3610
  throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3383
3611
  }
3384
3612
  return {
3385
- type: import_transactions11.TransactionType.Upgrade,
3613
+ type: import_transactions12.TransactionType.Upgrade,
3386
3614
  ...super.getBaseTransaction(),
3387
3615
  upgradePurpose
3388
3616
  };
@@ -3406,7 +3634,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3406
3634
  */
3407
3635
  metadataGas(gasCosts) {
3408
3636
  const txBytesSize = this.byteSize();
3409
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
3637
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.ConsensusParameters) {
3410
3638
  const witnessIndex = this.bytecodeWitnessIndex;
3411
3639
  const consensusSize = this.witnesses[witnessIndex].length;
3412
3640
  return calculateMetadataGasForTxUpgrade({
@@ -3415,7 +3643,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3415
3643
  consensusSize
3416
3644
  });
3417
3645
  }
3418
- if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
3646
+ if (this.upgradePurpose.type === import_transactions12.UpgradePurposeTypeEnum.StateTransition) {
3419
3647
  return calculateMetadataGasForTxUpgrade({
3420
3648
  gasCosts,
3421
3649
  txBytesSize
@@ -3427,7 +3655,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3427
3655
 
3428
3656
  // src/providers/transaction-request/upload-transaction-request.ts
3429
3657
  var import_configs10 = require("@fuel-ts/address/configs");
3430
- var import_transactions12 = require("@fuel-ts/transactions");
3658
+ var import_transactions13 = require("@fuel-ts/transactions");
3431
3659
  var import_utils21 = require("@fuel-ts/utils");
3432
3660
  var import_ramda7 = require("ramda");
3433
3661
  var UploadTransactionRequest = class extends BaseTransactionRequest {
@@ -3438,7 +3666,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3438
3666
  return new this((0, import_ramda7.clone)(obj));
3439
3667
  }
3440
3668
  /** Type of the transaction */
3441
- type = import_transactions12.TransactionType.Upload;
3669
+ type = import_transactions13.TransactionType.Upload;
3442
3670
  /** The witness index of the subsection of the bytecode. */
3443
3671
  witnessIndex;
3444
3672
  /** The subsection data. */
@@ -3487,7 +3715,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3487
3715
  const baseTransaction = this.getBaseTransaction();
3488
3716
  const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
3489
3717
  return {
3490
- type: import_transactions12.TransactionType.Upload,
3718
+ type: import_transactions13.TransactionType.Upload,
3491
3719
  ...baseTransaction,
3492
3720
  subsectionIndex,
3493
3721
  subsectionsNumber,
@@ -3533,26 +3761,26 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3533
3761
 
3534
3762
  // src/providers/transaction-request/utils.ts
3535
3763
  var import_errors13 = require("@fuel-ts/errors");
3536
- var import_transactions13 = require("@fuel-ts/transactions");
3764
+ var import_transactions14 = require("@fuel-ts/transactions");
3537
3765
  var transactionRequestify = (obj) => {
3538
3766
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
3539
3767
  return obj;
3540
3768
  }
3541
3769
  const { type } = obj;
3542
3770
  switch (obj.type) {
3543
- case import_transactions13.TransactionType.Script: {
3771
+ case import_transactions14.TransactionType.Script: {
3544
3772
  return ScriptTransactionRequest.from(obj);
3545
3773
  }
3546
- case import_transactions13.TransactionType.Create: {
3774
+ case import_transactions14.TransactionType.Create: {
3547
3775
  return CreateTransactionRequest.from(obj);
3548
3776
  }
3549
- case import_transactions13.TransactionType.Blob: {
3777
+ case import_transactions14.TransactionType.Blob: {
3550
3778
  return BlobTransactionRequest.from(obj);
3551
3779
  }
3552
- case import_transactions13.TransactionType.Upgrade: {
3780
+ case import_transactions14.TransactionType.Upgrade: {
3553
3781
  return UpgradeTransactionRequest.from(obj);
3554
3782
  }
3555
- case import_transactions13.TransactionType.Upload: {
3783
+ case import_transactions14.TransactionType.Upload: {
3556
3784
  return UploadTransactionRequest.from(obj);
3557
3785
  }
3558
3786
  default: {
@@ -3563,24 +3791,115 @@ var transactionRequestify = (obj) => {
3563
3791
  }
3564
3792
  }
3565
3793
  };
3566
- var isTransactionTypeScript = (request) => request.type === import_transactions13.TransactionType.Script;
3567
- var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
3568
-
3569
- // src/providers/transaction-response/transaction-response.ts
3570
- var import_errors17 = require("@fuel-ts/errors");
3571
- var import_math18 = require("@fuel-ts/math");
3572
- var import_transactions21 = require("@fuel-ts/transactions");
3573
- var import_utils27 = require("@fuel-ts/utils");
3794
+ var isTransactionTypeScript = (request) => request.type === import_transactions14.TransactionType.Script;
3795
+ var isTransactionTypeCreate = (request) => request.type === import_transactions14.TransactionType.Create;
3796
+
3797
+ // src/providers/resource-cache.ts
3798
+ var cache = /* @__PURE__ */ new Map();
3799
+ var ResourceCache = class {
3800
+ ttl;
3801
+ constructor(ttl) {
3802
+ this.ttl = ttl;
3803
+ if (typeof ttl !== "number" || this.ttl <= 0) {
3804
+ throw new import_errors14.FuelError(
3805
+ import_errors14.ErrorCode.INVALID_TTL,
3806
+ `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
3807
+ );
3808
+ }
3809
+ }
3810
+ // Add resources to the cache
3811
+ set(transactionId, inputs) {
3812
+ const transactionResourceCache = this.setupResourcesCache(inputs);
3813
+ cache.set(transactionId, transactionResourceCache);
3814
+ }
3815
+ unset(transactionId) {
3816
+ cache.delete(transactionId);
3817
+ }
3818
+ getActiveData(owner) {
3819
+ const activeData = { utxos: [], messages: [] };
3820
+ const currentTime = Date.now();
3821
+ const expired = [];
3822
+ cache.forEach((resource, transactionId) => {
3823
+ const isActive = currentTime - resource.timestamp < this.ttl;
3824
+ if (isActive) {
3825
+ const resourcesFromOwner = resource.owners.get(owner);
3826
+ if (resourcesFromOwner) {
3827
+ activeData.utxos.push(...resourcesFromOwner.utxos);
3828
+ activeData.messages.push(...resourcesFromOwner.messages);
3829
+ }
3830
+ } else {
3831
+ expired.push(transactionId);
3832
+ }
3833
+ });
3834
+ expired.forEach(this.unset);
3835
+ activeData.utxos.reverse();
3836
+ activeData.messages.reverse();
3837
+ return activeData;
3838
+ }
3839
+ isCached(owner, key) {
3840
+ const currentTime = Date.now();
3841
+ let cached = false;
3842
+ const expired = [];
3843
+ for (const [transactionId, resourceData] of cache.entries()) {
3844
+ const isActive = currentTime - resourceData.timestamp < this.ttl;
3845
+ if (isActive) {
3846
+ const resourcesFromOwner = resourceData.owners.get(owner);
3847
+ if (resourcesFromOwner?.utxos.has(key) || resourcesFromOwner?.messages.has(key)) {
3848
+ cached = true;
3849
+ break;
3850
+ }
3851
+ } else {
3852
+ expired.push(transactionId);
3853
+ }
3854
+ }
3855
+ expired.forEach(this.unset);
3856
+ return cached;
3857
+ }
3858
+ clear() {
3859
+ cache.clear();
3860
+ }
3861
+ setupResourcesCache(inputs) {
3862
+ const currentTime = Date.now();
3863
+ const transactionResourcesCache = {
3864
+ owners: /* @__PURE__ */ new Map(),
3865
+ timestamp: currentTime
3866
+ };
3867
+ inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
3868
+ const { owner, key, type } = this.extractResourceData(input);
3869
+ if (!transactionResourcesCache.owners.has(owner)) {
3870
+ transactionResourcesCache.owners.set(owner, { utxos: /* @__PURE__ */ new Set(), messages: /* @__PURE__ */ new Set() });
3871
+ }
3872
+ if (type === "utxo") {
3873
+ transactionResourcesCache.owners.get(owner)?.utxos.add(key);
3874
+ } else {
3875
+ transactionResourcesCache.owners.get(owner)?.messages.add(key);
3876
+ }
3877
+ });
3878
+ return transactionResourcesCache;
3879
+ }
3880
+ extractResourceData(input) {
3881
+ if (isRequestInputCoin(input)) {
3882
+ return { owner: (0, import_utils23.hexlify)(input.owner), key: (0, import_utils23.hexlify)(input.id), type: "utxo" };
3883
+ }
3884
+ return { owner: (0, import_utils23.hexlify)(input.recipient), key: (0, import_utils23.hexlify)(input.nonce), type: "message" };
3885
+ }
3886
+ };
3887
+
3888
+ // src/providers/transaction-response/transaction-response.ts
3889
+ var import_errors18 = require("@fuel-ts/errors");
3890
+ var import_math18 = require("@fuel-ts/math");
3891
+ var import_transactions22 = require("@fuel-ts/transactions");
3892
+ var import_utils27 = require("@fuel-ts/utils");
3574
3893
 
3575
3894
  // src/providers/transaction-summary/assemble-transaction-summary.ts
3576
3895
  var import_math17 = require("@fuel-ts/math");
3577
- var import_transactions19 = require("@fuel-ts/transactions");
3896
+ var import_transactions20 = require("@fuel-ts/transactions");
3578
3897
  var import_utils25 = require("@fuel-ts/utils");
3579
3898
 
3580
3899
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
3581
3900
  var import_math13 = require("@fuel-ts/math");
3582
- var import_transactions14 = require("@fuel-ts/transactions");
3583
- var import_utils23 = require("@fuel-ts/utils");
3901
+ var import_transactions15 = require("@fuel-ts/transactions");
3902
+ var import_utils24 = require("@fuel-ts/utils");
3584
3903
  var calculateTXFeeForSummary = (params) => {
3585
3904
  const {
3586
3905
  gasPrice,
@@ -3590,17 +3909,17 @@ var calculateTXFeeForSummary = (params) => {
3590
3909
  } = params;
3591
3910
  const gasPerByte = (0, import_math13.bn)(feeParams.gasPerByte);
3592
3911
  const gasPriceFactor = (0, import_math13.bn)(feeParams.gasPriceFactor);
3593
- const transactionBytes = (0, import_utils23.arrayify)(rawPayload);
3594
- const [transaction] = new import_transactions14.TransactionCoder().decode(transactionBytes, 0);
3912
+ const transactionBytes = (0, import_utils24.arrayify)(rawPayload);
3913
+ const [transaction] = new import_transactions15.TransactionCoder().decode(transactionBytes, 0);
3595
3914
  const { type, witnesses, inputs, policies } = transaction;
3596
3915
  let metadataGas = (0, import_math13.bn)(0);
3597
3916
  let gasLimit = (0, import_math13.bn)(0);
3598
- if (type !== import_transactions14.TransactionType.Create && type !== import_transactions14.TransactionType.Script) {
3917
+ if (type !== import_transactions15.TransactionType.Create && type !== import_transactions15.TransactionType.Script) {
3599
3918
  return (0, import_math13.bn)(0);
3600
3919
  }
3601
- if (type === import_transactions14.TransactionType.Create) {
3920
+ if (type === import_transactions15.TransactionType.Create) {
3602
3921
  const { bytecodeWitnessIndex, storageSlots } = transaction;
3603
- const contractBytesSize = (0, import_math13.bn)((0, import_utils23.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
3922
+ const contractBytesSize = (0, import_math13.bn)((0, import_utils24.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
3604
3923
  metadataGas = calculateMetadataGasForTxCreate({
3605
3924
  contractBytesSize,
3606
3925
  gasCosts,
@@ -3624,7 +3943,7 @@ var calculateTXFeeForSummary = (params) => {
3624
3943
  metadataGas,
3625
3944
  txBytesSize: transactionBytes.length
3626
3945
  });
3627
- const witnessLimit = policies.find((policy) => policy.type === import_transactions14.PolicyType.WitnessLimit)?.data;
3946
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions15.PolicyType.WitnessLimit)?.data;
3628
3947
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
3629
3948
  const maxGas = getMaxGas({
3630
3949
  gasPerByte,
@@ -3645,47 +3964,14 @@ var calculateTXFeeForSummary = (params) => {
3645
3964
 
3646
3965
  // src/providers/transaction-summary/operations.ts
3647
3966
  var import_configs11 = require("@fuel-ts/address/configs");
3648
- var import_errors15 = require("@fuel-ts/errors");
3967
+ var import_errors16 = require("@fuel-ts/errors");
3649
3968
  var import_math15 = require("@fuel-ts/math");
3650
- var import_transactions17 = require("@fuel-ts/transactions");
3651
-
3652
- // src/providers/transaction-summary/call.ts
3653
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
3654
- var getFunctionCall = ({ abi, receipt }) => {
3655
- const abiInterface = new import_abi_coder5.Interface(abi);
3656
- const callFunctionSelector = receipt.param1.toHex(8);
3657
- const functionFragment = abiInterface.getFunction(callFunctionSelector);
3658
- const inputs = functionFragment.jsonFn.inputs;
3659
- const encodedArgs = receipt.param2.toHex();
3660
- let argumentsProvided;
3661
- const data = functionFragment.decodeArguments(encodedArgs);
3662
- if (data) {
3663
- argumentsProvided = inputs.reduce((prev, input, index) => {
3664
- const value = data[index];
3665
- const name = input.name;
3666
- if (name) {
3667
- return {
3668
- ...prev,
3669
- // reparse to remove bn
3670
- [name]: JSON.parse(JSON.stringify(value))
3671
- };
3672
- }
3673
- return prev;
3674
- }, {});
3675
- }
3676
- const call = {
3677
- functionSignature: functionFragment.signature,
3678
- functionName: functionFragment.name,
3679
- argumentsProvided,
3680
- ...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
3681
- };
3682
- return call;
3683
- };
3969
+ var import_transactions18 = require("@fuel-ts/transactions");
3684
3970
 
3685
3971
  // src/providers/transaction-summary/input.ts
3686
- var import_errors14 = require("@fuel-ts/errors");
3972
+ var import_errors15 = require("@fuel-ts/errors");
3687
3973
  var import_math14 = require("@fuel-ts/math");
3688
- var import_transactions15 = require("@fuel-ts/transactions");
3974
+ var import_transactions16 = require("@fuel-ts/transactions");
3689
3975
  function getInputsByTypes(inputs, types) {
3690
3976
  return inputs.filter((i) => types.includes(i.type));
3691
3977
  }
@@ -3693,19 +3979,19 @@ function getInputsByType(inputs, type) {
3693
3979
  return inputs.filter((i) => i.type === type);
3694
3980
  }
3695
3981
  function getInputsCoin(inputs) {
3696
- return getInputsByType(inputs, import_transactions15.InputType.Coin);
3982
+ return getInputsByType(inputs, import_transactions16.InputType.Coin);
3697
3983
  }
3698
3984
  function getInputsMessage(inputs) {
3699
- return getInputsByType(inputs, import_transactions15.InputType.Message);
3985
+ return getInputsByType(inputs, import_transactions16.InputType.Message);
3700
3986
  }
3701
3987
  function getInputsCoinAndMessage(inputs) {
3702
- return getInputsByTypes(inputs, [import_transactions15.InputType.Coin, import_transactions15.InputType.Message]);
3988
+ return getInputsByTypes(inputs, [import_transactions16.InputType.Coin, import_transactions16.InputType.Message]);
3703
3989
  }
3704
3990
  function isInputCoin(input) {
3705
- return input.type === import_transactions15.InputType.Coin;
3991
+ return input.type === import_transactions16.InputType.Coin;
3706
3992
  }
3707
3993
  function getInputsContract(inputs) {
3708
- return getInputsByType(inputs, import_transactions15.InputType.Contract);
3994
+ return getInputsByType(inputs, import_transactions16.InputType.Contract);
3709
3995
  }
3710
3996
  function findCoinInput(inputs, assetId) {
3711
3997
  const coinInputs = getInputsCoin(inputs);
@@ -3751,40 +4037,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
3751
4037
  if (!contractInput) {
3752
4038
  return void 0;
3753
4039
  }
3754
- if (contractInput.type !== import_transactions15.InputType.Contract) {
3755
- throw new import_errors14.FuelError(
3756
- import_errors14.ErrorCode.INVALID_TRANSACTION_INPUT,
4040
+ if (contractInput.type !== import_transactions16.InputType.Contract) {
4041
+ throw new import_errors15.FuelError(
4042
+ import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
3757
4043
  `Contract input should be of type 'contract'.`
3758
4044
  );
3759
4045
  }
3760
4046
  return contractInput;
3761
4047
  }
3762
4048
  function getInputAccountAddress(input) {
3763
- if (input.type === import_transactions15.InputType.Coin) {
4049
+ if (input.type === import_transactions16.InputType.Coin) {
3764
4050
  return input.owner.toString();
3765
4051
  }
3766
- if (input.type === import_transactions15.InputType.Message) {
4052
+ if (input.type === import_transactions16.InputType.Message) {
3767
4053
  return input.recipient.toString();
3768
4054
  }
3769
4055
  return "";
3770
4056
  }
3771
4057
 
3772
4058
  // src/providers/transaction-summary/output.ts
3773
- var import_transactions16 = require("@fuel-ts/transactions");
4059
+ var import_transactions17 = require("@fuel-ts/transactions");
3774
4060
  function getOutputsByType(outputs, type) {
3775
4061
  return outputs.filter((o) => o.type === type);
3776
4062
  }
3777
4063
  function getOutputsContractCreated(outputs) {
3778
- return getOutputsByType(outputs, import_transactions16.OutputType.ContractCreated);
4064
+ return getOutputsByType(outputs, import_transactions17.OutputType.ContractCreated);
3779
4065
  }
3780
4066
  function getOutputsCoin(outputs) {
3781
- return getOutputsByType(outputs, import_transactions16.OutputType.Coin);
4067
+ return getOutputsByType(outputs, import_transactions17.OutputType.Coin);
3782
4068
  }
3783
4069
  function getOutputsChange(outputs) {
3784
- return getOutputsByType(outputs, import_transactions16.OutputType.Change);
4070
+ return getOutputsByType(outputs, import_transactions17.OutputType.Change);
3785
4071
  }
3786
4072
  function getOutputsContract(outputs) {
3787
- return getOutputsByType(outputs, import_transactions16.OutputType.Contract);
4073
+ return getOutputsByType(outputs, import_transactions17.OutputType.Contract);
3788
4074
  }
3789
4075
 
3790
4076
  // src/providers/transaction-summary/operations.ts
@@ -3793,21 +4079,21 @@ function getReceiptsByType(receipts, type) {
3793
4079
  }
3794
4080
  function getTransactionTypeName(transactionType) {
3795
4081
  switch (transactionType) {
3796
- case import_transactions17.TransactionType.Mint:
4082
+ case import_transactions18.TransactionType.Mint:
3797
4083
  return "Mint" /* Mint */;
3798
- case import_transactions17.TransactionType.Create:
4084
+ case import_transactions18.TransactionType.Create:
3799
4085
  return "Create" /* Create */;
3800
- case import_transactions17.TransactionType.Script:
4086
+ case import_transactions18.TransactionType.Script:
3801
4087
  return "Script" /* Script */;
3802
- case import_transactions17.TransactionType.Blob:
4088
+ case import_transactions18.TransactionType.Blob:
3803
4089
  return "Blob" /* Blob */;
3804
- case import_transactions17.TransactionType.Upgrade:
4090
+ case import_transactions18.TransactionType.Upgrade:
3805
4091
  return "Upgrade" /* Upgrade */;
3806
- case import_transactions17.TransactionType.Upload:
4092
+ case import_transactions18.TransactionType.Upload:
3807
4093
  return "Upload" /* Upload */;
3808
4094
  default:
3809
- throw new import_errors15.FuelError(
3810
- import_errors15.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4095
+ throw new import_errors16.FuelError(
4096
+ import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3811
4097
  `Unsupported transaction type: ${transactionType}.`
3812
4098
  );
3813
4099
  }
@@ -3835,10 +4121,10 @@ function isTypeBlob(transactionType) {
3835
4121
  return isType(transactionType, "Blob" /* Blob */);
3836
4122
  }
3837
4123
  function getReceiptsCall(receipts) {
3838
- return getReceiptsByType(receipts, import_transactions17.ReceiptType.Call);
4124
+ return getReceiptsByType(receipts, import_transactions18.ReceiptType.Call);
3839
4125
  }
3840
4126
  function getReceiptsMessageOut(receipts) {
3841
- return getReceiptsByType(receipts, import_transactions17.ReceiptType.MessageOut);
4127
+ return getReceiptsByType(receipts, import_transactions18.ReceiptType.MessageOut);
3842
4128
  }
3843
4129
  function mergeAssets(op1, op2) {
3844
4130
  const assets1 = op1.assetsSent || [];
@@ -3876,7 +4162,11 @@ function mergeOperations(existing, toAdd) {
3876
4162
  return {
3877
4163
  ...existing,
3878
4164
  assetsSent: mergeAssetsSent(existing, toAdd),
3879
- calls: mergeCalls(existing, toAdd)
4165
+ calls: mergeCalls(existing, toAdd),
4166
+ receipts: [
4167
+ ...existing.receipts || [],
4168
+ ...toAdd.receipts?.filter((r) => !existing.receipts?.some((er) => er === r)) || []
4169
+ ]
3880
4170
  };
3881
4171
  }
3882
4172
  function addOperation(operations, toAdd) {
@@ -3913,7 +4203,8 @@ function getWithdrawFromFuelOperations({
3913
4203
  amount: receipt.amount,
3914
4204
  assetId: baseAssetId
3915
4205
  }
3916
- ]
4206
+ ],
4207
+ receipts: [receipt]
3917
4208
  });
3918
4209
  return newWithdrawFromFuelOps;
3919
4210
  }
@@ -3923,19 +4214,12 @@ function getWithdrawFromFuelOperations({
3923
4214
  );
3924
4215
  return withdrawFromFuelOperations;
3925
4216
  }
3926
- function getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs) {
4217
+ function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
3927
4218
  const abi = abiMap?.[contractInput.contractID];
3928
4219
  if (!abi) {
3929
4220
  return [];
3930
4221
  }
3931
- return [
3932
- getFunctionCall({
3933
- abi,
3934
- receipt,
3935
- rawPayload,
3936
- maxInputs
3937
- })
3938
- ];
4222
+ return [];
3939
4223
  }
3940
4224
  function getAssetsSent(receipt) {
3941
4225
  return receipt.amount?.isZero() ? void 0 : [
@@ -3965,7 +4249,8 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
3965
4249
  address: receipt.to
3966
4250
  },
3967
4251
  assetsSent: getAssetsSent(receipt),
3968
- calls
4252
+ calls,
4253
+ receipts: [receipt]
3969
4254
  }
3970
4255
  ];
3971
4256
  }
@@ -4022,7 +4307,8 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
4022
4307
  assetId: assetId.toString(),
4023
4308
  amount
4024
4309
  }
4025
- ]
4310
+ ],
4311
+ receipts: [receipt]
4026
4312
  };
4027
4313
  }
4028
4314
  function getTransferOperations({
@@ -4067,11 +4353,11 @@ function getTransferOperations({
4067
4353
  });
4068
4354
  const transferReceipts = getReceiptsByType(
4069
4355
  receipts,
4070
- import_transactions17.ReceiptType.Transfer
4356
+ import_transactions18.ReceiptType.Transfer
4071
4357
  );
4072
4358
  const transferOutReceipts = getReceiptsByType(
4073
4359
  receipts,
4074
- import_transactions17.ReceiptType.TransferOut
4360
+ import_transactions18.ReceiptType.TransferOut
4075
4361
  );
4076
4362
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
4077
4363
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -4155,12 +4441,11 @@ function getOperations({
4155
4441
  }
4156
4442
 
4157
4443
  // src/providers/transaction-summary/receipt.ts
4158
- var import_transactions18 = require("@fuel-ts/transactions");
4159
- var processGqlReceipt = (gqlReceipt) => assembleReceiptByType(gqlReceipt);
4444
+ var import_transactions19 = require("@fuel-ts/transactions");
4160
4445
  var extractMintedAssetsFromReceipts = (receipts) => {
4161
4446
  const mintedAssets = [];
4162
4447
  receipts.forEach((receipt) => {
4163
- if (receipt.type === import_transactions18.ReceiptType.Mint) {
4448
+ if (receipt.type === import_transactions19.ReceiptType.Mint) {
4164
4449
  mintedAssets.push({
4165
4450
  subId: receipt.subId,
4166
4451
  contractId: receipt.contractId,
@@ -4174,7 +4459,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
4174
4459
  var extractBurnedAssetsFromReceipts = (receipts) => {
4175
4460
  const burnedAssets = [];
4176
4461
  receipts.forEach((receipt) => {
4177
- if (receipt.type === import_transactions18.ReceiptType.Burn) {
4462
+ if (receipt.type === import_transactions19.ReceiptType.Burn) {
4178
4463
  burnedAssets.push({
4179
4464
  subId: receipt.subId,
4180
4465
  contractId: receipt.contractId,
@@ -4187,7 +4472,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
4187
4472
  };
4188
4473
 
4189
4474
  // src/providers/transaction-summary/status.ts
4190
- var import_errors16 = require("@fuel-ts/errors");
4475
+ var import_errors17 = require("@fuel-ts/errors");
4191
4476
  var import_math16 = require("@fuel-ts/math");
4192
4477
  var getTransactionStatusName = (gqlStatus) => {
4193
4478
  switch (gqlStatus) {
@@ -4200,8 +4485,8 @@ var getTransactionStatusName = (gqlStatus) => {
4200
4485
  case "SqueezedOutStatus":
4201
4486
  return "squeezedout" /* squeezedout */;
4202
4487
  default:
4203
- throw new import_errors16.FuelError(
4204
- import_errors16.ErrorCode.INVALID_TRANSACTION_STATUS,
4488
+ throw new import_errors17.FuelError(
4489
+ import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
4205
4490
  `Invalid transaction status: ${gqlStatus}.`
4206
4491
  );
4207
4492
  }
@@ -4283,7 +4568,7 @@ function assembleTransactionSummary(params) {
4283
4568
  baseAssetId
4284
4569
  });
4285
4570
  const typeName = getTransactionTypeName(transaction.type);
4286
- const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
4571
+ const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions20.PolicyType.Tip)?.data);
4287
4572
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
4288
4573
  const fee = totalFee ?? calculateTXFeeForSummary({
4289
4574
  gasPrice,
@@ -4333,13 +4618,13 @@ function assembleTransactionSummary(params) {
4333
4618
  }
4334
4619
 
4335
4620
  // src/providers/transaction-response/getDecodedLogs.ts
4336
- var import_abi_coder6 = require("@fuel-ts/abi-coder");
4337
- var import_transactions20 = require("@fuel-ts/transactions");
4621
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
4622
+ var import_transactions21 = require("@fuel-ts/transactions");
4338
4623
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4339
4624
  return receipts.reduce((logs, receipt) => {
4340
- if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
4341
- const interfaceToUse = new import_abi_coder6.Interface(externalAbis[receipt.id] || mainAbi);
4342
- const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4625
+ if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
4626
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
4627
+ const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4343
4628
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4344
4629
  logs.push(decodedLog);
4345
4630
  }
@@ -4353,24 +4638,24 @@ function mapGqlOutputsToTxOutputs(outputs) {
4353
4638
  const obj = "amount" in o ? { ...o, amount: (0, import_math18.bn)(o.amount) } : o;
4354
4639
  switch (obj.type) {
4355
4640
  case "CoinOutput":
4356
- return { ...obj, type: import_transactions21.OutputType.Coin };
4641
+ return { ...obj, type: import_transactions22.OutputType.Coin };
4357
4642
  case "ContractOutput":
4358
4643
  return {
4359
4644
  ...obj,
4360
- type: import_transactions21.OutputType.Contract,
4645
+ type: import_transactions22.OutputType.Contract,
4361
4646
  inputIndex: parseInt(obj.inputIndex, 10)
4362
4647
  };
4363
4648
  case "ChangeOutput":
4364
4649
  return {
4365
4650
  ...obj,
4366
- type: import_transactions21.OutputType.Change
4651
+ type: import_transactions22.OutputType.Change
4367
4652
  };
4368
4653
  case "VariableOutput":
4369
- return { ...obj, type: import_transactions21.OutputType.Variable };
4654
+ return { ...obj, type: import_transactions22.OutputType.Variable };
4370
4655
  case "ContractCreated":
4371
4656
  return {
4372
4657
  ...obj,
4373
- type: import_transactions21.OutputType.ContractCreated,
4658
+ type: import_transactions22.OutputType.ContractCreated,
4374
4659
  contractId: obj.contract
4375
4660
  };
4376
4661
  default:
@@ -4391,6 +4676,7 @@ var TransactionResponse = class {
4391
4676
  this.provider = provider;
4392
4677
  this.abis = abis;
4393
4678
  this.request = typeof tx === "string" ? void 0 : tx;
4679
+ this.waitForResult = this.waitForResult.bind(this);
4394
4680
  }
4395
4681
  /** Transaction ID */
4396
4682
  id;
@@ -4429,7 +4715,7 @@ var TransactionResponse = class {
4429
4715
  const correspondingInput = status.transaction.inputs?.[idx];
4430
4716
  return {
4431
4717
  ...input,
4432
- txPointer: import_transactions21.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
4718
+ txPointer: import_transactions22.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
4433
4719
  };
4434
4720
  }
4435
4721
  return input;
@@ -4460,7 +4746,7 @@ var TransactionResponse = class {
4460
4746
  switch (status?.type) {
4461
4747
  case "SuccessStatus":
4462
4748
  case "FailureStatus":
4463
- return status.receipts.map(processGqlReceipt);
4749
+ return status.receipts.map(deserializeReceipt);
4464
4750
  default:
4465
4751
  return [];
4466
4752
  }
@@ -4496,7 +4782,7 @@ var TransactionResponse = class {
4496
4782
  * @returns The decoded transaction.
4497
4783
  */
4498
4784
  decodeTransaction(transactionWithReceipts) {
4499
- return new import_transactions21.TransactionCoder().decode(
4785
+ return new import_transactions22.TransactionCoder().decode(
4500
4786
  (0, import_utils27.arrayify)(transactionWithReceipts.rawPayload),
4501
4787
  0
4502
4788
  )?.[0];
@@ -4545,8 +4831,8 @@ var TransactionResponse = class {
4545
4831
  this.status = statusChange;
4546
4832
  if (statusChange.type === "SqueezedOutStatus") {
4547
4833
  this.unsetResourceCache();
4548
- throw new import_errors17.FuelError(
4549
- import_errors17.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4834
+ throw new import_errors18.FuelError(
4835
+ import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4550
4836
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4551
4837
  );
4552
4838
  }
@@ -4584,7 +4870,6 @@ var TransactionResponse = class {
4584
4870
  const { receipts } = transactionResult;
4585
4871
  const status = this.status ?? this.gqlTransaction?.status;
4586
4872
  if (status?.type === "FailureStatus") {
4587
- this.unsetResourceCache();
4588
4873
  const { reason } = status;
4589
4874
  throw extractTxError({
4590
4875
  receipts,
@@ -4601,6 +4886,7 @@ var TransactionResponse = class {
4601
4886
  */
4602
4887
  async waitForResult(contractsAbiMap) {
4603
4888
  await this.waitForStatusChange();
4889
+ this.unsetResourceCache();
4604
4890
  return this.assembleResult(contractsAbiMap);
4605
4891
  }
4606
4892
  /**
@@ -4653,27 +4939,20 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4653
4939
  };
4654
4940
  }
4655
4941
 
4656
- // src/providers/utils/handle-gql-error-message.ts
4657
- var import_errors18 = require("@fuel-ts/errors");
4658
- var handleGqlErrorMessage = (errorMessage, rawError) => {
4659
- switch (errorMessage) {
4660
- case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4661
- throw new import_errors18.FuelError(
4662
- import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
4663
- `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4664
- {},
4665
- rawError
4666
- );
4667
- case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4668
- throw new import_errors18.FuelError(
4669
- import_errors18.ErrorCode.MAX_COINS_REACHED,
4670
- "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4671
- {},
4672
- rawError
4673
- );
4674
- default:
4675
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_REQUEST, errorMessage);
4676
- }
4942
+ // src/providers/utils/helpers.ts
4943
+ var adjustResourcesToExclude = (params) => {
4944
+ const { userInput, cached, maxInputs } = params;
4945
+ const final = { ...userInput };
4946
+ let total = final.utxos.length + final.messages.length;
4947
+ if (total >= maxInputs) {
4948
+ return final;
4949
+ }
4950
+ final.utxos = [...final.utxos, ...cached.utxos.slice(0, maxInputs - total)];
4951
+ total = final.utxos.length + final.messages.length;
4952
+ if (total < maxInputs) {
4953
+ final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
4954
+ }
4955
+ return final;
4677
4956
  };
4678
4957
 
4679
4958
  // src/providers/utils/validate-pagination-args.ts
@@ -4715,64 +4994,10 @@ var validatePaginationArgs = (params) => {
4715
4994
  var MAX_RETRIES = 10;
4716
4995
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
4717
4996
  var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
4997
+ var BALANCES_PAGE_SIZE_LIMIT = 100;
4718
4998
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
4719
4999
  var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
4720
5000
  var GAS_USED_MODIFIER = 1.2;
4721
- var processGqlChain = (chain) => {
4722
- const { name, daHeight, consensusParameters } = chain;
4723
- const {
4724
- contractParams,
4725
- feeParams,
4726
- predicateParams,
4727
- scriptParams,
4728
- txParams,
4729
- gasCosts,
4730
- baseAssetId,
4731
- chainId,
4732
- version
4733
- } = consensusParameters;
4734
- return {
4735
- name,
4736
- baseChainHeight: (0, import_math19.bn)(daHeight),
4737
- consensusParameters: {
4738
- version,
4739
- chainId: (0, import_math19.bn)(chainId),
4740
- baseAssetId,
4741
- feeParameters: {
4742
- version: feeParams.version,
4743
- gasPerByte: (0, import_math19.bn)(feeParams.gasPerByte),
4744
- gasPriceFactor: (0, import_math19.bn)(feeParams.gasPriceFactor)
4745
- },
4746
- contractParameters: {
4747
- version: contractParams.version,
4748
- contractMaxSize: (0, import_math19.bn)(contractParams.contractMaxSize),
4749
- maxStorageSlots: (0, import_math19.bn)(contractParams.maxStorageSlots)
4750
- },
4751
- txParameters: {
4752
- version: txParams.version,
4753
- maxInputs: (0, import_math19.bn)(txParams.maxInputs),
4754
- maxOutputs: (0, import_math19.bn)(txParams.maxOutputs),
4755
- maxWitnesses: (0, import_math19.bn)(txParams.maxWitnesses),
4756
- maxGasPerTx: (0, import_math19.bn)(txParams.maxGasPerTx),
4757
- maxSize: (0, import_math19.bn)(txParams.maxSize),
4758
- maxBytecodeSubsections: (0, import_math19.bn)(txParams.maxBytecodeSubsections)
4759
- },
4760
- predicateParameters: {
4761
- version: predicateParams.version,
4762
- maxPredicateLength: (0, import_math19.bn)(predicateParams.maxPredicateLength),
4763
- maxPredicateDataLength: (0, import_math19.bn)(predicateParams.maxPredicateDataLength),
4764
- maxGasPerPredicate: (0, import_math19.bn)(predicateParams.maxGasPerPredicate),
4765
- maxMessageDataLength: (0, import_math19.bn)(predicateParams.maxMessageDataLength)
4766
- },
4767
- scriptParameters: {
4768
- version: scriptParams.version,
4769
- maxScriptLength: (0, import_math19.bn)(scriptParams.maxScriptLength),
4770
- maxScriptDataLength: (0, import_math19.bn)(scriptParams.maxScriptDataLength)
4771
- },
4772
- gasCosts
4773
- }
4774
- };
4775
- };
4776
5001
  var _cacheInputs, cacheInputs_fn;
4777
5002
  var _Provider = class {
4778
5003
  /**
@@ -4794,13 +5019,19 @@ var _Provider = class {
4794
5019
  /** @hidden */
4795
5020
  __publicField(this, "urlWithoutAuth");
4796
5021
  /** @hidden */
5022
+ __publicField(this, "features", {
5023
+ balancePagination: false,
5024
+ amount128: false
5025
+ });
5026
+ /** @hidden */
4797
5027
  __publicField(this, "consensusParametersTimestamp");
4798
5028
  __publicField(this, "options", {
4799
5029
  timeout: void 0,
4800
5030
  resourceCacheTTL: void 0,
4801
5031
  fetch: void 0,
4802
5032
  retryOptions: void 0,
4803
- headers: void 0
5033
+ headers: void 0,
5034
+ cache: void 0
4804
5035
  });
4805
5036
  const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
4806
5037
  this.url = rawUrl;
@@ -4814,7 +5045,13 @@ var _Provider = class {
4814
5045
  headers
4815
5046
  };
4816
5047
  this.operations = this.createOperations();
4817
- const { resourceCacheTTL } = this.options;
5048
+ const { resourceCacheTTL, cache: cache2 } = this.options;
5049
+ if (cache2) {
5050
+ const { consensusParametersTimestamp, chain, nodeInfo } = deserializeProviderCache(cache2);
5051
+ this.consensusParametersTimestamp = consensusParametersTimestamp;
5052
+ _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
5053
+ _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
5054
+ }
4818
5055
  if ((0, import_utils30.isDefined)(resourceCacheTTL)) {
4819
5056
  if (resourceCacheTTL !== -1) {
4820
5057
  this.cache = new ResourceCache(resourceCacheTTL);
@@ -4873,7 +5110,8 @@ var _Provider = class {
4873
5110
  * Initialize Provider async stuff
4874
5111
  */
4875
5112
  async init() {
4876
- await this.fetchChainAndNodeInfo();
5113
+ const { nodeInfo } = await this.fetchChainAndNodeInfo();
5114
+ this.setupFeatures(nodeInfo.nodeVersion);
4877
5115
  return this;
4878
5116
  }
4879
5117
  /**
@@ -4944,15 +5182,9 @@ var _Provider = class {
4944
5182
  }
4945
5183
  } catch (_err) {
4946
5184
  const data = await this.operations.getChainAndNodeInfo();
4947
- nodeInfo = {
4948
- maxDepth: (0, import_math19.bn)(data.nodeInfo.maxDepth),
4949
- maxTx: (0, import_math19.bn)(data.nodeInfo.maxTx),
4950
- nodeVersion: data.nodeInfo.nodeVersion,
4951
- utxoValidation: data.nodeInfo.utxoValidation,
4952
- vmBacktrace: data.nodeInfo.vmBacktrace
4953
- };
4954
- _Provider.ensureClientVersionIsSupported(nodeInfo);
4955
- chain = processGqlChain(data.chain);
5185
+ nodeInfo = deserializeNodeInfo(data.nodeInfo);
5186
+ _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
5187
+ chain = deserializeChain(data.chain);
4956
5188
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
4957
5189
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
4958
5190
  this.consensusParametersTimestamp = Date.now();
@@ -4965,15 +5197,15 @@ var _Provider = class {
4965
5197
  /**
4966
5198
  * @hidden
4967
5199
  */
4968
- static ensureClientVersionIsSupported(nodeInfo) {
5200
+ static setIncompatibleNodeVersionMessage(nodeInfo) {
4969
5201
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
4970
5202
  if (!isMajorSupported || !isMinorSupported) {
4971
- console.warn(
4972
- `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
4973
- which is not supported by the version of the TS SDK that you are using.
4974
- Things may not work as expected.
4975
- Supported fuel-core version: ${supportedVersion}.`
4976
- );
5203
+ _Provider.incompatibleNodeVersionMessage = [
5204
+ `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}.`,
5205
+ `The TS SDK currently supports fuel-core version ${supportedVersion}.`,
5206
+ `Things may not work as expected.`
5207
+ ].join("\n");
5208
+ FuelGraphqlSubscriber.incompatibleNodeVersionMessage = _Provider.incompatibleNodeVersionMessage;
4977
5209
  }
4978
5210
  }
4979
5211
  /**
@@ -4989,11 +5221,10 @@ Supported fuel-core version: ${supportedVersion}.`
4989
5221
  responseMiddleware: (response) => {
4990
5222
  if ("response" in response) {
4991
5223
  const graphQlResponse = response.response;
4992
- if (Array.isArray(graphQlResponse?.errors)) {
4993
- for (const error of graphQlResponse.errors) {
4994
- handleGqlErrorMessage(error.message, error);
4995
- }
4996
- }
5224
+ assertGqlResponseHasNoErrors(
5225
+ graphQlResponse.errors,
5226
+ _Provider.incompatibleNodeVersionMessage
5227
+ );
4997
5228
  }
4998
5229
  }
4999
5230
  });
@@ -5031,6 +5262,15 @@ Supported fuel-core version: ${supportedVersion}.`
5031
5262
  });
5032
5263
  return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
5033
5264
  }
5265
+ /**
5266
+ * @hidden
5267
+ */
5268
+ setupFeatures(nodeVersion) {
5269
+ if ((0, import_versions.gte)(nodeVersion, "0.41.0")) {
5270
+ this.features.balancePagination = true;
5271
+ this.features.amount128 = true;
5272
+ }
5273
+ }
5034
5274
  /**
5035
5275
  * Returns the version of the connected node.
5036
5276
  *
@@ -5062,13 +5302,7 @@ Supported fuel-core version: ${supportedVersion}.`
5062
5302
  */
5063
5303
  async fetchNode() {
5064
5304
  const { nodeInfo } = await this.operations.getNodeInfo();
5065
- const processedNodeInfo = {
5066
- maxDepth: (0, import_math19.bn)(nodeInfo.maxDepth),
5067
- maxTx: (0, import_math19.bn)(nodeInfo.maxTx),
5068
- nodeVersion: nodeInfo.nodeVersion,
5069
- utxoValidation: nodeInfo.utxoValidation,
5070
- vmBacktrace: nodeInfo.vmBacktrace
5071
- };
5305
+ const processedNodeInfo = deserializeNodeInfo(nodeInfo);
5072
5306
  _Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
5073
5307
  return processedNodeInfo;
5074
5308
  }
@@ -5079,7 +5313,7 @@ Supported fuel-core version: ${supportedVersion}.`
5079
5313
  */
5080
5314
  async fetchChain() {
5081
5315
  const { chain } = await this.operations.getChain();
5082
- const processedChain = processGqlChain(chain);
5316
+ const processedChain = deserializeChain(chain);
5083
5317
  _Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
5084
5318
  return processedChain;
5085
5319
  }
@@ -5106,6 +5340,21 @@ Supported fuel-core version: ${supportedVersion}.`
5106
5340
  } = all;
5107
5341
  return baseAssetId;
5108
5342
  }
5343
+ /**
5344
+ * Retrieves the details of an asset given its ID.
5345
+ *
5346
+ * @param assetId - The unique identifier of the asset.
5347
+ * @returns A promise that resolves to an object containing the asset details.
5348
+ */
5349
+ async getAssetDetails(assetId) {
5350
+ const { assetDetails } = await this.operations.getAssetDetails({ assetId });
5351
+ const { contractId, subId, totalSupply } = assetDetails;
5352
+ return {
5353
+ subId,
5354
+ contractId,
5355
+ totalSupply: (0, import_math19.bn)(totalSupply)
5356
+ };
5357
+ }
5109
5358
  /**
5110
5359
  * @hidden
5111
5360
  */
@@ -5180,22 +5429,20 @@ Supported fuel-core version: ${supportedVersion}.`
5180
5429
  utxoValidation: utxoValidation || false
5181
5430
  });
5182
5431
  const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
5183
- const receipts = rawReceipts.map(processGqlReceipt);
5432
+ const receipts = rawReceipts.map(deserializeReceipt);
5184
5433
  return { receipts, dryRunStatus };
5185
5434
  }
5186
5435
  /**
5187
- * Verifies whether enough gas is available to complete transaction.
5436
+ * Estimates the gas usage for predicates in a transaction request.
5188
5437
  *
5189
5438
  * @template T - The type of the transaction request object.
5190
5439
  *
5191
- * @param transactionRequest - The transaction request object.
5192
- * @returns A promise that resolves to the estimated transaction request object.
5440
+ * @param transactionRequest - The transaction request to estimate predicates for.
5441
+ * @returns A promise that resolves to the updated transaction request with estimated gas usage for predicates.
5193
5442
  */
5194
5443
  async estimatePredicates(transactionRequest) {
5195
- const shouldEstimatePredicates = Boolean(
5196
- transactionRequest.inputs.find(
5197
- (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()
5198
- )
5444
+ const shouldEstimatePredicates = transactionRequest.inputs.some(
5445
+ (input) => isPredicate(input) && (0, import_math19.bn)(input.predicateGasUsed).isZero()
5199
5446
  );
5200
5447
  if (!shouldEstimatePredicates) {
5201
5448
  return transactionRequest;
@@ -5204,18 +5451,42 @@ Supported fuel-core version: ${supportedVersion}.`
5204
5451
  const response = await this.operations.estimatePredicates({
5205
5452
  encodedTransaction
5206
5453
  });
5207
- const {
5208
- estimatePredicates: { inputs }
5209
- } = response;
5210
- if (inputs) {
5211
- inputs.forEach((input, index) => {
5212
- if ("predicateGasUsed" in input && (0, import_math19.bn)(input.predicateGasUsed).gt(0)) {
5213
- transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
5214
- }
5215
- });
5216
- }
5454
+ const { estimatePredicates } = response;
5455
+ transactionRequest = this.parseEstimatePredicatesResponse(
5456
+ transactionRequest,
5457
+ estimatePredicates
5458
+ );
5217
5459
  return transactionRequest;
5218
5460
  }
5461
+ /**
5462
+ * Estimates the gas price and predicates for a given transaction request and block horizon.
5463
+ *
5464
+ * @param transactionRequest - The transaction request to estimate predicates and gas price for.
5465
+ * @param blockHorizon - The block horizon to use for gas price estimation.
5466
+ * @returns A promise that resolves to an object containing the updated transaction
5467
+ * request and the estimated gas price.
5468
+ */
5469
+ async estimatePredicatesAndGasPrice(transactionRequest, blockHorizon) {
5470
+ const shouldEstimatePredicates = transactionRequest.inputs.some(
5471
+ (input) => isPredicate(input) && (0, import_math19.bn)(input.predicateGasUsed).isZero()
5472
+ );
5473
+ if (!shouldEstimatePredicates) {
5474
+ const gasPrice2 = await this.estimateGasPrice(blockHorizon);
5475
+ return { transactionRequest, gasPrice: gasPrice2 };
5476
+ }
5477
+ const {
5478
+ estimateGasPrice: { gasPrice },
5479
+ estimatePredicates
5480
+ } = await this.operations.estimatePredicatesAndGasPrice({
5481
+ blockHorizon: String(blockHorizon),
5482
+ encodedTransaction: (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())
5483
+ });
5484
+ transactionRequest = this.parseEstimatePredicatesResponse(
5485
+ transactionRequest,
5486
+ estimatePredicates
5487
+ );
5488
+ return { transactionRequest, gasPrice: (0, import_math19.bn)(gasPrice) };
5489
+ }
5219
5490
  /**
5220
5491
  * Will dryRun a transaction and check for missing dependencies.
5221
5492
  *
@@ -5223,30 +5494,35 @@ Supported fuel-core version: ${supportedVersion}.`
5223
5494
  * `addVariableOutputs` is called on the transaction.
5224
5495
  *
5225
5496
  * @param transactionRequest - The transaction request object.
5497
+ * @param gasPrice - The gas price to use for the transaction, if not provided it will be fetched.
5226
5498
  * @returns A promise that resolves to the estimate transaction dependencies.
5227
5499
  */
5228
- async estimateTxDependencies(transactionRequest) {
5500
+ async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
5229
5501
  if (isTransactionTypeCreate(transactionRequest)) {
5230
5502
  return {
5503
+ rawReceipts: [],
5231
5504
  receipts: [],
5232
5505
  outputVariables: 0,
5233
5506
  missingContractIds: []
5234
5507
  };
5235
5508
  }
5509
+ let rawReceipts = [];
5236
5510
  let receipts = [];
5237
5511
  const missingContractIds = [];
5238
5512
  let outputVariables = 0;
5239
5513
  let dryRunStatus;
5240
5514
  await this.validateTransaction(transactionRequest);
5515
+ const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
5241
5516
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5242
5517
  const {
5243
- dryRun: [{ receipts: rawReceipts, status }]
5518
+ dryRun: [{ receipts: serializedReceipts, status }]
5244
5519
  } = await this.operations.dryRun({
5245
5520
  encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
5246
5521
  utxoValidation: false,
5247
- gasPrice: "0"
5522
+ gasPrice: gasPrice.toString()
5248
5523
  });
5249
- receipts = rawReceipts.map(processGqlReceipt);
5524
+ rawReceipts = serializedReceipts;
5525
+ receipts = serializedReceipts.map(deserializeReceipt);
5250
5526
  dryRunStatus = status;
5251
5527
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
5252
5528
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
@@ -5254,12 +5530,12 @@ Supported fuel-core version: ${supportedVersion}.`
5254
5530
  outputVariables += missingOutputVariables.length;
5255
5531
  transactionRequest.addVariableOutputs(missingOutputVariables.length);
5256
5532
  missingOutputContractIds.forEach(({ contractId }) => {
5257
- transactionRequest.addContractInputAndOutput(import_address4.Address.fromString(contractId));
5533
+ transactionRequest.addContractInputAndOutput(new import_address4.Address(contractId));
5258
5534
  missingContractIds.push(contractId);
5259
5535
  });
5260
5536
  const { maxFee } = await this.estimateTxGasAndFee({
5261
5537
  transactionRequest,
5262
- gasPrice: (0, import_math19.bn)(0)
5538
+ gasPrice
5263
5539
  });
5264
5540
  transactionRequest.maxFee = maxFee;
5265
5541
  } else {
@@ -5267,6 +5543,7 @@ Supported fuel-core version: ${supportedVersion}.`
5267
5543
  }
5268
5544
  }
5269
5545
  return {
5546
+ rawReceipts,
5270
5547
  receipts,
5271
5548
  outputVariables,
5272
5549
  missingContractIds,
@@ -5285,6 +5562,7 @@ Supported fuel-core version: ${supportedVersion}.`
5285
5562
  */
5286
5563
  async estimateMultipleTxDependencies(transactionRequests) {
5287
5564
  const results = transactionRequests.map(() => ({
5565
+ rawReceipts: [],
5288
5566
  receipts: [],
5289
5567
  outputVariables: 0,
5290
5568
  missingContractIds: [],
@@ -5312,7 +5590,7 @@ Supported fuel-core version: ${supportedVersion}.`
5312
5590
  const requestIdx = transactionsToProcess[i];
5313
5591
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
5314
5592
  const result = results[requestIdx];
5315
- result.receipts = rawReceipts.map(processGqlReceipt);
5593
+ result.receipts = rawReceipts.map(deserializeReceipt);
5316
5594
  result.dryRunStatus = status;
5317
5595
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
5318
5596
  result.receipts
@@ -5323,7 +5601,7 @@ Supported fuel-core version: ${supportedVersion}.`
5323
5601
  result.outputVariables += missingOutputVariables.length;
5324
5602
  request.addVariableOutputs(missingOutputVariables.length);
5325
5603
  missingOutputContractIds.forEach(({ contractId }) => {
5326
- request.addContractInputAndOutput(import_address4.Address.fromString(contractId));
5604
+ request.addContractInputAndOutput(new import_address4.Address(contractId));
5327
5605
  result.missingContractIds.push(contractId);
5328
5606
  });
5329
5607
  const { maxFee } = await this.estimateTxGasAndFee({
@@ -5357,7 +5635,7 @@ Supported fuel-core version: ${supportedVersion}.`
5357
5635
  utxoValidation: utxoValidation || false
5358
5636
  });
5359
5637
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
5360
- const receipts = rawReceipts.map(processGqlReceipt);
5638
+ const receipts = rawReceipts.map(deserializeReceipt);
5361
5639
  return { receipts, dryRunStatus: status };
5362
5640
  });
5363
5641
  return results;
@@ -5389,12 +5667,12 @@ Supported fuel-core version: ${supportedVersion}.`
5389
5667
  }
5390
5668
  /**
5391
5669
  * Estimates the transaction gas and fee based on the provided transaction request.
5392
- * @param transactionRequest - The transaction request object.
5670
+ * @param params - The parameters for estimating the transaction gas and fee.
5393
5671
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
5394
5672
  */
5395
5673
  async estimateTxGasAndFee(params) {
5396
- const { transactionRequest } = params;
5397
- let { gasPrice } = params;
5674
+ const { transactionRequest, gasPrice: gasPriceParam } = params;
5675
+ let gasPrice = gasPriceParam;
5398
5676
  await this.autoRefetchConfigs();
5399
5677
  const chainInfo = await this.getChain();
5400
5678
  const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
@@ -5458,7 +5736,7 @@ Supported fuel-core version: ${supportedVersion}.`
5458
5736
  });
5459
5737
  const callResult = dryRunStatuses.map((dryRunStatus) => {
5460
5738
  const { id, receipts, status } = dryRunStatus;
5461
- const processedReceipts = receipts.map(processGqlReceipt);
5739
+ const processedReceipts = receipts.map(deserializeReceipt);
5462
5740
  return { id, receipts: processedReceipts, status };
5463
5741
  });
5464
5742
  return { receipts: callResult[0].receipts };
@@ -5475,7 +5753,7 @@ Supported fuel-core version: ${supportedVersion}.`
5475
5753
  *
5476
5754
  * @returns A promise that resolves to the transaction cost object.
5477
5755
  */
5478
- async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
5756
+ async getTransactionCost(transactionRequestLike, { signatureCallback, gasPrice: gasPriceParam } = {}) {
5479
5757
  const txRequestClone = (0, import_ramda8.clone)(transactionRequestify(transactionRequestLike));
5480
5758
  const updateMaxFee = txRequestClone.maxFee.eq(0);
5481
5759
  const isScriptTransaction = isTransactionTypeScript(txRequestClone);
@@ -5489,11 +5767,20 @@ Supported fuel-core version: ${supportedVersion}.`
5489
5767
  await signatureCallback(signedRequest);
5490
5768
  addedSignatures = signedRequest.witnesses.length - lengthBefore;
5491
5769
  }
5492
- await this.estimatePredicates(signedRequest);
5770
+ let gasPrice;
5771
+ if (gasPriceParam) {
5772
+ gasPrice = gasPriceParam;
5773
+ await this.estimatePredicates(signedRequest);
5774
+ } else {
5775
+ ({ gasPrice } = await this.estimatePredicatesAndGasPrice(signedRequest, 10));
5776
+ }
5493
5777
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
5494
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
5495
- transactionRequest: signedRequest
5778
+ let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
5779
+ // Fetches and returns a gas price
5780
+ transactionRequest: signedRequest,
5781
+ gasPrice
5496
5782
  });
5783
+ let rawReceipts = [];
5497
5784
  let receipts = [];
5498
5785
  let dryRunStatus;
5499
5786
  let missingContractIds = [];
@@ -5505,7 +5792,7 @@ Supported fuel-core version: ${supportedVersion}.`
5505
5792
  if (signatureCallback) {
5506
5793
  await signatureCallback(txRequestClone);
5507
5794
  }
5508
- ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
5795
+ ({ rawReceipts, receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
5509
5796
  if (dryRunStatus && "reason" in dryRunStatus) {
5510
5797
  throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
5511
5798
  }
@@ -5513,12 +5800,17 @@ Supported fuel-core version: ${supportedVersion}.`
5513
5800
  const pristineGasUsed = getGasUsedFromReceipts(receipts);
5514
5801
  gasUsed = (0, import_math19.bn)(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
5515
5802
  txRequestClone.gasLimit = gasUsed;
5516
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
5803
+ ({ maxFee, maxGas, minFee, minGas } = await this.estimateTxGasAndFee({
5517
5804
  transactionRequest: txRequestClone,
5518
5805
  gasPrice
5519
5806
  }));
5520
5807
  }
5808
+ const transactionSummary = {
5809
+ gasPrice: gasPrice.toString(),
5810
+ receipts: rawReceipts
5811
+ };
5521
5812
  return {
5813
+ rawReceipts,
5522
5814
  receipts,
5523
5815
  gasUsed,
5524
5816
  gasPrice,
@@ -5531,7 +5823,8 @@ Supported fuel-core version: ${supportedVersion}.`
5531
5823
  addedSignatures,
5532
5824
  estimatedPredicates: txRequestClone.inputs,
5533
5825
  dryRunStatus,
5534
- updateMaxFee
5826
+ updateMaxFee,
5827
+ transactionSummary
5535
5828
  };
5536
5829
  }
5537
5830
  /**
@@ -5544,7 +5837,7 @@ Supported fuel-core version: ${supportedVersion}.`
5544
5837
  * @returns A promise that resolves to the coins.
5545
5838
  */
5546
5839
  async getCoins(owner, assetId, paginationArgs) {
5547
- const ownerAddress = import_address4.Address.fromAddressOrString(owner);
5840
+ const ownerAddress = new import_address4.Address(owner);
5548
5841
  const {
5549
5842
  coins: { edges, pageInfo }
5550
5843
  } = await this.operations.getCoins({
@@ -5576,24 +5869,34 @@ Supported fuel-core version: ${supportedVersion}.`
5576
5869
  * @returns A promise that resolves to the resources.
5577
5870
  */
5578
5871
  async getResourcesToSpend(owner, quantities, excludedIds) {
5579
- const ownerAddress = import_address4.Address.fromAddressOrString(owner);
5580
- const excludeInput = {
5872
+ const ownerAddress = new import_address4.Address(owner);
5873
+ let idsToExclude = {
5581
5874
  messages: excludedIds?.messages?.map((nonce) => (0, import_utils30.hexlify)(nonce)) || [],
5582
5875
  utxos: excludedIds?.utxos?.map((id) => (0, import_utils30.hexlify)(id)) || []
5583
5876
  };
5584
5877
  if (this.cache) {
5585
- const cached = this.cache.getActiveData();
5586
- excludeInput.messages.push(...cached.messages);
5587
- excludeInput.utxos.push(...cached.utxos);
5878
+ const cached = this.cache.getActiveData(ownerAddress.toB256());
5879
+ if (cached.utxos.length || cached.messages.length) {
5880
+ const {
5881
+ consensusParameters: {
5882
+ txParameters: { maxInputs }
5883
+ }
5884
+ } = await this.getChain();
5885
+ idsToExclude = adjustResourcesToExclude({
5886
+ userInput: idsToExclude,
5887
+ cached,
5888
+ maxInputs: maxInputs.toNumber()
5889
+ });
5890
+ }
5588
5891
  }
5589
5892
  const coinsQuery = {
5590
5893
  owner: ownerAddress.toB256(),
5591
5894
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
5592
5895
  assetId: (0, import_utils30.hexlify)(assetId),
5593
- amount: amount.toString(10),
5896
+ amount: (amount.eqn(0) ? (0, import_math19.bn)(1) : amount).toString(10),
5594
5897
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
5595
5898
  })),
5596
- excludedIds: excludeInput
5899
+ excludedIds: idsToExclude
5597
5900
  };
5598
5901
  const result = await this.operations.getCoinsToSpend(coinsQuery);
5599
5902
  const coins = result.coinsToSpend.flat().map((coin) => {
@@ -5603,8 +5906,8 @@ Supported fuel-core version: ${supportedVersion}.`
5603
5906
  amount: (0, import_math19.bn)(coin.amount),
5604
5907
  assetId: coin.assetId,
5605
5908
  daHeight: (0, import_math19.bn)(coin.daHeight),
5606
- sender: import_address4.Address.fromAddressOrString(coin.sender),
5607
- recipient: import_address4.Address.fromAddressOrString(coin.recipient),
5909
+ sender: new import_address4.Address(coin.sender),
5910
+ recipient: new import_address4.Address(coin.recipient),
5608
5911
  nonce: coin.nonce
5609
5912
  };
5610
5913
  case "Coin":
@@ -5651,7 +5954,7 @@ Supported fuel-core version: ${supportedVersion}.`
5651
5954
  } = await this.operations.getLatestBlock();
5652
5955
  block = latestBlock;
5653
5956
  } else {
5654
- const isblockId = typeof idOrHeight === "string" && idOrHeight.length === 66;
5957
+ const isblockId = typeof idOrHeight === "string" && (0, import_address4.isB256)(idOrHeight);
5655
5958
  const variables = isblockId ? { blockId: idOrHeight } : { height: (0, import_math19.bn)(idOrHeight).toString(10) };
5656
5959
  const response = await this.operations.getBlock(variables);
5657
5960
  block = response.block;
@@ -5722,8 +6025,10 @@ Supported fuel-core version: ${supportedVersion}.`
5722
6025
  variables = { blockHeight: (0, import_math19.bn)(idOrHeight).toString(10) };
5723
6026
  } else if (idOrHeight === "latest") {
5724
6027
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
5725
- } else {
6028
+ } else if (typeof idOrHeight === "string" && (0, import_address4.isB256)(idOrHeight)) {
5726
6029
  variables = { blockId: idOrHeight };
6030
+ } else {
6031
+ variables = { blockHeight: (0, import_math19.bn)(idOrHeight).toString() };
5727
6032
  }
5728
6033
  const { block } = await this.operations.getBlockWithTransactions(variables);
5729
6034
  if (!block) {
@@ -5745,7 +6050,7 @@ Supported fuel-core version: ${supportedVersion}.`
5745
6050
  },
5746
6051
  transactionIds: block.transactions.map((tx) => tx.id),
5747
6052
  transactions: block.transactions.map(
5748
- (tx) => new import_transactions22.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
6053
+ (tx) => new import_transactions23.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
5749
6054
  )
5750
6055
  };
5751
6056
  }
@@ -5761,7 +6066,7 @@ Supported fuel-core version: ${supportedVersion}.`
5761
6066
  return null;
5762
6067
  }
5763
6068
  try {
5764
- return new import_transactions22.TransactionCoder().decode(
6069
+ return new import_transactions23.TransactionCoder().decode(
5765
6070
  (0, import_utils30.arrayify)(transaction.rawPayload),
5766
6071
  0
5767
6072
  )?.[0];
@@ -5787,7 +6092,7 @@ Supported fuel-core version: ${supportedVersion}.`
5787
6092
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5788
6093
  })
5789
6094
  });
5790
- const coder = new import_transactions22.TransactionCoder();
6095
+ const coder = new import_transactions23.TransactionCoder();
5791
6096
  const transactions = edges.map(({ node: { rawPayload } }) => {
5792
6097
  try {
5793
6098
  return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
@@ -5801,6 +6106,21 @@ Supported fuel-core version: ${supportedVersion}.`
5801
6106
  }).filter((tx) => tx !== null);
5802
6107
  return { transactions, pageInfo };
5803
6108
  }
6109
+ /**
6110
+ * Fetches a compressed block at the specified height.
6111
+ *
6112
+ * @param height - The height of the block to fetch.
6113
+ * @returns The compressed block if available, otherwise `null`.
6114
+ */
6115
+ async daCompressedBlock(height) {
6116
+ const { daCompressedBlock } = await this.operations.daCompressedBlock({
6117
+ height
6118
+ });
6119
+ if (!daCompressedBlock) {
6120
+ return null;
6121
+ }
6122
+ return daCompressedBlock;
6123
+ }
5804
6124
  /**
5805
6125
  * Get deployed contract with the given ID.
5806
6126
  *
@@ -5823,7 +6143,7 @@ Supported fuel-core version: ${supportedVersion}.`
5823
6143
  */
5824
6144
  async getContractBalance(contractId, assetId) {
5825
6145
  const { contractBalance } = await this.operations.getContractBalance({
5826
- contract: import_address4.Address.fromAddressOrString(contractId).toB256(),
6146
+ contract: new import_address4.Address(contractId).toB256(),
5827
6147
  asset: (0, import_utils30.hexlify)(assetId)
5828
6148
  });
5829
6149
  return (0, import_math19.bn)(contractBalance.amount, 10);
@@ -5836,11 +6156,20 @@ Supported fuel-core version: ${supportedVersion}.`
5836
6156
  * @returns A promise that resolves to the balance.
5837
6157
  */
5838
6158
  async getBalance(owner, assetId) {
5839
- const { balance } = await this.operations.getBalance({
5840
- owner: import_address4.Address.fromAddressOrString(owner).toB256(),
5841
- assetId: (0, import_utils30.hexlify)(assetId)
6159
+ const ownerStr = new import_address4.Address(owner).toB256();
6160
+ const assetIdStr = (0, import_utils30.hexlify)(assetId);
6161
+ if (!this.features.amount128) {
6162
+ const { balance: balance2 } = await this.operations.getBalance({
6163
+ owner: ownerStr,
6164
+ assetId: assetIdStr
6165
+ });
6166
+ return (0, import_math19.bn)(balance2.amount, 10);
6167
+ }
6168
+ const { balance } = await this.operations.getBalanceV2({
6169
+ owner: ownerStr,
6170
+ assetId: assetIdStr
5842
6171
  });
5843
- return (0, import_math19.bn)(balance.amount, 10);
6172
+ return (0, import_math19.bn)(balance.amountU128, 10);
5844
6173
  }
5845
6174
  /**
5846
6175
  * Returns balances for the given owner.
@@ -5849,7 +6178,16 @@ Supported fuel-core version: ${supportedVersion}.`
5849
6178
  * @param paginationArgs - Pagination arguments (optional).
5850
6179
  * @returns A promise that resolves to the balances.
5851
6180
  */
5852
- async getBalances(owner) {
6181
+ async getBalances(owner, paginationArgs) {
6182
+ if (!this.features.balancePagination) {
6183
+ return this.getBalancesV1(owner, paginationArgs);
6184
+ }
6185
+ return this.getBalancesV2(owner, paginationArgs);
6186
+ }
6187
+ /**
6188
+ * @hidden
6189
+ */
6190
+ async getBalancesV1(owner, _paginationArgs) {
5853
6191
  const {
5854
6192
  balances: { edges }
5855
6193
  } = await this.operations.getBalances({
@@ -5858,7 +6196,7 @@ Supported fuel-core version: ${supportedVersion}.`
5858
6196
  * but the current Fuel-Core implementation does not support pagination yet.
5859
6197
  */
5860
6198
  first: 1e4,
5861
- filter: { owner: import_address4.Address.fromAddressOrString(owner).toB256() }
6199
+ filter: { owner: new import_address4.Address(owner).toB256() }
5862
6200
  });
5863
6201
  const balances = edges.map(({ node }) => ({
5864
6202
  assetId: node.assetId,
@@ -5866,6 +6204,25 @@ Supported fuel-core version: ${supportedVersion}.`
5866
6204
  }));
5867
6205
  return { balances };
5868
6206
  }
6207
+ /**
6208
+ * @hidden
6209
+ */
6210
+ async getBalancesV2(owner, paginationArgs) {
6211
+ const {
6212
+ balances: { edges, pageInfo }
6213
+ } = await this.operations.getBalancesV2({
6214
+ ...validatePaginationArgs({
6215
+ inputArgs: paginationArgs,
6216
+ paginationLimit: BALANCES_PAGE_SIZE_LIMIT
6217
+ }),
6218
+ filter: { owner: new import_address4.Address(owner).toB256() }
6219
+ });
6220
+ const balances = edges.map(({ node }) => ({
6221
+ assetId: node.assetId,
6222
+ amount: (0, import_math19.bn)(node.amountU128)
6223
+ }));
6224
+ return { balances, pageInfo };
6225
+ }
5869
6226
  /**
5870
6227
  * Returns message for the given address.
5871
6228
  *
@@ -5881,21 +6238,21 @@ Supported fuel-core version: ${supportedVersion}.`
5881
6238
  inputArgs: paginationArgs,
5882
6239
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5883
6240
  }),
5884
- owner: import_address4.Address.fromAddressOrString(address).toB256()
6241
+ owner: new import_address4.Address(address).toB256()
5885
6242
  });
5886
6243
  const messages = edges.map(({ node }) => ({
5887
- messageId: import_transactions22.InputMessageCoder.getMessageId({
6244
+ messageId: import_transactions23.InputMessageCoder.getMessageId({
5888
6245
  sender: node.sender,
5889
6246
  recipient: node.recipient,
5890
6247
  nonce: node.nonce,
5891
6248
  amount: (0, import_math19.bn)(node.amount),
5892
6249
  data: node.data
5893
6250
  }),
5894
- sender: import_address4.Address.fromAddressOrString(node.sender),
5895
- recipient: import_address4.Address.fromAddressOrString(node.recipient),
6251
+ sender: new import_address4.Address(node.sender),
6252
+ recipient: new import_address4.Address(node.recipient),
5896
6253
  nonce: node.nonce,
5897
6254
  amount: (0, import_math19.bn)(node.amount),
5898
- data: import_transactions22.InputMessageCoder.decodeData(node.data),
6255
+ data: import_transactions23.InputMessageCoder.decodeData(node.data),
5899
6256
  daHeight: (0, import_math19.bn)(node.daHeight)
5900
6257
  }));
5901
6258
  return {
@@ -5932,15 +6289,12 @@ Supported fuel-core version: ${supportedVersion}.`
5932
6289
  if (commitBlockHeight) {
5933
6290
  inputObject = {
5934
6291
  ...inputObject,
5935
- // Conver BN into a number string required on the query
5936
- // This should problably be fixed on the fuel client side
6292
+ // Convert BN into a number string required on the query
6293
+ // This should probably be fixed on the fuel client side
5937
6294
  commitBlockHeight: commitBlockHeight.toNumber().toString()
5938
6295
  };
5939
6296
  }
5940
6297
  const result = await this.operations.getMessageProof(inputObject);
5941
- if (!result.messageProof) {
5942
- return null;
5943
- }
5944
6298
  const {
5945
6299
  messageProof,
5946
6300
  messageBlockHeader,
@@ -5962,830 +6316,241 @@ Supported fuel-core version: ${supportedVersion}.`
5962
6316
  },
5963
6317
  messageBlockHeader: {
5964
6318
  id: messageBlockHeader.id,
5965
- daHeight: (0, import_math19.bn)(messageBlockHeader.daHeight),
5966
- transactionsCount: Number(messageBlockHeader.transactionsCount),
5967
- transactionsRoot: messageBlockHeader.transactionsRoot,
5968
- height: (0, import_math19.bn)(messageBlockHeader.height),
5969
- prevRoot: messageBlockHeader.prevRoot,
5970
- time: messageBlockHeader.time,
5971
- applicationHash: messageBlockHeader.applicationHash,
5972
- messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
5973
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
5974
- consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
5975
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
5976
- stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
5977
- },
5978
- commitBlockHeader: {
5979
- id: commitBlockHeader.id,
5980
- daHeight: (0, import_math19.bn)(commitBlockHeader.daHeight),
5981
- transactionsCount: Number(commitBlockHeader.transactionsCount),
5982
- transactionsRoot: commitBlockHeader.transactionsRoot,
5983
- height: (0, import_math19.bn)(commitBlockHeader.height),
5984
- prevRoot: commitBlockHeader.prevRoot,
5985
- time: commitBlockHeader.time,
5986
- applicationHash: commitBlockHeader.applicationHash,
5987
- messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
5988
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
5989
- consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
5990
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
5991
- stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
5992
- },
5993
- sender: import_address4.Address.fromAddressOrString(sender),
5994
- recipient: import_address4.Address.fromAddressOrString(recipient),
5995
- nonce,
5996
- amount: (0, import_math19.bn)(amount),
5997
- data
5998
- };
5999
- }
6000
- /**
6001
- * Get the latest gas price from the node.
6002
- *
6003
- * @returns A promise that resolves to the latest gas price.
6004
- */
6005
- async getLatestGasPrice() {
6006
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
6007
- return (0, import_math19.bn)(latestGasPrice.gasPrice);
6008
- }
6009
- /**
6010
- * Returns the estimate gas price for the given block horizon.
6011
- *
6012
- * @param blockHorizon - The block horizon to estimate gas price for.
6013
- * @returns A promise that resolves to the estimated gas price.
6014
- */
6015
- async estimateGasPrice(blockHorizon) {
6016
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
6017
- blockHorizon: String(blockHorizon)
6018
- });
6019
- return (0, import_math19.bn)(estimateGasPrice.gasPrice);
6020
- }
6021
- /**
6022
- * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
6023
- *
6024
- * @param nonce - The nonce of the message to get status from.
6025
- * @returns A promise that resolves to the message status
6026
- */
6027
- async getMessageStatus(nonce) {
6028
- const result = await this.operations.getMessageStatus({ nonce });
6029
- return result.messageStatus;
6030
- }
6031
- /**
6032
- * Lets you produce blocks with custom timestamps and the block number of the last block produced.
6033
- *
6034
- * @param amount - The amount of blocks to produce.
6035
- * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
6036
- * @returns A promise that resolves to the block number of the last produced block.
6037
- */
6038
- async produceBlocks(amount, startTime) {
6039
- const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
6040
- blocksToProduce: (0, import_math19.bn)(amount).toString(10),
6041
- startTimestamp: startTime ? import_utils30.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
6042
- });
6043
- return (0, import_math19.bn)(latestBlockHeight);
6044
- }
6045
- /**
6046
- * Check if the given ID is an account.
6047
- *
6048
- * @param id - The ID to check.
6049
- * @returns A promise that resolves to the result of the check.
6050
- */
6051
- async isUserAccount(id) {
6052
- const { contract, blob, transaction } = await this.operations.isUserAccount({
6053
- blobId: id,
6054
- contractId: id,
6055
- transactionId: id
6056
- });
6057
- if (contract || blob || transaction) {
6058
- return false;
6059
- }
6060
- return true;
6061
- }
6062
- async getAddressType(id) {
6063
- const { contract, blob, transaction } = await this.operations.isUserAccount({
6064
- blobId: id,
6065
- contractId: id,
6066
- transactionId: id
6067
- });
6068
- if (contract) {
6069
- return "Contract";
6070
- }
6071
- if (blob) {
6072
- return "Blob";
6073
- }
6074
- if (transaction) {
6075
- return "Transaction";
6076
- }
6077
- return "Account";
6078
- }
6079
- /**
6080
- * Get the transaction response for the given transaction ID.
6081
- *
6082
- * @param transactionId - The transaction ID to get the response for.
6083
- * @returns A promise that resolves to the transaction response.
6084
- */
6085
- async getTransactionResponse(transactionId) {
6086
- const chainId = await this.getChainId();
6087
- return new TransactionResponse(transactionId, this, chainId);
6088
- }
6089
- /**
6090
- * Returns Message for given nonce.
6091
- *
6092
- * @param nonce - The nonce of the message to retrieve.
6093
- * @returns A promise that resolves to the Message object or null.
6094
- */
6095
- async getMessageByNonce(nonce) {
6096
- const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
6097
- if (!rawMessage) {
6098
- return null;
6099
- }
6100
- const message = {
6101
- messageId: import_transactions22.InputMessageCoder.getMessageId({
6102
- sender: rawMessage.sender,
6103
- recipient: rawMessage.recipient,
6104
- nonce,
6105
- amount: (0, import_math19.bn)(rawMessage.amount),
6106
- data: rawMessage.data
6107
- }),
6108
- sender: import_address4.Address.fromAddressOrString(rawMessage.sender),
6109
- recipient: import_address4.Address.fromAddressOrString(rawMessage.recipient),
6110
- nonce,
6111
- amount: (0, import_math19.bn)(rawMessage.amount),
6112
- data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
6113
- daHeight: (0, import_math19.bn)(rawMessage.daHeight)
6114
- };
6115
- return message;
6116
- }
6117
- /**
6118
- * Get the relayed transaction for the given transaction ID.
6119
- *
6120
- * @param relayedTransactionId - The relayed transaction ID to get the response for.
6121
- * @returns A promise that resolves to the relayed transaction.
6122
- */
6123
- async getRelayedTransactionStatus(relayedTransactionId) {
6124
- const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
6125
- relayedTransactionId
6126
- });
6127
- if (!relayedTransactionStatus) {
6128
- return null;
6129
- }
6130
- return relayedTransactionStatus;
6131
- }
6132
- /**
6133
- * @hidden
6134
- */
6135
- extractDryRunError(transactionRequest, receipts, dryRunStatus) {
6136
- const status = dryRunStatus;
6137
- let logs = [];
6138
- if (transactionRequest.abis) {
6139
- logs = getDecodedLogs(
6140
- receipts,
6141
- transactionRequest.abis.main,
6142
- transactionRequest.abis.otherContractsAbis
6143
- );
6144
- }
6145
- return extractTxError({
6146
- logs,
6147
- receipts,
6148
- statusReason: status.reason
6149
- });
6150
- }
6151
- };
6152
- var Provider = _Provider;
6153
- _cacheInputs = new WeakSet();
6154
- cacheInputs_fn = function(inputs, transactionId) {
6155
- if (!this.cache) {
6156
- return;
6157
- }
6158
- const inputsToCache = inputs.reduce(
6159
- (acc, input) => {
6160
- if (input.type === import_transactions22.InputType.Coin) {
6161
- acc.utxos.push(input.id);
6162
- } else if (input.type === import_transactions22.InputType.Message) {
6163
- acc.messages.push(input.nonce);
6164
- }
6165
- return acc;
6166
- },
6167
- { utxos: [], messages: [] }
6168
- );
6169
- this.cache.set(transactionId, inputsToCache);
6170
- };
6171
- /** @hidden */
6172
- __publicField(Provider, "chainInfoCache", {});
6173
- /** @hidden */
6174
- __publicField(Provider, "nodeInfoCache", {});
6175
-
6176
- // src/providers/transaction-summary/get-transaction-summary.ts
6177
- var import_errors21 = require("@fuel-ts/errors");
6178
- var import_math20 = require("@fuel-ts/math");
6179
- var import_transactions23 = require("@fuel-ts/transactions");
6180
- var import_utils33 = require("@fuel-ts/utils");
6181
-
6182
- // src/providers/chains.ts
6183
- var CHAIN_IDS = {
6184
- eth: {
6185
- mainnet: 1,
6186
- sepolia: 11155111,
6187
- foundry: 31337
6188
- },
6189
- fuel: {
6190
- devnet: 0,
6191
- testnet: 0,
6192
- mainnet: 9889
6193
- }
6194
- };
6195
-
6196
- // src/providers/assets/utils/url.ts
6197
- var DELIMITER_PATH = "/";
6198
- var trimRegex = /^\/|\/$/g;
6199
- var trimPath = (path2 = "") => path2.replace(trimRegex, "");
6200
- function urlJoin(baseUrl, ...paths) {
6201
- const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
6202
- const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
6203
- const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
6204
- if (rootPath && hasBaseUrl) {
6205
- allPaths.unshift("");
6206
- }
6207
- return allPaths.join(DELIMITER_PATH);
6208
- }
6209
-
6210
- // src/providers/assets/utils/resolveIconPaths.ts
6211
- function resolveIconPaths(assets2, basePath = "./") {
6212
- return assets2.map((asset) => ({
6213
- ...asset,
6214
- icon: urlJoin(basePath, asset.icon)
6215
- }));
6216
- }
6217
-
6218
- // src/providers/assets/utils/fuelAssetsBaseUrl.ts
6219
- var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
6220
-
6221
- // src/providers/assets/assets.ts
6222
- var rawAssets = [
6223
- {
6224
- name: "Ethereum",
6225
- symbol: "ETH",
6226
- icon: "eth.svg",
6227
- networks: [
6228
- {
6229
- type: "ethereum",
6230
- chainId: CHAIN_IDS.eth.sepolia,
6231
- decimals: 18
6232
- },
6233
- {
6234
- type: "ethereum",
6235
- chainId: CHAIN_IDS.eth.foundry,
6236
- decimals: 18
6237
- },
6238
- {
6239
- type: "ethereum",
6240
- chainId: CHAIN_IDS.eth.mainnet,
6241
- decimals: 18
6242
- },
6243
- {
6244
- type: "fuel",
6245
- chainId: CHAIN_IDS.fuel.devnet,
6246
- decimals: 9,
6247
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6248
- },
6249
- {
6250
- type: "fuel",
6251
- chainId: CHAIN_IDS.fuel.testnet,
6252
- decimals: 9,
6253
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6254
- },
6255
- {
6256
- type: "fuel",
6257
- chainId: CHAIN_IDS.fuel.mainnet,
6258
- decimals: 9,
6259
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6260
- }
6261
- ]
6262
- },
6263
- {
6264
- name: "WETH",
6265
- symbol: "WETH",
6266
- icon: "weth.svg",
6267
- networks: [
6268
- {
6269
- type: "ethereum",
6270
- chainId: CHAIN_IDS.eth.mainnet,
6271
- address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
6272
- decimals: 18
6273
- },
6274
- {
6275
- type: "fuel",
6276
- chainId: CHAIN_IDS.fuel.mainnet,
6277
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6278
- assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
6279
- decimals: 9
6280
- }
6281
- ]
6282
- },
6283
- {
6284
- name: "weETH",
6285
- symbol: "weETH",
6286
- icon: "weETH.webp",
6287
- networks: [
6288
- {
6289
- type: "ethereum",
6290
- chainId: CHAIN_IDS.eth.mainnet,
6291
- address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
6292
- decimals: 18
6293
- },
6294
- {
6295
- type: "fuel",
6296
- chainId: CHAIN_IDS.fuel.mainnet,
6297
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6298
- assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
6299
- decimals: 9
6300
- }
6301
- ]
6302
- },
6303
- {
6304
- name: "rsETH",
6305
- symbol: "rsETH",
6306
- icon: "rsETH.webp",
6307
- networks: [
6308
- {
6309
- type: "ethereum",
6310
- chainId: CHAIN_IDS.eth.mainnet,
6311
- address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
6312
- decimals: 18
6313
- },
6314
- {
6315
- type: "fuel",
6316
- chainId: CHAIN_IDS.fuel.mainnet,
6317
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6318
- assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
6319
- decimals: 9
6320
- }
6321
- ]
6322
- },
6323
- {
6324
- name: "rETH",
6325
- symbol: "rETH",
6326
- icon: "reth.svg",
6327
- networks: [
6328
- {
6329
- type: "ethereum",
6330
- chainId: CHAIN_IDS.eth.mainnet,
6331
- address: "0xae78736cd615f374d3085123a210448e74fc6393",
6332
- decimals: 18
6333
- },
6334
- {
6335
- type: "fuel",
6336
- chainId: CHAIN_IDS.fuel.mainnet,
6337
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6338
- assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
6339
- decimals: 9
6340
- }
6341
- ]
6342
- },
6343
- {
6344
- name: "wbETH",
6345
- symbol: "wbETH",
6346
- icon: "wbeth.png",
6347
- networks: [
6348
- {
6349
- type: "ethereum",
6350
- chainId: CHAIN_IDS.eth.mainnet,
6351
- address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
6352
- decimals: 18
6353
- },
6354
- {
6355
- type: "fuel",
6356
- chainId: CHAIN_IDS.fuel.mainnet,
6357
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6358
- assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
6359
- decimals: 9
6360
- }
6361
- ]
6362
- },
6363
- {
6364
- name: "rstETH",
6365
- symbol: "rstETH",
6366
- icon: "rstETH.webp",
6367
- networks: [
6368
- {
6369
- type: "ethereum",
6370
- chainId: CHAIN_IDS.eth.mainnet,
6371
- address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
6372
- decimals: 18
6373
- },
6374
- {
6375
- type: "fuel",
6376
- chainId: CHAIN_IDS.fuel.mainnet,
6377
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6378
- assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
6379
- decimals: 9
6380
- }
6381
- ]
6382
- },
6383
- {
6384
- name: "amphrETH",
6385
- symbol: "amphrETH",
6386
- icon: "amphrETH.png",
6387
- networks: [
6388
- {
6389
- type: "ethereum",
6390
- chainId: CHAIN_IDS.eth.mainnet,
6391
- address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
6392
- decimals: 18
6393
- },
6394
- {
6395
- type: "fuel",
6396
- chainId: CHAIN_IDS.fuel.mainnet,
6397
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6398
- assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
6399
- decimals: 9
6400
- }
6401
- ]
6402
- },
6403
- {
6404
- name: "Manta mBTC",
6405
- symbol: "Manta mBTC",
6406
- icon: "manta-mbtc.svg",
6407
- networks: [
6408
- {
6409
- type: "ethereum",
6410
- chainId: CHAIN_IDS.eth.mainnet,
6411
- address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
6412
- decimals: 18
6413
- },
6414
- {
6415
- type: "fuel",
6416
- chainId: CHAIN_IDS.fuel.mainnet,
6417
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6418
- assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
6419
- decimals: 9
6420
- }
6421
- ]
6422
- },
6423
- {
6424
- name: "Manta mETH",
6425
- symbol: "Manta mETH",
6426
- icon: "manta-meth.svg",
6427
- networks: [
6428
- {
6429
- type: "ethereum",
6430
- chainId: CHAIN_IDS.eth.mainnet,
6431
- address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
6432
- decimals: 18
6433
- },
6434
- {
6435
- type: "fuel",
6436
- chainId: CHAIN_IDS.fuel.mainnet,
6437
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6438
- assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
6439
- decimals: 9
6440
- }
6441
- ]
6442
- },
6443
- {
6444
- name: "Manta mUSD",
6445
- symbol: "Manta mUSD",
6446
- icon: "manta-musd.svg",
6447
- networks: [
6448
- {
6449
- type: "ethereum",
6450
- chainId: CHAIN_IDS.eth.mainnet,
6451
- address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
6452
- decimals: 18
6453
- },
6454
- {
6455
- type: "fuel",
6456
- chainId: CHAIN_IDS.fuel.mainnet,
6457
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6458
- assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
6459
- decimals: 9
6460
- }
6461
- ]
6462
- },
6463
- {
6464
- name: "pumpBTC",
6465
- symbol: "pumpBTC",
6466
- icon: "pumpbtc.webp",
6467
- networks: [
6468
- {
6469
- type: "ethereum",
6470
- chainId: CHAIN_IDS.eth.mainnet,
6471
- address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
6472
- decimals: 8
6473
- },
6474
- {
6475
- type: "fuel",
6476
- chainId: CHAIN_IDS.fuel.mainnet,
6477
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6478
- assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
6479
- decimals: 8
6480
- }
6481
- ]
6482
- },
6483
- {
6484
- name: "FBTC",
6485
- symbol: "FBTC",
6486
- icon: "fbtc.svg",
6487
- networks: [
6488
- {
6489
- type: "ethereum",
6490
- chainId: CHAIN_IDS.eth.mainnet,
6491
- address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
6492
- decimals: 8
6493
- },
6494
- {
6495
- type: "fuel",
6496
- chainId: CHAIN_IDS.fuel.mainnet,
6497
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6498
- assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
6499
- decimals: 8
6500
- }
6501
- ]
6502
- },
6503
- {
6504
- name: "SolvBTC",
6505
- symbol: "SolvBTC",
6506
- icon: "solvBTC.webp",
6507
- networks: [
6508
- {
6509
- type: "ethereum",
6510
- chainId: CHAIN_IDS.eth.mainnet,
6511
- address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
6512
- decimals: 18
6513
- },
6514
- {
6515
- type: "fuel",
6516
- chainId: CHAIN_IDS.fuel.mainnet,
6517
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6518
- assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
6519
- decimals: 9
6520
- }
6521
- ]
6522
- },
6523
- {
6524
- name: "SolvBTC.BBN",
6525
- symbol: "SolvBTC.BBN",
6526
- icon: "SolvBTC.BBN.png",
6527
- networks: [
6528
- {
6529
- type: "ethereum",
6530
- chainId: CHAIN_IDS.eth.mainnet,
6531
- address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
6532
- decimals: 18
6533
- },
6534
- {
6535
- type: "fuel",
6536
- chainId: CHAIN_IDS.fuel.mainnet,
6537
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6538
- assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
6539
- decimals: 9
6540
- }
6541
- ]
6542
- },
6543
- {
6544
- name: "Mantle mETH",
6545
- symbol: "Mantle mETH",
6546
- icon: "mantle-meth.svg",
6547
- networks: [
6548
- {
6549
- type: "ethereum",
6550
- chainId: CHAIN_IDS.eth.mainnet,
6551
- address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
6552
- decimals: 18
6553
- },
6554
- {
6555
- type: "fuel",
6556
- chainId: CHAIN_IDS.fuel.mainnet,
6557
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6558
- assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
6559
- decimals: 9
6560
- }
6561
- ]
6562
- },
6563
- {
6564
- name: "sDAI",
6565
- symbol: "sDAI",
6566
- icon: "sdai.svg",
6567
- networks: [
6568
- {
6569
- type: "ethereum",
6570
- chainId: CHAIN_IDS.eth.mainnet,
6571
- address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
6572
- decimals: 18
6573
- },
6574
- {
6575
- type: "fuel",
6576
- chainId: CHAIN_IDS.fuel.mainnet,
6577
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6578
- assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
6579
- decimals: 9
6580
- }
6581
- ]
6582
- },
6583
- {
6584
- name: "USDT",
6585
- symbol: "USDT",
6586
- icon: "usdt.svg",
6587
- networks: [
6588
- {
6589
- type: "ethereum",
6590
- chainId: CHAIN_IDS.eth.mainnet,
6591
- address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
6592
- decimals: 6
6593
- },
6594
- {
6595
- type: "fuel",
6596
- chainId: CHAIN_IDS.fuel.mainnet,
6597
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6598
- assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
6599
- decimals: 6
6600
- }
6601
- ]
6602
- },
6603
- {
6604
- name: "USDC",
6605
- symbol: "USDC",
6606
- icon: "usdc.svg",
6607
- networks: [
6608
- {
6609
- type: "ethereum",
6610
- chainId: CHAIN_IDS.eth.mainnet,
6611
- address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
6612
- decimals: 6
6613
- },
6614
- {
6615
- type: "fuel",
6616
- chainId: CHAIN_IDS.fuel.mainnet,
6617
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6618
- assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
6619
- decimals: 6
6620
- }
6621
- ]
6622
- },
6623
- {
6624
- name: "USDe",
6625
- symbol: "USDe",
6626
- icon: "USDe.svg",
6627
- networks: [
6628
- {
6629
- type: "ethereum",
6630
- chainId: CHAIN_IDS.eth.mainnet,
6631
- address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
6632
- decimals: 18
6633
- },
6634
- {
6635
- type: "fuel",
6636
- chainId: CHAIN_IDS.fuel.mainnet,
6637
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6638
- assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
6639
- decimals: 9
6640
- }
6641
- ]
6642
- },
6643
- {
6644
- name: "sUSDe",
6645
- symbol: "sUSDe",
6646
- icon: "sUSDe.webp",
6647
- networks: [
6648
- {
6649
- type: "ethereum",
6650
- chainId: CHAIN_IDS.eth.mainnet,
6651
- address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
6652
- decimals: 18
6653
- },
6654
- {
6655
- type: "fuel",
6656
- chainId: CHAIN_IDS.fuel.mainnet,
6657
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6658
- assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
6659
- decimals: 9
6660
- }
6661
- ]
6662
- },
6663
- {
6664
- name: "rsUSDe",
6665
- symbol: "rsUSDe",
6666
- icon: "rsUSDe.svg",
6667
- networks: [
6668
- {
6669
- type: "ethereum",
6670
- chainId: CHAIN_IDS.eth.mainnet,
6671
- address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
6672
- decimals: 18
6673
- },
6674
- {
6675
- type: "fuel",
6676
- chainId: CHAIN_IDS.fuel.mainnet,
6677
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6678
- assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
6679
- decimals: 9
6680
- }
6681
- ]
6682
- },
6683
- {
6684
- name: "wstETH",
6685
- symbol: "wstETH",
6686
- icon: "wsteth.svg",
6687
- networks: [
6688
- {
6689
- type: "ethereum",
6690
- chainId: CHAIN_IDS.eth.mainnet,
6691
- address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
6692
- decimals: 18
6693
- },
6694
- {
6695
- type: "fuel",
6696
- chainId: CHAIN_IDS.fuel.mainnet,
6697
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6698
- assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
6699
- decimals: 9
6700
- }
6701
- ]
6702
- },
6703
- {
6704
- name: "ezETH",
6705
- symbol: "ezETH",
6706
- icon: "ezeth.webp",
6707
- networks: [
6708
- {
6709
- type: "ethereum",
6710
- chainId: CHAIN_IDS.eth.mainnet,
6711
- address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
6712
- decimals: 18
6713
- },
6714
- {
6715
- type: "fuel",
6716
- chainId: CHAIN_IDS.fuel.mainnet,
6717
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6718
- assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
6719
- decimals: 9
6720
- }
6721
- ]
6722
- },
6723
- {
6724
- name: "pzETH",
6725
- symbol: "pzETH",
6726
- icon: "pzETH.webp",
6727
- networks: [
6728
- {
6729
- type: "ethereum",
6730
- chainId: CHAIN_IDS.eth.mainnet,
6731
- address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
6732
- decimals: 18
6733
- },
6734
- {
6735
- type: "fuel",
6736
- chainId: CHAIN_IDS.fuel.mainnet,
6737
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6738
- assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
6739
- decimals: 9
6740
- }
6741
- ]
6742
- },
6743
- {
6744
- name: "Re7LRT",
6745
- symbol: "Re7LRT",
6746
- icon: "Re7LRT.png",
6747
- networks: [
6748
- {
6749
- type: "ethereum",
6750
- chainId: CHAIN_IDS.eth.mainnet,
6751
- address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
6752
- decimals: 18
6319
+ daHeight: (0, import_math19.bn)(messageBlockHeader.daHeight),
6320
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
6321
+ transactionsRoot: messageBlockHeader.transactionsRoot,
6322
+ height: (0, import_math19.bn)(messageBlockHeader.height),
6323
+ prevRoot: messageBlockHeader.prevRoot,
6324
+ time: messageBlockHeader.time,
6325
+ applicationHash: messageBlockHeader.applicationHash,
6326
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
6327
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
6328
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
6329
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
6330
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
6753
6331
  },
6754
- {
6755
- type: "fuel",
6756
- chainId: CHAIN_IDS.fuel.mainnet,
6757
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6758
- assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
6759
- decimals: 9
6760
- }
6761
- ]
6762
- },
6763
- {
6764
- name: "steakLRT",
6765
- symbol: "steakLRT",
6766
- icon: "steakLRT.png",
6767
- networks: [
6768
- {
6769
- type: "ethereum",
6770
- chainId: CHAIN_IDS.eth.mainnet,
6771
- address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
6772
- decimals: 18
6332
+ commitBlockHeader: {
6333
+ id: commitBlockHeader.id,
6334
+ daHeight: (0, import_math19.bn)(commitBlockHeader.daHeight),
6335
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
6336
+ transactionsRoot: commitBlockHeader.transactionsRoot,
6337
+ height: (0, import_math19.bn)(commitBlockHeader.height),
6338
+ prevRoot: commitBlockHeader.prevRoot,
6339
+ time: commitBlockHeader.time,
6340
+ applicationHash: commitBlockHeader.applicationHash,
6341
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
6342
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
6343
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
6344
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
6345
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
6773
6346
  },
6774
- {
6775
- type: "fuel",
6776
- chainId: CHAIN_IDS.fuel.mainnet,
6777
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6778
- assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
6779
- decimals: 9
6347
+ sender: new import_address4.Address(sender),
6348
+ recipient: new import_address4.Address(recipient),
6349
+ nonce,
6350
+ amount: (0, import_math19.bn)(amount),
6351
+ data
6352
+ };
6353
+ }
6354
+ /**
6355
+ * Get the latest gas price from the node.
6356
+ *
6357
+ * @returns A promise that resolves to the latest gas price.
6358
+ */
6359
+ async getLatestGasPrice() {
6360
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
6361
+ return (0, import_math19.bn)(latestGasPrice.gasPrice);
6362
+ }
6363
+ /**
6364
+ * Returns the estimate gas price for the given block horizon.
6365
+ *
6366
+ * @param blockHorizon - The block horizon to estimate gas price for.
6367
+ * @returns A promise that resolves to the estimated gas price.
6368
+ */
6369
+ async estimateGasPrice(blockHorizon) {
6370
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
6371
+ blockHorizon: String(blockHorizon)
6372
+ });
6373
+ return (0, import_math19.bn)(estimateGasPrice.gasPrice);
6374
+ }
6375
+ /**
6376
+ * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
6377
+ *
6378
+ * @param nonce - The nonce of the message to get status from.
6379
+ * @returns A promise that resolves to the message status
6380
+ */
6381
+ async getMessageStatus(nonce) {
6382
+ const result = await this.operations.getMessageStatus({ nonce });
6383
+ return result.messageStatus;
6384
+ }
6385
+ /**
6386
+ * Lets you produce blocks with custom timestamps and the block number of the last block produced.
6387
+ *
6388
+ * @param amount - The amount of blocks to produce.
6389
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
6390
+ * @returns A promise that resolves to the block number of the last produced block.
6391
+ */
6392
+ async produceBlocks(amount, startTime) {
6393
+ const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
6394
+ blocksToProduce: (0, import_math19.bn)(amount).toString(10),
6395
+ startTimestamp: startTime ? import_utils30.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
6396
+ });
6397
+ return (0, import_math19.bn)(latestBlockHeight);
6398
+ }
6399
+ /**
6400
+ * Check if the given ID is an account.
6401
+ *
6402
+ * @param id - The ID to check.
6403
+ * @returns A promise that resolves to the result of the check.
6404
+ */
6405
+ async isUserAccount(id) {
6406
+ const type = await this.getAddressType(id);
6407
+ return type === "Account";
6408
+ }
6409
+ /**
6410
+ * Determines the type of address based on the provided ID.
6411
+ *
6412
+ * @param id - The ID to be checked.
6413
+ * @returns A promise that resolves to a string indicating the type of address.
6414
+ */
6415
+ async getAddressType(id) {
6416
+ const { contract, blob, transaction } = await this.operations.isUserAccount({
6417
+ blobId: id,
6418
+ contractId: id,
6419
+ transactionId: id
6420
+ });
6421
+ if (contract) {
6422
+ return "Contract";
6423
+ }
6424
+ if (blob) {
6425
+ return "Blob";
6426
+ }
6427
+ if (transaction) {
6428
+ return "Transaction";
6429
+ }
6430
+ try {
6431
+ const asset = await this.getAssetDetails(id);
6432
+ if (asset) {
6433
+ return "Asset";
6780
6434
  }
6781
- ]
6435
+ } catch (e) {
6436
+ }
6437
+ return "Account";
6782
6438
  }
6783
- ];
6784
- var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
6439
+ /**
6440
+ * Get the transaction response for the given transaction ID.
6441
+ *
6442
+ * @param transactionId - The transaction ID to get the response for.
6443
+ * @returns A promise that resolves to the transaction response.
6444
+ */
6445
+ async getTransactionResponse(transactionId) {
6446
+ const chainId = await this.getChainId();
6447
+ return new TransactionResponse(transactionId, this, chainId);
6448
+ }
6449
+ /**
6450
+ * Returns Message for given nonce.
6451
+ *
6452
+ * @param nonce - The nonce of the message to retrieve.
6453
+ * @returns A promise that resolves to the Message object or null.
6454
+ */
6455
+ async getMessageByNonce(nonce) {
6456
+ const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
6457
+ if (!rawMessage) {
6458
+ return null;
6459
+ }
6460
+ const message = {
6461
+ messageId: import_transactions23.InputMessageCoder.getMessageId({
6462
+ sender: rawMessage.sender,
6463
+ recipient: rawMessage.recipient,
6464
+ nonce,
6465
+ amount: (0, import_math19.bn)(rawMessage.amount),
6466
+ data: rawMessage.data
6467
+ }),
6468
+ sender: new import_address4.Address(rawMessage.sender),
6469
+ recipient: new import_address4.Address(rawMessage.recipient),
6470
+ nonce,
6471
+ amount: (0, import_math19.bn)(rawMessage.amount),
6472
+ data: import_transactions23.InputMessageCoder.decodeData(rawMessage.data),
6473
+ daHeight: (0, import_math19.bn)(rawMessage.daHeight)
6474
+ };
6475
+ return message;
6476
+ }
6477
+ /**
6478
+ * Get the relayed transaction for the given transaction ID.
6479
+ *
6480
+ * @param relayedTransactionId - The relayed transaction ID to get the response for.
6481
+ * @returns A promise that resolves to the relayed transaction.
6482
+ */
6483
+ async getRelayedTransactionStatus(relayedTransactionId) {
6484
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
6485
+ relayedTransactionId
6486
+ });
6487
+ if (!relayedTransactionStatus) {
6488
+ return null;
6489
+ }
6490
+ return relayedTransactionStatus;
6491
+ }
6492
+ /**
6493
+ * @hidden
6494
+ */
6495
+ extractDryRunError(transactionRequest, receipts, dryRunStatus) {
6496
+ const status = dryRunStatus;
6497
+ let logs = [];
6498
+ if (transactionRequest.abis) {
6499
+ logs = getDecodedLogs(
6500
+ receipts,
6501
+ transactionRequest.abis.main,
6502
+ transactionRequest.abis.otherContractsAbis
6503
+ );
6504
+ }
6505
+ return extractTxError({
6506
+ logs,
6507
+ receipts,
6508
+ statusReason: status.reason
6509
+ });
6510
+ }
6511
+ /**
6512
+ * @hidden
6513
+ */
6514
+ parseEstimatePredicatesResponse(transactionRequest, { inputs }) {
6515
+ if (inputs) {
6516
+ inputs.forEach((input, i) => {
6517
+ if (input && "predicateGasUsed" in input && (0, import_math19.bn)(input.predicateGasUsed).gt(0)) {
6518
+ transactionRequest.inputs[i].predicateGasUsed = input.predicateGasUsed;
6519
+ }
6520
+ });
6521
+ }
6522
+ return transactionRequest;
6523
+ }
6524
+ };
6525
+ var Provider = _Provider;
6526
+ _cacheInputs = new WeakSet();
6527
+ cacheInputs_fn = function(inputs, transactionId) {
6528
+ if (!this.cache) {
6529
+ return;
6530
+ }
6531
+ this.cache.set(transactionId, inputs);
6532
+ };
6533
+ /** @hidden */
6534
+ __publicField(Provider, "chainInfoCache", {});
6535
+ /** @hidden */
6536
+ __publicField(Provider, "nodeInfoCache", {});
6537
+ /** @hidden */
6538
+ __publicField(Provider, "incompatibleNodeVersionMessage", "");
6539
+
6540
+ // src/providers/transaction-summary/get-transaction-summary.ts
6541
+ var import_errors21 = require("@fuel-ts/errors");
6542
+ var import_math20 = require("@fuel-ts/math");
6543
+ var import_transactions24 = require("@fuel-ts/transactions");
6544
+ var import_utils32 = require("@fuel-ts/utils");
6545
+
6546
+ // src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
6547
+ var import_math21 = require("@fuel-ts/math");
6548
+ var import_transactions25 = require("@fuel-ts/transactions");
6549
+ var import_utils33 = require("@fuel-ts/utils");
6785
6550
 
6786
6551
  // src/test-utils/test-asset-id.ts
6787
6552
  var import_crypto4 = require("@fuel-ts/crypto");
6788
- var import_utils35 = require("@fuel-ts/utils");
6553
+ var import_utils34 = require("@fuel-ts/utils");
6789
6554
  var _TestAssetId = class {
6790
6555
  constructor(value) {
6791
6556
  this.value = value;
@@ -6793,7 +6558,7 @@ var _TestAssetId = class {
6793
6558
  static random(count = 1) {
6794
6559
  const assetIds = [];
6795
6560
  for (let i = 0; i < count; i++) {
6796
- assetIds.push(new _TestAssetId((0, import_utils35.hexlify)((0, import_crypto4.randomBytes)(32))));
6561
+ assetIds.push(new _TestAssetId((0, import_utils34.hexlify)((0, import_crypto4.randomBytes)(32))));
6797
6562
  }
6798
6563
  return assetIds;
6799
6564
  }
@@ -6809,20 +6574,21 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6809
6574
  // src/test-utils/wallet-config.ts
6810
6575
  var import_crypto9 = require("@fuel-ts/crypto");
6811
6576
  var import_errors27 = require("@fuel-ts/errors");
6812
- var import_utils44 = require("@fuel-ts/utils");
6577
+ var import_math24 = require("@fuel-ts/math");
6578
+ var import_utils43 = require("@fuel-ts/utils");
6813
6579
 
6814
6580
  // src/wallet/base-wallet-unlocked.ts
6815
6581
  var import_hasher4 = require("@fuel-ts/hasher");
6816
- var import_utils39 = require("@fuel-ts/utils");
6582
+ var import_utils38 = require("@fuel-ts/utils");
6817
6583
 
6818
6584
  // src/account.ts
6819
- var import_abi_coder8 = require("@fuel-ts/abi-coder");
6585
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
6820
6586
  var import_address6 = require("@fuel-ts/address");
6821
6587
  var import_crypto5 = require("@fuel-ts/crypto");
6822
6588
  var import_errors22 = require("@fuel-ts/errors");
6823
- var import_math21 = require("@fuel-ts/math");
6824
- var import_transactions24 = require("@fuel-ts/transactions");
6825
- var import_utils37 = require("@fuel-ts/utils");
6589
+ var import_math22 = require("@fuel-ts/math");
6590
+ var import_transactions26 = require("@fuel-ts/transactions");
6591
+ var import_utils36 = require("@fuel-ts/utils");
6826
6592
  var import_ramda9 = require("ramda");
6827
6593
 
6828
6594
  // src/providers/utils/merge-quantities.ts
@@ -6844,21 +6610,17 @@ var AbstractAccount = class {
6844
6610
  };
6845
6611
 
6846
6612
  // src/utils/formatTransferToContractScriptData.ts
6847
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
6613
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
6848
6614
  var import_address5 = require("@fuel-ts/address");
6849
- var import_utils36 = require("@fuel-ts/utils");
6615
+ var import_utils35 = require("@fuel-ts/utils");
6850
6616
  var asm = __toESM(require("@fuels/vm-asm"));
6851
6617
  var formatTransferToContractScriptData = (transferParams) => {
6852
- const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
6618
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
6853
6619
  return transferParams.reduce((acc, transferParam) => {
6854
6620
  const { assetId, amount, contractId } = transferParam;
6855
6621
  const encoded = numberCoder.encode(amount);
6856
- const scriptData = (0, import_utils36.concat)([
6857
- import_address5.Address.fromAddressOrString(contractId).toBytes(),
6858
- encoded,
6859
- (0, import_utils36.arrayify)(assetId)
6860
- ]);
6861
- return (0, import_utils36.concat)([acc, scriptData]);
6622
+ const scriptData = (0, import_utils35.concat)([new import_address5.Address(contractId).toBytes(), encoded, (0, import_utils35.arrayify)(assetId)]);
6623
+ return (0, import_utils35.concat)([acc, scriptData]);
6862
6624
  }, new Uint8Array());
6863
6625
  };
6864
6626
  var assembleTransferToContractScript = async (transferParams) => {
@@ -6866,24 +6628,24 @@ var assembleTransferToContractScript = async (transferParams) => {
6866
6628
  await asm.initWasm();
6867
6629
  let script = new Uint8Array();
6868
6630
  transferParams.forEach((_, i) => {
6869
- const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
6870
- script = (0, import_utils36.concat)([
6631
+ const offset = (import_abi_coder6.CONTRACT_ID_LEN + import_abi_coder6.WORD_SIZE + import_abi_coder6.ASSET_ID_LEN) * i;
6632
+ script = (0, import_utils35.concat)([
6871
6633
  script,
6872
6634
  // Load ScriptData into register 0x10.
6873
6635
  asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6874
6636
  // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6875
6637
  asm.addi(17, 16, offset).to_bytes(),
6876
6638
  // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6877
- asm.addi(18, 17, import_abi_coder7.CONTRACT_ID_LEN).to_bytes(),
6639
+ asm.addi(18, 17, import_abi_coder6.CONTRACT_ID_LEN).to_bytes(),
6878
6640
  // Load word to the amount at 0x12 into register 0x13.
6879
6641
  asm.lw(19, 18, 0).to_bytes(),
6880
6642
  // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6881
- asm.addi(20, 18, import_abi_coder7.WORD_SIZE).to_bytes(),
6643
+ asm.addi(20, 18, import_abi_coder6.WORD_SIZE).to_bytes(),
6882
6644
  // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6883
6645
  asm.tr(17, 19, 20).to_bytes()
6884
6646
  ]);
6885
6647
  });
6886
- script = (0, import_utils36.concat)([script, asm.ret(1).to_bytes()]);
6648
+ script = (0, import_utils35.concat)([script, asm.ret(1).to_bytes()]);
6887
6649
  return { script, scriptData };
6888
6650
  };
6889
6651
 
@@ -6913,7 +6675,7 @@ var Account = class extends AbstractAccount {
6913
6675
  super();
6914
6676
  this._provider = provider;
6915
6677
  this._connector = connector;
6916
- this.address = import_address6.Address.fromDynamicInput(address);
6678
+ this.address = new import_address6.Address(address);
6917
6679
  }
6918
6680
  /**
6919
6681
  * The provider used to interact with the network.
@@ -7001,12 +6763,20 @@ var Account = class extends AbstractAccount {
7001
6763
  * @returns A promise that resolves to the funded transaction request.
7002
6764
  */
7003
6765
  async fund(request, params) {
7004
- const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6766
+ const {
6767
+ addedSignatures,
6768
+ estimatedPredicates,
6769
+ requiredQuantities,
6770
+ updateMaxFee,
6771
+ gasPrice,
6772
+ transactionSummary
6773
+ } = params;
6774
+ const chainId = await this.provider.getChainId();
7005
6775
  const fee = request.maxFee;
7006
6776
  const baseAssetId = await this.provider.getBaseAssetId();
7007
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
6777
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math22.bn)(0);
7008
6778
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
7009
- amount: (0, import_math21.bn)(fee),
6779
+ amount: (0, import_math22.bn)(fee),
7010
6780
  assetId: baseAssetId,
7011
6781
  coinQuantities: requiredQuantities
7012
6782
  });
@@ -7014,7 +6784,7 @@ var Account = class extends AbstractAccount {
7014
6784
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
7015
6785
  quantitiesDict[assetId] = {
7016
6786
  required: amount,
7017
- owned: (0, import_math21.bn)(0)
6787
+ owned: (0, import_math22.bn)(0)
7018
6788
  };
7019
6789
  });
7020
6790
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -7076,10 +6846,11 @@ var Account = class extends AbstractAccount {
7076
6846
  }
7077
6847
  if (needsToBeFunded) {
7078
6848
  throw new import_errors22.FuelError(
7079
- import_errors22.ErrorCode.NOT_ENOUGH_FUNDS,
6849
+ import_errors22.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
7080
6850
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
7081
6851
  );
7082
6852
  }
6853
+ request.updateState(chainId, "funded", transactionSummary);
7083
6854
  await this.provider.validateTransaction(request);
7084
6855
  request.updatePredicateGasUsed(estimatedPredicates);
7085
6856
  const requestToReestimate = (0, import_ramda9.clone)(request);
@@ -7151,7 +6922,7 @@ var Account = class extends AbstractAccount {
7151
6922
  addTransfer(request, transferParams) {
7152
6923
  const { destination, amount, assetId } = transferParams;
7153
6924
  this.validateTransferAmount(amount);
7154
- request.addCoinOutput(import_address6.Address.fromAddressOrString(destination), amount, assetId);
6925
+ request.addCoinOutput(new import_address6.Address(destination), amount, assetId);
7155
6926
  return request;
7156
6927
  }
7157
6928
  /**
@@ -7190,9 +6961,9 @@ var Account = class extends AbstractAccount {
7190
6961
  const quantities = [];
7191
6962
  const defaultAssetId = await this.provider.getBaseAssetId();
7192
6963
  const transferParams = contractTransferParams.map((transferParam) => {
7193
- const amount = (0, import_math21.bn)(transferParam.amount);
7194
- const contractAddress = import_address6.Address.fromAddressOrString(transferParam.contractId);
7195
- const assetId = transferParam.assetId ? (0, import_utils37.hexlify)(transferParam.assetId) : defaultAssetId;
6964
+ const amount = (0, import_math22.bn)(transferParam.amount);
6965
+ const contractAddress = new import_address6.Address(transferParam.contractId);
6966
+ const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
7196
6967
  if (amount.lte(0)) {
7197
6968
  throw new import_errors22.FuelError(
7198
6969
  import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -7222,22 +6993,22 @@ var Account = class extends AbstractAccount {
7222
6993
  * @returns A promise that resolves to the transaction response.
7223
6994
  */
7224
6995
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7225
- const recipientAddress = import_address6.Address.fromAddressOrString(recipient);
7226
- const recipientDataArray = (0, import_utils37.arrayify)(
6996
+ const recipientAddress = new import_address6.Address(recipient);
6997
+ const recipientDataArray = (0, import_utils36.arrayify)(
7227
6998
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7228
6999
  );
7229
- const amountDataArray = (0, import_utils37.arrayify)(
7230
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7000
+ const amountDataArray = (0, import_utils36.arrayify)(
7001
+ "0x".concat((0, import_math22.bn)(amount).toHex().substring(2).padStart(16, "0"))
7231
7002
  );
7232
7003
  const script = new Uint8Array([
7233
- ...(0, import_utils37.arrayify)(withdrawScript.bytes),
7004
+ ...(0, import_utils36.arrayify)(withdrawScript.bytes),
7234
7005
  ...recipientDataArray,
7235
7006
  ...amountDataArray
7236
7007
  ]);
7237
7008
  const params = { script, ...txParams };
7238
7009
  const baseAssetId = await this.provider.getBaseAssetId();
7239
7010
  let request = new ScriptTransactionRequest(params);
7240
- const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7011
+ const quantities = [{ amount: (0, import_math22.bn)(amount), assetId: baseAssetId }];
7241
7012
  const txCost = await this.getTransactionCost(request, { quantities });
7242
7013
  request = this.validateGasLimitAndMaxFee({
7243
7014
  transactionRequest: request,
@@ -7258,14 +7029,14 @@ var Account = class extends AbstractAccount {
7258
7029
  *
7259
7030
  * @returns A promise that resolves to the transaction cost object.
7260
7031
  */
7261
- async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
7032
+ async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [], gasPrice } = {}) {
7262
7033
  const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
7263
7034
  const baseAssetId = await this.provider.getBaseAssetId();
7264
7035
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7265
7036
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7266
- const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7037
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
7267
7038
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
7268
- if (input.type === import_transactions24.InputType.Coin) {
7039
+ if (input.type === import_transactions26.InputType.Coin) {
7269
7040
  return input.assetId === assetId;
7270
7041
  }
7271
7042
  if (isRequestInputMessageWithoutData(input)) {
@@ -7293,7 +7064,8 @@ var Account = class extends AbstractAccount {
7293
7064
  ({ amount, assetId }) => updateAssetInput(assetId, amount)
7294
7065
  );
7295
7066
  const txCost = await this.provider.getTransactionCost(txRequestClone, {
7296
- signatureCallback
7067
+ signatureCallback,
7068
+ gasPrice
7297
7069
  });
7298
7070
  return {
7299
7071
  ...txCost,
@@ -7336,16 +7108,28 @@ var Account = class extends AbstractAccount {
7336
7108
  * @param sendTransactionParams - The provider send transaction parameters (optional).
7337
7109
  * @returns A promise that resolves to the transaction response.
7338
7110
  */
7339
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
7111
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
7112
+ let transactionRequest = transactionRequestify(transactionRequestLike);
7340
7113
  if (this._connector) {
7341
- return this.provider.getTransactionResponse(
7342
- await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
7343
- onBeforeSend,
7344
- skipCustomFee
7345
- })
7114
+ const { onBeforeSend, skipCustomFee = false } = connectorOptions;
7115
+ transactionRequest = await this.prepareTransactionForSend(transactionRequest);
7116
+ const params = {
7117
+ onBeforeSend,
7118
+ skipCustomFee,
7119
+ provider: {
7120
+ url: this.provider.url,
7121
+ cache: await serializeProviderCache(this.provider)
7122
+ },
7123
+ transactionState: transactionRequest.flag.state,
7124
+ transactionSummary: await this.prepareTransactionSummary(transactionRequest)
7125
+ };
7126
+ const transaction = await this._connector.sendTransaction(
7127
+ this.address.toString(),
7128
+ transactionRequest,
7129
+ params
7346
7130
  );
7131
+ return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
7347
7132
  }
7348
- const transactionRequest = transactionRequestify(transactionRequestLike);
7349
7133
  if (estimateTxDependencies) {
7350
7134
  await this.provider.estimateTxDependencies(transactionRequest);
7351
7135
  }
@@ -7375,16 +7159,38 @@ var Account = class extends AbstractAccount {
7375
7159
  */
7376
7160
  generateFakeResources(coins) {
7377
7161
  return coins.map((coin) => ({
7378
- id: (0, import_utils37.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
7162
+ id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
7379
7163
  owner: this.address,
7380
- blockCreated: (0, import_math21.bn)(1),
7381
- txCreatedIdx: (0, import_math21.bn)(1),
7164
+ blockCreated: (0, import_math22.bn)(1),
7165
+ txCreatedIdx: (0, import_math22.bn)(1),
7382
7166
  ...coin
7383
7167
  }));
7384
7168
  }
7169
+ /** @hidden */
7170
+ async prepareTransactionForSend(request) {
7171
+ const { transactionId } = request.flag;
7172
+ if (!(0, import_utils36.isDefined)(transactionId)) {
7173
+ return request;
7174
+ }
7175
+ const chainId = await this.provider.getChainId();
7176
+ const currentTransactionId = request.getTransactionId(chainId);
7177
+ if (transactionId !== currentTransactionId) {
7178
+ request.updateState(chainId);
7179
+ }
7180
+ return request;
7181
+ }
7182
+ /** @hidden */
7183
+ async prepareTransactionSummary(request) {
7184
+ const chainId = await this.provider.getChainId();
7185
+ return (0, import_utils36.isDefined)(request.flag.summary) ? {
7186
+ ...request.flag.summary,
7187
+ id: request.getTransactionId(chainId),
7188
+ transactionBytes: (0, import_utils36.hexlify)(request.toTransactionBytes())
7189
+ } : void 0;
7190
+ }
7385
7191
  /** @hidden * */
7386
7192
  validateTransferAmount(amount) {
7387
- if ((0, import_math21.bn)(amount).lte(0)) {
7193
+ if ((0, import_math22.bn)(amount).lte(0)) {
7388
7194
  throw new import_errors22.FuelError(
7389
7195
  import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7390
7196
  "Transfer amount must be a positive number."
@@ -7412,7 +7218,7 @@ var Account = class extends AbstractAccount {
7412
7218
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
7413
7219
  }) {
7414
7220
  const request = transactionRequestify(transactionRequest);
7415
- if (!(0, import_utils37.isDefined)(setGasLimit)) {
7221
+ if (!(0, import_utils36.isDefined)(setGasLimit)) {
7416
7222
  request.gasLimit = gasUsed;
7417
7223
  } else if (gasUsed.gt(setGasLimit)) {
7418
7224
  throw new import_errors22.FuelError(
@@ -7420,7 +7226,7 @@ var Account = class extends AbstractAccount {
7420
7226
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7421
7227
  );
7422
7228
  }
7423
- if (!(0, import_utils37.isDefined)(setMaxFee)) {
7229
+ if (!(0, import_utils36.isDefined)(setMaxFee)) {
7424
7230
  request.maxFee = maxFee;
7425
7231
  } else if (maxFee.gt(setMaxFee)) {
7426
7232
  throw new import_errors22.FuelError(
@@ -7436,7 +7242,7 @@ var Account = class extends AbstractAccount {
7436
7242
  var import_address7 = require("@fuel-ts/address");
7437
7243
  var import_crypto6 = require("@fuel-ts/crypto");
7438
7244
  var import_errors23 = require("@fuel-ts/errors");
7439
- var import_utils38 = require("@fuel-ts/utils");
7245
+ var import_utils37 = require("@fuel-ts/utils");
7440
7246
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7441
7247
  var DEFAULT_KDF_PARAMS_R = 8;
7442
7248
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -7450,7 +7256,7 @@ var removeHexPrefix = (hexString) => {
7450
7256
  };
7451
7257
  async function encryptKeystoreWallet(privateKey, address, password) {
7452
7258
  const privateKeyBuffer = (0, import_crypto6.bufferFromString)(removeHexPrefix(privateKey), "hex");
7453
- const ownerAddress = import_address7.Address.fromAddressOrString(address);
7259
+ const ownerAddress = new import_address7.Address(address);
7454
7260
  const salt = (0, import_crypto6.randomBytes)(DEFAULT_KEY_SIZE);
7455
7261
  const key = (0, import_crypto6.scrypt)({
7456
7262
  password: (0, import_crypto6.bufferFromString)(password),
@@ -7518,7 +7324,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7518
7324
  );
7519
7325
  }
7520
7326
  const buffer = await (0, import_crypto6.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
7521
- const privateKey = (0, import_utils38.hexlify)(buffer);
7327
+ const privateKey = (0, import_utils37.hexlify)(buffer);
7522
7328
  return privateKey;
7523
7329
  }
7524
7330
 
@@ -7563,7 +7369,7 @@ var BaseWalletUnlocked = class extends Account {
7563
7369
  */
7564
7370
  async signMessage(message) {
7565
7371
  const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
7566
- return (0, import_utils39.hexlify)(signedMessage);
7372
+ return (0, import_utils38.hexlify)(signedMessage);
7567
7373
  }
7568
7374
  /**
7569
7375
  * Signs a transaction with the wallet's private key.
@@ -7576,7 +7382,7 @@ var BaseWalletUnlocked = class extends Account {
7576
7382
  const chainId = await this.provider.getChainId();
7577
7383
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
7578
7384
  const signature = await this.signer().sign(hashedTransaction);
7579
- return (0, import_utils39.hexlify)(signature);
7385
+ return (0, import_utils38.hexlify)(signature);
7580
7386
  }
7581
7387
  /**
7582
7388
  * Populates a transaction with the witnesses signature.
@@ -7650,14 +7456,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7650
7456
  var import_crypto8 = require("@fuel-ts/crypto");
7651
7457
  var import_errors26 = require("@fuel-ts/errors");
7652
7458
  var import_hasher7 = require("@fuel-ts/hasher");
7653
- var import_math22 = require("@fuel-ts/math");
7654
- var import_utils43 = require("@fuel-ts/utils");
7459
+ var import_math23 = require("@fuel-ts/math");
7460
+ var import_utils42 = require("@fuel-ts/utils");
7655
7461
 
7656
7462
  // src/mnemonic/mnemonic.ts
7657
7463
  var import_crypto7 = require("@fuel-ts/crypto");
7658
7464
  var import_errors25 = require("@fuel-ts/errors");
7659
7465
  var import_hasher6 = require("@fuel-ts/hasher");
7660
- var import_utils41 = require("@fuel-ts/utils");
7466
+ var import_utils40 = require("@fuel-ts/utils");
7661
7467
 
7662
7468
  // src/wordlists/words/english.ts
7663
7469
  var english = [
@@ -9714,7 +9520,7 @@ var english = [
9714
9520
  // src/mnemonic/utils.ts
9715
9521
  var import_errors24 = require("@fuel-ts/errors");
9716
9522
  var import_hasher5 = require("@fuel-ts/hasher");
9717
- var import_utils40 = require("@fuel-ts/utils");
9523
+ var import_utils39 = require("@fuel-ts/utils");
9718
9524
  function getLowerMask(bits) {
9719
9525
  return (1 << bits) - 1;
9720
9526
  }
@@ -9749,14 +9555,14 @@ function entropyToMnemonicIndices(entropy) {
9749
9555
  }
9750
9556
  }
9751
9557
  const checksumBits = entropy.length / 4;
9752
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
9558
+ const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
9753
9559
  indices[indices.length - 1] <<= checksumBits;
9754
9560
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
9755
9561
  return indices;
9756
9562
  }
9757
9563
  function mnemonicWordsToEntropy(words, wordlist) {
9758
9564
  const size = Math.ceil(11 * words.length / 8);
9759
- const entropy = (0, import_utils40.arrayify)(new Uint8Array(size));
9565
+ const entropy = (0, import_utils39.arrayify)(new Uint8Array(size));
9760
9566
  let offset = 0;
9761
9567
  for (let i = 0; i < words.length; i += 1) {
9762
9568
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -9776,7 +9582,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
9776
9582
  const entropyBits = 32 * words.length / 3;
9777
9583
  const checksumBits = words.length / 3;
9778
9584
  const checksumMask = getUpperMask(checksumBits);
9779
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9585
+ const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9780
9586
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9781
9587
  throw new import_errors24.FuelError(
9782
9588
  import_errors24.ErrorCode.INVALID_CHECKSUM,
@@ -9787,7 +9593,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
9787
9593
  }
9788
9594
 
9789
9595
  // src/mnemonic/mnemonic.ts
9790
- var MasterSecret = (0, import_utils41.toUtf8Bytes)("Bitcoin seed");
9596
+ var MasterSecret = (0, import_utils40.toUtf8Bytes)("Bitcoin seed");
9791
9597
  var MainnetPRV = "0x0488ade4";
9792
9598
  var TestnetPRV = "0x04358394";
9793
9599
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -9851,7 +9657,7 @@ var Mnemonic = class {
9851
9657
  static mnemonicToEntropy(phrase, wordlist = english) {
9852
9658
  const words = getWords(phrase);
9853
9659
  assertMnemonic(words);
9854
- return (0, import_utils41.hexlify)(mnemonicWordsToEntropy(words, wordlist));
9660
+ return (0, import_utils40.hexlify)(mnemonicWordsToEntropy(words, wordlist));
9855
9661
  }
9856
9662
  /**
9857
9663
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -9859,7 +9665,7 @@ var Mnemonic = class {
9859
9665
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
9860
9666
  */
9861
9667
  static entropyToMnemonic(entropy, wordlist = english) {
9862
- const entropyBytes = (0, import_utils41.arrayify)(entropy);
9668
+ const entropyBytes = (0, import_utils40.arrayify)(entropy);
9863
9669
  assertWordList(wordlist);
9864
9670
  assertEntropy(entropyBytes);
9865
9671
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -9871,8 +9677,8 @@ var Mnemonic = class {
9871
9677
  */
9872
9678
  static mnemonicToSeed(phrase, passphrase = "") {
9873
9679
  assertMnemonic(getWords(phrase));
9874
- const phraseBytes = (0, import_utils41.toUtf8Bytes)(getPhrase(phrase));
9875
- const salt = (0, import_utils41.toUtf8Bytes)(`mnemonic${passphrase}`);
9680
+ const phraseBytes = (0, import_utils40.toUtf8Bytes)(getPhrase(phrase));
9681
+ const salt = (0, import_utils40.toUtf8Bytes)(`mnemonic${passphrase}`);
9876
9682
  return (0, import_crypto7.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
9877
9683
  }
9878
9684
  /**
@@ -9928,14 +9734,14 @@ var Mnemonic = class {
9928
9734
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
9929
9735
  */
9930
9736
  static masterKeysFromSeed(seed) {
9931
- const seedArray = (0, import_utils41.arrayify)(seed);
9737
+ const seedArray = (0, import_utils40.arrayify)(seed);
9932
9738
  if (seedArray.length < 16 || seedArray.length > 64) {
9933
9739
  throw new import_errors25.FuelError(
9934
9740
  import_errors25.ErrorCode.INVALID_SEED,
9935
9741
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9936
9742
  );
9937
9743
  }
9938
- return (0, import_utils41.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
9744
+ return (0, import_utils40.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
9939
9745
  }
9940
9746
  /**
9941
9747
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -9946,22 +9752,22 @@ var Mnemonic = class {
9946
9752
  */
9947
9753
  static seedToExtendedKey(seed, testnet = false) {
9948
9754
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
9949
- const prefix = (0, import_utils41.arrayify)(testnet ? TestnetPRV : MainnetPRV);
9755
+ const prefix = (0, import_utils40.arrayify)(testnet ? TestnetPRV : MainnetPRV);
9950
9756
  const depth = "0x00";
9951
9757
  const fingerprint = "0x00000000";
9952
9758
  const index = "0x00000000";
9953
9759
  const chainCode = masterKey.slice(32);
9954
9760
  const privateKey = masterKey.slice(0, 32);
9955
- const extendedKey = (0, import_utils41.concat)([
9761
+ const extendedKey = (0, import_utils40.concat)([
9956
9762
  prefix,
9957
9763
  depth,
9958
9764
  fingerprint,
9959
9765
  index,
9960
9766
  chainCode,
9961
- (0, import_utils41.concat)(["0x00", privateKey])
9767
+ (0, import_utils40.concat)(["0x00", privateKey])
9962
9768
  ]);
9963
- const checksum = (0, import_utils41.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
9964
- return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([extendedKey, checksum]));
9769
+ const checksum = (0, import_utils40.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
9770
+ return (0, import_utils40.encodeBase58)((0, import_utils40.concat)([extendedKey, checksum]));
9965
9771
  }
9966
9772
  /**
9967
9773
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9976,7 +9782,7 @@ var Mnemonic = class {
9976
9782
  * @returns A randomly generated mnemonic
9977
9783
  */
9978
9784
  static generate(size = 32, extraEntropy = "") {
9979
- const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils41.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils41.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
9785
+ const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils40.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils40.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
9980
9786
  return Mnemonic.entropyToMnemonic(entropy);
9981
9787
  }
9982
9788
  };
@@ -9984,12 +9790,12 @@ var mnemonic_default = Mnemonic;
9984
9790
 
9985
9791
  // src/hdwallet/hdwallet.ts
9986
9792
  var HARDENED_INDEX = 2147483648;
9987
- var MainnetPRV2 = (0, import_utils43.hexlify)("0x0488ade4");
9988
- var MainnetPUB = (0, import_utils43.hexlify)("0x0488b21e");
9989
- var TestnetPRV2 = (0, import_utils43.hexlify)("0x04358394");
9990
- var TestnetPUB = (0, import_utils43.hexlify)("0x043587cf");
9793
+ var MainnetPRV2 = (0, import_utils42.hexlify)("0x0488ade4");
9794
+ var MainnetPUB = (0, import_utils42.hexlify)("0x0488b21e");
9795
+ var TestnetPRV2 = (0, import_utils42.hexlify)("0x04358394");
9796
+ var TestnetPUB = (0, import_utils42.hexlify)("0x043587cf");
9991
9797
  function base58check(data) {
9992
- return (0, import_utils43.encodeBase58)((0, import_utils43.concat)([data, (0, import_utils43.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
9798
+ return (0, import_utils42.encodeBase58)((0, import_utils42.concat)([data, (0, import_utils42.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
9993
9799
  }
9994
9800
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9995
9801
  if (isPublic) {
@@ -9998,11 +9804,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9998
9804
  return testnet ? TestnetPRV2 : MainnetPRV2;
9999
9805
  }
10000
9806
  function isPublicExtendedKey(extendedKey) {
10001
- return [MainnetPUB, TestnetPUB].includes((0, import_utils43.hexlify)(extendedKey.slice(0, 4)));
9807
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils42.hexlify)(extendedKey.slice(0, 4)));
10002
9808
  }
10003
9809
  function isValidExtendedKey(extendedKey) {
10004
9810
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
10005
- (0, import_utils43.hexlify)(extendedKey.slice(0, 4))
9811
+ (0, import_utils42.hexlify)(extendedKey.slice(0, 4))
10006
9812
  );
10007
9813
  }
10008
9814
  function parsePath(path2, depth = 0) {
@@ -10020,8 +9826,8 @@ function parsePath(path2, depth = 0) {
10020
9826
  var HDWallet = class {
10021
9827
  depth = 0;
10022
9828
  index = 0;
10023
- fingerprint = (0, import_utils43.hexlify)("0x00000000");
10024
- parentFingerprint = (0, import_utils43.hexlify)("0x00000000");
9829
+ fingerprint = (0, import_utils42.hexlify)("0x00000000");
9830
+ parentFingerprint = (0, import_utils42.hexlify)("0x00000000");
10025
9831
  privateKey;
10026
9832
  publicKey;
10027
9833
  chainCode;
@@ -10033,8 +9839,8 @@ var HDWallet = class {
10033
9839
  constructor(config) {
10034
9840
  if (config.privateKey) {
10035
9841
  const signer = new Signer(config.privateKey);
10036
- this.publicKey = (0, import_utils43.hexlify)(signer.compressedPublicKey);
10037
- this.privateKey = (0, import_utils43.hexlify)(config.privateKey);
9842
+ this.publicKey = (0, import_utils42.hexlify)(signer.compressedPublicKey);
9843
+ this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
10038
9844
  } else {
10039
9845
  if (!config.publicKey) {
10040
9846
  throw new import_errors26.FuelError(
@@ -10042,10 +9848,10 @@ var HDWallet = class {
10042
9848
  "Both public and private Key cannot be missing. At least one should be provided."
10043
9849
  );
10044
9850
  }
10045
- this.publicKey = (0, import_utils43.hexlify)(config.publicKey);
9851
+ this.publicKey = (0, import_utils42.hexlify)(config.publicKey);
10046
9852
  }
10047
9853
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
10048
- this.fingerprint = (0, import_utils43.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
9854
+ this.fingerprint = (0, import_utils42.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
10049
9855
  this.depth = config.depth || this.depth;
10050
9856
  this.index = config.index || this.index;
10051
9857
  this.chainCode = config.chainCode;
@@ -10061,9 +9867,9 @@ var HDWallet = class {
10061
9867
  * @returns A new instance of HDWallet on the derived index
10062
9868
  */
10063
9869
  deriveIndex(index) {
10064
- const privateKey = this.privateKey && (0, import_utils43.arrayify)(this.privateKey);
10065
- const publicKey = (0, import_utils43.arrayify)(this.publicKey);
10066
- const chainCode = (0, import_utils43.arrayify)(this.chainCode);
9870
+ const privateKey = this.privateKey && (0, import_utils42.arrayify)(this.privateKey);
9871
+ const publicKey = (0, import_utils42.arrayify)(this.publicKey);
9872
+ const chainCode = (0, import_utils42.arrayify)(this.chainCode);
10067
9873
  const data = new Uint8Array(37);
10068
9874
  if (index & HARDENED_INDEX) {
10069
9875
  if (!privateKey) {
@@ -10074,15 +9880,15 @@ var HDWallet = class {
10074
9880
  }
10075
9881
  data.set(privateKey, 1);
10076
9882
  } else {
10077
- data.set((0, import_utils43.arrayify)(this.publicKey));
9883
+ data.set((0, import_utils42.arrayify)(this.publicKey));
10078
9884
  }
10079
- data.set((0, import_math22.toBytes)(index, 4), 33);
10080
- const bytes = (0, import_utils43.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
9885
+ data.set((0, import_math23.toBytes)(index, 4), 33);
9886
+ const bytes = (0, import_utils42.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
10081
9887
  const IL = bytes.slice(0, 32);
10082
9888
  const IR = bytes.slice(32);
10083
9889
  if (privateKey) {
10084
9890
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
10085
- const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
9891
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
10086
9892
  return new HDWallet({
10087
9893
  privateKey: ki,
10088
9894
  chainCode: IR,
@@ -10091,7 +9897,7 @@ var HDWallet = class {
10091
9897
  parentFingerprint: this.fingerprint
10092
9898
  });
10093
9899
  }
10094
- const signer = new Signer((0, import_utils43.hexlify)(IL));
9900
+ const signer = new Signer((0, import_utils42.hexlify)(IL));
10095
9901
  const Ki = signer.addPoint(publicKey);
10096
9902
  return new HDWallet({
10097
9903
  publicKey: Ki,
@@ -10126,12 +9932,12 @@ var HDWallet = class {
10126
9932
  );
10127
9933
  }
10128
9934
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
10129
- const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
9935
+ const depth = (0, import_utils42.hexlify)(Uint8Array.from([this.depth]));
10130
9936
  const parentFingerprint = this.parentFingerprint;
10131
- const index = (0, import_math22.toHex)(this.index, 4);
9937
+ const index = (0, import_math23.toHex)(this.index, 4);
10132
9938
  const chainCode = this.chainCode;
10133
- const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
10134
- const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
9939
+ const key = this.privateKey != null && !isPublic ? (0, import_utils42.concat)(["0x00", this.privateKey]) : this.publicKey;
9940
+ const extendedKey = (0, import_utils42.arrayify)((0, import_utils42.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
10135
9941
  return base58check(extendedKey);
10136
9942
  }
10137
9943
  /**
@@ -10143,13 +9949,13 @@ var HDWallet = class {
10143
9949
  static fromSeed(seed) {
10144
9950
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
10145
9951
  return new HDWallet({
10146
- chainCode: (0, import_utils43.arrayify)(masterKey.slice(32)),
10147
- privateKey: (0, import_utils43.arrayify)(masterKey.slice(0, 32))
9952
+ chainCode: (0, import_utils42.arrayify)(masterKey.slice(32)),
9953
+ privateKey: (0, import_utils42.arrayify)(masterKey.slice(0, 32))
10148
9954
  });
10149
9955
  }
10150
9956
  static fromExtendedKey(extendedKey) {
10151
- const decoded = (0, import_utils43.hexlify)((0, import_math22.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
10152
- const bytes = (0, import_utils43.arrayify)(decoded);
9957
+ const decoded = (0, import_utils42.hexlify)((0, import_math23.toBytes)((0, import_utils42.decodeBase58)(extendedKey)));
9958
+ const bytes = (0, import_utils42.arrayify)(decoded);
10153
9959
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10154
9960
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10155
9961
  throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -10158,9 +9964,9 @@ var HDWallet = class {
10158
9964
  throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10159
9965
  }
10160
9966
  const depth = bytes[4];
10161
- const parentFingerprint = (0, import_utils43.hexlify)(bytes.slice(5, 9));
10162
- const index = parseInt((0, import_utils43.hexlify)(bytes.slice(9, 13)).substring(2), 16);
10163
- const chainCode = (0, import_utils43.hexlify)(bytes.slice(13, 45));
9967
+ const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
9968
+ const index = parseInt((0, import_utils42.hexlify)(bytes.slice(9, 13)).substring(2), 16);
9969
+ const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
10164
9970
  const key = bytes.slice(45, 78);
10165
9971
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10166
9972
  throw new import_errors26.FuelError(
@@ -10361,14 +10167,14 @@ var WalletsConfig = class {
10361
10167
  constructor(baseAssetId, config) {
10362
10168
  WalletsConfig.validate(config);
10363
10169
  this.options = config;
10364
- const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
10170
+ const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
10365
10171
  this.wallets = this.generateWallets();
10366
10172
  this.initialState = {
10367
10173
  messages: WalletsConfig.createMessages(this.wallets, messages),
10368
10174
  coins: WalletsConfig.createCoins(
10369
10175
  this.wallets,
10370
10176
  baseAssetId,
10371
- assets2,
10177
+ assets,
10372
10178
  coinsPerAsset,
10373
10179
  amountPerCoin
10374
10180
  )
@@ -10378,7 +10184,7 @@ var WalletsConfig = class {
10378
10184
  return {
10379
10185
  ...snapshotConfig,
10380
10186
  stateConfig: {
10381
- ...snapshotConfig?.stateConfig ?? import_utils44.defaultSnapshotConfigs.stateConfig,
10187
+ ...snapshotConfig?.stateConfig ?? import_utils43.defaultSnapshotConfigs.stateConfig,
10382
10188
  coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
10383
10189
  messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
10384
10190
  }
@@ -10393,25 +10199,25 @@ var WalletsConfig = class {
10393
10199
  /**
10394
10200
  * Create coins for the wallets in the format that the chain expects.
10395
10201
  */
10396
- static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
10202
+ static createCoins(wallets, baseAssetId, assets, coinsPerAsset, amountPerCoin) {
10397
10203
  const coins = [];
10398
10204
  let assetIds = [baseAssetId];
10399
- if (Array.isArray(assets2)) {
10400
- assetIds = assetIds.concat(assets2.map((a) => a.value));
10205
+ if (Array.isArray(assets)) {
10206
+ assetIds = assetIds.concat(assets.map((a) => a.value));
10401
10207
  } else {
10402
- assetIds = assetIds.concat(TestAssetId.random(assets2 - 1).map((a) => a.value));
10208
+ assetIds = assetIds.concat(TestAssetId.random(assets - 1).map((a) => a.value));
10403
10209
  }
10404
10210
  wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
10405
10211
  assetIds.forEach((assetId) => {
10406
10212
  for (let index = 0; index < coinsPerAsset; index++) {
10407
10213
  coins.push({
10408
- amount: amountPerCoin,
10214
+ amount: (0, import_math24.bn)(amountPerCoin).toString(),
10409
10215
  asset_id: assetId,
10410
10216
  owner: walletAddress,
10411
10217
  tx_pointer_block_height: 0,
10412
10218
  tx_pointer_tx_idx: 0,
10413
10219
  output_index: 0,
10414
- tx_id: (0, import_utils44.hexlify)((0, import_crypto9.randomBytes)(32))
10220
+ tx_id: (0, import_utils43.hexlify)((0, import_crypto9.randomBytes)(32))
10415
10221
  });
10416
10222
  }
10417
10223
  });
@@ -10420,7 +10226,7 @@ var WalletsConfig = class {
10420
10226
  }
10421
10227
  static validate({
10422
10228
  count: wallets,
10423
- assets: assets2,
10229
+ assets,
10424
10230
  coinsPerAsset,
10425
10231
  amountPerCoin
10426
10232
  }) {
@@ -10430,7 +10236,7 @@ var WalletsConfig = class {
10430
10236
  "Number of wallets must be greater than zero."
10431
10237
  );
10432
10238
  }
10433
- if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
10239
+ if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
10434
10240
  throw new import_errors27.FuelError(
10435
10241
  import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10436
10242
  "Number of assets per wallet must be greater than zero."
@@ -10442,7 +10248,7 @@ var WalletsConfig = class {
10442
10248
  "Number of coins per asset must be greater than zero."
10443
10249
  );
10444
10250
  }
10445
- if (amountPerCoin < 0) {
10251
+ if ((0, import_math24.bn)(amountPerCoin).lt(0)) {
10446
10252
  throw new import_errors27.FuelError(
10447
10253
  import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10448
10254
  "Amount per coin must be greater than or equal to zero."
@@ -10467,7 +10273,7 @@ async function setupTestProviderAndWallets({
10467
10273
  } = {}) {
10468
10274
  Symbol.dispose ??= Symbol("Symbol.dispose");
10469
10275
  const walletsConfig = new WalletsConfig(
10470
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils45.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
10276
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils44.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
10471
10277
  {
10472
10278
  ...defaultWalletConfigOptions,
10473
10279
  ...walletsConfigOptions
@@ -10477,7 +10283,7 @@ async function setupTestProviderAndWallets({
10477
10283
  loggingEnabled: false,
10478
10284
  ...nodeOptions,
10479
10285
  snapshotConfig: (0, import_ramda10.mergeDeepRight)(
10480
- import_utils45.defaultSnapshotConfigs,
10286
+ import_utils44.defaultSnapshotConfigs,
10481
10287
  walletsConfig.apply(nodeOptions?.snapshotConfig)
10482
10288
  ),
10483
10289
  port: nodeOptions.port || "0"
@@ -10518,8 +10324,8 @@ async function setupTestProviderAndWallets({
10518
10324
  // src/test-utils/test-message.ts
10519
10325
  var import_address8 = require("@fuel-ts/address");
10520
10326
  var import_crypto10 = require("@fuel-ts/crypto");
10521
- var import_math23 = require("@fuel-ts/math");
10522
- var import_utils46 = require("@fuel-ts/utils");
10327
+ var import_math25 = require("@fuel-ts/math");
10328
+ var import_utils45 = require("@fuel-ts/utils");
10523
10329
  var TestMessage = class {
10524
10330
  sender;
10525
10331
  recipient;
@@ -10536,7 +10342,7 @@ var TestMessage = class {
10536
10342
  constructor({
10537
10343
  sender = import_address8.Address.fromRandom(),
10538
10344
  recipient = import_address8.Address.fromRandom(),
10539
- nonce = (0, import_utils46.hexlify)((0, import_crypto10.randomBytes)(32)),
10345
+ nonce = (0, import_utils45.hexlify)((0, import_crypto10.randomBytes)(32)),
10540
10346
  amount = 1e6,
10541
10347
  data = "",
10542
10348
  // Will default to empty data in order to be a spendable message
@@ -10555,7 +10361,7 @@ var TestMessage = class {
10555
10361
  sender: this.sender.toB256(),
10556
10362
  recipient: recipient?.toB256() ?? this.recipient.toB256(),
10557
10363
  nonce: this.nonce,
10558
- amount: (0, import_math23.bn)(this.amount).toNumber(),
10364
+ amount: (0, import_math25.bn)(this.amount).toNumber(),
10559
10365
  data,
10560
10366
  da_height: this.da_height
10561
10367
  };