@fuel-ts/account 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (112) hide show
  1. package/dist/account.d.ts +4 -5
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts +2 -1
  4. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  5. package/dist/connectors/fuel.d.ts +1 -2
  6. package/dist/connectors/fuel.d.ts.map +1 -1
  7. package/dist/connectors/types/data-type.d.ts +0 -8
  8. package/dist/connectors/types/data-type.d.ts.map +1 -1
  9. package/dist/connectors/types/events.d.ts +2 -36
  10. package/dist/connectors/types/events.d.ts.map +1 -1
  11. package/dist/connectors/types/index.d.ts +0 -2
  12. package/dist/connectors/types/index.d.ts.map +1 -1
  13. package/dist/hdwallet/hdwallet.d.ts +1 -1
  14. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  15. package/dist/index.global.js +1554 -2272
  16. package/dist/index.global.js.map +1 -1
  17. package/dist/index.js +576 -451
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +495 -385
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/mnemonic/mnemonic.d.ts +1 -1
  22. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  23. package/dist/mnemonic/utils.d.ts +1 -1
  24. package/dist/mnemonic/utils.d.ts.map +1 -1
  25. package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
  26. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
  27. package/dist/providers/__generated__/operations.d.ts +38 -38
  28. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  29. package/dist/providers/assets/index.d.ts +4 -0
  30. package/dist/providers/assets/index.d.ts.map +1 -0
  31. package/dist/providers/assets/types.d.ts +36 -0
  32. package/dist/providers/assets/types.d.ts.map +1 -0
  33. package/dist/providers/assets/utils/index.d.ts +4 -0
  34. package/dist/providers/assets/utils/index.d.ts.map +1 -0
  35. package/dist/providers/assets/utils/network.d.ts +33 -0
  36. package/dist/providers/assets/utils/network.d.ts.map +1 -0
  37. package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
  38. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
  39. package/dist/providers/assets/utils/url.d.ts +2 -0
  40. package/dist/providers/assets/utils/url.d.ts.map +1 -0
  41. package/dist/providers/chains.d.ts +11 -0
  42. package/dist/providers/chains.d.ts.map +1 -0
  43. package/dist/providers/coin-quantity.d.ts +1 -1
  44. package/dist/providers/coin-quantity.d.ts.map +1 -1
  45. package/dist/providers/fuel-graphql-subscriber.d.ts +13 -3
  46. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  47. package/dist/providers/index.d.ts +2 -0
  48. package/dist/providers/index.d.ts.map +1 -1
  49. package/dist/providers/memory-cache.d.ts +1 -1
  50. package/dist/providers/memory-cache.d.ts.map +1 -1
  51. package/dist/providers/message.d.ts +1 -2
  52. package/dist/providers/message.d.ts.map +1 -1
  53. package/dist/providers/provider.d.ts +18 -8
  54. package/dist/providers/provider.d.ts.map +1 -1
  55. package/dist/providers/resource.d.ts +1 -1
  56. package/dist/providers/resource.d.ts.map +1 -1
  57. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  58. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  59. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  60. package/dist/providers/transaction-request/input.d.ts +1 -1
  61. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  62. package/dist/providers/transaction-request/output.d.ts +1 -1
  63. package/dist/providers/transaction-request/output.d.ts.map +1 -1
  64. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
  65. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  66. package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
  67. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
  68. package/dist/providers/transaction-request/transaction-request.d.ts +2 -10
  69. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  70. package/dist/providers/transaction-request/witness.d.ts +1 -1
  71. package/dist/providers/transaction-request/witness.d.ts.map +1 -1
  72. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  73. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  74. package/dist/providers/transaction-summary/index.d.ts +0 -1
  75. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  76. package/dist/providers/transaction-summary/operations.d.ts +0 -2
  77. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  78. package/dist/providers/transaction-summary/output.d.ts +2 -2
  79. package/dist/providers/transaction-summary/output.d.ts.map +1 -1
  80. package/dist/providers/transaction-summary/types.d.ts +0 -1
  81. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  82. package/dist/providers/utils/gas.d.ts.map +1 -1
  83. package/dist/providers/utils/index.d.ts +0 -1
  84. package/dist/providers/utils/index.d.ts.map +1 -1
  85. package/dist/signer/signer.d.ts +1 -1
  86. package/dist/signer/signer.d.ts.map +1 -1
  87. package/dist/test-utils/launchNode.d.ts.map +1 -1
  88. package/dist/test-utils.global.js +4098 -4882
  89. package/dist/test-utils.global.js.map +1 -1
  90. package/dist/test-utils.js +466 -416
  91. package/dist/test-utils.js.map +1 -1
  92. package/dist/test-utils.mjs +390 -352
  93. package/dist/test-utils.mjs.map +1 -1
  94. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
  95. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  96. package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
  97. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  98. package/dist/wallet/wallet.d.ts +1 -2
  99. package/dist/wallet/wallet.d.ts.map +1 -1
  100. package/dist/wallet/wallets.d.ts +1 -1
  101. package/dist/wallet/wallets.d.ts.map +1 -1
  102. package/package.json +16 -16
  103. package/dist/connectors/types/asset.d.ts +0 -2
  104. package/dist/connectors/types/asset.d.ts.map +0 -1
  105. package/dist/connectors/types/constants.d.ts +0 -7
  106. package/dist/connectors/types/constants.d.ts.map +0 -1
  107. package/dist/connectors/types/message.d.ts +0 -15
  108. package/dist/connectors/types/message.d.ts.map +0 -1
  109. package/dist/providers/transaction-summary/date.d.ts +0 -3
  110. package/dist/providers/transaction-summary/date.d.ts.map +0 -1
  111. package/dist/providers/utils/time.d.ts +0 -40
  112. package/dist/providers/utils/time.d.ts.map +0 -1
