@fuel-ts/account 0.0.0-rc-1976-20240411153008 → 0.0.0-rc-2037-20240411163513

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.map +1 -1
  2. package/dist/index.global.js +120 -131
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +197 -204
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +125 -132
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +9 -1
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/coin-quantity.d.ts +2 -2
  11. package/dist/providers/coin-quantity.d.ts.map +1 -1
  12. package/dist/providers/coin.d.ts +2 -1
  13. package/dist/providers/coin.d.ts.map +1 -1
  14. package/dist/providers/message.d.ts +1 -0
  15. package/dist/providers/message.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +13 -9
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  19. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  22. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/transaction-request.d.ts +4 -25
  24. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  25. package/dist/test-utils/launchNode.d.ts.map +1 -1
  26. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  27. package/dist/test-utils.global.js +108 -137
  28. package/dist/test-utils.global.js.map +1 -1
  29. package/dist/test-utils.js +179 -204
  30. package/dist/test-utils.js.map +1 -1
  31. package/dist/test-utils.mjs +112 -137
  32. package/dist/test-utils.mjs.map +1 -1
  33. package/package.json +16 -16
@@ -1 +1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6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
@@ -31272,6 +31272,10 @@ This unreleased fuel-core build may include features and updates not yet support
31272
31272
  }
31273
31273
  };
31274
31274
 
31275
+ // ../address/dist/configs.mjs
31276
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31277
+ var BaseAssetId = ZeroBytes32;
31278
+
31275
31279
  // ../math/dist/index.mjs
31276
31280
  var import_bn = __toESM(require_bn(), 1);
31277
31281
  var DEFAULT_PRECISION = 9;
@@ -31502,11 +31506,11 @@ This unreleased fuel-core build may include features and updates not yet support
31502
31506
  let max2;
31503
31507
  if (Array.isArray(coinQuantityLike)) {
31504
31508
  amount = coinQuantityLike[0];
31505
- assetId = coinQuantityLike[1];
31506
- max2 = coinQuantityLike[2];
31509
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
31510
+ max2 = coinQuantityLike[2] ?? void 0;
31507
31511
  } else {
31508
31512
  amount = coinQuantityLike.amount;
31509
- assetId = coinQuantityLike.assetId;
31513
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
31510
31514
  max2 = coinQuantityLike.max ?? void 0;
31511
31515
  }
31512
31516
  const bnAmount = bn(amount);
@@ -31601,6 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
31601
31605
  var ENCODING_V1 = "1";
31602
31606
  var WORD_SIZE = 8;
31603
31607
  var BYTES_32 = 32;
31608
+ var UTXO_ID_LEN = BYTES_32 + 1;
31604
31609
  var ASSET_ID_LEN = BYTES_32;
31605
31610
  var ADDRESS_LEN = BYTES_32;
31606
31611
  var NONCE_LEN = BYTES_32;
@@ -38860,9 +38865,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38860
38865
  }
38861
38866
  };
38862
38867
 
38863
- // ../address/dist/configs.mjs
38864
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38865
-
38866
38868
  // src/providers/transaction-request/input.ts
