@fuel-ts/account 0.97.2 → 0.99.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 (154) hide show
  1. package/dist/account.d.ts +20 -17
  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 +5 -5
  21. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  22. package/dist/connectors/fuel.d.ts +3 -3
  23. package/dist/connectors/fuel.d.ts.map +1 -1
  24. package/dist/connectors/types/data-type.d.ts +8 -0
  25. package/dist/connectors/types/data-type.d.ts.map +1 -1
  26. package/dist/connectors/types/events.d.ts +1 -1
  27. package/dist/connectors/types/events.d.ts.map +1 -1
  28. package/dist/hdwallet/hdwallet.d.ts +1 -1
  29. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.global.js +17174 -15376
  33. package/dist/index.global.js.map +1 -1
  34. package/dist/index.js +6602 -6428
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +6613 -6450
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/mnemonic/mnemonic.d.ts +1 -1
  39. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  40. package/dist/mnemonic/utils.d.ts +1 -1
  41. package/dist/mnemonic/utils.d.ts.map +1 -1
  42. package/dist/predicate/predicate.d.ts +9 -1
  43. package/dist/predicate/predicate.d.ts.map +1 -1
  44. package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
  45. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
  46. package/dist/providers/__generated__/operations.d.ts +28 -175
  47. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  48. package/dist/providers/coin-quantity.d.ts +1 -1
  49. package/dist/providers/coin-quantity.d.ts.map +1 -1
  50. package/dist/providers/coin.d.ts +3 -2
  51. package/dist/providers/coin.d.ts.map +1 -1
  52. package/dist/providers/fuel-graphql-subscriber.d.ts +1 -0
  53. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  54. package/dist/providers/index.d.ts +0 -1
  55. package/dist/providers/index.d.ts.map +1 -1
  56. package/dist/providers/message.d.ts +8 -7
  57. package/dist/providers/message.d.ts.map +1 -1
  58. package/dist/providers/provider.d.ts +65 -42
  59. package/dist/providers/provider.d.ts.map +1 -1
  60. package/dist/providers/resource.d.ts +1 -1
  61. package/dist/providers/resource.d.ts.map +1 -1
  62. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  63. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  64. package/dist/providers/transaction-request/errors.d.ts +3 -3
  65. package/dist/providers/transaction-request/errors.d.ts.map +1 -1
  66. package/dist/providers/transaction-request/helpers.d.ts +26 -4
  67. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  68. package/dist/providers/transaction-request/input.d.ts +1 -1
  69. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  70. package/dist/providers/transaction-request/output.d.ts +1 -1
  71. package/dist/providers/transaction-request/output.d.ts.map +1 -1
  72. package/dist/providers/transaction-request/script-transaction-request.d.ts +13 -3
  73. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  74. package/dist/providers/transaction-request/scripts.d.ts +1 -1
  75. package/dist/providers/transaction-request/scripts.d.ts.map +1 -1
  76. package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
  77. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
  78. package/dist/providers/transaction-request/transaction-request.d.ts +5 -3
  79. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  80. package/dist/providers/transaction-request/types.d.ts +7 -0
  81. package/dist/providers/transaction-request/types.d.ts.map +1 -1
  82. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +1 -1
  83. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
  84. package/dist/providers/transaction-request/upload-transaction-request.d.ts +1 -1
  85. package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
  86. package/dist/providers/transaction-request/witness.d.ts +1 -1
  87. package/dist/providers/transaction-request/witness.d.ts.map +1 -1
  88. package/dist/providers/transaction-response/transaction-response.d.ts +1 -1
  89. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  90. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  91. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +0 -1
  92. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -1
  93. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  94. package/dist/providers/transaction-summary/input.d.ts +1 -1
  95. package/dist/providers/transaction-summary/status.d.ts +9 -2
  96. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  97. package/dist/providers/transaction-summary/types.d.ts +1 -21
  98. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  99. package/dist/providers/utils/handle-gql-error-message.d.ts +5 -1
  100. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  101. package/dist/providers/utils/receipts.d.ts.map +1 -1
  102. package/dist/signer/signer.d.ts +1 -1
  103. package/dist/signer/signer.d.ts.map +1 -1
  104. package/dist/test-utils/launchNode.d.ts +2 -1
  105. package/dist/test-utils/launchNode.d.ts.map +1 -1
  106. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
  107. package/dist/test-utils/test-message.d.ts +6 -6
  108. package/dist/test-utils/test-message.d.ts.map +1 -1
  109. package/dist/test-utils/wallet-config.d.ts +2 -1
  110. package/dist/test-utils/wallet-config.d.ts.map +1 -1
  111. package/dist/test-utils.global.js +3096 -1963
  112. package/dist/test-utils.global.js.map +1 -1
  113. package/dist/test-utils.js +498 -1011
  114. package/dist/test-utils.js.map +1 -1
  115. package/dist/test-utils.mjs +453 -966
  116. package/dist/test-utils.mjs.map +1 -1
  117. package/dist/types.d.ts +11 -0
  118. package/dist/types.d.ts.map +1 -0
  119. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -1
  120. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
  121. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  122. package/dist/utils/predicate-script-loader-instructions.d.ts +36 -1
  123. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -1
  124. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  125. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  126. package/dist/wallet/keystore-wallet.d.ts +2 -2
  127. package/dist/wallet/keystore-wallet.d.ts.map +1 -1
  128. package/dist/wallet/wallet.d.ts +3 -2
  129. package/dist/wallet/wallet.d.ts.map +1 -1
  130. package/dist/wallet/wallets.d.ts +1 -1
  131. package/dist/wallet/wallets.d.ts.map +1 -1
  132. package/dist/wallet-manager/types.d.ts +4 -4
  133. package/dist/wallet-manager/types.d.ts.map +1 -1
  134. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +6 -5
  135. package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
  136. package/dist/wallet-manager/vaults/privatekey-vault.d.ts +6 -5
  137. package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
  138. package/dist/wallet-manager/wallet-manager.d.ts +3 -3
  139. package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
  140. package/package.json +28 -30
  141. package/dist/providers/assets/assets.d.ts.map +0 -1
  142. package/dist/providers/assets/index.d.ts.map +0 -1
  143. package/dist/providers/assets/types.d.ts.map +0 -1
  144. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +0 -2
  145. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +0 -1
  146. package/dist/providers/assets/utils/index.d.ts.map +0 -1
  147. package/dist/providers/assets/utils/network.d.ts.map +0 -1
  148. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
  149. package/dist/providers/assets/utils/url.d.ts.map +0 -1
  150. /package/dist/{providers/assets → assets}/assets.d.ts +0 -0
  151. /package/dist/{providers/assets → assets}/types.d.ts +0 -0
  152. /package/dist/{providers/assets → assets}/utils/index.d.ts +0 -0
  153. /package/dist/{providers/assets → assets}/utils/resolveIconPaths.d.ts +0 -0
  154. /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
