@fuel-ts/account 0.0.0-rc-2045-20240415152456 → 0.0.0-rc-2040-20240415161332

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.

@@ -28952,7 +28952,7 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.53.0",
28955
+ FORC: "0.49.3",
28956
28956
  FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.79.0"
28958
28958
  };
@@ -31144,7 +31144,7 @@ This unreleased fuel-core build may include features and updates not yet support
31144
31144
  toEvmAddress() {
31145
31145
  const b256Address = toB256(this.bech32Address);
31146
31146
  return {
31147
- bits: clearFirst12BytesFromB256(b256Address)
31147
+ value: clearFirst12BytesFromB256(b256Address)
31148
31148
  };
31149
31149
  }
31150
31150
  /**
@@ -31154,7 +31154,7 @@ This unreleased fuel-core build may include features and updates not yet support
31154
31154
  */
31155
31155
  toAssetId() {
31156
31156
  return {
31157
- bits: this.toB256()
31157
+ value: this.toB256()
31158
31158
  };
31159
31159
  }
31160
31160
  /**
@@ -31605,7 +31605,6 @@ This unreleased fuel-core build may include features and updates not yet support
31605
31605
  var ENCODING_V1 = "1";
31606
31606
  var WORD_SIZE = 8;
31607
31607
  var BYTES_32 = 32;
31608
- var UTXO_ID_LEN = BYTES_32 + 1;
31609
31608
  var ASSET_ID_LEN = BYTES_32;
31610
31609
  var ADDRESS_LEN = BYTES_32;
31611
31610
  var NONCE_LEN = BYTES_32;
@@ -38874,8 +38873,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38874
38873
  const predicateData = arrayify(value.predicateData ?? "0x");
38875
38874
  return {
38876
38875
  type: InputType.Coin,
38877
- txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38878
- outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38876
+ txID: hexlify(arrayify(value.id).slice(0, 32)),
38877
+ outputIndex: arrayify(value.id)[32],
38879
38878
  owner: hexlify(value.owner),
38880
38879
  amount: bn(value.amount),
38881
38880
  assetId: hexlify(value.assetId),
@@ -39961,6 +39960,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39961
39960
  * @param quantities - CoinQuantity Array.
39962
39961
  */