38867
38869
  var inputify = (value) => {
38868
38870
  const { type: type3 } = value;
@@ -38872,8 +38874,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38872
38874
  const predicateData = arrayify(value.predicateData ?? "0x");
38873
38875
  return {
38874
38876
  type: InputType.Coin,
38875
- txID: hexlify(arrayify(value.id).slice(0, 32)),
38876
- outputIndex: arrayify(value.id)[32],
38877
+ txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38878
+ outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38877
38879
  owner: hexlify(value.owner),
38878
38880
  amount: bn(value.amount),
38879
38881
  assetId: hexlify(value.assetId),
@@ -39539,8 +39541,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39539
39541
  outputs = [];
39540
39542
  /** List of witnesses */
39541
39543
  witnesses = [];
39542
- /** Base asset ID - should be fetched from the chain */
39543
- baseAssetId;
39544
39544
  /**
39545
39545
  * Constructor for initializing a base transaction request.
39546
39546
  *
@@ -39553,9 +39553,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39553
39553
  witnessLimit,
39554
39554
  inputs,
39555
39555
  outputs,
39556
- witnesses,
39557
- baseAssetId
39558
- }) {
39556
+ witnesses
39557
+ } = {}) {
39559
39558
  this.gasPrice = bn(gasPrice);
39560
39559
  this.maturity = maturity ?? 0;
39561
39560
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
@@ -39563,7 +39562,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39563
39562
  this.inputs = inputs ?? [];
39564
39563
  this.outputs = outputs ?? [];
39565
39564
  this.witnesses = witnesses ?? [];
39566
- this.baseAssetId = baseAssetId;
39567
39565
  }
39568
39566
  static getPolicyMeta(req) {
39569
39567
  let policyTypes = 0;
@@ -39757,8 +39755,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39757
39755
  * @param predicate - Predicate bytes.
39758
39756
  * @param predicateData - Predicate data bytes.
39759
39757
  */
39760
- addCoinInput(coin, predicate) {
39761
- const { assetId, owner, amount } = coin;
39758
+ addCoinInput(coin) {
39759
+ const { assetId, owner, amount, id, predicate } = coin;
39762
39760
  let witnessIndex;
39763
39761
  if (predicate) {
39764
39762
  witnessIndex = 0;
@@ -39769,14 +39767,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39769
39767
  }
39770
39768
  }
39771
39769
  const input = {
39772
- ...coin,
39770
+ id,
39773
39771
  type: InputType.Coin,
39774
39772
  owner: owner.toB256(),
39775
39773
  amount,
39776
39774
  assetId,
39777
39775
  txPointer: "0x00000000000000000000000000000000",
39778
39776
  witnessIndex,
39779
- predicate: predicate?.bytes
39777
+ predicate
39780
39778
  };
39781
39779
  this.pushInput(input);
39782
39780
  this.addChangeOutput(owner, assetId);
@@ -39787,9 +39785,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39787
39785
  *
39788
39786
  * @param message - Message resource.
39789
39787
  * @param predicate - Predicate bytes.
39788
+ * @param predicateData - Predicate data bytes.
39790
39789
  */
39791
- addMessageInput(message, predicate) {
39792
- const { recipient, sender, amount } = message;
39790
+ addMessageInput(message) {
39791
+ const { recipient, sender, amount, predicate, nonce } = message;
39792
+ const assetId = BaseAssetId;
39793
39793
  let witnessIndex;
39794
39794
  if (predicate) {
39795
39795
  witnessIndex = 0;
@@ -39800,16 +39800,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39800
39800
  }
39801
39801
  }
39802
39802
  const input = {
39803
- ...message,
39803
+ nonce,
39804
39804
  type: InputType.Message,
39805
39805
  sender: sender.toB256(),
39806
39806
  recipient: recipient.toB256(),
39807
39807
  amount,
39808
39808
  witnessIndex,
39809
- predicate: predicate?.bytes
39809
+ predicate
39810
39810
  };
39811
39811
  this.pushInput(input);
39812
- this.addChangeOutput(recipient, this.baseAssetId);
39812
+ this.addChangeOutput(recipient, assetId);
39813
39813
  }
39814
39814
  /**
39815
39815
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39837,32 +39837,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39837
39837
  resources.forEach((resource) => this.addResource(resource));
39838
39838
  return this;
39839
39839
  }
39840
- /**
39841
- * Adds multiple resources to the transaction by adding coin/message inputs and change
39842
- * outputs from the related assetIds.
39843
- *
39844
- * @param resources - The resources to add.
39845
- * @returns This transaction.
39846
- */
39847
- addPredicateResource(resource, predicate) {
39848
- if (isCoin(resource)) {
39849
- this.addCoinInput(resource, predicate);
39850
- } else {
39851
- this.addMessageInput(resource, predicate);
39852
- }
39853
- return this;
39854
- }
39855
- /**
39856
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
39857
- * from the related assetIds.
39858
- *
39859
- * @param resources - The resources to add.
39860
- * @returns This transaction.
39861
- */
39862
- addPredicateResources(resources, predicate) {
39863
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39864
- return this;
39865
- }
39866
39840
  /**
39867
39841
  * Adds a coin output to the transaction.
39868
39842
  *
@@ -39870,12 +39844,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39870
39844
  * @param amount - Amount of coin.
39871
39845
  * @param assetId - Asset ID of coin.
39872
39846
  */
39873
- addCoinOutput(to, amount, assetId) {
39847
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39874
39848
  this.pushOutput({
39875
39849
  type: OutputType.Coin,
39876
39850
  to: addressify(to).toB256(),
39877
39851
  amount,
39878
- assetId: assetId ?? this.baseAssetId
39852
+ assetId
39879
39853
  });
39880
39854
  return this;
39881
39855
  }
@@ -39902,7 +39876,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39902
39876
  * @param to - Address of the owner.
39903
39877
  * @param assetId - Asset ID of coin.
39904
39878
  */
39905
- addChangeOutput(to, assetId) {
39879
+ addChangeOutput(to, assetId = BaseAssetId) {
39906
39880
  const changeOutput = this.getChangeOutputs().find(
39907
39881
  (output3) => hexlify(output3.assetId) === assetId
39908
39882
  );
@@ -39910,7 +39884,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39910
39884
  this.pushOutput({
39911
39885
  type: OutputType.Change,
39912
39886
  to: addressify(to).toB256(),
39913
- assetId: assetId ?? this.baseAssetId
39887
+ assetId
39914
39888
  });
39915
39889
  }
39916
39890
  }
@@ -39961,12 +39935,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39961
39935
  * @param quantities - CoinQuantity Array.
39962
39936
  */
39963
39937
  fundWithFakeUtxos(quantities, resourcesOwner) {
39964
- let idCounter = 0;
39965
- const generateId = () => {
39966
- const counterString = String(idCounter++);
39967
- const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
39968
- return id;
39969
- };
39970
39938
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39971
39939
  if ("assetId" in input) {
39972
39940
  return input.assetId === assetId;
@@ -39976,12 +39944,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39976
39944
  const updateAssetInput = (assetId, quantity) => {
39977
39945
  const assetInput = findAssetInput(assetId);
39978
39946
  if (assetInput && "assetId" in assetInput) {
39979
- assetInput.id = generateId();
39947
+ assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39980
39948
  assetInput.amount = quantity;
39981
39949
  } else {
39982
39950
  this.addResources([
39983
39951
  {
39984
- id: generateId(),
39952
+ id: hexlify(randomBytes22(UTXO_ID_LEN)),
39985
39953
  amount: quantity,
39986
39954
  assetId,
39987
39955
  owner: resourcesOwner || Address.fromRandom(),
@@ -39992,7 +39960,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39992
39960
  ]);
39993
39961
  }
39994
39962
  };
39995
- updateAssetInput(this.baseAssetId, bn(1e11));
39963
+ updateAssetInput(BaseAssetId, bn(1e11));
39996
39964
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39997
39965
  }
39998
39966
  /**
@@ -40149,7 +40117,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40149
40117
  *
40150
40118
  * @param createTransactionRequestLike - The initial values for the instance
40151
40119
  */
40152
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40120
+ constructor({
40121
+ bytecodeWitnessIndex,
40122
+ salt,
40123
+ storageSlots,
40124
+ ...rest
40125
+ } = {}) {
40153
40126
  super(rest);
40154
40127
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40155
40128
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40264,7 +40237,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40264
40237
  *
40265
40238
  * @param scriptTransactionRequestLike - The initial values for the instance.
40266
40239
  */
40267
- constructor({ script, scriptData, gasLimit, ...rest }) {
40240
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40268
40241
  super(rest);
40269
40242
  this.gasLimit = bn(gasLimit);
40270
40243
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -41410,7 +41383,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41410
41383
  gasPerByte: bn(feeParams.gasPerByte),
41411
41384
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41412
41385
  chainId: bn(consensusParameters.chainId),
41413
- baseAssetId: consensusParameters.baseAssetId,
41414
41386
  gasCosts
41415
41387
  },
41416
41388
  gasCosts,
@@ -41653,17 +41625,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41653
41625
  } = this.getChain();
41654
41626
  return chainId.toNumber();
41655
41627
  }
41656
- /**
41657
- * Returns the base asset ID
41658
- *
41659
- * @returns A promise that resolves to the base asset ID
41660
- */
41661
- getBaseAssetId() {
41662
- const {
41663
- consensusParameters: { baseAssetId }
41664
- } = this.getChain();
41665
- return baseAssetId;
41666
- }
41667
41628
  /**
41668
41629
  * Submits a transaction to the chain to be executed.
41669
41630
  *
@@ -41814,6 +41775,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41814
41775
  missingContractIds
41815
41776
  };
41816
41777
  }
41778
+ /**
41779
+ * Estimates the transaction gas and fee based on the provided transaction request.
41780
+ * @param transactionRequest - The transaction request object.
41781
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41782
+ */
41783
+ estimateTxGasAndFee(params) {
41784
+ const { transactionRequest } = params;
41785
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41786
+ const chainInfo = this.getChain();
41787
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41788
+ transactionRequest.gasPrice = gasPrice;
41789
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
41790
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41791
+ if (transactionRequest.type === TransactionType.Script) {
41792
+ if (transactionRequest.gasLimit.eq(0)) {
41793
+ transactionRequest.gasLimit = minGas;
41794
+ transactionRequest.gasLimit = maxGasPerTx.sub(
41795
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
41796
+ );
41797
+ }
41798
+ }
41799
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41800
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41801
+ return {
41802
+ minGas,
41803
+ minFee,
41804
+ maxGas,
41805
+ maxFee
41806
+ };
41807
+ }
41817
41808
  /**
41818
41809
  * Executes a signed transaction without applying the states changes
41819
41810
  * on the chain.
@@ -41861,17 +41852,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41861
41852
  signatureCallback
41862
41853
  } = {}) {
41863
41854
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41864
- const chainInfo = this.getChain();
41865
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41866
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41855
+ const { minGasPrice } = this.getGasConfig();
41856
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41867
41857
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41868
41858
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41869
41859
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41870
41860
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41861
+ if (isScriptTransaction) {
41862
+ txRequestClone.gasLimit = bn(0);
41863
+ }
41871
41864
  if (estimatePredicates) {
41872
- if (isScriptTransaction) {
41873
- txRequestClone.gasLimit = bn(0);
41874
- }
41875
41865
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41876
41866
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41877
41867
  }
@@ -41880,36 +41870,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41880
41870
  if (signatureCallback && isScriptTransaction) {
41881
41871
  await signatureCallback(txRequestClone);
41882
41872
  }
41883
- const minGas = txRequestClone.calculateMinGas(chainInfo);
41884
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41873
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41874
+ transactionRequest: txRequestClone
41875
+ });
41885
41876
  let receipts = [];
41886
41877
  let missingContractIds = [];
41887
41878
  let outputVariables = 0;
41879
+ let gasUsed = bn(0);
41888
41880
  if (isScriptTransaction && estimateTxDependencies) {
41889
41881
  txRequestClone.gasPrice = bn(0);
41890
- txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41891
41882
  const result = await this.estimateTxDependencies(txRequestClone);
41892
41883
  receipts = result.receipts;
41893
41884
  outputVariables = result.outputVariables;
41894
41885
  missingContractIds = result.missingContractIds;
41886
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41887
+ txRequestClone.gasLimit = gasUsed;
41888
+ txRequestClone.gasPrice = setGasPrice;
41889
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41890
+ transactionRequest: txRequestClone
41891
+ }));
41895
41892
  }
41896
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41897
- const usedFee = calculatePriceWithFactor(
41898
- gasUsed,
41899
- gasPrice,
41900
- gasPriceFactor
41901
- ).normalizeZeroToOne();
41902
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41903
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41904
41893
  return {
41905
41894
  requiredQuantities: allQuantities,
41906
41895
  receipts,
41907
41896
  gasUsed,
41908
41897
  minGasPrice,
41909
- gasPrice,
41898
+ gasPrice: setGasPrice,
41910
41899
  minGas,
41911
41900
  maxGas,
41912
- usedFee,
41913
41901
  minFee,
41914
41902
  maxFee,
41915
41903
  estimatedInputs: txRequestClone.inputs,
@@ -42693,9 +42681,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42693
42681
  * @param assetId - The asset ID to check the balance for.
42694
42682
  * @returns A promise that resolves to the balance amount.
42695
42683
  */
42696
- async getBalance(assetId) {
42697
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42698
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42684
+ async getBalance(assetId = BaseAssetId) {
42685
+ const amount = await this.provider.getBalance(this.address, assetId);
42699
42686
  return amount;
42700
42687
  }
42701
42688
  /**
@@ -42733,10 +42720,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42733
42720
  * @returns A promise that resolves when the resources are added to the transaction.
42734
42721
  */
42735
42722
  async fund(request, coinQuantities, fee) {
42736
- const baseAssetId = this.provider.getBaseAssetId();
42737
42723
  const updatedQuantities = addAmountToAsset({
42738
42724
  amount: bn(fee),
42739
- assetId: baseAssetId,
42725
+ assetId: BaseAssetId,
42740
42726
  coinQuantities
42741
42727
  });
42742
42728
  const quantitiesDict = {};
@@ -42760,8 +42746,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42760
42746
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42761
42747
  cachedUtxos.push(input.id);
42762
42748
  }
42763
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42764
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42749
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42750
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42765
42751
  cachedMessages.push(input.nonce);
42766
42752
  }
42767
42753
  }
@@ -42793,13 +42779,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42793
42779
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42794
42780
  * @returns A promise that resolves to the prepared transaction request.
42795
42781
  */
42796
- async createTransfer(destination, amount, assetId, txParams = {}) {
42782
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42797
42783
  const { minGasPrice } = this.provider.getGasConfig();
42798
- const baseAssetId = this.provider.getBaseAssetId();
42799
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42800
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42784
+ const params = { gasPrice: minGasPrice, ...txParams };
42801
42785
  const request = new ScriptTransactionRequest(params);
42802
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42786
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42803
42787
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42804
42788
  estimateTxDependencies: true,
42805
42789
  resourcesOwner: this
@@ -42825,15 +42809,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42825
42809
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42826
42810
  * @returns A promise that resolves to the transaction response.
42827
42811
  */
42828
- async transfer(destination, amount, assetId, txParams = {}) {
42812
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42829
42813
  if (bn(amount).lte(0)) {
42830
42814
  throw new FuelError(
42831
42815
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42832
42816
  "Transfer amount must be a positive number."
42833
42817
  );
42834
42818
  }
42835
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42836
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42819
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42837
42820
  return this.sendTransaction(request, { estimateTxDependencies: false });
42838
42821
  }
42839
42822
  /**
@@ -42845,7 +42828,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42845
42828
  * @param txParams - The optional transaction parameters.
42846
42829
  * @returns A promise that resolves to the transaction response.
42847
42830
  */
42848
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42831
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42849
42832
  if (bn(amount).lte(0)) {
42850
42833
  throw new FuelError(
42851
42834
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42854,13 +42837,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42854
42837
  }
42855
42838
  const contractAddress = Address.fromAddressOrString(contractId);
42856
42839
  const { minGasPrice } = this.provider.getGasConfig();
42857
- const baseAssetId = this.provider.getBaseAssetId();
42858
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42859
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42840
+ const params = { gasPrice: minGasPrice, ...txParams };
42860
42841
  const { script, scriptData } = await assembleTransferToContractScript({
42861
42842
  hexlifiedContractId: contractAddress.toB256(),
42862
42843
  amountToTransfer: bn(amount),
42863
- assetId: assetIdToTransfer
42844
+ assetId
42864
42845
  });
42865
42846
  const request = new ScriptTransactionRequest({
42866
42847
  ...params,
@@ -42870,7 +42851,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42870
42851
  request.addContractInputAndOutput(contractAddress);
42871
42852
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42872
42853
  request,
42873
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42854
+ [{ amount: bn(amount), assetId: String(assetId) }]
42874
42855
  );
42875
42856
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42876
42857
  this.validateGas({
@@ -42892,7 +42873,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42892
42873
  */
42893
42874
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42894
42875
  const { minGasPrice } = this.provider.getGasConfig();
42895
- const baseAssetId = this.provider.getBaseAssetId();
42896
42876
  const recipientAddress = Address.fromAddressOrString(recipient);
42897
42877
  const recipientDataArray = arrayify(
42898
42878
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42905,14 +42885,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42905
42885
  ...recipientDataArray,
42906
42886
  ...amountDataArray
42907
42887
  ]);
42908
- const params = {
42909
- script,
42910
- gasPrice: minGasPrice,
42911
- baseAssetId,
42912
- ...txParams
42913
- };
42888
+ const params = { script, gasPrice: minGasPrice, ...txParams };
42914
42889
  const request = new ScriptTransactionRequest(params);
42915
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42890
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42916
42891
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42917
42892
  request,
42918
42893
  forwardingQuantities
@@ -44376,12 +44351,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44376
44351
  };
44377
44352
 
44378
44353
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44379
- var import_crypto15 = __toESM(__require("crypto"));
44354
+ var import_crypto16 = __toESM(__require("crypto"));
44380
44355
  var rnds8Pool = new Uint8Array(256);
44381
44356
  var poolPtr = rnds8Pool.length;
44382
44357
  function rng() {
44383
44358
  if (poolPtr > rnds8Pool.length - 16) {
44384
- import_crypto15.default.randomFillSync(rnds8Pool);
44359
+ import_crypto16.default.randomFillSync(rnds8Pool);
44385
44360
  poolPtr = 0;
44386
44361
  }
44387
44362
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44397,9 +44372,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44397
44372
  }
44398
44373
 
44399
44374
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44400
- var import_crypto16 = __toESM(__require("crypto"));
44375
+ var import_crypto17 = __toESM(__require("crypto"));
44401
44376
  var native_default = {
44402
- randomUUID: import_crypto16.default.randomUUID
44377
+ randomUUID: import_crypto17.default.randomUUID
44403
44378
  };
44404
44379
 
44405
44380
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47862,6 +47837,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47862
47837
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47863
47838
  input.predicate = this.bytes;
47864
47839
  input.predicateData = this.getPredicateData(policies.length);
47840
+ input.witnessIndex = 0;
47865
47841
  }
47866
47842
  });
47867
47843
  return request;
@@ -47875,9 +47851,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47875
47851
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47876
47852
  * @returns A promise that resolves to the prepared transaction request.
47877
47853
  */
47878
- async createTransfer(destination, amount, assetId, txParams = {}) {
47879
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47880
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47854
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47855
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47881
47856
  return this.populateTransactionPredicateData(request);
47882
47857
  }
47883
47858
  /**
@@ -47900,6 +47875,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47900
47875
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47901
47876
  return super.simulateTransaction(transactionRequest);
47902
47877
  }
47878
+ /**
47879
+ * Retrieves resources satisfying the spend query for the account.
47880
+ *
47881
+ * @param quantities - IDs of coins to exclude.
47882
+ * @param excludedIds - IDs of resources to be excluded from the query.
47883
+ * @returns A promise that resolves to an array of Resources.
47884
+ */
47885
+ async getResourcesToSpend(quantities, excludedIds) {
47886
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
47887
+ return resources.map((resource) => ({
47888
+ ...resource,
47889
+ predicate: hexlify(this.bytes)
47890
+ }));
47891
+ }
47903
47892
  getPredicateData(policiesLength) {
47904
47893
  if (!this.predicateData.length) {
47905
47894
  return new Uint8Array();