@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
@@ -1751,6 +1751,8 @@ import { InputType as InputType2 } from "@fuel-ts/transactions";
1751
1751
  var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1752
1752
  var isRequestInputMessage = (input) => input.type === InputType2.Message;
1753
1753
  var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1754
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1755
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1754
1756
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1755
1757
  if (isRequestInputCoin(input) && input.assetId === assetId) {
1756
1758
  return acc.add(input.amount);
@@ -2013,7 +2015,7 @@ var BaseTransactionRequest = class {
2013
2015
  * @param coin - Coin resource.
2014
2016
  */
2015
2017
  addCoinInput(coin) {
2016
- const { assetId, owner, amount, id, predicate } = coin;
2018
+ const { assetId, owner, amount, id, predicate, predicateData } = coin;
2017
2019
  let witnessIndex;
2018
2020
  if (coin.predicate) {
2019
2021
  witnessIndex = 0;
@@ -2031,7 +2033,8 @@ var BaseTransactionRequest = class {
2031
2033
  assetId,
2032
2034
  txPointer: "0x00000000000000000000000000000000",
2033
2035
  witnessIndex,
2034
- predicate
2036
+ predicate,
2037
+ predicateData
2035
2038
  };
2036
2039
  this.pushInput(input);
2037
2040
  this.addChangeOutput(owner, assetId);
@@ -2043,7 +2046,7 @@ var BaseTransactionRequest = class {
2043
2046
  * @param message - Message resource.
2044
2047
  */
2045
2048
  addMessageInput(message) {
2046
- const { recipient, sender, amount, predicate, nonce, assetId } = message;
2049
+ const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2047
2050
  let witnessIndex;
2048
2051
  if (message.predicate) {
2049
2052
  witnessIndex = 0;
@@ -2060,7 +2063,8 @@ var BaseTransactionRequest = class {
2060
2063
  recipient: recipient.toB256(),
2061
2064
  amount,
2062
2065
  witnessIndex,
2063
- predicate
2066
+ predicate,
2067
+ predicateData
2064
2068
  };
2065
2069
  this.pushInput(input);
2066
2070
  this.addChangeOutput(recipient, assetId);
@@ -2262,23 +2266,13 @@ var BaseTransactionRequest = class {
2262
2266
  });
2263
2267
  }
2264
2268
  updatePredicateGasUsed(inputs) {
2265
- this.inputs.forEach((i) => {
2266
- let correspondingInput;
2267
- switch (i.type) {
2268
- case InputType3.Coin:
2269
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2270
- break;
2271
- case InputType3.Message:
2272
- correspondingInput = inputs.find(
2273
- (x) => x.type === InputType3.Message && x.sender === i.sender
2274
- );
2275
- break;
2276
- default:
2277
- return;
2278
- }
2269
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2270
+ this.inputs.filter(isRequestInputResource).forEach((i) => {
2271
+ const owner = getRequestInputResourceOwner(i);
2272
+ const correspondingInput = inputsToExtractGasUsed.find(
2273
+ (x) => isRequestInputResourceFromOwner(x, Address.fromString(String(owner)))
2274
+ );
2279
2275
  if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
2280
- i.predicate = correspondingInput.predicate;
2281
- i.predicateData = correspondingInput.predicateData;
2282
2276
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
2283
2277
  }
2284
2278
  });
@@ -2611,6 +2605,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2611
2605
  }
2612
2606
  return this.outputs.length - 1;
2613
2607
  }
2608
+ /**
2609
+ * Calculates the maximum gas for the transaction.
2610
+ *
2611
+ * @param chainInfo - The chain information.
2612
+ * @param minGas - The minimum gas.
2613
+ * @returns the maximum gas.
2614
+ */
2614
2615
  calculateMaxGas(chainInfo, minGas) {
2615
2616
  const { consensusParameters } = chainInfo;
2616
2617
  const {
@@ -2979,13 +2980,13 @@ function addOperation(operations, toAdd) {
2979
2980
  }
2980
2981
  function getWithdrawFromFuelOperations({
2981
2982
  inputs,
2982
- receipts
2983
+ receipts,
2984
+ baseAssetId
2983
2985
  }) {
2984
2986
  const messageOutReceipts = getReceiptsMessageOut(receipts);
2985
2987
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
2986
2988
  (prevWithdrawFromFuelOps, receipt) => {
2987
- const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
2988
- const input = getInputFromAssetId(inputs, assetId);
2989
+ const input = getInputFromAssetId(inputs, baseAssetId);
2989
2990
  if (input) {
2990
2991
  const inputAddress = getInputAccountAddress(input);
2991
2992
  const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
@@ -3002,7 +3003,7 @@ function getWithdrawFromFuelOperations({
3002
3003
  assetsSent: [
3003
3004
  {
3004
3005
  amount: receipt.amount,
3005
- assetId
3006
+ assetId: baseAssetId
3006
3007
  }
3007
3008
  ]
3008
3009
  });
@@ -3198,7 +3199,8 @@ function getOperations({
3198
3199
  receipts,
3199
3200
  abiMap,
3200
3201
  rawPayload,
3201
- maxInputs
3202
+ maxInputs,
3203
+ baseAssetId
3202
3204
  }) {
3203
3205
  if (isTypeCreate(transactionType)) {
3204
3206
  return [
@@ -3217,7 +3219,7 @@ function getOperations({
3217
3219
  rawPayload,
3218
3220
  maxInputs
3219
3221
  }),
3220
- ...getWithdrawFromFuelOperations({ inputs, receipts })
3222
+ ...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
3221
3223
  ];
3222
3224
  }
3223
3225
  return [...getPayProducerOperations(outputs)];
@@ -3353,7 +3355,8 @@ function assembleTransactionSummary(params) {
3353
3355
  maxInputs,
3354
3356
  gasCosts,
3355
3357
  maxGasPerTx,
3356
- gasPrice
3358
+ gasPrice,
3359
+ baseAssetId
3357
3360
  } = params;
3358
3361
  const gasUsed = getGasUsedFromReceipts(receipts);
3359
3362
  const rawPayload = hexlify11(transactionBytes);
@@ -3364,7 +3367,8 @@ function assembleTransactionSummary(params) {
3364
3367
  receipts,
3365
3368
  rawPayload,
3366
3369
  abiMap,
3367
- maxInputs
3370
+ maxInputs,
3371
+ baseAssetId
3368
3372
  });
3369
3373
  const typeName = getTransactionTypeName(transaction.type);
3370
3374
  const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
@@ -3524,6 +3528,7 @@ var TransactionResponse = class {
3524
3528
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3525
3529
  const gasPrice = await this.provider.getLatestGasPrice();
3526
3530
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3531
+ const baseAssetId = this.provider.getBaseAssetId();
3527
3532
  const transactionSummary = assembleTransactionSummary({
3528
3533
  id: this.id,
3529
3534
  receipts,
@@ -3536,7 +3541,8 @@ var TransactionResponse = class {
3536
3541
  maxInputs,
3537
3542
  gasCosts,
3538
3543
  maxGasPerTx,
3539
- gasPrice
3544
+ gasPrice,
3545
+ baseAssetId
3540
3546
  });
3541
3547
  return transactionSummary;
3542
3548
  }
@@ -3724,7 +3730,6 @@ var _Provider = class {
3724
3730
  * Constructor to initialize a Provider.
3725
3731
  *
3726
3732
  * @param url - GraphQL endpoint of the Fuel node
3727
- * @param chainInfo - Chain info of the Fuel node
3728
3733
  * @param options - Additional options for the provider
3729
3734
  * @hidden
3730
3735
  */
@@ -3747,10 +3752,14 @@ var _Provider = class {
3747
3752
  this.operations = this.createOperations();
3748
3753
  this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
3749
3754
  }
3755
+ /** @hidden */
3750
3756
  static clearChainAndNodeCaches() {
3751
3757
  _Provider.nodeInfoCache = {};
3752
3758
  _Provider.chainInfoCache = {};
3753
3759
  }
3760
+ /**
3761
+ * @hidden
3762
+ */
3754
3763
  static getFetchFn(options) {
3755
3764
  const { retryOptions, timeout } = options;
3756
3765
  return autoRetryFetch(async (...args) => {
@@ -3766,8 +3775,11 @@ var _Provider = class {
3766
3775
  }
3767
3776
  /**
3768
3777
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
3778
+ *
3769
3779
  * @param url - GraphQL endpoint of the Fuel node
3770
3780
  * @param options - Additional options for the provider
3781
+ *
3782
+ * @returns A promise that resolves to a Provider instance.
3771
3783
  */
3772
3784
  static async create(url, options = {}) {
3773
3785
  const provider = new _Provider(url, options);
@@ -3776,6 +3788,8 @@ var _Provider = class {
3776
3788
  }
3777
3789
  /**
3778
3790
  * Returns the cached chainInfo for the current URL.
3791
+ *
3792
+ * @returns the chain information configuration.
3779
3793
  */
3780
3794
  getChain() {
3781
3795
  const chain = _Provider.chainInfoCache[this.url];
@@ -3789,6 +3803,8 @@ var _Provider = class {
3789
3803
  }
3790
3804
  /**
3791
3805
  * Returns the cached nodeInfo for the current URL.
3806
+ *
3807
+ * @returns the node information configuration.
3792
3808
  */
3793
3809
  getNode() {
3794
3810
  const node = _Provider.nodeInfoCache[this.url];
@@ -3820,6 +3836,9 @@ var _Provider = class {
3820
3836
  }
3821
3837
  /**
3822
3838
  * Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
3839
+ *
3840
+ * @param url - The URL to connect to.
3841
+ * @param options - Additional options for the provider.
3823
3842
  */
3824
3843
  async connect(url, options) {
3825
3844
  this.url = url;
@@ -3828,9 +3847,9 @@ var _Provider = class {
3828
3847
  await this.fetchChainAndNodeInfo();
3829
3848
  }
3830
3849
  /**
3831
- * Fetches both the chain and node information, saves it to the cache, and return it.
3850
+ * Return the chain and node information.
3832
3851
  *
3833
- * @returns NodeInfo and Chain
3852
+ * @returns A promise that resolves to the Chain and NodeInfo.
3834
3853
  */
3835
3854
  async fetchChainAndNodeInfo() {
3836
3855
  const chain = await this.fetchChain();
@@ -3841,6 +3860,9 @@ var _Provider = class {
3841
3860
  nodeInfo
3842
3861
  };
3843
3862
  }
3863
+ /**
3864
+ * @hidden
3865
+ */
3844
3866
  static ensureClientVersionIsSupported(nodeInfo) {
3845
3867
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3846
3868
  if (!isMajorSupported || !isMinorSupported) {
@@ -3856,6 +3878,7 @@ Supported fuel-core version: ${supportedVersion}.`
3856
3878
  * Create GraphQL client and set operations.
3857
3879
  *
3858
3880
  * @returns The operation SDK object
3881
+ * @hidden
3859
3882
  */
3860
3883
  createOperations() {
3861
3884
  const fetchFn = _Provider.getFetchFn(this.options);
@@ -3900,18 +3923,18 @@ Supported fuel-core version: ${supportedVersion}.`
3900
3923
  return nodeVersion;
3901
3924
  }
3902
3925
  /**
3903
- * Returns the block number.
3926
+ * Returns the latest block number.
3904
3927
  *
3905
- * @returns A promise that resolves to the block number
3928
+ * @returns A promise that resolves to the latest block number.
3906
3929
  */
3907
3930
  async getBlockNumber() {
3908
3931
  const { chain } = await this.operations.getChain();
3909
3932
  return bn17(chain.latestBlock.height, 10);
3910
3933
  }
3911
3934
  /**
3912
- * Returns the chain information.
3913
- * @param url - The URL of the Fuel node
3914
- * @returns NodeInfo object
3935
+ * Returns the node information for the current provider network.
3936
+ *
3937
+ * @returns a promise that resolves to the node information.
3915
3938
  */
3916
3939
  async fetchNode() {
3917
3940
  const { nodeInfo } = await this.operations.getNodeInfo();
@@ -3926,9 +3949,9 @@ Supported fuel-core version: ${supportedVersion}.`
3926
3949
  return processedNodeInfo;
3927
3950
  }
3928
3951
  /**
3929
- * Fetches the `chainInfo` for the given node URL.
3930
- * @param url - The URL of the Fuel node
3931
- * @returns ChainInfo object
3952
+ * Returns the chain information for the current provider network.
3953
+ *
3954
+ * @returns a promise that resolves to the chain information.
3932
3955
  */
3933
3956
  async fetchChain() {
3934
3957
  const { chain } = await this.operations.getChain();
@@ -3937,8 +3960,9 @@ Supported fuel-core version: ${supportedVersion}.`
3937
3960
  return processedChain;
3938
3961
  }
3939
3962
  /**
3940
- * Returns the chain ID
3941
- * @returns A promise that resolves to the chain ID number
3963
+ * Returns the chain ID for the current provider network.
3964
+ *
3965
+ * @returns A promise that resolves to the chain ID number.
3942
3966
  */
3943
3967
  getChainId() {
3944
3968
  const {
@@ -3947,9 +3971,9 @@ Supported fuel-core version: ${supportedVersion}.`
3947
3971
  return chainId.toNumber();
3948
3972
  }
3949
3973
  /**
3950
- * Returns the base asset ID for the current provider network
3974
+ * Returns the base asset ID for the current provider network.
3951
3975
  *
3952
- * @returns the base asset ID
3976
+ * @returns the base asset ID.
3953
3977
  */
3954
3978
  getBaseAssetId() {
3955
3979
  const {
@@ -3964,6 +3988,7 @@ Supported fuel-core version: ${supportedVersion}.`
3964
3988
  * the transaction will be mutated and those dependencies will be added.
3965
3989
  *
3966
3990
  * @param transactionRequestLike - The transaction request object.
3991
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
3967
3992
  * @returns A promise that resolves to the transaction response object.
3968
3993
  */
3969
3994
  // #region Provider-sendTransaction
@@ -4008,7 +4033,7 @@ Supported fuel-core version: ${supportedVersion}.`
4008
4033
  * the transaction will be mutated and those dependencies will be added.
4009
4034
  *
4010
4035
  * @param transactionRequestLike - The transaction request object.
4011
- * @param utxoValidation - Additional provider call parameters.
4036
+ * @param sendTransactionParams - The provider call parameters (optional).
4012
4037
  * @returns A promise that resolves to the call result object.
4013
4038
  */
4014
4039
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
@@ -4028,6 +4053,8 @@ Supported fuel-core version: ${supportedVersion}.`
4028
4053
  /**
4029
4054
  * Verifies whether enough gas is available to complete transaction.
4030
4055
  *
4056
+ * @template T - The type of the transaction request object.
4057
+ *
4031
4058
  * @param transactionRequest - The transaction request object.
4032
4059
  * @returns A promise that resolves to the estimated transaction request object.
4033
4060
  */
@@ -4062,9 +4089,8 @@ Supported fuel-core version: ${supportedVersion}.`
4062
4089
  * If there are missing variable outputs,
4063
4090
  * `addVariableOutputs` is called on the transaction.
4064
4091
  *
4065
- *
4066
4092
  * @param transactionRequest - The transaction request object.
4067
- * @returns A promise.
4093
+ * @returns A promise that resolves to the estimate transaction dependencies.
4068
4094
  */
4069
4095
  async estimateTxDependencies(transactionRequest) {
4070
4096
  if (transactionRequest.type === TransactionType8.Create) {
@@ -4177,6 +4203,14 @@ Supported fuel-core version: ${supportedVersion}.`
4177
4203
  }
4178
4204
  return results;
4179
4205
  }
4206
+ /**
4207
+ * Dry runs multiple transactions.
4208
+ *
4209
+ * @param transactionRequests - Array of transaction request objects.
4210
+ * @param sendTransactionParams - The provider call parameters (optional).
4211
+ *
4212
+ * @returns A promise that resolves to an array of results for each transaction call.
4213
+ */
4180
4214
  async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4181
4215
  if (estimateTxDependencies) {
4182
4216
  return this.estimateMultipleTxDependencies(transactionRequests);
@@ -4247,6 +4281,7 @@ Supported fuel-core version: ${supportedVersion}.`
4247
4281
  * the transaction will be mutated and those dependencies will be added
4248
4282
  *
4249
4283
  * @param transactionRequestLike - The transaction request object.
4284
+ * @param estimateTxParams - The estimate transaction params (optional).
4250
4285
  * @returns A promise that resolves to the call result object.
4251
4286
  */
4252
4287
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -4271,14 +4306,9 @@ Supported fuel-core version: ${supportedVersion}.`
4271
4306
  * to set gasLimit and also reserve balance amounts
4272
4307
  * on the the transaction.
4273
4308
  *
4274
- * @privateRemarks
4275
- * The tolerance is add on top of the gasUsed calculated
4276
- * from the node, this create a safe margin costs like
4277
- * change states on transfer that don't occur on the dryRun
4278
- * transaction. The default value is 0.2 or 20%
4279
- *
4280
4309
  * @param transactionRequestLike - The transaction request object.
4281
- * @param tolerance - The tolerance to add on top of the gasUsed.
4310
+ * @param transactionCostParams - The transaction cost parameters (optional).
4311
+ *
4282
4312
  * @returns A promise that resolves to the transaction cost object.
4283
4313
  */
4284
4314
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
@@ -4346,6 +4376,15 @@ Supported fuel-core version: ${supportedVersion}.`
4346
4376
  updateMaxFee
4347
4377
  };
4348
4378
  }
4379
+ /**
4380
+ * Get the required quantities and associated resources for a transaction.
4381
+ *
4382
+ * @param owner - address to add resources from.
4383
+ * @param transactionRequestLike - transaction request to populate resources for.
4384
+ * @param quantitiesToContract - quantities for the contract (optional).
4385
+ *
4386
+ * @returns a promise resolving to the required quantities for the transaction.
4387
+ */
4349
4388
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4350
4389
  const ownerAddress = Address2.fromAddressOrString(owner);
4351
4390
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
@@ -4367,6 +4406,12 @@ Supported fuel-core version: ${supportedVersion}.`
4367
4406
  }
4368
4407
  /**
4369
4408
  * Returns coins for the given owner.
4409
+ *
4410
+ * @param owner - The address to get coins for.
4411
+ * @param assetId - The asset ID of coins to get (optional).
4412
+ * @param paginationArgs - Pagination arguments (optional).
4413
+ *
4414
+ * @returns A promise that resolves to the coins.
4370
4415
  */
4371
4416
  async getCoins(owner, assetId, paginationArgs) {
4372
4417
  const ownerAddress = Address2.fromAddressOrString(owner);
@@ -4389,8 +4434,8 @@ Supported fuel-core version: ${supportedVersion}.`
4389
4434
  * Returns resources for the given owner satisfying the spend query.
4390
4435
  *
4391
4436
  * @param owner - The address to get resources for.
4392
- * @param quantities - The quantities to get.
4393
- * @param excludedIds - IDs of excluded resources from the selection.
4437
+ * @param quantities - The coin quantities to get.
4438
+ * @param excludedIds - IDs of excluded resources from the selection (optional).
4394
4439
  * @returns A promise that resolves to the resources.
4395
4440
  */
4396
4441
  async getResourcesToSpend(owner, quantities, excludedIds) {
@@ -4445,7 +4490,7 @@ Supported fuel-core version: ${supportedVersion}.`
4445
4490
  * Returns block matching the given ID or height.
4446
4491
  *
4447
4492
  * @param idOrHeight - ID or height of the block.
4448
- * @returns A promise that resolves to the block.
4493
+ * @returns A promise that resolves to the block or null.
4449
4494
  */
4450
4495
  async getBlock(idOrHeight) {
4451
4496
  let variables;
@@ -4575,7 +4620,7 @@ Supported fuel-core version: ${supportedVersion}.`
4575
4620
  * Returns balances for the given owner.
4576
4621
  *
4577
4622
  * @param owner - The address to get coins for.
4578
- * @param paginationArgs - Pagination arguments.
4623
+ * @param paginationArgs - Pagination arguments (optional).
4579
4624
  * @returns A promise that resolves to the balances.
4580
4625
  */
4581
4626
  async getBalances(owner, paginationArgs) {
@@ -4594,7 +4639,7 @@ Supported fuel-core version: ${supportedVersion}.`
4594
4639
  * Returns message for the given address.
4595
4640
  *
4596
4641
  * @param address - The address to get message from.
4597
- * @param paginationArgs - Pagination arguments.
4642
+ * @param paginationArgs - Pagination arguments (optional).
4598
4643
  * @returns A promise that resolves to the messages.
4599
4644
  */
4600
4645
  async getMessages(address, paginationArgs) {
@@ -4625,8 +4670,8 @@ Supported fuel-core version: ${supportedVersion}.`
4625
4670
  *
4626
4671
  * @param transactionId - The transaction to get message from.
4627
4672
  * @param messageId - The message id from MessageOut receipt.
4628
- * @param commitBlockId - The commit block id.
4629
- * @param commitBlockHeight - The commit block height.
4673
+ * @param commitBlockId - The commit block id (optional).
4674
+ * @param commitBlockHeight - The commit block height (optional).
4630
4675
  * @returns A promise that resolves to the message proof.
4631
4676
  */
4632
4677
  async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
@@ -4714,10 +4759,21 @@ Supported fuel-core version: ${supportedVersion}.`
4714
4759
  data
4715
4760
  };
4716
4761
  }
4762
+ /**
4763
+ * Get the latest gas price from the node.
4764
+ *
4765
+ * @returns A promise that resolves to the latest gas price.
4766
+ */
4717
4767
  async getLatestGasPrice() {
4718
4768
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4719
4769
  return bn17(latestGasPrice.gasPrice);
4720
4770
  }
4771
+ /**
4772
+ * Returns the estimate gas price for the given block horizon.
4773
+ *
4774
+ * @param blockHorizon - The block horizon to estimate gas price for.
4775
+ * @returns A promise that resolves to the estimated gas price.
4776
+ */
4721
4777
  async estimateGasPrice(blockHorizon) {
4722
4778
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4723
4779
  blockHorizon: String(blockHorizon)
@@ -4737,8 +4793,8 @@ Supported fuel-core version: ${supportedVersion}.`
4737
4793
  /**
4738
4794
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4739
4795
  *
4740
- * @param amount - The amount of blocks to produce
4741
- * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4796
+ * @param amount - The amount of blocks to produce.
4797
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
4742
4798
  * @returns A promise that resolves to the block number of the last produced block.
4743
4799
  */
4744
4800
  async produceBlocks(amount, startTime) {
@@ -4748,6 +4804,12 @@ Supported fuel-core version: ${supportedVersion}.`
4748
4804
  });
4749
4805
  return bn17(latestBlockHeight);
4750
4806
  }
4807
+ /**
4808
+ * Get the transaction response for the given transaction ID.
4809
+ *
4810
+ * @param transactionId - The transaction ID to get the response for.
4811
+ * @returns A promise that resolves to the transaction response.
4812
+ */
4751
4813
  // eslint-disable-next-line @typescript-eslint/require-await
4752
4814
  async getTransactionResponse(transactionId) {
4753
4815
  return new TransactionResponse(transactionId, this);
@@ -4756,7 +4818,7 @@ Supported fuel-core version: ${supportedVersion}.`
4756
4818
  * Returns Message for given nonce.
4757
4819
  *
4758
4820
  * @param nonce - The nonce of the message to retrieve.
4759
- * @returns A promise that resolves to the Message object.
4821
+ * @returns A promise that resolves to the Message object or null.
4760
4822
  */
4761
4823
  async getMessageByNonce(nonce) {
4762
4824
  const { message } = await this.operations.getMessageByNonce({ nonce });
@@ -4765,6 +4827,12 @@ Supported fuel-core version: ${supportedVersion}.`
4765
4827
  }
4766
4828
  return message;
4767
4829
  }
4830
+ /**
4831
+ * Get the relayed transaction for the given transaction ID.
4832
+ *
4833
+ * @param relayedTransactionId - The relayed transaction ID to get the response for.
4834
+ * @returns A promise that resolves to the relayed transaction.
4835
+ */
4768
4836
  async getRelayedTransactionStatus(relayedTransactionId) {
4769
4837
  const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4770
4838
  relayedTransactionId
@@ -4774,6 +4842,9 @@ Supported fuel-core version: ${supportedVersion}.`
4774
4842
  }
4775
4843
  return relayedTransactionStatus;
4776
4844
  }
4845
+ /**
4846
+ * @hidden
4847
+ */
4777
4848
  extractDryRunError(transactionRequest, receipts, dryRunStatus) {
4778
4849
  const status = dryRunStatus;
4779
4850
  let logs = [];
@@ -4803,7 +4874,9 @@ cacheInputs_fn = function(inputs) {
4803
4874
  }
4804
4875
  });
4805
4876
  };
4877
+ /** @hidden */
4806
4878
  __publicField(Provider, "chainInfoCache", {});
4879
+ /** @hidden */
4807
4880
  __publicField(Provider, "nodeInfoCache", {});
4808
4881
 
4809
4882
  // src/providers/transaction-summary/get-transaction-summary.ts
@@ -4930,12 +5003,16 @@ var Account = class extends AbstractAccount {
4930
5003
  * The provider used to interact with the network.
4931
5004
  */
4932
5005
  _provider;
5006
+ /**
5007
+ * The connector for use with external wallets
5008
+ */
4933
5009
  _connector;
4934
5010
  /**
4935
5011
  * Creates a new Account instance.
4936
5012
  *
4937
5013
  * @param address - The address of the account.
4938
5014
  * @param provider - A Provider instance (optional).
5015
+ * @param connector - A FuelConnector instance (optional).
4939
5016
  */
4940
5017
  constructor(address, provider, connector) {
4941
5018
  super();
@@ -4977,8 +5054,8 @@ var Account = class extends AbstractAccount {
4977
5054
  /**
4978
5055
  * Retrieves resources satisfying the spend query for the account.
4979
5056
  *
4980
- * @param quantities - IDs of coins to exclude.
4981
- * @param excludedIds - IDs of resources to be excluded from the query.
5057
+ * @param quantities - Quantities of resources to be obtained.
5058
+ * @param excludedIds - IDs of resources to be excluded from the query (optional).
4982
5059
  * @returns A promise that resolves to an array of Resources.
4983
5060
  */
4984
5061
  async getResourcesToSpend(quantities, excludedIds) {
@@ -4987,7 +5064,7 @@ var Account = class extends AbstractAccount {
4987
5064
  /**
4988
5065
  * Retrieves coins owned by the account.
4989
5066
  *
4990
- * @param assetId - The asset ID of the coins to retrieve.
5067
+ * @param assetId - The asset ID of the coins to retrieve (optional).
4991
5068
  * @returns A promise that resolves to an array of Coins.
4992
5069
  */
4993
5070
  async getCoins(assetId) {
@@ -5040,7 +5117,7 @@ var Account = class extends AbstractAccount {
5040
5117
  /**
5041
5118
  * Retrieves the balance of the account for the given asset.
5042
5119
  *
5043
- * @param assetId - The asset ID to check the balance for.
5120
+ * @param assetId - The asset ID to check the balance for (optional).
5044
5121
  * @returns A promise that resolves to the balance amount.
5045
5122
  */
5046
5123
  async getBalance(assetId) {
@@ -5080,7 +5157,7 @@ var Account = class extends AbstractAccount {
5080
5157
  * @typeParam T - The type of the TransactionRequest.
5081
5158
  * @param request - The transaction request to fund.
5082
5159
  * @param params - The estimated transaction parameters.
5083
- * @returns The funded transaction request.
5160
+ * @returns A promise that resolves to the funded transaction request.
5084
5161
  */
5085
5162
  async fund(request, params) {
5086
5163
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
@@ -5173,25 +5250,14 @@ var Account = class extends AbstractAccount {
5173
5250
  *
5174
5251
  * @param destination - The address of the destination.
5175
5252
  * @param amount - The amount of coins to transfer.
5176
- * @param assetId - The asset ID of the coins to transfer.
5177
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5253
+ * @param assetId - The asset ID of the coins to transfer (optional).
5254
+ * @param txParams - The transaction parameters (optional).
5178
5255
  * @returns A promise that resolves to the prepared transaction request.
5179
5256
  */
5180
5257
  async createTransfer(destination, amount, assetId, txParams = {}) {
5181
5258
  let request = new ScriptTransactionRequest(txParams);
5182
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5183
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5184
- const txCost = await this.provider.getTransactionCost(request, {
5185
- estimateTxDependencies: true,
5186
- resourcesOwner: this
5187
- });
5188
- request = this.validateGasLimitAndMaxFee({
5189
- transactionRequest: request,
5190
- gasUsed: txCost.gasUsed,
5191
- maxFee: txCost.maxFee,
5192
- txParams
5193
- });
5194
- await this.fund(request, txCost);
5259
+ request = this.addTransfer(request, { destination, amount, assetId });
5260
+ request = await this.estimateAndFundTransaction(request, txParams);
5195
5261
  return request;
5196
5262
  }
5197
5263
  /**
@@ -5199,28 +5265,69 @@ var Account = class extends AbstractAccount {
5199
5265
  *
5200
5266
  * @param destination - The address of the destination.
5201
5267
  * @param amount - The amount of coins to transfer.
5202
- * @param assetId - The asset ID of the coins to transfer.
5203
- * @param txParams - The transaction parameters (gasLimit, maturity).
5268
+ * @param assetId - The asset ID of the coins to transfer (optional).
5269
+ * @param txParams - The transaction parameters (optional).
5204
5270
  * @returns A promise that resolves to the transaction response.
5205
5271
  */
5206
5272
  async transfer(destination, amount, assetId, txParams = {}) {
5207
- if (bn19(amount).lte(0)) {
5208
- throw new FuelError15(
5209
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
5210
- "Transfer amount must be a positive number."
5211
- );
5212
- }
5213
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5214
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5273
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5215
5274
  return this.sendTransaction(request, { estimateTxDependencies: false });
5216
5275
  }
5276
+ /**
5277
+ * Transfers multiple amounts of a token to multiple recipients.
5278
+ *
5279
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5280
+ * @param txParams - Optional transaction parameters.
5281
+ * @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
5282
+ */
5283
+ async batchTransfer(transferParams, txParams = {}) {
5284
+ let request = new ScriptTransactionRequest(txParams);
5285
+ request = this.addBatchTransfer(request, transferParams);
5286
+ request = await this.estimateAndFundTransaction(request, txParams);
5287
+ return this.sendTransaction(request, { estimateTxDependencies: false });
5288
+ }
5289
+ /**
5290
+ * Adds a transfer to the given transaction request.
5291
+ *
5292
+ * @param request - The script transaction request to add transfers to.
5293
+ * @param transferParams - The object representing the transfer to be made.
5294
+ * @returns The updated transaction request with the added transfer.
5295
+ */
5296
+ addTransfer(request, transferParams) {
5297
+ const { destination, amount, assetId } = transferParams;
5298
+ this.validateTransferAmount(amount);
5299
+ request.addCoinOutput(
5300
+ Address3.fromAddressOrString(destination),
5301
+ amount,
5302
+ assetId ?? this.provider.getBaseAssetId()
5303
+ );
5304
+ return request;
5305
+ }
5306
+ /**
5307
+ * Adds multiple transfers to a script transaction request.
5308
+ *
5309
+ * @param request - The script transaction request to add transfers to.
5310
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5311
+ * @returns The updated script transaction request.
5312
+ */
5313
+ addBatchTransfer(request, transferParams) {
5314
+ const baseAssetId = this.provider.getBaseAssetId();
5315
+ transferParams.forEach(({ destination, amount, assetId }) => {
5316
+ this.addTransfer(request, {
5317
+ destination,
5318
+ amount,
5319
+ assetId: assetId ?? baseAssetId
5320
+ });
5321
+ });
5322
+ return request;
5323
+ }
5217
5324
  /**
5218
5325
  * Transfers coins to a contract address.
5219
5326
  *
5220
5327
  * @param contractId - The address of the contract.
5221
5328
  * @param amount - The amount of coins to transfer.
5222
- * @param assetId - The asset ID of the coins to transfer.
5223
- * @param txParams - The optional transaction parameters.
5329
+ * @param assetId - The asset ID of the coins to transfer (optional).
5330
+ * @param txParams - The transaction parameters (optional).
5224
5331
  * @returns A promise that resolves to the transaction response.
5225
5332
  */
5226
5333
  async transferToContract(contractId, amount, assetId, txParams = {}) {
@@ -5261,7 +5368,7 @@ var Account = class extends AbstractAccount {
5261
5368
  *
5262
5369
  * @param recipient - Address of the recipient on the base chain.
5263
5370
  * @param amount - Amount of base asset.
5264
- * @param txParams - The optional transaction parameters.
5371
+ * @param txParams - The transaction parameters (optional).
5265
5372
  * @returns A promise that resolves to the transaction response.
5266
5373
  */
5267
5374
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
@@ -5291,6 +5398,14 @@ var Account = class extends AbstractAccount {
5291
5398
  await this.fund(request, txCost);
5292
5399
  return this.sendTransaction(request);
5293
5400
  }
5401
+ /**
5402
+ * Sign a message from the account via the connector.
5403
+ *
5404
+ * @param message - the message to sign.
5405
+ * @returns a promise that resolves to the signature.
5406
+ *
5407
+ * @hidden
5408
+ */
5294
5409
  async signMessage(message) {
5295
5410
  if (!this._connector) {
5296
5411
  throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
@@ -5298,7 +5413,7 @@ var Account = class extends AbstractAccount {
5298
5413
  return this._connector.signMessage(this.address.toString(), message);
5299
5414
  }
5300
5415
  /**
5301
- * Signs a transaction with the wallet's private key.
5416
+ * Signs a transaction from the account via the connector..
5302
5417
  *
5303
5418
  * @param transactionRequestLike - The transaction request to sign.
5304
5419
  * @returns A promise that resolves to the signature of the transaction.
@@ -5316,6 +5431,7 @@ var Account = class extends AbstractAccount {
5316
5431
  * Sends a transaction to the network.
5317
5432
  *
5318
5433
  * @param transactionRequestLike - The transaction request to be sent.
5434
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
5319
5435
  * @returns A promise that resolves to the transaction response.
5320
5436
  */
5321
5437
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
@@ -5337,6 +5453,7 @@ var Account = class extends AbstractAccount {
5337
5453
  * Simulates a transaction.
5338
5454
  *
5339
5455
  * @param transactionRequestLike - The transaction request to be simulated.
5456
+ * @param estimateTxParams - The estimate transaction params (optional).
5340
5457
  * @returns A promise that resolves to the call result.
5341
5458
  */
5342
5459
  async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -5346,6 +5463,31 @@ var Account = class extends AbstractAccount {
5346
5463
  }
5347
5464
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5348
5465
  }
5466
+ /** @hidden * */
5467
+ validateTransferAmount(amount) {
5468
+ if (bn19(amount).lte(0)) {
5469
+ throw new FuelError15(
5470
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
5471
+ "Transfer amount must be a positive number."
5472
+ );
5473
+ }
5474
+ }
5475
+ /** @hidden * */
5476
+ async estimateAndFundTransaction(transactionRequest, txParams) {
5477
+ let request = transactionRequest;
5478
+ const txCost = await this.provider.getTransactionCost(request, {
5479
+ resourcesOwner: this
5480
+ });
5481
+ request = this.validateGasLimitAndMaxFee({
5482
+ transactionRequest: request,
5483
+ gasUsed: txCost.gasUsed,
5484
+ maxFee: txCost.maxFee,
5485
+ txParams
5486
+ });
5487
+ request = await this.fund(request, txCost);
5488
+ return request;
5489
+ }
5490
+ /** @hidden * */
5349
5491
  validateGasLimitAndMaxFee({
5350
5492
  gasUsed,
5351
5493
  maxFee,
@@ -5653,6 +5795,8 @@ var BaseWalletUnlocked = class extends Account {
5653
5795
  * Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
5654
5796
  *
5655
5797
  * @param transactionRequestLike - The transaction request to send.
5798
+ * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
5799
+ * @param awaitExecution - Whether to wait for the transaction to be executed.
5656
5800
  * @returns A promise that resolves to the TransactionResponse object.
5657
5801
  */
5658
5802
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
@@ -5684,6 +5828,12 @@ var BaseWalletUnlocked = class extends Account {
5684
5828
  }
5685
5829
  );
5686
5830
  }
5831
+ /**
5832
+ * Encrypts an unlocked wallet with a password.
5833
+ *
5834
+ * @param password - the password to encrypt the wallet with.
5835
+ * @returns - the encrypted wallet.
5836
+ */
5687
5837
  async encrypt(password) {
5688
5838
  return encryptKeystoreWallet(this.privateKey, this.address, password);
5689
5839
  }
@@ -8424,10 +8574,9 @@ var generateTestWallet = async (provider, quantities) => {
8424
8574
  };
8425
8575
 
8426
8576
  // src/test-utils/launchNode.ts
8427
- import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8577
+ import { BYTES_32 as BYTES_322 } from "@fuel-ts/abi-coder";
8428
8578
  import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8429
8579
  import { defaultSnapshotConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8430
- import { findBinPath } from "@fuel-ts/utils/cli-utils";
8431
8580
  import { spawn } from "child_process";
8432
8581
  import { randomUUID } from "crypto";
8433
8582
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
@@ -8470,7 +8619,7 @@ var launchNode = async ({
8470
8619
  ip,
8471
8620
  port,
8472
8621
  args = [],
8473
- useSystemFuelCore = false,
8622
+ fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
8474
8623
  loggingEnabled = true,
8475
8624
  debugEnabled = false,
8476
8625
  basePath
@@ -8489,9 +8638,9 @@ var launchNode = async ({
8489
8638
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8490
8639
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8491
8640
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8641
+ const nativeExecutorVersion = getFlagValueFromArgs(args, "--native-executor-version") || "0";
8492
8642
  const graphQLStartSubstring = "Binding GraphQL provider to";
8493
- const binPath = findBinPath("fuels-core", __dirname);
8494
- const command = useSystemFuelCore ? "fuel-core" : binPath;
8643
+ const command = fuelCorePath ?? "fuel-core";
8495
8644
  const ipToUse = ip || "0.0.0.0";
8496
8645
  const portToUse = port || (await getPortPromise({
8497
8646
  port: 4e3,
@@ -8530,7 +8679,7 @@ var launchNode = async ({
8530
8679
  const signer = new Signer(pk);
8531
8680
  process.env.GENESIS_SECRET = hexlify18(pk);
8532
8681
  stateConfigJson.coins.push({
8533
- tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8682
+ tx_id: hexlify18(randomBytes6(BYTES_322)),
8534
8683
  owner: signer.address.toHexString(),
8535
8684
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8536
8685
  amount: "18446744073709551615",
@@ -8562,6 +8711,7 @@ var launchNode = async ({
8562
8711
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8563
8712
  ["--min-gas-price", "1"],
8564
8713
  poaInstant ? ["--poa-instant", "true"] : [],
8714
+ ["--native-executor-version", nativeExecutorVersion],
8565
8715
  ["--consensus-key", consensusKey],
8566
8716
  ["--snapshot", snapshotDirToUse],
8567
8717
  "--vm-backtrace",