@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
package/dist/index.mjs CHANGED
@@ -33,7 +33,7 @@ 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 { getBytesCopy as getBytesCopy14 } from "ethers";
37
37
 
38
38
  // src/providers/coin-quantity.ts
39
39
  import { BaseAssetId } from "@fuel-ts/address/configs";
@@ -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 } 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 { getBytesCopy as getBytesCopy11, hexlify as hexlify12, Network } from "ethers";
86
88
  import { GraphQLClient } from "graphql-request";
87
89
  import { clone as clone3 } from "ramda";
88
90
 
@@ -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 "ethers";
1159
1161
 
1160
1162
  // src/providers/resource.ts
1161
1163
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1998,7 +2000,7 @@ var BaseTransactionRequest = class {
1998
2000
  *
1999
2001
  * @param quantities - CoinQuantity Array.
2000
2002
  */
2001
- fundWithFakeUtxos(quantities) {
2003
+ fundWithFakeUtxos(quantities, resourcesOwner) {
2002
2004
  let idCounter = 0;
2003
2005
  const generateId = () => {
2004
2006
  const counterString = String(idCounter++);
@@ -2022,7 +2024,7 @@ var BaseTransactionRequest = class {
2022
2024
  id: generateId(),
2023
2025
  amount: quantity,
2024
2026
  assetId,
2025
- owner: Address.fromRandom(),
2027
+ owner: resourcesOwner || Address.fromRandom(),
2026
2028
  maturity: 0,
2027
2029
  blockCreated: bn6(1),
2028
2030
  txCreatedIdx: bn6(1)
@@ -2055,19 +2057,29 @@ var BaseTransactionRequest = class {
2055
2057
  toJSON() {
2056
2058
  return normalizeJSON(this);
2057
2059
  }
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
- );
2060
+ updatePredicateInputs(inputs) {
2061
+ this.inputs.forEach((i) => {
2062
+ let correspondingInput;
2063
+ switch (i.type) {
2064
+ case InputType2.Contract:
2065
+ return;
2066
+ case InputType2.Coin:
2067
+ correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2068
+ break;
2069
+ case InputType2.Message:
2070
+ correspondingInput = inputs.find(
2071
+ (x) => x.type === InputType2.Message && x.sender === i.sender
2072
+ );
2073
+ break;
2074
+ default:
2075
+ break;
2076
+ }
2077
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2078
+ i.predicate = correspondingInput.predicate;
2079
+ i.predicateData = correspondingInput.predicateData;
2080
+ i.predicateGasUsed = correspondingInput.predicateGasUsed;
2081
+ }
2082
+ });
2071
2083
  }
2072
2084
  };
2073
2085
 
@@ -2075,7 +2087,7 @@ var BaseTransactionRequest = class {
2075
2087
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2076
2088
  import { bn as bn8 } from "@fuel-ts/math";
2077
2089
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2078
- import { getBytesCopy as getBytesCopy7, hexlify as hexlify9 } from "ethers";
2090
+ import { getBytesCopy as getBytesCopy6, hexlify as hexlify9 } from "ethers";
2079
2091
 
2080
2092
  // src/providers/transaction-request/hash-transaction.ts
2081
2093
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
@@ -2149,10 +2161,10 @@ function hashTransaction(transactionRequest, chainId) {
2149
2161
  }
2150
2162
 
2151
2163
  // src/providers/transaction-request/storage-slot.ts
2152
- import { getBytesCopy as getBytesCopy6, hexlify as hexlify8 } from "ethers";
2164
+ import { getBytesCopy as getBytesCopy5, hexlify as hexlify8 } from "ethers";
2153
2165
  var getStorageValue = (value) => {
2154
2166
  const v = new Uint8Array(32);
2155
- v.set(getBytesCopy6(value));
2167
+ v.set(getBytesCopy5(value));
2156
2168
  return v;
2157
2169
  };
2158
2170
  var storageSlotify = (storageSlot) => {
@@ -2257,7 +2269,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2257
2269
  }
2258
2270
  metadataGas(gasCosts) {
2259
2271
  return calculateMetadataGasForTxCreate({
2260
- contractBytesSize: bn8(getBytesCopy7(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2272
+ contractBytesSize: bn8(getBytesCopy6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2261
2273
  gasCosts,
2262
2274
  stateRootSize: this.storageSlots.length,
2263
2275
  txBytesSize: this.byteSize()
@@ -2271,17 +2283,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
2271
2283
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2272
2284
  import { bn as bn9 } from "@fuel-ts/math";
2273
2285
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2274
- import { getBytesCopy as getBytesCopy9, hexlify as hexlify10 } from "ethers";
2286
+ import { getBytesCopy as getBytesCopy8, hexlify as hexlify10 } from "ethers";
2275
2287
 
2276
2288
  // src/providers/transaction-request/scripts.ts
2277
- import { getBytesCopy as getBytesCopy8 } from "ethers";
2289
+ import { getBytesCopy as getBytesCopy7 } from "ethers";
2278
2290
  var returnZeroScript = {
2279
2291
  /*
2280
2292
  Opcode::RET(REG_ZERO)
2281
2293
  Opcode::NOOP
2282
2294
  */
2283
2295
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2284
- bytes: getBytesCopy8("0x24000000"),
2296
+ bytes: getBytesCopy7("0x24000000"),
2285
2297
  encodeScriptData: () => new Uint8Array(0)
2286
2298
  };
2287
2299
  var withdrawScript = {
@@ -2295,7 +2307,7 @@ var withdrawScript = {
2295
2307
  00000000 00000000 [amount value]
2296
2308
  */
2297
2309
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2298
- bytes: getBytesCopy8("0x5040C0105D44C0064C40001124000000"),
2310
+ bytes: getBytesCopy7("0x5040C0105D44C0064C40001124000000"),
2299
2311
  encodeScriptData: () => new Uint8Array(0)
2300
2312
  };
2301
2313
 
@@ -2323,8 +2335,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2323
2335
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2324
2336
  super(rest);
2325
2337
  this.gasLimit = bn9(gasLimit);
2326
- this.script = getBytesCopy9(script ?? returnZeroScript.bytes);
2327
- this.scriptData = getBytesCopy9(scriptData ?? returnZeroScript.encodeScriptData());
2338
+ this.script = getBytesCopy8(script ?? returnZeroScript.bytes);
2339
+ this.scriptData = getBytesCopy8(scriptData ?? returnZeroScript.encodeScriptData());
2328
2340
  }
2329
2341
  /**
2330
2342
  * Converts the transaction request to a `TransactionScript`.
@@ -2332,8 +2344,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2332
2344
  * @returns The transaction script object.
2333
2345
  */
2334
2346
  toTransaction() {
2335
- const script = getBytesCopy9(this.script ?? "0x");
2336
- const scriptData = getBytesCopy9(this.scriptData ?? "0x");
2347
+ const script = getBytesCopy8(this.script ?? "0x");
2348
+ const scriptData = getBytesCopy8(this.scriptData ?? "0x");
2337
2349
  return {
2338
2350
  type: TransactionType4.Script,
2339
2351
  scriptGasLimit: this.gasLimit,
@@ -2493,7 +2505,7 @@ var transactionRequestify = (obj) => {
2493
2505
  import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2494
2506
  import { bn as bn13 } from "@fuel-ts/math";
2495
2507
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2496
- import { getBytesCopy as getBytesCopy11 } from "ethers";
2508
+ import { getBytesCopy as getBytesCopy10 } from "ethers";
2497
2509
 
2498
2510
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2499
2511
  import { hexlify as hexlify11 } from "ethers";
@@ -2501,7 +2513,7 @@ import { hexlify as hexlify11 } from "ethers";
2501
2513
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2502
2514
  import { bn as bn10 } from "@fuel-ts/math";
2503
2515
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2504
- import { getBytesCopy as getBytesCopy10 } from "ethers";
2516
+ import { getBytesCopy as getBytesCopy9 } from "ethers";
2505
2517
  var calculateTransactionFee = (params) => {
2506
2518
  const {
2507
2519
  gasUsed,
@@ -2510,7 +2522,7 @@ var calculateTransactionFee = (params) => {
2510
2522
  } = params;
2511
2523
  const gasPerByte = bn10(feeParams.gasPerByte);
2512
2524
  const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2513
- const transactionBytes = getBytesCopy10(rawPayload);
2525
+ const transactionBytes = getBytesCopy9(rawPayload);
2514
2526
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2515
2527
  if (transaction.type === TransactionType6.Mint) {
2516
2528
  return {
@@ -2525,7 +2537,7 @@ var calculateTransactionFee = (params) => {
2525
2537
  let gasLimit = bn10(0);
2526
2538
  if (type === TransactionType6.Create) {
2527
2539
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2528
- const contractBytesSize = bn10(getBytesCopy10(witnesses[bytecodeWitnessIndex].data).length);
2540
+ const contractBytesSize = bn10(getBytesCopy9(witnesses[bytecodeWitnessIndex].data).length);
2529
2541
  metadataGas = calculateMetadataGasForTxCreate({
2530
2542
  contractBytesSize,
2531
2543
  gasCosts,
@@ -3330,7 +3342,7 @@ var TransactionResponse = class {
3330
3342
  */
3331
3343
  decodeTransaction(transactionWithReceipts) {
3332
3344
  return new TransactionCoder4().decode(
3333
- getBytesCopy11(transactionWithReceipts.rawPayload),
3345
+ getBytesCopy10(transactionWithReceipts.rawPayload),
3334
3346
  0
3335
3347
  )?.[0];
3336
3348
  }
@@ -3356,7 +3368,7 @@ var TransactionResponse = class {
3356
3368
  id: this.id,
3357
3369
  receipts,
3358
3370
  transaction: decodedTransaction,
3359
- transactionBytes: getBytesCopy11(transaction.rawPayload),
3371
+ transactionBytes: getBytesCopy10(transaction.rawPayload),
3360
3372
  gqlTransactionStatus: transaction.status,
3361
3373
  gasPerByte,
3362
3374
  gasPriceFactor,
@@ -3790,7 +3802,7 @@ var _Provider = class {
3790
3802
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
3791
3803
  const transactionRequest = transactionRequestify(transactionRequestLike);
3792
3804
  if (estimateTxDependencies) {
3793
- await this.estimateTxDependencies(transactionRequest);
3805
+ return this.estimateTxDependencies(transactionRequest);
3794
3806
  }
3795
3807
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3796
3808
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3809,6 +3821,14 @@ var _Provider = class {
3809
3821
  * @returns A promise that resolves to the estimated transaction request object.
3810
3822
  */
3811
3823
  async estimatePredicates(transactionRequest) {
3824
+ const shouldEstimatePredicates = Boolean(
3825
+ transactionRequest.inputs.find(
3826
+ (input) => "predicate" in input && input.predicate && !equalBytes(arrayify(input.predicate), arrayify("0x")) && new BN(input.predicateGasUsed).isZero()
3827
+ )
3828
+ );
3829
+ if (!shouldEstimatePredicates) {
3830
+ return transactionRequest;
3831
+ }
3812
3832
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3813
3833
  const response = await this.operations.estimatePredicates({
3814
3834
  encodedTransaction
@@ -3839,34 +3859,33 @@ var _Provider = class {
3839
3859
  * @returns A promise.
3840
3860
  */
3841
3861
  async estimateTxDependencies(transactionRequest) {
3842
- let missingOutputVariableCount = 0;
3843
- let missingOutputContractIdsCount = 0;
3844
- let tries = 0;
3845
3862
  if (transactionRequest.type === TransactionType8.Create) {
3846
- return;
3847
- }
3848
- let txRequest = transactionRequest;
3849
- if (txRequest.hasPredicateInput()) {
3850
- txRequest = await this.estimatePredicates(txRequest);
3863
+ return {
3864
+ receipts: []
3865
+ };
3851
3866
  }
3852
- while (tries < MAX_RETRIES) {
3867
+ await this.estimatePredicates(transactionRequest);
3868
+ let receipts = [];
3869
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3853
3870
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3854
- encodedTransaction: hexlify12(txRequest.toTransactionBytes()),
3871
+ encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
3855
3872
  utxoValidation: false
3856
3873
  });
3857
- const receipts = gqlReceipts.map(processGqlReceipt);
3874
+ receipts = gqlReceipts.map(processGqlReceipt);
3858
3875
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3859
- missingOutputVariableCount = missingOutputVariables.length;
3860
- missingOutputContractIdsCount = missingOutputContractIds.length;
3861
- if (missingOutputVariableCount === 0 && missingOutputContractIdsCount === 0) {
3862
- return;
3876
+ const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3877
+ if (hasMissingOutputs) {
3878
+ transactionRequest.addVariableOutputs(missingOutputVariables.length);
3879
+ missingOutputContractIds.forEach(({ contractId }) => {
3880
+ transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
3881
+ });
3882
+ } else {
3883
+ break;
3863
3884
  }
3864
- txRequest.addVariableOutputs(missingOutputVariableCount);
3865
- missingOutputContractIds.forEach(
3866
- ({ contractId }) => txRequest.addContractInputAndOutput(Address2.fromString(contractId))
3867
- );
3868
- tries += 1;
3869
3885
  }
3886
+ return {
3887
+ receipts
3888
+ };
3870
3889
  }
3871
3890
  /**
3872
3891
  * Executes a signed transaction without applying the states changes
@@ -3881,7 +3900,7 @@ var _Provider = class {
3881
3900
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
3882
3901
  const transactionRequest = transactionRequestify(transactionRequestLike);
3883
3902
  if (estimateTxDependencies) {
3884
- await this.estimateTxDependencies(transactionRequest);
3903
+ return this.estimateTxDependencies(transactionRequest);
3885
3904
  }
3886
3905
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3887
3906
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
@@ -3908,36 +3927,38 @@ var _Provider = class {
3908
3927
  * @param tolerance - The tolerance to add on top of the gasUsed.
3909
3928
  * @returns A promise that resolves to the transaction cost object.
3910
3929
  */
3911
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], { estimateTxDependencies = true, estimatePredicates = true } = {}) {
3912
- const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
3930
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3931
+ estimateTxDependencies = true,
3932
+ estimatePredicates = true,
3933
+ resourcesOwner
3934
+ } = {}) {
3935
+ const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3913
3936
  const chainInfo = this.getChain();
3914
3937
  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) {
3938
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3939
+ const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3940
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3941
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3942
+ txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3943
+ if (estimatePredicates) {
3918
3944
  if (isScriptTransaction) {
3919
- transactionRequest.gasLimit = bn14(0);
3945
+ txRequestClone.gasLimit = bn14(0);
3920
3946
  }
3921
- await this.estimatePredicates(transactionRequest);
3947
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3948
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3949
+ }
3950
+ await this.estimatePredicates(txRequestClone);
3922
3951
  }
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;
3952
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3953
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3929
3954
  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
- });
3955
+ if (isScriptTransaction && estimateTxDependencies) {
3956
+ txRequestClone.gasPrice = bn14(0);
3957
+ txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3958
+ const result = await this.estimateTxDependencies(txRequestClone);
3936
3959
  receipts = result.receipts;
3937
- gasUsed = getGasUsedFromReceipts(receipts);
3938
- } else {
3939
- gasUsed = minGas;
3940
3960
  }
3961
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3941
3962
  const usedFee = calculatePriceWithFactor(
3942
3963
  gasUsed,
3943
3964
  gasPrice,
@@ -3955,7 +3976,9 @@ var _Provider = class {
3955
3976
  maxGas,
3956
3977
  usedFee,
3957
3978
  minFee,
3958
- maxFee
3979
+ maxFee,
3980
+ estimatedInputs: txRequestClone.inputs,
3981
+ estimatedOutputs: txRequestClone.outputs
3959
3982
  };
3960
3983
  }
3961
3984
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -4123,7 +4146,7 @@ var _Provider = class {
4123
4146
  time: block.header.time,
4124
4147
  transactionIds: block.transactions.map((tx) => tx.id),
4125
4148
  transactions: block.transactions.map(
4126
- (tx) => new TransactionCoder5().decode(getBytesCopy12(tx.rawPayload), 0)?.[0]
4149
+ (tx) => new TransactionCoder5().decode(getBytesCopy11(tx.rawPayload), 0)?.[0]
4127
4150
  )
4128
4151
  };
4129
4152
  }
@@ -4139,7 +4162,7 @@ var _Provider = class {
4139
4162
  return null;
4140
4163
  }
4141
4164
  return new TransactionCoder5().decode(
4142
- getBytesCopy12(transaction.rawPayload),
4165
+ getBytesCopy11(transaction.rawPayload),
4143
4166
  0
4144
4167
  )?.[0];
4145
4168
  }
@@ -4345,6 +4368,10 @@ var _Provider = class {
4345
4368
  });
4346
4369
  return bn14(latestBlockHeight);
4347
4370
  }
4371
+ // eslint-disable-next-line @typescript-eslint/require-await
4372
+ async getTransactionResponse(transactionId) {
4373
+ return new TransactionResponse(transactionId, this);
4374
+ }
4348
4375
  };
4349
4376
  var Provider = _Provider;
4350
4377
  _cacheInputs = new WeakSet();
@@ -4365,7 +4392,7 @@ __publicField(Provider, "nodeInfoCache", {});
4365
4392
  import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
4366
4393
  import { bn as bn15 } from "@fuel-ts/math";
4367
4394
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4368
- import { getBytesCopy as getBytesCopy13 } from "ethers";
4395
+ import { getBytesCopy as getBytesCopy12 } from "ethers";
4369
4396
  async function getTransactionSummary(params) {
4370
4397
  const { id, provider, abiMap } = params;
4371
4398
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4378,7 +4405,7 @@ async function getTransactionSummary(params) {
4378
4405
  );
4379
4406
  }
4380
4407
  const [decodedTransaction] = new TransactionCoder6().decode(
4381
- getBytesCopy13(gqlTransaction.rawPayload),
4408
+ getBytesCopy12(gqlTransaction.rawPayload),
4382
4409
  0
4383
4410
  );
4384
4411
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4389,7 +4416,7 @@ async function getTransactionSummary(params) {
4389
4416
  id: gqlTransaction.id,
4390
4417
  receipts,
4391
4418
  transaction: decodedTransaction,
4392
- transactionBytes: getBytesCopy13(gqlTransaction.rawPayload),
4419
+ transactionBytes: getBytesCopy12(gqlTransaction.rawPayload),
4393
4420
  gqlTransactionStatus: gqlTransaction.status,
4394
4421
  gasPerByte: bn15(gasPerByte),
4395
4422
  gasPriceFactor: bn15(gasPriceFactor),
@@ -4431,13 +4458,13 @@ async function getTransactionsSummaries(params) {
4431
4458
  const transactions = edges.map((edge) => {
4432
4459
  const { node: gqlTransaction } = edge;
4433
4460
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4434
- const [decodedTransaction] = new TransactionCoder6().decode(getBytesCopy13(rawPayload), 0);
4461
+ const [decodedTransaction] = new TransactionCoder6().decode(getBytesCopy12(rawPayload), 0);
4435
4462
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4436
4463
  const transactionSummary = assembleTransactionSummary({
4437
4464
  id,
4438
4465
  receipts,
4439
4466
  transaction: decodedTransaction,
4440
- transactionBytes: getBytesCopy13(rawPayload),
4467
+ transactionBytes: getBytesCopy12(rawPayload),
4441
4468
  gqlTransactionStatus: status,
4442
4469
  abiMap,
4443
4470
  gasPerByte,
@@ -4457,19 +4484,140 @@ async function getTransactionsSummaries(params) {
4457
4484
  };
4458
4485
  }
4459
4486
 
4487
+ // src/providers/chains.ts
4488
+ var CHAIN_IDS = {
4489
+ eth: {
4490
+ sepolia: 11155111,
4491
+ foundry: 31337
4492
+ },
4493
+ fuel: {
4494
+ beta5: 0,
4495
+ devnet: 10
4496
+ }
4497
+ };
4498
+
4499
+ // src/providers/assets/utils/network.ts
4500
+ var getDefaultChainId = (networkType) => {
4501
+ if (networkType === "ethereum") {
4502
+ return CHAIN_IDS.eth.sepolia;
4503
+ }
4504
+ if (networkType === "fuel") {
4505
+ return CHAIN_IDS.fuel.beta5;
4506
+ }
4507
+ return void 0;
4508
+ };
4509
+ var getAssetNetwork = ({
4510
+ asset,
4511
+ chainId,
4512
+ networkType
4513
+ }) => {
4514
+ const network = asset.networks.find(
4515
+ (item) => item.chainId === chainId && item.type === networkType
4516
+ );
4517
+ return network;
4518
+ };
4519
+ var getAssetWithNetwork = ({
4520
+ asset,
4521
+ chainId,
4522
+ networkType
4523
+ }) => {
4524
+ const { networks: _, ...assetRest } = asset;
4525
+ const chainIdToUse = chainId ?? getDefaultChainId(networkType);
4526
+ if (chainIdToUse === void 0) {
4527
+ return void 0;
4528
+ }
4529
+ const assetNetwork = getAssetNetwork({
4530
+ asset,
4531
+ chainId: chainIdToUse,
4532
+ networkType
4533
+ });
4534
+ if (!assetNetwork) {
4535
+ return void 0;
4536
+ }
4537
+ return {
4538
+ ...assetRest,
4539
+ ...assetNetwork
4540
+ };
4541
+ };
4542
+ var getAssetEth = (asset, chainId) => getAssetWithNetwork({
4543
+ asset,
4544
+ networkType: "ethereum",
4545
+ chainId
4546
+ });
4547
+ var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
4548
+ asset,
4549
+ networkType: "fuel",
4550
+ chainId
4551
+ });
4552
+
4553
+ // src/providers/assets/utils/url.ts
4554
+ var DELIMITER_PATH = "/";
4555
+ var trimRegex = /^\/|\/$/g;
4556
+ var trimPath = (path = "") => path.replace(trimRegex, "");
4557
+ function urlJoin(baseUrl, ...paths) {
4558
+ const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
4559
+ const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
4560
+ const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
4561
+ if (rootPath && hasBaseUrl) {
4562
+ allPaths.unshift("");
4563
+ }
4564
+ return allPaths.join(DELIMITER_PATH);
4565
+ }
4566
+
4567
+ // src/providers/assets/utils/resolveIconPaths.ts
4568
+ function resolveIconPaths(assets2, basePath = "./") {
4569
+ return assets2.map((asset) => ({
4570
+ ...asset,
4571
+ icon: urlJoin(basePath, asset.icon)
4572
+ }));
4573
+ }
4574
+
4575
+ // src/providers/assets/index.ts
4576
+ var assets = [
4577
+ {
4578
+ name: "Ethereum",
4579
+ symbol: "ETH",
4580
+ icon: "eth.svg",
4581
+ networks: [
4582
+ {
4583
+ type: "ethereum",
4584
+ chainId: CHAIN_IDS.eth.sepolia,
4585
+ decimals: 18
4586
+ },
4587
+ {
4588
+ type: "ethereum",
4589
+ chainId: CHAIN_IDS.eth.foundry,
4590
+ decimals: 18
4591
+ },
4592
+ {
4593
+ type: "fuel",
4594
+ chainId: CHAIN_IDS.fuel.beta5,
4595
+ decimals: 9,
4596
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4597
+ },
4598
+ {
4599
+ type: "fuel",
4600
+ chainId: CHAIN_IDS.fuel.devnet,
4601
+ decimals: 9,
4602
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4603
+ }
4604
+ ]
4605
+ }
4606
+ ];
4607
+
4460
4608
  // src/utils/formatTransferToContractScriptData.ts
4461
4609
  import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
4462
- import { BN } from "@fuel-ts/math";
4610
+ import { BN as BN2 } from "@fuel-ts/math";
4463
4611
  import * as asm from "@fuels/vm-asm";
4464
- import { getBytesCopy as getBytesCopy14 } from "ethers";
4612
+ import { getBytesCopy as getBytesCopy13 } from "ethers";
4465
4613
  var formatTransferToContractScriptData = (params) => {
4466
4614
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4467
4615
  const numberCoder = new U64Coder2();
4468
- const encoded = numberCoder.encode(new BN(amountToTransfer).toNumber());
4616
+ const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
4469
4617
  const scriptData = Uint8Array.from([
4470
- ...getBytesCopy14(hexlifiedContractId),
4618
+ ...getBytesCopy13(hexlifiedContractId),
4471
4619
  ...encoded,
4472
- ...getBytesCopy14(assetId)
4620
+ ...getBytesCopy13(assetId)
4473
4621
  ]);
4474
4622
  return scriptData;
4475
4623
  };
@@ -4503,15 +4651,17 @@ var Account = class extends AbstractAccount {
4503
4651
  * The provider used to interact with the network.
4504
4652
  */
4505
4653
  _provider;
4654
+ _connector;
4506
4655
  /**
4507
4656
  * Creates a new Account instance.
4508
4657
  *
4509
4658
  * @param address - The address of the account.
4510
4659
  * @param provider - A Provider instance (optional).
4511
4660
  */
4512
- constructor(address, provider) {
4661
+ constructor(address, provider, connector) {
4513
4662
  super();
4514
4663
  this._provider = provider;
4664
+ this._connector = connector;
4515
4665
  this.address = Address3.fromDynamicInput(address);
4516
4666
  }
4517
4667
  /**
@@ -4717,7 +4867,10 @@ var Account = class extends AbstractAccount {
4717
4867
  const params = { gasPrice: minGasPrice, ...txParams };
4718
4868
  const request = new ScriptTransactionRequest(params);
4719
4869
  request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4720
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4870
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4871
+ estimateTxDependencies: true,
4872
+ resourcesOwner: this
4873
+ });
4721
4874
  request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4722
4875
  request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4723
4876
  this.validateGas({
@@ -4727,6 +4880,7 @@ var Account = class extends AbstractAccount {
4727
4880
  minGasPrice
4728
4881
  });
4729
4882
  await this.fund(request, requiredQuantities, maxFee);
4883
+ request.updatePredicateInputs(estimatedInputs);
4730
4884
  return request;
4731
4885
  }
4732
4886
  /**
@@ -4740,7 +4894,7 @@ var Account = class extends AbstractAccount {
4740
4894
  */
4741
4895
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4742
4896
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4743
- return this.sendTransaction(request);
4897
+ return this.sendTransaction(request, { estimateTxDependencies: false });
4744
4898
  }
4745
4899
  /**
4746
4900
  * Transfers coins to a contract address.
@@ -4791,14 +4945,14 @@ var Account = class extends AbstractAccount {
4791
4945
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4792
4946
  const { minGasPrice } = this.provider.getGasConfig();
4793
4947
  const recipientAddress = Address3.fromAddressOrString(recipient);
4794
- const recipientDataArray = getBytesCopy15(
4948
+ const recipientDataArray = getBytesCopy14(
4795
4949
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4796
4950
  );
4797
- const amountDataArray = getBytesCopy15(
4951
+ const amountDataArray = getBytesCopy14(
4798
4952
  "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4799
4953
  );
4800
4954
  const script = new Uint8Array([
4801
- ...getBytesCopy15(withdrawScript.bytes),
4955
+ ...getBytesCopy14(withdrawScript.bytes),
4802
4956
  ...recipientDataArray,
4803
4957
  ...amountDataArray
4804
4958
  ]);
@@ -4819,17 +4973,30 @@ var Account = class extends AbstractAccount {
4819
4973
  await this.fund(request, requiredQuantities, maxFee);
4820
4974
  return this.sendTransaction(request);
4821
4975
  }
4976
+ async signMessage(message) {
4977
+ if (!this._connector) {
4978
+ throw new FuelError14(ErrorCode13.MISSING_CONNECTOR, "A connector is required to sign messages.");
4979
+ }
4980
+ return this._connector.signMessage(this.address.toString(), message);
4981
+ }
4822
4982
  /**
4823
4983
  * Sends a transaction to the network.
4824
4984
  *
4825
4985
  * @param transactionRequestLike - The transaction request to be sent.
4826
4986
  * @returns A promise that resolves to the transaction response.
4827
4987
  */
4828
- async sendTransaction(transactionRequestLike, options) {
4988
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4989
+ if (this._connector) {
4990
+ return this.provider.getTransactionResponse(
4991
+ await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
4992
+ );
4993
+ }
4829
4994
  const transactionRequest = transactionRequestify(transactionRequestLike);
4830
- await this.provider.estimateTxDependencies(transactionRequest);
4995
+ if (estimateTxDependencies) {
4996
+ await this.provider.estimateTxDependencies(transactionRequest);
4997
+ }
4831
4998
  return this.provider.sendTransaction(transactionRequest, {
4832
- ...options,
4999
+ awaitExecution,
4833
5000
  estimateTxDependencies: false
4834
5001
  });
4835
5002
  }
@@ -4839,9 +5006,11 @@ var Account = class extends AbstractAccount {
4839
5006
  * @param transactionRequestLike - The transaction request to be simulated.
4840
5007
  * @returns A promise that resolves to the call result.
4841
5008
  */
4842
- async simulateTransaction(transactionRequestLike) {
5009
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4843
5010
  const transactionRequest = transactionRequestify(transactionRequestLike);
4844
- await this.provider.estimateTxDependencies(transactionRequest);
5011
+ if (estimateTxDependencies) {
5012
+ await this.provider.estimateTxDependencies(transactionRequest);
5013
+ }
4845
5014
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4846
5015
  }
4847
5016
  validateGas({
@@ -4874,7 +5043,7 @@ import { randomBytes } from "@fuel-ts/crypto";
4874
5043
  import { hash } from "@fuel-ts/hasher";
4875
5044
  import { toBytes } from "@fuel-ts/math";
4876
5045
  import { secp256k1 } from "@noble/curves/secp256k1";
4877
- import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy16 } from "ethers";
5046
+ import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy15 } from "ethers";
4878
5047
  var Signer = class {
4879
5048
  address;
4880
5049
  publicKey;
@@ -4909,7 +5078,7 @@ 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(getBytesCopy15(data), getBytesCopy15(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;
@@ -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(getBytesCopy15(this.compressedPublicKey));
5095
+ const p1 = secp256k1.ProjectivePoint.fromHex(getBytesCopy15(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 = getBytesCopy15(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(getBytesCopy15(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), getBytesCopy15(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(getBytesCopy15(publicKey));
4976
5145
  return hexlify13(point.toRawBytes(false).slice(1));
4977
5146
  }
4978
5147
  };
@@ -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
  {
@@ -5196,7 +5369,7 @@ import {
5196
5369
  sha256 as sha2564,
5197
5370
  computeHmac as computeHmac2,
5198
5371
  ripemd160,
5199
- getBytesCopy as getBytesCopy19,
5372
+ getBytesCopy as getBytesCopy18,
5200
5373
  concat as concat5
5201
5374
  } from "ethers";
5202
5375
 
@@ -5211,7 +5384,7 @@ import {
5211
5384
  sha256 as sha2563,
5212
5385
  computeHmac,
5213
5386
  encodeBase58,
5214
- getBytesCopy as getBytesCopy18
5387
+ getBytesCopy as getBytesCopy17
5215
5388
  } from "ethers";
5216
5389
 
5217
5390
  // src/wordlists/words/english.ts
@@ -7274,7 +7447,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7274
7447
 
7275
7448
  // src/mnemonic/utils.ts
7276
7449
  import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
7277
- import { getBytesCopy as getBytesCopy17, sha256 as sha2562 } from "ethers";
7450
+ import { getBytesCopy as getBytesCopy16, sha256 as sha2562 } from "ethers";
7278
7451
  function toUtf8Bytes(stri) {
7279
7452
  const str = stri.normalize("NFKD");
7280
7453
  const result = [];
@@ -7341,14 +7514,14 @@ function entropyToMnemonicIndices(entropy) {
7341
7514
  }
7342
7515
  }
7343
7516
  const checksumBits = entropy.length / 4;
7344
- const checksum = getBytesCopy17(sha2562(entropy))[0] & getUpperMask(checksumBits);
7517
+ const checksum = getBytesCopy16(sha2562(entropy))[0] & getUpperMask(checksumBits);
7345
7518
  indices[indices.length - 1] <<= checksumBits;
7346
7519
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7347
7520
  return indices;
7348
7521
  }
7349
7522
  function mnemonicWordsToEntropy(words, wordlist) {
7350
7523
  const size = Math.ceil(11 * words.length / 8);
7351
- const entropy = getBytesCopy17(new Uint8Array(size));
7524
+ const entropy = getBytesCopy16(new Uint8Array(size));
7352
7525
  let offset = 0;
7353
7526
  for (let i = 0; i < words.length; i += 1) {
7354
7527
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7368,7 +7541,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7368
7541
  const entropyBits = 32 * words.length / 3;
7369
7542
  const checksumBits = words.length / 3;
7370
7543
  const checksumMask = getUpperMask(checksumBits);
7371
- const checksum = getBytesCopy17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7544
+ const checksum = getBytesCopy16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7372
7545
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7373
7546
  throw new FuelError16(
7374
7547
  ErrorCode15.INVALID_CHECKSUM,
@@ -7451,7 +7624,7 @@ var Mnemonic = class {
7451
7624
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7452
7625
  */
7453
7626
  static entropyToMnemonic(entropy, wordlist = english) {
7454
- const entropyBytes = getBytesCopy18(entropy);
7627
+ const entropyBytes = getBytesCopy17(entropy);
7455
7628
  assertWordList(wordlist);
7456
7629
  assertEntropy(entropyBytes);
7457
7630
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7520,14 +7693,14 @@ var Mnemonic = class {
7520
7693
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7521
7694
  */
7522
7695
  static masterKeysFromSeed(seed) {
7523
- const seedArray = getBytesCopy18(seed);
7696
+ const seedArray = getBytesCopy17(seed);
7524
7697
  if (seedArray.length < 16 || seedArray.length > 64) {
7525
7698
  throw new FuelError17(
7526
7699
  ErrorCode16.INVALID_SEED,
7527
7700
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7528
7701
  );
7529
7702
  }
7530
- return getBytesCopy18(computeHmac("sha512", MasterSecret, seedArray));
7703
+ return getBytesCopy17(computeHmac("sha512", MasterSecret, seedArray));
7531
7704
  }
7532
7705
  /**
7533
7706
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7538,7 +7711,7 @@ var Mnemonic = class {
7538
7711
  */
7539
7712
  static seedToExtendedKey(seed, testnet = false) {
7540
7713
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7541
- const prefix = getBytesCopy18(testnet ? TestnetPRV : MainnetPRV);
7714
+ const prefix = getBytesCopy17(testnet ? TestnetPRV : MainnetPRV);
7542
7715
  const depth = "0x00";
7543
7716
  const fingerprint = "0x00000000";
7544
7717
  const index = "0x00000000";
@@ -7568,7 +7741,7 @@ var Mnemonic = class {
7568
7741
  * @returns A randomly generated mnemonic
7569
7742
  */
7570
7743
  static generate(size = 32, extraEntropy = "") {
7571
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy18(extraEntropy)])) : randomBytes3(size);
7744
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), getBytesCopy17(extraEntropy)])) : randomBytes3(size);
7572
7745
  return Mnemonic.entropyToMnemonic(entropy);
7573
7746
  }
7574
7747
  };
@@ -7653,9 +7826,9 @@ var HDWallet = class {
7653
7826
  * @returns A new instance of HDWallet on the derived index
7654
7827
  */
7655
7828
  deriveIndex(index) {
7656
- const privateKey = this.privateKey && getBytesCopy19(this.privateKey);
7657
- const publicKey = getBytesCopy19(this.publicKey);
7658
- const chainCode = getBytesCopy19(this.chainCode);
7829
+ const privateKey = this.privateKey && getBytesCopy18(this.privateKey);
7830
+ const publicKey = getBytesCopy18(this.publicKey);
7831
+ const chainCode = getBytesCopy18(this.chainCode);
7659
7832
  const data = new Uint8Array(37);
7660
7833
  if (index & HARDENED_INDEX) {
7661
7834
  if (!privateKey) {
@@ -7666,10 +7839,10 @@ var HDWallet = class {
7666
7839
  }
7667
7840
  data.set(privateKey, 1);
7668
7841
  } else {
7669
- data.set(getBytesCopy19(this.publicKey));
7842
+ data.set(getBytesCopy18(this.publicKey));
7670
7843
  }
7671
7844
  data.set(toBytes2(index, 4), 33);
7672
- const bytes = getBytesCopy19(computeHmac2("sha512", chainCode, data));
7845
+ const bytes = getBytesCopy18(computeHmac2("sha512", chainCode, data));
7673
7846
  const IL = bytes.slice(0, 32);
7674
7847
  const IR = bytes.slice(32);
7675
7848
  if (privateKey) {
@@ -7723,7 +7896,7 @@ var HDWallet = class {
7723
7896
  const index = toHex(this.index, 4);
7724
7897
  const chainCode = this.chainCode;
7725
7898
  const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
7726
- const extendedKey = getBytesCopy19(
7899
+ const extendedKey = getBytesCopy18(
7727
7900
  concat5([prefix, depth, parentFingerprint, index, chainCode, key])
7728
7901
  );
7729
7902
  return base58check(extendedKey);
@@ -7737,13 +7910,13 @@ var HDWallet = class {
7737
7910
  static fromSeed(seed) {
7738
7911
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7739
7912
  return new HDWallet({
7740
- chainCode: getBytesCopy19(masterKey.slice(32)),
7741
- privateKey: getBytesCopy19(masterKey.slice(0, 32))
7913
+ chainCode: getBytesCopy18(masterKey.slice(32)),
7914
+ privateKey: getBytesCopy18(masterKey.slice(0, 32))
7742
7915
  });
7743
7916
  }
7744
7917
  static fromExtendedKey(extendedKey) {
7745
7918
  const decoded = toBeHex(decodeBase58(extendedKey));
7746
- const bytes = getBytesCopy19(decoded);
7919
+ const bytes = getBytesCopy18(decoded);
7747
7920
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7748
7921
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7749
7922
  throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8366,16 +8539,16 @@ import { Address as Address9 } from "@fuel-ts/address";
8366
8539
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8367
8540
  import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
8368
8541
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8369
- import { getBytesCopy as getBytesCopy21, hexlify as hexlify18 } from "ethers";
8542
+ import { getBytesCopy as getBytesCopy20, hexlify as hexlify18 } from "ethers";
8370
8543
 
8371
8544
  // src/predicate/utils/getPredicateRoot.ts
8372
8545
  import { hash as hash2 } from "@fuel-ts/hasher";
8373
8546
  import { calcRoot } from "@fuel-ts/merkle";
8374
8547
  import { chunkAndPadBytes } from "@fuel-ts/utils";
8375
- import { hexlify as hexlify17, concat as concat6, getBytesCopy as getBytesCopy20 } from "ethers";
8548
+ import { hexlify as hexlify17, concat as concat6, getBytesCopy as getBytesCopy19 } from "ethers";
8376
8549
  var getPredicateRoot = (bytecode) => {
8377
8550
  const chunkSize = 16 * 1024;
8378
- const bytes = getBytesCopy20(bytecode);
8551
+ const bytes = getBytesCopy19(bytecode);
8379
8552
  const chunks = chunkAndPadBytes(bytes, chunkSize);
8380
8553
  const codeRoot = calcRoot(chunks.map((c) => hexlify17(c)));
8381
8554
  const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
@@ -8488,7 +8661,7 @@ var Predicate = class extends Account {
8488
8661
  * @returns An object containing the new predicate bytes and interface.
8489
8662
  */
8490
8663
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8491
- let predicateBytes = getBytesCopy21(bytes);
8664
+ let predicateBytes = getBytesCopy20(bytes);
8492
8665
  let abiInterface;
8493
8666
  if (jsonAbi) {
8494
8667
  abiInterface = new Interface3(jsonAbi);
@@ -8548,6 +8721,9 @@ var Predicate = class extends Account {
8548
8721
  }
8549
8722
  };
8550
8723
 
8724
+ // src/connectors/fuel.ts
8725
+ import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
8726
+
8551
8727
  // src/connectors/fuel-connector.ts
8552
8728
  import { EventEmitter as EventEmitter2 } from "events";
8553
8729
 
@@ -8588,14 +8764,6 @@ var FuelConnectorEventTypes = /* @__PURE__ */ ((FuelConnectorEventTypes2) => {
8588
8764
  })(FuelConnectorEventTypes || {});
8589
8765
  var FuelConnectorEventType = "FuelConnector";
8590
8766
 
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
8767
  // src/connectors/types/data-type.ts
8600
8768
  var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
8601
8769
  MessageTypes2["ping"] = "ping";
@@ -8845,40 +9013,6 @@ var FuelConnector = class extends EventEmitter2 {
8845
9013
  }
8846
9014
  };
8847
9015
 
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
9016
  // src/connectors/utils/cache.ts
8883
9017
  function cacheFor(fn, { cache: cache2, cacheTime, key }) {
8884
9018
  return async (...args) => {
@@ -8908,23 +9042,6 @@ function dispatchFuelConnectorEvent(connector) {
8908
9042
  );
8909
9043
  }
8910
9044
 
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
9045
  // src/connectors/utils/promises.ts
8929
9046
  function deferPromise() {
8930
9047
  const defer = {};
@@ -8946,6 +9063,7 @@ async function withTimeout(promise, timeout = 1050) {
8946
9063
  // src/connectors/fuel.ts
8947
9064
  var HAS_CONNECTOR_TIMEOUT = 2e3;
8948
9065
  var PING_CACHE_TIME = 5e3;
9066
+ var { warn } = console;
8949
9067
  var _Fuel = class extends FuelConnector {
8950
9068
  _storage = null;
8951
9069
  _connectors = [];
@@ -9214,14 +9332,12 @@ var _Fuel = class extends FuelConnector {
9214
9332
  * Return a Fuel Provider instance with extends features to work with
9215
9333
  * connectors.
9216
9334
  *
9217
- * @deprecated Provider is going to be deprecated in the future.
9335
+ * @deprecated getProvider is deprecated and is going to be removed in the future, use getWallet instead.
9218
9336
  */
9219
9337
  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
- }
9338
+ warn(
9339
+ "getProvider is deprecated and is going to be removed in the future, use getWallet instead."
9340
+ );
9225
9341
  return this._getProvider(providerOrNetwork);
9226
9342
  }
9227
9343
  /**
@@ -9233,12 +9349,12 @@ var _Fuel = class extends FuelConnector {
9233
9349
  if (providerOrNetwork && "getTransactionResponse" in providerOrNetwork) {
9234
9350
  provider = providerOrNetwork;
9235
9351
  } else if (providerOrNetwork && "chainId" in providerOrNetwork && "url" in providerOrNetwork) {
9236
- provider = await FuelWalletProvider.create(providerOrNetwork.url);
9352
+ provider = await Provider.create(providerOrNetwork.url);
9237
9353
  } else if (!providerOrNetwork) {
9238
9354
  const currentNetwork = await this.currentNetwork();
9239
- provider = await FuelWalletProvider.create(currentNetwork.url);
9355
+ provider = await Provider.create(currentNetwork.url);
9240
9356
  } else {
9241
- throw new Error("Provider is not valid.");
9357
+ throw new FuelError24(ErrorCode23.INVALID_PROVIDER, "Provider is not valid.");
9242
9358
  }
9243
9359
  return provider;
9244
9360
  }
@@ -9248,7 +9364,7 @@ var _Fuel = class extends FuelConnector {
9248
9364
  */
9249
9365
  async getWallet(address, providerOrNetwork) {
9250
9366
  const provider = await this._getProvider(providerOrNetwork);
9251
- return new FuelWalletLocked(address, this, provider);
9367
+ return new Account(address, provider, this);
9252
9368
  }
9253
9369
  /**
9254
9370
  * Remove all open listeners this is useful when you want to
@@ -9279,22 +9395,17 @@ __publicField(Fuel, "defaultConfig", {});
9279
9395
  export {
9280
9396
  Account,
9281
9397
  AddressType,
9282
- BACKGROUND_SCRIPT_NAME,
9283
9398
  BaseTransactionRequest,
9284
9399
  BaseWalletUnlocked,
9285
- CONNECTOR_SCRIPT,
9286
- CONTENT_SCRIPT_NAME,
9400
+ CHAIN_IDS,
9287
9401
  ChainName,
9288
9402
  ChangeOutputCollisionError,
9289
9403
  CreateTransactionRequest,
9290
- EVENT_MESSAGE,
9291
9404
  Fuel,
9292
9405
  FuelConnector,
9293
9406
  FuelConnectorEventType,
9294
9407
  FuelConnectorEventTypes,
9295
9408
  FuelConnectorMethods,
9296
- FuelWalletLocked,
9297
- FuelWalletProvider,
9298
9409
  hdwallet_default as HDWallet,
9299
9410
  Language,
9300
9411
  LocalStorage,
@@ -9306,7 +9417,6 @@ export {
9306
9417
  NoWitnessAtIndexError,
9307
9418
  NoWitnessByOwnerError,
9308
9419
  OperationName,
9309
- POPUP_SCRIPT_NAME,
9310
9420
  Predicate,
9311
9421
  PrivateKeyVault,
9312
9422
  Provider,
@@ -9317,7 +9427,6 @@ export {
9317
9427
  TransactionStatus,
9318
9428
  TransactionType,
9319
9429
  TransactionTypeName,
9320
- VAULT_SCRIPT_NAME,
9321
9430
  Vault,
9322
9431
  Wallet,
9323
9432
  WalletLocked,
@@ -9327,6 +9436,7 @@ export {
9327
9436
  addOperation,
9328
9437
  assembleReceiptByType,
9329
9438
  assembleTransactionSummary,
9439
+ assets,
9330
9440
  buildBlockExplorerUrl,
9331
9441
  cacheFor,
9332
9442
  calculateMetadataGasForTxCreate,
@@ -9344,11 +9454,15 @@ export {
9344
9454
  fromTai64ToUnix,
9345
9455
  fromUnixToTai64,
9346
9456
  gasUsedByInputs,
9347
- getAssetByChain,
9457
+ getAssetEth,
9458
+ getAssetFuel,
9459
+ getAssetNetwork,
9460
+ getAssetWithNetwork,
9348
9461
  getContractCallOperations,
9349
9462
  getContractCreatedOperations,
9350
9463
  getContractTransferOperations,
9351
9464
  getDecodedLogs,
9465
+ getDefaultChainId,
9352
9466
  getGasUsedFromReceipts,
9353
9467
  getInputAccountAddress,
9354
9468
  getInputContractFromIndex,
@@ -9397,9 +9511,11 @@ export {
9397
9511
  processGqlReceipt,
9398
9512
  processGraphqlStatus,
9399
9513
  resolveGasDependentCosts,
9514
+ resolveIconPaths,
9400
9515
  returnZeroScript,
9401
9516
  sleep,
9402
9517
  transactionRequestify,
9518
+ urlJoin,
9403
9519
  withTimeout,
9404
9520
  withdrawScript
9405
9521
  };