39963
39962
  fundWithFakeUtxos(quantities, resourcesOwner) {
39963
+ let idCounter = 0;
39964
+ const generateId = () => {
39965
+ const counterString = String(idCounter++);
39966
+ const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
39967
+ return id;
39968
+ };
39964
39969
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39965
39970
  if ("assetId" in input) {
39966
39971
  return input.assetId === assetId;
@@ -39970,12 +39975,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39970
39975
  const updateAssetInput = (assetId, quantity) => {
39971
39976
  const assetInput = findAssetInput(assetId);
39972
39977
  if (assetInput && "assetId" in assetInput) {
39973
- assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39978
+ assetInput.id = generateId();
39974
39979
  assetInput.amount = quantity;
39975
39980
  } else {
39976
39981
  this.addResources([
39977
39982
  {
39978
- id: hexlify(randomBytes22(UTXO_ID_LEN)),
39983
+ id: generateId(),
39979
39984
  amount: quantity,
39980
39985
  assetId,
39981
39986
  owner: resourcesOwner || Address.fromRandom(),
@@ -41801,36 +41806,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41801
41806
  missingContractIds
41802
41807
  };
41803
41808
  }
41804
- /**
41805
- * Estimates the transaction gas and fee based on the provided transaction request.
41806
- * @param transactionRequest - The transaction request object.
41807
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41808
- */
41809
- estimateTxGasAndFee(params) {
41810
- const { transactionRequest } = params;
41811
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41812
- const chainInfo = this.getChain();
41813
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41814
- transactionRequest.gasPrice = gasPrice;
41815
- const minGas = transactionRequest.calculateMinGas(chainInfo);
41816
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41817
- if (transactionRequest.type === TransactionType.Script) {
41818
- if (transactionRequest.gasLimit.eq(0)) {
41819
- transactionRequest.gasLimit = minGas;
41820
- transactionRequest.gasLimit = maxGasPerTx.sub(
41821
- transactionRequest.calculateMaxGas(chainInfo, minGas)
41822
- );
41823
- }
41824
- }
41825
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41826
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41827
- return {
41828
- minGas,
41829
- minFee,
41830
- maxGas,
41831
- maxFee
41832
- };
41833
- }
41834
41809
  /**
41835
41810
  * Executes a signed transaction without applying the states changes
41836
41811
  * on the chain.
@@ -41878,16 +41853,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41878
41853
  signatureCallback
41879
41854
  } = {}) {
41880
41855
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41881
- const { minGasPrice } = this.getGasConfig();
41882
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41856
+ const chainInfo = this.getChain();
41857
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41858
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41883
41859
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41884
41860
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41885
41861
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41886
41862
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41887
- if (isScriptTransaction) {
41888
- txRequestClone.gasLimit = bn(0);
41889
- }
41890
41863
  if (estimatePredicates) {
41864
+ if (isScriptTransaction) {
41865
+ txRequestClone.gasLimit = bn(0);
41866
+ }
41891
41867
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41892
41868
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41893
41869
  }
@@ -41896,34 +41872,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41896
41872
  if (signatureCallback && isScriptTransaction) {
41897
41873
  await signatureCallback(txRequestClone);
41898
41874
  }
41899
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41900
- transactionRequest: txRequestClone
41901
- });
41875
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
41876
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41902
41877
  let receipts = [];
41903
41878
  let missingContractIds = [];
41904
41879
  let outputVariables = 0;
41905
- let gasUsed = bn(0);
41906
41880
  if (isScriptTransaction && estimateTxDependencies) {
41907
41881
  txRequestClone.gasPrice = bn(0);
41882
+ txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41908
41883
  const result = await this.estimateTxDependencies(txRequestClone);
41909
41884
  receipts = result.receipts;
41910
41885
  outputVariables = result.outputVariables;
41911
41886
  missingContractIds = result.missingContractIds;
41912
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41913
- txRequestClone.gasLimit = gasUsed;
41914
- txRequestClone.gasPrice = setGasPrice;
41915
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41916
- transactionRequest: txRequestClone
41917
- }));
41918
41887
  }
41888
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41889
+ const usedFee = calculatePriceWithFactor(
41890
+ gasUsed,
41891
+ gasPrice,
41892
+ gasPriceFactor
41893
+ ).normalizeZeroToOne();
41894
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41895
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41919
41896
  return {
41920
41897
  requiredQuantities: allQuantities,
41921
41898
  receipts,
41922
41899
  gasUsed,
41923
41900
  minGasPrice,
41924
- gasPrice: setGasPrice,
41901
+ gasPrice,
41925
41902
  minGas,
41926
41903
  maxGas,
41904
+ usedFee,
41927
41905
  minFee,
41928
41906
  maxFee,
41929
41907
  estimatedInputs: txRequestClone.inputs,
@@ -44377,12 +44355,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44377
44355
  };
44378
44356
 
44379
44357
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44380
- var import_crypto16 = __toESM(__require("crypto"));
44358
+ var import_crypto15 = __toESM(__require("crypto"));
44381
44359
  var rnds8Pool = new Uint8Array(256);
44382
44360
  var poolPtr = rnds8Pool.length;
44383
44361
  function rng() {
44384
44362
  if (poolPtr > rnds8Pool.length - 16) {
44385
- import_crypto16.default.randomFillSync(rnds8Pool);
44363
+ import_crypto15.default.randomFillSync(rnds8Pool);
44386
44364
  poolPtr = 0;
44387
44365
  }
44388
44366
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44398,9 +44376,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44398
44376
  }
44399
44377
 
44400
44378
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44401
- var import_crypto17 = __toESM(__require("crypto"));
44379
+ var import_crypto16 = __toESM(__require("crypto"));
44402
44380
  var native_default = {
44403
- randomUUID: import_crypto17.default.randomUUID
44381
+ randomUUID: import_crypto16.default.randomUUID
44404
44382
  };
44405
44383
 
44406
44384
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js