@@ -258,7 +258,8 @@ var launchNode = async ({
258
258
  loggingEnabled = true,
259
259
  basePath,
260
260
  snapshotConfig = import_utils2.defaultSnapshotConfigs,
261
- includeInitialState = false
261
+ includeInitialState = false,
262
+ killProcessOnExit = false
262
263
  } = {}) => (
263
264
  // eslint-disable-next-line no-async-promise-executor
264
265
  new Promise(async (resolve, reject) => {
@@ -335,14 +336,14 @@ var launchNode = async ({
335
336
  console.log(chunk.toString());
336
337
  });
337
338
  }
338
- const removeSideffects = () => {
339
+ const removeChildListeners = () => {
339
340
  child.stderr.removeAllListeners();
341
+ };
342
+ const removeTempDir = () => {
340
343
  if ((0, import_fs.existsSync)(tempDir)) {
341
344
  (0, import_fs.rmSync)(tempDir, { recursive: true });
342
345
  }
343
346
  };
344
- child.on("error", removeSideffects);
345
- child.on("exit", removeSideffects);
346
347
  const childState = {
347
348
  isDead: false
348
349
  };
@@ -351,7 +352,7 @@ var launchNode = async ({
351
352
  return;
352
353
  }
353
354
  childState.isDead = true;
354
- removeSideffects();
355
+ removeChildListeners();
355
356
  if (child.pid !== void 0) {
356
357
  try {
357
358
  process.kill(-child.pid);
@@ -370,6 +371,7 @@ var launchNode = async ({
370
371
  } else {
371
372
  console.error("No PID available for the child process, unable to kill launched node");
372
373
  }
374
+ removeTempDir();
373
375
  };
374
376
  child.stderr.on("data", (chunk) => {
375
377
  const text = typeof chunk === "string" ? chunk : chunk.toString();
@@ -398,12 +400,23 @@ var launchNode = async ({
398
400
  process.on("SIGUSR2", cleanup);
399
401
  process.on("beforeExit", cleanup);
400
402
  process.on("uncaughtException", cleanup);
401
- child.on("error", reject);
403
+ child.on("exit", (code, _signal) => {
404
+ removeChildListeners();
405
+ removeTempDir();
406
+ if (killProcessOnExit) {
407
+ process.exit(code);
408
+ }
409
+ });
410
+ child.on("error", (err) => {
411
+ removeChildListeners();
412
+ removeTempDir();
413
+ reject(err);
414
+ });
402
415
  })
403
416
  );
404
417
 
405
418
  // src/test-utils/setup-test-provider-and-wallets.ts
406
- var import_utils45 = require("@fuel-ts/utils");
419
+ var import_utils44 = require("@fuel-ts/utils");
407
420
  var import_ramda10 = require("ramda");
408
421
 
409
422
  // src/providers/coin-quantity.ts
@@ -443,7 +456,7 @@ var addAmountToCoinQuantities = (params) => {
443
456
 
444
457
  // src/providers/provider.ts
445
458
  var import_address4 = require("@fuel-ts/address");
446
- var import_errors19 = require("@fuel-ts/errors");
459
+ var import_errors20 = require("@fuel-ts/errors");
447
460
  var import_math19 = require("@fuel-ts/math");
448
461
  var import_transactions22 = require("@fuel-ts/transactions");
449
462
  var import_utils30 = require("@fuel-ts/utils");
@@ -1198,9 +1211,6 @@ var GetBalancesDocument = import_graphql_tag.default`
1198
1211
  first: $first
1199
1212
  last: $last
1200
1213
  ) {
1201
- pageInfo {
1202
- ...pageInfoFragment
1203
- }
1204
1214
  edges {
1205
1215
  node {
1206
1216
  assetId
@@ -1209,7 +1219,7 @@ var GetBalancesDocument = import_graphql_tag.default`
1209
1219
  }
1210
1220
  }
1211
1221
  }
1212
- ${PageInfoFragmentDoc}`;
1222
+ `;
1213
1223
  var GetMessagesDocument = import_graphql_tag.default`
1214
1224
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
1215
1225
  messages(
@@ -1231,6 +1241,13 @@ var GetMessagesDocument = import_graphql_tag.default`
1231
1241
  }
1232
1242
  ${PageInfoFragmentDoc}
1233
1243
  ${GetMessageFragmentDoc}`;
1244
+ var DaCompressedBlockDocument = import_graphql_tag.default`
1245
+ query daCompressedBlock($height: U32!) {
1246
+ daCompressedBlock(height: $height) {
1247
+ bytes
1248
+ }
1249
+ }
1250
+ `;
1234
1251
  var GetMessageProofDocument = import_graphql_tag.default`
1235
1252
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
1236
1253
  messageProof(
@@ -1314,13 +1331,6 @@ var GetConsensusParametersVersionDocument = import_graphql_tag.default`
1314
1331
  }
1315
1332
  }
1316
1333
  `;
1317
- var SubmitAndAwaitDocument = import_graphql_tag.default`
1318
- subscription submitAndAwait($encodedTransaction: HexString!) {
1319
- submitAndAwait(tx: $encodedTransaction) {
1320
- ...transactionStatusSubscriptionFragment
1321
- }
1322
- }
1323
- ${TransactionStatusSubscriptionFragmentDoc}`;
1324
1334
  var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
1325
1335
  subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
1326
1336
  submitAndAwaitStatus(tx: $encodedTransaction) {
@@ -1409,6 +1419,9 @@ function getSdk(requester) {
1409
1419
  getMessages(variables, options) {
1410
1420
  return requester(GetMessagesDocument, variables, options);
1411
1421
  },
1422
+ daCompressedBlock(variables, options) {
1423
+ return requester(DaCompressedBlockDocument, variables, options);
1424
+ },
1412
1425
  getMessageProof(variables, options) {
1413
1426
  return requester(GetMessageProofDocument, variables, options);
1414
1427
  },
@@ -1436,9 +1449,6 @@ function getSdk(requester) {
1436
1449
  getConsensusParametersVersion(variables, options) {
1437
1450
  return requester(GetConsensusParametersVersionDocument, variables, options);
1438
1451
  },
1439
- submitAndAwait(variables, options) {
1440
- return requester(SubmitAndAwaitDocument, variables, options);
1441
- },
1442
1452
  submitAndAwaitStatus(variables, options) {
1443
1453
  return requester(SubmitAndAwaitStatusDocument, variables, options);
1444
1454
  },
@@ -1449,8 +1459,60 @@ function getSdk(requester) {
1449
1459
  }
1450
1460
 
1451
1461
  // src/providers/fuel-graphql-subscriber.ts
1452
- var import_errors2 = require("@fuel-ts/errors");
1462
+ var import_errors3 = require("@fuel-ts/errors");
1453
1463
  var import_graphql = require("graphql");
1464
+
1465
+ // src/providers/utils/handle-gql-error-message.ts
1466
+ var import_errors2 = require("@fuel-ts/errors");
1467
+ var mapGqlErrorMessage = (error) => {
1468
+ switch (error.message) {
1469
+ case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
1470
+ return new import_errors2.FuelError(
1471
+ import_errors2.ErrorCode.NOT_ENOUGH_FUNDS,
1472
+ `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
1473
+ {},
1474
+ error
1475
+ );
1476
+ case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
1477
+ return new import_errors2.FuelError(
1478
+ import_errors2.ErrorCode.MAX_COINS_REACHED,
1479
+ "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
1480
+ {},
1481
+ error
1482
+ );
1483
+ default:
1484
+ return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1485
+ }
1486
+ };
1487
+ var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
1488
+ if (!incompatibleNodeVersionMessage) {
1489
+ return error;
1490
+ }
1491
+ return new import_errors2.FuelError(
1492
+ error.code,
1493
+ `${error.message}
1494
+
1495
+ ${incompatibleNodeVersionMessage}`,
1496
+ error.metadata,
1497
+ error.rawError
1498
+ );
1499
+ };
1500
+ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
1501
+ if (!Array.isArray(errors)) {
1502
+ return;
1503
+ }
1504
+ const mappedErrors = errors.map(mapGqlErrorMessage);
1505
+ if (mappedErrors.length === 1) {
1506
+ throw mapGqlErrorWithIncompatibleNodeVersion(mappedErrors[0], incompatibleNodeVersionMessage);
1507
+ }
1508
+ const errorMessage = mappedErrors.map((err) => err.message).join("\n");
1509
+ throw mapGqlErrorWithIncompatibleNodeVersion(
1510
+ new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1511
+ incompatibleNodeVersionMessage
1512
+ );
1513
+ };
1514
+
1515
+ // src/providers/fuel-graphql-subscriber.ts
1454
1516
  var _FuelGraphqlSubscriber = class {
1455
1517
  constructor(stream) {
1456
1518
  this.stream = stream;
@@ -1478,12 +1540,7 @@ var _FuelGraphqlSubscriber = class {
1478
1540
  while (true) {
1479
1541
  if (this.events.length > 0) {
1480
1542
  const { data, errors } = this.events.shift();
1481
- if (Array.isArray(errors)) {
1482
- throw new import_errors2.FuelError(
1483
- import_errors2.FuelError.CODES.INVALID_REQUEST,
1484
- errors.map((err) => err.message).join("\n\n")
1485
- );
1486
- }
1543
+ assertGqlResponseHasNoErrors(errors, _FuelGraphqlSubscriber.incompatibleNodeVersionMessage);
1487
1544
  return { value: data, done: false };
1488
1545
  }
1489
1546
  const { value, done } = await this.stream.read();
@@ -1501,8 +1558,8 @@ var _FuelGraphqlSubscriber = class {
1501
1558
  try {
1502
1559
  this.events.push(JSON.parse(match.replace(/^data:/, "")));
1503
1560
  } catch (e) {
1504
- throw new import_errors2.FuelError(
1505
- import_errors2.ErrorCode.STREAM_PARSING_ERROR,
1561
+ throw new import_errors3.FuelError(
1562
+ import_errors3.ErrorCode.STREAM_PARSING_ERROR,
1506
1563
  `Error while parsing stream data response: ${text}`
1507
1564
  );
1508
1565
  }
@@ -1521,10 +1578,11 @@ var _FuelGraphqlSubscriber = class {
1521
1578
  }
1522
1579
  };
1523
1580
  var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
1581
+ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
1524
1582
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1525
1583
 
1526
1584
  // src/providers/resource-cache.ts
1527
- var import_errors3 = require("@fuel-ts/errors");
1585
+ var import_errors4 = require("@fuel-ts/errors");
1528
1586
  var import_utils4 = require("@fuel-ts/utils");
1529
1587
  var cache = /* @__PURE__ */ new Map();
1530
1588
  var ResourceCache = class {
@@ -1532,8 +1590,8 @@ var ResourceCache = class {
1532
1590
  constructor(ttl) {
1533
1591
  this.ttl = ttl;
1534
1592
  if (typeof ttl !== "number" || this.ttl <= 0) {
1535
- throw new import_errors3.FuelError(
1536
- import_errors3.ErrorCode.INVALID_TTL,
1593
+ throw new import_errors4.FuelError(
1594
+ import_errors4.ErrorCode.INVALID_TTL,
1537
1595
  `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
1538
1596
  );
1539
1597
  }
@@ -1588,7 +1646,7 @@ var ResourceCache = class {
1588
1646
  // src/providers/transaction-request/input.ts
1589
1647
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1590
1648
  var import_configs = require("@fuel-ts/address/configs");
1591
- var import_errors4 = require("@fuel-ts/errors");
1649
+ var import_errors5 = require("@fuel-ts/errors");
1592
1650
  var import_math3 = require("@fuel-ts/math");
1593
1651
  var import_transactions = require("@fuel-ts/transactions");
1594
1652
  var import_utils5 = require("@fuel-ts/utils");
@@ -1652,8 +1710,8 @@ var inputify = (value) => {
1652
1710
  };
1653
1711
  }
1654
1712
  default: {
1655
- throw new import_errors4.FuelError(
1656
- import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
1713
+ throw new import_errors5.FuelError(
1714
+ import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
1657
1715
  `Invalid transaction input type: ${type}.`
1658
1716
  );
1659
1717
  }
@@ -1662,7 +1720,7 @@ var inputify = (value) => {
1662
1720
 
1663
1721
  // src/providers/transaction-request/output.ts
1664
1722
  var import_configs2 = require("@fuel-ts/address/configs");
1665
- var import_errors5 = require("@fuel-ts/errors");
1723
+ var import_errors6 = require("@fuel-ts/errors");
1666
1724
  var import_math4 = require("@fuel-ts/math");
1667
1725
  var import_transactions2 = require("@fuel-ts/transactions");
1668
1726
  var import_utils6 = require("@fuel-ts/utils");
@@ -1709,8 +1767,8 @@ var outputify = (value) => {
1709
1767
  };
1710
1768
  }
1711
1769
  default: {
1712
- throw new import_errors5.FuelError(
1713
- import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
1770
+ throw new import_errors6.FuelError(
1771
+ import_errors6.ErrorCode.INVALID_TRANSACTION_INPUT,
1714
1772
  `Invalid transaction output type: ${type}.`
1715
1773
  );
1716
1774
  }
@@ -1722,7 +1780,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
1722
1780
  var import_address2 = require("@fuel-ts/address");
1723
1781
  var import_configs6 = require("@fuel-ts/address/configs");
1724
1782
  var import_crypto3 = require("@fuel-ts/crypto");
1725
- var import_errors9 = require("@fuel-ts/errors");
1783
+ var import_errors11 = require("@fuel-ts/errors");
1726
1784
  var import_math9 = require("@fuel-ts/math");
1727
1785
  var import_transactions7 = require("@fuel-ts/transactions");
1728
1786
  var import_utils11 = require("@fuel-ts/utils");
@@ -1735,7 +1793,7 @@ var isCoin = (resource) => "id" in resource;
1735
1793
 
1736
1794
  // src/providers/utils/receipts.ts
1737
1795
  var import_configs3 = require("@fuel-ts/address/configs");
1738
- var import_errors6 = require("@fuel-ts/errors");
1796
+ var import_errors7 = require("@fuel-ts/errors");
1739
1797
  var import_math5 = require("@fuel-ts/math");
1740
1798
  var import_transactions3 = require("@fuel-ts/transactions");
1741
1799
  var import_configs4 = require("@fuel-ts/transactions/configs");
@@ -1766,7 +1824,6 @@ function assembleReceiptByType(receipt) {
1766
1824
  const callReceipt = {
1767
1825
  type: import_transactions3.ReceiptType.Call,
1768
1826
  id,
1769
- from: id,
1770
1827
  to: hexOrZero(receipt?.to),
1771
1828
  amount: (0, import_math5.bn)(receipt.amount),
1772
1829
  assetId: hexOrZero(receipt.assetId),
@@ -1834,10 +1891,6 @@ function assembleReceiptByType(receipt) {
1834
1891
  rb,
1835
1892
  rc,
1836
1893
  rd,
1837
- val0: ra,
1838
- val1: rb,
1839
- val2: rc,
1840
- val3: rd,
1841
1894
  pc: (0, import_math5.bn)(receipt.pc),
1842
1895
  is: (0, import_math5.bn)(receipt.is)
1843
1896
  };
@@ -1851,8 +1904,6 @@ function assembleReceiptByType(receipt) {
1851
1904
  id: hexOrZero(receipt.id || receipt.contractId),
1852
1905
  ra,
1853
1906
  rb,
1854
- val0: ra,
1855
- val1: rb,
1856
1907
  ptr: (0, import_math5.bn)(receipt.ptr),
1857
1908
  len: (0, import_math5.bn)(receipt.len),
1858
1909
  digest: hexOrZero(receipt.digest),
@@ -1867,7 +1918,6 @@ function assembleReceiptByType(receipt) {
1867
1918
  const transferReceipt = {
1868
1919
  type: import_transactions3.ReceiptType.Transfer,
1869
1920
  id,
1870
- from: id,
1871
1921
  to: hexOrZero(receipt.toAddress || receipt?.to),
1872
1922
  amount: (0, import_math5.bn)(receipt.amount),
1873
1923
  assetId: hexOrZero(receipt.assetId),
@@ -1881,7 +1931,6 @@ function assembleReceiptByType(receipt) {
1881
1931
  const transferOutReceipt = {
1882
1932
  type: import_transactions3.ReceiptType.TransferOut,
1883
1933
  id,
1884
- from: id,
1885
1934
  to: hexOrZero(receipt.toAddress || receipt.to),
1886
1935
  amount: (0, import_math5.bn)(receipt.amount),
1887
1936
  assetId: hexOrZero(receipt.assetId),
@@ -1957,12 +2006,12 @@ function assembleReceiptByType(receipt) {
1957
2006
  return burnReceipt;
1958
2007
  }
1959
2008
  default:
1960
- throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2009
+ throw new import_errors7.FuelError(import_errors7.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
1961
2010
  }
1962
2011
  }
1963
2012
 
1964
2013
  // src/providers/utils/block-explorer.ts
1965
- var import_errors7 = require("@fuel-ts/errors");
2014
+ var import_errors8 = require("@fuel-ts/errors");
1966
2015
 
1967
2016
  // src/providers/utils/gas.ts
1968
2017
  var import_math6 = require("@fuel-ts/math");
@@ -2134,7 +2183,7 @@ function normalizeJSON(root) {
2134
2183
  }
2135
2184
 
2136
2185
  // src/providers/utils/extract-tx-error.ts
2137
- var import_errors8 = require("@fuel-ts/errors");
2186
+ var import_errors9 = require("@fuel-ts/errors");
2138
2187
  var import_math7 = require("@fuel-ts/math");
2139
2188
  var import_transactions5 = require("@fuel-ts/transactions");
2140
2189
  var import_configs5 = require("@fuel-ts/transactions/configs");
@@ -2147,7 +2196,7 @@ You can read more about this error at:
2147
2196
 
2148
2197
  ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2149
2198
  }
2150
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2199
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2151
2200
  ...metadata,
2152
2201
  reason: statusReason
2153
2202
  });
@@ -2188,8 +2237,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2188
2237
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
2189
2238
  break;
2190
2239
  default:
2191
- throw new import_errors8.FuelError(
2192
- import_errors8.ErrorCode.UNKNOWN,
2240
+ throw new import_errors9.FuelError(
2241
+ import_errors9.ErrorCode.UNKNOWN,
2193
2242
  `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
2194
2243
  {
2195
2244
  ...metadata,
@@ -2198,7 +2247,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
2198
2247
  );
2199
2248
  }
2200
2249
  }
2201
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2250
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2202
2251
  ...metadata,
2203
2252
  reason
2204
2253
  });
@@ -2231,6 +2280,7 @@ var NoWitnessAtIndexError = class extends Error {
2231
2280
  };
2232
2281
 
2233
2282
  // src/providers/transaction-request/helpers.ts
2283
+ var import_errors10 = require("@fuel-ts/errors");
2234
2284
  var import_math8 = require("@fuel-ts/math");
2235
2285
  var import_transactions6 = require("@fuel-ts/transactions");
2236
2286
  var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
@@ -2263,6 +2313,32 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
2263
2313
  messages: []
2264
2314
  }
2265
2315
  );
2316
+ var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
2317
+ const { inputs, outputs } = transactionRequest;
2318
+ const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
2319
+ if (inputs.some((i) => isRequestInputMessage(i) && (0, import_math8.bn)(i.amount).gt(0))) {
2320
+ coinInputs.add(baseAssetId);
2321
+ }
2322
+ const changeOutputs = new Set(
2323
+ outputs.filter((output) => output.type === import_transactions6.OutputType.Change).map((output) => output.assetId)
2324
+ );
2325
+ const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
2326
+ return difference.size;
2327
+ };
2328
+ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
2329
+ if (enableAssetBurn === true) {
2330
+ return;
2331
+ }
2332
+ if (getBurnableAssetCount(baseAssetId, transactionRequest) <= 0) {
2333
+ return;
2334
+ }
2335
+ const message = [
2336
+ "Asset burn detected.",
2337
+ "Add the relevant change outputs to the transaction to avoid burning assets.",
2338
+ "Or enable asset burn, upon sending the transaction."
2339
+ ].join("\n");
2340
+ throw new import_errors10.FuelError(import_errors10.ErrorCode.ASSET_BURN_DETECTED, message);
2341
+ };
2266
2342
 
2267
2343
  // src/providers/transaction-request/witness.ts
2268
2344
  var import_utils10 = require("@fuel-ts/utils");
@@ -2412,7 +2488,7 @@ var BaseTransactionRequest = class {
2412
2488
  * @param signature - The signature to update the witness with.
2413
2489
  */
2414
2490
  updateWitnessByOwner(address, signature) {
2415
- const ownerAddress = import_address2.Address.fromAddressOrString(address);
2491
+ const ownerAddress = new import_address2.Address(address);
2416
2492
  const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress);
2417
2493
  if (typeof witnessIndex === "number") {
2418
2494
  this.updateWitness(witnessIndex, signature);
@@ -2646,7 +2722,7 @@ var BaseTransactionRequest = class {
2646
2722
  * @hidden
2647
2723
  */
2648
2724
  metadataGas(_gasCosts) {
2649
- throw new import_errors9.FuelError(import_errors9.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
2725
+ throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
2650
2726
  }
2651
2727
  /**
2652
2728
  * @hidden
@@ -2763,7 +2839,7 @@ var BaseTransactionRequest = class {
2763
2839
  this.inputs.filter(isRequestInputResource).forEach((i) => {
2764
2840
  const owner = getRequestInputResourceOwner(i);
2765
2841
  const correspondingInput = inputsToExtractGasUsed.find(
2766
- (x) => isRequestInputResourceFromOwner(x, import_address2.Address.fromString(String(owner)))
2842
+ (x) => isRequestInputResourceFromOwner(x, new import_address2.Address(String(owner)))
2767
2843
  );
2768
2844
  if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math9.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2769
2845
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -3086,6 +3162,20 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3086
3162
  this.scriptData = (0, import_utils18.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
3087
3163
  this.abis = rest.abis;
3088
3164
  }
3165
+ /**
3166
+ * Helper function to estimate and fund the transaction request with a specified account.
3167
+ *
3168
+ * @param account - The account to fund the transaction.
3169
+ * @param params - The parameters for the transaction cost.
3170
+ * @returns The current instance of the `ScriptTransactionRequest` funded.
3171
+ */
3172
+ async estimateAndFund(account, { signatureCallback, quantities = [] } = {}) {
3173
+ const txCost = await account.getTransactionCost(this, { signatureCallback, quantities });
3174
+ this.maxFee = txCost.maxFee;
3175
+ this.gasLimit = txCost.gasUsed;
3176
+ await account.fund(this, txCost);
3177
+ return this;
3178
+ }
3089
3179
  /**
3090
3180
  * Converts the transaction request to a `TransactionScript`.
3091
3181
  *
@@ -3240,7 +3330,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3240
3330
  };
3241
3331
 
3242
3332
  // src/providers/transaction-request/upgrade-transaction-request.ts
3243
- var import_errors11 = require("@fuel-ts/errors");
3333
+ var import_errors13 = require("@fuel-ts/errors");
3244
3334
  var import_hasher3 = require("@fuel-ts/hasher");
3245
3335
  var import_transactions11 = require("@fuel-ts/transactions");
3246
3336
  var import_utils19 = require("@fuel-ts/utils");
@@ -3344,7 +3434,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3344
3434
  }
3345
3435
  };
3346
3436
  } else {
3347
- throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3437
+ throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3348
3438
  }
3349
3439
  return {
3350
3440
  type: import_transactions11.TransactionType.Upgrade,
@@ -3386,7 +3476,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3386
3476
  txBytesSize
3387
3477
  });
3388
3478
  }
3389
- throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3479
+ throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3390
3480
  }
3391
3481
  };
3392
3482
 
@@ -3497,7 +3587,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3497
3587
  };
3498
3588
 
3499
3589
  // src/providers/transaction-request/utils.ts
3500
- var import_errors12 = require("@fuel-ts/errors");
3590
+ var import_errors14 = require("@fuel-ts/errors");
3501
3591
  var import_transactions13 = require("@fuel-ts/transactions");
3502
3592
  var transactionRequestify = (obj) => {
3503
3593
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
@@ -3521,8 +3611,8 @@ var transactionRequestify = (obj) => {
3521
3611
  return UploadTransactionRequest.from(obj);
3522
3612
  }
3523
3613
  default: {
3524
- throw new import_errors12.FuelError(
3525
- import_errors12.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3614
+ throw new import_errors14.FuelError(
3615
+ import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3526
3616
  `Unsupported transaction type: ${type}.`
3527
3617
  );
3528
3618
  }
@@ -3532,7 +3622,7 @@ var isTransactionTypeScript = (request) => request.type === import_transactions1
3532
3622
  var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
3533
3623
 
3534
3624
  // src/providers/transaction-response/transaction-response.ts
3535
- var import_errors16 = require("@fuel-ts/errors");
3625
+ var import_errors18 = require("@fuel-ts/errors");
3536
3626
  var import_math18 = require("@fuel-ts/math");
3537
3627
  var import_transactions21 = require("@fuel-ts/transactions");
3538
3628
  var import_utils27 = require("@fuel-ts/utils");
@@ -3551,12 +3641,8 @@ var calculateTXFeeForSummary = (params) => {
3551
3641
  gasPrice,
3552
3642
  rawPayload,
3553
3643
  tip,
3554
- totalFee,
3555
3644
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
3556
3645
  } = params;
3557
- if (totalFee) {
3558
- return totalFee;
3559
- }
3560
3646
  const gasPerByte = (0, import_math13.bn)(feeParams.gasPerByte);
3561
3647
  const gasPriceFactor = (0, import_math13.bn)(feeParams.gasPriceFactor);
3562
3648
  const transactionBytes = (0, import_utils23.arrayify)(rawPayload);
@@ -3614,7 +3700,7 @@ var calculateTXFeeForSummary = (params) => {
3614
3700
 
3615
3701
  // src/providers/transaction-summary/operations.ts
3616
3702
  var import_configs11 = require("@fuel-ts/address/configs");
3617
- var import_errors14 = require("@fuel-ts/errors");
3703
+ var import_errors16 = require("@fuel-ts/errors");
3618
3704
  var import_math15 = require("@fuel-ts/math");
3619
3705
  var import_transactions17 = require("@fuel-ts/transactions");
3620
3706
 
@@ -3652,7 +3738,7 @@ var getFunctionCall = ({ abi, receipt }) => {
3652
3738
  };
3653
3739
 
3654
3740
  // src/providers/transaction-summary/input.ts
3655
- var import_errors13 = require("@fuel-ts/errors");
3741
+ var import_errors15 = require("@fuel-ts/errors");
3656
3742
  var import_math14 = require("@fuel-ts/math");
3657
3743
  var import_transactions15 = require("@fuel-ts/transactions");
3658
3744
  function getInputsByTypes(inputs, types) {
@@ -3680,10 +3766,10 @@ function findCoinInput(inputs, assetId) {
3680
3766
  const coinInputs = getInputsCoin(inputs);
3681
3767
  return coinInputs.find((i) => i.assetId === assetId);
3682
3768
  }
3683
- function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
3769
+ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
3684
3770
  const aggregated = /* @__PURE__ */ new Map();
3685
3771
  getInputsCoinAndMessage(inputs).forEach((input) => {
3686
- const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
3772
+ const assetId = isInputCoin(input) ? input.assetId : baseAssetId;
3687
3773
  const owner = isInputCoin(input) ? input.owner : input.recipient;
3688
3774
  let ownersMap = aggregated.get(assetId);
3689
3775
  if (!ownersMap) {
@@ -3721,8 +3807,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
3721
3807
  return void 0;
3722
3808
  }
3723
3809
  if (contractInput.type !== import_transactions15.InputType.Contract) {
3724
- throw new import_errors13.FuelError(
3725
- import_errors13.ErrorCode.INVALID_TRANSACTION_INPUT,
3810
+ throw new import_errors15.FuelError(
3811
+ import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
3726
3812
  `Contract input should be of type 'contract'.`
3727
3813
  );
3728
3814
  }
@@ -3775,8 +3861,8 @@ function getTransactionTypeName(transactionType) {
3775
3861
  case import_transactions17.TransactionType.Upload:
3776
3862
  return "Upload" /* Upload */;
3777
3863
  default:
3778
- throw new import_errors14.FuelError(
3779
- import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3864
+ throw new import_errors16.FuelError(
3865
+ import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3780
3866
  `Unsupported transaction type: ${transactionType}.`
3781
3867
  );
3782
3868
  }
@@ -3969,7 +4055,7 @@ function getContractCallOperations({
3969
4055
  }
3970
4056
  function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
3971
4057
  const { to: toAddress, assetId, amount } = receipt;
3972
- let { from: fromAddress } = receipt;
4058
+ let { id: fromAddress } = receipt;
3973
4059
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3974
4060
  if (import_configs11.ZeroBytes32 === fromAddress) {
3975
4061
  const change = changeOutputs.find((output) => output.assetId === assetId);
@@ -4156,7 +4242,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
4156
4242
  };
4157
4243
 
4158
4244
  // src/providers/transaction-summary/status.ts
4159
- var import_errors15 = require("@fuel-ts/errors");
4245
+ var import_errors17 = require("@fuel-ts/errors");
4160
4246
  var import_math16 = require("@fuel-ts/math");
4161
4247
  var getTransactionStatusName = (gqlStatus) => {
4162
4248
  switch (gqlStatus) {
@@ -4169,8 +4255,8 @@ var getTransactionStatusName = (gqlStatus) => {
4169
4255
  case "SqueezedOutStatus":
4170
4256
  return "squeezedout" /* squeezedout */;
4171
4257
  default:
4172
- throw new import_errors15.FuelError(
4173
- import_errors15.ErrorCode.INVALID_TRANSACTION_STATUS,
4258
+ throw new import_errors17.FuelError(
4259
+ import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
4174
4260
  `Invalid transaction status: ${gqlStatus}.`
4175
4261
  );
4176
4262
  }
@@ -4220,6 +4306,7 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4220
4306
  };
4221
4307
  return processedGraphqlStatus;
4222
4308
  };
4309
+ var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? (0, import_math16.bn)(status.totalFee) : void 0;
4223
4310
 
4224
4311
  // src/providers/transaction-summary/assemble-transaction-summary.ts
4225
4312
  function assembleTransactionSummary(params) {
@@ -4253,8 +4340,7 @@ function assembleTransactionSummary(params) {
4253
4340
  const typeName = getTransactionTypeName(transaction.type);
4254
4341
  const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
4255
4342
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
4256
- const fee = calculateTXFeeForSummary({
4257
- totalFee,
4343
+ const fee = totalFee ?? calculateTXFeeForSummary({
4258
4344
  gasPrice,
4259
4345
  rawPayload,
4260
4346
  tip,
@@ -4308,8 +4394,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4308
4394
  return receipts.reduce((logs, receipt) => {
4309
4395
  if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
4310
4396
  const interfaceToUse = new import_abi_coder6.Interface(externalAbis[receipt.id] || mainAbi);
4311
- const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
4312
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
4397
+ const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4398
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4313
4399
  logs.push(decodedLog);
4314
4400
  }
4315
4401
  return logs;
@@ -4354,12 +4440,13 @@ var TransactionResponse = class {
4354
4440
  * @param tx - The transaction ID or TransactionRequest.
4355
4441
  * @param provider - The provider.
4356
4442
  */
4357
- constructor(tx, provider, abis, submitTxSubscription) {
4443
+ constructor(tx, provider, chainId, abis, submitTxSubscription) {
4358
4444
  this.submitTxSubscription = submitTxSubscription;
4359
- this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
4445
+ this.id = typeof tx === "string" ? tx : tx.getTransactionId(chainId);
4360
4446
  this.provider = provider;
4361
4447
  this.abis = abis;
4362
4448
  this.request = typeof tx === "string" ? void 0 : tx;
4449
+ this.waitForResult = this.waitForResult.bind(this);
4363
4450
  }
4364
4451
  /** Transaction ID */
4365
4452
  id;
@@ -4381,7 +4468,8 @@ var TransactionResponse = class {
4381
4468
  * @param provider - The provider.
4382
4469
  */
4383
4470
  static async create(id, provider, abis) {
4384
- const response = new TransactionResponse(id, provider, abis);
4471
+ const chainId = await provider.getChainId();
4472
+ const response = new TransactionResponse(id, provider, chainId, abis);
4385
4473
  await response.fetch();
4386
4474
  return response;
4387
4475
  }
@@ -4478,10 +4566,11 @@ var TransactionResponse = class {
4478
4566
  */
4479
4567
  async getTransactionSummary(contractsAbiMap) {
4480
4568
  const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
4481
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
4482
- const gasPrice = await this.provider.getLatestGasPrice();
4483
- const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
4484
- const baseAssetId = this.provider.getBaseAssetId();
4569
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig();
4570
+ const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status);
4571
+ const gasPrice = totalFee ? (0, import_math18.bn)(0) : await this.provider.getLatestGasPrice();
4572
+ const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs;
4573
+ const baseAssetId = await this.provider.getBaseAssetId();
4485
4574
  const transactionSummary = assembleTransactionSummary({
4486
4575
  id: this.id,
4487
4576
  receipts: this.getReceipts(),
@@ -4512,8 +4601,8 @@ var TransactionResponse = class {
4512
4601
  this.status = statusChange;
4513
4602
  if (statusChange.type === "SqueezedOutStatus") {
4514
4603
  this.unsetResourceCache();
4515
- throw new import_errors16.FuelError(
4516
- import_errors16.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4604
+ throw new import_errors18.FuelError(
4605
+ import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4517
4606
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4518
4607
  );
4519
4608
  }
@@ -4620,55 +4709,32 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4620
4709
  };
4621
4710
  }
4622
4711
 
4623
- // src/providers/utils/handle-gql-error-message.ts
4624
- var import_errors17 = require("@fuel-ts/errors");
4625
- var handleGqlErrorMessage = (errorMessage, rawError) => {
4626
- switch (errorMessage) {
4627
- case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4628
- throw new import_errors17.FuelError(
4629
- import_errors17.ErrorCode.NOT_ENOUGH_FUNDS,
4630
- `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4631
- {},
4632
- rawError
4633
- );
4634
- case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4635
- throw new import_errors17.FuelError(
4636
- import_errors17.ErrorCode.MAX_COINS_REACHED,
4637
- "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4638
- {},
4639
- rawError
4640
- );
4641
- default:
4642
- throw new import_errors17.FuelError(import_errors17.ErrorCode.INVALID_REQUEST, errorMessage);
4643
- }
4644
- };
4645
-
4646
4712
  // src/providers/utils/validate-pagination-args.ts
4647
- var import_errors18 = require("@fuel-ts/errors");
4713
+ var import_errors19 = require("@fuel-ts/errors");
4648
4714
  var validatePaginationArgs = (params) => {
4649
4715
  const { paginationLimit, inputArgs = {} } = params;
4650
4716
  const { first, last, after, before } = inputArgs;
4651
4717
  if (after && before) {
4652
- throw new import_errors18.FuelError(
4653
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
4718
+ throw new import_errors19.FuelError(
4719
+ import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4654
4720
  'Pagination arguments "after" and "before" cannot be used together'
4655
4721
  );
4656
4722
  }
4657
4723
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4658
- throw new import_errors18.FuelError(
4659
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
4724
+ throw new import_errors19.FuelError(
4725
+ import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4660
4726
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
4661
4727
  );
4662
4728
  }
4663
4729
  if (first && before) {
4664
- throw new import_errors18.FuelError(
4665
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
4730
+ throw new import_errors19.FuelError(
4731
+ import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4666
4732
  'The use of pagination argument "first" with "before" is not supported'
4667
4733
  );
4668
4734
  }
4669
4735
  if (last && after) {
4670
- throw new import_errors18.FuelError(
4671
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
4736
+ throw new import_errors19.FuelError(
4737
+ import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4672
4738
  'The use of pagination argument "last" with "after" is not supported'
4673
4739
  );
4674
4740
  }
@@ -4822,7 +4888,7 @@ var _Provider = class {
4822
4888
  try {
4823
4889
  parsedUrl = new URL(url);
4824
4890
  } catch (error) {
4825
- throw new import_errors19.FuelError(import_errors19.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4891
+ throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4826
4892
  }
4827
4893
  const username = parsedUrl.username;
4828
4894
  const password = parsedUrl.password;
@@ -4837,58 +4903,40 @@ var _Provider = class {
4837
4903
  };
4838
4904
  }
4839
4905
  /**
4840
- * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4841
- *
4842
- * @param url - GraphQL endpoint of the Fuel node
4843
- * @param options - Additional options for the provider
4844
- *
4845
- * @returns A promise that resolves to a Provider instance.
4906
+ * Initialize Provider async stuff
4846
4907
  */
4847
- static async create(url, options = {}) {
4848
- const provider = new _Provider(url, options);
4849
- await provider.fetchChainAndNodeInfo();
4850
- return provider;
4908
+ async init() {
4909
+ await this.fetchChainAndNodeInfo();
4910
+ return this;
4851
4911
  }
4852
4912
  /**
4853
- * Returns the cached chainInfo for the current URL.
4913
+ * Returns the `chainInfo` for the current network.
4854
4914
  *
4855
4915
  * @returns the chain information configuration.
4856
4916
  */
4857
- getChain() {
4858
- const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4859
- if (!chain) {
4860
- throw new import_errors19.FuelError(
4861
- import_errors19.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
4862
- "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4863
- );
4864
- }
4865
- return chain;
4917
+ async getChain() {
4918
+ await this.init();
4919
+ return _Provider.chainInfoCache[this.urlWithoutAuth];
4866
4920
  }
4867
4921
  /**
4868
- * Returns the cached nodeInfo for the current URL.
4922
+ * Returns the `nodeInfo` for the current network.
4869
4923
  *
4870
4924
  * @returns the node information configuration.
4871
4925
  */
4872
- getNode() {
4873
- const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4874
- if (!node) {
4875
- throw new import_errors19.FuelError(
4876
- import_errors19.ErrorCode.NODE_INFO_CACHE_EMPTY,
4877
- "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4878
- );
4879
- }
4880
- return node;
4926
+ async getNode() {
4927
+ await this.init();
4928
+ return _Provider.nodeInfoCache[this.urlWithoutAuth];
4881
4929
  }
4882
4930
  /**
4883
4931
  * Returns some helpful parameters related to gas fees.
4884
4932
  */
4885
- getGasConfig() {
4933
+ async getGasConfig() {
4886
4934
  const {
4887
4935
  txParameters: { maxGasPerTx },
4888
4936
  predicateParameters: { maxGasPerPredicate },
4889
4937
  feeParameters: { gasPriceFactor, gasPerByte },
4890
4938
  gasCosts
4891
- } = this.getChain().consensusParameters;
4939
+ } = (await this.getChain()).consensusParameters;
4892
4940
  return {
4893
4941
  maxGasPerTx,
4894
4942
  maxGasPerPredicate,
@@ -4910,7 +4958,7 @@ var _Provider = class {
4910
4958
  this.options = options ?? this.options;
4911
4959
  this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
4912
4960
  this.operations = this.createOperations();
4913
- await this.fetchChainAndNodeInfo();
4961
+ await this.init();
4914
4962
  }
4915
4963
  /**
4916
4964
  * Return the chain and node information.
@@ -4921,11 +4969,12 @@ var _Provider = class {
4921
4969
  let nodeInfo;
4922
4970
  let chain;
4923
4971
  try {
4924
- if (ignoreCache) {
4925
- throw new Error(`Jumps to the catch block andre-fetch`);
4972
+ nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
4973
+ chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4974
+ const noCache = !nodeInfo || !chain;
4975
+ if (ignoreCache || noCache) {
4976
+ throw new Error(`Jumps to the catch block and re-fetch`);
4926
4977
  }
4927
- nodeInfo = this.getNode();
4928
- chain = this.getChain();
4929
4978
  } catch (_err) {
4930
4979
  const data = await this.operations.getChainAndNodeInfo();
4931
4980
  nodeInfo = {
@@ -4935,7 +4984,7 @@ var _Provider = class {
4935
4984
  utxoValidation: data.nodeInfo.utxoValidation,
4936
4985
  vmBacktrace: data.nodeInfo.vmBacktrace
4937
4986
  };
4938
- _Provider.ensureClientVersionIsSupported(nodeInfo);
4987
+ _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
4939
4988
  chain = processGqlChain(data.chain);
4940
4989
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
4941
4990
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
@@ -4949,15 +4998,15 @@ var _Provider = class {
4949
4998
  /**
4950
4999
  * @hidden
4951
5000
  */
4952
- static ensureClientVersionIsSupported(nodeInfo) {
5001
+ static setIncompatibleNodeVersionMessage(nodeInfo) {
4953
5002
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
4954
5003
  if (!isMajorSupported || !isMinorSupported) {
4955
- console.warn(
4956
- `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
4957
- which is not supported by the version of the TS SDK that you are using.
4958
- Things may not work as expected.
4959
- Supported fuel-core version: ${supportedVersion}.`
4960
- );
5004
+ _Provider.incompatibleNodeVersionMessage = [
5005
+ `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}.`,
5006
+ `The TS SDK currently supports fuel-core version ${supportedVersion}.`,
5007
+ `Things may not work as expected.`
5008
+ ].join("\n");
5009
+ FuelGraphqlSubscriber.incompatibleNodeVersionMessage = _Provider.incompatibleNodeVersionMessage;
4961
5010
  }
4962
5011
  }
4963
5012
  /**
@@ -4973,11 +5022,10 @@ Supported fuel-core version: ${supportedVersion}.`
4973
5022
  responseMiddleware: (response) => {
4974
5023
  if ("response" in response) {
4975
5024
  const graphQlResponse = response.response;
4976
- if (Array.isArray(graphQlResponse?.errors)) {
4977
- for (const error of graphQlResponse.errors) {
4978
- handleGqlErrorMessage(error.message, error);
4979
- }
4980
- }
5025
+ assertGqlResponseHasNoErrors(
5026
+ graphQlResponse.errors,
5027
+ _Provider.incompatibleNodeVersionMessage
5028
+ );
4981
5029
  }
4982
5030
  }
4983
5031
  });
@@ -5072,10 +5120,10 @@ Supported fuel-core version: ${supportedVersion}.`
5072
5120
  *
5073
5121
  * @returns A promise that resolves to the chain ID number.
5074
5122
  */
5075
- getChainId() {
5123
+ async getChainId() {
5076
5124
  const {
5077
5125
  consensusParameters: { chainId }
5078
- } = this.getChain();
5126
+ } = await this.getChain();
5079
5127
  return chainId.toNumber();
5080
5128
  }
5081
5129
  /**
@@ -5083,30 +5131,31 @@ Supported fuel-core version: ${supportedVersion}.`
5083
5131
  *
5084
5132
  * @returns the base asset ID.
5085
5133
  */
5086
- getBaseAssetId() {
5134
+ async getBaseAssetId() {
5135
+ const all = await this.getChain();
5087
5136
  const {
5088
5137
  consensusParameters: { baseAssetId }
5089
- } = this.getChain();
5138
+ } = all;
5090
5139
  return baseAssetId;
5091
5140
  }
5092
5141
  /**
5093
5142
  * @hidden
5094
5143
  */
5095
- validateTransaction(tx) {
5144
+ async validateTransaction(tx) {
5096
5145
  const {
5097
5146
  consensusParameters: {
5098
5147
  txParameters: { maxInputs, maxOutputs }
5099
5148
  }
5100
- } = this.getChain();
5149
+ } = await this.getChain();
5101
5150
  if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
5102
- throw new import_errors19.FuelError(
5103
- import_errors19.ErrorCode.MAX_INPUTS_EXCEEDED,
5151
+ throw new import_errors20.FuelError(
5152
+ import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
5104
5153
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
5105
5154
  );
5106
5155
  }
5107
5156
  if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
5108
- throw new import_errors19.FuelError(
5109
- import_errors19.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5157
+ throw new import_errors20.FuelError(
5158
+ import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5110
5159
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
5111
5160
  );
5112
5161
  }
@@ -5121,20 +5170,26 @@ Supported fuel-core version: ${supportedVersion}.`
5121
5170
  * @param sendTransactionParams - The provider send transaction parameters (optional).
5122
5171
  * @returns A promise that resolves to the transaction response object.
5123
5172
  */
5124
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
5173
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, enableAssetBurn } = {}) {
5125
5174
  const transactionRequest = transactionRequestify(transactionRequestLike);
5175
+ validateTransactionForAssetBurn(
5176
+ await this.getBaseAssetId(),
5177
+ transactionRequest,
5178
+ enableAssetBurn
5179
+ );
5126
5180
  if (estimateTxDependencies) {
5127
5181
  await this.estimateTxDependencies(transactionRequest);
5128
5182
  }
5129
- this.validateTransaction(transactionRequest);
5183
+ await this.validateTransaction(transactionRequest);
5130
5184
  const encodedTransaction = (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes());
5131
5185
  let abis;
5132
5186
  if (isTransactionTypeScript(transactionRequest)) {
5133
5187
  abis = transactionRequest.abis;
5134
5188
  }
5135
5189
  const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
5136
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
5137
- return new TransactionResponse(transactionRequest, this, abis, subscription);
5190
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
5191
+ const chainId = await this.getChainId();
5192
+ return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
5138
5193
  }
5139
5194
  /**
5140
5195
  * Executes a transaction without actually submitting it to the chain.
@@ -5200,9 +5255,10 @@ Supported fuel-core version: ${supportedVersion}.`
5200
5255
  * `addVariableOutputs` is called on the transaction.
5201
5256
  *
5202
5257
  * @param transactionRequest - The transaction request object.
5258
+ * @param gasPrice - The gas price to use for the transaction, if not provided it will be fetched.
5203
5259
  * @returns A promise that resolves to the estimate transaction dependencies.
5204
5260
  */
5205
- async estimateTxDependencies(transactionRequest) {
5261
+ async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
5206
5262
  if (isTransactionTypeCreate(transactionRequest)) {
5207
5263
  return {
5208
5264
  receipts: [],
@@ -5214,14 +5270,15 @@ Supported fuel-core version: ${supportedVersion}.`
5214
5270
  const missingContractIds = [];
5215
5271
  let outputVariables = 0;
5216
5272
  let dryRunStatus;
5217
- this.validateTransaction(transactionRequest);
5273
+ await this.validateTransaction(transactionRequest);
5274
+ const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
5218
5275
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5219
5276
  const {
5220
5277
  dryRun: [{ receipts: rawReceipts, status }]
5221
5278
  } = await this.operations.dryRun({
5222
5279
  encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
5223
5280
  utxoValidation: false,
5224
- gasPrice: "0"
5281
+ gasPrice: gasPrice.toString()
5225
5282
  });
5226
5283
  receipts = rawReceipts.map(processGqlReceipt);
5227
5284
  dryRunStatus = status;
@@ -5231,12 +5288,12 @@ Supported fuel-core version: ${supportedVersion}.`
5231
5288
  outputVariables += missingOutputVariables.length;
5232
5289
  transactionRequest.addVariableOutputs(missingOutputVariables.length);
5233
5290
  missingOutputContractIds.forEach(({ contractId }) => {
5234
- transactionRequest.addContractInputAndOutput(import_address4.Address.fromString(contractId));
5291
+ transactionRequest.addContractInputAndOutput(new import_address4.Address(contractId));
5235
5292
  missingContractIds.push(contractId);
5236
5293
  });
5237
5294
  const { maxFee } = await this.estimateTxGasAndFee({
5238
5295
  transactionRequest,
5239
- gasPrice: (0, import_math19.bn)(0)
5296
+ gasPrice
5240
5297
  });
5241
5298
  transactionRequest.maxFee = maxFee;
5242
5299
  } else {
@@ -5300,7 +5357,7 @@ Supported fuel-core version: ${supportedVersion}.`
5300
5357
  result.outputVariables += missingOutputVariables.length;
5301
5358
  request.addVariableOutputs(missingOutputVariables.length);
5302
5359
  missingOutputContractIds.forEach(({ contractId }) => {
5303
- request.addContractInputAndOutput(import_address4.Address.fromString(contractId));
5360
+ request.addContractInputAndOutput(new import_address4.Address(contractId));
5304
5361
  result.missingContractIds.push(contractId);
5305
5362
  });
5306
5363
  const { maxFee } = await this.estimateTxGasAndFee({
@@ -5345,7 +5402,11 @@ Supported fuel-core version: ${supportedVersion}.`
5345
5402
  if (diff < 6e4) {
5346
5403
  return;
5347
5404
  }
5348
- const chainInfo = this.getChain();
5405
+ if (!_Provider.chainInfoCache?.[this.urlWithoutAuth]) {
5406
+ await this.fetchChainAndNodeInfo(true);
5407
+ return;
5408
+ }
5409
+ const chainInfo = _Provider.chainInfoCache[this.urlWithoutAuth];
5349
5410
  const {
5350
5411
  consensusParameters: { version: previous }
5351
5412
  } = chainInfo;
@@ -5362,15 +5423,15 @@ Supported fuel-core version: ${supportedVersion}.`
5362
5423
  }
5363
5424
  /**
5364
5425
  * Estimates the transaction gas and fee based on the provided transaction request.
5365
- * @param transactionRequest - The transaction request object.
5426
+ * @param params - The parameters for estimating the transaction gas and fee.
5366
5427
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
5367
5428
  */
5368
5429
  async estimateTxGasAndFee(params) {
5369
- const { transactionRequest } = params;
5370
- let { gasPrice } = params;
5430
+ const { transactionRequest, gasPrice: gasPriceParam } = params;
5431
+ let gasPrice = gasPriceParam;
5371
5432
  await this.autoRefetchConfigs();
5372
- const chainInfo = this.getChain();
5373
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5433
+ const chainInfo = await this.getChain();
5434
+ const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
5374
5435
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5375
5436
  if (!(0, import_utils30.isDefined)(gasPrice)) {
5376
5437
  gasPrice = await this.estimateGasPrice(10);
@@ -5448,7 +5509,7 @@ Supported fuel-core version: ${supportedVersion}.`
5448
5509
  *
5449
5510
  * @returns A promise that resolves to the transaction cost object.
5450
5511
  */
5451
- async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
5512
+ async getTransactionCost(transactionRequestLike, { signatureCallback, gasPrice: gasPriceParam } = {}) {
5452
5513
  const txRequestClone = (0, import_ramda8.clone)(transactionRequestify(transactionRequestLike));
5453
5514
  const updateMaxFee = txRequestClone.maxFee.eq(0);
5454
5515
  const isScriptTransaction = isTransactionTypeScript(txRequestClone);
@@ -5464,8 +5525,11 @@ Supported fuel-core version: ${supportedVersion}.`
5464
5525
  }
5465
5526
  await this.estimatePredicates(signedRequest);
5466
5527
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
5467
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
5468
- transactionRequest: signedRequest
5528
+ const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
5529
+ let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
5530
+ // Fetches and returns a gas price
5531
+ transactionRequest: signedRequest,
5532
+ gasPrice
5469
5533
  });
5470
5534
  let receipts = [];
5471
5535
  let dryRunStatus;
@@ -5478,15 +5542,15 @@ Supported fuel-core version: ${supportedVersion}.`
5478
5542
  if (signatureCallback) {
5479
5543
  await signatureCallback(txRequestClone);
5480
5544
  }
5481
- ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
5545
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
5482
5546
  if (dryRunStatus && "reason" in dryRunStatus) {
5483
5547
  throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
5484
5548
  }
5485
- const { maxGasPerTx } = this.getGasConfig();
5549
+ const { maxGasPerTx } = await this.getGasConfig();
5486
5550
  const pristineGasUsed = getGasUsedFromReceipts(receipts);
5487
5551
  gasUsed = (0, import_math19.bn)(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
5488
5552
  txRequestClone.gasLimit = gasUsed;
5489
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
5553
+ ({ maxFee, maxGas, minFee, minGas } = await this.estimateTxGasAndFee({
5490
5554
  transactionRequest: txRequestClone,
5491
5555
  gasPrice
5492
5556
  }));
@@ -5517,7 +5581,7 @@ Supported fuel-core version: ${supportedVersion}.`
5517
5581
  * @returns A promise that resolves to the coins.
5518
5582
  */
5519
5583
  async getCoins(owner, assetId, paginationArgs) {
5520
- const ownerAddress = import_address4.Address.fromAddressOrString(owner);
5584
+ const ownerAddress = new import_address4.Address(owner);
5521
5585
  const {
5522
5586
  coins: { edges, pageInfo }
5523
5587
  } = await this.operations.getCoins({
@@ -5549,7 +5613,7 @@ Supported fuel-core version: ${supportedVersion}.`
5549
5613
  * @returns A promise that resolves to the resources.
5550
5614
  */
5551
5615
  async getResourcesToSpend(owner, quantities, excludedIds) {
5552
- const ownerAddress = import_address4.Address.fromAddressOrString(owner);
5616
+ const ownerAddress = new import_address4.Address(owner);
5553
5617
  const excludeInput = {
5554
5618
  messages: excludedIds?.messages?.map((nonce) => (0, import_utils30.hexlify)(nonce)) || [],
5555
5619
  utxos: excludedIds?.utxos?.map((id) => (0, import_utils30.hexlify)(id)) || []
@@ -5576,8 +5640,8 @@ Supported fuel-core version: ${supportedVersion}.`
5576
5640
  amount: (0, import_math19.bn)(coin.amount),
5577
5641
  assetId: coin.assetId,
5578
5642
  daHeight: (0, import_math19.bn)(coin.daHeight),
5579
- sender: import_address4.Address.fromAddressOrString(coin.sender),
5580
- recipient: import_address4.Address.fromAddressOrString(coin.recipient),
5643
+ sender: new import_address4.Address(coin.sender),
5644
+ recipient: new import_address4.Address(coin.recipient),
5581
5645
  nonce: coin.nonce
5582
5646
  };
5583
5647
  case "Coin":
@@ -5739,7 +5803,7 @@ Supported fuel-core version: ${supportedVersion}.`
5739
5803
  0
5740
5804
  )?.[0];
5741
5805
  } catch (error) {
5742
- if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5806
+ if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5743
5807
  console.warn("Unsupported transaction type encountered");
5744
5808
  return null;
5745
5809
  }
@@ -5765,7 +5829,7 @@ Supported fuel-core version: ${supportedVersion}.`
5765
5829
  try {
5766
5830
  return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
5767
5831
  } catch (error) {
5768
- if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5832
+ if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5769
5833
  console.warn("Unsupported transaction type encountered");
5770
5834
  return null;
5771
5835
  }
@@ -5774,6 +5838,21 @@ Supported fuel-core version: ${supportedVersion}.`
5774
5838
  }).filter((tx) => tx !== null);
5775
5839
  return { transactions, pageInfo };
5776
5840
  }
5841
+ /**
5842
+ * Fetches a compressed block at the specified height.
5843
+ *
5844
+ * @param height - The height of the block to fetch.
5845
+ * @returns The compressed block if available, otherwise `null`.
5846
+ */
5847
+ async daCompressedBlock(height) {
5848
+ const { daCompressedBlock } = await this.operations.daCompressedBlock({
5849
+ height
5850
+ });
5851
+ if (!daCompressedBlock) {
5852
+ return null;
5853
+ }
5854
+ return daCompressedBlock;
5855
+ }
5777
5856
  /**
5778
5857
  * Get deployed contract with the given ID.
5779
5858
  *
@@ -5796,7 +5875,7 @@ Supported fuel-core version: ${supportedVersion}.`
5796
5875
  */
5797
5876
  async getContractBalance(contractId, assetId) {
5798
5877
  const { contractBalance } = await this.operations.getContractBalance({
5799
- contract: import_address4.Address.fromAddressOrString(contractId).toB256(),
5878
+ contract: new import_address4.Address(contractId).toB256(),
5800
5879
  asset: (0, import_utils30.hexlify)(assetId)
5801
5880
  });
5802
5881
  return (0, import_math19.bn)(contractBalance.amount, 10);
@@ -5810,7 +5889,7 @@ Supported fuel-core version: ${supportedVersion}.`
5810
5889
  */
5811
5890
  async getBalance(owner, assetId) {
5812
5891
  const { balance } = await this.operations.getBalance({
5813
- owner: import_address4.Address.fromAddressOrString(owner).toB256(),
5892
+ owner: new import_address4.Address(owner).toB256(),
5814
5893
  assetId: (0, import_utils30.hexlify)(assetId)
5815
5894
  });
5816
5895
  return (0, import_math19.bn)(balance.amount, 10);
@@ -5831,7 +5910,7 @@ Supported fuel-core version: ${supportedVersion}.`
5831
5910
  * but the current Fuel-Core implementation does not support pagination yet.
5832
5911
  */
5833
5912
  first: 1e4,
5834
- filter: { owner: import_address4.Address.fromAddressOrString(owner).toB256() }
5913
+ filter: { owner: new import_address4.Address(owner).toB256() }
5835
5914
  });
5836
5915
  const balances = edges.map(({ node }) => ({
5837
5916
  assetId: node.assetId,
@@ -5854,7 +5933,7 @@ Supported fuel-core version: ${supportedVersion}.`
5854
5933
  inputArgs: paginationArgs,
5855
5934
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5856
5935
  }),
5857
- owner: import_address4.Address.fromAddressOrString(address).toB256()
5936
+ owner: new import_address4.Address(address).toB256()
5858
5937
  });
5859
5938
  const messages = edges.map(({ node }) => ({
5860
5939
  messageId: import_transactions22.InputMessageCoder.getMessageId({
@@ -5864,8 +5943,8 @@ Supported fuel-core version: ${supportedVersion}.`
5864
5943
  amount: (0, import_math19.bn)(node.amount),
5865
5944
  data: node.data
5866
5945
  }),
5867
- sender: import_address4.Address.fromAddressOrString(node.sender),
5868
- recipient: import_address4.Address.fromAddressOrString(node.recipient),
5946
+ sender: new import_address4.Address(node.sender),
5947
+ recipient: new import_address4.Address(node.recipient),
5869
5948
  nonce: node.nonce,
5870
5949
  amount: (0, import_math19.bn)(node.amount),
5871
5950
  data: import_transactions22.InputMessageCoder.decodeData(node.data),
@@ -5891,8 +5970,8 @@ Supported fuel-core version: ${supportedVersion}.`
5891
5970
  nonce
5892
5971
  };
5893
5972
  if (commitBlockId && commitBlockHeight) {
5894
- throw new import_errors19.FuelError(
5895
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5973
+ throw new import_errors20.FuelError(
5974
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
5896
5975
  "commitBlockId and commitBlockHeight cannot be used together"
5897
5976
  );
5898
5977
  }
@@ -5963,8 +6042,8 @@ Supported fuel-core version: ${supportedVersion}.`
5963
6042
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
5964
6043
  stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
5965
6044
  },
5966
- sender: import_address4.Address.fromAddressOrString(sender),
5967
- recipient: import_address4.Address.fromAddressOrString(recipient),
6045
+ sender: new import_address4.Address(sender),
6046
+ recipient: new import_address4.Address(recipient),
5968
6047
  nonce,
5969
6048
  amount: (0, import_math19.bn)(amount),
5970
6049
  data
@@ -6055,9 +6134,9 @@ Supported fuel-core version: ${supportedVersion}.`
6055
6134
  * @param transactionId - The transaction ID to get the response for.
6056
6135
  * @returns A promise that resolves to the transaction response.
6057
6136
  */
6058
- // eslint-disable-next-line @typescript-eslint/require-await
6059
6137
  async getTransactionResponse(transactionId) {
6060
- return new TransactionResponse(transactionId, this);
6138
+ const chainId = await this.getChainId();
6139
+ return new TransactionResponse(transactionId, this, chainId);
6061
6140
  }
6062
6141
  /**
6063
6142
  * Returns Message for given nonce.
@@ -6078,8 +6157,8 @@ Supported fuel-core version: ${supportedVersion}.`
6078
6157
  amount: (0, import_math19.bn)(rawMessage.amount),
6079
6158
  data: rawMessage.data
6080
6159
  }),
6081
- sender: import_address4.Address.fromAddressOrString(rawMessage.sender),
6082
- recipient: import_address4.Address.fromAddressOrString(rawMessage.recipient),
6160
+ sender: new import_address4.Address(rawMessage.sender),
6161
+ recipient: new import_address4.Address(rawMessage.recipient),
6083
6162
  nonce,
6084
6163
  amount: (0, import_math19.bn)(rawMessage.amount),
6085
6164
  data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
@@ -6145,620 +6224,18 @@ cacheInputs_fn = function(inputs, transactionId) {
6145
6224
  __publicField(Provider, "chainInfoCache", {});
6146
6225
  /** @hidden */
6147
6226
  __publicField(Provider, "nodeInfoCache", {});
6227
+ /** @hidden */
6228
+ __publicField(Provider, "incompatibleNodeVersionMessage", "");
6148
6229
 
6149
6230
  // src/providers/transaction-summary/get-transaction-summary.ts
6150
- var import_errors20 = require("@fuel-ts/errors");
6231
+ var import_errors21 = require("@fuel-ts/errors");
6151
6232
  var import_math20 = require("@fuel-ts/math");
6152
6233
  var import_transactions23 = require("@fuel-ts/transactions");
6153
6234
  var import_utils33 = require("@fuel-ts/utils");
6154
6235
 
6155
- // src/providers/chains.ts
6156
- var CHAIN_IDS = {
6157
- eth: {
6158
- mainnet: 1,
6159
- sepolia: 11155111,
6160
- foundry: 31337
6161
- },
6162
- fuel: {
6163
- devnet: 0,
6164
- testnet: 0,
6165
- mainnet: 9889
6166
- }
6167
- };
6168
-
6169
- // src/providers/assets/utils/url.ts
6170
- var DELIMITER_PATH = "/";
6171
- var trimRegex = /^\/|\/$/g;
6172
- var trimPath = (path2 = "") => path2.replace(trimRegex, "");
6173
- function urlJoin(baseUrl, ...paths) {
6174
- const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
6175
- const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
6176
- const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
6177
- if (rootPath && hasBaseUrl) {
6178
- allPaths.unshift("");
6179
- }
6180
- return allPaths.join(DELIMITER_PATH);
6181
- }
6182
-
6183
- // src/providers/assets/utils/resolveIconPaths.ts
6184
- function resolveIconPaths(assets2, basePath = "./") {
6185
- return assets2.map((asset) => ({
6186
- ...asset,
6187
- icon: urlJoin(basePath, asset.icon)
6188
- }));
6189
- }
6190
-
6191
- // src/providers/assets/utils/fuelAssetsBaseUrl.ts
6192
- var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
6193
-
6194
- // src/providers/assets/assets.ts
6195
- var rawAssets = [
6196
- {
6197
- name: "Ethereum",
6198
- symbol: "ETH",
6199
- icon: "eth.svg",
6200
- networks: [
6201
- {
6202
- type: "ethereum",
6203
- chainId: CHAIN_IDS.eth.sepolia,
6204
- decimals: 18
6205
- },
6206
- {
6207
- type: "ethereum",
6208
- chainId: CHAIN_IDS.eth.foundry,
6209
- decimals: 18
6210
- },
6211
- {
6212
- type: "ethereum",
6213
- chainId: CHAIN_IDS.eth.mainnet,
6214
- decimals: 18
6215
- },
6216
- {
6217
- type: "fuel",
6218
- chainId: CHAIN_IDS.fuel.devnet,
6219
- decimals: 9,
6220
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6221
- },
6222
- {
6223
- type: "fuel",
6224
- chainId: CHAIN_IDS.fuel.testnet,
6225
- decimals: 9,
6226
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6227
- },
6228
- {
6229
- type: "fuel",
6230
- chainId: CHAIN_IDS.fuel.mainnet,
6231
- decimals: 9,
6232
- assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
6233
- }
6234
- ]
6235
- },
6236
- {
6237
- name: "WETH",
6238
- symbol: "WETH",
6239
- icon: "weth.svg",
6240
- networks: [
6241
- {
6242
- type: "ethereum",
6243
- chainId: CHAIN_IDS.eth.mainnet,
6244
- address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
6245
- decimals: 18
6246
- },
6247
- {
6248
- type: "fuel",
6249
- chainId: CHAIN_IDS.fuel.mainnet,
6250
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6251
- assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
6252
- decimals: 9
6253
- }
6254
- ]
6255
- },
6256
- {
6257
- name: "weETH",
6258
- symbol: "weETH",
6259
- icon: "weETH.webp",
6260
- networks: [
6261
- {
6262
- type: "ethereum",
6263
- chainId: CHAIN_IDS.eth.mainnet,
6264
- address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
6265
- decimals: 18
6266
- },
6267
- {
6268
- type: "fuel",
6269
- chainId: CHAIN_IDS.fuel.mainnet,
6270
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6271
- assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
6272
- decimals: 9
6273
- }
6274
- ]
6275
- },
6276
- {
6277
- name: "rsETH",
6278
- symbol: "rsETH",
6279
- icon: "rsETH.webp",
6280
- networks: [
6281
- {
6282
- type: "ethereum",
6283
- chainId: CHAIN_IDS.eth.mainnet,
6284
- address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
6285
- decimals: 18
6286
- },
6287
- {
6288
- type: "fuel",
6289
- chainId: CHAIN_IDS.fuel.mainnet,
6290
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6291
- assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
6292
- decimals: 9
6293
- }
6294
- ]
6295
- },
6296
- {
6297
- name: "rETH",
6298
- symbol: "rETH",
6299
- icon: "reth.svg",
6300
- networks: [
6301
- {
6302
- type: "ethereum",
6303
- chainId: CHAIN_IDS.eth.mainnet,
6304
- address: "0xae78736cd615f374d3085123a210448e74fc6393",
6305
- decimals: 18
6306
- },
6307
- {
6308
- type: "fuel",
6309
- chainId: CHAIN_IDS.fuel.mainnet,
6310
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6311
- assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
6312
- decimals: 9
6313
- }
6314
- ]
6315
- },
6316
- {
6317
- name: "wbETH",
6318
- symbol: "wbETH",
6319
- icon: "wbeth.png",
6320
- networks: [
6321
- {
6322
- type: "ethereum",
6323
- chainId: CHAIN_IDS.eth.mainnet,
6324
- address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
6325
- decimals: 18
6326
- },
6327
- {
6328
- type: "fuel",
6329
- chainId: CHAIN_IDS.fuel.mainnet,
6330
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6331
- assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
6332
- decimals: 9
6333
- }
6334
- ]
6335
- },
6336
- {
6337
- name: "rstETH",
6338
- symbol: "rstETH",
6339
- icon: "rstETH.webp",
6340
- networks: [
6341
- {
6342
- type: "ethereum",
6343
- chainId: CHAIN_IDS.eth.mainnet,
6344
- address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
6345
- decimals: 18
6346
- },
6347
- {
6348
- type: "fuel",
6349
- chainId: CHAIN_IDS.fuel.mainnet,
6350
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6351
- assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
6352
- decimals: 9
6353
- }
6354
- ]
6355
- },
6356
- {
6357
- name: "amphrETH",
6358
- symbol: "amphrETH",
6359
- icon: "amphrETH.png",
6360
- networks: [
6361
- {
6362
- type: "ethereum",
6363
- chainId: CHAIN_IDS.eth.mainnet,
6364
- address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
6365
- decimals: 18
6366
- },
6367
- {
6368
- type: "fuel",
6369
- chainId: CHAIN_IDS.fuel.mainnet,
6370
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6371
- assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
6372
- decimals: 9
6373
- }
6374
- ]
6375
- },
6376
- {
6377
- name: "Manta mBTC",
6378
- symbol: "Manta mBTC",
6379
- icon: "manta-mbtc.svg",
6380
- networks: [
6381
- {
6382
- type: "ethereum",
6383
- chainId: CHAIN_IDS.eth.mainnet,
6384
- address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
6385
- decimals: 18
6386
- },
6387
- {
6388
- type: "fuel",
6389
- chainId: CHAIN_IDS.fuel.mainnet,
6390
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6391
- assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
6392
- decimals: 9
6393
- }
6394
- ]
6395
- },
6396
- {
6397
- name: "Manta mETH",
6398
- symbol: "Manta mETH",
6399
- icon: "manta-meth.svg",
6400
- networks: [
6401
- {
6402
- type: "ethereum",
6403
- chainId: CHAIN_IDS.eth.mainnet,
6404
- address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
6405
- decimals: 18
6406
- },
6407
- {
6408
- type: "fuel",
6409
- chainId: CHAIN_IDS.fuel.mainnet,
6410
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6411
- assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
6412
- decimals: 9
6413
- }
6414
- ]
6415
- },
6416
- {
6417
- name: "Manta mUSD",
6418
- symbol: "Manta mUSD",
6419
- icon: "manta-musd.svg",
6420
- networks: [
6421
- {
6422
- type: "ethereum",
6423
- chainId: CHAIN_IDS.eth.mainnet,
6424
- address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
6425
- decimals: 18
6426
- },
6427
- {
6428
- type: "fuel",
6429
- chainId: CHAIN_IDS.fuel.mainnet,
6430
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6431
- assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
6432
- decimals: 9
6433
- }
6434
- ]
6435
- },
6436
- {
6437
- name: "pumpBTC",
6438
- symbol: "pumpBTC",
6439
- icon: "pumpbtc.webp",
6440
- networks: [
6441
- {
6442
- type: "ethereum",
6443
- chainId: CHAIN_IDS.eth.mainnet,
6444
- address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
6445
- decimals: 8
6446
- },
6447
- {
6448
- type: "fuel",
6449
- chainId: CHAIN_IDS.fuel.mainnet,
6450
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6451
- assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
6452
- decimals: 8
6453
- }
6454
- ]
6455
- },
6456
- {
6457
- name: "FBTC",
6458
- symbol: "FBTC",
6459
- icon: "fbtc.svg",
6460
- networks: [
6461
- {
6462
- type: "ethereum",
6463
- chainId: CHAIN_IDS.eth.mainnet,
6464
- address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
6465
- decimals: 8
6466
- },
6467
- {
6468
- type: "fuel",
6469
- chainId: CHAIN_IDS.fuel.mainnet,
6470
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6471
- assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
6472
- decimals: 8
6473
- }
6474
- ]
6475
- },
6476
- {
6477
- name: "SolvBTC",
6478
- symbol: "SolvBTC",
6479
- icon: "solvBTC.webp",
6480
- networks: [
6481
- {
6482
- type: "ethereum",
6483
- chainId: CHAIN_IDS.eth.mainnet,
6484
- address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
6485
- decimals: 18
6486
- },
6487
- {
6488
- type: "fuel",
6489
- chainId: CHAIN_IDS.fuel.mainnet,
6490
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6491
- assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
6492
- decimals: 9
6493
- }
6494
- ]
6495
- },
6496
- {
6497
- name: "SolvBTC.BBN",
6498
- symbol: "SolvBTC.BBN",
6499
- icon: "SolvBTC.BBN.png",
6500
- networks: [
6501
- {
6502
- type: "ethereum",
6503
- chainId: CHAIN_IDS.eth.mainnet,
6504
- address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
6505
- decimals: 18
6506
- },
6507
- {
6508
- type: "fuel",
6509
- chainId: CHAIN_IDS.fuel.mainnet,
6510
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6511
- assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
6512
- decimals: 9
6513
- }
6514
- ]
6515
- },
6516
- {
6517
- name: "Mantle mETH",
6518
- symbol: "Mantle mETH",
6519
- icon: "mantle-meth.svg",
6520
- networks: [
6521
- {
6522
- type: "ethereum",
6523
- chainId: CHAIN_IDS.eth.mainnet,
6524
- address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
6525
- decimals: 18
6526
- },
6527
- {
6528
- type: "fuel",
6529
- chainId: CHAIN_IDS.fuel.mainnet,
6530
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6531
- assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
6532
- decimals: 9
6533
- }
6534
- ]
6535
- },
6536
- {
6537
- name: "sDAI",
6538
- symbol: "sDAI",
6539
- icon: "sdai.svg",
6540
- networks: [
6541
- {
6542
- type: "ethereum",
6543
- chainId: CHAIN_IDS.eth.mainnet,
6544
- address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
6545
- decimals: 18
6546
- },
6547
- {
6548
- type: "fuel",
6549
- chainId: CHAIN_IDS.fuel.mainnet,
6550
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6551
- assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
6552
- decimals: 9
6553
- }
6554
- ]
6555
- },
6556
- {
6557
- name: "USDT",
6558
- symbol: "USDT",
6559
- icon: "usdt.svg",
6560
- networks: [
6561
- {
6562
- type: "ethereum",
6563
- chainId: CHAIN_IDS.eth.mainnet,
6564
- address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
6565
- decimals: 6
6566
- },
6567
- {
6568
- type: "fuel",
6569
- chainId: CHAIN_IDS.fuel.mainnet,
6570
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6571
- assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
6572
- decimals: 6
6573
- }
6574
- ]
6575
- },
6576
- {
6577
- name: "USDC",
6578
- symbol: "USDC",
6579
- icon: "usdc.svg",
6580
- networks: [
6581
- {
6582
- type: "ethereum",
6583
- chainId: CHAIN_IDS.eth.mainnet,
6584
- address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
6585
- decimals: 6
6586
- },
6587
- {
6588
- type: "fuel",
6589
- chainId: CHAIN_IDS.fuel.mainnet,
6590
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6591
- assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
6592
- decimals: 6
6593
- }
6594
- ]
6595
- },
6596
- {
6597
- name: "USDe",
6598
- symbol: "USDe",
6599
- icon: "USDe.svg",
6600
- networks: [
6601
- {
6602
- type: "ethereum",
6603
- chainId: CHAIN_IDS.eth.mainnet,
6604
- address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
6605
- decimals: 18
6606
- },
6607
- {
6608
- type: "fuel",
6609
- chainId: CHAIN_IDS.fuel.mainnet,
6610
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6611
- assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
6612
- decimals: 9
6613
- }
6614
- ]
6615
- },
6616
- {
6617
- name: "sUSDe",
6618
- symbol: "sUSDe",
6619
- icon: "sUSDe.webp",
6620
- networks: [
6621
- {
6622
- type: "ethereum",
6623
- chainId: CHAIN_IDS.eth.mainnet,
6624
- address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
6625
- decimals: 18
6626
- },
6627
- {
6628
- type: "fuel",
6629
- chainId: CHAIN_IDS.fuel.mainnet,
6630
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6631
- assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
6632
- decimals: 9
6633
- }
6634
- ]
6635
- },
6636
- {
6637
- name: "rsUSDe",
6638
- symbol: "rsUSDe",
6639
- icon: "rsUSDe.svg",
6640
- networks: [
6641
- {
6642
- type: "ethereum",
6643
- chainId: CHAIN_IDS.eth.mainnet,
6644
- address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
6645
- decimals: 18
6646
- },
6647
- {
6648
- type: "fuel",
6649
- chainId: CHAIN_IDS.fuel.mainnet,
6650
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6651
- assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
6652
- decimals: 9
6653
- }
6654
- ]
6655
- },
6656
- {
6657
- name: "wstETH",
6658
- symbol: "wstETH",
6659
- icon: "wsteth.svg",
6660
- networks: [
6661
- {
6662
- type: "ethereum",
6663
- chainId: CHAIN_IDS.eth.mainnet,
6664
- address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
6665
- decimals: 18
6666
- },
6667
- {
6668
- type: "fuel",
6669
- chainId: CHAIN_IDS.fuel.mainnet,
6670
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6671
- assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
6672
- decimals: 9
6673
- }
6674
- ]
6675
- },
6676
- {
6677
- name: "ezETH",
6678
- symbol: "ezETH",
6679
- icon: "ezeth.webp",
6680
- networks: [
6681
- {
6682
- type: "ethereum",
6683
- chainId: CHAIN_IDS.eth.mainnet,
6684
- address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
6685
- decimals: 18
6686
- },
6687
- {
6688
- type: "fuel",
6689
- chainId: CHAIN_IDS.fuel.mainnet,
6690
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6691
- assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
6692
- decimals: 9
6693
- }
6694
- ]
6695
- },
6696
- {
6697
- name: "pzETH",
6698
- symbol: "pzETH",
6699
- icon: "pzETH.webp",
6700
- networks: [
6701
- {
6702
- type: "ethereum",
6703
- chainId: CHAIN_IDS.eth.mainnet,
6704
- address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
6705
- decimals: 18
6706
- },
6707
- {
6708
- type: "fuel",
6709
- chainId: CHAIN_IDS.fuel.mainnet,
6710
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6711
- assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
6712
- decimals: 9
6713
- }
6714
- ]
6715
- },
6716
- {
6717
- name: "Re7LRT",
6718
- symbol: "Re7LRT",
6719
- icon: "Re7LRT.png",
6720
- networks: [
6721
- {
6722
- type: "ethereum",
6723
- chainId: CHAIN_IDS.eth.mainnet,
6724
- address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
6725
- decimals: 18
6726
- },
6727
- {
6728
- type: "fuel",
6729
- chainId: CHAIN_IDS.fuel.mainnet,
6730
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6731
- assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
6732
- decimals: 9
6733
- }
6734
- ]
6735
- },
6736
- {
6737
- name: "steakLRT",
6738
- symbol: "steakLRT",
6739
- icon: "steakLRT.png",
6740
- networks: [
6741
- {
6742
- type: "ethereum",
6743
- chainId: CHAIN_IDS.eth.mainnet,
6744
- address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
6745
- decimals: 18
6746
- },
6747
- {
6748
- type: "fuel",
6749
- chainId: CHAIN_IDS.fuel.mainnet,
6750
- contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
6751
- assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
6752
- decimals: 9
6753
- }
6754
- ]
6755
- }
6756
- ];
6757
- var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
6758
-
6759
6236
  // src/test-utils/test-asset-id.ts
6760
6237
  var import_crypto4 = require("@fuel-ts/crypto");
6761
- var import_utils35 = require("@fuel-ts/utils");
6238
+ var import_utils34 = require("@fuel-ts/utils");
6762
6239
  var _TestAssetId = class {
6763
6240
  constructor(value) {
6764
6241
  this.value = value;
@@ -6766,7 +6243,7 @@ var _TestAssetId = class {
6766
6243
  static random(count = 1) {
6767
6244
  const assetIds = [];
6768
6245
  for (let i = 0; i < count; i++) {
6769
- assetIds.push(new _TestAssetId((0, import_utils35.hexlify)((0, import_crypto4.randomBytes)(32))));
6246
+ assetIds.push(new _TestAssetId((0, import_utils34.hexlify)((0, import_crypto4.randomBytes)(32))));
6770
6247
  }
6771
6248
  return assetIds;
6772
6249
  }
@@ -6781,22 +6258,22 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6781
6258
 
6782
6259
  // src/test-utils/wallet-config.ts
6783
6260
  var import_crypto9 = require("@fuel-ts/crypto");
6784
- var import_errors26 = require("@fuel-ts/errors");
6785
- var import_utils44 = require("@fuel-ts/utils");
6261
+ var import_errors27 = require("@fuel-ts/errors");
6262
+ var import_math23 = require("@fuel-ts/math");
6263
+ var import_utils43 = require("@fuel-ts/utils");
6786
6264
 
6787
6265
  // src/wallet/base-wallet-unlocked.ts
6788
6266
  var import_hasher4 = require("@fuel-ts/hasher");
6789
- var import_utils39 = require("@fuel-ts/utils");
6267
+ var import_utils38 = require("@fuel-ts/utils");
6790
6268
 
6791
6269
  // src/account.ts
6792
6270
  var import_abi_coder8 = require("@fuel-ts/abi-coder");
6793
6271
  var import_address6 = require("@fuel-ts/address");
6794
6272
  var import_crypto5 = require("@fuel-ts/crypto");
6795
- var import_errors21 = require("@fuel-ts/errors");
6796
- var import_interfaces = require("@fuel-ts/interfaces");
6273
+ var import_errors22 = require("@fuel-ts/errors");
6797
6274
  var import_math21 = require("@fuel-ts/math");
6798
6275
  var import_transactions24 = require("@fuel-ts/transactions");
6799
- var import_utils37 = require("@fuel-ts/utils");
6276
+ var import_utils36 = require("@fuel-ts/utils");
6800
6277
  var import_ramda9 = require("ramda");
6801
6278
 
6802
6279
  // src/providers/utils/merge-quantities.ts
@@ -6813,22 +6290,22 @@ var mergeQuantities = (...coinQuantities) => {
6813
6290
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
6814
6291
  };
6815
6292
 
6293
+ // src/types.ts
6294
+ var AbstractAccount = class {
6295
+ };
6296
+
6816
6297
  // src/utils/formatTransferToContractScriptData.ts
6817
6298
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
6818
6299
  var import_address5 = require("@fuel-ts/address");
6819
- var import_utils36 = require("@fuel-ts/utils");
6300
+ var import_utils35 = require("@fuel-ts/utils");
6820
6301
  var asm = __toESM(require("@fuels/vm-asm"));
6821
6302
  var formatTransferToContractScriptData = (transferParams) => {
6822
6303
  const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
6823
6304
  return transferParams.reduce((acc, transferParam) => {
6824
6305
  const { assetId, amount, contractId } = transferParam;
6825
6306
  const encoded = numberCoder.encode(amount);
6826
- const scriptData = (0, import_utils36.concat)([
6827
- import_address5.Address.fromAddressOrString(contractId).toBytes(),
6828
- encoded,
6829
- (0, import_utils36.arrayify)(assetId)
6830
- ]);
6831
- return (0, import_utils36.concat)([acc, scriptData]);
6307
+ const scriptData = (0, import_utils35.concat)([new import_address5.Address(contractId).toBytes(), encoded, (0, import_utils35.arrayify)(assetId)]);
6308
+ return (0, import_utils35.concat)([acc, scriptData]);
6832
6309
  }, new Uint8Array());
6833
6310
  };
6834
6311
  var assembleTransferToContractScript = async (transferParams) => {
@@ -6837,7 +6314,7 @@ var assembleTransferToContractScript = async (transferParams) => {
6837
6314
  let script = new Uint8Array();
6838
6315
  transferParams.forEach((_, i) => {
6839
6316
  const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
6840
- script = (0, import_utils36.concat)([
6317
+ script = (0, import_utils35.concat)([
6841
6318
  script,
6842
6319
  // Load ScriptData into register 0x10.
6843
6320
  asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
@@ -6853,13 +6330,13 @@ var assembleTransferToContractScript = async (transferParams) => {
6853
6330
  asm.tr(17, 19, 20).to_bytes()
6854
6331
  ]);
6855
6332
  });
6856
- script = (0, import_utils36.concat)([script, asm.ret(1).to_bytes()]);
6333
+ script = (0, import_utils35.concat)([script, asm.ret(1).to_bytes()]);
6857
6334
  return { script, scriptData };
6858
6335
  };
6859
6336
 
6860
6337
  // src/account.ts
6861
6338
  var MAX_FUNDING_ATTEMPTS = 5;
6862
- var Account = class extends import_interfaces.AbstractAccount {
6339
+ var Account = class extends AbstractAccount {
6863
6340
  /**
6864
6341
  * The address associated with the account.
6865
6342
  */
@@ -6883,7 +6360,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6883
6360
  super();
6884
6361
  this._provider = provider;
6885
6362
  this._connector = connector;
6886
- this.address = import_address6.Address.fromDynamicInput(address);
6363
+ this.address = new import_address6.Address(address);
6887
6364
  }
6888
6365
  /**
6889
6366
  * The provider used to interact with the network.
@@ -6894,7 +6371,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6894
6371
  */
6895
6372
  get provider() {
6896
6373
  if (!this._provider) {
6897
- throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_PROVIDER, "Provider not set");
6374
+ throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
6898
6375
  }
6899
6376
  return this._provider;
6900
6377
  }
@@ -6950,7 +6427,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6950
6427
  * @returns A promise that resolves to the balance amount.
6951
6428
  */
6952
6429
  async getBalance(assetId) {
6953
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
6430
+ const assetIdToFetch = assetId ?? await this.provider.getBaseAssetId();
6954
6431
  const amount = await this.provider.getBalance(this.address, assetIdToFetch);
6955
6432
  return amount;
6956
6433
  }
@@ -6973,7 +6450,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6973
6450
  async fund(request, params) {
6974
6451
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6975
6452
  const fee = request.maxFee;
6976
- const baseAssetId = this.provider.getBaseAssetId();
6453
+ const baseAssetId = await this.provider.getBaseAssetId();
6977
6454
  const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
6978
6455
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
6979
6456
  amount: (0, import_math21.bn)(fee),
@@ -7045,12 +6522,12 @@ var Account = class extends import_interfaces.AbstractAccount {
7045
6522
  fundingAttempts += 1;
7046
6523
  }
7047
6524
  if (needsToBeFunded) {
7048
- throw new import_errors21.FuelError(
7049
- import_errors21.ErrorCode.NOT_ENOUGH_FUNDS,
6525
+ throw new import_errors22.FuelError(
6526
+ import_errors22.ErrorCode.NOT_ENOUGH_FUNDS,
7050
6527
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
7051
6528
  );
7052
6529
  }
7053
- this.provider.validateTransaction(request);
6530
+ await this.provider.validateTransaction(request);
7054
6531
  request.updatePredicateGasUsed(estimatedPredicates);
7055
6532
  const requestToReestimate = (0, import_ramda9.clone)(request);
7056
6533
  if (addedSignatures) {
@@ -7077,7 +6554,11 @@ var Account = class extends import_interfaces.AbstractAccount {
7077
6554
  */
7078
6555
  async createTransfer(destination, amount, assetId, txParams = {}) {
7079
6556
  let request = new ScriptTransactionRequest(txParams);
7080
- request = this.addTransfer(request, { destination, amount, assetId });
6557
+ request = this.addTransfer(request, {
6558
+ destination,
6559
+ amount,
6560
+ assetId: assetId || await this.provider.getBaseAssetId()
6561
+ });
7081
6562
  request = await this.estimateAndFundTransaction(request, txParams);
7082
6563
  return request;
7083
6564
  }
@@ -7117,11 +6598,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7117
6598
  addTransfer(request, transferParams) {
7118
6599
  const { destination, amount, assetId } = transferParams;
7119
6600
  this.validateTransferAmount(amount);
7120
- request.addCoinOutput(
7121
- import_address6.Address.fromAddressOrString(destination),
7122
- amount,
7123
- assetId ?? this.provider.getBaseAssetId()
7124
- );
6601
+ request.addCoinOutput(new import_address6.Address(destination), amount, assetId);
7125
6602
  return request;
7126
6603
  }
7127
6604
  /**
@@ -7132,12 +6609,11 @@ var Account = class extends import_interfaces.AbstractAccount {
7132
6609
  * @returns The updated script transaction request.
7133
6610
  */
7134
6611
  addBatchTransfer(request, transferParams) {
7135
- const baseAssetId = this.provider.getBaseAssetId();
7136
6612
  transferParams.forEach(({ destination, amount, assetId }) => {
7137
6613
  this.addTransfer(request, {
7138
6614
  destination,
7139
6615
  amount,
7140
- assetId: assetId ?? baseAssetId
6616
+ assetId
7141
6617
  });
7142
6618
  });
7143
6619
  return request;
@@ -7159,13 +6635,14 @@ var Account = class extends import_interfaces.AbstractAccount {
7159
6635
  ...txParams
7160
6636
  });
7161
6637
  const quantities = [];
6638
+ const defaultAssetId = await this.provider.getBaseAssetId();
7162
6639
  const transferParams = contractTransferParams.map((transferParam) => {
7163
6640
  const amount = (0, import_math21.bn)(transferParam.amount);
7164
- const contractAddress = import_address6.Address.fromAddressOrString(transferParam.contractId);
7165
- const assetId = transferParam.assetId ? (0, import_utils37.hexlify)(transferParam.assetId) : this.provider.getBaseAssetId();
6641
+ const contractAddress = new import_address6.Address(transferParam.contractId);
6642
+ const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
7166
6643
  if (amount.lte(0)) {
7167
- throw new import_errors21.FuelError(
7168
- import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
6644
+ throw new import_errors22.FuelError(
6645
+ import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7169
6646
  "Transfer amount must be a positive number."
7170
6647
  );
7171
6648
  }
@@ -7192,20 +6669,20 @@ var Account = class extends import_interfaces.AbstractAccount {
7192
6669
  * @returns A promise that resolves to the transaction response.
7193
6670
  */
7194
6671
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7195
- const recipientAddress = import_address6.Address.fromAddressOrString(recipient);
7196
- const recipientDataArray = (0, import_utils37.arrayify)(
6672
+ const recipientAddress = new import_address6.Address(recipient);
6673
+ const recipientDataArray = (0, import_utils36.arrayify)(
7197
6674
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7198
6675
  );
7199
- const amountDataArray = (0, import_utils37.arrayify)(
6676
+ const amountDataArray = (0, import_utils36.arrayify)(
7200
6677
  "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7201
6678
  );
7202
6679
  const script = new Uint8Array([
7203
- ...(0, import_utils37.arrayify)(withdrawScript.bytes),
6680
+ ...(0, import_utils36.arrayify)(withdrawScript.bytes),
7204
6681
  ...recipientDataArray,
7205
6682
  ...amountDataArray
7206
6683
  ]);
7207
6684
  const params = { script, ...txParams };
7208
- const baseAssetId = this.provider.getBaseAssetId();
6685
+ const baseAssetId = await this.provider.getBaseAssetId();
7209
6686
  let request = new ScriptTransactionRequest(params);
7210
6687
  const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7211
6688
  const txCost = await this.getTransactionCost(request, { quantities });
@@ -7228,9 +6705,9 @@ var Account = class extends import_interfaces.AbstractAccount {
7228
6705
  *
7229
6706
  * @returns A promise that resolves to the transaction cost object.
7230
6707
  */
7231
- async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
6708
+ async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [], gasPrice } = {}) {
7232
6709
  const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
7233
- const baseAssetId = this.provider.getBaseAssetId();
6710
+ const baseAssetId = await this.provider.getBaseAssetId();
7234
6711
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7235
6712
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7236
6713
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
@@ -7263,7 +6740,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7263
6740
  ({ amount, assetId }) => updateAssetInput(assetId, amount)
7264
6741
  );
7265
6742
  const txCost = await this.provider.getTransactionCost(txRequestClone, {
7266
- signatureCallback
6743
+ signatureCallback,
6744
+ gasPrice
7267
6745
  });
7268
6746
  return {
7269
6747
  ...txCost,
@@ -7280,7 +6758,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7280
6758
  */
7281
6759
  async signMessage(message) {
7282
6760
  if (!this._connector) {
7283
- throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
6761
+ throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7284
6762
  }
7285
6763
  return this._connector.signMessage(this.address.toString(), message);
7286
6764
  }
@@ -7292,8 +6770,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7292
6770
  */
7293
6771
  async signTransaction(transactionRequestLike) {
7294
6772
  if (!this._connector) {
7295
- throw new import_errors21.FuelError(
7296
- import_errors21.ErrorCode.MISSING_CONNECTOR,
6773
+ throw new import_errors22.FuelError(
6774
+ import_errors22.ErrorCode.MISSING_CONNECTOR,
7297
6775
  "A connector is required to sign transactions."
7298
6776
  );
7299
6777
  }
@@ -7306,10 +6784,13 @@ var Account = class extends import_interfaces.AbstractAccount {
7306
6784
  * @param sendTransactionParams - The provider send transaction parameters (optional).
7307
6785
  * @returns A promise that resolves to the transaction response.
7308
6786
  */
7309
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
6787
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
7310
6788
  if (this._connector) {
7311
6789
  return this.provider.getTransactionResponse(
7312
- await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
6790
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
6791
+ onBeforeSend,
6792
+ skipCustomFee
6793
+ })
7313
6794
  );
7314
6795
  }
7315
6796
  const transactionRequest = transactionRequestify(transactionRequestLike);
@@ -7342,7 +6823,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7342
6823
  */
7343
6824
  generateFakeResources(coins) {
7344
6825
  return coins.map((coin) => ({
7345
- id: (0, import_utils37.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
6826
+ id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
7346
6827
  owner: this.address,
7347
6828
  blockCreated: (0, import_math21.bn)(1),
7348
6829
  txCreatedIdx: (0, import_math21.bn)(1),
@@ -7352,8 +6833,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7352
6833
  /** @hidden * */
7353
6834
  validateTransferAmount(amount) {
7354
6835
  if ((0, import_math21.bn)(amount).lte(0)) {
7355
- throw new import_errors21.FuelError(
7356
- import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
6836
+ throw new import_errors22.FuelError(
6837
+ import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7357
6838
  "Transfer amount must be a positive number."
7358
6839
  );
7359
6840
  }
@@ -7379,19 +6860,19 @@ var Account = class extends import_interfaces.AbstractAccount {
7379
6860
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
7380
6861
  }) {
7381
6862
  const request = transactionRequestify(transactionRequest);
7382
- if (!(0, import_utils37.isDefined)(setGasLimit)) {
6863
+ if (!(0, import_utils36.isDefined)(setGasLimit)) {
7383
6864
  request.gasLimit = gasUsed;
7384
6865
  } else if (gasUsed.gt(setGasLimit)) {
7385
- throw new import_errors21.FuelError(
7386
- import_errors21.ErrorCode.GAS_LIMIT_TOO_LOW,
6866
+ throw new import_errors22.FuelError(
6867
+ import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
7387
6868
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7388
6869
  );
7389
6870
  }
7390
- if (!(0, import_utils37.isDefined)(setMaxFee)) {
6871
+ if (!(0, import_utils36.isDefined)(setMaxFee)) {
7391
6872
  request.maxFee = maxFee;
7392
6873
  } else if (maxFee.gt(setMaxFee)) {
7393
- throw new import_errors21.FuelError(
7394
- import_errors21.ErrorCode.MAX_FEE_TOO_LOW,
6874
+ throw new import_errors22.FuelError(
6875
+ import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
7395
6876
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7396
6877
  );
7397
6878
  }
@@ -7402,8 +6883,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7402
6883
  // src/wallet/keystore-wallet.ts
7403
6884
  var import_address7 = require("@fuel-ts/address");
7404
6885
  var import_crypto6 = require("@fuel-ts/crypto");
7405
- var import_errors22 = require("@fuel-ts/errors");
7406
- var import_utils38 = require("@fuel-ts/utils");
6886
+ var import_errors23 = require("@fuel-ts/errors");
6887
+ var import_utils37 = require("@fuel-ts/utils");
7407
6888
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7408
6889
  var DEFAULT_KDF_PARAMS_R = 8;
7409
6890
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -7417,7 +6898,7 @@ var removeHexPrefix = (hexString) => {
7417
6898
  };
7418
6899
  async function encryptKeystoreWallet(privateKey, address, password) {
7419
6900
  const privateKeyBuffer = (0, import_crypto6.bufferFromString)(removeHexPrefix(privateKey), "hex");
7420
- const ownerAddress = import_address7.Address.fromAddressOrString(address);
6901
+ const ownerAddress = new import_address7.Address(address);
7421
6902
  const salt = (0, import_crypto6.randomBytes)(DEFAULT_KEY_SIZE);
7422
6903
  const key = (0, import_crypto6.scrypt)({
7423
6904
  password: (0, import_crypto6.bufferFromString)(password),
@@ -7479,13 +6960,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7479
6960
  const macHashUint8Array = (0, import_crypto6.keccak256)(data);
7480
6961
  const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
7481
6962
  if (mac !== macHash) {
7482
- throw new import_errors22.FuelError(
7483
- import_errors22.ErrorCode.INVALID_PASSWORD,
6963
+ throw new import_errors23.FuelError(
6964
+ import_errors23.ErrorCode.INVALID_PASSWORD,
7484
6965
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7485
6966
  );
7486
6967
  }
7487
6968
  const buffer = await (0, import_crypto6.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
7488
- const privateKey = (0, import_utils38.hexlify)(buffer);
6969
+ const privateKey = (0, import_utils37.hexlify)(buffer);
7489
6970
  return privateKey;
7490
6971
  }
7491
6972
 
@@ -7530,7 +7011,7 @@ var BaseWalletUnlocked = class extends Account {
7530
7011
  */
7531
7012
  async signMessage(message) {
7532
7013
  const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
7533
- return (0, import_utils39.hexlify)(signedMessage);
7014
+ return (0, import_utils38.hexlify)(signedMessage);
7534
7015
  }
7535
7016
  /**
7536
7017
  * Signs a transaction with the wallet's private key.
@@ -7540,10 +7021,10 @@ var BaseWalletUnlocked = class extends Account {
7540
7021
  */
7541
7022
  async signTransaction(transactionRequestLike) {
7542
7023
  const transactionRequest = transactionRequestify(transactionRequestLike);
7543
- const chainId = this.provider.getChainId();
7024
+ const chainId = await this.provider.getChainId();
7544
7025
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
7545
7026
  const signature = await this.signer().sign(hashedTransaction);
7546
- return (0, import_utils39.hexlify)(signature);
7027
+ return (0, import_utils38.hexlify)(signature);
7547
7028
  }
7548
7029
  /**
7549
7030
  * Populates a transaction with the witnesses signature.
@@ -7564,14 +7045,19 @@ var BaseWalletUnlocked = class extends Account {
7564
7045
  * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
7565
7046
  * @returns A promise that resolves to the TransactionResponse object.
7566
7047
  */
7567
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
7048
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, enableAssetBurn } = {}) {
7568
7049
  const transactionRequest = transactionRequestify(transactionRequestLike);
7050
+ validateTransactionForAssetBurn(
7051
+ await this.provider.getBaseAssetId(),
7052
+ transactionRequest,
7053
+ enableAssetBurn
7054
+ );
7569
7055
  if (estimateTxDependencies) {
7570
7056
  await this.provider.estimateTxDependencies(transactionRequest);
7571
7057
  }
7572
7058
  return this.provider.sendTransaction(
7573
7059
  await this.populateTransactionWitnessesSignature(transactionRequest),
7574
- { estimateTxDependencies: false }
7060
+ { estimateTxDependencies: false, enableAssetBurn }
7575
7061
  );
7576
7062
  }
7577
7063
  /**
@@ -7610,16 +7096,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7610
7096
 
7611
7097
  // src/hdwallet/hdwallet.ts
7612
7098
  var import_crypto8 = require("@fuel-ts/crypto");
7613
- var import_errors25 = require("@fuel-ts/errors");
7099
+ var import_errors26 = require("@fuel-ts/errors");
7614
7100
  var import_hasher7 = require("@fuel-ts/hasher");
7615
7101
  var import_math22 = require("@fuel-ts/math");
7616
- var import_utils43 = require("@fuel-ts/utils");
7102
+ var import_utils42 = require("@fuel-ts/utils");
7617
7103
 
7618
7104
  // src/mnemonic/mnemonic.ts
7619
7105
  var import_crypto7 = require("@fuel-ts/crypto");
7620
- var import_errors24 = require("@fuel-ts/errors");
7106
+ var import_errors25 = require("@fuel-ts/errors");
7621
7107
  var import_hasher6 = require("@fuel-ts/hasher");
7622
- var import_utils41 = require("@fuel-ts/utils");
7108
+ var import_utils40 = require("@fuel-ts/utils");
7623
7109
 
7624
7110
  // src/wordlists/words/english.ts
7625
7111
  var english = [
@@ -9674,9 +9160,9 @@ var english = [
9674
9160
  ];
9675
9161
 
9676
9162
  // src/mnemonic/utils.ts
9677
- var import_errors23 = require("@fuel-ts/errors");
9163
+ var import_errors24 = require("@fuel-ts/errors");
9678
9164
  var import_hasher5 = require("@fuel-ts/hasher");
9679
- var import_utils40 = require("@fuel-ts/utils");
9165
+ var import_utils39 = require("@fuel-ts/utils");
9680
9166
  function getLowerMask(bits) {
9681
9167
  return (1 << bits) - 1;
9682
9168
  }
@@ -9711,20 +9197,20 @@ function entropyToMnemonicIndices(entropy) {
9711
9197
  }
9712
9198
  }
9713
9199
  const checksumBits = entropy.length / 4;
9714
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
9200
+ const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
9715
9201
  indices[indices.length - 1] <<= checksumBits;
9716
9202
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
9717
9203
  return indices;
9718
9204
  }
9719
9205
  function mnemonicWordsToEntropy(words, wordlist) {
9720
9206
  const size = Math.ceil(11 * words.length / 8);
9721
- const entropy = (0, import_utils40.arrayify)(new Uint8Array(size));
9207
+ const entropy = (0, import_utils39.arrayify)(new Uint8Array(size));
9722
9208
  let offset = 0;
9723
9209
  for (let i = 0; i < words.length; i += 1) {
9724
9210
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9725
9211
  if (index === -1) {
9726
- throw new import_errors23.FuelError(
9727
- import_errors23.ErrorCode.INVALID_MNEMONIC,
9212
+ throw new import_errors24.FuelError(
9213
+ import_errors24.ErrorCode.INVALID_MNEMONIC,
9728
9214
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9729
9215
  );
9730
9216
  }
@@ -9738,10 +9224,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
9738
9224
  const entropyBits = 32 * words.length / 3;
9739
9225
  const checksumBits = words.length / 3;
9740
9226
  const checksumMask = getUpperMask(checksumBits);
9741
- const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9227
+ const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9742
9228
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9743
- throw new import_errors23.FuelError(
9744
- import_errors23.ErrorCode.INVALID_CHECKSUM,
9229
+ throw new import_errors24.FuelError(
9230
+ import_errors24.ErrorCode.INVALID_CHECKSUM,
9745
9231
  "Checksum validation failed for the provided mnemonic."
9746
9232
  );
9747
9233
  }
@@ -9749,22 +9235,22 @@ function mnemonicWordsToEntropy(words, wordlist) {
9749
9235
  }
9750
9236
 
9751
9237
  // src/mnemonic/mnemonic.ts
9752
- var MasterSecret = (0, import_utils41.toUtf8Bytes)("Bitcoin seed");
9238
+ var MasterSecret = (0, import_utils40.toUtf8Bytes)("Bitcoin seed");
9753
9239
  var MainnetPRV = "0x0488ade4";
9754
9240
  var TestnetPRV = "0x04358394";
9755
9241
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9756
9242
  function assertWordList(wordlist) {
9757
9243
  if (wordlist.length !== 2048) {
9758
- throw new import_errors24.FuelError(
9759
- import_errors24.ErrorCode.INVALID_WORD_LIST,
9244
+ throw new import_errors25.FuelError(
9245
+ import_errors25.ErrorCode.INVALID_WORD_LIST,
9760
9246
  `Expected word list length of 2048, but got ${wordlist.length}.`
9761
9247
  );
9762
9248
  }
9763
9249
  }
9764
9250
  function assertEntropy(entropy) {
9765
9251
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9766
- throw new import_errors24.FuelError(
9767
- import_errors24.ErrorCode.INVALID_ENTROPY,
9252
+ throw new import_errors25.FuelError(
9253
+ import_errors25.ErrorCode.INVALID_ENTROPY,
9768
9254
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9769
9255
  );
9770
9256
  }
@@ -9774,7 +9260,7 @@ function assertMnemonic(words) {
9774
9260
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9775
9261
  ", "
9776
9262
  )}] words, but got ${words.length}.`;
9777
- throw new import_errors24.FuelError(import_errors24.ErrorCode.INVALID_MNEMONIC, errorMsg);
9263
+ throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
9778
9264
  }
9779
9265
  }
9780
9266
  var Mnemonic = class {
@@ -9813,7 +9299,7 @@ var Mnemonic = class {
9813
9299
  static mnemonicToEntropy(phrase, wordlist = english) {
9814
9300
  const words = getWords(phrase);
9815
9301
  assertMnemonic(words);
9816
- return (0, import_utils41.hexlify)(mnemonicWordsToEntropy(words, wordlist));
9302
+ return (0, import_utils40.hexlify)(mnemonicWordsToEntropy(words, wordlist));
9817
9303
  }
9818
9304
  /**
9819
9305
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -9821,7 +9307,7 @@ var Mnemonic = class {
9821
9307
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
9822
9308
  */
9823
9309
  static entropyToMnemonic(entropy, wordlist = english) {
9824
- const entropyBytes = (0, import_utils41.arrayify)(entropy);
9310
+ const entropyBytes = (0, import_utils40.arrayify)(entropy);
9825
9311
  assertWordList(wordlist);
9826
9312
  assertEntropy(entropyBytes);
9827
9313
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -9833,8 +9319,8 @@ var Mnemonic = class {
9833
9319
  */
9834
9320
  static mnemonicToSeed(phrase, passphrase = "") {
9835
9321
  assertMnemonic(getWords(phrase));
9836
- const phraseBytes = (0, import_utils41.toUtf8Bytes)(getPhrase(phrase));
9837
- const salt = (0, import_utils41.toUtf8Bytes)(`mnemonic${passphrase}`);
9322
+ const phraseBytes = (0, import_utils40.toUtf8Bytes)(getPhrase(phrase));
9323
+ const salt = (0, import_utils40.toUtf8Bytes)(`mnemonic${passphrase}`);
9838
9324
  return (0, import_crypto7.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
9839
9325
  }
9840
9326
  /**
@@ -9890,14 +9376,14 @@ var Mnemonic = class {
9890
9376
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
9891
9377
  */
9892
9378
  static masterKeysFromSeed(seed) {
9893
- const seedArray = (0, import_utils41.arrayify)(seed);
9379
+ const seedArray = (0, import_utils40.arrayify)(seed);
9894
9380
  if (seedArray.length < 16 || seedArray.length > 64) {
9895
- throw new import_errors24.FuelError(
9896
- import_errors24.ErrorCode.INVALID_SEED,
9381
+ throw new import_errors25.FuelError(
9382
+ import_errors25.ErrorCode.INVALID_SEED,
9897
9383
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9898
9384
  );
9899
9385
  }
9900
- return (0, import_utils41.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
9386
+ return (0, import_utils40.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
9901
9387
  }
9902
9388
  /**
9903
9389
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -9908,22 +9394,22 @@ var Mnemonic = class {
9908
9394
  */
9909
9395
  static seedToExtendedKey(seed, testnet = false) {
9910
9396
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
9911
- const prefix = (0, import_utils41.arrayify)(testnet ? TestnetPRV : MainnetPRV);
9397
+ const prefix = (0, import_utils40.arrayify)(testnet ? TestnetPRV : MainnetPRV);
9912
9398
  const depth = "0x00";
9913
9399
  const fingerprint = "0x00000000";
9914
9400
  const index = "0x00000000";
9915
9401
  const chainCode = masterKey.slice(32);
9916
9402
  const privateKey = masterKey.slice(0, 32);
9917
- const extendedKey = (0, import_utils41.concat)([
9403
+ const extendedKey = (0, import_utils40.concat)([
9918
9404
  prefix,
9919
9405
  depth,
9920
9406
  fingerprint,
9921
9407
  index,
9922
9408
  chainCode,
9923
- (0, import_utils41.concat)(["0x00", privateKey])
9409
+ (0, import_utils40.concat)(["0x00", privateKey])
9924
9410
  ]);
9925
- const checksum = (0, import_utils41.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
9926
- return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([extendedKey, checksum]));
9411
+ const checksum = (0, import_utils40.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
9412
+ return (0, import_utils40.encodeBase58)((0, import_utils40.concat)([extendedKey, checksum]));
9927
9413
  }
9928
9414
  /**
9929
9415
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9938,7 +9424,7 @@ var Mnemonic = class {
9938
9424
  * @returns A randomly generated mnemonic
9939
9425
  */
9940
9426
  static generate(size = 32, extraEntropy = "") {
9941
- 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);
9427
+ 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);
9942
9428
  return Mnemonic.entropyToMnemonic(entropy);
9943
9429
  }
9944
9430
  };
@@ -9946,12 +9432,12 @@ var mnemonic_default = Mnemonic;
9946
9432
 
9947
9433
  // src/hdwallet/hdwallet.ts
9948
9434
  var HARDENED_INDEX = 2147483648;
9949
- var MainnetPRV2 = (0, import_utils43.hexlify)("0x0488ade4");
9950
- var MainnetPUB = (0, import_utils43.hexlify)("0x0488b21e");
9951
- var TestnetPRV2 = (0, import_utils43.hexlify)("0x04358394");
9952
- var TestnetPUB = (0, import_utils43.hexlify)("0x043587cf");
9435
+ var MainnetPRV2 = (0, import_utils42.hexlify)("0x0488ade4");
9436
+ var MainnetPUB = (0, import_utils42.hexlify)("0x0488b21e");
9437
+ var TestnetPRV2 = (0, import_utils42.hexlify)("0x04358394");
9438
+ var TestnetPUB = (0, import_utils42.hexlify)("0x043587cf");
9953
9439
  function base58check(data) {
9954
- 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)]));
9440
+ 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)]));
9955
9441
  }
9956
9442
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9957
9443
  if (isPublic) {
@@ -9960,17 +9446,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9960
9446
  return testnet ? TestnetPRV2 : MainnetPRV2;
9961
9447
  }
9962
9448
  function isPublicExtendedKey(extendedKey) {
9963
- return [MainnetPUB, TestnetPUB].includes((0, import_utils43.hexlify)(extendedKey.slice(0, 4)));
9449
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils42.hexlify)(extendedKey.slice(0, 4)));
9964
9450
  }
9965
9451
  function isValidExtendedKey(extendedKey) {
9966
9452
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
9967
- (0, import_utils43.hexlify)(extendedKey.slice(0, 4))
9453
+ (0, import_utils42.hexlify)(extendedKey.slice(0, 4))
9968
9454
  );
9969
9455
  }
9970
9456
  function parsePath(path2, depth = 0) {
9971
9457
  const components = path2.split("/");
9972
9458
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9973
- throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9459
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9974
9460
  }
9975
9461
  if (components[0] === "m") {
9976
9462
  components.shift();
@@ -9982,8 +9468,8 @@ function parsePath(path2, depth = 0) {
9982
9468
  var HDWallet = class {
9983
9469
  depth = 0;
9984
9470
  index = 0;
9985
- fingerprint = (0, import_utils43.hexlify)("0x00000000");
9986
- parentFingerprint = (0, import_utils43.hexlify)("0x00000000");
9471
+ fingerprint = (0, import_utils42.hexlify)("0x00000000");
9472
+ parentFingerprint = (0, import_utils42.hexlify)("0x00000000");
9987
9473
  privateKey;
9988
9474
  publicKey;
9989
9475
  chainCode;
@@ -9995,19 +9481,19 @@ var HDWallet = class {
9995
9481
  constructor(config) {
9996
9482
  if (config.privateKey) {
9997
9483
  const signer = new Signer(config.privateKey);
9998
- this.publicKey = (0, import_utils43.hexlify)(signer.compressedPublicKey);
9999
- this.privateKey = (0, import_utils43.hexlify)(config.privateKey);
9484
+ this.publicKey = (0, import_utils42.hexlify)(signer.compressedPublicKey);
9485
+ this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
10000
9486
  } else {
10001
9487
  if (!config.publicKey) {
10002
- throw new import_errors25.FuelError(
10003
- import_errors25.ErrorCode.HD_WALLET_ERROR,
9488
+ throw new import_errors26.FuelError(
9489
+ import_errors26.ErrorCode.HD_WALLET_ERROR,
10004
9490
  "Both public and private Key cannot be missing. At least one should be provided."
10005
9491
  );
10006
9492
  }
10007
- this.publicKey = (0, import_utils43.hexlify)(config.publicKey);
9493
+ this.publicKey = (0, import_utils42.hexlify)(config.publicKey);
10008
9494
  }
10009
9495
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
10010
- this.fingerprint = (0, import_utils43.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
9496
+ this.fingerprint = (0, import_utils42.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
10011
9497
  this.depth = config.depth || this.depth;
10012
9498
  this.index = config.index || this.index;
10013
9499
  this.chainCode = config.chainCode;
@@ -10023,23 +9509,23 @@ var HDWallet = class {
10023
9509
  * @returns A new instance of HDWallet on the derived index
10024
9510
  */
10025
9511
  deriveIndex(index) {
10026
- const privateKey = this.privateKey && (0, import_utils43.arrayify)(this.privateKey);
10027
- const publicKey = (0, import_utils43.arrayify)(this.publicKey);
10028
- const chainCode = (0, import_utils43.arrayify)(this.chainCode);
9512
+ const privateKey = this.privateKey && (0, import_utils42.arrayify)(this.privateKey);
9513
+ const publicKey = (0, import_utils42.arrayify)(this.publicKey);
9514
+ const chainCode = (0, import_utils42.arrayify)(this.chainCode);
10029
9515
  const data = new Uint8Array(37);
10030
9516
  if (index & HARDENED_INDEX) {
10031
9517
  if (!privateKey) {
10032
- throw new import_errors25.FuelError(
10033
- import_errors25.ErrorCode.HD_WALLET_ERROR,
9518
+ throw new import_errors26.FuelError(
9519
+ import_errors26.ErrorCode.HD_WALLET_ERROR,
10034
9520
  "Cannot derive a hardened index without a private Key."
10035
9521
  );
10036
9522
  }
10037
9523
  data.set(privateKey, 1);
10038
9524
  } else {
10039
- data.set((0, import_utils43.arrayify)(this.publicKey));
9525
+ data.set((0, import_utils42.arrayify)(this.publicKey));
10040
9526
  }
10041
9527
  data.set((0, import_math22.toBytes)(index, 4), 33);
10042
- const bytes = (0, import_utils43.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
9528
+ const bytes = (0, import_utils42.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
10043
9529
  const IL = bytes.slice(0, 32);
10044
9530
  const IR = bytes.slice(32);
10045
9531
  if (privateKey) {
@@ -10053,7 +9539,7 @@ var HDWallet = class {
10053
9539
  parentFingerprint: this.fingerprint
10054
9540
  });
10055
9541
  }
10056
- const signer = new Signer((0, import_utils43.hexlify)(IL));
9542
+ const signer = new Signer((0, import_utils42.hexlify)(IL));
10057
9543
  const Ki = signer.addPoint(publicKey);
10058
9544
  return new HDWallet({
10059
9545
  publicKey: Ki,
@@ -10082,18 +9568,18 @@ var HDWallet = class {
10082
9568
  */
10083
9569
  toExtendedKey(isPublic = false, testnet = false) {
10084
9570
  if (this.depth >= 256) {
10085
- throw new import_errors25.FuelError(
10086
- import_errors25.ErrorCode.HD_WALLET_ERROR,
9571
+ throw new import_errors26.FuelError(
9572
+ import_errors26.ErrorCode.HD_WALLET_ERROR,
10087
9573
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10088
9574
  );
10089
9575
  }
10090
9576
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
10091
- const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
9577
+ const depth = (0, import_utils42.hexlify)(Uint8Array.from([this.depth]));
10092
9578
  const parentFingerprint = this.parentFingerprint;
10093
9579
  const index = (0, import_math22.toHex)(this.index, 4);
10094
9580
  const chainCode = this.chainCode;
10095
- const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
10096
- const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
9581
+ const key = this.privateKey != null && !isPublic ? (0, import_utils42.concat)(["0x00", this.privateKey]) : this.publicKey;
9582
+ const extendedKey = (0, import_utils42.arrayify)((0, import_utils42.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
10097
9583
  return base58check(extendedKey);
10098
9584
  }
10099
9585
  /**
@@ -10105,34 +9591,34 @@ var HDWallet = class {
10105
9591
  static fromSeed(seed) {
10106
9592
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
10107
9593
  return new HDWallet({
10108
- chainCode: (0, import_utils43.arrayify)(masterKey.slice(32)),
10109
- privateKey: (0, import_utils43.arrayify)(masterKey.slice(0, 32))
9594
+ chainCode: (0, import_utils42.arrayify)(masterKey.slice(32)),
9595
+ privateKey: (0, import_utils42.arrayify)(masterKey.slice(0, 32))
10110
9596
  });
10111
9597
  }
10112
9598
  static fromExtendedKey(extendedKey) {
10113
- const decoded = (0, import_utils43.hexlify)((0, import_math22.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
10114
- const bytes = (0, import_utils43.arrayify)(decoded);
9599
+ const decoded = (0, import_utils42.hexlify)((0, import_math22.toBytes)((0, import_utils42.decodeBase58)(extendedKey)));
9600
+ const bytes = (0, import_utils42.arrayify)(decoded);
10115
9601
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10116
9602
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10117
- throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9603
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10118
9604
  }
10119
9605
  if (!validChecksum) {
10120
- throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9606
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10121
9607
  }
10122
9608
  const depth = bytes[4];
10123
- const parentFingerprint = (0, import_utils43.hexlify)(bytes.slice(5, 9));
10124
- const index = parseInt((0, import_utils43.hexlify)(bytes.slice(9, 13)).substring(2), 16);
10125
- const chainCode = (0, import_utils43.hexlify)(bytes.slice(13, 45));
9609
+ const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
9610
+ const index = parseInt((0, import_utils42.hexlify)(bytes.slice(9, 13)).substring(2), 16);
9611
+ const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
10126
9612
  const key = bytes.slice(45, 78);
10127
9613
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10128
- throw new import_errors25.FuelError(
10129
- import_errors25.ErrorCode.HD_WALLET_ERROR,
9614
+ throw new import_errors26.FuelError(
9615
+ import_errors26.ErrorCode.HD_WALLET_ERROR,
10130
9616
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10131
9617
  );
10132
9618
  }
10133
9619
  if (isPublicExtendedKey(bytes)) {
10134
9620
  if (key[0] !== 3) {
10135
- throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
9621
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10136
9622
  }
10137
9623
  return new HDWallet({
10138
9624
  publicKey: key,
@@ -10143,7 +9629,7 @@ var HDWallet = class {
10143
9629
  });
10144
9630
  }
10145
9631
  if (key[0] !== 0) {
10146
- throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
9632
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10147
9633
  }
10148
9634
  return new HDWallet({
10149
9635
  privateKey: key.slice(1),
@@ -10323,14 +9809,14 @@ var WalletsConfig = class {
10323
9809
  constructor(baseAssetId, config) {
10324
9810
  WalletsConfig.validate(config);
10325
9811
  this.options = config;
10326
- const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
9812
+ const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
10327
9813
  this.wallets = this.generateWallets();
10328
9814
  this.initialState = {
10329
9815
  messages: WalletsConfig.createMessages(this.wallets, messages),
10330
9816
  coins: WalletsConfig.createCoins(
10331
9817
  this.wallets,
10332
9818
  baseAssetId,
10333
- assets2,
9819
+ assets,
10334
9820
  coinsPerAsset,
10335
9821
  amountPerCoin
10336
9822
  )
@@ -10340,7 +9826,7 @@ var WalletsConfig = class {
10340
9826
  return {
10341
9827
  ...snapshotConfig,
10342
9828
  stateConfig: {
10343
- ...snapshotConfig?.stateConfig ?? import_utils44.defaultSnapshotConfigs.stateConfig,
9829
+ ...snapshotConfig?.stateConfig ?? import_utils43.defaultSnapshotConfigs.stateConfig,
10344
9830
  coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
10345
9831
  messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
10346
9832
  }
@@ -10355,25 +9841,25 @@ var WalletsConfig = class {
10355
9841
  /**
10356
9842
  * Create coins for the wallets in the format that the chain expects.
10357
9843
  */
10358
- static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
9844
+ static createCoins(wallets, baseAssetId, assets, coinsPerAsset, amountPerCoin) {
10359
9845
  const coins = [];
10360
9846
  let assetIds = [baseAssetId];
10361
- if (Array.isArray(assets2)) {
10362
- assetIds = assetIds.concat(assets2.map((a) => a.value));
9847
+ if (Array.isArray(assets)) {
9848
+ assetIds = assetIds.concat(assets.map((a) => a.value));
10363
9849
  } else {
10364
- assetIds = assetIds.concat(TestAssetId.random(assets2 - 1).map((a) => a.value));
9850
+ assetIds = assetIds.concat(TestAssetId.random(assets - 1).map((a) => a.value));
10365
9851
  }
10366
9852
  wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
10367
9853
  assetIds.forEach((assetId) => {
10368
9854
  for (let index = 0; index < coinsPerAsset; index++) {
10369
9855
  coins.push({
10370
- amount: amountPerCoin,
9856
+ amount: (0, import_math23.bn)(amountPerCoin).toString(),
10371
9857
  asset_id: assetId,
10372
9858
  owner: walletAddress,
10373
9859
  tx_pointer_block_height: 0,
10374
9860
  tx_pointer_tx_idx: 0,
10375
9861
  output_index: 0,
10376
- tx_id: (0, import_utils44.hexlify)((0, import_crypto9.randomBytes)(32))
9862
+ tx_id: (0, import_utils43.hexlify)((0, import_crypto9.randomBytes)(32))
10377
9863
  });
10378
9864
  }
10379
9865
  });
@@ -10382,31 +9868,31 @@ var WalletsConfig = class {
10382
9868
  }
10383
9869
  static validate({
10384
9870
  count: wallets,
10385
- assets: assets2,
9871
+ assets,
10386
9872
  coinsPerAsset,
10387
9873
  amountPerCoin
10388
9874
  }) {
10389
9875
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
10390
- throw new import_errors26.FuelError(
10391
- import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9876
+ throw new import_errors27.FuelError(
9877
+ import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10392
9878
  "Number of wallets must be greater than zero."
10393
9879
  );
10394
9880
  }
10395
- if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
10396
- throw new import_errors26.FuelError(
10397
- import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9881
+ if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
9882
+ throw new import_errors27.FuelError(
9883
+ import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10398
9884
  "Number of assets per wallet must be greater than zero."
10399
9885
  );
10400
9886
  }
10401
9887
  if (coinsPerAsset <= 0) {
10402
- throw new import_errors26.FuelError(
10403
- import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9888
+ throw new import_errors27.FuelError(
9889
+ import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10404
9890
  "Number of coins per asset must be greater than zero."
10405
9891
  );
10406
9892
  }
10407
- if (amountPerCoin < 0) {
10408
- throw new import_errors26.FuelError(
10409
- import_errors26.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9893
+ if ((0, import_math23.bn)(amountPerCoin).lt(0)) {
9894
+ throw new import_errors27.FuelError(
9895
+ import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10410
9896
  "Amount per coin must be greater than or equal to zero."
10411
9897
  );
10412
9898
  }
@@ -10429,7 +9915,7 @@ async function setupTestProviderAndWallets({
10429
9915
  } = {}) {
10430
9916
  Symbol.dispose ??= Symbol("Symbol.dispose");
10431
9917
  const walletsConfig = new WalletsConfig(
10432
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils45.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
9918
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils44.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
10433
9919
  {
10434
9920
  ...defaultWalletConfigOptions,
10435
9921
  ...walletsConfigOptions
@@ -10439,7 +9925,7 @@ async function setupTestProviderAndWallets({
10439
9925
  loggingEnabled: false,
10440
9926
  ...nodeOptions,
10441
9927
  snapshotConfig: (0, import_ramda10.mergeDeepRight)(
10442
- import_utils45.defaultSnapshotConfigs,
9928
+ import_utils44.defaultSnapshotConfigs,
10443
9929
  walletsConfig.apply(nodeOptions?.snapshotConfig)
10444
9930
  ),
10445
9931
  port: nodeOptions.port || "0"
@@ -10459,7 +9945,8 @@ async function setupTestProviderAndWallets({
10459
9945
  }
10460
9946
  let provider;
10461
9947
  try {
10462
- provider = await Provider.create(url, providerOptions);
9948
+ provider = new Provider(url, providerOptions);
9949
+ await provider.init();
10463
9950
  } catch (err) {
10464
9951
  cleanup();
10465
9952
  throw err;
@@ -10479,8 +9966,8 @@ async function setupTestProviderAndWallets({
10479
9966
  // src/test-utils/test-message.ts
10480
9967
  var import_address8 = require("@fuel-ts/address");
10481
9968
  var import_crypto10 = require("@fuel-ts/crypto");
10482
- var import_math23 = require("@fuel-ts/math");
10483
- var import_utils46 = require("@fuel-ts/utils");
9969
+ var import_math24 = require("@fuel-ts/math");
9970
+ var import_utils45 = require("@fuel-ts/utils");
10484
9971
  var TestMessage = class {
10485
9972
  sender;
10486
9973
  recipient;
@@ -10497,7 +9984,7 @@ var TestMessage = class {
10497
9984
  constructor({
10498
9985
  sender = import_address8.Address.fromRandom(),
10499
9986
  recipient = import_address8.Address.fromRandom(),
10500
- nonce = (0, import_utils46.hexlify)((0, import_crypto10.randomBytes)(32)),
9987
+ nonce = (0, import_utils45.hexlify)((0, import_crypto10.randomBytes)(32)),
10501
9988
  amount = 1e6,
10502
9989
  data = "",
10503
9990
  // Will default to empty data in order to be a spendable message
@@ -10516,7 +10003,7 @@ var TestMessage = class {
10516
10003
  sender: this.sender.toB256(),
10517
10004
  recipient: recipient?.toB256() ?? this.recipient.toB256(),
10518
10005
  nonce: this.nonce,
10519
- amount: (0, import_math23.bn)(this.amount).toNumber(),
10006
+ amount: (0, import_math24.bn)(this.amount).toNumber(),
10520
10007
  data,
10521
10008
  da_height: this.da_height
10522
10009
  };