@fuel-ts/account 0.0.0-pr-1699-20240214162434 → 0.0.0-pr-1788-20240222085506

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 (109) hide show
  1. package/dist/account.d.ts +8 -6
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel.d.ts +5 -6
  4. package/dist/connectors/fuel.d.ts.map +1 -1
  5. package/dist/connectors/index.d.ts +0 -2
  6. package/dist/connectors/index.d.ts.map +1 -1
  7. package/dist/connectors/types/asset.d.ts +0 -14
  8. package/dist/connectors/types/asset.d.ts.map +1 -1
  9. package/dist/connectors/types/data-type.d.ts +0 -4
  10. package/dist/connectors/types/data-type.d.ts.map +1 -1
  11. package/dist/connectors/types/events.d.ts +0 -5
  12. package/dist/connectors/types/events.d.ts.map +1 -1
  13. package/dist/connectors/types/index.d.ts +0 -2
  14. package/dist/connectors/types/index.d.ts.map +1 -1
  15. package/dist/connectors/utils/cache.d.ts.map +1 -1
  16. package/dist/connectors/utils/index.d.ts +0 -1
  17. package/dist/connectors/utils/index.d.ts.map +1 -1
  18. package/dist/hdwallet/hdwallet.d.ts +1 -1
  19. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  20. package/dist/index.global.js +898 -785
  21. package/dist/index.global.js.map +1 -1
  22. package/dist/index.js +460 -344
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +388 -284
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/mnemonic/mnemonic.d.ts +1 -1
  27. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  28. package/dist/mnemonic/utils.d.ts +1 -1
  29. package/dist/mnemonic/utils.d.ts.map +1 -1
  30. package/dist/predicate/predicate.d.ts.map +1 -1
  31. package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
  32. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
  33. package/dist/providers/assets/index.d.ts +4 -0
  34. package/dist/providers/assets/index.d.ts.map +1 -0
  35. package/dist/providers/assets/types.d.ts +36 -0
  36. package/dist/providers/assets/types.d.ts.map +1 -0
  37. package/dist/providers/assets/utils/index.d.ts +4 -0
  38. package/dist/providers/assets/utils/index.d.ts.map +1 -0
  39. package/dist/providers/assets/utils/network.d.ts +33 -0
  40. package/dist/providers/assets/utils/network.d.ts.map +1 -0
  41. package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
  42. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
  43. package/dist/providers/assets/utils/url.d.ts +2 -0
  44. package/dist/providers/assets/utils/url.d.ts.map +1 -0
  45. package/dist/providers/chains.d.ts +11 -0
  46. package/dist/providers/chains.d.ts.map +1 -0
  47. package/dist/providers/coin-quantity.d.ts +1 -1
  48. package/dist/providers/coin-quantity.d.ts.map +1 -1
  49. package/dist/providers/index.d.ts +2 -0
  50. package/dist/providers/index.d.ts.map +1 -1
  51. package/dist/providers/memory-cache.d.ts +1 -1
  52. package/dist/providers/memory-cache.d.ts.map +1 -1
  53. package/dist/providers/message.d.ts +1 -2
  54. package/dist/providers/message.d.ts.map +1 -1
  55. package/dist/providers/provider.d.ts +14 -7
  56. package/dist/providers/provider.d.ts.map +1 -1
  57. package/dist/providers/resource.d.ts +1 -1
  58. package/dist/providers/resource.d.ts.map +1 -1
  59. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  60. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  61. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  62. package/dist/providers/transaction-request/input.d.ts +1 -1
  63. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  64. package/dist/providers/transaction-request/output.d.ts +1 -1
  65. package/dist/providers/transaction-request/output.d.ts.map +1 -1
  66. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
  67. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  68. package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
  69. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
  70. package/dist/providers/transaction-request/transaction-request.d.ts +3 -11
  71. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  72. package/dist/providers/transaction-request/witness.d.ts +1 -1
  73. package/dist/providers/transaction-request/witness.d.ts.map +1 -1
  74. package/dist/providers/utils/gas.d.ts.map +1 -1
  75. package/dist/providers/utils/json.d.ts.map +1 -1
  76. package/dist/signer/signer.d.ts +1 -1
  77. package/dist/signer/signer.d.ts.map +1 -1
  78. package/dist/test-utils/launchNode.d.ts.map +1 -1
  79. package/dist/test-utils.global.js +3319 -3222
  80. package/dist/test-utils.global.js.map +1 -1
  81. package/dist/test-utils.js +349 -252
  82. package/dist/test-utils.js.map +1 -1
  83. package/dist/test-utils.mjs +283 -198
  84. package/dist/test-utils.mjs.map +1 -1
  85. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
  86. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  87. package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
  88. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  89. package/dist/wallet/wallet.d.ts +1 -2
  90. package/dist/wallet/wallet.d.ts.map +1 -1
  91. package/dist/wallet/wallets.d.ts +1 -1
  92. package/dist/wallet/wallets.d.ts.map +1 -1
  93. package/package.json +17 -17
  94. package/dist/connectors/fixtures/generate-accounts.d.ts +0 -2
  95. package/dist/connectors/fixtures/generate-accounts.d.ts.map +0 -1
  96. package/dist/connectors/fixtures/mocked-connector.d.ts +0 -45
  97. package/dist/connectors/fixtures/mocked-connector.d.ts.map +0 -1
  98. package/dist/connectors/fixtures/promise-callback.d.ts +0 -7
  99. package/dist/connectors/fixtures/promise-callback.d.ts.map +0 -1
  100. package/dist/connectors/fuel-wallet-locked.d.ts +0 -13
  101. package/dist/connectors/fuel-wallet-locked.d.ts.map +0 -1
  102. package/dist/connectors/fuel-wallet-provider.d.ts +0 -14
  103. package/dist/connectors/fuel-wallet-provider.d.ts.map +0 -1
  104. package/dist/connectors/types/connection.d.ts +0 -7
  105. package/dist/connectors/types/connection.d.ts.map +0 -1
  106. package/dist/connectors/types/nertwork-data.d.ts +0 -7
  107. package/dist/connectors/types/nertwork-data.d.ts.map +0 -1
  108. package/dist/connectors/utils/get-asset-by-chain.d.ts +0 -3
  109. package/dist/connectors/utils/get-asset-by-chain.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -33,12 +33,12 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
33
  import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
35
  import { bn as bn16 } from "@fuel-ts/math";
36
- import { getBytesCopy as getBytesCopy15 } from "ethers";
36
+ import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
37
 
38
38
  // src/providers/coin-quantity.ts
39
39
  import { BaseAssetId } from "@fuel-ts/address/configs";
40
40
  import { bn } from "@fuel-ts/math";
