@fuel-ts/account 0.94.3 → 0.94.5

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 (36) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +391 -436
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +345 -195
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +427 -285
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/__generated__/operations.d.ts +250 -0
  10. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  11. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  12. package/dist/providers/message.d.ts +3 -0
  13. package/dist/providers/message.d.ts.map +1 -1
  14. package/dist/providers/provider.d.ts +36 -3
  15. package/dist/providers/provider.d.ts.map +1 -1
  16. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/helpers.d.ts +2 -0
  19. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/transaction-request.d.ts +4 -2
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
  24. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  25. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
  26. package/dist/providers/utils/handle-gql-error-message.d.ts +6 -0
  27. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -0
  28. package/dist/providers/utils/receipts.d.ts.map +1 -1
  29. package/dist/test-utils/launchNode.d.ts.map +1 -1
  30. package/dist/test-utils.global.js +235 -286
  31. package/dist/test-utils.global.js.map +1 -1
  32. package/dist/test-utils.js +300 -162
  33. package/dist/test-utils.js.map +1 -1
  34. package/dist/test-utils.mjs +372 -239
  35. package/dist/test-utils.mjs.map +1 -1
  36. package/package.json +16 -16
package/dist/index.mjs CHANGED
@@ -31,11 +31,12 @@ var __privateMethod = (obj, member, method) => {
31
31
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
32
32
  import { Address as Address3 } from "@fuel-ts/address";
33
33
  import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
34
- import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
34
+ import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
35
35
  import { AbstractAccount } from "@fuel-ts/interfaces";
36
36
  import { bn as bn19 } from "@fuel-ts/math";
37
- import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined3 } from "@fuel-ts/utils";
38
- import { clone as clone4 } from "ramda";
37
+ import { InputType as InputType8 } from "@fuel-ts/transactions";
38
+ import { arrayify as arrayify14, hexlify as hexlify14, isDefined as isDefined3 } from "@fuel-ts/utils";
39
+ import { clone as clone7 } from "ramda";
39
40
 
40
41
  // src/providers/coin-quantity.ts
41
42
  import { bn } from "@fuel-ts/math";
@@ -74,14 +75,15 @@ var addAmountToCoinQuantities = (params) => {
74
75
 
75
76
  // src/providers/provider.ts
76
77
  import { Address as Address2 } from "@fuel-ts/address";
77
- import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
78
+ import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
78
79
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
79
- import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
80
- import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
80
+ import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
81
+ import { arrayify as arrayify11, hexlify as hexlify13, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
81
82
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
82
83
  import { equalBytes } from "@noble/curves/abstract/utils";
83
84
  import { GraphQLClient } from "graphql-request";
84
- import { clone as clone3 } from "ramda";
85
+ import gql2 from "graphql-tag";
86
+ import { clone as clone6 } from "ramda";
85
87
 
86
88
  // src/providers/__generated__/operations.ts
87
89
  import gql from "graphql-tag";
@@ -414,6 +416,14 @@ var BlockFragmentDoc = gql`
414
416
  height
415
417
  header {
416
418
  time
419
+ daHeight
420
+ stateTransitionBytecodeVersion
421
+ transactionsCount
422
+ transactionsRoot
423
+ messageOutboxRoot
424
+ eventInboxRoot
425
+ prevRoot
426
+ applicationHash
417
427
  }
418
428
  transactions {
419
429
  id
@@ -1021,6 +1031,13 @@ var SubmitAndAwaitDocument = gql`
1021
1031
  }
1022
1032
  }
1023
1033
  ${TransactionStatusSubscriptionFragmentDoc}`;
1034
+ var SubmitAndAwaitStatusDocument = gql`
1035
+ subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
1036
+ submitAndAwaitStatus(tx: $encodedTransaction) {
1037
+ ...transactionStatusSubscriptionFragment
1038
+ }
1039
+ }
1040
+ ${TransactionStatusSubscriptionFragmentDoc}`;
1024
1041
  var StatusChangeDocument = gql`
1025
1042
  subscription statusChange($transactionId: TransactionId!) {
1026
1043
  statusChange(id: $transactionId) {
@@ -1117,6 +1134,9 @@ function getSdk(requester) {
1117
1134
  submitAndAwait(variables, options) {
1118
1135
  return requester(SubmitAndAwaitDocument, variables, options);
1119
1136
  },
1137
+ submitAndAwaitStatus(variables, options) {
1138
+ return requester(SubmitAndAwaitStatusDocument, variables, options);
1139
+ },
1120
1140
  statusChange(variables, options) {
1121
1141
  return requester(StatusChangeDocument, variables, options);
1122
1142
  }
@@ -1143,7 +1163,9 @@ var _FuelGraphqlSubscriber = class {
1143
1163
  Accept: "text/event-stream"
1144
1164
  }
1145
1165
  });
1146
- return new _FuelGraphqlSubscriber(response.body.getReader());
1166
+ const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
1167
+ await new _FuelGraphqlSubscriber(errorReader).next();
1168
+ return new _FuelGraphqlSubscriber(resultReader);
1147
1169
  }
1148
1170
  events = [];
1149
1171
  parsingLeftover = "";
