@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410132048

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.

@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CACjE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;IAE/B,SAAS,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAErC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,aAAa;IAO7F;;;;;;OAMG;IACH,IAAI,QAAQ,IAAI,QAA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GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,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"}
@@ -29245,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
29245
29245
  __publicField3(DateTime, "TAI64_NULL", "");
29246
29246
 
29247
29247
  // ../crypto/dist/index.mjs
29248
- var import_crypto8 = __toESM(__require("crypto"), 1);
29248
+ var import_crypto9 = __toESM(__require("crypto"), 1);
29249
29249
 
29250
29250
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
29251
29251
  var version = "6.7.1";
@@ -30317,6 +30317,27 @@ This unreleased fuel-core build may include features and updates not yet support
30317
30317
  };
30318
30318
  Object.freeze(pbkdf22);
30319
30319
 
30320
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
30321
+ var locked5 = false;
30322
+ var _randomBytes = function(length) {
30323
+ return new Uint8Array((0, import_crypto2.randomBytes)(length));
30324
+ };
30325
+ var __randomBytes = _randomBytes;
30326
+ function randomBytes3(length) {
30327
+ return __randomBytes(length);
30328
+ }
30329
+ randomBytes3._ = _randomBytes;
30330
+ randomBytes3.lock = function() {
30331
+ locked5 = true;
30332
+ };
30333
+ randomBytes3.register = function(func) {
30334
+ if (locked5) {
30335
+ throw new Error("randomBytes is locked");
30336
+ }
30337
+ __randomBytes = func;
30338
+ };
30339
+ Object.freeze(randomBytes3);
30340
+
30320
30341
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
30321
30342
  var BN_03 = BigInt(0);
30322
30343
  var BN_36 = BigInt(36);
@@ -30901,8 +30922,8 @@ This unreleased fuel-core build may include features and updates not yet support
30901
30922
  }
30902
30923
 
30903
30924
  // ../crypto/dist/index.mjs
30904
- var import_crypto9 = __toESM(__require("crypto"), 1);
30905
30925
  var import_crypto10 = __toESM(__require("crypto"), 1);
30926
+ var import_crypto11 = __toESM(__require("crypto"), 1);
30906
30927
  var scrypt3 = (params) => {
30907
30928
  const { password, salt, n, p, r, dklen } = params;
30908
30929
  const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
@@ -30911,7 +30932,7 @@ This unreleased fuel-core build may include features and updates not yet support
30911
30932
  var keccak2562 = (data) => keccak_256(data);
30912
30933
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
30913
30934
  var randomBytes4 = (length) => {
30914
- const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
30935
+ const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
30915
30936
  return randomValues;
30916
30937
  };
30917
30938
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -30926,7 +30947,7 @@ This unreleased fuel-core build may include features and updates not yet support
30926
30947
  const salt = randomBytes4(32);
30927
30948
  const secret = keyFromPassword(password, salt);
30928
30949
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
30929
- const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
30950
+ const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
30930
30951
  let cipherData = cipher.update(dataBuffer);
30931
30952
  cipherData = Buffer.concat([cipherData, cipher.final()]);
30932
30953
  return {
@@ -30940,7 +30961,7 @@ This unreleased fuel-core build may include features and updates not yet support
30940
30961
  const salt = bufferFromString(keystore.salt);
30941
30962
  const secret = keyFromPassword(password, salt);
30942
30963
  const encryptedText = bufferFromString(keystore.data);
30943
- const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
30964
+ const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
30944
30965
  const decrypted = decipher.update(encryptedText);
30945
30966
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
30946
30967
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -30951,12 +30972,12 @@ This unreleased fuel-core build may include features and updates not yet support
30951
30972
  }
30952
30973
  };
30953
30974
  async function encryptJsonWalletData(data, key, iv) {
30954
- const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30975
+ const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30955
30976
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
30956
30977
  return new Uint8Array(encrypted);
30957
30978
  }
30958
30979
  async function decryptJsonWalletData(data, key, iv) {
30959
- const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30980
+ const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30960
30981
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
30961
30982
  return new Uint8Array(decrypted);
30962
30983
  }
@@ -31272,6 +31293,10 @@ This unreleased fuel-core build may include features and updates not yet support
31272
31293
  }
31273
31294
  };
31274
31295
 
31296
+ // ../address/dist/configs.mjs
31297
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31298
+ var BaseAssetId = ZeroBytes32;
31299
+
31275
31300
  // ../math/dist/index.mjs
31276
31301
  var import_bn = __toESM(require_bn(), 1);
