@fuel-ts/account 0.0.0-pr-1699-20240214162434 → 0.0.0-pr-1784-20240221124858

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 (70) hide show
  1. package/dist/account.d.ts +7 -4
  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/index.global.js +718 -605
  19. package/dist/index.global.js.map +1 -1
  20. package/dist/index.js +278 -162
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +336 -220
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/predicate/predicate.d.ts.map +1 -1
  25. package/dist/providers/assets/index.d.ts +4 -0
  26. package/dist/providers/assets/index.d.ts.map +1 -0
  27. package/dist/providers/assets/types.d.ts +36 -0
  28. package/dist/providers/assets/types.d.ts.map +1 -0
  29. package/dist/providers/assets/utils/index.d.ts +4 -0
  30. package/dist/providers/assets/utils/index.d.ts.map +1 -0
  31. package/dist/providers/assets/utils/network.d.ts +33 -0
  32. package/dist/providers/assets/utils/network.d.ts.map +1 -0
  33. package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
  34. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
  35. package/dist/providers/assets/utils/url.d.ts +2 -0
  36. package/dist/providers/assets/utils/url.d.ts.map +1 -0
  37. package/dist/providers/chains.d.ts +11 -0
  38. package/dist/providers/chains.d.ts.map +1 -0
  39. package/dist/providers/index.d.ts +2 -0
  40. package/dist/providers/index.d.ts.map +1 -1
  41. package/dist/providers/provider.d.ts +14 -6
  42. package/dist/providers/provider.d.ts.map +1 -1
  43. package/dist/providers/transaction-request/transaction-request.d.ts +3 -10
  44. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  45. package/dist/providers/utils/json.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +593 -496
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +176 -79
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +231 -134
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts +3 -3
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
  55. package/dist/connectors/fixtures/generate-accounts.d.ts +0 -2
  56. package/dist/connectors/fixtures/generate-accounts.d.ts.map +0 -1
  57. package/dist/connectors/fixtures/mocked-connector.d.ts +0 -45
  58. package/dist/connectors/fixtures/mocked-connector.d.ts.map +0 -1
  59. package/dist/connectors/fixtures/promise-callback.d.ts +0 -7
  60. package/dist/connectors/fixtures/promise-callback.d.ts.map +0 -1
  61. package/dist/connectors/fuel-wallet-locked.d.ts +0 -13
  62. package/dist/connectors/fuel-wallet-locked.d.ts.map +0 -1
  63. package/dist/connectors/fuel-wallet-provider.d.ts +0 -14
  64. package/dist/connectors/fuel-wallet-provider.d.ts.map +0 -1
  65. package/dist/connectors/types/connection.d.ts +0 -7
  66. package/dist/connectors/types/connection.d.ts.map +0 -1
  67. package/dist/connectors/types/nertwork-data.d.ts +0 -7
  68. package/dist/connectors/types/nertwork-data.d.ts.map +0 -1
  69. package/dist/connectors/utils/get-asset-by-chain.d.ts +0 -3
  70. package/dist/connectors/utils/get-asset-by-chain.d.ts.map +0 -1
@@ -27,7 +27,7 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
27
27
  import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
28
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
29
  import { bn as bn16 } from "@fuel-ts/math";
30
- import { getBytesCopy as getBytesCopy15 } from "ethers";
30
+ import { getBytesCopy as getBytesCopy14 } from "ethers";
31
31
 
32
32
  // src/providers/coin-quantity.ts