41
- import { hexlify } from "ethers";
41
+ import { hexlify } from "@fuel-ts/utils";
42
42
  var coinQuantityfy = (coinQuantityLike) => {
43
43
  let assetId;
44
44
  let amount;
@@ -74,15 +74,17 @@ var addAmountToAsset = (params) => {
74
74
  // src/providers/provider.ts
75
75
  import { Address as Address2 } from "@fuel-ts/address";
76
76
  import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
77
- import { bn as bn14, max } from "@fuel-ts/math";
77
+ import { BN, bn as bn14, max } from "@fuel-ts/math";
78
78
  import {
79
79
  InputType as InputType6,
80
80
  TransactionType as TransactionType8,
81
81
  InputMessageCoder,
82
82
  TransactionCoder as TransactionCoder5
83
83
  } from "@fuel-ts/transactions";
84
+ import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
84
85
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
85
- import { getBytesCopy as getBytesCopy12, hexlify as hexlify12, Network } from "ethers";
86
+ import { equalBytes } from "@noble/curves/abstract/utils";
87
+ import { Network } from "ethers";
86
88
  import { GraphQLClient } from "graphql-request";
87
89
  import { clone as clone3 } from "ramda";
88
90
 
@@ -955,7 +957,7 @@ async function* fuelGraphQLSubscriber({
955
957
 
956
958
  // src/providers/memory-cache.ts
957
959
  import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
958
- import { hexlify as hexlify2 } from "ethers";
960
+ import { hexlify as hexlify2 } from "@fuel-ts/utils";
959
961
  var cache = {};
960
962
  var DEFAULT_TTL_IN_MS = 30 * 1e3;
961
963
  var MemoryCache = class {
@@ -1017,23 +1019,23 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
1017
1019
  import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
1018
1020
  import { bn as bn2, toNumber } from "@fuel-ts/math";
1019
1021
  import { InputType } from "@fuel-ts/transactions";
1020
- import { getBytesCopy, hexlify as hexlify3 } from "ethers";
1022
+ import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
1021
1023
  var inputify = (value) => {
1022
1024
  const { type } = value;
1023
1025
  switch (value.type) {
1024
1026
  case InputType.Coin: {
1025
- const predicate = getBytesCopy(value.predicate ?? "0x");
1026
- const predicateData = getBytesCopy(value.predicateData ?? "0x");
1027
+ const predicate = arrayify(value.predicate ?? "0x");
1028
+ const predicateData = arrayify(value.predicateData ?? "0x");
1027
1029
  return {
1028
1030
  type: InputType.Coin,
1029
- txID: hexlify3(getBytesCopy(value.id).slice(0, 32)),
1030
- outputIndex: getBytesCopy(value.id)[32],
1031
+ txID: hexlify3(arrayify(value.id).slice(0, 32)),
1032
+ outputIndex: arrayify(value.id)[32],
1031
1033
  owner: hexlify3(value.owner),
1032
1034
  amount: bn2(value.amount),
1033
1035
  assetId: hexlify3(value.assetId),
1034
1036
  txPointer: {
1035
- blockHeight: toNumber(getBytesCopy(value.txPointer).slice(0, 8)),
1036
- txIndex: toNumber(getBytesCopy(value.txPointer).slice(8, 16))
1037
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
1038
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1037
1039
  },
1038
1040
  witnessIndex: value.witnessIndex,
1039
1041
  maturity: value.maturity ?? 0,
@@ -1052,16 +1054,16 @@ var inputify = (value) => {
1052
1054
  balanceRoot: ZeroBytes32,
1053
1055
  stateRoot: ZeroBytes32,
1054
1056
  txPointer: {
1055
- blockHeight: toNumber(getBytesCopy(value.txPointer).slice(0, 8)),
1056
- txIndex: toNumber(getBytesCopy(value.txPointer).slice(8, 16))
1057
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
1058
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
1057
1059
  },
1058
1060
  contractID: hexlify3(value.contractId)
1059
1061
  };
1060
1062
  }
1061
1063
  case InputType.Message: {
1062
- const predicate = getBytesCopy(value.predicate ?? "0x");
1063
- const predicateData = getBytesCopy(value.predicateData ?? "0x");
1064
- const data = getBytesCopy(value.data ?? "0x");
1064
+ const predicate = arrayify(value.predicate ?? "0x");
1065
+ const predicateData = arrayify(value.predicateData ?? "0x");
1066
+ const data = arrayify(value.data ?? "0x");
1065
1067
  return {
1066
1068
  type: InputType.Message,
1067
1069
  sender: hexlify3(value.sender),
@@ -1092,7 +1094,7 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
1092
1094
  import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
1093
1095
  import { bn as bn3 } from "@fuel-ts/math";
1094
1096
  import { OutputType } from "@fuel-ts/transactions";
1095
- import { hexlify as hexlify4 } from "ethers";
1097
+ import { hexlify as hexlify4 } from "@fuel-ts/utils";
1096
1098
  var outputify = (value) => {
1097
1099
  const { type } = value;
1098
1100
  switch (type) {
@@ -1155,7 +1157,7 @@ import {
1155
1157
  OutputType as OutputType2,
1156
1158
  TransactionType
1157
1159
  } from "@fuel-ts/transactions";
1158
- import { concat, getBytesCopy as getBytesCopy5, hexlify as hexlify7 } from "ethers";
1160
+ import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1159
1161
 
1160
1162
  // src/providers/resource.ts
1161
1163
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1174,7 +1176,7 @@ import {
1174
1176
  ReceiptType
1175
1177
  } from "@fuel-ts/transactions";
1176
1178
  import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
1177
- import { getBytesCopy as getBytesCopy2 } from "ethers";
1179
+ import { arrayify as arrayify2 } from "@fuel-ts/utils";
1178
1180
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1179
1181
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1180
1182
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
@@ -1318,7 +1320,7 @@ function assembleReceiptByType(receipt) {
1318
1320
  const recipient = hexOrZero(receipt.recipient);
1319
1321
  const nonce = hexOrZero(receipt.nonce);
1320
1322
  const amount = bn4(receipt.amount);
1321
- const data = receipt.data ? getBytesCopy2(receipt.data) : Uint8Array.from([]);
1323
+ const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
1322
1324
  const digest = hexOrZero(receipt.digest);
1323
1325
  const messageId = ReceiptMessageOutCoder.getMessageId({
1324
1326
  sender,
@@ -1439,7 +1441,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1439
1441
  // src/providers/utils/gas.ts
1440
1442
  import { bn as bn5 } from "@fuel-ts/math";
1441
1443
  import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
1442
- import { getBytesCopy as getBytesCopy3 } from "ethers";
1444
+ import { arrayify as arrayify3 } from "@fuel-ts/utils";
1443
1445
  var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1444
1446
  var getGasUsedFromReceipts = (receipts) => {
1445
1447
  const scriptResult = receipts.filter(
@@ -1464,9 +1466,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1464
1466
  const totalGas = inputs.reduce((total, input) => {
1465
1467
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1466
1468
  return total.add(
1467
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
1468
- resolveGasDependentCosts(getBytesCopy3(input.predicate).length, gasCosts.contractRoot)
1469
- ).add(bn5(input.predicateGasUsed))
1469
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
1470
1470
  );
1471
1471
  }
1472
1472
  if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
@@ -1515,7 +1515,7 @@ function calculateMetadataGasForTxScript({
1515
1515
  }
1516
1516
 
1517
1517
  // src/providers/utils/json.ts
1518
- import { hexlify as hexlify5 } from "ethers";
1518
+ import { hexlify as hexlify5 } from "@fuel-ts/utils";
1519
1519
  import { clone } from "ramda";
1520
1520
  function normalize(object) {
1521
1521
  Object.keys(object).forEach((key) => {
@@ -1581,9 +1581,9 @@ var NoWitnessByOwnerError = class extends Error {
1581
1581
  };
1582
1582
 
1583
1583
  // src/providers/transaction-request/witness.ts
1584
- import { getBytesCopy as getBytesCopy4, hexlify as hexlify6 } from "ethers";
1584
+ import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1585
1585
  var witnessify = (value) => {
1586
- const data = getBytesCopy4(value);
1586
+ const data = arrayify4(value);
1587
1587
  return {
1588
1588
  data: hexlify6(data),
1589
1589
  dataLength: data.length
@@ -1998,7 +1998,7 @@ var BaseTransactionRequest = class {
1998
1998
  *
1999
1999
  * @param quantities - CoinQuantity Array.
2000
2000
  */
2001
- fundWithFakeUtxos(quantities) {
2001
+ fundWithFakeUtxos(quantities, resourcesOwner) {
2002
2002
  let idCounter = 0;
2003
2003
  const generateId = () => {
2004
2004
  const counterString = String(idCounter++);
@@ -2022,7 +2022,7 @@ var BaseTransactionRequest = class {
2022
2022
  id: generateId(),
2023
2023
  amount: quantity,
2024
2024
  assetId,
2025
- owner: Address.fromRandom(),
2025
+ owner: resourcesOwner || Address.fromRandom(),
2026
2026
  maturity: 0,
2027
2027
  blockCreated: bn6(1),
2028
2028
  txCreatedIdx: bn6(1)
@@ -2055,19 +2055,29 @@ var BaseTransactionRequest = class {
2055
2055
  toJSON() {
2056
2056
  return normalizeJSON(this);
2057
2057
  }
2058
- /**
2059
- * @hidden
2060
- *
2061
- * Determines whether the transaction has a predicate input.
2062
- *
2063
- * @returns Whether the transaction has a predicate input.
2064
- */
2065
- hasPredicateInput() {
2066
- return Boolean(
2067
- this.inputs.find(
2068
- (input) => "predicate" in input && input.predicate && input.predicate !== getBytesCopy5("0x")
2069
- )
2070
- );
2058
+ updatePredicateInputs(inputs) {
2059
+ this.inputs.forEach((i) => {
2060
+ let correspondingInput;
2061
+ switch (i.type) {
2062
+ case InputType2.Contract:
2063
+ return;
2064
+ case InputType2.Coin:
2065
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2066
+ break;
2067
+ case InputType2.Message:
2068
+ correspondingInput = inputs.find(
2069
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2070
+ );
2071
+ break;
2072
+ default:
2073
+ break;
2074
+ }
2075
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2076
+ i.predicate = correspondingInput.predicate;
2077
+ i.predicateData = correspondingInput.predicateData;
2078
+ i.predicateGasUsed = correspondingInput.predicateGasUsed;
2079
+ }
2080
+ });
2071
2081
  }
2072
2082
  };
2073
2083
 
@@ -2075,14 +2085,15 @@ var BaseTransactionRequest = class {
2075
2085
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2076
2086
  import { bn as bn8 } from "@fuel-ts/math";
2077
2087
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2078
- import { getBytesCopy as getBytesCopy7, hexlify as hexlify9 } from "ethers";
2088
+ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2079
2089
 
2080
2090
  // src/providers/transaction-request/hash-transaction.ts
2081
2091
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2082
2092
  import { uint64ToBytesBE } from "@fuel-ts/hasher";
2083
2093
  import { bn as bn7 } from "@fuel-ts/math";
2084
2094
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2085
- import { concat as concat2, sha256 } from "ethers";
2095
+ import { concat as concat2 } from "@fuel-ts/utils";
2096
+ import { sha256 } from "ethers";
2086
2097
  import { clone as clone2 } from "ramda";
2087
2098
  function hashTransaction(transactionRequest, chainId) {
2088
2099
  const transaction = transactionRequest.toTransaction();
@@ -2149,10 +2160,10 @@ function hashTransaction(transactionRequest, chainId) {
2149
2160
  }
2150
2161
 
2151
2162
  // src/providers/transaction-request/storage-slot.ts
2152
- import { getBytesCopy as getBytesCopy6, hexlify as hexlify8 } from "ethers";
2163
+ import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
2153
2164
  var getStorageValue = (value) => {
2154
2165
  const v = new Uint8Array(32);
2155
- v.set(getBytesCopy6(value));
2166
+ v.set(arrayify5(value));
2156
2167
  return v;
2157
2168
  };
2158
2169
  var storageSlotify = (storageSlot) => {
@@ -2257,7 +2268,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2257
2268
  }
2258
2269
  metadataGas(gasCosts) {
2259
2270
  return calculateMetadataGasForTxCreate({
2260
- contractBytesSize: bn8(getBytesCopy7(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2271
+ contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2261
2272
  gasCosts,
2262
2273
  stateRootSize: this.storageSlots.length,
2263
2274
  txBytesSize: this.byteSize()
@@ -2271,17 +2282,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
2271
2282
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2272
2283
  import { bn as bn9 } from "@fuel-ts/math";
2273
2284
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2274
- import { getBytesCopy as getBytesCopy9, hexlify as hexlify10 } from "ethers";
2285
+ import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2275
2286
 
2276
2287
  // src/providers/transaction-request/scripts.ts
2277
- import { getBytesCopy as getBytesCopy8 } from "ethers";
2288
+ import { arrayify as arrayify7 } from "@fuel-ts/utils";
2278
2289
  var returnZeroScript = {
2279
2290
  /*
2280
2291
  Opcode::RET(REG_ZERO)
2281
2292
  Opcode::NOOP
2282
2293
  */
2283
2294
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2284
- bytes: getBytesCopy8("0x24000000"),
2295
+ bytes: arrayify7("0x24000000"),
2285
2296
  encodeScriptData: () => new Uint8Array(0)
2286
2297
  };
2287
2298
  var withdrawScript = {
@@ -2295,7 +2306,7 @@ var withdrawScript = {
2295
2306
  00000000 00000000 [amount value]
2296
2307
  */
2297
2308
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2298
- bytes: getBytesCopy8("0x5040C0105D44C0064C40001124000000"),
2309
+ bytes: arrayify7("0x5040C0105D44C0064C40001124000000"),
2299
2310
  encodeScriptData: () => new Uint8Array(0)
2300
2311
  };
2301
2312
 
@@ -2323,8 +2334,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2323
2334
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2324
2335
  super(rest);
2325
2336
  this.gasLimit = bn9(gasLimit);
2326
- this.script = getBytesCopy9(script ?? returnZeroScript.bytes);
2327
- this.scriptData = getBytesCopy9(scriptData ?? returnZeroScript.encodeScriptData());
2337
+ this.script = arrayify8(script ?? returnZeroScript.bytes);
2338
+ this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2328
2339
  }
2329
2340
  /**
2330
2341
  * Converts the transaction request to a `TransactionScript`.
@@ -2332,8 +2343,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2332
2343
  * @returns The transaction script object.
2333
2344
  */
2334
2345
  toTransaction() {
2335
- const script = getBytesCopy9(this.script ?? "0x");
2336
- const scriptData = getBytesCopy9(this.scriptData ?? "0x");
2346
+ const script = arrayify8(this.script ?? "0x");
2347
+ const scriptData = arrayify8(this.scriptData ?? "0x");
2337
2348
  return {
2338
2349
  type: TransactionType4.Script,
2339
2350
  scriptGasLimit: this.gasLimit,
@@ -2493,15 +2504,15 @@ var transactionRequestify = (obj) => {
2493
2504
  import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2494
2505
  import { bn as bn13 } from "@fuel-ts/math";
2495
2506
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2496
- import { getBytesCopy as getBytesCopy11 } from "ethers";
2507
+ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2497
2508
 
2498
2509
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2499
- import { hexlify as hexlify11 } from "ethers";
2510
+ import { hexlify as hexlify11 } from "@fuel-ts/utils";
2500
2511
 
2501
2512
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2502
2513
  import { bn as bn10 } from "@fuel-ts/math";
2503
2514
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2504
- import { getBytesCopy as getBytesCopy10 } from "ethers";
2515
+ import { arrayify as arrayify9 } from "@fuel-ts/utils";
2505
2516
  var calculateTransactionFee = (params) => {
2506
2517
  const {
2507
2518
  gasUsed,
@@ -2510,7 +2521,7 @@ var calculateTransactionFee = (params) => {
2510
2521
  } = params;
2511
2522
  const gasPerByte = bn10(feeParams.gasPerByte);
2512
2523
  const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2513
- const transactionBytes = getBytesCopy10(rawPayload);
2524
+ const transactionBytes = arrayify9(rawPayload);
2514
2525
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2515
2526
  if (transaction.type === TransactionType6.Mint) {
2516
2527
  return {
@@ -2525,7 +2536,7 @@ var calculateTransactionFee = (params) => {
2525
2536
  let gasLimit = bn10(0);
2526
2537
  if (type === TransactionType6.Create) {
2527
2538
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2528
- const contractBytesSize = bn10(getBytesCopy10(witnesses[bytecodeWitnessIndex].data).length);
2539
+ const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2529
2540
  metadataGas = calculateMetadataGasForTxCreate({
2530
2541
  contractBytesSize,
2531
2542
  gasCosts,
@@ -3330,7 +3341,7 @@ var TransactionResponse = class {
3330
3341
  */
3331
3342
  decodeTransaction(transactionWithReceipts) {
3332
3343
  return new TransactionCoder4().decode(
3333
- getBytesCopy11(transactionWithReceipts.rawPayload),
3344
+ arrayify10(transactionWithReceipts.rawPayload),
3334
3345
  0
3335
3346
  )?.[0];
3336
3347
  }
@@ -3356,7 +3367,7 @@ var TransactionResponse = class {
3356
3367
  id: this.id,
3357
3368
  receipts,
3358
3369
  transaction: decodedTransaction,
3359
- transactionBytes: getBytesCopy11(transaction.rawPayload),
3370
+ transactionBytes: arrayify10(transaction.rawPayload),
3360
3371
  gqlTransactionStatus: transaction.status,
3361
3372
  gasPerByte,
3362
3373
  gasPriceFactor,
@@ -3790,7 +3801,7 @@ var _Provider = class {
3790
3801
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
3791
3802
  const transactionRequest = transactionRequestify(transactionRequestLike);
3792
3803
  if (estimateTxDependencies) {
3793
- await this.estimateTxDependencies(transactionRequest);
3804
+ return this.estimateTxDependencies(transactionRequest);
3794
3805
  }
3795
3806
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3796
3807
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3809,6 +3820,14 @@ var _Provider = class {
3809
3820
  * @returns A promise that resolves to the estimated transaction request object.
3810
3821
  */
3811
3822
  async estimatePredicates(transactionRequest) {
3823
+ const shouldEstimatePredicates = Boolean(
3824
+ transactionRequest.inputs.find(
3825
+ (input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
3826
+ )
3827
+ );
3828
+ if (!shouldEstimatePredicates) {
3829
+ return transactionRequest;
3830
+ }
3812
3831
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3813
3832
  const response = await this.operations.estimatePredicates({
3814
3833
  encodedTransaction
@@ -3839,34 +3858,33 @@ var _Provider = class {
3839
3858
  * @returns A promise.
3840
3859
  */
3841
3860
  async estimateTxDependencies(transactionRequest) {
3842
- let missingOutputVariableCount = 0;
3843
- let missingOutputContractIdsCount = 0;
3844
- let tries = 0;
3845
3861
  if (transactionRequest.type === TransactionType8.Create) {
3846
- return;
3847
- }
3848
- let txRequest = transactionRequest;
3849
- if (txRequest.hasPredicateInput()) {
3850
- txRequest = await this.estimatePredicates(txRequest);
3862
+ return {
3863
+ receipts: []
3864
+ };
3851
3865
  }
3852
- while (tries < MAX_RETRIES) {
3866
+ await this.estimatePredicates(transactionRequest);
3867
+ let receipts = [];
3868
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3853
3869
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3854
- encodedTransaction: hexlify12(txRequest.toTransactionBytes()),
3870
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3855
3871
  utxoValidation: false
3856
3872
  });
3857
- const receipts = gqlReceipts.map(processGqlReceipt);
3873
+ receipts = gqlReceipts.map(processGqlReceipt);
3858
3874
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3859
- missingOutputVariableCount = missingOutputVariables.length;
3860
- missingOutputContractIdsCount = missingOutputContractIds.length;
3861
- if (missingOutputVariableCount === 0 && missingOutputContractIdsCount === 0) {
3862
- return;
3875
+ const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3876
+ if (hasMissingOutputs) {
3877
+ transactionRequest.addVariableOutputs(missingOutputVariables.length);
3878
+ missingOutputContractIds.forEach(({ contractId }) => {
3879
+ transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3880
+ });
3881
+ } else {
3882
+ break;
3863
3883
  }
3864
- txRequest.addVariableOutputs(missingOutputVariableCount);
3865
- missingOutputContractIds.forEach(
3866
- ({ contractId }) => txRequest.addContractInputAndOutput(Address2.fromString(contractId))
3867
- );
3868
- tries += 1;
3869
3884
  }
3885
+ return {
3886
+ receipts
3887
+ };
3870
3888
  }
3871
3889
  /**
3872
3890
  * Executes a signed transaction without applying the states changes
@@ -3881,7 +3899,7 @@ var _Provider = class {
3881
3899
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
3882
3900
  const transactionRequest = transactionRequestify(transactionRequestLike);
3883
3901
  if (estimateTxDependencies) {
3884
- await this.estimateTxDependencies(transactionRequest);
3902
+ return this.estimateTxDependencies(transactionRequest);
3885
3903
  }
3886
3904
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3887
3905
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3908,36 +3926,38 @@ var _Provider = class {
3908
3926
  * @param tolerance - The tolerance to add on top of the gasUsed.
3909
3927
  * @returns A promise that resolves to the transaction cost object.
3910
3928
  */
3911
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], { estimateTxDependencies = true, estimatePredicates = true } = {}) {
3912
- const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
3929
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3930
+ estimateTxDependencies = true,
3931
+ estimatePredicates = true,
3932
+ resourcesOwner
3933
+ } = {}) {
3934
+ const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3913
3935
  const chainInfo = this.getChain();
3914
3936
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3915
- const gasPrice = max(transactionRequest.gasPrice, minGasPrice);
3916
- const isScriptTransaction = transactionRequest.type === TransactionType8.Script;
3917
- if (transactionRequest.hasPredicateInput() && estimatePredicates) {
3937
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3938
+ const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3939
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3940
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3941
+ txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3942
+ if (estimatePredicates) {
3918
3943
  if (isScriptTransaction) {
3919
- transactionRequest.gasLimit = bn14(0);
3944
+ txRequestClone.gasLimit = bn14(0);
3945
+ }
3946
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3947
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3920
3948
  }
3921
- await this.estimatePredicates(transactionRequest);
3949
+ await this.estimatePredicates(txRequestClone);
3922
3950
  }
3923
- const minGas = transactionRequest.calculateMinGas(chainInfo);
3924
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3925
- const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
3926
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3927
- transactionRequest.fundWithFakeUtxos(allQuantities);
3928
- let gasUsed = minGas;
3951
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3952
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3929
3953
  let receipts = [];
3930
- if (isScriptTransaction) {
3931
- transactionRequest.gasPrice = bn14(0);
3932
- transactionRequest.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3933
- const result = await this.call(transactionRequest, {
3934
- estimateTxDependencies
3935
- });
3954
+ if (isScriptTransaction && estimateTxDependencies) {
3955
+ txRequestClone.gasPrice = bn14(0);
3956
+ txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3957
+ const result = await this.estimateTxDependencies(txRequestClone);
3936
3958
  receipts = result.receipts;
3937
- gasUsed = getGasUsedFromReceipts(receipts);
3938
- } else {
3939
- gasUsed = minGas;
3940
3959
  }
3960
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3941
3961
  const usedFee = calculatePriceWithFactor(
3942
3962
  gasUsed,
3943
3963
  gasPrice,
@@ -3955,7 +3975,9 @@ var _Provider = class {
3955
3975
  maxGas,
3956
3976
  usedFee,
3957
3977
  minFee,
3958
- maxFee
3978
+ maxFee,
3979
+ estimatedInputs: txRequestClone.inputs,
3980
+ estimatedOutputs: txRequestClone.outputs
3959
3981
  };
3960
3982
  }
3961
3983
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -4123,7 +4145,7 @@ var _Provider = class {
4123
4145
  time: block.header.time,
4124
4146
  transactionIds: block.transactions.map((tx) => tx.id),
4125
4147
  transactions: block.transactions.map(
4126
- (tx) => new TransactionCoder5().decode(getBytesCopy12(tx.rawPayload), 0)?.[0]
4148
+ (tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
4127
4149
  )
4128
4150
  };
4129
4151
  }
@@ -4139,7 +4161,7 @@ var _Provider = class {
4139
4161
  return null;
4140
4162
  }
4141
4163
  return new TransactionCoder5().decode(
4142
- getBytesCopy12(transaction.rawPayload),
4164
+ arrayify11(transaction.rawPayload),
4143
4165
  0
4144
4166
  )?.[0];
4145
4167
  }
@@ -4345,6 +4367,10 @@ var _Provider = class {
4345
4367
  });
4346
4368
  return bn14(latestBlockHeight);
4347
4369
  }
4370
+ // eslint-disable-next-line @typescript-eslint/require-await
4371
+ async getTransactionResponse(transactionId) {
4372
+ return new TransactionResponse(transactionId, this);
4373
+ }
4348
4374
  };
4349
4375
  var Provider = _Provider;
4350
4376
  _cacheInputs = new WeakSet();
@@ -4365,7 +4391,7 @@ __publicField(Provider, "nodeInfoCache", {});
4365
4391
  import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
4366
4392
  import { bn as bn15 } from "@fuel-ts/math";
4367
4393
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4368
- import { getBytesCopy as getBytesCopy13 } from "ethers";
4394
+ import { arrayify as arrayify12 } from "@fuel-ts/utils";
4369
4395
  async function getTransactionSummary(params) {
4370
4396
  const { id, provider, abiMap } = params;
4371
4397
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4378,7 +4404,7 @@ async function getTransactionSummary(params) {
4378
4404
  );
4379
4405
  }
4380
4406
  const [decodedTransaction] = new TransactionCoder6().decode(
4381
- getBytesCopy13(gqlTransaction.rawPayload),
4407
+ arrayify12(gqlTransaction.rawPayload),
4382
4408
  0
4383
4409
  );
4384
4410
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4389,7 +4415,7 @@ async function getTransactionSummary(params) {
4389
4415
  id: gqlTransaction.id,
4390
4416
  receipts,
4391
4417
  transaction: decodedTransaction,
4392
- transactionBytes: getBytesCopy13(gqlTransaction.rawPayload),
4418
+ transactionBytes: arrayify12(gqlTransaction.rawPayload),
4393
4419
  gqlTransactionStatus: gqlTransaction.status,
4394
4420
  gasPerByte: bn15(gasPerByte),
4395
4421
  gasPriceFactor: bn15(gasPriceFactor),
@@ -4431,13 +4457,13 @@ async function getTransactionsSummaries(params) {
4431
4457
  const transactions = edges.map((edge) => {
4432
4458
  const { node: gqlTransaction } = edge;
4433
4459
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4434
- const [decodedTransaction] = new TransactionCoder6().decode(getBytesCopy13(rawPayload), 0);
4460
+ const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
4435
4461
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4436
4462
  const transactionSummary = assembleTransactionSummary({
4437
4463
  id,
4438
4464
  receipts,
4439
4465
  transaction: decodedTransaction,
4440
- transactionBytes: getBytesCopy13(rawPayload),
4466
+ transactionBytes: arrayify12(rawPayload),
4441
4467
  gqlTransactionStatus: status,
4442
4468
  abiMap,
4443
4469
  gasPerByte,
@@ -4457,19 +4483,140 @@ async function getTransactionsSummaries(params) {
4457
4483
  };
4458
4484
  }
4459
4485
 
4486
+ // src/providers/chains.ts
4487
+ var CHAIN_IDS = {
4488
+ eth: {
4489
+ sepolia: 11155111,
4490
+ foundry: 31337
4491
+ },
4492
+ fuel: {
4493
+ beta5: 0,
4494
+ devnet: 10
4495
+ }
4496
+ };
4497
+
4498
+ // src/providers/assets/utils/network.ts
4499
+ var getDefaultChainId = (networkType) => {
4500
+ if (networkType === "ethereum") {
4501
+ return CHAIN_IDS.eth.sepolia;
4502
+ }
4503
+ if (networkType === "fuel") {
4504
+ return CHAIN_IDS.fuel.beta5;
4505
+ }
4506
+ return void 0;
4507
+ };
4508
+ var getAssetNetwork = ({
4509
+ asset,
4510
+ chainId,
4511
+ networkType
4512
+ }) => {
4513
+ const network = asset.networks.find(
4514
+ (item) => item.chainId === chainId && item.type === networkType
4515
+ );
4516
+ return network;
4517
+ };
4518
+ var getAssetWithNetwork = ({
4519
+ asset,
4520
+ chainId,
4521
+ networkType
4522
+ }) => {
4523
+ const { networks: _, ...assetRest } = asset;
4524
+ const chainIdToUse = chainId ?? getDefaultChainId(networkType);
4525
+ if (chainIdToUse === void 0) {
4526
+ return void 0;
4527
+ }
4528
+ const assetNetwork = getAssetNetwork({
4529
+ asset,
4530
+ chainId: chainIdToUse,
4531
+ networkType
4532
+ });
4533
+ if (!assetNetwork) {
4534
+ return void 0;
4535
+ }
4536
+ return {
4537
+ ...assetRest,
4538
+ ...assetNetwork
4539
+ };
4540
+ };
4541
+ var getAssetEth = (asset, chainId) => getAssetWithNetwork({
4542
+ asset,
4543
+ networkType: "ethereum",
4544
+ chainId
4545
+ });
4546
+ var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
4547
+ asset,
4548
+ networkType: "fuel",
4549
+ chainId
4550
+ });
4551
+
4552
+ // src/providers/assets/utils/url.ts
4553
+ var DELIMITER_PATH = "/";
4554
+ var trimRegex = /^\/|\/$/g;
4555
+ var trimPath = (path = "") => path.replace(trimRegex, "");
4556
+ function urlJoin(baseUrl, ...paths) {
4557
+ const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
4558
+ const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
4559
+ const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
4560
+ if (rootPath && hasBaseUrl) {
4561
+ allPaths.unshift("");
4562
+ }
4563
+ return allPaths.join(DELIMITER_PATH);
4564
+ }
4565
+
4566
+ // src/providers/assets/utils/resolveIconPaths.ts
4567
+ function resolveIconPaths(assets2, basePath = "./") {
4568
+ return assets2.map((asset) => ({
4569
+ ...asset,
4570
+ icon: urlJoin(basePath, asset.icon)
4571
+ }));
4572
+ }
4573
+
4574
+ // src/providers/assets/index.ts
4575
+ var assets = [
4576
+ {
4577
+ name: "Ethereum",
4578
+ symbol: "ETH",
4579
+ icon: "eth.svg",
4580
+ networks: [
4581
+ {
4582
+ type: "ethereum",
4583
+ chainId: CHAIN_IDS.eth.sepolia,
4584
+ decimals: 18
4585
+ },
4586
+ {
4587
+ type: "ethereum",
4588
+ chainId: CHAIN_IDS.eth.foundry,
4589
+ decimals: 18
4590
+ },
4591
+ {
4592
+ type: "fuel",
4593
+ chainId: CHAIN_IDS.fuel.beta5,
4594
+ decimals: 9,
4595
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4596
+ },
4597
+ {
4598
+ type: "fuel",
4599
+ chainId: CHAIN_IDS.fuel.devnet,
4600
+ decimals: 9,
4601
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4602
+ }
4603
+ ]
4604
+ }
4605
+ ];
4606
+
4460
4607
  // src/utils/formatTransferToContractScriptData.ts
4461
4608
  import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
4462
- import { BN } from "@fuel-ts/math";
4609
+ import { BN as BN2 } from "@fuel-ts/math";
4610
+ import { arrayify as arrayify13 } from "@fuel-ts/utils";
4463
4611
  import * as asm from "@fuels/vm-asm";
4464
- import { getBytesCopy as getBytesCopy14 } from "ethers";
4465
4612
  var formatTransferToContractScriptData = (params) => {
4466
4613
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4467
4614
  const numberCoder = new U64Coder2();
4468
- const encoded = numberCoder.encode(new BN(amountToTransfer).toNumber());
4615
+ const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
4469
4616
  const scriptData = Uint8Array.from([
4470
- ...getBytesCopy14(hexlifiedContractId),
4617
+ ...arrayify13(hexlifiedContractId),
4471
4618
  ...encoded,
4472
- ...getBytesCopy14(assetId)
4619
+ ...arrayify13(assetId)
4473
4620
  ]);
4474
4621
  return scriptData;
4475
4622
  };
@@ -4503,15 +4650,17 @@ var Account = class extends AbstractAccount {
4503
4650
  * The provider used to interact with the network.
4504
4651
  */
4505
4652
  _provider;
4653
+ _connector;
4506
4654
  /**
4507
4655
  * Creates a new Account instance.
4508
4656
  *
4509
4657
  * @param address - The address of the account.
4510
4658
  * @param provider - A Provider instance (optional).
4511
4659
  */
4512
- constructor(address, provider) {
4660
+ constructor(address, provider, connector) {
4513
4661
  super();
4514
4662
  this._provider = provider;
4663
+ this._connector = connector;
4515
4664
  this.address = Address3.fromDynamicInput(address);
4516
4665
  }
4517
4666
  /**
@@ -4717,7 +4866,10 @@ var Account = class extends AbstractAccount {
4717
4866
  const params = { gasPrice: minGasPrice, ...txParams };
4718
4867
  const request = new ScriptTransactionRequest(params);
4719
4868
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4720
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4869
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4870
+ estimateTxDependencies: true,
4871
+ resourcesOwner: this
4872
+ });
4721
4873
  request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4722
4874
  request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4723
4875
  this.validateGas({
@@ -4727,6 +4879,7 @@ var Account = class extends AbstractAccount {
4727
4879
  minGasPrice
4728
4880
  });
4729
4881
  await this.fund(request, requiredQuantities, maxFee);
4882
+ request.updatePredicateInputs(estimatedInputs);
4730
4883
  return request;
4731
4884
  }
4732
4885
  /**
@@ -4740,7 +4893,7 @@ var Account = class extends AbstractAccount {
4740
4893
  */
4741
4894
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4742
4895
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4743
- return this.sendTransaction(request);
4896
+ return this.sendTransaction(request, { estimateTxDependencies: false });
4744
4897
  }
4745
4898
  /**
4746
4899
  * Transfers coins to a contract address.
@@ -4791,14 +4944,14 @@ var Account = class extends AbstractAccount {
4791
4944
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4792
4945
  const { minGasPrice } = this.provider.getGasConfig();
4793
4946
  const recipientAddress = Address3.fromAddressOrString(recipient);
4794
- const recipientDataArray = getBytesCopy15(
4947
+ const recipientDataArray = arrayify14(
4795
4948
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4796
4949
  );
4797
- const amountDataArray = getBytesCopy15(
4950
+ const amountDataArray = arrayify14(
4798
4951
  "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4799
4952
  );
4800
4953
  const script = new Uint8Array([
4801
- ...getBytesCopy15(withdrawScript.bytes),
4954
+ ...arrayify14(withdrawScript.bytes),
4802
4955
  ...recipientDataArray,
4803
4956
  ...amountDataArray
4804
4957
  ]);
@@ -4819,17 +4972,30 @@ var Account = class extends AbstractAccount {
4819
4972
  await this.fund(request, requiredQuantities, maxFee);
4820
4973
  return this.sendTransaction(request);
4821
4974
  }
4975
+ async signMessage(message) {
4976
+ if (!this._connector) {
4977
+ throw new FuelError14(ErrorCode13.MISSING_CONNECTOR, "A connector is required to sign messages.");
4978
+ }
4979
+ return this._connector.signMessage(this.address.toString(), message);
4980
+ }
4822
4981
  /**
4823
4982
  * Sends a transaction to the network.
4824
4983
  *
4825
4984
  * @param transactionRequestLike - The transaction request to be sent.
4826
4985
  * @returns A promise that resolves to the transaction response.
4827
4986
  */
4828
- async sendTransaction(transactionRequestLike, options) {
4987
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4988
+ if (this._connector) {
4989
+ return this.provider.getTransactionResponse(
4990
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
4991
+ );
4992
+ }
4829
4993
  const transactionRequest = transactionRequestify(transactionRequestLike);
4830
- await this.provider.estimateTxDependencies(transactionRequest);
4994
+ if (estimateTxDependencies) {
4995
+ await this.provider.estimateTxDependencies(transactionRequest);
4996
+ }
4831
4997
  return this.provider.sendTransaction(transactionRequest, {
4832
- ...options,
4998
+ awaitExecution,
4833
4999
  estimateTxDependencies: false
4834
5000
  });
4835
5001
  }
@@ -4839,9 +5005,11 @@ var Account = class extends AbstractAccount {
4839
5005
  * @param transactionRequestLike - The transaction request to be simulated.
4840
5006
  * @returns A promise that resolves to the call result.
4841
5007
  */
4842
- async simulateTransaction(transactionRequestLike) {
5008
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4843
5009
  const transactionRequest = transactionRequestify(transactionRequestLike);
4844
- await this.provider.estimateTxDependencies(transactionRequest);
5010
+ if (estimateTxDependencies) {
5011
+ await this.provider.estimateTxDependencies(transactionRequest);
5012
+ }
4845
5013
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4846
5014
  }
4847
5015
  validateGas({
@@ -4867,14 +5035,15 @@ var Account = class extends AbstractAccount {
4867
5035
 
4868
5036
  // src/wallet/base-wallet-unlocked.ts
4869
5037
  import { hashMessage } from "@fuel-ts/hasher";
5038
+ import { hexlify as hexlify15 } from "@fuel-ts/utils";
4870
5039
 
4871
5040
  // src/signer/signer.ts
4872
5041
  import { Address as Address4 } from "@fuel-ts/address";
4873
5042
  import { randomBytes } from "@fuel-ts/crypto";
4874
5043
  import { hash } from "@fuel-ts/hasher";
4875
5044
  import { toBytes } from "@fuel-ts/math";
5045
+ import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
4876
5046
  import { secp256k1 } from "@noble/curves/secp256k1";
4877
- import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy16 } from "ethers";
4878
5047
  var Signer = class {
4879
5048
  address;
4880
5049
  publicKey;
@@ -4909,11 +5078,11 @@ var Signer = class {
4909
5078
  * @returns hashed signature
4910
5079
  */
4911
5080
  sign(data) {
4912
- const signature = secp256k1.sign(getBytesCopy16(data), getBytesCopy16(this.privateKey));
5081
+ const signature = secp256k1.sign(arrayify15(data), arrayify15(this.privateKey));
4913
5082
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
4914
5083
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
4915
5084
  s[0] |= (signature.recovery || 0) << 7;
4916
- return concat3([r, s]);
5085
+ return hexlify13(concat3([r, s]));
4917
5086
  }
4918
5087
  /**
4919
5088
  * Add point on the current elliptic curve
@@ -4922,8 +5091,8 @@ var Signer = class {
4922
5091
  * @returns compressed point on the curve
4923
5092
  */
4924
5093
  addPoint(point) {
4925
- const p0 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(this.compressedPublicKey));
4926
- const p1 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(point));
5094
+ const p0 = secp256k1.ProjectivePoint.fromHex(arrayify15(this.compressedPublicKey));
5095
+ const p1 = secp256k1.ProjectivePoint.fromHex(arrayify15(point));
4927
5096
  const result = p0.add(p1);
4928
5097
  return `0x${result.toHex(true)}`;
4929
5098
  }
@@ -4935,7 +5104,7 @@ var Signer = class {
4935
5104
  * @returns public key from signature from the
4936
5105
  */
4937
5106
  static recoverPublicKey(data, signature) {
4938
- const signedMessageBytes = getBytesCopy16(signature);
5107
+ const signedMessageBytes = arrayify15(signature);
4939
5108
  const r = signedMessageBytes.slice(0, 32);
4940
5109
  const s = signedMessageBytes.slice(32, 64);
4941
5110
  const recoveryParam = (s[0] & 128) >> 7;
@@ -4943,7 +5112,7 @@ var Signer = class {
4943
5112
  const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
4944
5113
  recoveryParam
4945
5114
  );
4946
- const publicKey = sig.recoverPublicKey(getBytesCopy16(data)).toRawBytes(false).slice(1);
5115
+ const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
4947
5116
  return hexlify13(publicKey);
4948
5117
  }
4949
5118
  /**
@@ -4963,7 +5132,7 @@ var Signer = class {
4963
5132
  * @returns random 32-byte hashed
4964
5133
  */
4965
5134
  static generatePrivateKey(entropy) {
4966
- return entropy ? hash(concat3([randomBytes(32), getBytesCopy16(entropy)])) : randomBytes(32);
5135
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
4967
5136
  }
4968
5137
  /**
4969
5138
  * Extended publicKey from a compact publicKey
@@ -4972,7 +5141,7 @@ var Signer = class {
4972
5141
  * @returns extended publicKey
4973
5142
  */
4974
5143
  static extendPublicKey(publicKey) {
4975
- const point = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(publicKey));
5144
+ const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
4976
5145
  return hexlify13(point.toRawBytes(false).slice(1));
4977
5146
  }
4978
5147
  };
@@ -4989,7 +5158,7 @@ import {
4989
5158
  encryptJsonWalletData
4990
5159
  } from "@fuel-ts/crypto";
4991
5160
  import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
4992
- import { hexlify as hexlify14 } from "ethers";
5161
+ import { hexlify as hexlify14 } from "@fuel-ts/utils";
4993
5162
  import { v4 as uuidv4 } from "uuid";
4994
5163
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4995
5164
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5117,7 +5286,7 @@ var BaseWalletUnlocked = class extends Account {
5117
5286
  */
5118
5287
  async signMessage(message) {
5119
5288
  const signedMessage = await this.signer().sign(hashMessage(message));
5120
- return signedMessage;
5289
+ return hexlify15(signedMessage);
5121
5290
  }
5122
5291
  /**
5123
5292
  * Signs a transaction with the wallet's private key.
@@ -5130,7 +5299,7 @@ var BaseWalletUnlocked = class extends Account {
5130
5299
  const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
5131
5300
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5132
5301
  const signature = await this.signer().sign(hashedTransaction);
5133
- return signature;
5302
+ return hexlify15(signature);
5134
5303
  }
5135
5304
  /**
5136
5305
  * Populates a transaction with the witnesses signature.
@@ -5150,12 +5319,14 @@ var BaseWalletUnlocked = class extends Account {
5150
5319
  * @param transactionRequestLike - The transaction request to send.
5151
5320
  * @returns A promise that resolves to the TransactionResponse object.
5152
5321
  */
5153
- async sendTransaction(transactionRequestLike, options) {
5322
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5154
5323
  const transactionRequest = transactionRequestify(transactionRequestLike);
5155
- await this.provider.estimateTxDependencies(transactionRequest);
5324
+ if (estimateTxDependencies) {
5325
+ await this.provider.estimateTxDependencies(transactionRequest);
5326
+ }
5156
5327
  return this.provider.sendTransaction(
5157
5328
  await this.populateTransactionWitnessesSignature(transactionRequest),
5158
- { ...options, estimateTxDependencies: false }
5329
+ { awaitExecution, estimateTxDependencies: false }
5159
5330
  );
5160
5331
  }
5161
5332
  /**
@@ -5164,9 +5335,11 @@ var BaseWalletUnlocked = class extends Account {
5164
5335
  * @param transactionRequestLike - The transaction request to simulate.
5165
5336
  * @returns A promise that resolves to the CallResult object.
5166
5337
  */
5167
- async simulateTransaction(transactionRequestLike) {
5338
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
5168
5339
  const transactionRequest = transactionRequestify(transactionRequestLike);
5169
- await this.provider.estimateTxDependencies(transactionRequest);
5340
+ if (estimateTxDependencies) {
5341
+ await this.provider.estimateTxDependencies(transactionRequest);
5342
+ }
5170
5343
  return this.provider.call(
5171
5344
  await this.populateTransactionWitnessesSignature(transactionRequest),
5172
5345
  {
@@ -5187,32 +5360,22 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5187
5360
  // src/hdwallet/hdwallet.ts
5188
5361
  import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
5189
5362
  import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5363
+ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5190
5364
  import {
5191
5365
  toBeHex,
5192
5366
  dataSlice as dataSlice2,
5193
- hexlify as hexlify16,
5194
5367
  encodeBase58 as encodeBase582,
5195
5368
  decodeBase58,
5196
5369
  sha256 as sha2564,
5197
5370
  computeHmac as computeHmac2,
5198
- ripemd160,
5199
- getBytesCopy as getBytesCopy19,
5200
- concat as concat5
5371
+ ripemd160
5201
5372
  } from "ethers";
5202
5373
 
5203
5374
  // src/mnemonic/mnemonic.ts
5204
5375
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5205
5376
  import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
5206
- import {
5207
- concat as concat4,
5208
- hexlify as hexlify15,
5209
- dataSlice,
5210
- pbkdf2,
5211
- sha256 as sha2563,
5212
- computeHmac,
5213
- encodeBase58,
5214
- getBytesCopy as getBytesCopy18
5215
- } from "ethers";
5377
+ import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5378
+ import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
5216
5379
 
5217
5380
  // src/wordlists/words/english.ts
5218
5381
  var english = [
@@ -7274,7 +7437,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
7274
7437
 
7275
7438
  // src/mnemonic/utils.ts
7276
7439
  import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
7277
- import { getBytesCopy as getBytesCopy17, sha256 as sha2562 } from "ethers";
7440
+ import { arrayify as arrayify16 } from "@fuel-ts/utils";
7441
+ import { sha256 as sha2562 } from "ethers";
7278
7442
  function toUtf8Bytes(stri) {
7279
7443
  const str = stri.normalize("NFKD");
7280
7444
  const result = [];
@@ -7341,14 +7505,14 @@ function entropyToMnemonicIndices(entropy) {
7341
7505
  }
7342
7506
  }
7343
7507
  const checksumBits = entropy.length / 4;
7344
- const checksum = getBytesCopy17(sha2562(entropy))[0] & getUpperMask(checksumBits);
7508
+ const checksum = arrayify16(sha2562(entropy))[0] & getUpperMask(checksumBits);
7345
7509
  indices[indices.length - 1] <<= checksumBits;
7346
7510
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7347
7511
  return indices;
7348
7512
  }
7349
7513
  function mnemonicWordsToEntropy(words, wordlist) {
7350
7514
  const size = Math.ceil(11 * words.length / 8);
7351
- const entropy = getBytesCopy17(new Uint8Array(size));
7515
+ const entropy = arrayify16(new Uint8Array(size));
7352
7516
  let offset = 0;
7353
7517
  for (let i = 0; i < words.length; i += 1) {
7354
7518
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7368,7 +7532,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7368
7532
  const entropyBits = 32 * words.length / 3;
7369
7533
  const checksumBits = words.length / 3;
7370
7534
  const checksumMask = getUpperMask(checksumBits);
7371
- const checksum = getBytesCopy17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7535
+ const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7372
7536
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7373
7537
  throw new FuelError16(
7374
7538
  ErrorCode15.INVALID_CHECKSUM,
@@ -7443,7 +7607,7 @@ var Mnemonic = class {
7443
7607
  static mnemonicToEntropy(phrase, wordlist = english) {
7444
7608
  const words = getWords(phrase);
7445
7609
  assertMnemonic(words);
7446
- return hexlify15(mnemonicWordsToEntropy(words, wordlist));
7610
+ return hexlify16(mnemonicWordsToEntropy(words, wordlist));
7447
7611
  }
7448
7612
  /**
7449
7613
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7451,7 +7615,7 @@ var Mnemonic = class {
7451
7615
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7452
7616
  */
7453
7617
  static entropyToMnemonic(entropy, wordlist = english) {
7454
- const entropyBytes = getBytesCopy18(entropy);
7618
+ const entropyBytes = arrayify17(entropy);
7455
7619
  assertWordList(wordlist);
7456
7620
  assertEntropy(entropyBytes);
7457
7621
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7520,14 +7684,14 @@ var Mnemonic = class {
7520
7684
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7521
7685
  */
7522
7686
  static masterKeysFromSeed(seed) {
7523
- const seedArray = getBytesCopy18(seed);
7687
+ const seedArray = arrayify17(seed);
7524
7688
  if (seedArray.length < 16 || seedArray.length > 64) {
7525
7689
  throw new FuelError17(
7526
7690
  ErrorCode16.INVALID_SEED,
7527
7691
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7528
7692
  );
7529
7693
  }
7530
- return getBytesCopy18(computeHmac("sha512", MasterSecret, seedArray));
7694
+ return arrayify17(computeHmac("sha512", MasterSecret, seedArray));
7531
7695
  }
7532
7696
  /**
7533
7697
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7538,7 +7702,7 @@ var Mnemonic = class {
7538
7702
  */
7539
7703
  static seedToExtendedKey(seed, testnet = false) {
7540
7704
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7541
- const prefix = getBytesCopy18(testnet ? TestnetPRV : MainnetPRV);
7705
+ const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
7542
7706
  const depth = "0x00";
7543
7707
  const fingerprint = "0x00000000";
7544
7708
  const index = "0x00000000";
@@ -7568,7 +7732,7 @@ var Mnemonic = class {
7568
7732
  * @returns A randomly generated mnemonic
7569
7733
  */
7570
7734
  static generate(size = 32, extraEntropy = "") {
7571
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy18(extraEntropy)])) : randomBytes3(size);
7735
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7572
7736
  return Mnemonic.entropyToMnemonic(entropy);
7573
7737
  }
7574
7738
  };
@@ -7576,10 +7740,10 @@ var mnemonic_default = Mnemonic;
7576
7740
 
7577
7741
  // src/hdwallet/hdwallet.ts
7578
7742
  var HARDENED_INDEX = 2147483648;
7579
- var MainnetPRV2 = hexlify16("0x0488ade4");
7580
- var MainnetPUB = hexlify16("0x0488b21e");
7581
- var TestnetPRV2 = hexlify16("0x04358394");
7582
- var TestnetPUB = hexlify16("0x043587cf");
7743
+ var MainnetPRV2 = hexlify17("0x0488ade4");
7744
+ var MainnetPUB = hexlify17("0x0488b21e");
7745
+ var TestnetPRV2 = hexlify17("0x04358394");
7746
+ var TestnetPUB = hexlify17("0x043587cf");
7583
7747
  function base58check(data) {
7584
7748
  return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
7585
7749
  }
@@ -7590,11 +7754,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7590
7754
  return testnet ? TestnetPRV2 : MainnetPRV2;
7591
7755
  }
7592
7756
  function isPublicExtendedKey(extendedKey) {
7593
- return [MainnetPUB, TestnetPUB].includes(hexlify16(extendedKey.slice(0, 4)));
7757
+ return [MainnetPUB, TestnetPUB].includes(hexlify17(extendedKey.slice(0, 4)));
7594
7758
  }
7595
7759
  function isValidExtendedKey(extendedKey) {
7596
7760
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7597
- hexlify16(extendedKey.slice(0, 4))
7761
+ hexlify17(extendedKey.slice(0, 4))
7598
7762
  );
7599
7763
  }
7600
7764
  function parsePath(path, depth = 0) {
@@ -7612,8 +7776,8 @@ function parsePath(path, depth = 0) {
7612
7776
  var HDWallet = class {
7613
7777
  depth = 0;
7614
7778
  index = 0;
7615
- fingerprint = hexlify16("0x00000000");
7616
- parentFingerprint = hexlify16("0x00000000");
7779
+ fingerprint = hexlify17("0x00000000");
7780
+ parentFingerprint = hexlify17("0x00000000");
7617
7781
  privateKey;
7618
7782
  publicKey;
7619
7783
  chainCode;
@@ -7625,8 +7789,8 @@ var HDWallet = class {
7625
7789
  constructor(config) {
7626
7790
  if (config.privateKey) {
7627
7791
  const signer = new Signer(config.privateKey);
7628
- this.publicKey = hexlify16(signer.compressedPublicKey);
7629
- this.privateKey = hexlify16(config.privateKey);
7792
+ this.publicKey = hexlify17(signer.compressedPublicKey);
7793
+ this.privateKey = hexlify17(config.privateKey);
7630
7794
  } else {
7631
7795
  if (!config.publicKey) {
7632
7796
  throw new FuelError18(
@@ -7634,7 +7798,7 @@ var HDWallet = class {
7634
7798
  "Both public and private Key cannot be missing. At least one should be provided."
7635
7799
  );
7636
7800
  }
7637
- this.publicKey = hexlify16(config.publicKey);
7801
+ this.publicKey = hexlify17(config.publicKey);
7638
7802
  }
7639
7803
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7640
7804
  this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
@@ -7653,9 +7817,9 @@ var HDWallet = class {
7653
7817
  * @returns A new instance of HDWallet on the derived index
7654
7818
  */
7655
7819
  deriveIndex(index) {
7656
- const privateKey = this.privateKey && getBytesCopy19(this.privateKey);
7657
- const publicKey = getBytesCopy19(this.publicKey);
7658
- const chainCode = getBytesCopy19(this.chainCode);
7820
+ const privateKey = this.privateKey && arrayify18(this.privateKey);
7821
+ const publicKey = arrayify18(this.publicKey);
7822
+ const chainCode = arrayify18(this.chainCode);
7659
7823
  const data = new Uint8Array(37);
7660
7824
  if (index & HARDENED_INDEX) {
7661
7825
  if (!privateKey) {
@@ -7666,10 +7830,10 @@ var HDWallet = class {
7666
7830
  }
7667
7831
  data.set(privateKey, 1);
7668
7832
  } else {
7669
- data.set(getBytesCopy19(this.publicKey));
7833
+ data.set(arrayify18(this.publicKey));
7670
7834
  }
7671
7835
  data.set(toBytes2(index, 4), 33);
7672
- const bytes = getBytesCopy19(computeHmac2("sha512", chainCode, data));
7836
+ const bytes = arrayify18(computeHmac2("sha512", chainCode, data));
7673
7837
  const IL = bytes.slice(0, 32);
7674
7838
  const IR = bytes.slice(32);
7675
7839
  if (privateKey) {
@@ -7683,7 +7847,7 @@ var HDWallet = class {
7683
7847
  parentFingerprint: this.fingerprint
7684
7848
  });
7685
7849
  }
7686
- const signer = new Signer(hexlify16(IL));
7850
+ const signer = new Signer(hexlify17(IL));
7687
7851
  const Ki = signer.addPoint(publicKey);
7688
7852
  return new HDWallet({
7689
7853
  publicKey: Ki,
@@ -7718,14 +7882,12 @@ var HDWallet = class {
7718
7882
  );
7719
7883
  }
7720
7884
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7721
- const depth = hexlify16(Uint8Array.from([this.depth]));
7885
+ const depth = hexlify17(Uint8Array.from([this.depth]));
7722
7886
  const parentFingerprint = this.parentFingerprint;
7723
7887
  const index = toHex(this.index, 4);
7724
7888
  const chainCode = this.chainCode;
7725
7889
  const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
7726
- const extendedKey = getBytesCopy19(
7727
- concat5([prefix, depth, parentFingerprint, index, chainCode, key])
7728
- );
7890
+ const extendedKey = arrayify18(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
7729
7891
  return base58check(extendedKey);
7730
7892
  }
7731
7893
  /**
@@ -7737,13 +7899,13 @@ var HDWallet = class {
7737
7899
  static fromSeed(seed) {
7738
7900
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7739
7901
  return new HDWallet({
7740
- chainCode: getBytesCopy19(masterKey.slice(32)),
7741
- privateKey: getBytesCopy19(masterKey.slice(0, 32))
7902
+ chainCode: arrayify18(masterKey.slice(32)),
7903
+ privateKey: arrayify18(masterKey.slice(0, 32))
7742
7904
  });
7743
7905
  }
7744
7906
  static fromExtendedKey(extendedKey) {
7745
7907
  const decoded = toBeHex(decodeBase58(extendedKey));
7746
- const bytes = getBytesCopy19(decoded);
7908
+ const bytes = arrayify18(decoded);
7747
7909
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7748
7910
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7749
7911
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7752,9 +7914,9 @@ var HDWallet = class {
7752
7914
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7753
7915
  }
7754
7916
  const depth = bytes[4];
7755
- const parentFingerprint = hexlify16(bytes.slice(5, 9));
7756
- const index = parseInt(hexlify16(bytes.slice(9, 13)).substring(2), 16);
7757
- const chainCode = hexlify16(bytes.slice(13, 45));
7917
+ const parentFingerprint = hexlify17(bytes.slice(5, 9));
7918
+ const index = parseInt(hexlify17(bytes.slice(9, 13)).substring(2), 16);
7919
+ const chainCode = hexlify17(bytes.slice(13, 45));
7758
7920
  const key = bytes.slice(45, 78);
7759
7921
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7760
7922
  throw new FuelError18(
@@ -8366,18 +8528,17 @@ import { Address as Address9 } from "@fuel-ts/address";
8366
8528
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8367
8529
  import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
8368
8530
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8369
- import { getBytesCopy as getBytesCopy21, hexlify as hexlify18 } from "ethers";
8531
+ import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8370
8532
 
8371
8533
  // src/predicate/utils/getPredicateRoot.ts
8372
8534
  import { hash as hash2 } from "@fuel-ts/hasher";
8373
8535
  import { calcRoot } from "@fuel-ts/merkle";
8374
- import { chunkAndPadBytes } from "@fuel-ts/utils";
8375
- import { hexlify as hexlify17, concat as concat6, getBytesCopy as getBytesCopy20 } from "ethers";
8536
+ import { chunkAndPadBytes, hexlify as hexlify18, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
8376
8537
  var getPredicateRoot = (bytecode) => {
8377
8538
  const chunkSize = 16 * 1024;
8378
- const bytes = getBytesCopy20(bytecode);
8539
+ const bytes = arrayify19(bytecode);
8379
8540
  const chunks = chunkAndPadBytes(bytes, chunkSize);
8380
- const codeRoot = calcRoot(chunks.map((c) => hexlify17(c)));
8541
+ const codeRoot = calcRoot(chunks.map((c) => hexlify18(c)));
8381
8542
  const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
8382
8543
  return predicateRoot;
8383
8544
  };
@@ -8417,7 +8578,7 @@ var Predicate = class extends Account {
8417
8578
  const request = transactionRequestify(transactionRequestLike);
8418
8579
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8419
8580
  request.inputs?.forEach((input) => {
8420
- if (input.type === InputType7.Coin && hexlify18(input.owner) === this.address.toB256()) {
8581
+ if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8421
8582
  input.predicate = this.bytes;
8422
8583
  input.predicateData = this.getPredicateData(policies.length);
8423
8584
  }
@@ -8488,7 +8649,7 @@ var Predicate = class extends Account {
8488
8649
  * @returns An object containing the new predicate bytes and interface.
8489
8650
  */
8490
8651
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8491
- let predicateBytes = getBytesCopy21(bytes);
8652
+ let predicateBytes = arrayify20(bytes);
8492
8653
  let abiInterface;
8493
8654
  if (jsonAbi) {
8494
8655
  abiInterface = new Interface3(jsonAbi);
@@ -8548,6 +8709,9 @@ var Predicate = class extends Account {
8548
8709
  }
8549
8710
  };
8550
8711
 
8712
+ // src/connectors/fuel.ts
8713
+ import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
8714
+
8551
8715
  // src/connectors/fuel-connector.ts
8552
8716
  import { EventEmitter as EventEmitter2 } from "events";
8553
8717
 
@@ -8588,14 +8752,6 @@ var FuelConnectorEventTypes = /* @__PURE__ */ ((FuelConnectorEventTypes2) => {
8588
8752
  })(FuelConnectorEventTypes || {});
8589
8753
  var FuelConnectorEventType = "FuelConnector";
8590
8754
 
8591
- // src/connectors/types/constants.ts
8592
- var CONNECTOR_SCRIPT = "FuelConnectorScript";
8593
- var CONTENT_SCRIPT_NAME = "FuelContentScript";
8594
- var BACKGROUND_SCRIPT_NAME = "FuelBackgroundScript";
8595
- var POPUP_SCRIPT_NAME = "FuelPopUpScript";
8596
- var VAULT_SCRIPT_NAME = "FuelVaultScript";
8597
- var EVENT_MESSAGE = "message";
8598
-
8599
8755
  // src/connectors/types/data-type.ts
8600
8756
  var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
8601
8757
  MessageTypes2["ping"] = "ping";
@@ -8845,40 +9001,6 @@ var FuelConnector = class extends EventEmitter2 {
8845
9001
  }
8846
9002
  };
8847
9003
 
8848
- // src/connectors/fuel-wallet-locked.ts
8849
- var FuelWalletLocked = class extends WalletLocked {
8850
- connector;
8851
- _provider;
8852
- constructor(address, connector, provider) {
8853
- super(address, provider);
8854
- this.connector = connector;
8855
- this._provider = provider;
8856
- }
8857
- async signMessage(message) {
8858
- return this.connector.signMessage(this.address.toString(), message);
8859
- }
8860
- async sendTransaction(transaction) {
8861
- const transactionId = await this.connector.sendTransaction(
8862
- this.address.toString(),
8863
- transaction
8864
- );
8865
- return this.provider.getTransactionResponse(transactionId);
8866
- }
8867
- };
8868
-
8869
- // src/connectors/fuel-wallet-provider.ts
8870
- var FuelWalletProvider = class extends Provider {
8871
- static async create(url, options) {
8872
- const provider = new FuelWalletProvider(url, options);
8873
- await provider.fetchChainAndNodeInfo();
8874
- return provider;
8875
- }
8876
- // eslint-disable-next-line @typescript-eslint/require-await
8877
- async getTransactionResponse(transactionId) {
8878
- return new TransactionResponse(transactionId, this);
8879
- }
8880
- };
8881
-
8882
9004
  // src/connectors/utils/cache.ts
8883
9005
  function cacheFor(fn, { cache: cache2, cacheTime, key }) {
8884
9006
  return async (...args) => {
@@ -8908,23 +9030,6 @@ function dispatchFuelConnectorEvent(connector) {
8908
9030
  );
8909
9031
  }
8910
9032
 
8911
- // src/connectors/utils/get-asset-by-chain.ts
8912
- function getAssetByChain(asset, chainId, network = "fuel") {
8913
- const assetFuelNetwork = asset.networks.find(
8914
- (item) => item.chainId === chainId && item.type === network
8915
- );
8916
- if (!assetFuelNetwork) {
8917
- throw new Error("Asset not found for the given chain and network.");
8918
- }
8919
- return {
8920
- ...asset,
8921
- assetId: assetFuelNetwork.assetId,
8922
- decimals: assetFuelNetwork.decimals,
8923
- chainId: assetFuelNetwork.chainId,
8924
- network: assetFuelNetwork.type
8925
- };
8926
- }
8927
-
8928
9033
  // src/connectors/utils/promises.ts
8929
9034
  function deferPromise() {
8930
9035
  const defer = {};
@@ -8946,6 +9051,7 @@ async function withTimeout(promise, timeout = 1050) {
8946
9051
  // src/connectors/fuel.ts
8947
9052
  var HAS_CONNECTOR_TIMEOUT = 2e3;
8948
9053
  var PING_CACHE_TIME = 5e3;
9054
+ var { warn } = console;
8949
9055
  var _Fuel = class extends FuelConnector {
8950
9056
  _storage = null;
8951
9057
  _connectors = [];
@@ -9214,14 +9320,12 @@ var _Fuel = class extends FuelConnector {
9214
9320
  * Return a Fuel Provider instance with extends features to work with
9215
9321
  * connectors.
9216
9322
  *
9217
- * @deprecated Provider is going to be deprecated in the future.
9323
+ * @deprecated getProvider is deprecated and is going to be removed in the future, use getWallet instead.
9218
9324
  */
9219
9325
  async getProvider(providerOrNetwork) {
9220
- if (process.env.NODE_ENV !== "production") {
9221
- console.warn(
9222
- "Get provider is deprecated, use getWallet instead. Provider is going to be removed in the future."
9223
- );
9224
- }
9326
+ warn(
9327
+ "getProvider is deprecated and is going to be removed in the future, use getWallet instead."
9328
+ );
9225
9329
  return this._getProvider(providerOrNetwork);
9226
9330
  }
9227
9331
  /**
@@ -9233,12 +9337,12 @@ var _Fuel = class extends FuelConnector {
9233
9337
  if (providerOrNetwork && "getTransactionResponse" in providerOrNetwork) {
9234
9338
  provider = providerOrNetwork;
9235
9339
  } else if (providerOrNetwork && "chainId" in providerOrNetwork && "url" in providerOrNetwork) {
9236
- provider = await FuelWalletProvider.create(providerOrNetwork.url);
9340
+ provider = await Provider.create(providerOrNetwork.url);
9237
9341
  } else if (!providerOrNetwork) {
9238
9342
  const currentNetwork = await this.currentNetwork();
9239
- provider = await FuelWalletProvider.create(currentNetwork.url);
9343
+ provider = await Provider.create(currentNetwork.url);
9240
9344
  } else {
9241
- throw new Error("Provider is not valid.");
9345
+ throw new FuelError24(ErrorCode23.INVALID_PROVIDER, "Provider is not valid.");
9242
9346
  }
9243
9347
  return provider;
9244
9348
  }
@@ -9248,7 +9352,7 @@ var _Fuel = class extends FuelConnector {
9248
9352
  */
9249
9353
  async getWallet(address, providerOrNetwork) {
9250
9354
  const provider = await this._getProvider(providerOrNetwork);
9251
- return new FuelWalletLocked(address, this, provider);
9355
+ return new Account(address, provider, this);
9252
9356
  }
9253
9357
  /**
9254
9358
  * Remove all open listeners this is useful when you want to
@@ -9279,22 +9383,17 @@ __publicField(Fuel, "defaultConfig", {});
9279
9383
  export {
9280
9384
  Account,
9281
9385
  AddressType,
9282
- BACKGROUND_SCRIPT_NAME,
9283
9386
  BaseTransactionRequest,
9284
9387
  BaseWalletUnlocked,
9285
- CONNECTOR_SCRIPT,
9286
- CONTENT_SCRIPT_NAME,
9388
+ CHAIN_IDS,
9287
9389
  ChainName,
9288
9390
  ChangeOutputCollisionError,
9289
9391
  CreateTransactionRequest,
9290
- EVENT_MESSAGE,
9291
9392
  Fuel,
9292
9393
  FuelConnector,
9293
9394
  FuelConnectorEventType,
9294
9395
  FuelConnectorEventTypes,
9295
9396
  FuelConnectorMethods,
9296
- FuelWalletLocked,
9297
- FuelWalletProvider,
9298
9397
  hdwallet_default as HDWallet,
9299
9398
  Language,
9300
9399
  LocalStorage,
@@ -9306,7 +9405,6 @@ export {
9306
9405
  NoWitnessAtIndexError,
9307
9406
  NoWitnessByOwnerError,
9308
9407
  OperationName,
9309
- POPUP_SCRIPT_NAME,
9310
9408
  Predicate,
9311
9409
  PrivateKeyVault,
9312
9410
  Provider,
@@ -9317,7 +9415,6 @@ export {
9317
9415
  TransactionStatus,
9318
9416
  TransactionType,
9319
9417
  TransactionTypeName,
9320
- VAULT_SCRIPT_NAME,
9321
9418
  Vault,
9322
9419
  Wallet,
9323
9420
  WalletLocked,
@@ -9327,6 +9424,7 @@ export {
9327
9424
  addOperation,
9328
9425
  assembleReceiptByType,
9329
9426
  assembleTransactionSummary,
9427
+ assets,
9330
9428
  buildBlockExplorerUrl,
9331
9429
  cacheFor,
9332
9430
  calculateMetadataGasForTxCreate,
@@ -9344,11 +9442,15 @@ export {
9344
9442
  fromTai64ToUnix,
9345
9443
  fromUnixToTai64,
9346
9444
  gasUsedByInputs,
9347
- getAssetByChain,
9445
+ getAssetEth,
9446
+ getAssetFuel,
9447
+ getAssetNetwork,
9448
+ getAssetWithNetwork,
9348
9449
  getContractCallOperations,
9349
9450
  getContractCreatedOperations,
9350
9451
  getContractTransferOperations,
9351
9452
  getDecodedLogs,
9453
+ getDefaultChainId,
9352
9454
  getGasUsedFromReceipts,
9353
9455
  getInputAccountAddress,
9354
9456
  getInputContractFromIndex,
@@ -9397,9 +9499,11 @@ export {
9397
9499
  processGqlReceipt,
9398
9500
  processGraphqlStatus,
9399
9501
  resolveGasDependentCosts,
9502
+ resolveIconPaths,
9400
9503
  returnZeroScript,
9401
9504
  sleep,
9402
9505
  transactionRequestify,
9506
+ urlJoin,
9403
9507
  withTimeout,
9404
9508
  withdrawScript
9405
9509
  };