31277
31302
  var DEFAULT_PRECISION = 9;
@@ -31502,11 +31527,11 @@ This unreleased fuel-core build may include features and updates not yet support
31502
31527
  let max2;
31503
31528
  if (Array.isArray(coinQuantityLike)) {
31504
31529
  amount = coinQuantityLike[0];
31505
- assetId = coinQuantityLike[1];
31506
- max2 = coinQuantityLike[2];
31530
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
31531
+ max2 = coinQuantityLike[2] ?? void 0;
31507
31532
  } else {
31508
31533
  amount = coinQuantityLike.amount;
31509
- assetId = coinQuantityLike.assetId;
31534
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
31510
31535
  max2 = coinQuantityLike.max ?? void 0;
31511
31536
  }
31512
31537
  const bnAmount = bn(amount);
@@ -31760,6 +31785,7 @@ This unreleased fuel-core build may include features and updates not yet support
31760
31785
  const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
31761
31786
  return concatBytes2([encoded, padding]);
31762
31787
  };
31788
+ var isUint8Array = (value) => value instanceof Uint8Array;
31763
31789
  var ArrayCoder = class extends Coder {
31764
31790
  coder;
31765
31791
  length;
@@ -32301,8 +32327,11 @@ This unreleased fuel-core build may include features and updates not yet support
32301
32327
  this.coder = coder;
32302
32328
  }