33
33
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -68,15 +68,17 @@ var addAmountToAsset = (params) => {
68
68
  // src/providers/provider.ts
69
69
  import { Address as Address2 } from "@fuel-ts/address";
70
70
  import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
71
- import { bn as bn14, max } from "@fuel-ts/math";
71
+ import { BN, bn as bn14, max } from "@fuel-ts/math";
72
72
  import {
73
73
  InputType as InputType6,
74
74
  TransactionType as TransactionType8,
75
75
  InputMessageCoder,
76
76
  TransactionCoder as TransactionCoder5
77
77
  } from "@fuel-ts/transactions";
78
+ import { arrayify } from "@fuel-ts/utils";
78
79
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
79
- import { getBytesCopy as getBytesCopy12, hexlify as hexlify12, Network } from "ethers";
80
+ import { equalBytes } from "@noble/curves/abstract/utils";
81
+ import { getBytesCopy as getBytesCopy11, hexlify as hexlify12, Network } from "ethers";
80
82
  import { GraphQLClient } from "graphql-request";
81
83
  import { clone as clone3 } from "ramda";
82
84
 
@@ -1149,7 +1151,7 @@ import {
1149
1151
  OutputType as OutputType2,
1150
1152
  TransactionType
1151
1153
  } from "@fuel-ts/transactions";
1152
- import { concat, getBytesCopy as getBytesCopy5, hexlify as hexlify7 } from "ethers";
1154
+ import { concat, hexlify as hexlify7 } from "ethers";
1153
1155
 
1154
1156
  // src/providers/resource.ts
1155
1157
  var isCoin = (resource) => "id" in resource;
@@ -1917,7 +1919,7 @@ var BaseTransactionRequest = class {
1917
1919
  *
1918
1920
  * @param quantities - CoinQuantity Array.
1919
1921
  */
1920
- fundWithFakeUtxos(quantities) {
1922
+ fundWithFakeUtxos(quantities, resourcesOwner) {
1921
1923
  let idCounter = 0;
1922
1924
  const generateId = () => {
1923
1925
  const counterString = String(idCounter++);
@@ -1941,7 +1943,7 @@ var BaseTransactionRequest = class {
1941
1943
  id: generateId(),
1942
1944
  amount: quantity,
1943
1945
  assetId,
1944
- owner: Address.fromRandom(),
1946
+ owner: resourcesOwner || Address.fromRandom(),
1945
1947
  maturity: 0,
1946
1948
  blockCreated: bn6(1),
1947
1949
  txCreatedIdx: bn6(1)
@@ -1974,19 +1976,29 @@ var BaseTransactionRequest = class {
1974
1976
  toJSON() {
1975
1977
  return normalizeJSON(this);
1976
1978
  }
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
- );
1979
+ updatePredicateInputs(inputs) {
1980
+ this.inputs.forEach((i) => {
1981
+ let correspondingInput;
1982
+ switch (i.type) {
1983
+ case InputType2.Contract:
1984
+ return;
1985
+ case InputType2.Coin:
1986
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
1987
+ break;
1988
+ case InputType2.Message:
1989
+ correspondingInput = inputs.find(
1990
+ (x) => x.type === InputType2.Message && x.sender === i.sender
1991
+ );
1992
+ break;
1993
+ default:
1994
+ break;
1995
+ }
1996
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
1997
+ i.predicate = correspondingInput.predicate;
1998
+ i.predicateData = correspondingInput.predicateData;
1999
+ i.predicateGasUsed = correspondingInput.predicateGasUsed;
2000
+ }
2001
+ });
1990
2002
  }
1991
2003
  };
1992
2004
 
@@ -1994,7 +2006,7 @@ var BaseTransactionRequest = class {
1994
2006
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
1995
2007
  import { bn as bn8 } from "@fuel-ts/math";
1996
2008
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
1997
- import { getBytesCopy as getBytesCopy7, hexlify as hexlify9 } from "ethers";
2009
+ import { getBytesCopy as getBytesCopy6, hexlify as hexlify9 } from "ethers";
1998
2010
 
1999
2011
  // src/providers/transaction-request/hash-transaction.ts
2000
2012
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
@@ -2068,10 +2080,10 @@ function hashTransaction(transactionRequest, chainId) {
2068
2080
  }
2069
2081
 
2070
2082
  // src/providers/transaction-request/storage-slot.ts
2071
- import { getBytesCopy as getBytesCopy6, hexlify as hexlify8 } from "ethers";
2083
+ import { getBytesCopy as getBytesCopy5, hexlify as hexlify8 } from "ethers";
2072
2084
  var getStorageValue = (value) => {
2073
2085
  const v = new Uint8Array(32);
2074
- v.set(getBytesCopy6(value));
2086
+ v.set(getBytesCopy5(value));
2075
2087
  return v;
2076
2088
  };
2077
2089
  var storageSlotify = (storageSlot) => {
@@ -2176,7 +2188,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2176
2188
  }
2177
2189
  metadataGas(gasCosts) {
2178
2190
  return calculateMetadataGasForTxCreate({
2179
- contractBytesSize: bn8(getBytesCopy7(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2191
+ contractBytesSize: bn8(getBytesCopy6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2180
2192
  gasCosts,
2181
2193
  stateRootSize: this.storageSlots.length,
2182
2194
  txBytesSize: this.byteSize()
@@ -2190,17 +2202,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
2190
2202
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2191
2203
  import { bn as bn9 } from "@fuel-ts/math";
2192
2204
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2193
- import { getBytesCopy as getBytesCopy9, hexlify as hexlify10 } from "ethers";
2205
+ import { getBytesCopy as getBytesCopy8, hexlify as hexlify10 } from "ethers";
2194
2206
 
2195
2207
  // src/providers/transaction-request/scripts.ts
2196
- import { getBytesCopy as getBytesCopy8 } from "ethers";
2208
+ import { getBytesCopy as getBytesCopy7 } from "ethers";
2197
2209
  var returnZeroScript = {
2198
2210
  /*
2199
2211
  Opcode::RET(REG_ZERO)
2200
2212
  Opcode::NOOP
2201
2213
  */
2202
2214
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2203
- bytes: getBytesCopy8("0x24000000"),
2215
+ bytes: getBytesCopy7("0x24000000"),
2204
2216
  encodeScriptData: () => new Uint8Array(0)
2205
2217
  };
2206
2218
  var withdrawScript = {
@@ -2214,7 +2226,7 @@ var withdrawScript = {
2214
2226
  00000000 00000000 [amount value]
2215
2227
  */
2216
2228
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2217
- bytes: getBytesCopy8("0x5040C0105D44C0064C40001124000000"),
2229
+ bytes: getBytesCopy7("0x5040C0105D44C0064C40001124000000"),
2218
2230
  encodeScriptData: () => new Uint8Array(0)
2219
2231
  };
2220
2232
 
@@ -2242,8 +2254,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2242
2254
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2243
2255
  super(rest);
2244
2256
  this.gasLimit = bn9(gasLimit);
2245
- this.script = getBytesCopy9(script ?? returnZeroScript.bytes);
2246
- this.scriptData = getBytesCopy9(scriptData ?? returnZeroScript.encodeScriptData());
2257
+ this.script = getBytesCopy8(script ?? returnZeroScript.bytes);
2258
+ this.scriptData = getBytesCopy8(scriptData ?? returnZeroScript.encodeScriptData());
2247
2259
  }
2248
2260
  /**
2249
2261
  * Converts the transaction request to a `TransactionScript`.
@@ -2251,8 +2263,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2251
2263
  * @returns The transaction script object.
2252
2264
  */
2253
2265
  toTransaction() {
2254
- const script = getBytesCopy9(this.script ?? "0x");
2255
- const scriptData = getBytesCopy9(this.scriptData ?? "0x");
2266
+ const script = getBytesCopy8(this.script ?? "0x");
2267
+ const scriptData = getBytesCopy8(this.scriptData ?? "0x");
2256
2268
  return {
2257
2269
  type: TransactionType4.Script,
2258
2270
  scriptGasLimit: this.gasLimit,
@@ -2412,7 +2424,7 @@ var transactionRequestify = (obj) => {
2412
2424
  import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2413
2425
  import { bn as bn13 } from "@fuel-ts/math";
2414
2426
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2415
- import { getBytesCopy as getBytesCopy11 } from "ethers";
2427
+ import { getBytesCopy as getBytesCopy10 } from "ethers";
2416
2428
 
2417
2429
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2418
2430
  import { hexlify as hexlify11 } from "ethers";
@@ -2420,7 +2432,7 @@ import { hexlify as hexlify11 } from "ethers";
2420
2432
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2421
2433
  import { bn as bn10 } from "@fuel-ts/math";
2422
2434
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2423
- import { getBytesCopy as getBytesCopy10 } from "ethers";
2435
+ import { getBytesCopy as getBytesCopy9 } from "ethers";
2424
2436
  var calculateTransactionFee = (params) => {
2425
2437
  const {
2426
2438
  gasUsed,
@@ -2429,7 +2441,7 @@ var calculateTransactionFee = (params) => {
2429
2441
  } = params;
2430
2442
  const gasPerByte = bn10(feeParams.gasPerByte);
2431
2443
  const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2432
- const transactionBytes = getBytesCopy10(rawPayload);
2444
+ const transactionBytes = getBytesCopy9(rawPayload);
2433
2445
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2434
2446
  if (transaction.type === TransactionType6.Mint) {
2435
2447
  return {
@@ -2444,7 +2456,7 @@ var calculateTransactionFee = (params) => {
2444
2456
  let gasLimit = bn10(0);
2445
2457
  if (type === TransactionType6.Create) {
2446
2458
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2447
- const contractBytesSize = bn10(getBytesCopy10(witnesses[bytecodeWitnessIndex].data).length);
2459
+ const contractBytesSize = bn10(getBytesCopy9(witnesses[bytecodeWitnessIndex].data).length);
2448
2460
  metadataGas = calculateMetadataGasForTxCreate({
2449
2461
  contractBytesSize,
2450
2462
  gasCosts,
@@ -3203,7 +3215,7 @@ var TransactionResponse = class {
3203
3215
  */
3204
3216
  decodeTransaction(transactionWithReceipts) {
3205
3217
  return new TransactionCoder4().decode(
3206
- getBytesCopy11(transactionWithReceipts.rawPayload),
3218
+ getBytesCopy10(transactionWithReceipts.rawPayload),
3207
3219
  0
3208
3220
  )?.[0];
3209
3221
  }
@@ -3229,7 +3241,7 @@ var TransactionResponse = class {
3229
3241
  id: this.id,
3230
3242
  receipts,
3231
3243
  transaction: decodedTransaction,
3232
- transactionBytes: getBytesCopy11(transaction.rawPayload),
3244
+ transactionBytes: getBytesCopy10(transaction.rawPayload),
3233
3245
  gqlTransactionStatus: transaction.status,
3234
3246
  gasPerByte,
3235
3247
  gasPriceFactor,
@@ -3652,7 +3664,7 @@ var _Provider = class {
3652
3664
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
3653
3665
  const transactionRequest = transactionRequestify(transactionRequestLike);
3654
3666
  if (estimateTxDependencies) {
3655
- await this.estimateTxDependencies(transactionRequest);
3667
+ return this.estimateTxDependencies(transactionRequest);
3656
3668
  }
3657
3669
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3658
3670
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3671,6 +3683,14 @@ var _Provider = class {
3671
3683
  * @returns A promise that resolves to the estimated transaction request object.
3672
3684
  */
3673
3685
  async estimatePredicates(transactionRequest) {
3686
+ const shouldEstimatePredicates = Boolean(
3687
+ transactionRequest.inputs.find(
3688
+ (input) => "predicate" in input && input.predicate && !equalBytes(arrayify(input.predicate), arrayify("0x")) && new BN(input.predicateGasUsed).isZero()
3689
+ )
3690
+ );
3691
+ if (!shouldEstimatePredicates) {
3692
+ return transactionRequest;
3693
+ }
3674
3694
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3675
3695
  const response = await this.operations.estimatePredicates({
3676
3696
  encodedTransaction
@@ -3701,34 +3721,33 @@ var _Provider = class {
3701
3721
  * @returns A promise.
3702
3722
  */
3703
3723
  async estimateTxDependencies(transactionRequest) {
3704
- let missingOutputVariableCount = 0;
3705
- let missingOutputContractIdsCount = 0;
3706
- let tries = 0;
3707
3724
  if (transactionRequest.type === TransactionType8.Create) {
3708
- return;
3709
- }
3710
- let txRequest = transactionRequest;
3711
- if (txRequest.hasPredicateInput()) {
3712
- txRequest = await this.estimatePredicates(txRequest);
3725
+ return {
3726
+ receipts: []
3727
+ };
3713
3728
  }
3714
- while (tries < MAX_RETRIES) {
3729
+ await this.estimatePredicates(transactionRequest);
3730
+ let receipts = [];
3731
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3715
3732
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3716
- encodedTransaction: hexlify12(txRequest.toTransactionBytes()),
3733
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3717
3734
  utxoValidation: false
3718
3735
  });
3719
- const receipts = gqlReceipts.map(processGqlReceipt);
3736
+ receipts = gqlReceipts.map(processGqlReceipt);
3720
3737
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3721
- missingOutputVariableCount = missingOutputVariables.length;
3722
- missingOutputContractIdsCount = missingOutputContractIds.length;
3723
- if (missingOutputVariableCount === 0 && missingOutputContractIdsCount === 0) {
3724
- return;
3738
+ const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3739
+ if (hasMissingOutputs) {
3740
+ transactionRequest.addVariableOutputs(missingOutputVariables.length);
3741
+ missingOutputContractIds.forEach(({ contractId }) => {
3742
+ transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3743
+ });
3744
+ } else {
3745
+ break;
3725
3746
  }
3726
- txRequest.addVariableOutputs(missingOutputVariableCount);
3727
- missingOutputContractIds.forEach(
3728
- ({ contractId }) => txRequest.addContractInputAndOutput(Address2.fromString(contractId))
3729
- );
3730
- tries += 1;
3731
3747
  }
3748
+ return {
3749
+ receipts
3750
+ };
3732
3751
  }
3733
3752
  /**
3734
3753
  * Executes a signed transaction without applying the states changes
@@ -3743,7 +3762,7 @@ var _Provider = class {
3743
3762
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
3744
3763
  const transactionRequest = transactionRequestify(transactionRequestLike);
3745
3764
  if (estimateTxDependencies) {
3746
- await this.estimateTxDependencies(transactionRequest);
3765
+ return this.estimateTxDependencies(transactionRequest);
3747
3766
  }
3748
3767
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3749
3768
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3770,36 +3789,38 @@ var _Provider = class {
3770
3789
  * @param tolerance - The tolerance to add on top of the gasUsed.
3771
3790
  * @returns A promise that resolves to the transaction cost object.
3772
3791
  */
3773
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], { estimateTxDependencies = true, estimatePredicates = true } = {}) {
3774
- const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
3792
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3793
+ estimateTxDependencies = true,
3794
+ estimatePredicates = true,
3795
+ resourcesOwner
3796
+ } = {}) {
3797
+ const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3775
3798
  const chainInfo = this.getChain();
3776
3799
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3777
- const gasPrice = max(transactionRequest.gasPrice, minGasPrice);
3778
- const isScriptTransaction = transactionRequest.type === TransactionType8.Script;
3779
- if (transactionRequest.hasPredicateInput() && estimatePredicates) {
3800
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3801
+ const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3802
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3803
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3804
+ txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3805
+ if (estimatePredicates) {
3780
3806
  if (isScriptTransaction) {
3781
- transactionRequest.gasLimit = bn14(0);
3807
+ txRequestClone.gasLimit = bn14(0);
3808
+ }
3809
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3810
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3782
3811
  }
3783
- await this.estimatePredicates(transactionRequest);
3812
+ await this.estimatePredicates(txRequestClone);
3784
3813
  }
3785
- const minGas = transactionRequest.calculateMinGas(chainInfo);
3786
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3787
- const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
3788
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3789
- transactionRequest.fundWithFakeUtxos(allQuantities);
3790
- let gasUsed = minGas;
3814
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3815
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3791
3816
  let receipts = [];
3792
- if (isScriptTransaction) {
3793
- transactionRequest.gasPrice = bn14(0);
3794
- transactionRequest.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3795
- const result = await this.call(transactionRequest, {
3796
- estimateTxDependencies
3797
- });
3817
+ if (isScriptTransaction && estimateTxDependencies) {
3818
+ txRequestClone.gasPrice = bn14(0);
3819
+ txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3820
+ const result = await this.estimateTxDependencies(txRequestClone);
3798
3821
  receipts = result.receipts;
3799
- gasUsed = getGasUsedFromReceipts(receipts);
3800
- } else {
3801
- gasUsed = minGas;
3802
3822
  }
3823
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3803
3824
  const usedFee = calculatePriceWithFactor(
3804
3825
  gasUsed,
3805
3826
  gasPrice,
@@ -3817,7 +3838,9 @@ var _Provider = class {
3817
3838
  maxGas,
3818
3839
  usedFee,
3819
3840
  minFee,
3820
- maxFee
3841
+ maxFee,
3842
+ estimatedInputs: txRequestClone.inputs,
3843
+ estimatedOutputs: txRequestClone.outputs
3821
3844
  };
3822
3845
  }
3823
3846
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -3985,7 +4008,7 @@ var _Provider = class {
3985
4008
  time: block.header.time,
3986
4009
  transactionIds: block.transactions.map((tx) => tx.id),
3987
4010
  transactions: block.transactions.map(
3988
- (tx) => new TransactionCoder5().decode(getBytesCopy12(tx.rawPayload), 0)?.[0]
4011
+ (tx) => new TransactionCoder5().decode(getBytesCopy11(tx.rawPayload), 0)?.[0]
3989
4012
  )
3990
4013
  };
3991
4014
  }
@@ -4001,7 +4024,7 @@ var _Provider = class {
4001
4024
  return null;
4002
4025
  }
4003
4026
  return new TransactionCoder5().decode(
4004
- getBytesCopy12(transaction.rawPayload),
4027
+ getBytesCopy11(transaction.rawPayload),
4005
4028
  0
4006
4029
  )?.[0];
4007
4030
  }
@@ -4207,6 +4230,10 @@ var _Provider = class {
4207
4230
  });
4208
4231
  return bn14(latestBlockHeight);
4209
4232
  }
4233
+ // eslint-disable-next-line @typescript-eslint/require-await
4234
+ async getTransactionResponse(transactionId) {
4235
+ return new TransactionResponse(transactionId, this);
4236
+ }
4210
4237
  };
4211
4238
  var Provider = _Provider;
4212
4239
  _cacheInputs = new WeakSet();
@@ -4227,21 +4254,66 @@ __publicField(Provider, "nodeInfoCache", {});
4227
4254
  import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
4228
4255
  import { bn as bn15 } from "@fuel-ts/math";
4229
4256
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4230
- import { getBytesCopy as getBytesCopy13 } from "ethers";
4257
+ import { getBytesCopy as getBytesCopy12 } from "ethers";
4258
+
4259
+ // src/providers/chains.ts
4260
+ var CHAIN_IDS = {
4261
+ eth: {
4262
+ sepolia: 11155111,
4263
+ foundry: 31337
4264
+ },
4265
+ fuel: {
4266
+ beta5: 0,
4267
+ devnet: 10
4268
+ }
4269
+ };
4270
+
4271
+ // src/providers/assets/index.ts
4272
+ var assets = [
4273
+ {
4274
+ name: "Ethereum",
4275
+ symbol: "ETH",
4276
+ icon: "eth.svg",
4277
+ networks: [
4278
+ {
4279
+ type: "ethereum",
4280
+ chainId: CHAIN_IDS.eth.sepolia,
4281
+ decimals: 18
4282
+ },
4283
+ {
4284
+ type: "ethereum",
4285
+ chainId: CHAIN_IDS.eth.foundry,
4286
+ decimals: 18
4287
+ },
4288
+ {
4289
+ type: "fuel",
4290
+ chainId: CHAIN_IDS.fuel.beta5,
4291
+ decimals: 9,
4292
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4293
+ },
4294
+ {
4295
+ type: "fuel",
4296
+ chainId: CHAIN_IDS.fuel.devnet,
4297
+ decimals: 9,
4298
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4299
+ }
4300
+ ]
4301
+ }
4302
+ ];
4231
4303
 
4232
4304
  // src/utils/formatTransferToContractScriptData.ts
4233
4305
  import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
4234
- import { BN } from "@fuel-ts/math";
4306
+ import { BN as BN2 } from "@fuel-ts/math";
4235
4307
  import * as asm from "@fuels/vm-asm";
4236
- import { getBytesCopy as getBytesCopy14 } from "ethers";
4308
+ import { getBytesCopy as getBytesCopy13 } from "ethers";
4237
4309
  var formatTransferToContractScriptData = (params) => {
4238
4310
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4239
4311
  const numberCoder = new U64Coder2();
4240
- const encoded = numberCoder.encode(new BN(amountToTransfer).toNumber());
4312
+ const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
4241
4313
  const scriptData = Uint8Array.from([
4242
- ...getBytesCopy14(hexlifiedContractId),
4314
+ ...getBytesCopy13(hexlifiedContractId),
4243
4315
  ...encoded,
4244
- ...getBytesCopy14(assetId)
4316
+ ...getBytesCopy13(assetId)
4245
4317
  ]);
4246
4318
  return scriptData;
4247
4319
  };
@@ -4275,15 +4347,17 @@ var Account = class extends AbstractAccount {
4275
4347
  * The provider used to interact with the network.
4276
4348
  */
4277
4349
  _provider;
4350
+ _connector;
4278
4351
  /**
4279
4352
  * Creates a new Account instance.
4280
4353
  *
4281
4354
  * @param address - The address of the account.
4282
4355
  * @param provider - A Provider instance (optional).
4283
4356
  */
4284
- constructor(address, provider) {
4357
+ constructor(address, provider, connector) {
4285
4358
  super();
4286
4359
  this._provider = provider;
4360
+ this._connector = connector;
4287
4361
  this.address = Address3.fromDynamicInput(address);
4288
4362
  }
4289
4363
  /**
@@ -4489,7 +4563,10 @@ var Account = class extends AbstractAccount {
4489
4563
  const params = { gasPrice: minGasPrice, ...txParams };
4490
4564
  const request = new ScriptTransactionRequest(params);
4491
4565
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4492
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4566
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4567
+ estimateTxDependencies: true,
4568
+ resourcesOwner: this
4569
+ });
4493
4570
  request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4494
4571
  request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4495
4572
  this.validateGas({
@@ -4499,6 +4576,7 @@ var Account = class extends AbstractAccount {
4499
4576
  minGasPrice
4500
4577
  });
4501
4578
  await this.fund(request, requiredQuantities, maxFee);
4579
+ request.updatePredicateInputs(estimatedInputs);
4502
4580
  return request;
4503
4581
  }
4504
4582
  /**
@@ -4512,7 +4590,7 @@ var Account = class extends AbstractAccount {
4512
4590
  */
4513
4591
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4514
4592
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4515
- return this.sendTransaction(request);
4593
+ return this.sendTransaction(request, { estimateTxDependencies: false });
4516
4594
  }
4517
4595
  /**
4518
4596
  * Transfers coins to a contract address.
@@ -4563,14 +4641,14 @@ var Account = class extends AbstractAccount {
4563
4641
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4564
4642
  const { minGasPrice } = this.provider.getGasConfig();
4565
4643
  const recipientAddress = Address3.fromAddressOrString(recipient);
4566
- const recipientDataArray = getBytesCopy15(
4644
+ const recipientDataArray = getBytesCopy14(
4567
4645
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4568
4646
  );
4569
- const amountDataArray = getBytesCopy15(
4647
+ const amountDataArray = getBytesCopy14(
4570
4648
  "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4571
4649
  );
4572
4650
  const script = new Uint8Array([
4573
- ...getBytesCopy15(withdrawScript.bytes),
4651
+ ...getBytesCopy14(withdrawScript.bytes),
4574
4652
  ...recipientDataArray,
4575
4653
  ...amountDataArray
4576
4654
  ]);
@@ -4591,17 +4669,30 @@ var Account = class extends AbstractAccount {
4591
4669
  await this.fund(request, requiredQuantities, maxFee);
4592
4670
  return this.sendTransaction(request);
4593
4671
  }
4672
+ async signMessage(message) {
4673
+ if (!this._connector) {
4674
+ throw new FuelError14(ErrorCode13.MISSING_CONNECTOR, "A connector is required to sign messages.");
4675
+ }
4676
+ return this._connector.signMessage(this.address.toString(), message);
4677
+ }
4594
4678
  /**
4595
4679
  * Sends a transaction to the network.
4596
4680
  *
4597
4681
  * @param transactionRequestLike - The transaction request to be sent.
4598
4682
  * @returns A promise that resolves to the transaction response.
4599
4683
  */
4600
- async sendTransaction(transactionRequestLike, options) {
4684
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4685
+ if (this._connector) {
4686
+ return this.provider.getTransactionResponse(
4687
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
4688
+ );
4689
+ }
4601
4690
  const transactionRequest = transactionRequestify(transactionRequestLike);
4602
- await this.provider.estimateTxDependencies(transactionRequest);
4691
+ if (estimateTxDependencies) {
4692
+ await this.provider.estimateTxDependencies(transactionRequest);
4693
+ }
4603
4694
  return this.provider.sendTransaction(transactionRequest, {
4604
- ...options,
4695
+ awaitExecution,
4605
4696
  estimateTxDependencies: false
4606
4697
  });
4607
4698
  }
@@ -4611,9 +4702,11 @@ var Account = class extends AbstractAccount {
4611
4702
  * @param transactionRequestLike - The transaction request to be simulated.
4612
4703
  * @returns A promise that resolves to the call result.
4613
4704
  */
4614
- async simulateTransaction(transactionRequestLike) {
4705
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4615
4706
  const transactionRequest = transactionRequestify(transactionRequestLike);
4616
- await this.provider.estimateTxDependencies(transactionRequest);
4707
+ if (estimateTxDependencies) {
4708
+ await this.provider.estimateTxDependencies(transactionRequest);
4709
+ }
4617
4710
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4618
4711
  }
4619
4712
  validateGas({
@@ -4643,7 +4736,7 @@ import { randomBytes } from "@fuel-ts/crypto";
4643
4736
  import { hash } from "@fuel-ts/hasher";
4644
4737
  import { toBytes } from "@fuel-ts/math";
4645
4738
  import { secp256k1 } from "@noble/curves/secp256k1";
4646
- import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy16 } from "ethers";
4739
+ import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy15 } from "ethers";
4647
4740
  var Signer = class {
4648
4741
  address;
4649
4742
  publicKey;
@@ -4678,7 +4771,7 @@ var Signer = class {
4678
4771
  * @returns hashed signature
4679
4772
  */
4680
4773
  sign(data) {
4681
- const signature = secp256k1.sign(getBytesCopy16(data), getBytesCopy16(this.privateKey));
4774
+ const signature = secp256k1.sign(getBytesCopy15(data), getBytesCopy15(this.privateKey));
4682
4775
  const r = toBytes(`0x${signature.r.toString(16)}`, 32);
4683
4776
  const s = toBytes(`0x${signature.s.toString(16)}`, 32);
4684
4777
  s[0] |= (signature.recovery || 0) << 7;
@@ -4691,8 +4784,8 @@ var Signer = class {
4691
4784
  * @returns compressed point on the curve
4692
4785
  */
4693
4786
  addPoint(point) {
4694
- const p0 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(this.compressedPublicKey));
4695
- const p1 = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(point));
4787
+ const p0 = secp256k1.ProjectivePoint.fromHex(getBytesCopy15(this.compressedPublicKey));
4788
+ const p1 = secp256k1.ProjectivePoint.fromHex(getBytesCopy15(point));
4696
4789
  const result = p0.add(p1);
4697
4790
  return `0x${result.toHex(true)}`;
4698
4791
  }
@@ -4704,7 +4797,7 @@ var Signer = class {
4704
4797
  * @returns public key from signature from the
4705
4798
  */
4706
4799
  static recoverPublicKey(data, signature) {
4707
- const signedMessageBytes = getBytesCopy16(signature);
4800
+ const signedMessageBytes = getBytesCopy15(signature);
4708
4801
  const r = signedMessageBytes.slice(0, 32);
4709
4802
  const s = signedMessageBytes.slice(32, 64);
4710
4803
  const recoveryParam = (s[0] & 128) >> 7;
@@ -4712,7 +4805,7 @@ var Signer = class {
4712
4805
  const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
4713
4806
  recoveryParam
4714
4807
  );
4715
- const publicKey = sig.recoverPublicKey(getBytesCopy16(data)).toRawBytes(false).slice(1);
4808
+ const publicKey = sig.recoverPublicKey(getBytesCopy15(data)).toRawBytes(false).slice(1);
4716
4809
  return hexlify13(publicKey);
4717
4810
  }
4718
4811
  /**
@@ -4732,7 +4825,7 @@ var Signer = class {
4732
4825
  * @returns random 32-byte hashed
4733
4826
  */
4734
4827
  static generatePrivateKey(entropy) {
4735
- return entropy ? hash(concat3([randomBytes(32), getBytesCopy16(entropy)])) : randomBytes(32);
4828
+ return entropy ? hash(concat3([randomBytes(32), getBytesCopy15(entropy)])) : randomBytes(32);
4736
4829
  }
4737
4830
  /**
4738
4831
  * Extended publicKey from a compact publicKey
@@ -4741,7 +4834,7 @@ var Signer = class {
4741
4834
  * @returns extended publicKey
4742
4835
  */
4743
4836
  static extendPublicKey(publicKey) {
4744
- const point = secp256k1.ProjectivePoint.fromHex(getBytesCopy16(publicKey));
4837
+ const point = secp256k1.ProjectivePoint.fromHex(getBytesCopy15(publicKey));
4745
4838
  return hexlify13(point.toRawBytes(false).slice(1));
4746
4839
  }
4747
4840
  };
@@ -4919,12 +5012,14 @@ var BaseWalletUnlocked = class extends Account {
4919
5012
  * @param transactionRequestLike - The transaction request to send.
4920
5013
  * @returns A promise that resolves to the TransactionResponse object.
4921
5014
  */
4922
- async sendTransaction(transactionRequestLike, options) {
5015
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4923
5016
  const transactionRequest = transactionRequestify(transactionRequestLike);
4924
- await this.provider.estimateTxDependencies(transactionRequest);
5017
+ if (estimateTxDependencies) {
5018
+ await this.provider.estimateTxDependencies(transactionRequest);
5019
+ }
4925
5020
  return this.provider.sendTransaction(
4926
5021
  await this.populateTransactionWitnessesSignature(transactionRequest),
4927
- { ...options, estimateTxDependencies: false }
5022
+ { awaitExecution, estimateTxDependencies: false }
4928
5023
  );
4929
5024
  }
4930
5025
  /**
@@ -4933,9 +5028,11 @@ var BaseWalletUnlocked = class extends Account {
4933
5028
  * @param transactionRequestLike - The transaction request to simulate.
4934
5029
  * @returns A promise that resolves to the CallResult object.
4935
5030
  */
4936
- async simulateTransaction(transactionRequestLike) {
5031
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4937
5032
  const transactionRequest = transactionRequestify(transactionRequestLike);
4938
- await this.provider.estimateTxDependencies(transactionRequest);
5033
+ if (estimateTxDependencies) {
5034
+ await this.provider.estimateTxDependencies(transactionRequest);
5035
+ }
4939
5036
  return this.provider.call(
4940
5037
  await this.populateTransactionWitnessesSignature(transactionRequest),
4941
5038
  {
@@ -4965,7 +5062,7 @@ import {
4965
5062
  sha256 as sha2564,
4966
5063
  computeHmac as computeHmac2,
4967
5064
  ripemd160,
4968
- getBytesCopy as getBytesCopy19,
5065
+ getBytesCopy as getBytesCopy18,
4969
5066
  concat as concat5
4970
5067
  } from "ethers";
4971
5068
 
@@ -4980,7 +5077,7 @@ import {
4980
5077
  sha256 as sha2563,
4981
5078
  computeHmac,
4982
5079
  encodeBase58,
4983
- getBytesCopy as getBytesCopy18
5080
+ getBytesCopy as getBytesCopy17
4984
5081
  } from "ethers";
4985
5082
 
4986
5083
  // src/wordlists/words/english.ts
@@ -7037,7 +7134,7 @@ var english = [
7037
7134
 
7038
7135
  // src/mnemonic/utils.ts
7039
7136
  import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
7040
- import { getBytesCopy as getBytesCopy17, sha256 as sha2562 } from "ethers";
7137
+ import { getBytesCopy as getBytesCopy16, sha256 as sha2562 } from "ethers";
7041
7138
  function toUtf8Bytes(stri) {
7042
7139
  const str = stri.normalize("NFKD");
7043
7140
  const result = [];
@@ -7104,14 +7201,14 @@ function entropyToMnemonicIndices(entropy) {
7104
7201
  }
7105
7202
  }
7106
7203
  const checksumBits = entropy.length / 4;
7107
- const checksum = getBytesCopy17(sha2562(entropy))[0] & getUpperMask(checksumBits);
7204
+ const checksum = getBytesCopy16(sha2562(entropy))[0] & getUpperMask(checksumBits);
7108
7205
  indices[indices.length - 1] <<= checksumBits;
7109
7206
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7110
7207
  return indices;
7111
7208
  }
7112
7209
  function mnemonicWordsToEntropy(words, wordlist) {
7113
7210
  const size = Math.ceil(11 * words.length / 8);
7114
- const entropy = getBytesCopy17(new Uint8Array(size));
7211
+ const entropy = getBytesCopy16(new Uint8Array(size));
7115
7212
  let offset = 0;
7116
7213
  for (let i = 0; i < words.length; i += 1) {
7117
7214
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7131,7 +7228,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7131
7228
  const entropyBits = 32 * words.length / 3;
7132
7229
  const checksumBits = words.length / 3;
7133
7230
  const checksumMask = getUpperMask(checksumBits);
7134
- const checksum = getBytesCopy17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7231
+ const checksum = getBytesCopy16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7135
7232
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7136
7233
  throw new FuelError16(
7137
7234
  ErrorCode15.INVALID_CHECKSUM,
@@ -7214,7 +7311,7 @@ var Mnemonic = class {
7214
7311
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7215
7312
  */
7216
7313
  static entropyToMnemonic(entropy, wordlist = english) {
7217
- const entropyBytes = getBytesCopy18(entropy);
7314
+ const entropyBytes = getBytesCopy17(entropy);
7218
7315
  assertWordList(wordlist);
7219
7316
  assertEntropy(entropyBytes);
7220
7317
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7283,14 +7380,14 @@ var Mnemonic = class {
7283
7380
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7284
7381
  */
7285
7382
  static masterKeysFromSeed(seed) {
7286
- const seedArray = getBytesCopy18(seed);
7383
+ const seedArray = getBytesCopy17(seed);
7287
7384
  if (seedArray.length < 16 || seedArray.length > 64) {
7288
7385
  throw new FuelError17(
7289
7386
  ErrorCode16.INVALID_SEED,
7290
7387
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7291
7388
  );
7292
7389
  }
7293
- return getBytesCopy18(computeHmac("sha512", MasterSecret, seedArray));
7390
+ return getBytesCopy17(computeHmac("sha512", MasterSecret, seedArray));
7294
7391
  }
7295
7392
  /**
7296
7393
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7301,7 +7398,7 @@ var Mnemonic = class {
7301
7398
  */
7302
7399
  static seedToExtendedKey(seed, testnet = false) {
7303
7400
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7304
- const prefix = getBytesCopy18(testnet ? TestnetPRV : MainnetPRV);
7401
+ const prefix = getBytesCopy17(testnet ? TestnetPRV : MainnetPRV);
7305
7402
  const depth = "0x00";
7306
7403
  const fingerprint = "0x00000000";
7307
7404
  const index = "0x00000000";
@@ -7331,7 +7428,7 @@ var Mnemonic = class {
7331
7428
  * @returns A randomly generated mnemonic
7332
7429
  */
7333
7430
  static generate(size = 32, extraEntropy = "") {
7334
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy18(extraEntropy)])) : randomBytes3(size);
7431
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy17(extraEntropy)])) : randomBytes3(size);
7335
7432
  return Mnemonic.entropyToMnemonic(entropy);
7336
7433
  }
7337
7434
  };
@@ -7416,9 +7513,9 @@ var HDWallet = class {
7416
7513
  * @returns A new instance of HDWallet on the derived index
7417
7514
  */
7418
7515
  deriveIndex(index) {
7419
- const privateKey = this.privateKey && getBytesCopy19(this.privateKey);
7420
- const publicKey = getBytesCopy19(this.publicKey);
7421
- const chainCode = getBytesCopy19(this.chainCode);
7516
+ const privateKey = this.privateKey && getBytesCopy18(this.privateKey);
7517
+ const publicKey = getBytesCopy18(this.publicKey);
7518
+ const chainCode = getBytesCopy18(this.chainCode);
7422
7519
  const data = new Uint8Array(37);
7423
7520
  if (index & HARDENED_INDEX) {
7424
7521
  if (!privateKey) {
@@ -7429,10 +7526,10 @@ var HDWallet = class {
7429
7526
  }
7430
7527
  data.set(privateKey, 1);
7431
7528
  } else {
7432
- data.set(getBytesCopy19(this.publicKey));
7529
+ data.set(getBytesCopy18(this.publicKey));
7433
7530
  }
7434
7531
  data.set(toBytes2(index, 4), 33);
7435
- const bytes = getBytesCopy19(computeHmac2("sha512", chainCode, data));
7532
+ const bytes = getBytesCopy18(computeHmac2("sha512", chainCode, data));
7436
7533
  const IL = bytes.slice(0, 32);
7437
7534
  const IR = bytes.slice(32);
7438
7535
  if (privateKey) {
@@ -7486,7 +7583,7 @@ var HDWallet = class {
7486
7583
  const index = toHex(this.index, 4);
7487
7584
  const chainCode = this.chainCode;
7488
7585
  const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
7489
- const extendedKey = getBytesCopy19(
7586
+ const extendedKey = getBytesCopy18(
7490
7587
  concat5([prefix, depth, parentFingerprint, index, chainCode, key])
7491
7588
  );
7492
7589
  return base58check(extendedKey);
@@ -7500,13 +7597,13 @@ var HDWallet = class {
7500
7597
  static fromSeed(seed) {
7501
7598
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7502
7599
  return new HDWallet({
7503
- chainCode: getBytesCopy19(masterKey.slice(32)),
7504
- privateKey: getBytesCopy19(masterKey.slice(0, 32))
7600
+ chainCode: getBytesCopy18(masterKey.slice(32)),
7601
+ privateKey: getBytesCopy18(masterKey.slice(0, 32))
7505
7602
  });
7506
7603
  }
7507
7604
  static fromExtendedKey(extendedKey) {
7508
7605
  const decoded = toBeHex(decodeBase58(extendedKey));
7509
- const bytes = getBytesCopy19(decoded);
7606
+ const bytes = getBytesCopy18(decoded);
7510
7607
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7511
7608
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7512
7609
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");