@@ -1186,10 +1208,8 @@ var _FuelGraphqlSubscriber = class {
1186
1208
  /**
1187
1209
  * Gets called when `break` is called in a `for-await-of` loop.
1188
1210
  */
1189
- async return() {
1190
- await this.stream.cancel();
1191
- this.stream.releaseLock();
1192
- return { done: true, value: void 0 };
1211
+ return() {
1212
+ return Promise.resolve({ done: true, value: void 0 });
1193
1213
  }
1194
1214
  [Symbol.asyncIterator]() {
1195
1215
  return this;
@@ -1406,7 +1426,10 @@ import {
1406
1426
  OutputType as OutputType2,
1407
1427
  TransactionType
1408
1428
  } from "@fuel-ts/transactions";
1409
- import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
1429
+ import { concat, hexlify as hexlify8, isDefined } from "@fuel-ts/utils";
1430
+
1431
+ // src/providers/message.ts
1432
+ var isMessageCoin = (message) => !("data" in message);
1410
1433
 
1411
1434
  // src/providers/resource.ts
1412
1435
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1418,14 +1441,9 @@ var isMessage = (resource) => "recipient" in resource;
1418
1441
  import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
1419
1442
  import { ErrorCode as ErrorCode5, FuelError as FuelError5 } from "@fuel-ts/errors";
1420
1443
  import { bn as bn4 } from "@fuel-ts/math";
1421
- import {
1422
- ReceiptBurnCoder,
1423
- ReceiptMessageOutCoder,
1424
- ReceiptMintCoder,
1425
- ReceiptType
1426
- } from "@fuel-ts/transactions";
1444
+ import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
1427
1445
  import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
1428
- import { arrayify as arrayify2 } from "@fuel-ts/utils";
1446
+ import { arrayify as arrayify2, hexlify as hexlify5 } from "@fuel-ts/utils";
1429
1447
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1430
1448
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1431
1449
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
@@ -1571,12 +1589,12 @@ function assembleReceiptByType(receipt) {
1571
1589
  const amount = bn4(receipt.amount);
1572
1590
  const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
1573
1591
  const digest = hexOrZero(receipt.digest);
1574
- const messageId = ReceiptMessageOutCoder.getMessageId({
1592
+ const messageId = InputMessageCoder.getMessageId({
1575
1593
  sender,
1576
1594
  recipient,
1577
1595
  nonce,
1578
1596
  amount,
1579
- data
1597
+ data: hexlify5(data)
1580
1598
  });
1581
1599
  const receiptMessageOut = {
1582
1600
  type: ReceiptType.MessageOut,
@@ -1593,7 +1611,7 @@ function assembleReceiptByType(receipt) {
1593
1611
  case "MINT" /* Mint */: {
1594
1612
  const contractId = hexOrZero(receipt.id || receipt.contractId);
1595
1613
  const subId = hexOrZero(receipt.subId);
1596
- const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
1614
+ const assetId = getMintedAssetId(contractId, subId);
1597
1615
  const mintReceipt = {
1598
1616
  type: ReceiptType.Mint,
1599
1617
  subId,
@@ -1608,7 +1626,7 @@ function assembleReceiptByType(receipt) {
1608
1626
  case "BURN" /* Burn */: {
1609
1627
  const contractId = hexOrZero(receipt.id || receipt.contractId);
1610
1628
  const subId = hexOrZero(receipt.subId);
1611
- const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
1629
+ const assetId = getMintedAssetId(contractId, subId);
1612
1630
  const burnReceipt = {
1613
1631
  type: ReceiptType.Burn,
1614
1632
  subId,
@@ -1793,13 +1811,13 @@ var calculateGasFee = (params) => {
1793
1811
  };
1794
1812
 
1795
1813
  // src/providers/utils/json.ts
1796
- import { hexlify as hexlify5 } from "@fuel-ts/utils";
1814
+ import { hexlify as hexlify6 } from "@fuel-ts/utils";
1797
1815
  import { clone } from "ramda";
1798
1816
  function normalize(object) {
1799
1817
  Object.keys(object).forEach((key) => {
1800
1818
  switch (object[key]?.constructor.name) {
1801
1819
  case "Uint8Array":
1802
- object[key] = hexlify5(object[key]);
1820
+ object[key] = hexlify6(object[key]);
1803
1821
  break;
1804
1822
  case "Array":
1805
1823
  object[key] = normalize(object[key]);
@@ -1857,20 +1875,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
1857
1875
  let reason = "";
1858
1876
  if (revertReceipt) {
1859
1877
  const reasonHex = bn6(revertReceipt.val).toHex();
1878
+ const lastLog = logs[logs.length - 1];
1879
+ const lastButOneLog = logs[logs.length - 2];
1860
1880
  switch (reasonHex) {
1861
1881
  case FAILED_REQUIRE_SIGNAL: {
1862
1882
  reason = "require";
1863
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1883
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
1864
1884
  break;
1865
1885
  }
1866
1886
  case FAILED_ASSERT_EQ_SIGNAL: {
1867
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1887
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
1868
1888
  reason = "assert_eq";
1869
1889
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1870
1890
  break;
1871
1891
  }
1872
1892
  case FAILED_ASSERT_NE_SIGNAL: {
1873
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1893
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
1874
1894
  reason = "assert_ne";
1875
1895
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1876
1896
  break;
@@ -1943,7 +1963,9 @@ import { bn as bn7 } from "@fuel-ts/math";
1943
1963
  import { InputType as InputType2 } from "@fuel-ts/transactions";
1944
1964
  var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1945
1965
  var isRequestInputMessage = (input) => input.type === InputType2.Message;
1946
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1966
+ var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
1967
+ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1968
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
1947
1969
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1948
1970
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1949
1971
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
@@ -1985,11 +2007,11 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
1985
2007
  );
1986
2008
 
1987
2009
  // src/providers/transaction-request/witness.ts
1988
- import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
2010
+ import { arrayify as arrayify4, hexlify as hexlify7 } from "@fuel-ts/utils";
1989
2011
  var witnessify = (value) => {
1990
2012
  const data = arrayify4(value);
1991
2013
  return {
1992
- data: hexlify6(data),
2014
+ data: hexlify7(data),
1993
2015
  dataLength: data.length
1994
2016
  };
1995
2017
  };
@@ -2206,9 +2228,9 @@ var BaseTransactionRequest = class {
2206
2228
  const found = this.inputs.find((input) => {
2207
2229
  switch (input.type) {
2208
2230
  case InputType3.Coin:
2209
- return hexlify7(input.owner) === ownerAddress.toB256();
2231
+ return hexlify8(input.owner) === ownerAddress.toB256();
2210
2232
  case InputType3.Message:
2211
- return hexlify7(input.recipient) === ownerAddress.toB256();
2233
+ return hexlify8(input.recipient) === ownerAddress.toB256();
2212
2234
  default:
2213
2235
  return false;
2214
2236
  }
@@ -2253,7 +2275,7 @@ var BaseTransactionRequest = class {
2253
2275
  * @param message - Message resource.
2254
2276
  */
2255
2277
  addMessageInput(message) {
2256
- const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2278
+ const { recipient, sender, amount, predicate, nonce, predicateData } = message;
2257
2279
  let witnessIndex;
2258
2280
  if (message.predicate) {
2259
2281
  witnessIndex = 0;
@@ -2268,13 +2290,16 @@ var BaseTransactionRequest = class {
2268
2290
  type: InputType3.Message,
2269
2291
  sender: sender.toB256(),
2270
2292
  recipient: recipient.toB256(),
2293
+ data: isMessageCoin(message) ? "0x" : message.data,
2271
2294
  amount,
2272
2295
  witnessIndex,
2273
2296
  predicate,
2274
2297
  predicateData
2275
2298
  };
2276
2299
  this.pushInput(input);
2277
- this.addChangeOutput(recipient, assetId);
2300
+ if (isMessageCoin(message)) {
2301
+ this.addChangeOutput(recipient, message.assetId);
2302
+ }
2278
2303
  }
2279
2304
  /**
2280
2305
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2343,7 +2368,7 @@ var BaseTransactionRequest = class {
2343
2368
  */
2344
2369
  addChangeOutput(to, assetId) {
2345
2370
  const changeOutput = this.getChangeOutputs().find(
2346
- (output) => hexlify7(output.assetId) === assetId
2371
+ (output) => hexlify8(output.assetId) === assetId
2347
2372
  );
2348
2373
  if (!changeOutput) {
2349
2374
  this.pushOutput({
@@ -2406,6 +2431,8 @@ var BaseTransactionRequest = class {
2406
2431
  *
2407
2432
  * @param quantities - CoinQuantity Array.
2408
2433
  * @param baseAssetId - The base asset to fund the transaction.
2434
+ * @deprecated - This method is deprecated and will be removed in future versions.
2435
+ * Please use `Account.generateFakeResources` along with `this.addResources` instead.
2409
2436
  */
2410
2437
  fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
2411
2438
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2421,12 +2448,12 @@ var BaseTransactionRequest = class {
2421
2448
  usedQuantity = bn8("1000000000000000000");
2422
2449
  }
2423
2450
  if (assetInput && "assetId" in assetInput) {
2424
- assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2451
+ assetInput.id = hexlify8(randomBytes(UTXO_ID_LEN2));
2425
2452
  assetInput.amount = usedQuantity;
2426
2453
  } else {
2427
2454
  this.addResources([
2428
2455
  {
2429
- id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2456
+ id: hexlify8(randomBytes(UTXO_ID_LEN2)),
2430
2457
  amount: usedQuantity,
2431
2458
  assetId,
2432
2459
  owner: resourcesOwner || Address.fromRandom(),
@@ -2474,7 +2501,7 @@ var BaseTransactionRequest = class {
2474
2501
  });
2475
2502
  }
2476
2503
  updatePredicateGasUsed(inputs) {
2477
- const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2504
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
2478
2505
  this.inputs.filter(isRequestInputResource).forEach((i) => {
2479
2506
  const owner = getRequestInputResourceOwner(i);
2480
2507
  const correspondingInput = inputsToExtractGasUsed.find(
@@ -2490,6 +2517,9 @@ var BaseTransactionRequest = class {
2490
2517
  }
2491
2518
  };
2492
2519
 
2520
+ // src/providers/transaction-request/blob-transaction-request.ts
2521
+ import { clone as clone3 } from "ramda";
2522
+
2493
2523
  // src/providers/transaction-request/hash-transaction.ts
2494
2524
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2495
2525
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
@@ -2564,10 +2594,7 @@ function hashTransaction(transactionRequest, chainId) {
2564
2594
  // src/providers/transaction-request/blob-transaction-request.ts
2565
2595
  var BlobTransactionRequest = class extends BaseTransactionRequest {
2566
2596
  static from(obj) {
2567
- if (obj instanceof this) {
2568
- return obj;
2569
- }
2570
- return new this(obj);
2597
+ return new this(clone3(obj));
2571
2598
  }
2572
2599
  /** Type of the transaction */
2573
2600
  type = TransactionType.Blob;
@@ -2629,10 +2656,11 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2629
2656
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2630
2657
  import { bn as bn10 } from "@fuel-ts/math";
2631
2658
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2632
- import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2659
+ import { arrayify as arrayify6, hexlify as hexlify10 } from "@fuel-ts/utils";
2660
+ import { clone as clone4 } from "ramda";
2633
2661
 
2634
2662
  // src/providers/transaction-request/storage-slot.ts
2635
- import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
2663
+ import { arrayify as arrayify5, hexlify as hexlify9 } from "@fuel-ts/utils";
2636
2664
  var getStorageValue = (value) => {
2637
2665
  const v = new Uint8Array(32);
2638
2666
  v.set(arrayify5(value));
@@ -2649,18 +2677,15 @@ var storageSlotify = (storageSlot) => {
2649
2677
  value = storageSlot.value;
2650
2678
  }
2651
2679
  return {
2652
- key: hexlify8(key),
2653
- value: hexlify8(getStorageValue(value))
2680
+ key: hexlify9(key),
2681
+ value: hexlify9(getStorageValue(value))
2654
2682
  };
2655
2683
  };
2656
2684
 
2657
2685
  // src/providers/transaction-request/create-transaction-request.ts
2658
2686
  var CreateTransactionRequest = class extends BaseTransactionRequest {
2659
2687
  static from(obj) {
2660
- if (obj instanceof this) {
2661
- return obj;
2662
- }
2663
- return new this(obj);
2688
+ return new this(clone4(obj));
2664
2689
  }
2665
2690
  /** Type of the transaction */
2666
2691
  type = TransactionType3.Create;
@@ -2678,7 +2703,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2678
2703
  constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2679
2704
  super(rest);
2680
2705
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2681
- this.salt = hexlify9(salt ?? ZeroBytes326);
2706
+ this.salt = hexlify10(salt ?? ZeroBytes326);
2682
2707
  this.storageSlots = [...storageSlots ?? []];
2683
2708
  }
2684
2709
  /**
@@ -2695,7 +2720,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2695
2720
  ...baseTransaction,
2696
2721
  bytecodeWitnessIndex,
2697
2722
  storageSlotsCount: bn10(storageSlots.length),
2698
- salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2723
+ salt: this.salt ? hexlify10(this.salt) : ZeroBytes326,
2699
2724
  storageSlots
2700
2725
  };
2701
2726
  }
@@ -2748,7 +2773,8 @@ import { addressify as addressify2 } from "@fuel-ts/address";
2748
2773
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2749
2774
  import { bn as bn11 } from "@fuel-ts/math";
2750
2775
  import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2751
- import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2776
+ import { arrayify as arrayify8, hexlify as hexlify11 } from "@fuel-ts/utils";
2777
+ import { clone as clone5 } from "ramda";
2752
2778
 
2753
2779
  // src/providers/transaction-request/scripts.ts
2754
2780
  import { arrayify as arrayify7 } from "@fuel-ts/utils";
@@ -2779,10 +2805,7 @@ var withdrawScript = {
2779
2805
  // src/providers/transaction-request/script-transaction-request.ts
2780
2806
  var ScriptTransactionRequest = class extends BaseTransactionRequest {
2781
2807
  static from(obj) {
2782
- if (obj instanceof this) {
2783
- return obj;
2784
- }
2785
- return new this(obj);
2808
+ return new this(clone5(obj));
2786
2809
  }
2787
2810
  /** Type of the transaction */
2788
2811
  type = TransactionType4.Script;
@@ -2820,8 +2843,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2820
2843
  scriptLength: bn11(script.length),
2821
2844
  scriptDataLength: bn11(scriptData.length),
2822
2845
  receiptsRoot: ZeroBytes327,
2823
- script: hexlify10(script),
2824
- scriptData: hexlify10(scriptData)
2846
+ script: hexlify11(script),
2847
+ scriptData: hexlify11(scriptData)
2825
2848
  };
2826
2849
  }
2827
2850
  /**
@@ -2997,7 +3020,7 @@ import { arrayify as arrayify10, assertUnreachable } from "@fuel-ts/utils";
2997
3020
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2998
3021
  import { bn as bn15 } from "@fuel-ts/math";
2999
3022
  import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
3000
- import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
3023
+ import { DateTime, hexlify as hexlify12 } from "@fuel-ts/utils";
3001
3024
 
3002
3025
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
3003
3026
  import { bn as bn12 } from "@fuel-ts/math";
@@ -3760,7 +3783,7 @@ function assembleTransactionSummary(params) {
3760
3783
  baseAssetId
3761
3784
  } = params;
3762
3785
  const gasUsed = getGasUsedFromReceipts(receipts);
3763
- const rawPayload = hexlify11(transactionBytes);
3786
+ const rawPayload = hexlify12(transactionBytes);
3764
3787
  const operations = getOperations({
3765
3788
  transactionType: transaction.type,
3766
3789
  inputs: transaction.inputs || [],
@@ -3869,29 +3892,30 @@ function mapGqlOutputsToTxOutputs(outputs) {
3869
3892
  });
3870
3893
  }
3871
3894
  var TransactionResponse = class {
3872
- /** Transaction ID */
3873
- id;
3874
- /** Current provider */
3875
- provider;
3876
- /** Gas used on the transaction */
3877
- gasUsed = bn16(0);
3878
- /** The graphql Transaction with receipts object. */
3879
- gqlTransaction;
3880
- request;
3881
- status;
3882
- abis;
3883
3895
  /**
3884
3896
  * Constructor for `TransactionResponse`.
3885
3897
  *
3886
3898
  * @param tx - The transaction ID or TransactionRequest.
3887
3899
  * @param provider - The provider.
3888
3900
  */
3889
- constructor(tx, provider, abis) {
3901
+ constructor(tx, provider, abis, submitTxSubscription) {
3902
+ this.submitTxSubscription = submitTxSubscription;
3890
3903
  this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
3891
3904
  this.provider = provider;
3892
3905
  this.abis = abis;
3893
3906
  this.request = typeof tx === "string" ? void 0 : tx;
3894
3907
  }
3908
+ /** Transaction ID */
3909
+ id;
3910
+ /** Current provider */
3911
+ provider;
3912
+ /** Gas used on the transaction */
3913
+ gasUsed = bn16(0);
3914
+ /** The graphql Transaction with receipts object. */
3915
+ gqlTransaction;
3916
+ request;
3917
+ status;
3918
+ abis;
3895
3919
  /**
3896
3920
  * Async constructor for `TransactionResponse`. This method can be used to create
3897
3921
  * an instance of `TransactionResponse` and wait for the transaction to be fetched
@@ -4024,10 +4048,11 @@ var TransactionResponse = class {
4024
4048
  if (status && status !== "SubmittedStatus") {
4025
4049
  return;
4026
4050
  }
4027
- const subscription = await this.provider.operations.statusChange({
4051
+ const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
4028
4052
  transactionId: this.id
4029
4053
  });
4030
- for await (const { statusChange } of subscription) {
4054
+ for await (const sub of subscription) {
4055
+ const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
4031
4056
  this.status = statusChange;
4032
4057
  if (statusChange.type === "SqueezedOutStatus") {
4033
4058
  this.unsetResourceCache();
@@ -4139,6 +4164,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4139
4164
  };
4140
4165
  }
4141
4166
 
4167
+ // src/providers/utils/handle-gql-error-message.ts
4168
+ import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
4169
+ var handleGqlErrorMessage = (errorMessage, rawError) => {
4170
+ switch (errorMessage) {
4171
+ case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4172
+ throw new FuelError14(
4173
+ ErrorCode13.NOT_ENOUGH_FUNDS,
4174
+ `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4175
+ {},
4176
+ rawError
4177
+ );
4178
+ default:
4179
+ throw new FuelError14(ErrorCode13.INVALID_REQUEST, errorMessage);
4180
+ }
4181
+ };
4182
+
4142
4183
  // src/providers/provider.ts
4143
4184
  var MAX_RETRIES = 10;
4144
4185
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4265,6 +4306,17 @@ var _Provider = class {
4265
4306
  return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
4266
4307
  }, retryOptions);
4267
4308
  }
4309
+ static extractBasicAuth(url) {
4310
+ const parsedUrl = new URL(url);
4311
+ const username = parsedUrl.username;
4312
+ const password = parsedUrl.password;
4313
+ const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
4314
+ if (!(username && password)) {
4315
+ return { url, auth: void 0 };
4316
+ }
4317
+ const auth = `Basic ${btoa(`${username}:${password}`)}`;
4318
+ return { url: urlNoBasicAuth, auth };
4319
+ }
4268
4320
  /**
4269
4321
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4270
4322
  *
@@ -4274,7 +4326,17 @@ var _Provider = class {
4274
4326
  * @returns A promise that resolves to a Provider instance.
4275
4327
  */
4276
4328
  static async create(url, options = {}) {
4277
- const provider = new _Provider(url, options);
4329
+ const { url: urlToUse, auth } = this.extractBasicAuth(url);
4330
+ const provider = new _Provider(urlToUse, {
4331
+ ...options,
4332
+ requestMiddleware: async (request) => {
4333
+ if (auth && request) {
4334
+ request.headers ??= {};
4335
+ request.headers.Authorization = auth;
4336
+ }
4337
+ return options.requestMiddleware?.(request) ?? request;
4338
+ }
4339
+ });
4278
4340
  await provider.fetchChainAndNodeInfo();
4279
4341
  return provider;
4280
4342
  }
@@ -4286,8 +4348,8 @@ var _Provider = class {
4286
4348
  getChain() {
4287
4349
  const chain = _Provider.chainInfoCache[this.url];
4288
4350
  if (!chain) {
4289
- throw new FuelError14(
4290
- ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
4351
+ throw new FuelError15(
4352
+ ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
4291
4353
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4292
4354
  );
4293
4355
  }
@@ -4301,8 +4363,8 @@ var _Provider = class {
4301
4363
  getNode() {
4302
4364
  const node = _Provider.nodeInfoCache[this.url];
4303
4365
  if (!node) {
4304
- throw new FuelError14(
4305
- ErrorCode13.NODE_INFO_CACHE_EMPTY,
4366
+ throw new FuelError15(
4367
+ ErrorCode14.NODE_INFO_CACHE_EMPTY,
4306
4368
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4307
4369
  );
4308
4370
  }
@@ -4380,10 +4442,9 @@ Supported fuel-core version: ${supportedVersion}.`
4380
4442
  if ("response" in response) {
4381
4443
  const graphQlResponse = response.response;
4382
4444
  if (Array.isArray(graphQlResponse?.errors)) {
4383
- throw new FuelError14(
4384
- FuelError14.CODES.INVALID_REQUEST,
4385
- graphQlResponse.errors.map((err) => err.message).join("\n\n")
4386
- );
4445
+ for (const error of graphQlResponse.errors) {
4446
+ handleGqlErrorMessage(error.message, error);
4447
+ }
4387
4448
  }
4388
4449
  }
4389
4450
  }
@@ -4401,7 +4462,26 @@ Supported fuel-core version: ${supportedVersion}.`
4401
4462
  }
4402
4463
  return gqlClient.request(query, vars);
4403
4464
  };
4404
- return getSdk(executeQuery);
4465
+ const customOperations = (requester) => ({
4466
+ getBlobs(variables) {
4467
+ const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
4468
+ const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
4469
+ const updatedVariables = variables.blobIds.reduce(
4470
+ (acc, blobId, i) => {
4471
+ acc[`blobId${i}`] = blobId;
4472
+ return acc;
4473
+ },
4474
+ {}
4475
+ );
4476
+ const document2 = gql2`
4477
+ query getBlobs(${queryParams}) {
4478
+ ${blobParams}
4479
+ }
4480
+ `;
4481
+ return requester(document2, updatedVariables);
4482
+ }
4483
+ });
4484
+ return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
4405
4485
  }
4406
4486
  /**
4407
4487
  * Returns the version of the connected node.
@@ -4476,14 +4556,14 @@ Supported fuel-core version: ${supportedVersion}.`
4476
4556
  validateTransaction(tx, consensusParameters) {
4477
4557
  const { maxOutputs, maxInputs } = consensusParameters.txParameters;
4478
4558
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4479
- throw new FuelError14(
4480
- ErrorCode13.MAX_INPUTS_EXCEEDED,
4559
+ throw new FuelError15(
4560
+ ErrorCode14.MAX_INPUTS_EXCEEDED,
4481
4561
  "The transaction exceeds the maximum allowed number of inputs."
4482
4562
  );
4483
4563
  }
4484
4564
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4485
- throw new FuelError14(
4486
- ErrorCode13.MAX_OUTPUTS_EXCEEDED,
4565
+ throw new FuelError15(
4566
+ ErrorCode14.MAX_OUTPUTS_EXCEEDED,
4487
4567
  "The transaction exceeds the maximum allowed number of outputs."
4488
4568
  );
4489
4569
  }
@@ -4505,16 +4585,14 @@ Supported fuel-core version: ${supportedVersion}.`
4505
4585
  }
4506
4586
  const { consensusParameters } = this.getChain();
4507
4587
  this.validateTransaction(transactionRequest, consensusParameters);
4508
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4588
+ const encodedTransaction = hexlify13(transactionRequest.toTransactionBytes());
4509
4589
  let abis;
4510
4590
  if (isTransactionTypeScript(transactionRequest)) {
4511
4591
  abis = transactionRequest.abis;
4512
4592
  }
4513
- const {
4514
- submit: { id: transactionId }
4515
- } = await this.operations.submit({ encodedTransaction });
4516
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
4517
- return new TransactionResponse(transactionRequest, this, abis);
4593
+ const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
4594
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
4595
+ return new TransactionResponse(transactionRequest, this, abis, subscription);
4518
4596
  }
4519
4597
  /**
4520
4598
  * Executes a transaction without actually submitting it to the chain.
@@ -4531,7 +4609,7 @@ Supported fuel-core version: ${supportedVersion}.`
4531
4609
  if (estimateTxDependencies) {
4532
4610
  return this.estimateTxDependencies(transactionRequest);
4533
4611
  }
4534
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4612
+ const encodedTransaction = hexlify13(transactionRequest.toTransactionBytes());
4535
4613
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4536
4614
  encodedTransactions: encodedTransaction,
4537
4615
  utxoValidation: utxoValidation || false
@@ -4557,7 +4635,7 @@ Supported fuel-core version: ${supportedVersion}.`
4557
4635
  if (!shouldEstimatePredicates) {
4558
4636
  return transactionRequest;
4559
4637
  }
4560
- const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4638
+ const encodedTransaction = hexlify13(transactionRequest.toTransactionBytes());
4561
4639
  const response = await this.operations.estimatePredicates({
4562
4640
  encodedTransaction
4563
4641
  });
@@ -4598,7 +4676,7 @@ Supported fuel-core version: ${supportedVersion}.`
4598
4676
  const {
4599
4677
  dryRun: [{ receipts: rawReceipts, status }]
4600
4678
  } = await this.operations.dryRun({
4601
- encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
4679
+ encodedTransactions: [hexlify13(transactionRequest.toTransactionBytes())],
4602
4680
  utxoValidation: false
4603
4681
  });
4604
4682
  receipts = rawReceipts.map(processGqlReceipt);
@@ -4644,11 +4722,11 @@ Supported fuel-core version: ${supportedVersion}.`
4644
4722
  missingContractIds: [],
4645
4723
  dryRunStatus: void 0
4646
4724
  }));
4647
- const allRequests = clone3(transactionRequests);
4725
+ const allRequests = clone6(transactionRequests);
4648
4726
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4649
4727
  allRequests.forEach((req, index) => {
4650
4728
  if (isTransactionTypeScript(req)) {
4651
- serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4729
+ serializedTransactionsMap.set(index, hexlify13(req.toTransactionBytes()));
4652
4730
  }
4653
4731
  });
4654
4732
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -4684,7 +4762,7 @@ Supported fuel-core version: ${supportedVersion}.`
4684
4762
  transactionRequest: request
4685
4763
  });
4686
4764
  request.maxFee = maxFee;
4687
- serializedTransactionsMap.set(requestIdx, hexlify12(request.toTransactionBytes()));
4765
+ serializedTransactionsMap.set(requestIdx, hexlify13(request.toTransactionBytes()));
4688
4766
  nextRoundTransactions.push(requestIdx);
4689
4767
  }
4690
4768
  }
@@ -4705,7 +4783,7 @@ Supported fuel-core version: ${supportedVersion}.`
4705
4783
  if (estimateTxDependencies) {
4706
4784
  return this.estimateMultipleTxDependencies(transactionRequests);
4707
4785
  }
4708
- const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
4786
+ const encodedTransactions = transactionRequests.map((tx) => hexlify13(tx.toTransactionBytes()));
4709
4787
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4710
4788
  encodedTransactions,
4711
4789
  utxoValidation: utxoValidation || false
@@ -4779,7 +4857,7 @@ Supported fuel-core version: ${supportedVersion}.`
4779
4857
  if (estimateTxDependencies) {
4780
4858
  return this.estimateTxDependencies(transactionRequest);
4781
4859
  }
4782
- const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
4860
+ const encodedTransactions = [hexlify13(transactionRequest.toTransactionBytes())];
4783
4861
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4784
4862
  encodedTransactions,
4785
4863
  utxoValidation: true
@@ -4804,13 +4882,13 @@ Supported fuel-core version: ${supportedVersion}.`
4804
4882
  * @returns A promise that resolves to the transaction cost object.
4805
4883
  */
4806
4884
  async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
4807
- const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4885
+ const txRequestClone = clone6(transactionRequestify(transactionRequestLike));
4808
4886
  const updateMaxFee = txRequestClone.maxFee.eq(0);
4809
4887
  const isScriptTransaction = isTransactionTypeScript(txRequestClone);
4810
4888
  if (isScriptTransaction) {
4811
4889
  txRequestClone.gasLimit = bn17(0);
4812
4890
  }
4813
- const signedRequest = clone3(txRequestClone);
4891
+ const signedRequest = clone6(txRequestClone);
4814
4892
  let addedSignatures = 0;
4815
4893
  if (signatureCallback && isTransactionTypeScript(signedRequest)) {
4816
4894
  const lengthBefore = signedRequest.witnesses.length;
@@ -4878,7 +4956,7 @@ Supported fuel-core version: ${supportedVersion}.`
4878
4956
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
4879
4957
  inputArgs: paginationArgs
4880
4958
  }),
4881
- filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify12(assetId) }
4959
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify13(assetId) }
4882
4960
  });
4883
4961
  const coins = edges.map(({ node }) => ({
4884
4962
  id: node.utxoId,
@@ -4904,8 +4982,8 @@ Supported fuel-core version: ${supportedVersion}.`
4904
4982
  async getResourcesToSpend(owner, quantities, excludedIds) {
4905
4983
  const ownerAddress = Address2.fromAddressOrString(owner);
4906
4984
  const excludeInput = {
4907
- messages: excludedIds?.messages?.map((nonce) => hexlify12(nonce)) || [],
4908
- utxos: excludedIds?.utxos?.map((id) => hexlify12(id)) || []
4985
+ messages: excludedIds?.messages?.map((nonce) => hexlify13(nonce)) || [],
4986
+ utxos: excludedIds?.utxos?.map((id) => hexlify13(id)) || []
4909
4987
  };
4910
4988
  if (this.cache) {
4911
4989
  const cached = this.cache.getActiveData();
@@ -4915,7 +4993,7 @@ Supported fuel-core version: ${supportedVersion}.`
4915
4993
  const coinsQuery = {
4916
4994
  owner: ownerAddress.toB256(),
4917
4995
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4918
- assetId: hexlify12(assetId),
4996
+ assetId: hexlify13(assetId),
4919
4997
  amount: amount.toString(10),
4920
4998
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4921
4999
  })),
@@ -4948,6 +5026,21 @@ Supported fuel-core version: ${supportedVersion}.`
4948
5026
  }).filter((v) => !!v);
4949
5027
  return coins;
4950
5028
  }
5029
+ /**
5030
+ * Returns an array of blobIds that exist on chain, for a given array of blobIds.
5031
+ *
5032
+ * @param blobIds - blobIds to check.
5033
+ * @returns - A promise that resolves to an array of blobIds that exist on chain.
5034
+ */
5035
+ async getBlobs(blobIds) {
5036
+ const res = await this.operations.getBlobs({ blobIds });
5037
+ const blobs = [];
5038
+ Object.keys(res).forEach((key) => {
5039
+ const val = res[key];
5040
+ blobs.push(val?.id ?? null);
5041
+ });
5042
+ return blobs.filter((v) => v);
5043
+ }
4951
5044
  /**
4952
5045
  * Returns block matching the given ID or height.
4953
5046
  *
@@ -4969,11 +5062,22 @@ Supported fuel-core version: ${supportedVersion}.`
4969
5062
  if (!block) {
4970
5063
  return null;
4971
5064
  }
5065
+ const { header, height, id, transactions } = block;
4972
5066
  return {
4973
- id: block.id,
4974
- height: bn17(block.height),
4975
- time: block.header.time,
4976
- transactionIds: block.transactions.map((tx) => tx.id)
5067
+ id,
5068
+ height: bn17(height),
5069
+ time: header.time,
5070
+ header: {
5071
+ applicationHash: header.applicationHash,
5072
+ daHeight: bn17(header.daHeight),
5073
+ eventInboxRoot: header.eventInboxRoot,
5074
+ messageOutboxRoot: header.messageOutboxRoot,
5075
+ prevRoot: header.prevRoot,
5076
+ stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
5077
+ transactionsCount: header.transactionsCount,
5078
+ transactionsRoot: header.transactionsRoot
5079
+ },
5080
+ transactionIds: transactions.map((tx) => tx.id)
4977
5081
  };
4978
5082
  }
4979
5083
  /**
@@ -4995,6 +5099,16 @@ Supported fuel-core version: ${supportedVersion}.`
4995
5099
  id: block.id,
4996
5100
  height: bn17(block.height),
4997
5101
  time: block.header.time,
5102
+ header: {
5103
+ applicationHash: block.header.applicationHash,
5104
+ daHeight: bn17(block.header.daHeight),
5105
+ eventInboxRoot: block.header.eventInboxRoot,
5106
+ messageOutboxRoot: block.header.messageOutboxRoot,
5107
+ prevRoot: block.header.prevRoot,
5108
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5109
+ transactionsCount: block.header.transactionsCount,
5110
+ transactionsRoot: block.header.transactionsRoot
5111
+ },
4998
5112
  transactionIds: block.transactions.map((tx) => tx.id)
4999
5113
  }));
5000
5114
  return { blocks, pageInfo };
@@ -5022,6 +5136,16 @@ Supported fuel-core version: ${supportedVersion}.`
5022
5136
  id: block.id,
5023
5137
  height: bn17(block.height, 10),
5024
5138
  time: block.header.time,
5139
+ header: {
5140
+ applicationHash: block.header.applicationHash,
5141
+ daHeight: bn17(block.header.daHeight),
5142
+ eventInboxRoot: block.header.eventInboxRoot,
5143
+ messageOutboxRoot: block.header.messageOutboxRoot,
5144
+ prevRoot: block.header.prevRoot,
5145
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5146
+ transactionsCount: block.header.transactionsCount,
5147
+ transactionsRoot: block.header.transactionsRoot
5148
+ },
5025
5149
  transactionIds: block.transactions.map((tx) => tx.id),
5026
5150
  transactions: block.transactions.map(
5027
5151
  (tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
@@ -5045,7 +5169,7 @@ Supported fuel-core version: ${supportedVersion}.`
5045
5169
  0
5046
5170
  )?.[0];
5047
5171
  } catch (error) {
5048
- if (error instanceof FuelError14 && error.code === ErrorCode13.UNSUPPORTED_TRANSACTION_TYPE) {
5172
+ if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5049
5173
  console.warn("Unsupported transaction type encountered");
5050
5174
  return null;
5051
5175
  }
@@ -5066,7 +5190,7 @@ Supported fuel-core version: ${supportedVersion}.`
5066
5190
  try {
5067
5191
  return coder.decode(arrayify11(rawPayload), 0)[0];
5068
5192
  } catch (error) {
5069
- if (error instanceof FuelError14 && error.code === ErrorCode13.UNSUPPORTED_TRANSACTION_TYPE) {
5193
+ if (error instanceof FuelError15 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5070
5194
  console.warn("Unsupported transaction type encountered");
5071
5195
  return null;
5072
5196
  }
@@ -5098,7 +5222,7 @@ Supported fuel-core version: ${supportedVersion}.`
5098
5222
  async getContractBalance(contractId, assetId) {
5099
5223
  const { contractBalance } = await this.operations.getContractBalance({
5100
5224
  contract: Address2.fromAddressOrString(contractId).toB256(),
5101
- asset: hexlify12(assetId)
5225
+ asset: hexlify13(assetId)
5102
5226
  });
5103
5227
  return bn17(contractBalance.amount, 10);
5104
5228
  }
@@ -5112,7 +5236,7 @@ Supported fuel-core version: ${supportedVersion}.`
5112
5236
  async getBalance(owner, assetId) {
5113
5237
  const { balance } = await this.operations.getBalance({
5114
5238
  owner: Address2.fromAddressOrString(owner).toB256(),
5115
- assetId: hexlify12(assetId)
5239
+ assetId: hexlify13(assetId)
5116
5240
  });
5117
5241
  return bn17(balance.amount, 10);
5118
5242
  }
@@ -5158,7 +5282,7 @@ Supported fuel-core version: ${supportedVersion}.`
5158
5282
  owner: Address2.fromAddressOrString(address).toB256()
5159
5283
  });
5160
5284
  const messages = edges.map(({ node }) => ({
5161
- messageId: InputMessageCoder.getMessageId({
5285
+ messageId: InputMessageCoder2.getMessageId({
5162
5286
  sender: node.sender,
5163
5287
  recipient: node.recipient,
5164
5288
  nonce: node.nonce,
@@ -5169,7 +5293,7 @@ Supported fuel-core version: ${supportedVersion}.`
5169
5293
  recipient: Address2.fromAddressOrString(node.recipient),
5170
5294
  nonce: node.nonce,
5171
5295
  amount: bn17(node.amount),
5172
- data: InputMessageCoder.decodeData(node.data),
5296
+ data: InputMessageCoder2.decodeData(node.data),
5173
5297
  daHeight: bn17(node.daHeight)
5174
5298
  }));
5175
5299
  return {
@@ -5192,8 +5316,8 @@ Supported fuel-core version: ${supportedVersion}.`
5192
5316
  nonce
5193
5317
  };
5194
5318
  if (commitBlockId && commitBlockHeight) {
5195
- throw new FuelError14(
5196
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5319
+ throw new FuelError15(
5320
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5197
5321
  "commitBlockId and commitBlockHeight cannot be used together"
5198
5322
  );
5199
5323
  }
@@ -5333,10 +5457,25 @@ Supported fuel-core version: ${supportedVersion}.`
5333
5457
  * @returns A promise that resolves to the Message object or null.
5334
5458
  */
5335
5459
  async getMessageByNonce(nonce) {
5336
- const { message } = await this.operations.getMessageByNonce({ nonce });
5337
- if (!message) {
5460
+ const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
5461
+ if (!rawMessage) {
5338
5462
  return null;
5339
5463
  }
5464
+ const message = {
5465
+ messageId: InputMessageCoder2.getMessageId({
5466
+ sender: rawMessage.sender,
5467
+ recipient: rawMessage.recipient,
5468
+ nonce: rawMessage.nonce,
5469
+ amount: bn17(rawMessage.amount),
5470
+ data: rawMessage.data
5471
+ }),
5472
+ sender: Address2.fromAddressOrString(rawMessage.sender),
5473
+ recipient: Address2.fromAddressOrString(rawMessage.recipient),
5474
+ nonce: rawMessage.nonce,
5475
+ amount: bn17(rawMessage.amount),
5476
+ data: InputMessageCoder2.decodeData(rawMessage.data),
5477
+ daHeight: bn17(rawMessage.daHeight)
5478
+ };
5340
5479
  return message;
5341
5480
  }
5342
5481
  /**
@@ -5361,26 +5500,26 @@ Supported fuel-core version: ${supportedVersion}.`
5361
5500
  const { paginationLimit, inputArgs = {} } = params;
5362
5501
  const { first, last, after, before } = inputArgs;
5363
5502
  if (after && before) {
5364
- throw new FuelError14(
5365
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5503
+ throw new FuelError15(
5504
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5366
5505
  'Pagination arguments "after" and "before" cannot be used together'
5367
5506
  );
5368
5507
  }
5369
5508
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5370
- throw new FuelError14(
5371
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5509
+ throw new FuelError15(
5510
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5372
5511
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
5373
5512
  );
5374
5513
  }
5375
5514
  if (first && before) {
5376
- throw new FuelError14(
5377
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5515
+ throw new FuelError15(
5516
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5378
5517
  'The use of pagination argument "first" with "before" is not supported'
5379
5518
  );
5380
5519
  }
5381
5520
  if (last && after) {
5382
- throw new FuelError14(
5383
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5521
+ throw new FuelError15(
5522
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5384
5523
  'The use of pagination argument "last" with "after" is not supported'
5385
5524
  );
5386
5525
  }
@@ -5434,7 +5573,7 @@ __publicField(Provider, "chainInfoCache", {});
5434
5573
  __publicField(Provider, "nodeInfoCache", {});
5435
5574
 
5436
5575
  // src/providers/transaction-summary/get-transaction-summary.ts
5437
- import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
5576
+ import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
5438
5577
  import { bn as bn18 } from "@fuel-ts/math";
5439
5578
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5440
5579
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
@@ -5444,8 +5583,8 @@ async function getTransactionSummary(params) {
5444
5583
  transactionId: id
5445
5584
  });
5446
5585
  if (!gqlTransaction) {
5447
- throw new FuelError15(
5448
- ErrorCode14.TRANSACTION_NOT_FOUND,
5586
+ throw new FuelError16(
5587
+ ErrorCode15.TRANSACTION_NOT_FOUND,
5449
5588
  `Transaction not found for given id: ${id}.`
5450
5589
  );
5451
5590
  }
@@ -5771,7 +5910,7 @@ var Account = class extends AbstractAccount {
5771
5910
  */
5772
5911
  get provider() {
5773
5912
  if (!this._provider) {
5774
- throw new FuelError16(ErrorCode15.MISSING_PROVIDER, "Provider not set");
5913
+ throw new FuelError17(ErrorCode16.MISSING_PROVIDER, "Provider not set");
5775
5914
  }
5776
5915
  return this._provider;
5777
5916
  }
@@ -5889,7 +6028,7 @@ var Account = class extends AbstractAccount {
5889
6028
  );
5890
6029
  request.addResources(resources);
5891
6030
  request.updatePredicateGasUsed(estimatedPredicates);
5892
- const requestToReestimate2 = clone4(request);
6031
+ const requestToReestimate2 = clone7(request);
5893
6032
  if (addedSignatures) {
5894
6033
  Array.from({ length: addedSignatures }).forEach(
5895
6034
  () => requestToReestimate2.addEmptyWitness()
@@ -5904,7 +6043,7 @@ var Account = class extends AbstractAccount {
5904
6043
  gasPrice
5905
6044
  });
5906
6045
  const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5907
- request.inputs,
6046
+ request.inputs.filter(isRequestInputResource),
5908
6047
  baseAssetId,
5909
6048
  baseAssetId
5910
6049
  );
@@ -5922,13 +6061,13 @@ var Account = class extends AbstractAccount {
5922
6061
  fundingAttempts += 1;
5923
6062
  }
5924
6063
  if (needsToBeFunded) {
5925
- throw new FuelError16(
5926
- ErrorCode15.NOT_ENOUGH_FUNDS,
6064
+ throw new FuelError17(
6065
+ ErrorCode16.NOT_ENOUGH_FUNDS,
5927
6066
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
5928
6067
  );
5929
6068
  }
5930
6069
  request.updatePredicateGasUsed(estimatedPredicates);
5931
- const requestToReestimate = clone4(request);
6070
+ const requestToReestimate = clone7(request);
5932
6071
  if (addedSignatures) {
5933
6072
  Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5934
6073
  }
@@ -6028,8 +6167,8 @@ var Account = class extends AbstractAccount {
6028
6167
  */
6029
6168
  async transferToContract(contractId, amount, assetId, txParams = {}) {
6030
6169
  if (bn19(amount).lte(0)) {
6031
- throw new FuelError16(
6032
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
6170
+ throw new FuelError17(
6171
+ ErrorCode16.INVALID_TRANSFER_AMOUNT,
6033
6172
  "Transfer amount must be a positive number."
6034
6173
  );
6035
6174
  }
@@ -6104,16 +6243,16 @@ var Account = class extends AbstractAccount {
6104
6243
  * @returns A promise that resolves to the transaction cost object.
6105
6244
  */
6106
6245
  async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
6107
- const txRequestClone = clone4(transactionRequestify(transactionRequestLike));
6246
+ const txRequestClone = clone7(transactionRequestify(transactionRequestLike));
6108
6247
  const baseAssetId = this.provider.getBaseAssetId();
6109
6248
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
6110
6249
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
6111
6250
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
6112
6251
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
6113
- if ("assetId" in input) {
6252
+ if (input.type === InputType8.Coin) {
6114
6253
  return input.assetId === assetId;
6115
6254
  }
6116
- if ("recipient" in input) {
6255
+ if (isRequestInputMessageWithoutData(input)) {
6117
6256
  return baseAssetId === assetId;
6118
6257
  }
6119
6258
  return false;
@@ -6155,7 +6294,7 @@ var Account = class extends AbstractAccount {
6155
6294
  */
6156
6295
  async signMessage(message) {
6157
6296
  if (!this._connector) {
6158
- throw new FuelError16(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
6297
+ throw new FuelError17(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
6159
6298
  }
6160
6299
  return this._connector.signMessage(this.address.toString(), message);
6161
6300
  }
@@ -6167,8 +6306,8 @@ var Account = class extends AbstractAccount {
6167
6306
  */
6168
6307
  async signTransaction(transactionRequestLike) {
6169
6308
  if (!this._connector) {
6170
- throw new FuelError16(
6171
- ErrorCode15.MISSING_CONNECTOR,
6309
+ throw new FuelError17(
6310
+ ErrorCode16.MISSING_CONNECTOR,
6172
6311
  "A connector is required to sign transactions."
6173
6312
  );
6174
6313
  }
@@ -6217,7 +6356,7 @@ var Account = class extends AbstractAccount {
6217
6356
  */
6218
6357
  generateFakeResources(coins) {
6219
6358
  return coins.map((coin) => ({
6220
- id: hexlify13(randomBytes2(UTXO_ID_LEN3)),
6359
+ id: hexlify14(randomBytes2(UTXO_ID_LEN3)),
6221
6360
  owner: this.address,
6222
6361
  blockCreated: bn19(1),
6223
6362
  txCreatedIdx: bn19(1),
@@ -6227,8 +6366,8 @@ var Account = class extends AbstractAccount {
6227
6366
  /** @hidden * */
6228
6367
  validateTransferAmount(amount) {
6229
6368
  if (bn19(amount).lte(0)) {
6230
- throw new FuelError16(
6231
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
6369
+ throw new FuelError17(
6370
+ ErrorCode16.INVALID_TRANSFER_AMOUNT,
6232
6371
  "Transfer amount must be a positive number."
6233
6372
  );
6234
6373
  }
@@ -6257,16 +6396,16 @@ var Account = class extends AbstractAccount {
6257
6396
  if (!isDefined3(setGasLimit)) {
6258
6397
  request.gasLimit = gasUsed;
6259
6398
  } else if (gasUsed.gt(setGasLimit)) {
6260
- throw new FuelError16(
6261
- ErrorCode15.GAS_LIMIT_TOO_LOW,
6399
+ throw new FuelError17(
6400
+ ErrorCode16.GAS_LIMIT_TOO_LOW,
6262
6401
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
6263
6402
  );
6264
6403
  }
6265
6404
  if (!isDefined3(setMaxFee)) {
6266
6405
  request.maxFee = maxFee;
6267
6406
  } else if (maxFee.gt(setMaxFee)) {
6268
- throw new FuelError16(
6269
- ErrorCode15.MAX_FEE_TOO_LOW,
6407
+ throw new FuelError17(
6408
+ ErrorCode16.MAX_FEE_TOO_LOW,
6270
6409
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
6271
6410
  );
6272
6411
  }
@@ -6276,14 +6415,14 @@ var Account = class extends AbstractAccount {
6276
6415
 
6277
6416
  // src/wallet/base-wallet-unlocked.ts
6278
6417
  import { hashMessage } from "@fuel-ts/hasher";
6279
- import { hexlify as hexlify16 } from "@fuel-ts/utils";
6418
+ import { hexlify as hexlify17 } from "@fuel-ts/utils";
6280
6419
 
6281
6420
  // src/signer/signer.ts
6282
6421
  import { Address as Address4 } from "@fuel-ts/address";
6283
6422
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
6284
6423
  import { hash } from "@fuel-ts/hasher";
6285
6424
  import { toBytes } from "@fuel-ts/math";
6286
- import { hexlify as hexlify14, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
6425
+ import { hexlify as hexlify15, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
6287
6426
  import { secp256k1 } from "@noble/curves/secp256k1";
6288
6427
  var Signer = class {
6289
6428
  address;
@@ -6303,9 +6442,9 @@ var Signer = class {
6303
6442
  }
6304
6443
  }
6305
6444
  const privateKeyBytes = toBytes(privateKey, 32);
6306
- this.privateKey = hexlify14(privateKeyBytes);
6307
- this.publicKey = hexlify14(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
6308
- this.compressedPublicKey = hexlify14(secp256k1.getPublicKey(privateKeyBytes, true));
6445
+ this.privateKey = hexlify15(privateKeyBytes);
6446
+ this.publicKey = hexlify15(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
6447
+ this.compressedPublicKey = hexlify15(secp256k1.getPublicKey(privateKeyBytes, true));
6309
6448
  this.address = Address4.fromPublicKey(this.publicKey);
6310
6449
  }
6311
6450
  /**
@@ -6323,7 +6462,7 @@ var Signer = class {
6323
6462
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
6324
6463
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
6325
6464
  s[0] |= (signature.recovery || 0) << 7;
6326
- return hexlify14(concat3([r, s]));
6465
+ return hexlify15(concat3([r, s]));
6327
6466
  }
6328
6467
  /**
6329
6468
  * Add point on the current elliptic curve
@@ -6350,11 +6489,11 @@ var Signer = class {
6350
6489
  const s = signedMessageBytes.slice(32, 64);
6351
6490
  const recoveryParam = (s[0] & 128) >> 7;
6352
6491
  s[0] &= 127;
6353
- const sig = new secp256k1.Signature(BigInt(hexlify14(r)), BigInt(hexlify14(s))).addRecoveryBit(
6492
+ const sig = new secp256k1.Signature(BigInt(hexlify15(r)), BigInt(hexlify15(s))).addRecoveryBit(
6354
6493
  recoveryParam
6355
6494
  );
6356
6495
  const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
6357
- return hexlify14(publicKey);
6496
+ return hexlify15(publicKey);
6358
6497
  }
6359
6498
  /**
6360
6499
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -6383,7 +6522,7 @@ var Signer = class {
6383
6522
  */
6384
6523
  static extendPublicKey(publicKey) {
6385
6524
  const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
6386
- return hexlify14(point.toRawBytes(false).slice(1));
6525
+ return hexlify15(point.toRawBytes(false).slice(1));
6387
6526
  }
6388
6527
  };
6389
6528
 
@@ -6399,8 +6538,8 @@ import {
6399
6538
  encryptJsonWalletData,
6400
6539
  randomUUID
6401
6540
  } from "@fuel-ts/crypto";
6402
- import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
6403
- import { hexlify as hexlify15 } from "@fuel-ts/utils";
6541
+ import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
6542
+ import { hexlify as hexlify16 } from "@fuel-ts/utils";
6404
6543
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
6405
6544
  var DEFAULT_KDF_PARAMS_R = 8;
6406
6545
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -6476,13 +6615,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6476
6615
  const macHashUint8Array = keccak256(data);
6477
6616
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
6478
6617
  if (mac !== macHash) {
6479
- throw new FuelError17(
6480
- ErrorCode16.INVALID_PASSWORD,
6618
+ throw new FuelError18(
6619
+ ErrorCode17.INVALID_PASSWORD,
6481
6620
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
6482
6621
  );
6483
6622
  }
6484
6623
  const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
6485
- const privateKey = hexlify15(buffer);
6624
+ const privateKey = hexlify16(buffer);
6486
6625
  return privateKey;
6487
6626
  }
6488
6627
 
@@ -6527,7 +6666,7 @@ var BaseWalletUnlocked = class extends Account {
6527
6666
  */
6528
6667
  async signMessage(message) {
6529
6668
  const signedMessage = await this.signer().sign(hashMessage(message));
6530
- return hexlify16(signedMessage);
6669
+ return hexlify17(signedMessage);
6531
6670
  }
6532
6671
  /**
6533
6672
  * Signs a transaction with the wallet's private key.
@@ -6540,7 +6679,7 @@ var BaseWalletUnlocked = class extends Account {
6540
6679
  const chainId = this.provider.getChainId();
6541
6680
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
6542
6681
  const signature = await this.signer().sign(hashedTransaction);
6543
- return hexlify16(signature);
6682
+ return hexlify17(signature);
6544
6683
  }
6545
6684
  /**
6546
6685
  * Populates a transaction with the witnesses signature.
@@ -6607,16 +6746,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6607
6746
 
6608
6747
  // src/hdwallet/hdwallet.ts
6609
6748
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
6610
- import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
6749
+ import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
6611
6750
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
6612
6751
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
6613
- import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
6752
+ import { arrayify as arrayify18, hexlify as hexlify19, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
6614
6753
 
6615
6754
  // src/mnemonic/mnemonic.ts
6616
6755
  import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
6617
- import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
6756
+ import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
6618
6757
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
6619
- import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
6758
+ import { arrayify as arrayify17, hexlify as hexlify18, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
6620
6759
 
6621
6760
  // src/wordlists/words/english.ts
6622
6761
  var english = [
@@ -8677,7 +8816,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
8677
8816
  })(Language || {});
8678
8817
 
8679
8818
  // src/mnemonic/utils.ts
8680
- import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
8819
+ import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
8681
8820
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
8682
8821
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
8683
8822
  function getLowerMask(bits) {
@@ -8726,8 +8865,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8726
8865
  for (let i = 0; i < words.length; i += 1) {
8727
8866
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
8728
8867
  if (index === -1) {
8729
- throw new FuelError18(
8730
- ErrorCode17.INVALID_MNEMONIC,
8868
+ throw new FuelError19(
8869
+ ErrorCode18.INVALID_MNEMONIC,
8731
8870
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
8732
8871
  );
8733
8872
  }
@@ -8743,8 +8882,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8743
8882
  const checksumMask = getUpperMask(checksumBits);
8744
8883
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8745
8884
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8746
- throw new FuelError18(
8747
- ErrorCode17.INVALID_CHECKSUM,
8885
+ throw new FuelError19(
8886
+ ErrorCode18.INVALID_CHECKSUM,
8748
8887
  "Checksum validation failed for the provided mnemonic."
8749
8888
  );
8750
8889
  }
@@ -8758,16 +8897,16 @@ var TestnetPRV = "0x04358394";
8758
8897
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
8759
8898
  function assertWordList(wordlist) {
8760
8899
  if (wordlist.length !== 2048) {
8761
- throw new FuelError19(
8762
- ErrorCode18.INVALID_WORD_LIST,
8900
+ throw new FuelError20(
8901
+ ErrorCode19.INVALID_WORD_LIST,
8763
8902
  `Expected word list length of 2048, but got ${wordlist.length}.`
8764
8903
  );
8765
8904
  }
8766
8905
  }
8767
8906
  function assertEntropy(entropy) {
8768
8907
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
8769
- throw new FuelError19(
8770
- ErrorCode18.INVALID_ENTROPY,
8908
+ throw new FuelError20(
8909
+ ErrorCode19.INVALID_ENTROPY,
8771
8910
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
8772
8911
  );
8773
8912
  }
@@ -8777,7 +8916,7 @@ function assertMnemonic(words) {
8777
8916
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
8778
8917
  ", "
8779
8918
  )}] words, but got ${words.length}.`;
8780
- throw new FuelError19(ErrorCode18.INVALID_MNEMONIC, errorMsg);
8919
+ throw new FuelError20(ErrorCode19.INVALID_MNEMONIC, errorMsg);
8781
8920
  }
8782
8921
  }
8783
8922
  var Mnemonic = class {
@@ -8816,7 +8955,7 @@ var Mnemonic = class {
8816
8955
  static mnemonicToEntropy(phrase, wordlist = english) {
8817
8956
  const words = getWords(phrase);
8818
8957
  assertMnemonic(words);
8819
- return hexlify17(mnemonicWordsToEntropy(words, wordlist));
8958
+ return hexlify18(mnemonicWordsToEntropy(words, wordlist));
8820
8959
  }
8821
8960
  /**
8822
8961
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8895,8 +9034,8 @@ var Mnemonic = class {
8895
9034
  static masterKeysFromSeed(seed) {
8896
9035
  const seedArray = arrayify17(seed);
8897
9036
  if (seedArray.length < 16 || seedArray.length > 64) {
8898
- throw new FuelError19(
8899
- ErrorCode18.INVALID_SEED,
9037
+ throw new FuelError20(
9038
+ ErrorCode19.INVALID_SEED,
8900
9039
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8901
9040
  );
8902
9041
  }
@@ -8949,10 +9088,10 @@ var mnemonic_default = Mnemonic;
8949
9088
 
8950
9089
  // src/hdwallet/hdwallet.ts
8951
9090
  var HARDENED_INDEX = 2147483648;
8952
- var MainnetPRV2 = hexlify18("0x0488ade4");
8953
- var MainnetPUB = hexlify18("0x0488b21e");
8954
- var TestnetPRV2 = hexlify18("0x04358394");
8955
- var TestnetPUB = hexlify18("0x043587cf");
9091
+ var MainnetPRV2 = hexlify19("0x0488ade4");
9092
+ var MainnetPUB = hexlify19("0x0488b21e");
9093
+ var TestnetPRV2 = hexlify19("0x04358394");
9094
+ var TestnetPUB = hexlify19("0x043587cf");
8956
9095
  function base58check(data) {
8957
9096
  return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
8958
9097
  }
@@ -8963,17 +9102,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8963
9102
  return testnet ? TestnetPRV2 : MainnetPRV2;
8964
9103
  }
8965
9104
  function isPublicExtendedKey(extendedKey) {
8966
- return [MainnetPUB, TestnetPUB].includes(hexlify18(extendedKey.slice(0, 4)));
9105
+ return [MainnetPUB, TestnetPUB].includes(hexlify19(extendedKey.slice(0, 4)));
8967
9106
  }
8968
9107
  function isValidExtendedKey(extendedKey) {
8969
9108
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8970
- hexlify18(extendedKey.slice(0, 4))
9109
+ hexlify19(extendedKey.slice(0, 4))
8971
9110
  );
8972
9111
  }
8973
9112
  function parsePath(path, depth = 0) {
8974
9113
  const components = path.split("/");
8975
9114
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
8976
- throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
9115
+ throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
8977
9116
  }
8978
9117
  if (components[0] === "m") {
8979
9118
  components.shift();
@@ -8985,8 +9124,8 @@ function parsePath(path, depth = 0) {
8985
9124
  var HDWallet = class {
8986
9125
  depth = 0;
8987
9126
  index = 0;
8988
- fingerprint = hexlify18("0x00000000");
8989
- parentFingerprint = hexlify18("0x00000000");
9127
+ fingerprint = hexlify19("0x00000000");
9128
+ parentFingerprint = hexlify19("0x00000000");
8990
9129
  privateKey;
8991
9130
  publicKey;
8992
9131
  chainCode;
@@ -8998,16 +9137,16 @@ var HDWallet = class {
8998
9137
  constructor(config) {
8999
9138
  if (config.privateKey) {
9000
9139
  const signer = new Signer(config.privateKey);
9001
- this.publicKey = hexlify18(signer.compressedPublicKey);
9002
- this.privateKey = hexlify18(config.privateKey);
9140
+ this.publicKey = hexlify19(signer.compressedPublicKey);
9141
+ this.privateKey = hexlify19(config.privateKey);
9003
9142
  } else {
9004
9143
  if (!config.publicKey) {
9005
- throw new FuelError20(
9006
- ErrorCode19.HD_WALLET_ERROR,
9144
+ throw new FuelError21(
9145
+ ErrorCode20.HD_WALLET_ERROR,
9007
9146
  "Both public and private Key cannot be missing. At least one should be provided."
9008
9147
  );
9009
9148
  }
9010
- this.publicKey = hexlify18(config.publicKey);
9149
+ this.publicKey = hexlify19(config.publicKey);
9011
9150
  }
9012
9151
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
9013
9152
  this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
@@ -9032,8 +9171,8 @@ var HDWallet = class {
9032
9171
  const data = new Uint8Array(37);
9033
9172
  if (index & HARDENED_INDEX) {
9034
9173
  if (!privateKey) {
9035
- throw new FuelError20(
9036
- ErrorCode19.HD_WALLET_ERROR,
9174
+ throw new FuelError21(
9175
+ ErrorCode20.HD_WALLET_ERROR,
9037
9176
  "Cannot derive a hardened index without a private Key."
9038
9177
  );
9039
9178
  }
@@ -9056,7 +9195,7 @@ var HDWallet = class {
9056
9195
  parentFingerprint: this.fingerprint
9057
9196
  });
9058
9197
  }
9059
- const signer = new Signer(hexlify18(IL));
9198
+ const signer = new Signer(hexlify19(IL));
9060
9199
  const Ki = signer.addPoint(publicKey);
9061
9200
  return new HDWallet({
9062
9201
  publicKey: Ki,
@@ -9085,13 +9224,13 @@ var HDWallet = class {
9085
9224
  */
9086
9225
  toExtendedKey(isPublic = false, testnet = false) {
9087
9226
  if (this.depth >= 256) {
9088
- throw new FuelError20(
9089
- ErrorCode19.HD_WALLET_ERROR,
9227
+ throw new FuelError21(
9228
+ ErrorCode20.HD_WALLET_ERROR,
9090
9229
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9091
9230
  );
9092
9231
  }
9093
9232
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
9094
- const depth = hexlify18(Uint8Array.from([this.depth]));
9233
+ const depth = hexlify19(Uint8Array.from([this.depth]));
9095
9234
  const parentFingerprint = this.parentFingerprint;
9096
9235
  const index = toHex(this.index, 4);
9097
9236
  const chainCode = this.chainCode;
@@ -9113,29 +9252,29 @@ var HDWallet = class {
9113
9252
  });
9114
9253
  }
9115
9254
  static fromExtendedKey(extendedKey) {
9116
- const decoded = hexlify18(toBytes2(decodeBase58(extendedKey)));
9255
+ const decoded = hexlify19(toBytes2(decodeBase58(extendedKey)));
9117
9256
  const bytes = arrayify18(decoded);
9118
9257
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
9119
9258
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
9120
- throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9259
+ throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9121
9260
  }
9122
9261
  if (!validChecksum) {
9123
- throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9262
+ throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9124
9263
  }
9125
9264
  const depth = bytes[4];
9126
- const parentFingerprint = hexlify18(bytes.slice(5, 9));
9127
- const index = parseInt(hexlify18(bytes.slice(9, 13)).substring(2), 16);
9128
- const chainCode = hexlify18(bytes.slice(13, 45));
9265
+ const parentFingerprint = hexlify19(bytes.slice(5, 9));
9266
+ const index = parseInt(hexlify19(bytes.slice(9, 13)).substring(2), 16);
9267
+ const chainCode = hexlify19(bytes.slice(13, 45));
9129
9268
  const key = bytes.slice(45, 78);
9130
9269
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
9131
- throw new FuelError20(
9132
- ErrorCode19.HD_WALLET_ERROR,
9270
+ throw new FuelError21(
9271
+ ErrorCode20.HD_WALLET_ERROR,
9133
9272
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
9134
9273
  );
9135
9274
  }
9136
9275
  if (isPublicExtendedKey(bytes)) {
9137
9276
  if (key[0] !== 3) {
9138
- throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
9277
+ throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
9139
9278
  }
9140
9279
  return new HDWallet({
9141
9280
  publicKey: key,
@@ -9146,7 +9285,7 @@ var HDWallet = class {
9146
9285
  });
9147
9286
  }
9148
9287
  if (key[0] !== 0) {
9149
- throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
9288
+ throw new FuelError21(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
9150
9289
  }
9151
9290
  return new HDWallet({
9152
9291
  privateKey: key.slice(1),
@@ -9314,7 +9453,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
9314
9453
  // src/wallet-manager/wallet-manager.ts
9315
9454
  import { Address as Address8 } from "@fuel-ts/address";
9316
9455
  import { encrypt, decrypt } from "@fuel-ts/crypto";
9317
- import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
9456
+ import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
9318
9457
  import { EventEmitter } from "events";
9319
9458
 
9320
9459
  // src/wallet-manager/storages/memory-storage.ts
@@ -9337,7 +9476,7 @@ var MemoryStorage = class {
9337
9476
 
9338
9477
  // src/wallet-manager/vaults/mnemonic-vault.ts
9339
9478
  import { Address as Address6 } from "@fuel-ts/address";
9340
- import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
9479
+ import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
9341
9480
  var _secret;
9342
9481
  var MnemonicVault = class {
9343
9482
  constructor(options) {
@@ -9393,8 +9532,8 @@ var MnemonicVault = class {
9393
9532
  }
9394
9533
  numberOfAccounts += 1;
9395
9534
  } while (numberOfAccounts < this.numberOfAccounts);
9396
- throw new FuelError21(
9397
- ErrorCode20.WALLET_MANAGER_ERROR,
9535
+ throw new FuelError22(
9536
+ ErrorCode21.WALLET_MANAGER_ERROR,
9398
9537
  `Account with address '${address}' not found in derived wallets.`
9399
9538
  );
9400
9539
  }
@@ -9408,7 +9547,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
9408
9547
 
9409
9548
  // src/wallet-manager/vaults/privatekey-vault.ts
9410
9549
  import { Address as Address7 } from "@fuel-ts/address";
9411
- import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
9550
+ import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
9412
9551
  var _privateKeys;
9413
9552
  var PrivateKeyVault = class {
9414
9553
  /**
@@ -9449,8 +9588,8 @@ var PrivateKeyVault = class {
9449
9588
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
9450
9589
  );
9451
9590
  if (!privateKey) {
9452
- throw new FuelError22(
9453
- ErrorCode21.WALLET_MANAGER_ERROR,
9591
+ throw new FuelError23(
9592
+ ErrorCode22.WALLET_MANAGER_ERROR,
9454
9593
  `No private key found for address '${address}'.`
9455
9594
  );
9456
9595
  }
@@ -9474,7 +9613,7 @@ var ERROR_MESSAGES = {
9474
9613
  };
9475
9614
  function assert(condition, message) {
9476
9615
  if (!condition) {
9477
- throw new FuelError23(ErrorCode22.WALLET_MANAGER_ERROR, message);
9616
+ throw new FuelError24(ErrorCode23.WALLET_MANAGER_ERROR, message);
9478
9617
  }
9479
9618
  }
9480
9619
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -9700,25 +9839,25 @@ deserializeVaults_fn = function(vaults) {
9700
9839
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
9701
9840
 
9702
9841
  // src/wallet-manager/types.ts
9703
- import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
9842
+ import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
9704
9843
  var Vault = class {
9705
9844
  constructor(_options) {
9706
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9845
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9707
9846
  }
9708
9847
  serialize() {
9709
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9848
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9710
9849
  }
9711
9850
  getAccounts() {
9712
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9851
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9713
9852
  }
9714
9853
  addAccount() {
9715
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9854
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9716
9855
  }
9717
9856
  exportAccount(_address) {
9718
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9857
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9719
9858
  }
9720
9859
  getWallet(_address) {
9721
- throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9860
+ throw new FuelError25(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
9722
9861
  }
9723
9862
  };
9724
9863
  __publicField(Vault, "type");
@@ -9728,18 +9867,18 @@ var StorageAbstract = class {
9728
9867
  // src/predicate/predicate.ts
9729
9868
  import { Interface as Interface4 } from "@fuel-ts/abi-coder";
9730
9869
  import { Address as Address9 } from "@fuel-ts/address";
9731
- import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
9732
- import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
9870
+ import { ErrorCode as ErrorCode25, FuelError as FuelError26 } from "@fuel-ts/errors";
9871
+ import { arrayify as arrayify20, hexlify as hexlify21 } from "@fuel-ts/utils";
9733
9872
 
9734
9873
  // src/predicate/utils/getPredicateRoot.ts
9735
9874
  import { hash as hash2 } from "@fuel-ts/hasher";
9736
9875
  import { calcRoot } from "@fuel-ts/merkle";
9737
- import { chunkAndPadBytes, hexlify as hexlify19, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
9876
+ import { chunkAndPadBytes, hexlify as hexlify20, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
9738
9877
  var getPredicateRoot = (bytecode) => {
9739
9878
  const chunkSize = 16 * 1024;
9740
9879
  const bytes = arrayify19(bytecode);
9741
9880
  const chunks = chunkAndPadBytes(bytes, chunkSize);
9742
- const codeRoot = calcRoot(chunks.map((c) => hexlify19(c)));
9881
+ const codeRoot = calcRoot(chunks.map((c) => hexlify20(c)));
9743
9882
  const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
9744
9883
  return predicateRoot;
9745
9884
  };
@@ -9790,10 +9929,10 @@ var Predicate = class extends Account {
9790
9929
  if (placeholderIndex !== -1) {
9791
9930
  request.removeWitness(placeholderIndex);
9792
9931
  }
9793
- request.inputs.filter(isRequestInputResource).forEach((input) => {
9932
+ request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
9794
9933
  if (isRequestInputResourceFromOwner(input, this.address)) {
9795
- input.predicate = hexlify20(this.bytes);
9796
- input.predicateData = hexlify20(this.getPredicateData());
9934
+ input.predicate = hexlify21(this.bytes);
9935
+ input.predicateData = hexlify21(this.getPredicateData());
9797
9936
  input.witnessIndex = 0;
9798
9937
  }
9799
9938
  });
@@ -9840,8 +9979,8 @@ var Predicate = class extends Account {
9840
9979
  if (jsonAbi) {
9841
9980
  abiInterface = new Interface4(jsonAbi);
9842
9981
  if (abiInterface.functions.main === void 0) {
9843
- throw new FuelError25(
9844
- ErrorCode24.ABI_MAIN_METHOD_MISSING,
9982
+ throw new FuelError26(
9983
+ ErrorCode25.ABI_MAIN_METHOD_MISSING,
9845
9984
  'Cannot use ABI without "main" function.'
9846
9985
  );
9847
9986
  }
@@ -9873,8 +10012,8 @@ var Predicate = class extends Account {
9873
10012
  );
9874
10013
  return resources.map((resource) => ({
9875
10014
  ...resource,
9876
- predicate: hexlify20(this.bytes),
9877
- predicateData: hexlify20(this.getPredicateData())
10015
+ predicate: hexlify21(this.bytes),
10016
+ predicateData: hexlify21(this.getPredicateData())
9878
10017
  }));
9879
10018
  }
9880
10019
  /**
@@ -9886,8 +10025,8 @@ var Predicate = class extends Account {
9886
10025
  generateFakeResources(coins) {
9887
10026
  return super.generateFakeResources(coins).map((coin) => ({
9888
10027
  ...coin,
9889
- predicate: hexlify20(this.bytes),
9890
- predicateData: hexlify20(this.getPredicateData())
10028
+ predicate: hexlify21(this.bytes),
10029
+ predicateData: hexlify21(this.getPredicateData())
9891
10030
  }));
9892
10031
  }
9893
10032
  /**
@@ -9902,21 +10041,21 @@ var Predicate = class extends Account {
9902
10041
  const mutatedBytes = bytes;
9903
10042
  try {
9904
10043
  if (!abiInterface) {
9905
- throw new FuelError25(
9906
- ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
10044
+ throw new FuelError26(
10045
+ ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
9907
10046
  "Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
9908
10047
  );
9909
10048
  }
9910
10049
  if (Object.keys(abiInterface.configurables).length === 0) {
9911
- throw new FuelError25(
9912
- ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
10050
+ throw new FuelError26(
10051
+ ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
9913
10052
  "Predicate has no configurable constants to be set"
9914
10053
  );
9915
10054
  }
9916
10055
  Object.entries(configurableConstants).forEach(([key, value]) => {
9917
10056
  if (!abiInterface?.configurables[key]) {
9918
- throw new FuelError25(
9919
- ErrorCode24.CONFIGURABLE_NOT_FOUND,
10057
+ throw new FuelError26(
10058
+ ErrorCode25.CONFIGURABLE_NOT_FOUND,
9920
10059
  `No configurable constant named '${key}' found in the Predicate`
9921
10060
  );
9922
10061
  }
@@ -9925,8 +10064,8 @@ var Predicate = class extends Account {
9925
10064
  mutatedBytes.set(encoded, offset);
9926
10065
  });
9927
10066
  } catch (err) {
9928
- throw new FuelError25(
9929
- ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
10067
+ throw new FuelError26(
10068
+ ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
9930
10069
  `Error setting configurable constants: ${err.message}.`
9931
10070
  );
9932
10071
  }
@@ -9957,10 +10096,10 @@ var Predicate = class extends Account {
9957
10096
  };
9958
10097
 
9959
10098
  // src/connectors/fuel.ts
9960
- import { ErrorCode as ErrorCode25, FuelError as FuelError28 } from "@fuel-ts/errors";
10099
+ import { ErrorCode as ErrorCode26, FuelError as FuelError29 } from "@fuel-ts/errors";
9961
10100
 
9962
10101
  // src/connectors/fuel-connector.ts
9963
- import { FuelError as FuelError26 } from "@fuel-ts/errors";
10102
+ import { FuelError as FuelError27 } from "@fuel-ts/errors";
9964
10103
  import { EventEmitter as EventEmitter2 } from "events";
9965
10104
 
9966
10105
  // src/connectors/types/connector-types.ts
@@ -10034,7 +10173,7 @@ var FuelConnector = class extends EventEmitter2 {
10034
10173
  * @returns Always true.
10035
10174
  */
10036
10175
  async ping() {
10037
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10176
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10038
10177
  }
10039
10178
  /**
10040
10179
  * Should return the current version of the connector
@@ -10043,7 +10182,7 @@ var FuelConnector = class extends EventEmitter2 {
10043
10182
  * @returns boolean - connection status.
10044
10183
  */
10045
10184
  async version() {
10046
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10185
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10047
10186
  }
10048
10187
  /**
10049
10188
  * Should return true if the connector is connected
@@ -10052,7 +10191,7 @@ var FuelConnector = class extends EventEmitter2 {
10052
10191
  * @returns The connection status.
10053
10192
  */
10054
10193
  async isConnected() {
10055
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10194
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10056
10195
  }
10057
10196
  /**
10058
10197
  * Should return all the accounts authorized for the
@@ -10061,7 +10200,7 @@ var FuelConnector = class extends EventEmitter2 {
10061
10200
  * @returns The accounts addresses strings
10062
10201
  */
10063
10202
  async accounts() {
10064
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10203
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10065
10204
  }
10066
10205
  /**
10067
10206
  * Should start the connection process and return
@@ -10073,7 +10212,7 @@ var FuelConnector = class extends EventEmitter2 {
10073
10212
  * @returns boolean - connection status.
10074
10213
  */
10075
10214
  async connect() {
10076
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10215
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10077
10216
  }
10078
10217
  /**
10079
10218
  * Should disconnect the current connection and
@@ -10083,7 +10222,7 @@ var FuelConnector = class extends EventEmitter2 {
10083
10222
  * @returns The connection status.
10084
10223
  */
10085
10224
  async disconnect() {
10086
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10225
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10087
10226
  }
10088
10227
  /**
10089
10228
  * Should start the sign message process and return
@@ -10095,7 +10234,7 @@ var FuelConnector = class extends EventEmitter2 {
10095
10234
  * @returns Message signature
10096
10235
  */
10097
10236
  async signMessage(_address, _message) {
10098
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10237
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10099
10238
  }
10100
10239
  /**
10101
10240
  * Should start the sign transaction process and return
@@ -10107,7 +10246,7 @@ var FuelConnector = class extends EventEmitter2 {
10107
10246
  * @returns Transaction signature
10108
10247
  */
10109
10248
  async signTransaction(_address, _transaction) {
10110
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10249
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10111
10250
  }
10112
10251
  /**
10113
10252
  * Should start the send transaction process and return
@@ -10123,7 +10262,7 @@ var FuelConnector = class extends EventEmitter2 {
10123
10262
  * @returns The transaction id
10124
10263
  */
10125
10264
  async sendTransaction(_address, _transaction) {
10126
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10265
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10127
10266
  }
10128
10267
  /**
10129
10268
  * Should return the current account selected inside the connector, if the account
@@ -10134,7 +10273,7 @@ var FuelConnector = class extends EventEmitter2 {
10134
10273
  * @returns The current account selected otherwise null.
10135
10274
  */
10136
10275
  async currentAccount() {
10137
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10276
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10138
10277
  }
10139
10278
  /**
10140
10279
  * Should add the assets metadata to the connector and return true if the asset
@@ -10148,7 +10287,7 @@ var FuelConnector = class extends EventEmitter2 {
10148
10287
  * @returns True if the asset was added successfully
10149
10288
  */
10150
10289
  async addAssets(_assets) {
10151
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10290
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10152
10291
  }
10153
10292
  /**
10154
10293
  * Should add the asset metadata to the connector and return true if the asset
@@ -10162,7 +10301,7 @@ var FuelConnector = class extends EventEmitter2 {
10162
10301
  * @returns True if the asset was added successfully
10163
10302
  */
10164
10303
  async addAsset(_asset) {
10165
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10304
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10166
10305
  }
10167
10306
  /**
10168
10307
  * Should return all the assets added to the connector. If a connection is already established.
@@ -10170,7 +10309,7 @@ var FuelConnector = class extends EventEmitter2 {
10170
10309
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
10171
10310
  */
10172
10311
  async assets() {
10173
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10312
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10174
10313
  }
10175
10314
  /**
10176
10315
  * Should start the add network process and return true if the network was added successfully.
@@ -10181,7 +10320,7 @@ var FuelConnector = class extends EventEmitter2 {
10181
10320
  * @returns Return true if the network was added successfully
10182
10321
  */
10183
10322
  async addNetwork(_networkUrl) {
10184
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10323
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10185
10324
  }
10186
10325
  /**
10187
10326
  * Should start the select network process and return true if the network has change successfully.
@@ -10192,7 +10331,7 @@ var FuelConnector = class extends EventEmitter2 {
10192
10331
  * @returns Return true if the network was added successfully
10193
10332
  */
10194
10333
  async selectNetwork(_network) {
10195
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10334
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10196
10335
  }
10197
10336
  /**
10198
10337
  * Should return all the networks available from the connector. If the connection is already established.
@@ -10200,7 +10339,7 @@ var FuelConnector = class extends EventEmitter2 {
10200
10339
  * @returns Return all the networks added to the connector.
10201
10340
  */
10202
10341
  async networks() {
10203
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10342
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10204
10343
  }
10205
10344
  /**
10206
10345
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -10208,7 +10347,7 @@ var FuelConnector = class extends EventEmitter2 {
10208
10347
  * @returns Return the current network selected inside the connector.
10209
10348
  */
10210
10349
  async currentNetwork() {
10211
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10350
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10212
10351
  }
10213
10352
  /**
10214
10353
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -10218,7 +10357,7 @@ var FuelConnector = class extends EventEmitter2 {
10218
10357
  * @returns Return true if the ABI was added successfully.
10219
10358
  */
10220
10359
  async addABI(_contractId, _abi) {
10221
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10360
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10222
10361
  }
10223
10362
  /**
10224
10363
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -10227,7 +10366,7 @@ var FuelConnector = class extends EventEmitter2 {
10227
10366
  * @returns The ABI if it exists, otherwise return null.
10228
10367
  */
10229
10368
  async getABI(_id) {
10230
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10369
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10231
10370
  }
10232
10371
  /**
10233
10372
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -10236,7 +10375,7 @@ var FuelConnector = class extends EventEmitter2 {
10236
10375
  * @returns Returns true if the abi exists or false if not.
10237
10376
  */
10238
10377
  async hasABI(_id) {
10239
- throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10378
+ throw new FuelError27(FuelError27.CODES.NOT_IMPLEMENTED, "Method not implemented.");
10240
10379
  }
10241
10380
  /**
10242
10381
  * Event listener for the connector.
@@ -10280,7 +10419,7 @@ function dispatchFuelConnectorEvent(connector) {
10280
10419
  }
10281
10420
 
10282
10421
  // src/connectors/utils/promises.ts
10283
- import { FuelError as FuelError27 } from "@fuel-ts/errors";
10422
+ import { FuelError as FuelError28 } from "@fuel-ts/errors";
10284
10423
  function deferPromise() {
10285
10424
  const defer = {};
10286
10425
  defer.promise = new Promise((resolve, reject) => {
@@ -10292,7 +10431,7 @@ function deferPromise() {
10292
10431
  async function withTimeout(promise, timeout = 1050) {
10293
10432
  const timeoutPromise = new Promise((resolve, reject) => {
10294
10433
  setTimeout(() => {
10295
- reject(new FuelError27(FuelError27.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
10434
+ reject(new FuelError28(FuelError28.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
10296
10435
  }, timeout);
10297
10436
  });
10298
10437
  return Promise.race([timeoutPromise, promise]);
@@ -10326,7 +10465,7 @@ var _Fuel = class extends FuelConnector {
10326
10465
  await this.setDefaultConnector();
10327
10466
  this._targetUnsubscribe = this.setupConnectorListener();
10328
10467
  } catch (error) {
10329
- throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Error initializing Fuel Connector");
10468
+ throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
10330
10469
  }
10331
10470
  }
10332
10471
  async init() {
@@ -10392,8 +10531,8 @@ var _Fuel = class extends FuelConnector {
10392
10531
  const hasConnector = await this.hasConnector();
10393
10532
  await this.pingConnector();
10394
10533
  if (!this._currentConnector || !hasConnector) {
10395
- throw new FuelError28(
10396
- ErrorCode25.MISSING_CONNECTOR,
10534
+ throw new FuelError29(
10535
+ ErrorCode26.MISSING_CONNECTOR,
10397
10536
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
10398
10537
  );
10399
10538
  }
@@ -10457,7 +10596,7 @@ var _Fuel = class extends FuelConnector {
10457
10596
  cacheTime: PING_CACHE_TIME
10458
10597
  })();
10459
10598
  } catch {
10460
- throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Current connector is not available.");
10599
+ throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
10461
10600
  }
10462
10601
  }
10463
10602
  /**
@@ -10606,7 +10745,7 @@ var _Fuel = class extends FuelConnector {
10606
10745
  const currentNetwork = await this.currentNetwork();
10607
10746
  provider = await Provider.create(currentNetwork.url);
10608
10747
  } else {
10609
- throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
10748
+ throw new FuelError29(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
10610
10749
  }
10611
10750
  return provider;
10612
10751
  }
@@ -10761,10 +10900,13 @@ export {
10761
10900
  isCoin,
10762
10901
  isInputCoin,
10763
10902
  isMessage,
10903
+ isMessageCoin,
10764
10904
  isRawCoin,
10765
10905
  isRawMessage,
10766
10906
  isRequestInputCoin,
10907
+ isRequestInputCoinOrMessage,
10767
10908
  isRequestInputMessage,
10909
+ isRequestInputMessageWithoutData,
10768
10910
  isRequestInputResource,
10769
10911
  isRequestInputResourceFromOwner,
10770
10912
  isTransactionTypeBlob,