@fuel-ts/account 0.88.1 → 0.89.1

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 (33) hide show
  1. package/dist/account.d.ts +67 -48
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/index.global.js +371 -204
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +257 -102
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +257 -102
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/provider.d.ts +126 -72
  11. package/dist/providers/provider.d.ts.map +1 -1
  12. package/dist/providers/transaction-request/script-transaction-request.d.ts +7 -0
  13. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  14. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  15. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  16. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +1 -0
  17. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  18. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  19. package/dist/providers/transaction-summary/operations.d.ts +4 -2
  20. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  21. package/dist/providers/transaction-summary/types.d.ts +1 -0
  22. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  23. package/dist/test-utils/launchNode.d.ts +3 -3
  24. package/dist/test-utils/launchNode.d.ts.map +1 -1
  25. package/dist/test-utils.global.js +574 -426
  26. package/dist/test-utils.global.js.map +1 -1
  27. package/dist/test-utils.js +253 -103
  28. package/dist/test-utils.js.map +1 -1
  29. package/dist/test-utils.mjs +254 -104
  30. package/dist/test-utils.mjs.map +1 -1
  31. package/dist/wallet/base-wallet-unlocked.d.ts +8 -0
  32. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  33. package/package.json +16 -16
@@ -1765,6 +1765,8 @@ var import_transactions6 = require("@fuel-ts/transactions");
1765
1765
  var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1766
1766
  var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1767