32303
32329
  encode(value) {
32304
- if (!Array.isArray(value)) {
32305
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32330
+ if (!Array.isArray(value) && !isUint8Array(value)) {
32331
+ throw new FuelError(
32332
+ ErrorCode.ENCODE_ERROR,
32333
+ `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
32334
+ );
32306
32335
  }
32307
32336
  const parts = [];
32308
32337
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
@@ -38846,9 +38875,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38846
38875
  }
38847
38876
  };
38848
38877
 
38849
- // ../address/dist/configs.mjs
38850
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38851
-
38852
38878
  // src/providers/transaction-request/input.ts
38853
38879
  var inputify = (value) => {
38854
38880
  const { type: type3 } = value;
@@ -38859,7 +38885,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38859
38885
  return {
38860
38886
  type: InputType.Coin,
38861
38887
  txID: hexlify(arrayify(value.id).slice(0, 32)),
38862
- outputIndex: arrayify(value.id)[32],
38888
+ outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
38863
38889
  owner: hexlify(value.owner),
38864
38890
  amount: bn(value.amount),
38865
38891
  assetId: hexlify(value.assetId),
@@ -39525,8 +39551,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39525
39551
  outputs = [];
39526
39552
  /** List of witnesses */
39527
39553
  witnesses = [];
39528
- /** Base asset ID - should be fetched from the chain */
39529
- baseAssetId = ZeroBytes32;
39530
39554
  /**
39531
39555
  * Constructor for initializing a base transaction request.
39532
39556
  *
@@ -39539,8 +39563,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39539
39563
  witnessLimit,
39540
39564
  inputs,
39541
39565
  outputs,
39542
- witnesses,
39543
- baseAssetId
39566
+ witnesses
39544
39567
  } = {}) {
39545
39568
  this.gasPrice = bn(gasPrice);
39546
39569
  this.maturity = maturity ?? 0;
@@ -39549,7 +39572,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39549
39572
  this.inputs = inputs ?? [];
39550
39573
  this.outputs = outputs ?? [];
39551
39574
  this.witnesses = witnesses ?? [];
39552
- this.baseAssetId = baseAssetId ?? ZeroBytes32;
39553
39575
  }
39554
39576
  static getPolicyMeta(req) {
39555
39577
  let policyTypes = 0;
@@ -39774,9 +39796,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39774
39796
  *
39775
39797
  * @param message - Message resource.
39776
39798
  * @param predicate - Predicate bytes.
39799
+ * @param predicateData - Predicate data bytes.
39777
39800
  */
39778
39801
  addMessageInput(message, predicate) {
39779
39802
  const { recipient, sender, amount } = message;
39803
+ const assetId = BaseAssetId;
39780
39804
  let witnessIndex;
39781
39805
  if (predicate) {
39782
39806
  witnessIndex = 0;
@@ -39797,7 +39821,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39797
39821
  predicateData: predicate?.predicateDataBytes
39798
39822
  };
39799
39823
  this.pushInput(input);
39800
- this.addChangeOutput(recipient, this.baseAssetId);
39824
+ this.addChangeOutput(recipient, assetId);
39801
39825
  }
39802
39826
  /**
39803
39827
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39858,12 +39882,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39858
39882
  * @param amount - Amount of coin.
39859
39883
  * @param assetId - Asset ID of coin.
39860
39884
  */
39861
- addCoinOutput(to, amount, assetId) {
39885
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39862
39886
  this.pushOutput({
39863
39887
  type: OutputType.Coin,
39864
39888
  to: addressify(to).toB256(),
39865
39889
  amount,
39866
- assetId: assetId ?? this.baseAssetId
39890
+ assetId
39867
39891
  });
39868
39892
  return this;
39869
39893
  }
@@ -39890,7 +39914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39890
39914
  * @param to - Address of the owner.
39891
39915
  * @param assetId - Asset ID of coin.
39892
39916
  */
39893
- addChangeOutput(to, assetId) {
39917
+ addChangeOutput(to, assetId = BaseAssetId) {
39894
39918
  const changeOutput = this.getChangeOutputs().find(
39895
39919
  (output3) => hexlify(output3.assetId) === assetId
39896
39920
  );
@@ -39898,7 +39922,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39898
39922
  this.pushOutput({
39899
39923
  type: OutputType.Change,
39900
39924
  to: addressify(to).toB256(),
39901
- assetId: assetId ?? this.baseAssetId
39925
+ assetId
39902
39926
  });
39903
39927
  }
39904
39928
  }
@@ -39949,12 +39973,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39949
39973
  * @param quantities - CoinQuantity Array.
39950
39974
  */
39951
39975
  fundWithFakeUtxos(quantities, resourcesOwner) {
39952
- let idCounter = 0;
39953
- const generateId = () => {
39954
- const counterString = String(idCounter++);
39955
- const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
39956
- return id;
39957
- };
39958
39976
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39959
39977
  if ("assetId" in input) {
39960
39978
  return input.assetId === assetId;
@@ -39964,12 +39982,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39964
39982
  const updateAssetInput = (assetId, quantity) => {
39965
39983
  const assetInput = findAssetInput(assetId);
39966
39984
  if (assetInput && "assetId" in assetInput) {
39967
- assetInput.id = generateId();
39985
+ assetInput.id = hexlify(randomBytes3(33));
39968
39986
  assetInput.amount = quantity;
39969
39987
  } else {
39970
39988
  this.addResources([
39971
39989
  {
39972
- id: generateId(),
39990
+ id: hexlify(randomBytes3(33)),
39973
39991
  amount: quantity,
39974
39992
  assetId,
39975
39993
  owner: resourcesOwner || Address.fromRandom(),
@@ -39980,7 +39998,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39980
39998
  ]);
39981
39999
  }
39982
40000
  };
39983
- updateAssetInput(this.baseAssetId, bn(1e11));
40001
+ updateAssetInput(BaseAssetId, bn(1e11));
39984
40002
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39985
40003
  }
39986
40004
  /**
@@ -41403,7 +41421,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41403
41421
  gasPerByte: bn(feeParams.gasPerByte),
41404
41422
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41405
41423
  chainId: bn(consensusParameters.chainId),
41406
- baseAssetId: consensusParameters.baseAssetId,
41407
41424
  gasCosts
41408
41425
  },
41409
41426
  gasCosts,
@@ -41646,17 +41663,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41646
41663
  } = this.getChain();
41647
41664
  return chainId.toNumber();
41648
41665
  }
41649
- /**
41650
- * Returns the base asset ID
41651
- *
41652
- * @returns A promise that resolves to the base asset ID
41653
- */
41654
- getBaseAssetId() {
41655
- const {
41656
- consensusParameters: { baseAssetId }
41657
- } = this.getChain();
41658
- return baseAssetId;
41659
- }
41660
41666
  /**
41661
41667
  * Submits a transaction to the chain to be executed.
41662
41668
  *
@@ -41807,6 +41813,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41807
41813
  missingContractIds
41808
41814
  };
41809
41815
  }
41816
+ /**
41817
+ * Estimates the transaction gas and fee based on the provided transaction request.
41818
+ * @param transactionRequest - The transaction request object.
41819
+ * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
41820
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41821
+ */
41822
+ estimateTxGasAndFee(params) {
41823
+ const { transactionRequest } = params;
41824
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41825
+ const chainInfo = this.getChain();
41826
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41827
+ transactionRequest.gasPrice = gasPrice;
41828
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
41829
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41830
+ if (transactionRequest.type === TransactionType.Script) {
41831
+ if (transactionRequest.gasLimit.eq(0)) {
41832
+ transactionRequest.gasLimit = minGas;
41833
+ transactionRequest.gasLimit = maxGasPerTx.sub(
41834
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
41835
+ );
41836
+ }
41837
+ }
41838
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41839
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41840
+ return {
41841
+ minGas,
41842
+ minFee,
41843
+ maxGas,
41844
+ maxFee
41845
+ };
41846
+ }
41810
41847
  /**
41811
41848
  * Executes a signed transaction without applying the states changes
41812
41849
  * on the chain.
@@ -41854,17 +41891,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41854
41891
  signatureCallback
41855
41892
  } = {}) {
41856
41893
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41857
- const chainInfo = this.getChain();
41858
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41859
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41894
+ const { minGasPrice } = this.getGasConfig();
41895
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41860
41896
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41861
41897
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41862
41898
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41863
41899
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41900
+ if (isScriptTransaction) {
41901
+ txRequestClone.gasLimit = bn(0);
41902
+ }
41864
41903
  if (estimatePredicates) {
41865
- if (isScriptTransaction) {
41866
- txRequestClone.gasLimit = bn(0);
41867
- }
41868
41904
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41869
41905
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41870
41906
  }
@@ -41873,36 +41909,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41873
41909
  if (signatureCallback && isScriptTransaction) {
41874
41910
  await signatureCallback(txRequestClone);
41875
41911
  }
41876
- const minGas = txRequestClone.calculateMinGas(chainInfo);
41877
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41912
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41913
+ transactionRequest: txRequestClone
41914
+ });
41878
41915
  let receipts = [];
41879
41916
  let missingContractIds = [];
41880
41917
  let outputVariables = 0;
41918
+ let gasUsed = bn(0);
41881
41919
  if (isScriptTransaction && estimateTxDependencies) {
41882
41920
  txRequestClone.gasPrice = bn(0);
41883
- txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41884
41921
  const result = await this.estimateTxDependencies(txRequestClone);
41885
41922
  receipts = result.receipts;
41886
41923
  outputVariables = result.outputVariables;
41887
41924
  missingContractIds = result.missingContractIds;
41925
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41926
+ txRequestClone.gasLimit = gasUsed;
41927
+ txRequestClone.gasPrice = setGasPrice;
41928
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41929
+ transactionRequest: txRequestClone
41930
+ }));
41888
41931
  }
41889
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41890
- const usedFee = calculatePriceWithFactor(
41891
- gasUsed,
41892
- gasPrice,
41893
- gasPriceFactor
41894
- ).normalizeZeroToOne();
41895
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41896
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41897
41932
  return {
41898
41933
  requiredQuantities: allQuantities,
41899
41934
  receipts,
41900
41935
  gasUsed,
41901
41936
  minGasPrice,
41902
- gasPrice,
41937
+ gasPrice: setGasPrice,
41903
41938
  minGas,
41904
41939
  maxGas,
41905
- usedFee,
41906
41940
  minFee,
41907
41941
  maxFee,
41908
41942
  estimatedInputs: txRequestClone.inputs,
@@ -42686,9 +42720,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42686
42720
  * @param assetId - The asset ID to check the balance for.
42687
42721
  * @returns A promise that resolves to the balance amount.
42688
42722
  */
42689
- async getBalance(assetId) {
42690
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42691
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42723
+ async getBalance(assetId = BaseAssetId) {
42724
+ const amount = await this.provider.getBalance(this.address, assetId);
42692
42725
  return amount;
42693
42726
  }
42694
42727
  /**
@@ -42726,10 +42759,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42726
42759
  * @returns A promise that resolves when the resources are added to the transaction.
42727
42760
  */
42728
42761
  async fund(request, coinQuantities, fee) {
42729
- const baseAssetId = this.provider.getBaseAssetId();
42730
42762
  const updatedQuantities = addAmountToAsset({
42731
42763
  amount: bn(fee),
42732
- assetId: baseAssetId,
42764
+ assetId: BaseAssetId,
42733
42765
  coinQuantities
42734
42766
  });
42735
42767
  const quantitiesDict = {};
@@ -42753,8 +42785,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42753
42785
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42754
42786
  cachedUtxos.push(input.id);
42755
42787
  }
42756
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42757
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42788
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42789
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42758
42790
  cachedMessages.push(input.nonce);
42759
42791
  }
42760
42792
  }
@@ -42786,12 +42818,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42786
42818
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42787
42819
  * @returns A promise that resolves to the prepared transaction request.
42788
42820
  */
42789
- async createTransfer(destination, amount, assetId, txParams = {}) {
42821
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42790
42822
  const { minGasPrice } = this.provider.getGasConfig();
42791
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42792
42823
  const params = { gasPrice: minGasPrice, ...txParams };
42793
42824
  const request = new ScriptTransactionRequest(params);
42794
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42825
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42795
42826
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42796
42827
  estimateTxDependencies: true,
42797
42828
  resourcesOwner: this
@@ -42817,15 +42848,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42817
42848
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42818
42849
  * @returns A promise that resolves to the transaction response.
42819
42850
  */
42820
- async transfer(destination, amount, assetId, txParams = {}) {
42851
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42821
42852
  if (bn(amount).lte(0)) {
42822
42853
  throw new FuelError(
42823
42854
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42824
42855
  "Transfer amount must be a positive number."
42825
42856
  );
42826
42857
  }
42827
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42828
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42858
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42829
42859
  return this.sendTransaction(request, { estimateTxDependencies: false });
42830
42860
  }
42831
42861
  /**
@@ -42837,7 +42867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42837
42867
  * @param txParams - The optional transaction parameters.
42838
42868
  * @returns A promise that resolves to the transaction response.
42839
42869
  */
42840
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42870
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42841
42871
  if (bn(amount).lte(0)) {
42842
42872
  throw new FuelError(
42843
42873
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42846,12 +42876,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42846
42876
  }
42847
42877
  const contractAddress = Address.fromAddressOrString(contractId);
42848
42878
  const { minGasPrice } = this.provider.getGasConfig();
42849
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42850
42879
  const params = { gasPrice: minGasPrice, ...txParams };
42851
42880
  const { script, scriptData } = await assembleTransferToContractScript({
42852
42881
  hexlifiedContractId: contractAddress.toB256(),
42853
42882
  amountToTransfer: bn(amount),
42854
- assetId: assetIdToTransfer
42883
+ assetId
42855
42884
  });
42856
42885
  const request = new ScriptTransactionRequest({
42857
42886
  ...params,
@@ -42861,7 +42890,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42861
42890
  request.addContractInputAndOutput(contractAddress);
42862
42891
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42863
42892
  request,
42864
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42893
+ [{ amount: bn(amount), assetId: String(assetId) }]
42865
42894
  );
42866
42895
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42867
42896
  this.validateGas({
@@ -42883,7 +42912,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42883
42912
  */
42884
42913
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42885
42914
  const { minGasPrice } = this.provider.getGasConfig();
42886
- const baseAssetId = this.provider.getBaseAssetId();
42887
42915
  const recipientAddress = Address.fromAddressOrString(recipient);
42888
42916
  const recipientDataArray = arrayify(
42889
42917
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42898,7 +42926,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42898
42926
  ]);
42899
42927
  const params = { script, gasPrice: minGasPrice, ...txParams };
42900
42928
  const request = new ScriptTransactionRequest(params);
42901
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42929
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42902
42930
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42903
42931
  request,
42904
42932
  forwardingQuantities
@@ -44362,12 +44390,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44362
44390
  };
44363
44391
 
44364
44392
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44365
- var import_crypto15 = __toESM(__require("crypto"));
44393
+ var import_crypto16 = __toESM(__require("crypto"));
44366
44394
  var rnds8Pool = new Uint8Array(256);
44367
44395
  var poolPtr = rnds8Pool.length;
44368
44396
  function rng() {
44369
44397
  if (poolPtr > rnds8Pool.length - 16) {
44370
- import_crypto15.default.randomFillSync(rnds8Pool);
44398
+ import_crypto16.default.randomFillSync(rnds8Pool);
44371
44399
  poolPtr = 0;
44372
44400
  }
44373
44401
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44383,9 +44411,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44383
44411
  }
44384
44412
 
44385
44413
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44386
- var import_crypto16 = __toESM(__require("crypto"));
44414
+ var import_crypto17 = __toESM(__require("crypto"));
44387
44415
  var native_default = {
44388
- randomUUID: import_crypto16.default.randomUUID
44416
+ randomUUID: import_crypto17.default.randomUUID
44389
44417
  };
44390
44418
 
44391
44419
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47862,9 +47890,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47862
47890
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47863
47891
  * @returns A promise that resolves to the prepared transaction request.
47864
47892
  */
47865
- async createTransfer(destination, amount, assetId, txParams = {}) {
47866
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47867
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47893
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47894
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47868
47895
  return this.populateTransactionPredicateData(request);
47869
47896
  }
47870
47897
  /**