@@ -20,6 +20,7 @@ var __privateMethod = (obj, member, method) => {
20
20
 
21
21
  // src/wallet/base-wallet-unlocked.ts
22
22
  import { hashMessage } from "@fuel-ts/hasher";
23
+ import { hexlify as hexlify15 } from "@fuel-ts/utils";
23
24
 
24
25
  // src/account.ts
25
26
  import { Address as Address3 } from "@fuel-ts/address";
@@ -27,12 +28,12 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
27
28
  import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
28
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
30
  import { bn as bn16 } from "@fuel-ts/math";
30
- import { getBytesCopy as getBytesCopy15 } from "ethers";
31
+ import { arrayify as arrayify14 } from "@fuel-ts/utils";
31
32
 
32
33
  // src/providers/coin-quantity.ts
33
34
  import { BaseAssetId } from "@fuel-ts/address/configs";
34
35
  import { bn } from "@fuel-ts/math";
35
- import { hexlify } from "ethers";
36
+ import { hexlify } from "@fuel-ts/utils";
36
37
  var coinQuantityfy = (coinQuantityLike) => {
37
38
  let assetId;
38
39
  let amount;
@@ -68,15 +69,17 @@ var addAmountToAsset = (params) => {
68
69
  // src/providers/provider.ts
69
70
  import { Address as Address2 } from "@fuel-ts/address";
70
71
  import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
71
- import { bn as bn14, max } from "@fuel-ts/math";
72
+ import { BN, bn as bn14, max } from "@fuel-ts/math";
72
73
  import {
73
74
  InputType as InputType6,
74
75
  TransactionType as TransactionType8,
75
76
  InputMessageCoder,
76
77
  TransactionCoder as TransactionCoder5
77
78
  } from "@fuel-ts/transactions";
79
+ import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
78
80
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
79
- import { getBytesCopy as getBytesCopy12, hexlify as hexlify12, Network } from "ethers";
81
+ import { equalBytes } from "@noble/curves/abstract/utils";
82
+ import { Network } from "ethers";
80
83
  import { GraphQLClient } from "graphql-request";
81
84
  import { clone as clone3 } from "ramda";
82
85
 
@@ -885,71 +888,67 @@ function getSdk(requester) {
885
888
  // src/providers/fuel-graphql-subscriber.ts
886
889
  import { FuelError } from "@fuel-ts/errors";
887
890
  import { print } from "graphql";
888
- var _FuelSubscriptionStream = class {
889
- readable;
890
- writable;
891
- readableStreamController;
892
- constructor() {
893
- this.readable = new ReadableStream({
894
- start: (controller) => {
895
- this.readableStreamController = controller;
896
- }
897
- });
898
- this.writable = new WritableStream({
899
- write: (bytes) => {
900
- const text = _FuelSubscriptionStream.textDecoder.decode(bytes);
901
- if (text.startsWith("data:")) {
902
- const { data, errors } = JSON.parse(text.split("data:")[1]);
903
- if (Array.isArray(errors)) {
904
- this.readableStreamController.enqueue(
905
- new FuelError(
906
- FuelError.CODES.INVALID_REQUEST,
907
- errors.map((err) => err.message).join("\n\n")
908
- )
909
- );
910
- } else {
911
- this.readableStreamController.enqueue(data);
912
- }
913
- }
891
+ var _FuelGraphqlSubscriber = class {
892
+ constructor(options) {
893
+ this.options = options;
894
+ }
895
+ stream;
896
+ async setStream() {
897
+ const { url, query, variables, fetchFn } = this.options;
898
+ const response = await fetchFn(`${url}-sub`, {
899
+ method: "POST",
900
+ body: JSON.stringify({
901
+ query: print(query),
902
+ variables
903
+ }),
904
+ headers: {
905
+ "Content-Type": "application/json",
906
+ Accept: "text/event-stream"
914
907
  }
915
908
  });
909
+ this.stream = response.body.getReader();
916
910
  }
917
- };
918
- var FuelSubscriptionStream = _FuelSubscriptionStream;
919
- __publicField(FuelSubscriptionStream, "textDecoder", new TextDecoder());
920
- async function* fuelGraphQLSubscriber({
921
- url,
922
- variables,
923
- query,
924
- fetchFn
925
- }) {
926
- const response = await fetchFn(`${url}-sub`, {
927
- method: "POST",
928
- body: JSON.stringify({
929
- query: print(query),
930
- variables
931
- }),
932
- headers: {
933
- "Content-Type": "application/json",
934
- Accept: "text/event-stream"
935
- }
936
- });
937
- const subscriptionStreamReader = response.body.pipeThrough(new FuelSubscriptionStream()).getReader();
938
- while (true) {
939
- const { value, done } = await subscriptionStreamReader.read();
940
- if (value instanceof FuelError) {
941
- throw value;
911
+ async next() {
912
+ if (!this.stream) {
913
+ await this.setStream();
942
914
  }
943
- yield value;
944
- if (done) {
945
- break;
915
+ while (true) {
916
+ const { value, done } = await this.stream.read();
917
+ if (done) {
918
+ return { value, done };
919
+ }
920
+ const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
921
+ if (!text.startsWith("data:")) {
922
+ continue;
923
+ }
924
+ const { data, errors } = JSON.parse(text.split("data:")[1]);
925
+ if (Array.isArray(errors)) {
926
+ throw new FuelError(
927
+ FuelError.CODES.INVALID_REQUEST,
928
+ errors.map((err) => err.message).join("\n\n")
929
+ );
930
+ }
931
+ return { value: data, done: false };
946
932
  }
947
933
  }
948
- }
934
+ /**
935
+ * Gets called when `break` is called in a `for-await-of` loop.
936
+ */
937
+ async return() {
938
+ await this.stream.cancel();
939
+ this.stream.releaseLock();
940
+ return { done: true, value: void 0 };
941
+ }
942
+ [Symbol.asyncIterator]() {
943
+ return this;
944
+ }
945
+ };
946
+ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
947
+ __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
949
948
 
950
949
  // src/providers/memory-cache.ts
951
950
  import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
952
- import { hexlify as hexlify2 } from "ethers";
951
+ import { hexlify as hexlify2 } from "@fuel-ts/utils";
953
952
  var cache = {};
954
953
  var DEFAULT_TTL_IN_MS = 30 * 1e3;
955
954
  var MemoryCache = class {
@@ -1011,23 +1010,23 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
1011
1010
  import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
1012
1011
  import { bn as bn2, toNumber } from "@fuel-ts/math";
1013
1012
  import { InputType } from "@fuel-ts/transactions";
1014
- import { getBytesCopy, hexlify as hexlify3 } from "ethers";
1013
+ import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
1015
1014
  var inputify = (value) => {
1016
1015
  const { type } = value;
1017
1016
  switch (value.type) {
1018
1017
  case InputType.Coin: {
1019
- const predicate = getBytesCopy(value.predicate ?? "0x");
1020
- const predicateData = getBytesCopy(value.predicateData ?? "0x");
1018
+ const predicate = arrayify(value.predicate ?? "0x");
1019
+ const predicateData = arrayify(value.predicateData ?? "0x");
1021
1020
  return {
1022
1021
  type: InputType.Coin,
1023
- txID: hexlify3(getBytesCopy(value.id).slice(0, 32)),
1024
- outputIndex: getBytesCopy(value.id)[32],
1022
+ txID: hexlify3(arrayify(value.id).slice(0, 32)),
1023
+ outputIndex: arrayify(value.id)[32],
1025
1024
  owner: hexlify3(value.owner),
1026
1025
  amount: bn2(value.amount),
1027
1026
  assetId: hexlify3(value.assetId),
1028
1027
  txPointer: {
1029
- blockHeight: toNumber(getBytesCopy(value.txPointer).slice(0, 8)),
1030
- txIndex: toNumber(getBytesCopy(value.txPointer).slice(8, 16))
1028
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
1029
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1031
1030
  },
1032
1031
  witnessIndex: value.witnessIndex,
1033
1032
  maturity: value.maturity ?? 0,
@@ -1046,16 +1045,16 @@ var inputify = (value) => {
1046
1045
  balanceRoot: ZeroBytes32,
1047
1046
  stateRoot: ZeroBytes32,
1048
1047
  txPointer: {
1049
- blockHeight: toNumber(getBytesCopy(value.txPointer).slice(0, 8)),
1050
- txIndex: toNumber(getBytesCopy(value.txPointer).slice(8, 16))
1048
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
1049
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1051
1050
  },
1052
1051
  contractID: hexlify3(value.contractId)
1053
1052
  };
1054
1053
  }
1055
1054
  case InputType.Message: {
1056
- const predicate = getBytesCopy(value.predicate ?? "0x");
1057
- const predicateData = getBytesCopy(value.predicateData ?? "0x");
1058
- const data = getBytesCopy(value.data ?? "0x");
1055
+ const predicate = arrayify(value.predicate ?? "0x");
1056
+ const predicateData = arrayify(value.predicateData ?? "0x");
1057
+ const data = arrayify(value.data ?? "0x");
1059
1058
  return {
1060
1059
  type: InputType.Message,
1061
1060
  sender: hexlify3(value.sender),
@@ -1086,7 +1085,7 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
1086
1085
  import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
1087
1086
  import { bn as bn3 } from "@fuel-ts/math";
1088
1087
  import { OutputType } from "@fuel-ts/transactions";
1089
- import { hexlify as hexlify4 } from "ethers";
1088
+ import { hexlify as hexlify4 } from "@fuel-ts/utils";
1090
1089
  var outputify = (value) => {
1091
1090
  const { type } = value;
1092
1091
  switch (type) {
@@ -1149,7 +1148,7 @@ import {
1149
1148
  OutputType as OutputType2,
1150
1149
  TransactionType
1151
1150
  } from "@fuel-ts/transactions";
1152
- import { concat, getBytesCopy as getBytesCopy5, hexlify as hexlify7 } from "ethers";
1151
+ import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1153
1152
 
1154
1153
  // src/providers/resource.ts
1155
1154
  var isCoin = (resource) => "id" in resource;
@@ -1165,7 +1164,7 @@ import {
1165
1164
  ReceiptType
1166
1165
  } from "@fuel-ts/transactions";
1167
1166
  import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
1168
- import { getBytesCopy as getBytesCopy2 } from "ethers";
1167
+ import { arrayify as arrayify2 } from "@fuel-ts/utils";
1169
1168
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1170
1169
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1171
1170
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
@@ -1309,7 +1308,7 @@ function assembleReceiptByType(receipt) {
1309
1308
  const recipient = hexOrZero(receipt.recipient);
1310
1309
  const nonce = hexOrZero(receipt.nonce);
1311
1310
  const amount = bn4(receipt.amount);
1312
- const data = receipt.data ? getBytesCopy2(receipt.data) : Uint8Array.from([]);
1311
+ const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
1313
1312
  const digest = hexOrZero(receipt.digest);
1314
1313
  const messageId = ReceiptMessageOutCoder.getMessageId({
1315
1314
  sender,
@@ -1371,7 +1370,7 @@ import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/error
1371
1370
  // src/providers/utils/gas.ts
1372
1371
  import { bn as bn5 } from "@fuel-ts/math";
1373
1372
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1374
- import { getBytesCopy as getBytesCopy3 } from "ethers";
1373
+ import { arrayify as arrayify3 } from "@fuel-ts/utils";
1375
1374
  var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1376
1375
  var getGasUsedFromReceipts = (receipts) => {
1377
1376
  const scriptResult = receipts.filter(
@@ -1396,9 +1395,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1396
1395
  const totalGas = inputs.reduce((total, input) => {
1397
1396
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1398
1397
  return total.add(
1399
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
1400
- resolveGasDependentCosts(getBytesCopy3(input.predicate).length, gasCosts.contractRoot)
1401
- ).add(bn5(input.predicateGasUsed))
1398
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1402
1399
  );
1403
1400
  }
1404
1401
  if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
@@ -1447,7 +1444,7 @@ function calculateMetadataGasForTxScript({
1447
1444
  }
1448
1445
 
1449
1446
  // src/providers/utils/json.ts
1450
- import { hexlify as hexlify5 } from "ethers";
1447
+ import { hexlify as hexlify5 } from "@fuel-ts/utils";
1451
1448
  import { clone } from "ramda";
1452
1449
  function normalize(object) {
1453
1450
  Object.keys(object).forEach((key) => {
@@ -1486,9 +1483,6 @@ function sleep(time) {
1486
1483
  });
1487
1484
  }
1488
1485
 
1489
- // src/providers/utils/time.ts
1490
- var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
1491
-
1492
1486
  // src/providers/transaction-request/errors.ts
1493
1487
  var NoWitnessAtIndexError = class extends Error {
1494
1488
  constructor(index) {
@@ -1500,9 +1494,9 @@ var NoWitnessAtIndexError = class extends Error {
1500
1494
  };
1501
1495
 
1502
1496
  // src/providers/transaction-request/witness.ts
1503
- import { getBytesCopy as getBytesCopy4, hexlify as hexlify6 } from "ethers";
1497
+ import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1504
1498
  var witnessify = (value) => {
1505
- const data = getBytesCopy4(value);
1499
+ const data = arrayify4(value);
1506
1500
  return {
1507
1501
  data: hexlify6(data),
1508
1502
  dataLength: data.length
@@ -1974,19 +1968,27 @@ var BaseTransactionRequest = class {
1974
1968
  toJSON() {
1975
1969
  return normalizeJSON(this);
1976
1970
  }
1977
- /**
1978
- * @hidden
1979
- *
1980
- * Determines whether the transaction has a predicate input.
1981
- *
1982
- * @returns Whether the transaction has a predicate input.
1983
- */
1984
- hasPredicateInput() {
1985
- return Boolean(
1986
- this.inputs.find(
1987
- (input) => "predicate" in input && input.predicate && input.predicate !== getBytesCopy5("0x")
1988
- )
1989
- );
1971
+ updatePredicateInputs(inputs) {
1972
+ this.inputs.forEach((i) => {
1973
+ let correspondingInput;
1974
+ switch (i.type) {
1975
+ case InputType2.Coin:
1976
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
1977
+ break;
1978
+ case InputType2.Message:
1979
+ correspondingInput = inputs.find(
1980
+ (x) => x.type === InputType2.Message && x.sender === i.sender
1981
+ );
1982
+ break;
1983
+ default:
1984
+ return;
1985
+ }
1986
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
1987
+ i.predicate = correspondingInput.predicate;
1988
+ i.predicateData = correspondingInput.predicateData;
1989
+ i.predicateGasUsed = correspondingInput.predicateGasUsed;
1990
+ }
1991
+ });
1990
1992
  }
1991
1993
  };
1992
1994
 
@@ -1994,14 +1996,15 @@ var BaseTransactionRequest = class {
1994
1996
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
1995
1997
  import { bn as bn8 } from "@fuel-ts/math";
1996
1998
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
1997
- import { getBytesCopy as getBytesCopy7, hexlify as hexlify9 } from "ethers";
1999
+ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
1998
2000
 
1999
2001
  // src/providers/transaction-request/hash-transaction.ts
2000
2002
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2001
2003
  import { uint64ToBytesBE } from "@fuel-ts/hasher";
2002
2004
  import { bn as bn7 } from "@fuel-ts/math";
2003
2005
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2004
- import { concat as concat2, sha256 } from "ethers";
2006
+ import { concat as concat2 } from "@fuel-ts/utils";
2007
+ import { sha256 } from "ethers";
2005
2008
  import { clone as clone2 } from "ramda";
2006
2009
  function hashTransaction(transactionRequest, chainId) {
2007
2010
  const transaction = transactionRequest.toTransaction();
@@ -2068,10 +2071,10 @@ function hashTransaction(transactionRequest, chainId) {
2068
2071
  }
2069
2072
 
2070
2073
  // src/providers/transaction-request/storage-slot.ts
2071
- import { getBytesCopy as getBytesCopy6, hexlify as hexlify8 } from "ethers";
2074
+ import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
2072
2075
  var getStorageValue = (value) => {
2073
2076
  const v = new Uint8Array(32);
2074
- v.set(getBytesCopy6(value));
2077
+ v.set(arrayify5(value));
2075
2078
  return v;
2076
2079
  };
2077
2080
  var storageSlotify = (storageSlot) => {
@@ -2176,7 +2179,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2176
2179
  }
2177
2180
  metadataGas(gasCosts) {
2178
2181
  return calculateMetadataGasForTxCreate({
2179
- contractBytesSize: bn8(getBytesCopy7(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2182
+ contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2180
2183
  gasCosts,
2181
2184
  stateRootSize: this.storageSlots.length,
2182
2185
  txBytesSize: this.byteSize()
@@ -2190,17 +2193,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
2190
2193
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2191
2194
  import { bn as bn9 } from "@fuel-ts/math";
2192
2195
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2193
- import { getBytesCopy as getBytesCopy9, hexlify as hexlify10 } from "ethers";
2196
+ import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2194
2197
 
2195
2198
  // src/providers/transaction-request/scripts.ts
2196
- import { getBytesCopy as getBytesCopy8 } from "ethers";
2199
+ import { arrayify as arrayify7 } from "@fuel-ts/utils";
2197
2200
  var returnZeroScript = {
2198
2201
  /*
2199
2202
  Opcode::RET(REG_ZERO)
2200
2203
  Opcode::NOOP
2201
2204
  */
2202
2205
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2203
- bytes: getBytesCopy8("0x24000000"),
2206
+ bytes: arrayify7("0x24000000"),
2204
2207
  encodeScriptData: () => new Uint8Array(0)
2205
2208
  };
2206
2209
  var withdrawScript = {
@@ -2214,7 +2217,7 @@ var withdrawScript = {
2214
2217
  00000000 00000000 [amount value]
2215
2218
  */
2216
2219
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2217
- bytes: getBytesCopy8("0x5040C0105D44C0064C40001124000000"),
2220
+ bytes: arrayify7("0x5040C0105D44C0064C40001124000000"),
2218
2221
  encodeScriptData: () => new Uint8Array(0)
2219
2222
  };
2220
2223
 
@@ -2242,8 +2245,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2242
2245
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2243
2246
  super(rest);
2244
2247
  this.gasLimit = bn9(gasLimit);
2245
- this.script = getBytesCopy9(script ?? returnZeroScript.bytes);
2246
- this.scriptData = getBytesCopy9(scriptData ?? returnZeroScript.encodeScriptData());
2248
+ this.script = arrayify8(script ?? returnZeroScript.bytes);
2249
+ this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2247
2250
  }
2248
2251
  /**
2249
2252
  * Converts the transaction request to a `TransactionScript`.
@@ -2251,8 +2254,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2251
2254
  * @returns The transaction script object.
2252
2255
  */
2253
2256
  toTransaction() {
2254
- const script = getBytesCopy9(this.script ?? "0x");
2255
- const scriptData = getBytesCopy9(this.scriptData ?? "0x");
2257
+ const script = arrayify8(this.script ?? "0x");
2258
+ const scriptData = arrayify8(this.scriptData ?? "0x");
2256
2259
  return {
2257
2260
  type: TransactionType4.Script,
2258
2261
  scriptGasLimit: this.gasLimit,
@@ -2412,15 +2415,15 @@ var transactionRequestify = (obj) => {
2412
2415
  import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2413
2416
  import { bn as bn13 } from "@fuel-ts/math";
2414
2417
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2415
- import { getBytesCopy as getBytesCopy11 } from "ethers";
2418
+ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2416
2419
 
2417
2420
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2418
- import { hexlify as hexlify11 } from "ethers";
2421
+ import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2419
2422
 
2420
2423
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2421
2424
  import { bn as bn10 } from "@fuel-ts/math";
2422
2425
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2423
- import { getBytesCopy as getBytesCopy10 } from "ethers";
2426
+ import { arrayify as arrayify9 } from "@fuel-ts/utils";
2424
2427
  var calculateTransactionFee = (params) => {
2425
2428
  const {
2426
2429
  gasUsed,
@@ -2429,7 +2432,7 @@ var calculateTransactionFee = (params) => {
2429
2432
  } = params;
2430
2433
  const gasPerByte = bn10(feeParams.gasPerByte);
2431
2434
  const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2432
- const transactionBytes = getBytesCopy10(rawPayload);
2435
+ const transactionBytes = arrayify9(rawPayload);
2433
2436
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2434
2437
  if (transaction.type === TransactionType6.Mint) {
2435
2438
  return {
@@ -2444,7 +2447,7 @@ var calculateTransactionFee = (params) => {
2444
2447
  let gasLimit = bn10(0);
2445
2448
  if (type === TransactionType6.Create) {
2446
2449
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2447
- const contractBytesSize = bn10(getBytesCopy10(witnesses[bytecodeWitnessIndex].data).length);
2450
+ const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2448
2451
  metadataGas = calculateMetadataGasForTxCreate({
2449
2452
  contractBytesSize,
2450
2453
  gasCosts,
@@ -2490,14 +2493,8 @@ var calculateTransactionFee = (params) => {
2490
2493
  };
2491
2494
  };
2492
2495
 
2493
- // src/providers/transaction-summary/date.ts
2494
- import { TAI64 } from "tai64";
2495
- var fromTai64ToDate = (tai64Timestamp) => {
2496
- const timestamp = TAI64.fromString(tai64Timestamp, 10).toUnix();
2497
- return new Date(timestamp * 1e3);
2498
- };
2499
-
2500
2496
  // src/providers/transaction-summary/operations.ts
2497
+ import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2501
2498
  import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
2502
2499
  import { bn as bn12 } from "@fuel-ts/math";
2503
2500
  import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
@@ -2694,36 +2691,6 @@ function addOperation(operations, toAdd) {
2694
2691
  }
2695
2692
  return allOperations;
2696
2693
  }
2697
- function getReceiptsTransferOut(receipts) {
2698
- return getReceiptsByType(receipts, ReceiptType3.TransferOut);
2699
- }
2700
- function getContractTransferOperations({ receipts }) {
2701
- const transferOutReceipts = getReceiptsTransferOut(receipts);
2702
- const contractTransferOperations = transferOutReceipts.reduce(
2703
- (prevContractTransferOps, receipt) => {
2704
- const newContractTransferOps = addOperation(prevContractTransferOps, {
2705
- name: "Contract transfer" /* contractTransfer */,
2706
- from: {
2707
- type: 0 /* contract */,
2708
- address: receipt.from
2709
- },
2710
- to: {
2711
- type: 1 /* account */,
2712
- address: receipt.to
2713
- },
2714
- assetsSent: [
2715
- {
2716
- amount: receipt.amount,
2717
- assetId: receipt.assetId
2718
- }
2719
- ]
2720
- });
2721
- return newContractTransferOps;
2722
- },
2723
- []
2724
- );
2725
- return contractTransferOperations;
2726
- }
2727
2694
  function getWithdrawFromFuelOperations({
2728
2695
  inputs,
2729
2696
  receipts
@@ -2821,70 +2788,77 @@ function getContractCallOperations({
2821
2788
  }, []);
2822
2789
  return contractCallOperations;
2823
2790
  }
2791
+ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
2792
+ const { to: toAddress, assetId, amount } = receipt;
2793
+ let { from: fromAddress } = receipt;
2794
+ const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2795
+ if (ZeroBytes328 === fromAddress) {
2796
+ const change = changeOutputs.find((output) => output.assetId === assetId);
2797
+ fromAddress = change?.to || fromAddress;
2798
+ }
2799
+ const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
2800
+ return {
2801
+ name: "Transfer asset" /* transfer */,
2802
+ from: {
2803
+ type: fromType,
2804
+ address: fromAddress
2805
+ },
2806
+ to: {
2807
+ type: toType,
2808
+ address: toAddress
2809
+ },
2810
+ assetsSent: [
2811
+ {
2812
+ assetId: assetId.toString(),
2813
+ amount
2814
+ }
2815
+ ]
2816
+ };
2817
+ }
2824
2818
  function getTransferOperations({
2825
2819
  inputs,
2826
2820
  outputs,
2827
2821
  receipts
2828
2822
  }) {
2823
+ let operations = [];
2829
2824
  const coinOutputs = getOutputsCoin(outputs);
2830
- const [transferReceipt] = getReceiptsByType(
2825
+ const contractInputs = getInputsContract(inputs);
2826
+ const changeOutputs = getOutputsChange(outputs);
2827
+ coinOutputs.forEach((output) => {
2828
+ const { amount, assetId, to } = output;
2829
+ const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
2830
+ if (changeOutput) {
2831
+ operations = addOperation(operations, {
2832
+ name: "Transfer asset" /* transfer */,
2833
+ from: {
2834
+ type: 1 /* account */,
2835
+ address: changeOutput.to
2836
+ },
2837
+ to: {
2838
+ type: 1 /* account */,
2839
+ address: to
2840
+ },
2841
+ assetsSent: [
2842
+ {
2843
+ assetId,
2844
+ amount
2845
+ }
2846
+ ]
2847
+ });
2848
+ }
2849
+ });
2850
+ const transferReceipts = getReceiptsByType(
2831
2851
  receipts,
2832
2852
  ReceiptType3.Transfer
2833
2853
  );
2834
- let operations = [];
2835
- if (transferReceipt) {
2836
- const changeOutputs = getOutputsChange(outputs);
2837
- changeOutputs.forEach((output) => {
2838
- const { assetId } = output;
2839
- const [contractInput] = getInputsContract(inputs);
2840
- const utxo = getInputFromAssetId(inputs, assetId);
2841
- if (utxo && contractInput) {
2842
- const inputAddress = getInputAccountAddress(utxo);
2843
- operations = addOperation(operations, {
2844
- name: "Transfer asset" /* transfer */,
2845
- from: {
2846
- type: 1 /* account */,
2847
- address: inputAddress
2848
- },
2849
- to: {
2850
- type: 0 /* contract */,
2851
- address: contractInput.contractID
2852
- },
2853
- assetsSent: [
2854
- {
2855
- assetId: assetId.toString(),
2856
- amount: transferReceipt.amount
2857
- }
2858
- ]
2859
- });
2860
- }
2861
- });
2862
- } else {
2863
- coinOutputs.forEach((output) => {
2864
- const input = getInputFromAssetId(inputs, output.assetId);
2865
- if (input) {
2866
- const inputAddress = getInputAccountAddress(input);
2867
- const operationToAdd = {
2868
- name: "Transfer asset" /* transfer */,
2869
- from: {
2870
- type: 1 /* account */,
2871
- address: inputAddress
2872
- },
2873
- to: {
2874
- type: 1 /* account */,
2875
- address: output.to.toString()
2876
- },
2877
- assetsSent: [
2878
- {
2879
- assetId: output.assetId.toString(),
2880
- amount: output.amount
2881
- }
2882
- ]
2883
- };
2884
- operations = addOperation(operations, operationToAdd);
2885
- }
2886
- });
2887
- }
2854
+ const transferOutReceipts = getReceiptsByType(
2855
+ receipts,
2856
+ ReceiptType3.TransferOut
2857
+ );
2858
+ [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2859
+ const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
2860
+ operations = addOperation(operations, operation);
2861
+ });
2888
2862
  return operations;
2889
2863
  }
2890
2864
  function getPayProducerOperations(outputs) {
@@ -2957,7 +2931,6 @@ function getOperations({
2957
2931
  rawPayload,
2958
2932
  maxInputs
2959
2933
  }),
2960
- ...getContractTransferOperations({ receipts }),
2961
2934
  ...getWithdrawFromFuelOperations({ inputs, receipts })
2962
2935
  ];
2963
2936
  }
@@ -3113,7 +3086,7 @@ function assembleTransactionSummary(params) {
3113
3086
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3114
3087
  let date;
3115
3088
  if (time) {
3116
- date = fromTai64ToDate(time);
3089
+ date = DateTime.fromTai64(time);
3117
3090
  }
3118
3091
  const transactionSummary = {
3119
3092
  id,
@@ -3203,7 +3176,7 @@ var TransactionResponse = class {
3203
3176
  */
3204
3177
  decodeTransaction(transactionWithReceipts) {
3205
3178
  return new TransactionCoder4().decode(
3206
- getBytesCopy11(transactionWithReceipts.rawPayload),
3179
+ arrayify10(transactionWithReceipts.rawPayload),
3207
3180
  0
3208
3181
  )?.[0];
3209
3182
  }
@@ -3229,7 +3202,7 @@ var TransactionResponse = class {
3229
3202
  id: this.id,
3230
3203
  receipts,
3231
3204
  transaction: decodedTransaction,
3232
- transactionBytes: getBytesCopy11(transaction.rawPayload),
3205
+ transactionBytes: arrayify10(transaction.rawPayload),
3233
3206
  gqlTransactionStatus: transaction.status,
3234
3207
  gasPerByte,
3235
3208
  gasPriceFactor,
@@ -3286,7 +3259,7 @@ var TransactionResponse = class {
3286
3259
  };
3287
3260
 
3288
3261
  // src/providers/transaction-response/getDecodedLogs.ts
3289
- import { U64Coder } from "@fuel-ts/abi-coder";
3262
+ import { BigNumberCoder } from "@fuel-ts/abi-coder";
3290
3263
  import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3291
3264
 
3292
3265
  // src/providers/utils/auto-retry-fetch.ts
@@ -3519,7 +3492,7 @@ var _Provider = class {
3519
3492
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
3520
3493
  const isSubscription = opDefinition?.operation === "subscription";
3521
3494
  if (isSubscription) {
3522
- return fuelGraphQLSubscriber({
3495
+ return new FuelGraphqlSubscriber({
3523
3496
  url: this.url,
3524
3497
  query,
3525
3498
  fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
@@ -3652,7 +3625,7 @@ var _Provider = class {
3652
3625
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
3653
3626
  const transactionRequest = transactionRequestify(transactionRequestLike);
3654
3627
  if (estimateTxDependencies) {
3655
- await this.estimateTxDependencies(transactionRequest);
3628
+ return this.estimateTxDependencies(transactionRequest);
3656
3629
  }
3657
3630
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3658
3631
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3671,6 +3644,14 @@ var _Provider = class {
3671
3644
  * @returns A promise that resolves to the estimated transaction request object.
3672
3645
  */
3673
3646
  async estimatePredicates(transactionRequest) {
3647
+ const shouldEstimatePredicates = Boolean(
3648
+ transactionRequest.inputs.find(
3649
+ (input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
3650
+ )
3651
+ );
3652
+ if (!shouldEstimatePredicates) {
3653
+ return transactionRequest;
3654
+ }
3674
3655
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3675
3656
  const response = await this.operations.estimatePredicates({
3676
3657
  encodedTransaction
@@ -3701,34 +3682,41 @@ var _Provider = class {
3701
3682
  * @returns A promise.
3702
3683
  */
3703
3684
  async estimateTxDependencies(transactionRequest) {
3704
- let missingOutputVariableCount = 0;
3705
- let missingOutputContractIdsCount = 0;
3706
- let tries = 0;
3707
3685
  if (transactionRequest.type === TransactionType8.Create) {
3708
- return;
3709
- }
3710
- let txRequest = transactionRequest;
3711
- if (txRequest.hasPredicateInput()) {
3712
- txRequest = await this.estimatePredicates(txRequest);
3686
+ return {
3687
+ receipts: [],
3688
+ outputVariables: 0,
3689
+ missingContractIds: []
3690
+ };
3713
3691
  }
3714
- while (tries < MAX_RETRIES) {
3692
+ await this.estimatePredicates(transactionRequest);
3693
+ let receipts = [];
3694
+ const missingContractIds = [];
3695
+ let outputVariables = 0;
3696
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3715
3697
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3716
- encodedTransaction: hexlify12(txRequest.toTransactionBytes()),
3698
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3717
3699
  utxoValidation: false
3718
3700
  });
3719
- const receipts = gqlReceipts.map(processGqlReceipt);
3701
+ receipts = gqlReceipts.map(processGqlReceipt);
3720
3702
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3721
- missingOutputVariableCount = missingOutputVariables.length;
3722
- missingOutputContractIdsCount = missingOutputContractIds.length;
3723
- if (missingOutputVariableCount === 0 && missingOutputContractIdsCount === 0) {
3724
- return;
3703
+ const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3704
+ if (hasMissingOutputs) {
3705
+ outputVariables += missingOutputVariables.length;
3706
+ transactionRequest.addVariableOutputs(missingOutputVariables.length);
3707
+ missingOutputContractIds.forEach(({ contractId }) => {
3708
+ transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3709
+ missingContractIds.push(contractId);
3710
+ });
3711
+ } else {
3712
+ break;
3725
3713
  }
3726
- txRequest.addVariableOutputs(missingOutputVariableCount);
3727
- missingOutputContractIds.forEach(
3728
- ({ contractId }) => txRequest.addContractInputAndOutput(Address2.fromString(contractId))
3729
- );
3730
- tries += 1;
3731
3714
  }
3715
+ return {
3716
+ receipts,
3717
+ outputVariables,
3718
+ missingContractIds
3719
+ };
3732
3720
  }
3733
3721
  /**
3734
3722
  * Executes a signed transaction without applying the states changes
@@ -3743,7 +3731,7 @@ var _Provider = class {
3743
3731
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
3744
3732
  const transactionRequest = transactionRequestify(transactionRequestLike);
3745
3733
  if (estimateTxDependencies) {
3746
- await this.estimateTxDependencies(transactionRequest);
3734
+ return this.estimateTxDependencies(transactionRequest);
3747
3735
  }
3748
3736
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3749
3737
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3775,35 +3763,37 @@ var _Provider = class {
3775
3763
  estimatePredicates = true,
3776
3764
  resourcesOwner
3777
3765
  } = {}) {
3778
- const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
3766
+ const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3779
3767
  const chainInfo = this.getChain();
3780
3768
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3781
- const gasPrice = max(transactionRequest.gasPrice, minGasPrice);
3782
- const isScriptTransaction = transactionRequest.type === TransactionType8.Script;
3783
- if (transactionRequest.hasPredicateInput() && estimatePredicates) {
3769
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3770
+ const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3771
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3772
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3773
+ txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3774
+ if (estimatePredicates) {
3784
3775
  if (isScriptTransaction) {
3785
- transactionRequest.gasLimit = bn14(0);
3776
+ txRequestClone.gasLimit = bn14(0);
3777
+ }
3778
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3779
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3786
3780
  }
3787
- await this.estimatePredicates(transactionRequest);
3781
+ await this.estimatePredicates(txRequestClone);
3788
3782
  }
3789
- const minGas = transactionRequest.calculateMinGas(chainInfo);
3790
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3791
- const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
3792
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3793
- transactionRequest.fundWithFakeUtxos(allQuantities, resourcesOwner);
3794
- let gasUsed = minGas;
3783
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3784
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3795
3785
  let receipts = [];
3796
- if (isScriptTransaction) {
3797
- transactionRequest.gasPrice = bn14(0);
3798
- transactionRequest.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3799
- const result = await this.call(transactionRequest, {
3800
- estimateTxDependencies
3801
- });
3786
+ let missingContractIds = [];
3787
+ let outputVariables = 0;
3788
+ if (isScriptTransaction && estimateTxDependencies) {
3789
+ txRequestClone.gasPrice = bn14(0);
3790
+ txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3791
+ const result = await this.estimateTxDependencies(txRequestClone);
3802
3792
  receipts = result.receipts;
3803
- gasUsed = getGasUsedFromReceipts(receipts);
3804
- } else {
3805
- gasUsed = minGas;
3793
+ outputVariables = result.outputVariables;
3794
+ missingContractIds = result.missingContractIds;
3806
3795
  }
3796
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3807
3797
  const usedFee = calculatePriceWithFactor(
3808
3798
  gasUsed,
3809
3799
  gasPrice,
@@ -3821,7 +3811,10 @@ var _Provider = class {
3821
3811
  maxGas,
3822
3812
  usedFee,
3823
3813
  minFee,
3824
- maxFee
3814
+ maxFee,
3815
+ estimatedInputs: txRequestClone.inputs,
3816
+ outputVariables,
3817
+ missingContractIds
3825
3818
  };
3826
3819
  }
3827
3820
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -3989,7 +3982,7 @@ var _Provider = class {
3989
3982
  time: block.header.time,
3990
3983
  transactionIds: block.transactions.map((tx) => tx.id),
3991
3984
  transactions: block.transactions.map(
3992
- (tx) => new TransactionCoder5().decode(getBytesCopy12(tx.rawPayload), 0)?.[0]
3985
+ (tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
3993
3986
  )
3994
3987
  };
3995
3988
  }
@@ -4005,7 +3998,7 @@ var _Provider = class {
4005
3998
  return null;
4006
3999
  }
4007
4000
  return new TransactionCoder5().decode(
4008
- getBytesCopy12(transaction.rawPayload),
4001
+ arrayify11(transaction.rawPayload),
4009
4002
  0
4010
4003
  )?.[0];
4011
4004
  }
@@ -4201,13 +4194,13 @@ var _Provider = class {
4201
4194
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4202
4195
  *
4203
4196
  * @param amount - The amount of blocks to produce
4204
- * @param startTime - The UNIX timestamp to set for the first produced block
4197
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4205
4198
  * @returns A promise that resolves to the block number of the last produced block.
4206
4199
  */
4207
4200
  async produceBlocks(amount, startTime) {
4208
4201
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4209
4202
  blocksToProduce: bn14(amount).toString(10),
4210
- startTimestamp: startTime ? fromUnixToTai64(startTime) : void 0
4203
+ startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4211
4204
  });
4212
4205
  return bn14(latestBlockHeight);
4213
4206
  }
@@ -4235,21 +4228,66 @@ __publicField(Provider, "nodeInfoCache", {});
4235
4228
  import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
4236
4229
  import { bn as bn15 } from "@fuel-ts/math";
4237
4230
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4238
- import { getBytesCopy as getBytesCopy13 } from "ethers";
4231
+ import { arrayify as arrayify12 } from "@fuel-ts/utils";
4232
+
4233
+ // src/providers/chains.ts
4234
+ var CHAIN_IDS = {
4235
+ eth: {
4236
+ sepolia: 11155111,
4237
+ foundry: 31337
4238
+ },
4239
+ fuel: {
4240
+ beta5: 0,
4241
+ devnet: 10
4242
+ }
4243
+ };
4244
+
4245
+ // src/providers/assets/index.ts
4246
+ var assets = [
4247
+ {
4248
+ name: "Ethereum",
4249
+ symbol: "ETH",
4250
+ icon: "eth.svg",
4251
+ networks: [
4252
+ {
4253
+ type: "ethereum",
4254
+ chainId: CHAIN_IDS.eth.sepolia,
4255
+ decimals: 18
4256
+ },
4257
+ {
4258
+ type: "ethereum",
4259
+ chainId: CHAIN_IDS.eth.foundry,
4260
+ decimals: 18
4261
+ },
4262
+ {
4263
+ type: "fuel",
4264
+ chainId: CHAIN_IDS.fuel.beta5,
4265
+ decimals: 9,
4266
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4267
+ },
4268
+ {
4269
+ type: "fuel",
4270
+ chainId: CHAIN_IDS.fuel.devnet,
4271
+ decimals: 9,
4272
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4273
+ }
4274
+ ]
4275
+ }
4276
+ ];
4239
4277
 
4240
4278
  // src/utils/formatTransferToContractScriptData.ts
4241
- import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
4242
- import { BN } from "@fuel-ts/math";
4279
+ import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
4280
+ import { BN as BN2 } from "@fuel-ts/math";
4281
+ import { arrayify as arrayify13 } from "@fuel-ts/utils";
4243
4282
  import * as asm from "@fuels/vm-asm";
4244
- import { getBytesCopy as getBytesCopy14 } from "ethers";
4245
4283
  var formatTransferToContractScriptData = (params) => {
4246
4284
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4247
- const numberCoder = new U64Coder2();
4248
- const encoded = numberCoder.encode(new BN(amountToTransfer).toNumber());
4285
+ const numberCoder = new BigNumberCoder2("u64");
4286
+ const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
4249
4287
  const scriptData = Uint8Array.from([
4250
- ...getBytesCopy14(hexlifiedContractId),
4288
+ ...arrayify13(hexlifiedContractId),
4251
4289
  ...encoded,
4252
- ...getBytesCopy14(assetId)
4290
+ ...arrayify13(assetId)
4253
4291
  ]);
4254
4292
  return scriptData;
4255
4293
  };
@@ -4499,7 +4537,10 @@ var Account = class extends AbstractAccount {
4499
4537
  const params = { gasPrice: minGasPrice, ...txParams };
4500
4538
  const request = new ScriptTransactionRequest(params);
4501
4539
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4502
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4540
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4541
+ estimateTxDependencies: true,
4542
+ resourcesOwner: this
4543
+ });
4503
4544
  request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4504
4545
  request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4505
4546
  this.validateGas({
@@ -4509,6 +4550,7 @@ var Account = class extends AbstractAccount {
4509
4550
  minGasPrice
4510
4551
  });
4511
4552
  await this.fund(request, requiredQuantities, maxFee);
4553
+ request.updatePredicateInputs(estimatedInputs);
4512
4554
  return request;
4513
4555
  }
4514
4556
  /**
@@ -4522,7 +4564,7 @@ var Account = class extends AbstractAccount {
4522
4564
  */
4523
4565
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4524
4566
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4525
- return this.sendTransaction(request);
4567
+ return this.sendTransaction(request, { estimateTxDependencies: false });
4526
4568
  }
4527
4569
  /**
4528
4570
  * Transfers coins to a contract address.
@@ -4573,14 +4615,14 @@ var Account = class extends AbstractAccount {
4573
4615
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4574
4616
  const { minGasPrice } = this.provider.getGasConfig();
4575
4617
  const recipientAddress = Address3.fromAddressOrString(recipient);
4576
- const recipientDataArray = getBytesCopy15(
4618
+ const recipientDataArray = arrayify14(
4577
4619
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4578
4620
  );
4579
- const amountDataArray = getBytesCopy15(
4621
+ const amountDataArray = arrayify14(
4580
4622
  "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4581
4623
  );
4582
4624
  const script = new Uint8Array([
4583
- ...getBytesCopy15(withdrawScript.bytes),
4625
+ ...arrayify14(withdrawScript.bytes),
4584
4626
  ...recipientDataArray,
4585
4627
  ...amountDataArray
4586
4628
  ]);
@@ -4613,16 +4655,18 @@ var Account = class extends AbstractAccount {
4613
4655
  * @param transactionRequestLike - The transaction request to be sent.
4614
4656
  * @returns A promise that resolves to the transaction response.
4615
4657
  */
4616
- async sendTransaction(transactionRequestLike, options) {
4658
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4617
4659
  if (this._connector) {
4618
4660
  return this.provider.getTransactionResponse(
4619
4661
  await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
4620
4662
  );
4621
4663
  }
4622
4664
  const transactionRequest = transactionRequestify(transactionRequestLike);
4623
- await this.provider.estimateTxDependencies(transactionRequest);
4665
+ if (estimateTxDependencies) {
4666
+ await this.provider.estimateTxDependencies(transactionRequest);
4667
+ }
4624
4668
  return this.provider.sendTransaction(transactionRequest, {
4625
- ...options,
4669
+ awaitExecution,
4626
4670
  estimateTxDependencies: false
4627
4671
  });
4628
4672
  }
@@ -4632,9 +4676,11 @@ var Account = class extends AbstractAccount {
4632
4676
  * @param transactionRequestLike - The transaction request to be simulated.
4633
4677
  * @returns A promise that resolves to the call result.
4634
4678
  */
4635
- async simulateTransaction(transactionRequestLike) {
4679
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4636
4680
  const transactionRequest = transactionRequestify(transactionRequestLike);
4637
- await this.provider.estimateTxDependencies(transactionRequest);
4681
+ if (estimateTxDependencies) {
4682
+ await this.provider.estimateTxDependencies(transactionRequest);
4683
+ }
4638
4684
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4639
4685
  }
4640
4686
  validateGas({
@@ -4663,8 +4709,8 @@ import { Address as Address4 } from "@fuel-ts/address";
4663
4709
  import { randomBytes } from "@fuel-ts/crypto";
4664
4710
  import { hash } from "@fuel-ts/hasher";
4665
4711
  import { toBytes } from "@fuel-ts/math";
4712
+ import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
4666
4713
  import { secp256k1 } from "@noble/curves/secp256k1";
4667
- import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy16 } from "ethers";
4668
4714
  var Signer = class {
4669
4715
  address;
4670
4716
  publicKey;
@@ -4699,11 +4745,11 @@ var Signer = class {
4699
4745
  * @returns hashed signature
4700
4746
  */
4701
4747
  sign(data) {
4702
- const signature = secp256k1.sign(getBytesCopy16(data), getBytesCopy16(this.privateKey));
4748
+ const signature = secp256k1.sign(arrayify15(data), arrayify15(this.privateKey));
4703
4749
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
4704
4750
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
4705
4751
  s[0] |= (signature.recovery || 0) << 7;
4706
- return concat3([r, s]);
4752
+ return hexlify13(concat3([r, s]));
4707
4753
  }
4708
4754
  /**
4709
4755
  * Add point on the current elliptic curve
@@ -4712,8 +4758,8 @@ var Signer = class {
4712
4758
  * @returns compressed point on the curve
4713
4759
  */
4714
4760
  addPoint(point) {
4715
- const p0 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(this.compressedPublicKey));
4716
- const p1 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(point));
4761
+ const p0 = secp256k1.ProjectivePoint.fromHex(arrayify15(this.compressedPublicKey));
4762
+ const p1 = secp256k1.ProjectivePoint.fromHex(arrayify15(point));
4717
4763
  const result = p0.add(p1);
4718
4764
  return `0x${result.toHex(true)}`;
4719
4765
  }
@@ -4725,7 +4771,7 @@ var Signer = class {
4725
4771
  * @returns public key from signature from the
4726
4772
  */
4727
4773
  static recoverPublicKey(data, signature) {
4728
- const signedMessageBytes = getBytesCopy16(signature);
4774
+ const signedMessageBytes = arrayify15(signature);
4729
4775
  const r = signedMessageBytes.slice(0, 32);
4730
4776
  const s = signedMessageBytes.slice(32, 64);
4731
4777
  const recoveryParam = (s[0] & 128) >> 7;
@@ -4733,7 +4779,7 @@ var Signer = class {
4733
4779
  const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
4734
4780
  recoveryParam
4735
4781
  );
4736
- const publicKey = sig.recoverPublicKey(getBytesCopy16(data)).toRawBytes(false).slice(1);
4782
+ const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
4737
4783
  return hexlify13(publicKey);
4738
4784
  }
4739
4785
  /**
@@ -4753,7 +4799,7 @@ var Signer = class {
4753
4799
  * @returns random 32-byte hashed
4754
4800
  */
4755
4801
  static generatePrivateKey(entropy) {
4756
- return entropy ? hash(concat3([randomBytes(32), getBytesCopy16(entropy)])) : randomBytes(32);
4802
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
4757
4803
  }
4758
4804
  /**
4759
4805
  * Extended publicKey from a compact publicKey
@@ -4762,7 +4808,7 @@ var Signer = class {
4762
4808
  * @returns extended publicKey
4763
4809
  */
4764
4810
  static extendPublicKey(publicKey) {
4765
- const point = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(publicKey));
4811
+ const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
4766
4812
  return hexlify13(point.toRawBytes(false).slice(1));
4767
4813
  }
4768
4814
  };
@@ -4779,7 +4825,7 @@ import {
4779
4825
  encryptJsonWalletData
4780
4826
  } from "@fuel-ts/crypto";
4781
4827
  import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
4782
- import { hexlify as hexlify14 } from "ethers";
4828
+ import { hexlify as hexlify14 } from "@fuel-ts/utils";
4783
4829
  import { v4 as uuidv4 } from "uuid";
4784
4830
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4785
4831
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -4907,7 +4953,7 @@ var BaseWalletUnlocked = class extends Account {
4907
4953
  */
4908
4954
  async signMessage(message) {
4909
4955
  const signedMessage = await this.signer().sign(hashMessage(message));
4910
- return signedMessage;
4956
+ return hexlify15(signedMessage);
4911
4957
  }
4912
4958
  /**
4913
4959
  * Signs a transaction with the wallet's private key.
@@ -4920,7 +4966,7 @@ var BaseWalletUnlocked = class extends Account {
4920
4966
  const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
4921
4967
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
4922
4968
  const signature = await this.signer().sign(hashedTransaction);
4923
- return signature;
4969
+ return hexlify15(signature);
4924
4970
  }
4925
4971
  /**
4926
4972
  * Populates a transaction with the witnesses signature.
@@ -4940,12 +4986,14 @@ var BaseWalletUnlocked = class extends Account {
4940
4986
  * @param transactionRequestLike - The transaction request to send.
4941
4987
  * @returns A promise that resolves to the TransactionResponse object.
4942
4988
  */
4943
- async sendTransaction(transactionRequestLike, options) {
4989
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4944
4990
  const transactionRequest = transactionRequestify(transactionRequestLike);
4945
- await this.provider.estimateTxDependencies(transactionRequest);
4991
+ if (estimateTxDependencies) {
4992
+ await this.provider.estimateTxDependencies(transactionRequest);
4993
+ }
4946
4994
  return this.provider.sendTransaction(
4947
4995
  await this.populateTransactionWitnessesSignature(transactionRequest),
4948
- { ...options, estimateTxDependencies: false }
4996
+ { awaitExecution, estimateTxDependencies: false }
4949
4997
  );
4950
4998
  }
4951
4999
  /**
@@ -4954,9 +5002,11 @@ var BaseWalletUnlocked = class extends Account {
4954
5002
  * @param transactionRequestLike - The transaction request to simulate.
4955
5003
  * @returns A promise that resolves to the CallResult object.
4956
5004
  */
4957
- async simulateTransaction(transactionRequestLike) {
5005
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4958
5006
  const transactionRequest = transactionRequestify(transactionRequestLike);
4959
- await this.provider.estimateTxDependencies(transactionRequest);
5007
+ if (estimateTxDependencies) {
5008
+ await this.provider.estimateTxDependencies(transactionRequest);
5009
+ }
4960
5010
  return this.provider.call(
4961
5011
  await this.populateTransactionWitnessesSignature(transactionRequest),
4962
5012
  {
@@ -4977,32 +5027,22 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
4977
5027
  // src/hdwallet/hdwallet.ts
4978
5028
  import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
4979
5029
  import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5030
+ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
4980
5031
  import {
4981
5032
  toBeHex,
4982
5033
  dataSlice as dataSlice2,
4983
- hexlify as hexlify16,
4984
5034
  encodeBase58 as encodeBase582,
4985
5035
  decodeBase58,
4986
5036
  sha256 as sha2564,
4987
5037
  computeHmac as computeHmac2,
4988
- ripemd160,
4989
- getBytesCopy as getBytesCopy19,
4990
- concat as concat5
5038
+ ripemd160
4991
5039
  } from "ethers";
4992
5040
 
4993
5041
  // src/mnemonic/mnemonic.ts
4994
5042
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
4995
5043
  import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
4996
- import {
4997
- concat as concat4,
4998
- hexlify as hexlify15,
4999
- dataSlice,
5000
- pbkdf2,
5001
- sha256 as sha2563,
5002
- computeHmac,
5003
- encodeBase58,
5004
- getBytesCopy as getBytesCopy18
5005
- } from "ethers";
5044
+ import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5045
+ import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
5006
5046
 
5007
5047
  // src/wordlists/words/english.ts
5008
5048
  var english = [
@@ -7058,7 +7098,8 @@ var english = [
7058
7098
 
7059
7099
  // src/mnemonic/utils.ts
7060
7100
  import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
7061
- import { getBytesCopy as getBytesCopy17, sha256 as sha2562 } from "ethers";
7101
+ import { arrayify as arrayify16 } from "@fuel-ts/utils";
7102
+ import { sha256 as sha2562 } from "ethers";
7062
7103
  function toUtf8Bytes(stri) {
7063
7104
  const str = stri.normalize("NFKD");
7064
7105
  const result = [];
@@ -7125,14 +7166,14 @@ function entropyToMnemonicIndices(entropy) {
7125
7166
  }
7126
7167
  }
7127
7168
  const checksumBits = entropy.length / 4;
7128
- const checksum = getBytesCopy17(sha2562(entropy))[0] & getUpperMask(checksumBits);
7169
+ const checksum = arrayify16(sha2562(entropy))[0] & getUpperMask(checksumBits);
7129
7170
  indices[indices.length - 1] <<= checksumBits;
7130
7171
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7131
7172
  return indices;
7132
7173
  }
7133
7174
  function mnemonicWordsToEntropy(words, wordlist) {
7134
7175
  const size = Math.ceil(11 * words.length / 8);
7135
- const entropy = getBytesCopy17(new Uint8Array(size));
7176
+ const entropy = arrayify16(new Uint8Array(size));
7136
7177
  let offset = 0;
7137
7178
  for (let i = 0; i < words.length; i += 1) {
7138
7179
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7152,7 +7193,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7152
7193
  const entropyBits = 32 * words.length / 3;
7153
7194
  const checksumBits = words.length / 3;
7154
7195
  const checksumMask = getUpperMask(checksumBits);
7155
- const checksum = getBytesCopy17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7196
+ const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7156
7197
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7157
7198
  throw new FuelError16(
7158
7199
  ErrorCode15.INVALID_CHECKSUM,
@@ -7227,7 +7268,7 @@ var Mnemonic = class {
7227
7268
  static mnemonicToEntropy(phrase, wordlist = english) {
7228
7269
  const words = getWords(phrase);
7229
7270
  assertMnemonic(words);
7230
- return hexlify15(mnemonicWordsToEntropy(words, wordlist));
7271
+ return hexlify16(mnemonicWordsToEntropy(words, wordlist));
7231
7272
  }
7232
7273
  /**
7233
7274
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7235,7 +7276,7 @@ var Mnemonic = class {
7235
7276
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7236
7277
  */
7237
7278
  static entropyToMnemonic(entropy, wordlist = english) {
7238
- const entropyBytes = getBytesCopy18(entropy);
7279
+ const entropyBytes = arrayify17(entropy);
7239
7280
  assertWordList(wordlist);
7240
7281
  assertEntropy(entropyBytes);
7241
7282
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7304,14 +7345,14 @@ var Mnemonic = class {
7304
7345
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7305
7346
  */
7306
7347
  static masterKeysFromSeed(seed) {
7307
- const seedArray = getBytesCopy18(seed);
7348
+ const seedArray = arrayify17(seed);
7308
7349
  if (seedArray.length < 16 || seedArray.length > 64) {
7309
7350
  throw new FuelError17(
7310
7351
  ErrorCode16.INVALID_SEED,
7311
7352
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7312
7353
  );
7313
7354
  }
7314
- return getBytesCopy18(computeHmac("sha512", MasterSecret, seedArray));
7355
+ return arrayify17(computeHmac("sha512", MasterSecret, seedArray));
7315
7356
  }
7316
7357
  /**
7317
7358
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7322,7 +7363,7 @@ var Mnemonic = class {
7322
7363
  */
7323
7364
  static seedToExtendedKey(seed, testnet = false) {
7324
7365
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7325
- const prefix = getBytesCopy18(testnet ? TestnetPRV : MainnetPRV);
7366
+ const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
7326
7367
  const depth = "0x00";
7327
7368
  const fingerprint = "0x00000000";
7328
7369
  const index = "0x00000000";
@@ -7352,7 +7393,7 @@ var Mnemonic = class {
7352
7393
  * @returns A randomly generated mnemonic
7353
7394
  */
7354
7395
  static generate(size = 32, extraEntropy = "") {
7355
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy18(extraEntropy)])) : randomBytes3(size);
7396
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7356
7397
  return Mnemonic.entropyToMnemonic(entropy);
7357
7398
  }
7358
7399
  };
@@ -7360,10 +7401,10 @@ var mnemonic_default = Mnemonic;
7360
7401
 
7361
7402
  // src/hdwallet/hdwallet.ts
7362
7403
  var HARDENED_INDEX = 2147483648;
7363
- var MainnetPRV2 = hexlify16("0x0488ade4");
7364
- var MainnetPUB = hexlify16("0x0488b21e");
7365
- var TestnetPRV2 = hexlify16("0x04358394");
7366
- var TestnetPUB = hexlify16("0x043587cf");
7404
+ var MainnetPRV2 = hexlify17("0x0488ade4");
7405
+ var MainnetPUB = hexlify17("0x0488b21e");
7406
+ var TestnetPRV2 = hexlify17("0x04358394");
7407
+ var TestnetPUB = hexlify17("0x043587cf");
7367
7408
  function base58check(data) {
7368
7409
  return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
7369
7410
  }
@@ -7374,11 +7415,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7374
7415
  return testnet ? TestnetPRV2 : MainnetPRV2;
7375
7416
  }
7376
7417
  function isPublicExtendedKey(extendedKey) {
7377
- return [MainnetPUB, TestnetPUB].includes(hexlify16(extendedKey.slice(0, 4)));
7418
+ return [MainnetPUB, TestnetPUB].includes(hexlify17(extendedKey.slice(0, 4)));
7378
7419
  }
7379
7420
  function isValidExtendedKey(extendedKey) {
7380
7421
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7381
- hexlify16(extendedKey.slice(0, 4))
7422
+ hexlify17(extendedKey.slice(0, 4))
7382
7423
  );
7383
7424
  }
7384
7425
  function parsePath(path2, depth = 0) {
@@ -7396,8 +7437,8 @@ function parsePath(path2, depth = 0) {
7396
7437
  var HDWallet = class {
7397
7438
  depth = 0;
7398
7439
  index = 0;
7399
- fingerprint = hexlify16("0x00000000");
7400
- parentFingerprint = hexlify16("0x00000000");
7440
+ fingerprint = hexlify17("0x00000000");
7441
+ parentFingerprint = hexlify17("0x00000000");
7401
7442
  privateKey;
7402
7443
  publicKey;
7403
7444
  chainCode;
@@ -7409,8 +7450,8 @@ var HDWallet = class {
7409
7450
  constructor(config) {
7410
7451
  if (config.privateKey) {
7411
7452
  const signer = new Signer(config.privateKey);
7412
- this.publicKey = hexlify16(signer.compressedPublicKey);
7413
- this.privateKey = hexlify16(config.privateKey);
7453
+ this.publicKey = hexlify17(signer.compressedPublicKey);
7454
+ this.privateKey = hexlify17(config.privateKey);
7414
7455
  } else {
7415
7456
  if (!config.publicKey) {
7416
7457
  throw new FuelError18(
@@ -7418,7 +7459,7 @@ var HDWallet = class {
7418
7459
  "Both public and private Key cannot be missing. At least one should be provided."
7419
7460
  );
7420
7461
  }
7421
- this.publicKey = hexlify16(config.publicKey);
7462
+ this.publicKey = hexlify17(config.publicKey);
7422
7463
  }
7423
7464
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7424
7465
  this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
@@ -7437,9 +7478,9 @@ var HDWallet = class {
7437
7478
  * @returns A new instance of HDWallet on the derived index
7438
7479
  */
7439
7480
  deriveIndex(index) {
7440
- const privateKey = this.privateKey && getBytesCopy19(this.privateKey);
7441
- const publicKey = getBytesCopy19(this.publicKey);
7442
- const chainCode = getBytesCopy19(this.chainCode);
7481
+ const privateKey = this.privateKey && arrayify18(this.privateKey);
7482
+ const publicKey = arrayify18(this.publicKey);
7483
+ const chainCode = arrayify18(this.chainCode);
7443
7484
  const data = new Uint8Array(37);
7444
7485
  if (index & HARDENED_INDEX) {
7445
7486
  if (!privateKey) {
@@ -7450,10 +7491,10 @@ var HDWallet = class {
7450
7491
  }
7451
7492
  data.set(privateKey, 1);
7452
7493
  } else {
7453
- data.set(getBytesCopy19(this.publicKey));
7494
+ data.set(arrayify18(this.publicKey));
7454
7495
  }
7455
7496
  data.set(toBytes2(index, 4), 33);
7456
- const bytes = getBytesCopy19(computeHmac2("sha512", chainCode, data));
7497
+ const bytes = arrayify18(computeHmac2("sha512", chainCode, data));
7457
7498
  const IL = bytes.slice(0, 32);
7458
7499
  const IR = bytes.slice(32);
7459
7500
  if (privateKey) {
@@ -7467,7 +7508,7 @@ var HDWallet = class {
7467
7508
  parentFingerprint: this.fingerprint
7468
7509
  });
7469
7510
  }
7470
- const signer = new Signer(hexlify16(IL));
7511
+ const signer = new Signer(hexlify17(IL));
7471
7512
  const Ki = signer.addPoint(publicKey);
7472
7513
  return new HDWallet({
7473
7514
  publicKey: Ki,
@@ -7502,14 +7543,12 @@ var HDWallet = class {
7502
7543
  );
7503
7544
  }
7504
7545
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7505
- const depth = hexlify16(Uint8Array.from([this.depth]));
7546
+ const depth = hexlify17(Uint8Array.from([this.depth]));
7506
7547
  const parentFingerprint = this.parentFingerprint;
7507
7548
  const index = toHex(this.index, 4);
7508
7549
  const chainCode = this.chainCode;
7509
7550
  const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
7510
- const extendedKey = getBytesCopy19(
7511
- concat5([prefix, depth, parentFingerprint, index, chainCode, key])
7512
- );
7551
+ const extendedKey = arrayify18(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
7513
7552
  return base58check(extendedKey);
7514
7553
  }
7515
7554
  /**
@@ -7521,13 +7560,13 @@ var HDWallet = class {
7521
7560
  static fromSeed(seed) {
7522
7561
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7523
7562
  return new HDWallet({
7524
- chainCode: getBytesCopy19(masterKey.slice(32)),
7525
- privateKey: getBytesCopy19(masterKey.slice(0, 32))
7563
+ chainCode: arrayify18(masterKey.slice(32)),
7564
+ privateKey: arrayify18(masterKey.slice(0, 32))
7526
7565
  });
7527
7566
  }
7528
7567
  static fromExtendedKey(extendedKey) {
7529
7568
  const decoded = toBeHex(decodeBase58(extendedKey));
7530
- const bytes = getBytesCopy19(decoded);
7569
+ const bytes = arrayify18(decoded);
7531
7570
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7532
7571
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7533
7572
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7536,9 +7575,9 @@ var HDWallet = class {
7536
7575
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7537
7576
  }
7538
7577
  const depth = bytes[4];
7539
- const parentFingerprint = hexlify16(bytes.slice(5, 9));
7540
- const index = parseInt(hexlify16(bytes.slice(9, 13)).substring(2), 16);
7541
- const chainCode = hexlify16(bytes.slice(13, 45));
7578
+ const parentFingerprint = hexlify17(bytes.slice(5, 9));
7579
+ const index = parseInt(hexlify17(bytes.slice(9, 13)).substring(2), 16);
7580
+ const chainCode = hexlify17(bytes.slice(13, 45));
7542
7581
  const key = bytes.slice(45, 78);
7543
7582
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7544
7583
  throw new FuelError18(
@@ -7754,11 +7793,10 @@ var generateTestWallet = async (provider, quantities) => {
7754
7793
  // src/test-utils/launchNode.ts
7755
7794
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
7756
7795
  import { toHex as toHex2 } from "@fuel-ts/math";
7757
- import { defaultChainConfig, defaultConsensusKey } from "@fuel-ts/utils";
7796
+ import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
7758
7797
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
7759
7798
  import { spawn } from "child_process";
7760
7799
  import { randomUUID } from "crypto";
7761
- import { hexlify as hexlify17 } from "ethers";
7762
7800
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
7763
7801
  import os from "os";
7764
7802
  import path from "path";
@@ -7843,7 +7881,7 @@ var launchNode = async ({
7843
7881
  if (!process.env.GENESIS_SECRET) {
7844
7882
  const pk = Signer.generatePrivateKey();
7845
7883
  const signer = new Signer(pk);
7846
- process.env.GENESIS_SECRET = hexlify17(pk);
7884
+ process.env.GENESIS_SECRET = hexlify18(pk);
7847
7885
  chainConfig = {
7848
7886
  ...defaultChainConfig,
7849
7887
  initial_state: {