1767
  var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1768
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1769
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1768
1770
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1769
1771
  if (isRequestInputCoin(input) && input.assetId === assetId) {
1770
1772
  return acc.add(input.amount);
@@ -2027,7 +2029,7 @@ var BaseTransactionRequest = class {
2027
2029
  * @param coin - Coin resource.
2028
2030
  */
2029
2031
  addCoinInput(coin) {
2030
- const { assetId, owner, amount, id, predicate } = coin;
2032
+ const { assetId, owner, amount, id, predicate, predicateData } = coin;
2031
2033
  let witnessIndex;
2032
2034
  if (coin.predicate) {
2033
2035
  witnessIndex = 0;
@@ -2045,7 +2047,8 @@ var BaseTransactionRequest = class {
2045
2047
  assetId,
2046
2048
  txPointer: "0x00000000000000000000000000000000",
2047
2049
  witnessIndex,
2048
- predicate
2050
+ predicate,
2051
+ predicateData
2049
2052
  };
2050
2053
  this.pushInput(input);
2051
2054
  this.addChangeOutput(owner, assetId);
@@ -2057,7 +2060,7 @@ var BaseTransactionRequest = class {
2057
2060
  * @param message - Message resource.
2058
2061
  */
2059
2062
  addMessageInput(message) {
2060
- const { recipient, sender, amount, predicate, nonce, assetId } = message;
2063
+ const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2061
2064
  let witnessIndex;
2062
2065
  if (message.predicate) {
2063
2066
  witnessIndex = 0;
@@ -2074,7 +2077,8 @@ var BaseTransactionRequest = class {
2074
2077
  recipient: recipient.toB256(),
2075
2078
  amount,
2076
2079
  witnessIndex,
2077
- predicate
2080
+ predicate,
2081
+ predicateData
2078
2082
  };
2079
2083
  this.pushInput(input);
2080
2084
  this.addChangeOutput(recipient, assetId);
@@ -2276,23 +2280,13 @@ var BaseTransactionRequest = class {
2276
2280
  });
2277
2281
  }
2278
2282
  updatePredicateGasUsed(inputs) {
2279
- this.inputs.forEach((i) => {
2280
- let correspondingInput;
2281
- switch (i.type) {
2282
- case import_transactions7.InputType.Coin:
2283
- correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2284
- break;
2285
- case import_transactions7.InputType.Message:
2286
- correspondingInput = inputs.find(
2287
- (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2288
- );
2289
- break;
2290
- default:
2291
- return;
2292
- }
2283
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2284
+ this.inputs.filter(isRequestInputResource).forEach((i) => {
2285
+ const owner = getRequestInputResourceOwner(i);
2286
+ const correspondingInput = inputsToExtractGasUsed.find(
2287
+ (x) => isRequestInputResourceFromOwner(x, import_address.Address.fromString(String(owner)))
2288
+ );
2293
2289
  if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2294
- i.predicate = correspondingInput.predicate;
2295
- i.predicateData = correspondingInput.predicateData;
2296
2290
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
2297
2291
  }
2298
2292
  });
@@ -2625,6 +2619,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2625
2619
  }
2626
2620
  return this.outputs.length - 1;
2627
2621
  }
2622
+ /**
2623
+ * Calculates the maximum gas for the transaction.
2624
+ *
2625
+ * @param chainInfo - The chain information.
2626
+ * @param minGas - The minimum gas.
2627
+ * @returns the maximum gas.
2628
+ */
2628
2629
  calculateMaxGas(chainInfo, minGas) {
2629
2630
  const { consensusParameters } = chainInfo;
2630
2631
  const {
@@ -2993,13 +2994,13 @@ function addOperation(operations, toAdd) {
2993
2994
  }
2994
2995
  function getWithdrawFromFuelOperations({
2995
2996
  inputs,
2996
- receipts
2997
+ receipts,
2998
+ baseAssetId
2997
2999
  }) {
2998
3000
  const messageOutReceipts = getReceiptsMessageOut(receipts);
2999
3001
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
3000
3002
  (prevWithdrawFromFuelOps, receipt) => {
3001
- const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
3002
- const input = getInputFromAssetId(inputs, assetId);
3003
+ const input = getInputFromAssetId(inputs, baseAssetId);
3003
3004
  if (input) {
3004
3005
  const inputAddress = getInputAccountAddress(input);
3005
3006
  const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
@@ -3016,7 +3017,7 @@ function getWithdrawFromFuelOperations({
3016
3017
  assetsSent: [
3017
3018
  {
3018
3019
  amount: receipt.amount,
3019
- assetId
3020
+ assetId: baseAssetId
3020
3021
  }
3021
3022
  ]
3022
3023
  });
@@ -3212,7 +3213,8 @@ function getOperations({
3212
3213
  receipts,
3213
3214
  abiMap,
3214
3215
  rawPayload,
3215
- maxInputs
3216
+ maxInputs,
3217
+ baseAssetId
3216
3218
  }) {
3217
3219
  if (isTypeCreate(transactionType)) {
3218
3220
  return [
@@ -3231,7 +3233,7 @@ function getOperations({
3231
3233
  rawPayload,
3232
3234
  maxInputs
3233
3235
  }),
3234
- ...getWithdrawFromFuelOperations({ inputs, receipts })
3236
+ ...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
3235
3237
  ];
3236
3238
  }
3237
3239
  return [...getPayProducerOperations(outputs)];
@@ -3367,7 +3369,8 @@ function assembleTransactionSummary(params) {
3367
3369
  maxInputs,
3368
3370
  gasCosts,
3369
3371
  maxGasPerTx,
3370
- gasPrice
3372
+ gasPrice,
3373
+ baseAssetId
3371
3374
  } = params;
3372
3375
  const gasUsed = getGasUsedFromReceipts(receipts);
3373
3376
  const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
@@ -3378,7 +3381,8 @@ function assembleTransactionSummary(params) {
3378
3381
  receipts,
3379
3382
  rawPayload,
3380
3383
  abiMap,
3381
- maxInputs
3384
+ maxInputs,
3385
+ baseAssetId
3382
3386
  });
3383
3387
  const typeName = getTransactionTypeName(transaction.type);
3384
3388
  const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
@@ -3538,6 +3542,7 @@ var TransactionResponse = class {
3538
3542
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3539
3543
  const gasPrice = await this.provider.getLatestGasPrice();
3540
3544
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3545
+ const baseAssetId = this.provider.getBaseAssetId();
3541
3546
  const transactionSummary = assembleTransactionSummary({
3542
3547
  id: this.id,
3543
3548
  receipts,
@@ -3550,7 +3555,8 @@ var TransactionResponse = class {
3550
3555
  maxInputs,
3551
3556
  gasCosts,
3552
3557
  maxGasPerTx,
3553
- gasPrice
3558
+ gasPrice,
3559
+ baseAssetId
3554
3560
  });
3555
3561
  return transactionSummary;
3556
3562
  }
@@ -3738,7 +3744,6 @@ var _Provider = class {
3738
3744
  * Constructor to initialize a Provider.
3739
3745
  *
3740
3746
  * @param url - GraphQL endpoint of the Fuel node
3741
- * @param chainInfo - Chain info of the Fuel node
3742
3747
  * @param options - Additional options for the provider
3743
3748
  * @hidden
3744
3749
  */
@@ -3761,10 +3766,14 @@ var _Provider = class {
3761
3766
  this.operations = this.createOperations();
3762
3767
  this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
3763
3768
  }
3769
+ /** @hidden */
3764
3770
  static clearChainAndNodeCaches() {
3765
3771
  _Provider.nodeInfoCache = {};
3766
3772
  _Provider.chainInfoCache = {};
3767
3773
  }
3774
+ /**
3775
+ * @hidden
3776
+ */
3768
3777
  static getFetchFn(options) {
3769
3778
  const { retryOptions, timeout } = options;
3770
3779
  return autoRetryFetch(async (...args) => {
@@ -3780,8 +3789,11 @@ var _Provider = class {
3780
3789
  }
3781
3790
  /**
3782
3791
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
3792
+ *
3783
3793
  * @param url - GraphQL endpoint of the Fuel node
3784
3794
  * @param options - Additional options for the provider
3795
+ *
3796
+ * @returns A promise that resolves to a Provider instance.
3785
3797
  */
3786
3798
  static async create(url, options = {}) {
3787
3799
  const provider = new _Provider(url, options);
@@ -3790,6 +3802,8 @@ var _Provider = class {
3790
3802
  }
3791
3803
  /**
3792
3804
  * Returns the cached chainInfo for the current URL.
3805
+ *
3806
+ * @returns the chain information configuration.
3793
3807
  */
3794
3808
  getChain() {
3795
3809
  const chain = _Provider.chainInfoCache[this.url];
@@ -3803,6 +3817,8 @@ var _Provider = class {
3803
3817
  }
3804
3818
  /**
3805
3819
  * Returns the cached nodeInfo for the current URL.
3820
+ *
3821
+ * @returns the node information configuration.
3806
3822
  */
3807
3823
  getNode() {
3808
3824
  const node = _Provider.nodeInfoCache[this.url];
@@ -3834,6 +3850,9 @@ var _Provider = class {
3834
3850
  }
3835
3851
  /**
3836
3852
  * Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
3853
+ *
3854
+ * @param url - The URL to connect to.
3855
+ * @param options - Additional options for the provider.
3837
3856
  */
3838
3857
  async connect(url, options) {
3839
3858
  this.url = url;
@@ -3842,9 +3861,9 @@ var _Provider = class {
3842
3861
  await this.fetchChainAndNodeInfo();
3843
3862
  }
3844
3863
  /**
3845
- * Fetches both the chain and node information, saves it to the cache, and return it.
3864
+ * Return the chain and node information.
3846
3865
  *
3847
- * @returns NodeInfo and Chain
3866
+ * @returns A promise that resolves to the Chain and NodeInfo.
3848
3867
  */
3849
3868
  async fetchChainAndNodeInfo() {
3850
3869
  const chain = await this.fetchChain();
@@ -3855,6 +3874,9 @@ var _Provider = class {
3855
3874
  nodeInfo
3856
3875
  };
3857
3876
  }
3877
+ /**
3878
+ * @hidden
3879
+ */
3858
3880
  static ensureClientVersionIsSupported(nodeInfo) {
3859
3881
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3860
3882
  if (!isMajorSupported || !isMinorSupported) {
@@ -3870,6 +3892,7 @@ Supported fuel-core version: ${supportedVersion}.`
3870
3892
  * Create GraphQL client and set operations.
3871
3893
  *
3872
3894
  * @returns The operation SDK object
3895
+ * @hidden
3873
3896
  */
3874
3897
  createOperations() {
3875
3898
  const fetchFn = _Provider.getFetchFn(this.options);
@@ -3914,18 +3937,18 @@ Supported fuel-core version: ${supportedVersion}.`
3914
3937
  return nodeVersion;
3915
3938
  }
3916
3939
  /**
3917
- * Returns the block number.
3940
+ * Returns the latest block number.
3918
3941
  *
3919
- * @returns A promise that resolves to the block number
3942
+ * @returns A promise that resolves to the latest block number.
3920
3943
  */
3921
3944
  async getBlockNumber() {
3922
3945
  const { chain } = await this.operations.getChain();
3923
3946
  return (0, import_math17.bn)(chain.latestBlock.height, 10);
3924
3947
  }
3925
3948
  /**
3926
- * Returns the chain information.
3927
- * @param url - The URL of the Fuel node
3928
- * @returns NodeInfo object
3949
+ * Returns the node information for the current provider network.
3950
+ *
3951
+ * @returns a promise that resolves to the node information.
3929
3952
  */
3930
3953
  async fetchNode() {
3931
3954
  const { nodeInfo } = await this.operations.getNodeInfo();
@@ -3940,9 +3963,9 @@ Supported fuel-core version: ${supportedVersion}.`
3940
3963
  return processedNodeInfo;
3941
3964
  }
3942
3965
  /**
3943
- * Fetches the `chainInfo` for the given node URL.
3944
- * @param url - The URL of the Fuel node
3945
- * @returns ChainInfo object
3966
+ * Returns the chain information for the current provider network.
3967
+ *
3968
+ * @returns a promise that resolves to the chain information.
3946
3969
  */
3947
3970
  async fetchChain() {
3948
3971
  const { chain } = await this.operations.getChain();
@@ -3951,8 +3974,9 @@ Supported fuel-core version: ${supportedVersion}.`
3951
3974
  return processedChain;
3952
3975
  }
3953
3976
  /**
3954
- * Returns the chain ID
3955
- * @returns A promise that resolves to the chain ID number
3977
+ * Returns the chain ID for the current provider network.
3978
+ *
3979
+ * @returns A promise that resolves to the chain ID number.
3956
3980
  */
3957
3981
  getChainId() {
3958
3982
  const {
@@ -3961,9 +3985,9 @@ Supported fuel-core version: ${supportedVersion}.`
3961
3985
  return chainId.toNumber();
3962
3986
  }
3963
3987
  /**
3964
- * Returns the base asset ID for the current provider network
3988
+ * Returns the base asset ID for the current provider network.
3965
3989
  *
3966
- * @returns the base asset ID
3990
+ * @returns the base asset ID.
3967
3991
  */
3968
3992
  getBaseAssetId() {
3969
3993
  const {
@@ -3978,6 +4002,7 @@ Supported fuel-core version: ${supportedVersion}.`
3978
4002
  * the transaction will be mutated and those dependencies will be added.
3979
4003
  *
3980
4004
  * @param transactionRequestLike - The transaction request object.
4005
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
3981
4006
  * @returns A promise that resolves to the transaction response object.
3982
4007
  */
3983
4008
  // #region Provider-sendTransaction
@@ -4022,7 +4047,7 @@ Supported fuel-core version: ${supportedVersion}.`
4022
4047
  * the transaction will be mutated and those dependencies will be added.
4023
4048
  *
4024
4049
  * @param transactionRequestLike - The transaction request object.
4025
- * @param utxoValidation - Additional provider call parameters.
4050
+ * @param sendTransactionParams - The provider call parameters (optional).
4026
4051
  * @returns A promise that resolves to the call result object.
4027
4052
  */
4028
4053
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
@@ -4042,6 +4067,8 @@ Supported fuel-core version: ${supportedVersion}.`
4042
4067
  /**
4043
4068
  * Verifies whether enough gas is available to complete transaction.
4044
4069
  *
4070
+ * @template T - The type of the transaction request object.
4071
+ *
4045
4072
  * @param transactionRequest - The transaction request object.
4046
4073
  * @returns A promise that resolves to the estimated transaction request object.
4047
4074
  */
@@ -4076,9 +4103,8 @@ Supported fuel-core version: ${supportedVersion}.`
4076
4103
  * If there are missing variable outputs,
4077
4104
  * `addVariableOutputs` is called on the transaction.
4078
4105
  *
4079
- *
4080
4106
  * @param transactionRequest - The transaction request object.
4081
- * @returns A promise.
4107
+ * @returns A promise that resolves to the estimate transaction dependencies.
4082
4108
  */
4083
4109
  async estimateTxDependencies(transactionRequest) {
4084
4110
  if (transactionRequest.type === import_transactions20.TransactionType.Create) {
@@ -4191,6 +4217,14 @@ Supported fuel-core version: ${supportedVersion}.`
4191
4217
  }
4192
4218
  return results;
4193
4219
  }
4220
+ /**
4221
+ * Dry runs multiple transactions.
4222
+ *
4223
+ * @param transactionRequests - Array of transaction request objects.
4224
+ * @param sendTransactionParams - The provider call parameters (optional).
4225
+ *
4226
+ * @returns A promise that resolves to an array of results for each transaction call.
4227
+ */
4194
4228
  async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4195
4229
  if (estimateTxDependencies) {
4196
4230
  return this.estimateMultipleTxDependencies(transactionRequests);
@@ -4261,6 +4295,7 @@ Supported fuel-core version: ${supportedVersion}.`
4261
4295
  * the transaction will be mutated and those dependencies will be added
4262
4296
  *
4263
4297
  * @param transactionRequestLike - The transaction request object.
4298
+ * @param estimateTxParams - The estimate transaction params (optional).
4264
4299
  * @returns A promise that resolves to the call result object.
4265
4300
  */
4266
4301
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -4285,14 +4320,9 @@ Supported fuel-core version: ${supportedVersion}.`
4285
4320
  * to set gasLimit and also reserve balance amounts
4286
4321
  * on the the transaction.
4287
4322
  *
4288
- * @privateRemarks
4289
- * The tolerance is add on top of the gasUsed calculated
4290
- * from the node, this create a safe margin costs like
4291
- * change states on transfer that don't occur on the dryRun
4292
- * transaction. The default value is 0.2 or 20%
4293
- *
4294
4323
  * @param transactionRequestLike - The transaction request object.
4295
- * @param tolerance - The tolerance to add on top of the gasUsed.
4324
+ * @param transactionCostParams - The transaction cost parameters (optional).
4325
+ *
4296
4326
  * @returns A promise that resolves to the transaction cost object.
4297
4327
  */
4298
4328
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
@@ -4360,6 +4390,15 @@ Supported fuel-core version: ${supportedVersion}.`
4360
4390
  updateMaxFee
4361
4391
  };
4362
4392
  }
4393
+ /**
4394
+ * Get the required quantities and associated resources for a transaction.
4395
+ *
4396
+ * @param owner - address to add resources from.
4397
+ * @param transactionRequestLike - transaction request to populate resources for.
4398
+ * @param quantitiesToContract - quantities for the contract (optional).
4399
+ *
4400
+ * @returns a promise resolving to the required quantities for the transaction.
4401
+ */
4363
4402
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4364
4403
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4365
4404
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
@@ -4381,6 +4420,12 @@ Supported fuel-core version: ${supportedVersion}.`
4381
4420
  }
4382
4421
  /**
4383
4422
  * Returns coins for the given owner.
4423
+ *
4424
+ * @param owner - The address to get coins for.
4425
+ * @param assetId - The asset ID of coins to get (optional).
4426
+ * @param paginationArgs - Pagination arguments (optional).
4427
+ *
4428
+ * @returns A promise that resolves to the coins.
4384
4429
  */
4385
4430
  async getCoins(owner, assetId, paginationArgs) {
4386
4431
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
@@ -4403,8 +4448,8 @@ Supported fuel-core version: ${supportedVersion}.`
4403
4448
  * Returns resources for the given owner satisfying the spend query.
4404
4449
  *
4405
4450
  * @param owner - The address to get resources for.
4406
- * @param quantities - The quantities to get.
4407
- * @param excludedIds - IDs of excluded resources from the selection.
4451
+ * @param quantities - The coin quantities to get.
4452
+ * @param excludedIds - IDs of excluded resources from the selection (optional).
4408
4453
  * @returns A promise that resolves to the resources.
4409
4454
  */
4410
4455
  async getResourcesToSpend(owner, quantities, excludedIds) {
@@ -4459,7 +4504,7 @@ Supported fuel-core version: ${supportedVersion}.`
4459
4504
  * Returns block matching the given ID or height.
4460
4505
  *
4461
4506
  * @param idOrHeight - ID or height of the block.
4462
- * @returns A promise that resolves to the block.
4507
+ * @returns A promise that resolves to the block or null.
4463
4508
  */
4464
4509
  async getBlock(idOrHeight) {
4465
4510
  let variables;
@@ -4589,7 +4634,7 @@ Supported fuel-core version: ${supportedVersion}.`
4589
4634
  * Returns balances for the given owner.
4590
4635
  *
4591
4636
  * @param owner - The address to get coins for.
4592
- * @param paginationArgs - Pagination arguments.
4637
+ * @param paginationArgs - Pagination arguments (optional).
4593
4638
  * @returns A promise that resolves to the balances.
4594
4639
  */
4595
4640
  async getBalances(owner, paginationArgs) {
@@ -4608,7 +4653,7 @@ Supported fuel-core version: ${supportedVersion}.`
4608
4653
  * Returns message for the given address.
4609
4654
  *
4610
4655
  * @param address - The address to get message from.
4611
- * @param paginationArgs - Pagination arguments.
4656
+ * @param paginationArgs - Pagination arguments (optional).
4612
4657
  * @returns A promise that resolves to the messages.
4613
4658
  */
4614
4659
  async getMessages(address, paginationArgs) {
@@ -4639,8 +4684,8 @@ Supported fuel-core version: ${supportedVersion}.`
4639
4684
  *
4640
4685
  * @param transactionId - The transaction to get message from.
4641
4686
  * @param messageId - The message id from MessageOut receipt.
4642
- * @param commitBlockId - The commit block id.
4643
- * @param commitBlockHeight - The commit block height.
4687
+ * @param commitBlockId - The commit block id (optional).
4688
+ * @param commitBlockHeight - The commit block height (optional).
4644
4689
  * @returns A promise that resolves to the message proof.
4645
4690
  */
4646
4691
  async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
@@ -4728,10 +4773,21 @@ Supported fuel-core version: ${supportedVersion}.`
4728
4773
  data
4729
4774
  };
4730
4775
  }
4776
+ /**
4777
+ * Get the latest gas price from the node.
4778
+ *
4779
+ * @returns A promise that resolves to the latest gas price.
4780
+ */
4731
4781
  async getLatestGasPrice() {
4732
4782
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4733
4783
  return (0, import_math17.bn)(latestGasPrice.gasPrice);
4734
4784
  }
4785
+ /**
4786
+ * Returns the estimate gas price for the given block horizon.
4787
+ *
4788
+ * @param blockHorizon - The block horizon to estimate gas price for.
4789
+ * @returns A promise that resolves to the estimated gas price.
4790
+ */
4735
4791
  async estimateGasPrice(blockHorizon) {
4736
4792
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4737
4793
  blockHorizon: String(blockHorizon)
@@ -4751,8 +4807,8 @@ Supported fuel-core version: ${supportedVersion}.`
4751
4807
  /**
4752
4808
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4753
4809
  *
4754
- * @param amount - The amount of blocks to produce
4755
- * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4810
+ * @param amount - The amount of blocks to produce.
4811
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
4756
4812
  * @returns A promise that resolves to the block number of the last produced block.
4757
4813
  */
4758
4814
  async produceBlocks(amount, startTime) {
@@ -4762,6 +4818,12 @@ Supported fuel-core version: ${supportedVersion}.`
4762
4818
  });
4763
4819
  return (0, import_math17.bn)(latestBlockHeight);
4764
4820
  }
4821
+ /**
4822
+ * Get the transaction response for the given transaction ID.
4823
+ *
4824
+ * @param transactionId - The transaction ID to get the response for.
4825
+ * @returns A promise that resolves to the transaction response.
4826
+ */
4765
4827
  // eslint-disable-next-line @typescript-eslint/require-await
4766
4828
  async getTransactionResponse(transactionId) {
4767
4829
  return new TransactionResponse(transactionId, this);
@@ -4770,7 +4832,7 @@ Supported fuel-core version: ${supportedVersion}.`
4770
4832
  * Returns Message for given nonce.
4771
4833
  *
4772
4834
  * @param nonce - The nonce of the message to retrieve.
4773
- * @returns A promise that resolves to the Message object.
4835
+ * @returns A promise that resolves to the Message object or null.
4774
4836
  */
4775
4837
  async getMessageByNonce(nonce) {
4776
4838
  const { message } = await this.operations.getMessageByNonce({ nonce });
@@ -4779,6 +4841,12 @@ Supported fuel-core version: ${supportedVersion}.`
4779
4841
  }
4780
4842
  return message;
4781
4843
  }
4844
+ /**
4845
+ * Get the relayed transaction for the given transaction ID.
4846
+ *
4847
+ * @param relayedTransactionId - The relayed transaction ID to get the response for.
4848
+ * @returns A promise that resolves to the relayed transaction.
4849
+ */
4782
4850
  async getRelayedTransactionStatus(relayedTransactionId) {
4783
4851
  const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4784
4852
  relayedTransactionId
@@ -4788,6 +4856,9 @@ Supported fuel-core version: ${supportedVersion}.`
4788
4856
  }
4789
4857
  return relayedTransactionStatus;
4790
4858
  }
4859
+ /**
4860
+ * @hidden
4861
+ */
4791
4862
  extractDryRunError(transactionRequest, receipts, dryRunStatus) {
4792
4863
  const status = dryRunStatus;
4793
4864
  let logs = [];
@@ -4817,7 +4888,9 @@ cacheInputs_fn = function(inputs) {
4817
4888
  }
4818
4889
  });
4819
4890
  };
4891
+ /** @hidden */
4820
4892
  __publicField(Provider, "chainInfoCache", {});
4893
+ /** @hidden */
4821
4894
  __publicField(Provider, "nodeInfoCache", {});
4822
4895
 
4823
4896
  // src/providers/transaction-summary/get-transaction-summary.ts
@@ -4944,12 +5017,16 @@ var Account = class extends import_interfaces.AbstractAccount {
4944
5017
  * The provider used to interact with the network.
4945
5018
  */
4946
5019
  _provider;
5020
+ /**
5021
+ * The connector for use with external wallets
5022
+ */
4947
5023
  _connector;
4948
5024
  /**
4949
5025
  * Creates a new Account instance.
4950
5026
  *
4951
5027
  * @param address - The address of the account.
4952
5028
  * @param provider - A Provider instance (optional).
5029
+ * @param connector - A FuelConnector instance (optional).
4953
5030
  */
4954
5031
  constructor(address, provider, connector) {
4955
5032
  super();
@@ -4991,8 +5068,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4991
5068
  /**
4992
5069
  * Retrieves resources satisfying the spend query for the account.
4993
5070
  *
4994
- * @param quantities - IDs of coins to exclude.
4995
- * @param excludedIds - IDs of resources to be excluded from the query.
5071
+ * @param quantities - Quantities of resources to be obtained.
5072
+ * @param excludedIds - IDs of resources to be excluded from the query (optional).
4996
5073
  * @returns A promise that resolves to an array of Resources.
4997
5074
  */
4998
5075
  async getResourcesToSpend(quantities, excludedIds) {
@@ -5001,7 +5078,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5001
5078
  /**
5002
5079
  * Retrieves coins owned by the account.
5003
5080
  *
5004
- * @param assetId - The asset ID of the coins to retrieve.
5081
+ * @param assetId - The asset ID of the coins to retrieve (optional).
5005
5082
  * @returns A promise that resolves to an array of Coins.
5006
5083
  */
5007
5084
  async getCoins(assetId) {
@@ -5054,7 +5131,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5054
5131
  /**
5055
5132
  * Retrieves the balance of the account for the given asset.
5056
5133
  *
5057
- * @param assetId - The asset ID to check the balance for.
5134
+ * @param assetId - The asset ID to check the balance for (optional).
5058
5135
  * @returns A promise that resolves to the balance amount.
5059
5136
  */
5060
5137
  async getBalance(assetId) {
@@ -5094,7 +5171,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5094
5171
  * @typeParam T - The type of the TransactionRequest.
5095
5172
  * @param request - The transaction request to fund.
5096
5173
  * @param params - The estimated transaction parameters.
5097
- * @returns The funded transaction request.
5174
+ * @returns A promise that resolves to the funded transaction request.
5098
5175
  */
5099
5176
  async fund(request, params) {
5100
5177
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
@@ -5187,25 +5264,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5187
5264
  *
5188
5265
  * @param destination - The address of the destination.
5189
5266
  * @param amount - The amount of coins to transfer.
5190
- * @param assetId - The asset ID of the coins to transfer.
5191
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5267
+ * @param assetId - The asset ID of the coins to transfer (optional).
5268
+ * @param txParams - The transaction parameters (optional).
5192
5269
  * @returns A promise that resolves to the prepared transaction request.
5193
5270
  */
5194
5271
  async createTransfer(destination, amount, assetId, txParams = {}) {
5195
5272
  let request = new ScriptTransactionRequest(txParams);
5196
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5197
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5198
- const txCost = await this.provider.getTransactionCost(request, {
5199
- estimateTxDependencies: true,
5200
- resourcesOwner: this
5201
- });
5202
- request = this.validateGasLimitAndMaxFee({
5203
- transactionRequest: request,
5204
- gasUsed: txCost.gasUsed,
5205
- maxFee: txCost.maxFee,
5206
- txParams
5207
- });
5208
- await this.fund(request, txCost);
5273
+ request = this.addTransfer(request, { destination, amount, assetId });
5274
+ request = await this.estimateAndFundTransaction(request, txParams);
5209
5275
  return request;
5210
5276
  }
5211
5277
  /**
@@ -5213,28 +5279,69 @@ var Account = class extends import_interfaces.AbstractAccount {
5213
5279
  *
5214
5280
  * @param destination - The address of the destination.
5215
5281
  * @param amount - The amount of coins to transfer.
5216
- * @param assetId - The asset ID of the coins to transfer.
5217
- * @param txParams - The transaction parameters (gasLimit, maturity).
5282
+ * @param assetId - The asset ID of the coins to transfer (optional).
5283
+ * @param txParams - The transaction parameters (optional).
5218
5284
  * @returns A promise that resolves to the transaction response.
5219
5285
  */
5220
5286
  async transfer(destination, amount, assetId, txParams = {}) {
5221
- if ((0, import_math20.bn)(amount).lte(0)) {
5222
- throw new import_errors16.FuelError(
5223
- import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5224
- "Transfer amount must be a positive number."
5225
- );
5226
- }
5227
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5228
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5287
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5229
5288
  return this.sendTransaction(request, { estimateTxDependencies: false });
5230
5289
  }
5290
+ /**
5291
+ * Transfers multiple amounts of a token to multiple recipients.
5292
+ *
5293
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5294
+ * @param txParams - Optional transaction parameters.
5295
+ * @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
5296
+ */
5297
+ async batchTransfer(transferParams, txParams = {}) {
5298
+ let request = new ScriptTransactionRequest(txParams);
5299
+ request = this.addBatchTransfer(request, transferParams);
5300
+ request = await this.estimateAndFundTransaction(request, txParams);
5301
+ return this.sendTransaction(request, { estimateTxDependencies: false });
5302
+ }
5303
+ /**
5304
+ * Adds a transfer to the given transaction request.
5305
+ *
5306
+ * @param request - The script transaction request to add transfers to.
5307
+ * @param transferParams - The object representing the transfer to be made.
5308
+ * @returns The updated transaction request with the added transfer.
5309
+ */
5310
+ addTransfer(request, transferParams) {
5311
+ const { destination, amount, assetId } = transferParams;
5312
+ this.validateTransferAmount(amount);
5313
+ request.addCoinOutput(
5314
+ import_address4.Address.fromAddressOrString(destination),
5315
+ amount,
5316
+ assetId ?? this.provider.getBaseAssetId()
5317
+ );
5318
+ return request;
5319
+ }
5320
+ /**
5321
+ * Adds multiple transfers to a script transaction request.
5322
+ *
5323
+ * @param request - The script transaction request to add transfers to.
5324
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5325
+ * @returns The updated script transaction request.
5326
+ */
5327
+ addBatchTransfer(request, transferParams) {
5328
+ const baseAssetId = this.provider.getBaseAssetId();
5329
+ transferParams.forEach(({ destination, amount, assetId }) => {
5330
+ this.addTransfer(request, {
5331
+ destination,
5332
+ amount,
5333
+ assetId: assetId ?? baseAssetId
5334
+ });
5335
+ });
5336
+ return request;
5337
+ }
5231
5338
  /**
5232
5339
  * Transfers coins to a contract address.
5233
5340
  *
5234
5341
  * @param contractId - The address of the contract.
5235
5342
  * @param amount - The amount of coins to transfer.
5236
- * @param assetId - The asset ID of the coins to transfer.
5237
- * @param txParams - The optional transaction parameters.
5343
+ * @param assetId - The asset ID of the coins to transfer (optional).
5344
+ * @param txParams - The transaction parameters (optional).
5238
5345
  * @returns A promise that resolves to the transaction response.
5239
5346
  */
5240
5347
  async transferToContract(contractId, amount, assetId, txParams = {}) {
@@ -5275,7 +5382,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5275
5382
  *
5276
5383
  * @param recipient - Address of the recipient on the base chain.
5277
5384
  * @param amount - Amount of base asset.
5278
- * @param txParams - The optional transaction parameters.
5385
+ * @param txParams - The transaction parameters (optional).
5279
5386
  * @returns A promise that resolves to the transaction response.
5280
5387
  */
5281
5388
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
@@ -5305,6 +5412,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5305
5412
  await this.fund(request, txCost);
5306
5413
  return this.sendTransaction(request);
5307
5414
  }
5415
+ /**
5416
+ * Sign a message from the account via the connector.
5417
+ *
5418
+ * @param message - the message to sign.
5419
+ * @returns a promise that resolves to the signature.
5420
+ *
5421
+ * @hidden
5422
+ */
5308
5423
  async signMessage(message) {
5309
5424
  if (!this._connector) {
5310
5425
  throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
@@ -5312,7 +5427,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5312
5427
  return this._connector.signMessage(this.address.toString(), message);
5313
5428
  }
5314
5429
  /**
5315
- * Signs a transaction with the wallet's private key.
5430
+ * Signs a transaction from the account via the connector..
5316
5431
  *
5317
5432
  * @param transactionRequestLike - The transaction request to sign.
5318
5433
  * @returns A promise that resolves to the signature of the transaction.
@@ -5330,6 +5445,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5330
5445
  * Sends a transaction to the network.
5331
5446
  *
5332
5447
  * @param transactionRequestLike - The transaction request to be sent.
5448
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
5333
5449
  * @returns A promise that resolves to the transaction response.
5334
5450
  */
5335
5451
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
@@ -5351,6 +5467,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5351
5467
  * Simulates a transaction.
5352
5468
  *
5353
5469
  * @param transactionRequestLike - The transaction request to be simulated.
5470
+ * @param estimateTxParams - The estimate transaction params (optional).
5354
5471
  * @returns A promise that resolves to the call result.
5355
5472
  */
5356
5473
  async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -5360,6 +5477,31 @@ var Account = class extends import_interfaces.AbstractAccount {
5360
5477
  }
5361
5478
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5362
5479
  }
5480
+ /** @hidden * */
5481
+ validateTransferAmount(amount) {
5482
+ if ((0, import_math20.bn)(amount).lte(0)) {
5483
+ throw new import_errors16.FuelError(
5484
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5485
+ "Transfer amount must be a positive number."
5486
+ );
5487
+ }
5488
+ }
5489
+ /** @hidden * */
5490
+ async estimateAndFundTransaction(transactionRequest, txParams) {
5491
+ let request = transactionRequest;
5492
+ const txCost = await this.provider.getTransactionCost(request, {
5493
+ resourcesOwner: this
5494
+ });
5495
+ request = this.validateGasLimitAndMaxFee({
5496
+ transactionRequest: request,
5497
+ gasUsed: txCost.gasUsed,
5498
+ maxFee: txCost.maxFee,
5499
+ txParams
5500
+ });
5501
+ request = await this.fund(request, txCost);
5502
+ return request;
5503
+ }
5504
+ /** @hidden * */
5363
5505
  validateGasLimitAndMaxFee({
5364
5506
  gasUsed,
5365
5507
  maxFee,
@@ -5659,6 +5801,8 @@ var BaseWalletUnlocked = class extends Account {
5659
5801
  * Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
5660
5802
  *
5661
5803
  * @param transactionRequestLike - The transaction request to send.
5804
+ * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
5805
+ * @param awaitExecution - Whether to wait for the transaction to be executed.
5662
5806
  * @returns A promise that resolves to the TransactionResponse object.
5663
5807
  */
5664
5808
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
@@ -5690,6 +5834,12 @@ var BaseWalletUnlocked = class extends Account {
5690
5834
  }
5691
5835
  );
5692
5836
  }
5837
+ /**
5838
+ * Encrypts an unlocked wallet with a password.
5839
+ *
5840
+ * @param password - the password to encrypt the wallet with.
5841
+ * @returns - the encrypted wallet.
5842
+ */
5693
5843
  async encrypt(password) {
5694
5844
  return encryptKeystoreWallet(this.privateKey, this.address, password);
5695
5845
  }
@@ -8433,7 +8583,6 @@ var generateTestWallet = async (provider, quantities) => {
8433
8583
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8434
8584
  var import_crypto7 = require("@fuel-ts/crypto");
8435
8585
  var import_utils36 = require("@fuel-ts/utils");
8436
- var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8437
8586
  var import_child_process = require("child_process");
8438
8587
  var import_crypto8 = require("crypto");
8439
8588
  var import_fs = require("fs");
@@ -8476,7 +8625,7 @@ var launchNode = async ({
8476
8625
  ip,
8477
8626
  port,
8478
8627
  args = [],
8479
- useSystemFuelCore = false,
8628
+ fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
8480
8629
  loggingEnabled = true,
8481
8630
  debugEnabled = false,
8482
8631
  basePath
@@ -8495,9 +8644,9 @@ var launchNode = async ({
8495
8644
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8496
8645
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8497
8646
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8647
+ const nativeExecutorVersion = getFlagValueFromArgs(args, "--native-executor-version") || "0";
8498
8648
  const graphQLStartSubstring = "Binding GraphQL provider to";
8499
- const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8500
- const command = useSystemFuelCore ? "fuel-core" : binPath;
8649
+ const command = fuelCorePath ?? "fuel-core";
8501
8650
  const ipToUse = ip || "0.0.0.0";
8502
8651
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
8503
8652
  port: 4e3,
@@ -8536,7 +8685,7 @@ var launchNode = async ({
8536
8685
  const signer = new Signer(pk);
8537
8686
  process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8538
8687
  stateConfigJson.coins.push({
8539
- tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8688
+ tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.BYTES_32)),
8540
8689
  owner: signer.address.toHexString(),
8541
8690
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8542
8691
  amount: "18446744073709551615",
@@ -8568,6 +8717,7 @@ var launchNode = async ({
8568
8717
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8569
8718
  ["--min-gas-price", "1"],
8570
8719
  poaInstant ? ["--poa-instant", "true"] : [],
8720
+ ["--native-executor-version", nativeExecutorVersion],
8571
8721
  ["--consensus-key", consensusKey],
8572
8722
  ["--snapshot", snapshotDirToUse],
8573
8723
  "--vm-backtrace",