@fuel-ts/account 0.88.0 → 0.89.0

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 +305 -138
  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 +456 -310
  26. package/dist/test-utils.global.js.map +1 -1
  27. package/dist/test-utils.js +250 -102
  28. package/dist/test-utils.js.map +1 -1
  29. package/dist/test-utils.mjs +250 -102
  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 +15 -15
package/dist/index.mjs CHANGED
@@ -2108,7 +2108,7 @@ var BaseTransactionRequest = class {
2108
2108
  * @param coin - Coin resource.
2109
2109
  */
2110
2110
  addCoinInput(coin) {
2111
- const { assetId, owner, amount, id, predicate } = coin;
2111
+ const { assetId, owner, amount, id, predicate, predicateData } = coin;
2112
2112
  let witnessIndex;
2113
2113
  if (coin.predicate) {
2114
2114
  witnessIndex = 0;
@@ -2126,7 +2126,8 @@ var BaseTransactionRequest = class {
2126
2126
  assetId,
2127
2127
  txPointer: "0x00000000000000000000000000000000",
2128
2128
  witnessIndex,
2129
- predicate
2129
+ predicate,
2130
+ predicateData
2130
2131
  };
2131
2132
  this.pushInput(input);
2132
2133
  this.addChangeOutput(owner, assetId);
@@ -2138,7 +2139,7 @@ var BaseTransactionRequest = class {
2138
2139
  * @param message - Message resource.
2139
2140
  */
2140
2141
  addMessageInput(message) {
2141
- const { recipient, sender, amount, predicate, nonce, assetId } = message;
2142
+ const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2142
2143
  let witnessIndex;
2143
2144
  if (message.predicate) {
2144
2145
  witnessIndex = 0;
@@ -2155,7 +2156,8 @@ var BaseTransactionRequest = class {
2155
2156
  recipient: recipient.toB256(),
2156
2157
  amount,
2157
2158
  witnessIndex,
2158
- predicate
2159
+ predicate,
2160
+ predicateData
2159
2161
  };
2160
2162
  this.pushInput(input);
2161
2163
  this.addChangeOutput(recipient, assetId);
@@ -2357,23 +2359,13 @@ var BaseTransactionRequest = class {
2357
2359
  });
2358
2360
  }
2359
2361
  updatePredicateGasUsed(inputs) {
2360
- this.inputs.forEach((i) => {
2361
- let correspondingInput;
2362
- switch (i.type) {
2363
- case InputType3.Coin:
2364
- correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2365
- break;
2366
- case InputType3.Message:
2367
- correspondingInput = inputs.find(
2368
- (x) => x.type === InputType3.Message && x.sender === i.sender
2369
- );
2370
- break;
2371
- default:
2372
- return;
2373
- }
2362
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2363
+ this.inputs.filter(isRequestInputResource).forEach((i) => {
2364
+ const owner = getRequestInputResourceOwner(i);
2365
+ const correspondingInput = inputsToExtractGasUsed.find(
2366
+ (x) => isRequestInputResourceFromOwner(x, Address.fromString(String(owner)))
2367
+ );
2374
2368
  if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
2375
- i.predicate = correspondingInput.predicate;
2376
- i.predicateData = correspondingInput.predicateData;
2377
2369
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
2378
2370
  }
2379
2371
  });
@@ -2706,6 +2698,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2706
2698
  }
2707
2699
  return this.outputs.length - 1;
2708
2700
  }
2701
+ /**
2702
+ * Calculates the maximum gas for the transaction.
2703
+ *
2704
+ * @param chainInfo - The chain information.
2705
+ * @param minGas - The minimum gas.
2706
+ * @returns the maximum gas.
2707
+ */
2709
2708
  calculateMaxGas(chainInfo, minGas) {
2710
2709
  const { consensusParameters } = chainInfo;
2711
2710
  const {
@@ -3123,13 +3122,13 @@ function getReceiptsTransferOut(receipts) {
3123
3122
  }
3124
3123
  function getWithdrawFromFuelOperations({
3125
3124
  inputs,
3126
- receipts
3125
+ receipts,
3126
+ baseAssetId
3127
3127
  }) {
3128
3128
  const messageOutReceipts = getReceiptsMessageOut(receipts);
3129
3129
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
3130
3130
  (prevWithdrawFromFuelOps, receipt) => {
3131
- const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
3132
- const input = getInputFromAssetId(inputs, assetId);
3131
+ const input = getInputFromAssetId(inputs, baseAssetId);
3133
3132
  if (input) {
3134
3133
  const inputAddress = getInputAccountAddress(input);
3135
3134
  const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
@@ -3146,7 +3145,7 @@ function getWithdrawFromFuelOperations({
3146
3145
  assetsSent: [
3147
3146
  {
3148
3147
  amount: receipt.amount,
3149
- assetId
3148
+ assetId: baseAssetId
3150
3149
  }
3151
3150
  ]
3152
3151
  });
@@ -3342,7 +3341,8 @@ function getOperations({
3342
3341
  receipts,
3343
3342
  abiMap,
3344
3343
  rawPayload,
3345
- maxInputs
3344
+ maxInputs,
3345
+ baseAssetId
3346
3346
  }) {
3347
3347
  if (isTypeCreate(transactionType)) {
3348
3348
  return [
@@ -3361,7 +3361,7 @@ function getOperations({
3361
3361
  rawPayload,
3362
3362
  maxInputs
3363
3363
  }),
3364
- ...getWithdrawFromFuelOperations({ inputs, receipts })
3364
+ ...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
3365
3365
  ];
3366
3366
  }
3367
3367
  return [...getPayProducerOperations(outputs)];
@@ -3497,7 +3497,8 @@ function assembleTransactionSummary(params) {
3497
3497
  maxInputs,
3498
3498
  gasCosts,
3499
3499
  maxGasPerTx,
3500
- gasPrice
3500
+ gasPrice,
3501
+ baseAssetId
3501
3502
  } = params;
3502
3503
  const gasUsed = getGasUsedFromReceipts(receipts);
3503
3504
  const rawPayload = hexlify11(transactionBytes);
@@ -3508,7 +3509,8 @@ function assembleTransactionSummary(params) {
3508
3509
  receipts,
3509
3510
  rawPayload,
3510
3511
  abiMap,
3511
- maxInputs
3512
+ maxInputs,
3513
+ baseAssetId
3512
3514
  });
3513
3515
  const typeName = getTransactionTypeName(transaction.type);
3514
3516
  const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
@@ -3668,6 +3670,7 @@ var TransactionResponse = class {
3668
3670
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3669
3671
  const gasPrice = await this.provider.getLatestGasPrice();
3670
3672
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3673
+ const baseAssetId = this.provider.getBaseAssetId();
3671
3674
  const transactionSummary = assembleTransactionSummary({
3672
3675
  id: this.id,
3673
3676
  receipts,
@@ -3680,7 +3683,8 @@ var TransactionResponse = class {
3680
3683
  maxInputs,
3681
3684
  gasCosts,
3682
3685
  maxGasPerTx,
3683
- gasPrice
3686
+ gasPrice,
3687
+ baseAssetId
3684
3688
  });
3685
3689
  return transactionSummary;
3686
3690
  }
@@ -3868,7 +3872,6 @@ var _Provider = class {
3868
3872
  * Constructor to initialize a Provider.
3869
3873
  *
3870
3874
  * @param url - GraphQL endpoint of the Fuel node
3871
- * @param chainInfo - Chain info of the Fuel node
3872
3875
  * @param options - Additional options for the provider
3873
3876
  * @hidden
3874
3877
  */
@@ -3891,10 +3894,14 @@ var _Provider = class {
3891
3894
  this.operations = this.createOperations();
3892
3895
  this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
3893
3896
  }
3897
+ /** @hidden */
3894
3898
  static clearChainAndNodeCaches() {
3895
3899
  _Provider.nodeInfoCache = {};
3896
3900
  _Provider.chainInfoCache = {};
3897
3901
  }
3902
+ /**
3903
+ * @hidden
3904
+ */
3898
3905
  static getFetchFn(options) {
3899
3906
  const { retryOptions, timeout } = options;
3900
3907
  return autoRetryFetch(async (...args) => {
@@ -3910,8 +3917,11 @@ var _Provider = class {
3910
3917
  }
3911
3918
  /**
3912
3919
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
3920
+ *
3913
3921
  * @param url - GraphQL endpoint of the Fuel node
3914
3922
  * @param options - Additional options for the provider
3923
+ *
3924
+ * @returns A promise that resolves to a Provider instance.
3915
3925
  */
3916
3926
  static async create(url, options = {}) {
3917
3927
  const provider = new _Provider(url, options);
@@ -3920,6 +3930,8 @@ var _Provider = class {
3920
3930
  }
3921
3931
  /**
3922
3932
  * Returns the cached chainInfo for the current URL.
3933
+ *
3934
+ * @returns the chain information configuration.
3923
3935
  */
3924
3936
  getChain() {
3925
3937
  const chain = _Provider.chainInfoCache[this.url];
@@ -3933,6 +3945,8 @@ var _Provider = class {
3933
3945
  }
3934
3946
  /**
3935
3947
  * Returns the cached nodeInfo for the current URL.
3948
+ *
3949
+ * @returns the node information configuration.
3936
3950
  */
3937
3951
  getNode() {
3938
3952
  const node = _Provider.nodeInfoCache[this.url];
@@ -3964,6 +3978,9 @@ var _Provider = class {
3964
3978
  }
3965
3979
  /**
3966
3980
  * Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
3981
+ *
3982
+ * @param url - The URL to connect to.
3983
+ * @param options - Additional options for the provider.
3967
3984
  */
3968
3985
  async connect(url, options) {
3969
3986
  this.url = url;
@@ -3972,9 +3989,9 @@ var _Provider = class {
3972
3989
  await this.fetchChainAndNodeInfo();
3973
3990
  }
3974
3991
  /**
3975
- * Fetches both the chain and node information, saves it to the cache, and return it.
3992
+ * Return the chain and node information.
3976
3993
  *
3977
- * @returns NodeInfo and Chain
3994
+ * @returns A promise that resolves to the Chain and NodeInfo.
3978
3995
  */
3979
3996
  async fetchChainAndNodeInfo() {
3980
3997
  const chain = await this.fetchChain();
@@ -3985,6 +4002,9 @@ var _Provider = class {
3985
4002
  nodeInfo
3986
4003
  };
3987
4004
  }
4005
+ /**
4006
+ * @hidden
4007
+ */
3988
4008
  static ensureClientVersionIsSupported(nodeInfo) {
3989
4009
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3990
4010
  if (!isMajorSupported || !isMinorSupported) {
@@ -4000,6 +4020,7 @@ Supported fuel-core version: ${supportedVersion}.`
4000
4020
  * Create GraphQL client and set operations.
4001
4021
  *
4002
4022
  * @returns The operation SDK object
4023
+ * @hidden
4003
4024
  */
4004
4025
  createOperations() {
4005
4026
  const fetchFn = _Provider.getFetchFn(this.options);
@@ -4044,18 +4065,18 @@ Supported fuel-core version: ${supportedVersion}.`
4044
4065
  return nodeVersion;
4045
4066
  }
4046
4067
  /**
4047
- * Returns the block number.
4068
+ * Returns the latest block number.
4048
4069
  *
4049
- * @returns A promise that resolves to the block number
4070
+ * @returns A promise that resolves to the latest block number.
4050
4071
  */
4051
4072
  async getBlockNumber() {
4052
4073
  const { chain } = await this.operations.getChain();
4053
4074
  return bn17(chain.latestBlock.height, 10);
4054
4075
  }
4055
4076
  /**
4056
- * Returns the chain information.
4057
- * @param url - The URL of the Fuel node
4058
- * @returns NodeInfo object
4077
+ * Returns the node information for the current provider network.
4078
+ *
4079
+ * @returns a promise that resolves to the node information.
4059
4080
  */
4060
4081
  async fetchNode() {
4061
4082
  const { nodeInfo } = await this.operations.getNodeInfo();
@@ -4070,9 +4091,9 @@ Supported fuel-core version: ${supportedVersion}.`
4070
4091
  return processedNodeInfo;
4071
4092
  }
4072
4093
  /**
4073
- * Fetches the `chainInfo` for the given node URL.
4074
- * @param url - The URL of the Fuel node
4075
- * @returns ChainInfo object
4094
+ * Returns the chain information for the current provider network.
4095
+ *
4096
+ * @returns a promise that resolves to the chain information.
4076
4097
  */
4077
4098
  async fetchChain() {
4078
4099
  const { chain } = await this.operations.getChain();
@@ -4081,8 +4102,9 @@ Supported fuel-core version: ${supportedVersion}.`
4081
4102
  return processedChain;
4082
4103
  }
4083
4104
  /**
4084
- * Returns the chain ID
4085
- * @returns A promise that resolves to the chain ID number
4105
+ * Returns the chain ID for the current provider network.
4106
+ *
4107
+ * @returns A promise that resolves to the chain ID number.
4086
4108
  */
4087
4109
  getChainId() {
4088
4110
  const {
@@ -4091,9 +4113,9 @@ Supported fuel-core version: ${supportedVersion}.`
4091
4113
  return chainId.toNumber();
4092
4114
  }
4093
4115
  /**
4094
- * Returns the base asset ID for the current provider network
4116
+ * Returns the base asset ID for the current provider network.
4095
4117
  *
4096
- * @returns the base asset ID
4118
+ * @returns the base asset ID.
4097
4119
  */
4098
4120
  getBaseAssetId() {
4099
4121
  const {
@@ -4108,6 +4130,7 @@ Supported fuel-core version: ${supportedVersion}.`
4108
4130
  * the transaction will be mutated and those dependencies will be added.
4109
4131
  *
4110
4132
  * @param transactionRequestLike - The transaction request object.
4133
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
4111
4134
  * @returns A promise that resolves to the transaction response object.
4112
4135
  */
4113
4136
  // #region Provider-sendTransaction
@@ -4152,7 +4175,7 @@ Supported fuel-core version: ${supportedVersion}.`
4152
4175
  * the transaction will be mutated and those dependencies will be added.
4153
4176
  *
4154
4177
  * @param transactionRequestLike - The transaction request object.
4155
- * @param utxoValidation - Additional provider call parameters.
4178
+ * @param sendTransactionParams - The provider call parameters (optional).
4156
4179
  * @returns A promise that resolves to the call result object.
4157
4180
  */
4158
4181
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
@@ -4172,6 +4195,8 @@ Supported fuel-core version: ${supportedVersion}.`
4172
4195
  /**
4173
4196
  * Verifies whether enough gas is available to complete transaction.
4174
4197
  *
4198
+ * @template T - The type of the transaction request object.
4199
+ *
4175
4200
  * @param transactionRequest - The transaction request object.
4176
4201
  * @returns A promise that resolves to the estimated transaction request object.
4177
4202
  */
@@ -4206,9 +4231,8 @@ Supported fuel-core version: ${supportedVersion}.`
4206
4231
  * If there are missing variable outputs,
4207
4232
  * `addVariableOutputs` is called on the transaction.
4208
4233
  *
4209
- *
4210
4234
  * @param transactionRequest - The transaction request object.
4211
- * @returns A promise.
4235
+ * @returns A promise that resolves to the estimate transaction dependencies.
4212
4236
  */
4213
4237
  async estimateTxDependencies(transactionRequest) {
4214
4238
  if (transactionRequest.type === TransactionType8.Create) {
@@ -4321,6 +4345,14 @@ Supported fuel-core version: ${supportedVersion}.`
4321
4345
  }
4322
4346
  return results;
4323
4347
  }
4348
+ /**
4349
+ * Dry runs multiple transactions.
4350
+ *
4351
+ * @param transactionRequests - Array of transaction request objects.
4352
+ * @param sendTransactionParams - The provider call parameters (optional).
4353
+ *
4354
+ * @returns A promise that resolves to an array of results for each transaction call.
4355
+ */
4324
4356
  async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4325
4357
  if (estimateTxDependencies) {
4326
4358
  return this.estimateMultipleTxDependencies(transactionRequests);
@@ -4391,6 +4423,7 @@ Supported fuel-core version: ${supportedVersion}.`
4391
4423
  * the transaction will be mutated and those dependencies will be added
4392
4424
  *
4393
4425
  * @param transactionRequestLike - The transaction request object.
4426
+ * @param estimateTxParams - The estimate transaction params (optional).
4394
4427
  * @returns A promise that resolves to the call result object.
4395
4428
  */
4396
4429
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -4415,14 +4448,9 @@ Supported fuel-core version: ${supportedVersion}.`
4415
4448
  * to set gasLimit and also reserve balance amounts
4416
4449
  * on the the transaction.
4417
4450
  *
4418
- * @privateRemarks
4419
- * The tolerance is add on top of the gasUsed calculated
4420
- * from the node, this create a safe margin costs like
4421
- * change states on transfer that don't occur on the dryRun
4422
- * transaction. The default value is 0.2 or 20%
4423
- *
4424
4451
  * @param transactionRequestLike - The transaction request object.
4425
- * @param tolerance - The tolerance to add on top of the gasUsed.
4452
+ * @param transactionCostParams - The transaction cost parameters (optional).
4453
+ *
4426
4454
  * @returns A promise that resolves to the transaction cost object.
4427
4455
  */
4428
4456
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
@@ -4490,6 +4518,15 @@ Supported fuel-core version: ${supportedVersion}.`
4490
4518
  updateMaxFee
4491
4519
  };
4492
4520
  }
4521
+ /**
4522
+ * Get the required quantities and associated resources for a transaction.
4523
+ *
4524
+ * @param owner - address to add resources from.
4525
+ * @param transactionRequestLike - transaction request to populate resources for.
4526
+ * @param quantitiesToContract - quantities for the contract (optional).
4527
+ *
4528
+ * @returns a promise resolving to the required quantities for the transaction.
4529
+ */
4493
4530
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4494
4531
  const ownerAddress = Address2.fromAddressOrString(owner);
4495
4532
  const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
@@ -4511,6 +4548,12 @@ Supported fuel-core version: ${supportedVersion}.`
4511
4548
  }
4512
4549
  /**
4513
4550
  * Returns coins for the given owner.
4551
+ *
4552
+ * @param owner - The address to get coins for.
4553
+ * @param assetId - The asset ID of coins to get (optional).
4554
+ * @param paginationArgs - Pagination arguments (optional).
4555
+ *
4556
+ * @returns A promise that resolves to the coins.
4514
4557
  */
4515
4558
  async getCoins(owner, assetId, paginationArgs) {
4516
4559
  const ownerAddress = Address2.fromAddressOrString(owner);
@@ -4533,8 +4576,8 @@ Supported fuel-core version: ${supportedVersion}.`
4533
4576
  * Returns resources for the given owner satisfying the spend query.
4534
4577
  *
4535
4578
  * @param owner - The address to get resources for.
4536
- * @param quantities - The quantities to get.
4537
- * @param excludedIds - IDs of excluded resources from the selection.
4579
+ * @param quantities - The coin quantities to get.
4580
+ * @param excludedIds - IDs of excluded resources from the selection (optional).
4538
4581
  * @returns A promise that resolves to the resources.
4539
4582
  */
4540
4583
  async getResourcesToSpend(owner, quantities, excludedIds) {
@@ -4589,7 +4632,7 @@ Supported fuel-core version: ${supportedVersion}.`
4589
4632
  * Returns block matching the given ID or height.
4590
4633
  *
4591
4634
  * @param idOrHeight - ID or height of the block.
4592
- * @returns A promise that resolves to the block.
4635
+ * @returns A promise that resolves to the block or null.
4593
4636
  */
4594
4637
  async getBlock(idOrHeight) {
4595
4638
  let variables;
@@ -4719,7 +4762,7 @@ Supported fuel-core version: ${supportedVersion}.`
4719
4762
  * Returns balances for the given owner.
4720
4763
  *
4721
4764
  * @param owner - The address to get coins for.
4722
- * @param paginationArgs - Pagination arguments.
4765
+ * @param paginationArgs - Pagination arguments (optional).
4723
4766
  * @returns A promise that resolves to the balances.
4724
4767
  */
4725
4768
  async getBalances(owner, paginationArgs) {
@@ -4738,7 +4781,7 @@ Supported fuel-core version: ${supportedVersion}.`
4738
4781
  * Returns message for the given address.
4739
4782
  *
4740
4783
  * @param address - The address to get message from.
4741
- * @param paginationArgs - Pagination arguments.
4784
+ * @param paginationArgs - Pagination arguments (optional).
4742
4785
  * @returns A promise that resolves to the messages.
4743
4786
  */
4744
4787
  async getMessages(address, paginationArgs) {
@@ -4769,8 +4812,8 @@ Supported fuel-core version: ${supportedVersion}.`
4769
4812
  *
4770
4813
  * @param transactionId - The transaction to get message from.
4771
4814
  * @param messageId - The message id from MessageOut receipt.
4772
- * @param commitBlockId - The commit block id.
4773
- * @param commitBlockHeight - The commit block height.
4815
+ * @param commitBlockId - The commit block id (optional).
4816
+ * @param commitBlockHeight - The commit block height (optional).
4774
4817
  * @returns A promise that resolves to the message proof.
4775
4818
  */
4776
4819
  async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
@@ -4858,10 +4901,21 @@ Supported fuel-core version: ${supportedVersion}.`
4858
4901
  data
4859
4902
  };
4860
4903
  }
4904
+ /**
4905
+ * Get the latest gas price from the node.
4906
+ *
4907
+ * @returns A promise that resolves to the latest gas price.
4908
+ */
4861
4909
  async getLatestGasPrice() {
4862
4910
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4863
4911
  return bn17(latestGasPrice.gasPrice);
4864
4912
  }
4913
+ /**
4914
+ * Returns the estimate gas price for the given block horizon.
4915
+ *
4916
+ * @param blockHorizon - The block horizon to estimate gas price for.
4917
+ * @returns A promise that resolves to the estimated gas price.
4918
+ */
4865
4919
  async estimateGasPrice(blockHorizon) {
4866
4920
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4867
4921
  blockHorizon: String(blockHorizon)
@@ -4881,8 +4935,8 @@ Supported fuel-core version: ${supportedVersion}.`
4881
4935
  /**
4882
4936
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4883
4937
  *
4884
- * @param amount - The amount of blocks to produce
4885
- * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4938
+ * @param amount - The amount of blocks to produce.
4939
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
4886
4940
  * @returns A promise that resolves to the block number of the last produced block.
4887
4941
  */
4888
4942
  async produceBlocks(amount, startTime) {
@@ -4892,6 +4946,12 @@ Supported fuel-core version: ${supportedVersion}.`
4892
4946
  });
4893
4947
  return bn17(latestBlockHeight);
4894
4948
  }
4949
+ /**
4950
+ * Get the transaction response for the given transaction ID.
4951
+ *
4952
+ * @param transactionId - The transaction ID to get the response for.
4953
+ * @returns A promise that resolves to the transaction response.
4954
+ */
4895
4955
  // eslint-disable-next-line @typescript-eslint/require-await
4896
4956
  async getTransactionResponse(transactionId) {
4897
4957
  return new TransactionResponse(transactionId, this);
@@ -4900,7 +4960,7 @@ Supported fuel-core version: ${supportedVersion}.`
4900
4960
  * Returns Message for given nonce.
4901
4961
  *
4902
4962
  * @param nonce - The nonce of the message to retrieve.
4903
- * @returns A promise that resolves to the Message object.
4963
+ * @returns A promise that resolves to the Message object or null.
4904
4964
  */
4905
4965
  async getMessageByNonce(nonce) {
4906
4966
  const { message } = await this.operations.getMessageByNonce({ nonce });
@@ -4909,6 +4969,12 @@ Supported fuel-core version: ${supportedVersion}.`
4909
4969
  }
4910
4970
  return message;
4911
4971
  }
4972
+ /**
4973
+ * Get the relayed transaction for the given transaction ID.
4974
+ *
4975
+ * @param relayedTransactionId - The relayed transaction ID to get the response for.
4976
+ * @returns A promise that resolves to the relayed transaction.
4977
+ */
4912
4978
  async getRelayedTransactionStatus(relayedTransactionId) {
4913
4979
  const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4914
4980
  relayedTransactionId
@@ -4918,6 +4984,9 @@ Supported fuel-core version: ${supportedVersion}.`
4918
4984
  }
4919
4985
  return relayedTransactionStatus;
4920
4986
  }
4987
+ /**
4988
+ * @hidden
4989
+ */
4921
4990
  extractDryRunError(transactionRequest, receipts, dryRunStatus) {
4922
4991
  const status = dryRunStatus;
4923
4992
  let logs = [];
@@ -4947,7 +5016,9 @@ cacheInputs_fn = function(inputs) {
4947
5016
  }
4948
5017
  });
4949
5018
  };
5019
+ /** @hidden */
4950
5020
  __publicField(Provider, "chainInfoCache", {});
5021
+ /** @hidden */
4951
5022
  __publicField(Provider, "nodeInfoCache", {});
4952
5023
 
4953
5024
  // src/providers/transaction-summary/get-transaction-summary.ts
@@ -4983,6 +5054,7 @@ async function getTransactionSummary(params) {
4983
5054
  }
4984
5055
  } = provider.getChain();
4985
5056
  const gasPrice = await provider.getLatestGasPrice();
5057
+ const baseAssetId = provider.getBaseAssetId();
4986
5058
  const transactionInfo = assembleTransactionSummary({
4987
5059
  id: gqlTransaction.id,
4988
5060
  receipts,
@@ -4995,7 +5067,8 @@ async function getTransactionSummary(params) {
4995
5067
  maxInputs,
4996
5068
  gasCosts,
4997
5069
  maxGasPerTx,
4998
- gasPrice
5070
+ gasPrice,
5071
+ baseAssetId
4999
5072
  });
5000
5073
  return {
5001
5074
  gqlTransaction,
@@ -5010,6 +5083,7 @@ async function getTransactionSummaryFromRequest(params) {
5010
5083
  const transaction = transactionRequest.toTransaction();
5011
5084
  const transactionBytes = transactionRequest.toTransactionBytes();
5012
5085
  const gasPrice = await provider.getLatestGasPrice();
5086
+ const baseAssetId = provider.getBaseAssetId();
5013
5087
  const transactionSummary = assembleTransactionSummary({
5014
5088
  receipts,
5015
5089
  transaction,
@@ -5020,7 +5094,8 @@ async function getTransactionSummaryFromRequest(params) {
5020
5094
  maxInputs,
5021
5095
  gasCosts,
5022
5096
  maxGasPerTx,
5023
- gasPrice
5097
+ gasPrice,
5098
+ baseAssetId
5024
5099
  });
5025
5100
  return transactionSummary;
5026
5101
  }
@@ -5036,6 +5111,7 @@ async function getTransactionsSummaries(params) {
5036
5111
  }
5037
5112
  } = provider.getChain();
5038
5113
  const gasPrice = await provider.getLatestGasPrice();
5114
+ const baseAssetId = provider.getBaseAssetId();
5039
5115
  const transactions = edges.map((edge) => {
5040
5116
  const { node: gqlTransaction } = edge;
5041
5117
  const { id, rawPayload, status } = gqlTransaction;
@@ -5057,7 +5133,8 @@ async function getTransactionsSummaries(params) {
5057
5133
  maxInputs,
5058
5134
  gasCosts,
5059
5135
  maxGasPerTx,
5060
- gasPrice
5136
+ gasPrice,
5137
+ baseAssetId
5061
5138
  });
5062
5139
  const output = {
5063
5140
  gqlTransaction,
@@ -5243,12 +5320,16 @@ var Account = class extends AbstractAccount {
5243
5320
  * The provider used to interact with the network.
5244
5321
  */
5245
5322
  _provider;
5323
+ /**
5324
+ * The connector for use with external wallets
5325
+ */
5246
5326
  _connector;
5247
5327
  /**
5248
5328
  * Creates a new Account instance.
5249
5329
  *
5250
5330
  * @param address - The address of the account.
5251
5331
  * @param provider - A Provider instance (optional).
5332
+ * @param connector - A FuelConnector instance (optional).
5252
5333
  */
5253
5334
  constructor(address, provider, connector) {
5254
5335
  super();
@@ -5290,8 +5371,8 @@ var Account = class extends AbstractAccount {
5290
5371
  /**
5291
5372
  * Retrieves resources satisfying the spend query for the account.
5292
5373
  *
5293
- * @param quantities - IDs of coins to exclude.
5294
- * @param excludedIds - IDs of resources to be excluded from the query.
5374
+ * @param quantities - Quantities of resources to be obtained.
5375
+ * @param excludedIds - IDs of resources to be excluded from the query (optional).
5295
5376
  * @returns A promise that resolves to an array of Resources.
5296
5377
  */
5297
5378
  async getResourcesToSpend(quantities, excludedIds) {
@@ -5300,7 +5381,7 @@ var Account = class extends AbstractAccount {
5300
5381
  /**
5301
5382
  * Retrieves coins owned by the account.
5302
5383
  *
5303
- * @param assetId - The asset ID of the coins to retrieve.
5384
+ * @param assetId - The asset ID of the coins to retrieve (optional).
5304
5385
  * @returns A promise that resolves to an array of Coins.
5305
5386
  */
5306
5387
  async getCoins(assetId) {
@@ -5353,7 +5434,7 @@ var Account = class extends AbstractAccount {
5353
5434
  /**
5354
5435
  * Retrieves the balance of the account for the given asset.
5355
5436
  *
5356
- * @param assetId - The asset ID to check the balance for.
5437
+ * @param assetId - The asset ID to check the balance for (optional).
5357
5438
  * @returns A promise that resolves to the balance amount.
5358
5439
  */
5359
5440
  async getBalance(assetId) {
@@ -5393,7 +5474,7 @@ var Account = class extends AbstractAccount {
5393
5474
  * @typeParam T - The type of the TransactionRequest.
5394
5475
  * @param request - The transaction request to fund.
5395
5476
  * @param params - The estimated transaction parameters.
5396
- * @returns The funded transaction request.
5477
+ * @returns A promise that resolves to the funded transaction request.
5397
5478
  */
5398
5479
  async fund(request, params) {
5399
5480
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
@@ -5486,25 +5567,14 @@ var Account = class extends AbstractAccount {
5486
5567
  *
5487
5568
  * @param destination - The address of the destination.
5488
5569
  * @param amount - The amount of coins to transfer.
5489
- * @param assetId - The asset ID of the coins to transfer.
5490
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5570
+ * @param assetId - The asset ID of the coins to transfer (optional).
5571
+ * @param txParams - The transaction parameters (optional).
5491
5572
  * @returns A promise that resolves to the prepared transaction request.
5492
5573
  */
5493
5574
  async createTransfer(destination, amount, assetId, txParams = {}) {
5494
5575
  let request = new ScriptTransactionRequest(txParams);
5495
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5496
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5497
- const txCost = await this.provider.getTransactionCost(request, {
5498
- estimateTxDependencies: true,
5499
- resourcesOwner: this
5500
- });
5501
- request = this.validateGasLimitAndMaxFee({
5502
- transactionRequest: request,
5503
- gasUsed: txCost.gasUsed,
5504
- maxFee: txCost.maxFee,
5505
- txParams
5506
- });
5507
- await this.fund(request, txCost);
5576
+ request = this.addTransfer(request, { destination, amount, assetId });
5577
+ request = await this.estimateAndFundTransaction(request, txParams);
5508
5578
  return request;
5509
5579
  }
5510
5580
  /**
@@ -5512,28 +5582,69 @@ var Account = class extends AbstractAccount {
5512
5582
  *
5513
5583
  * @param destination - The address of the destination.
5514
5584
  * @param amount - The amount of coins to transfer.
5515
- * @param assetId - The asset ID of the coins to transfer.
5516
- * @param txParams - The transaction parameters (gasLimit, maturity).
5585
+ * @param assetId - The asset ID of the coins to transfer (optional).
5586
+ * @param txParams - The transaction parameters (optional).
5517
5587
  * @returns A promise that resolves to the transaction response.
5518
5588
  */
5519
5589
  async transfer(destination, amount, assetId, txParams = {}) {
5520
- if (bn19(amount).lte(0)) {
5521
- throw new FuelError15(
5522
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
5523
- "Transfer amount must be a positive number."
5524
- );
5525
- }
5526
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5527
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5590
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5591
+ return this.sendTransaction(request, { estimateTxDependencies: false });
5592
+ }
5593
+ /**
5594
+ * Transfers multiple amounts of a token to multiple recipients.
5595
+ *
5596
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5597
+ * @param txParams - Optional transaction parameters.
5598
+ * @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
5599
+ */
5600
+ async batchTransfer(transferParams, txParams = {}) {
5601
+ let request = new ScriptTransactionRequest(txParams);
5602
+ request = this.addBatchTransfer(request, transferParams);
5603
+ request = await this.estimateAndFundTransaction(request, txParams);
5528
5604
  return this.sendTransaction(request, { estimateTxDependencies: false });
5529
5605
  }
5606
+ /**
5607
+ * Adds a transfer to the given transaction request.
5608
+ *
5609
+ * @param request - The script transaction request to add transfers to.
5610
+ * @param transferParams - The object representing the transfer to be made.
5611
+ * @returns The updated transaction request with the added transfer.
5612
+ */
5613
+ addTransfer(request, transferParams) {
5614
+ const { destination, amount, assetId } = transferParams;
5615
+ this.validateTransferAmount(amount);
5616
+ request.addCoinOutput(
5617
+ Address3.fromAddressOrString(destination),
5618
+ amount,
5619
+ assetId ?? this.provider.getBaseAssetId()
5620
+ );
5621
+ return request;
5622
+ }
5623
+ /**
5624
+ * Adds multiple transfers to a script transaction request.
5625
+ *
5626
+ * @param request - The script transaction request to add transfers to.
5627
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5628
+ * @returns The updated script transaction request.
5629
+ */
5630
+ addBatchTransfer(request, transferParams) {
5631
+ const baseAssetId = this.provider.getBaseAssetId();
5632
+ transferParams.forEach(({ destination, amount, assetId }) => {
5633
+ this.addTransfer(request, {
5634
+ destination,
5635
+ amount,
5636
+ assetId: assetId ?? baseAssetId
5637
+ });
5638
+ });
5639
+ return request;
5640
+ }
5530
5641
  /**
5531
5642
  * Transfers coins to a contract address.
5532
5643
  *
5533
5644
  * @param contractId - The address of the contract.
5534
5645
  * @param amount - The amount of coins to transfer.
5535
- * @param assetId - The asset ID of the coins to transfer.
5536
- * @param txParams - The optional transaction parameters.
5646
+ * @param assetId - The asset ID of the coins to transfer (optional).
5647
+ * @param txParams - The transaction parameters (optional).
5537
5648
  * @returns A promise that resolves to the transaction response.
5538
5649
  */
5539
5650
  async transferToContract(contractId, amount, assetId, txParams = {}) {
@@ -5574,7 +5685,7 @@ var Account = class extends AbstractAccount {
5574
5685
  *
5575
5686
  * @param recipient - Address of the recipient on the base chain.
5576
5687
  * @param amount - Amount of base asset.
5577
- * @param txParams - The optional transaction parameters.
5688
+ * @param txParams - The transaction parameters (optional).
5578
5689
  * @returns A promise that resolves to the transaction response.
5579
5690
  */
5580
5691
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
@@ -5604,6 +5715,14 @@ var Account = class extends AbstractAccount {
5604
5715
  await this.fund(request, txCost);
5605
5716
  return this.sendTransaction(request);
5606
5717
  }
5718
+ /**
5719
+ * Sign a message from the account via the connector.
5720
+ *
5721
+ * @param message - the message to sign.
5722
+ * @returns a promise that resolves to the signature.
5723
+ *
5724
+ * @hidden
5725
+ */
5607
5726
  async signMessage(message) {
5608
5727
  if (!this._connector) {
5609
5728
  throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
@@ -5611,7 +5730,7 @@ var Account = class extends AbstractAccount {
5611
5730
  return this._connector.signMessage(this.address.toString(), message);
5612
5731
  }
5613
5732
  /**
5614
- * Signs a transaction with the wallet's private key.
5733
+ * Signs a transaction from the account via the connector..
5615
5734
  *
5616
5735
  * @param transactionRequestLike - The transaction request to sign.
5617
5736
  * @returns A promise that resolves to the signature of the transaction.
@@ -5629,6 +5748,7 @@ var Account = class extends AbstractAccount {
5629
5748
  * Sends a transaction to the network.
5630
5749
  *
5631
5750
  * @param transactionRequestLike - The transaction request to be sent.
5751
+ * @param sendTransactionParams - The provider send transaction parameters (optional).
5632
5752
  * @returns A promise that resolves to the transaction response.
5633
5753
  */
5634
5754
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
@@ -5650,6 +5770,7 @@ var Account = class extends AbstractAccount {
5650
5770
  * Simulates a transaction.
5651
5771
  *
5652
5772
  * @param transactionRequestLike - The transaction request to be simulated.
5773
+ * @param estimateTxParams - The estimate transaction params (optional).
5653
5774
  * @returns A promise that resolves to the call result.
5654
5775
  */
5655
5776
  async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
@@ -5659,6 +5780,31 @@ var Account = class extends AbstractAccount {
5659
5780
  }
5660
5781
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5661
5782
  }
5783
+ /** @hidden * */
5784
+ validateTransferAmount(amount) {
5785
+ if (bn19(amount).lte(0)) {
5786
+ throw new FuelError15(
5787
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
5788
+ "Transfer amount must be a positive number."
5789
+ );
5790
+ }
5791
+ }
5792
+ /** @hidden * */
5793
+ async estimateAndFundTransaction(transactionRequest, txParams) {
5794
+ let request = transactionRequest;
5795
+ const txCost = await this.provider.getTransactionCost(request, {
5796
+ resourcesOwner: this
5797
+ });
5798
+ request = this.validateGasLimitAndMaxFee({
5799
+ transactionRequest: request,
5800
+ gasUsed: txCost.gasUsed,
5801
+ maxFee: txCost.maxFee,
5802
+ txParams
5803
+ });
5804
+ request = await this.fund(request, txCost);
5805
+ return request;
5806
+ }
5807
+ /** @hidden * */
5662
5808
  validateGasLimitAndMaxFee({
5663
5809
  gasUsed,
5664
5810
  maxFee,
@@ -5970,6 +6116,8 @@ var BaseWalletUnlocked = class extends Account {
5970
6116
  * Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
5971
6117
  *
5972
6118
  * @param transactionRequestLike - The transaction request to send.
6119
+ * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
6120
+ * @param awaitExecution - Whether to wait for the transaction to be executed.
5973
6121
  * @returns A promise that resolves to the TransactionResponse object.
5974
6122
  */
5975
6123
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
@@ -6001,6 +6149,12 @@ var BaseWalletUnlocked = class extends Account {
6001
6149
  }
6002
6150
  );
6003
6151
  }
6152
+ /**
6153
+ * Encrypts an unlocked wallet with a password.
6154
+ *
6155
+ * @param password - the password to encrypt the wallet with.
6156
+ * @returns - the encrypted wallet.
6157
+ */
6004
6158
  async encrypt(password) {
6005
6159
  return encryptKeystoreWallet(this.privateKey, this.address, password);
6006
6160
  }
@@ -9278,7 +9432,8 @@ var Predicate = class extends Account {
9278
9432
  );
9279
9433
  return resources.map((resource) => ({
9280
9434
  ...resource,
9281
- predicate: hexlify19(this.bytes)
9435
+ predicate: hexlify19(this.bytes),
9436
+ predicateData: hexlify19(this.getPredicateData())
9282
9437
  }));
9283
9438
  }
9284
9439
  /**