@fuel-ts/account 0.0.0-rc-1976-20240410144111 → 0.0.0-rc-2034-20240410182856

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"}
@@ -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;
@@ -38850,9 +38855,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38850
38855
  }
38851
38856
  };
38852
38857
 
38853
- // ../address/dist/configs.mjs
38854
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38855
-
38856
38858
  // src/providers/transaction-request/input.ts
38857
38859
  var inputify = (value) => {
38858
38860
  const { type: type3 } = value;
@@ -38862,8 +38864,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38862
38864
  const predicateData = arrayify(value.predicateData ?? "0x");
38863
38865
  return {
38864
38866
  type: InputType.Coin,
38865
- txID: hexlify(arrayify(value.id).slice(0, 32)),
38866
- outputIndex: arrayify(value.id)[32],
38867
+ txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38868
+ outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38867
38869
  owner: hexlify(value.owner),
38868
38870
  amount: bn(value.amount),
38869
38871
  assetId: hexlify(value.assetId),
@@ -39529,8 +39531,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39529
39531
  outputs = [];
39530
39532
  /** List of witnesses */
39531
39533
  witnesses = [];
39532
- /** Base asset ID - should be fetched from the chain */
39533
- baseAssetId;
39534
39534
  /**
39535
39535
  * Constructor for initializing a base transaction request.
39536
39536
  *
@@ -39543,9 +39543,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39543
39543
  witnessLimit,
39544
39544
  inputs,
39545
39545
  outputs,
39546
- witnesses,
39547
- baseAssetId
39548
- }) {
39546
+ witnesses
39547
+ } = {}) {
39549
39548
  this.gasPrice = bn(gasPrice);
39550
39549
  this.maturity = maturity ?? 0;
39551
39550
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
@@ -39553,7 +39552,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39553
39552
  this.inputs = inputs ?? [];
39554
39553
  this.outputs = outputs ?? [];
39555
39554
  this.witnesses = witnesses ?? [];
39556
- this.baseAssetId = baseAssetId;
39557
39555
  }
39558
39556
  static getPolicyMeta(req) {
39559
39557
  let policyTypes = 0;
@@ -39777,9 +39775,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39777
39775
  *
39778
39776
  * @param message - Message resource.
39779
39777
  * @param predicate - Predicate bytes.
39778
+ * @param predicateData - Predicate data bytes.
39780
39779
  */
39781
39780
  addMessageInput(message, predicate) {
39782
39781
  const { recipient, sender, amount } = message;
39782
+ const assetId = BaseAssetId;
39783
39783
  let witnessIndex;
39784
39784
  if (predicate) {
39785
39785
  witnessIndex = 0;
@@ -39799,7 +39799,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39799
39799
  predicate: predicate?.bytes
39800
39800
  };
39801
39801
  this.pushInput(input);
39802
- this.addChangeOutput(recipient, this.baseAssetId);
39802
+ this.addChangeOutput(recipient, assetId);
39803
39803
  }
39804
39804
  /**
39805
39805
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39860,12 +39860,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39860
39860
  * @param amount - Amount of coin.
39861
39861
  * @param assetId - Asset ID of coin.
39862
39862
  */
39863
- addCoinOutput(to, amount, assetId) {
39863
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39864
39864
  this.pushOutput({
39865
39865
  type: OutputType.Coin,
39866
39866
  to: addressify(to).toB256(),
39867
39867
  amount,
39868
- assetId: assetId ?? this.baseAssetId
39868
+ assetId
39869
39869
  });
39870
39870
  return this;
39871
39871
  }
@@ -39892,7 +39892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39892
39892
  * @param to - Address of the owner.
39893
39893
  * @param assetId - Asset ID of coin.
39894
39894
  */
39895
- addChangeOutput(to, assetId) {
39895
+ addChangeOutput(to, assetId = BaseAssetId) {
39896
39896
  const changeOutput = this.getChangeOutputs().find(
39897
39897
  (output3) => hexlify(output3.assetId) === assetId
39898
39898
  );
@@ -39900,7 +39900,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39900
39900
  this.pushOutput({
39901
39901
  type: OutputType.Change,
39902
39902
  to: addressify(to).toB256(),
39903
- assetId: assetId ?? this.baseAssetId
39903
+ assetId
39904
39904
  });
39905
39905
  }
39906
39906
  }
@@ -39951,12 +39951,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39951
39951
  * @param quantities - CoinQuantity Array.
39952
39952
  */
39953
39953
  fundWithFakeUtxos(quantities, resourcesOwner) {
39954
- let idCounter = 0;
39955
- const generateId = () => {
39956
- const counterString = String(idCounter++);
39957
- const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
39958
- return id;
39959
- };
39960
39954
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39961
39955
  if ("assetId" in input) {
39962
39956
  return input.assetId === assetId;
@@ -39966,12 +39960,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39966
39960
  const updateAssetInput = (assetId, quantity) => {
39967
39961
  const assetInput = findAssetInput(assetId);
39968
39962
  if (assetInput && "assetId" in assetInput) {
39969
- assetInput.id = generateId();
39963
+ assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39970
39964
  assetInput.amount = quantity;
39971
39965
  } else {
39972
39966
  this.addResources([
39973
39967
  {
39974
- id: generateId(),
39968
+ id: hexlify(randomBytes22(UTXO_ID_LEN)),
39975
39969
  amount: quantity,
39976
39970
  assetId,
39977
39971
  owner: resourcesOwner || Address.fromRandom(),
@@ -39982,7 +39976,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39982
39976
  ]);
39983
39977
  }
39984
39978
  };
39985
- updateAssetInput(this.baseAssetId, bn(1e11));
39979
+ updateAssetInput(BaseAssetId, bn(1e11));
39986
39980
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39987
39981
  }
39988
39982
  /**
@@ -40139,7 +40133,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40139
40133
  *
40140
40134
  * @param createTransactionRequestLike - The initial values for the instance
40141
40135
  */
40142
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40136
+ constructor({
40137
+ bytecodeWitnessIndex,
40138
+ salt,
40139
+ storageSlots,
40140
+ ...rest
40141
+ } = {}) {
40143
40142
  super(rest);
40144
40143
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40145
40144
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40254,7 +40253,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40254
40253
  *
40255
40254
  * @param scriptTransactionRequestLike - The initial values for the instance.
40256
40255
  */
40257
- constructor({ script, scriptData, gasLimit, ...rest }) {
40256
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40258
40257
  super(rest);
40259
40258
  this.gasLimit = bn(gasLimit);
40260
40259
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -41400,7 +41399,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41400
41399
  gasPerByte: bn(feeParams.gasPerByte),
41401
41400
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41402
41401
  chainId: bn(consensusParameters.chainId),
41403
- baseAssetId: consensusParameters.baseAssetId,
41404
41402
  gasCosts
41405
41403
  },
41406
41404
  gasCosts,
@@ -41643,17 +41641,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41643
41641
  } = this.getChain();
41644
41642
  return chainId.toNumber();
41645
41643
  }
41646
- /**
41647
- * Returns the base asset ID
41648
- *
41649
- * @returns A promise that resolves to the base asset ID
41650
- */
41651
- getBaseAssetId() {
41652
- const {
41653
- consensusParameters: { baseAssetId }
41654
- } = this.getChain();
41655
- return baseAssetId;
41656
- }
41657
41644
  /**
41658
41645
  * Submits a transaction to the chain to be executed.
41659
41646
  *
@@ -41804,6 +41791,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41804
41791
  missingContractIds
41805
41792
  };
41806
41793
  }
41794
+ /**
41795
+ * Estimates the transaction gas and fee based on the provided transaction request.
41796
+ * @param transactionRequest - The transaction request object.
41797
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41798
+ */
41799
+ estimateTxGasAndFee(params) {
41800
+ const { transactionRequest } = params;
41801
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41802
+ const chainInfo = this.getChain();
41803
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41804
+ transactionRequest.gasPrice = gasPrice;
41805
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
41806
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41807
+ if (transactionRequest.type === TransactionType.Script) {
41808
+ if (transactionRequest.gasLimit.eq(0)) {
41809
+ transactionRequest.gasLimit = minGas;
41810
+ transactionRequest.gasLimit = maxGasPerTx.sub(
41811
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
41812
+ );
41813
+ }
41814
+ }
41815
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41816
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41817
+ return {
41818
+ minGas,
41819
+ minFee,
41820
+ maxGas,
41821
+ maxFee
41822
+ };
41823
+ }
41807
41824
  /**
41808
41825
  * Executes a signed transaction without applying the states changes
41809
41826
  * on the chain.
@@ -41851,17 +41868,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41851
41868
  signatureCallback
41852
41869
  } = {}) {
41853
41870
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41854
- const chainInfo = this.getChain();
41855
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41856
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41871
+ const { minGasPrice } = this.getGasConfig();
41872
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41857
41873
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41858
41874
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41859
41875
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41860
41876
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41877
+ if (isScriptTransaction) {
41878
+ txRequestClone.gasLimit = bn(0);
41879
+ }
41861
41880
  if (estimatePredicates) {
41862
- if (isScriptTransaction) {
41863
- txRequestClone.gasLimit = bn(0);
41864
- }
41865
41881
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41866
41882
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41867
41883
  }
@@ -41870,36 +41886,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41870
41886
  if (signatureCallback && isScriptTransaction) {
41871
41887
  await signatureCallback(txRequestClone);
41872
41888
  }
41873
- const minGas = txRequestClone.calculateMinGas(chainInfo);
41874
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41889
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41890
+ transactionRequest: txRequestClone
41891
+ });
41875
41892
  let receipts = [];
41876
41893
  let missingContractIds = [];
41877
41894
  let outputVariables = 0;
41895
+ let gasUsed = bn(0);
41878
41896
  if (isScriptTransaction && estimateTxDependencies) {
41879
41897
  txRequestClone.gasPrice = bn(0);
41880
- txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41881
41898
  const result = await this.estimateTxDependencies(txRequestClone);
41882
41899
  receipts = result.receipts;
41883
41900
  outputVariables = result.outputVariables;
41884
41901
  missingContractIds = result.missingContractIds;
41902
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41903
+ txRequestClone.gasLimit = gasUsed;
41904
+ txRequestClone.gasPrice = setGasPrice;
41905
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41906
+ transactionRequest: txRequestClone
41907
+ }));
41885
41908
  }
41886
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41887
- const usedFee = calculatePriceWithFactor(
41888
- gasUsed,
41889
- gasPrice,
41890
- gasPriceFactor
41891
- ).normalizeZeroToOne();
41892
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41893
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41894
41909
  return {
41895
41910
  requiredQuantities: allQuantities,
41896
41911
  receipts,
41897
41912
  gasUsed,
41898
41913
  minGasPrice,
41899
- gasPrice,
41914
+ gasPrice: setGasPrice,
41900
41915
  minGas,
41901
41916
  maxGas,
41902
- usedFee,
41903
41917
  minFee,
41904
41918
  maxFee,
41905
41919
  estimatedInputs: txRequestClone.inputs,
@@ -42683,9 +42697,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42683
42697
  * @param assetId - The asset ID to check the balance for.
42684
42698
  * @returns A promise that resolves to the balance amount.
42685
42699
  */
42686
- async getBalance(assetId) {
42687
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42688
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42700
+ async getBalance(assetId = BaseAssetId) {
42701
+ const amount = await this.provider.getBalance(this.address, assetId);
42689
42702
  return amount;
42690
42703
  }
42691
42704
  /**
@@ -42723,10 +42736,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42723
42736
  * @returns A promise that resolves when the resources are added to the transaction.
42724
42737
  */
42725
42738
  async fund(request, coinQuantities, fee) {
42726
- const baseAssetId = this.provider.getBaseAssetId();
42727
42739
  const updatedQuantities = addAmountToAsset({
42728
42740
  amount: bn(fee),
42729
- assetId: baseAssetId,
42741
+ assetId: BaseAssetId,
42730
42742
  coinQuantities
42731
42743
  });
42732
42744
  const quantitiesDict = {};
@@ -42750,8 +42762,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42750
42762
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42751
42763
  cachedUtxos.push(input.id);
42752
42764
  }
42753
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42754
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42765
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42766
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42755
42767
  cachedMessages.push(input.nonce);
42756
42768
  }
42757
42769
  }
@@ -42783,13 +42795,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42783
42795
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42784
42796
  * @returns A promise that resolves to the prepared transaction request.
42785
42797
  */
42786
- async createTransfer(destination, amount, assetId, txParams = {}) {
42798
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42787
42799
  const { minGasPrice } = this.provider.getGasConfig();
42788
- const baseAssetId = this.provider.getBaseAssetId();
42789
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42790
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42800
+ const params = { gasPrice: minGasPrice, ...txParams };
42791
42801
  const request = new ScriptTransactionRequest(params);
42792
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42802
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42793
42803
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42794
42804
  estimateTxDependencies: true,
42795
42805
  resourcesOwner: this
@@ -42815,15 +42825,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42815
42825
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42816
42826
  * @returns A promise that resolves to the transaction response.
42817
42827
  */
42818
- async transfer(destination, amount, assetId, txParams = {}) {
42828
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42819
42829
  if (bn(amount).lte(0)) {
42820
42830
  throw new FuelError(
42821
42831
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42822
42832
  "Transfer amount must be a positive number."
42823
42833
  );
42824
42834
  }
42825
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42826
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42835
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42827
42836
  return this.sendTransaction(request, { estimateTxDependencies: false });
42828
42837
  }
42829
42838
  /**
@@ -42835,7 +42844,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42835
42844
  * @param txParams - The optional transaction parameters.
42836
42845
  * @returns A promise that resolves to the transaction response.
42837
42846
  */
42838
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42847
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42839
42848
  if (bn(amount).lte(0)) {
42840
42849
  throw new FuelError(
42841
42850
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42844,13 +42853,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42844
42853
  }
42845
42854
  const contractAddress = Address.fromAddressOrString(contractId);
42846
42855
  const { minGasPrice } = this.provider.getGasConfig();
42847
- const baseAssetId = this.provider.getBaseAssetId();
42848
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42849
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42856
+ const params = { gasPrice: minGasPrice, ...txParams };
42850
42857
  const { script, scriptData } = await assembleTransferToContractScript({
42851
42858
  hexlifiedContractId: contractAddress.toB256(),
42852
42859
  amountToTransfer: bn(amount),
42853
- assetId: assetIdToTransfer
42860
+ assetId
42854
42861
  });
42855
42862
  const request = new ScriptTransactionRequest({
42856
42863
  ...params,
@@ -42860,7 +42867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42860
42867
  request.addContractInputAndOutput(contractAddress);
42861
42868
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42862
42869
  request,
42863
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42870
+ [{ amount: bn(amount), assetId: String(assetId) }]
42864
42871
  );
42865
42872
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42866
42873
  this.validateGas({
@@ -42882,7 +42889,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42882
42889
  */
42883
42890
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42884
42891
  const { minGasPrice } = this.provider.getGasConfig();
42885
- const baseAssetId = this.provider.getBaseAssetId();
42886
42892
  const recipientAddress = Address.fromAddressOrString(recipient);
42887
42893
  const recipientDataArray = arrayify(
42888
42894
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42895,14 +42901,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42895
42901
  ...recipientDataArray,
42896
42902
  ...amountDataArray
42897
42903
  ]);
42898
- const params = {
42899
- script,
42900
- gasPrice: minGasPrice,
42901
- baseAssetId,
42902
- ...txParams
42903
- };
42904
+ const params = { script, gasPrice: minGasPrice, ...txParams };
42904
42905
  const request = new ScriptTransactionRequest(params);
42905
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42906
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42906
42907
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42907
42908
  request,
42908
42909
  forwardingQuantities
@@ -44366,12 +44367,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44366
44367
  };
44367
44368
 
44368
44369
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44369
- var import_crypto15 = __toESM(__require("crypto"));
44370
+ var import_crypto16 = __toESM(__require("crypto"));
44370
44371
  var rnds8Pool = new Uint8Array(256);
44371
44372
  var poolPtr = rnds8Pool.length;
44372
44373
  function rng() {
44373
44374
  if (poolPtr > rnds8Pool.length - 16) {
44374
- import_crypto15.default.randomFillSync(rnds8Pool);
44375
+ import_crypto16.default.randomFillSync(rnds8Pool);
44375
44376
  poolPtr = 0;
44376
44377
  }
44377
44378
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44387,9 +44388,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44387
44388
  }
44388
44389
 
44389
44390
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44390
- var import_crypto16 = __toESM(__require("crypto"));
44391
+ var import_crypto17 = __toESM(__require("crypto"));
44391
44392
  var native_default = {
44392
- randomUUID: import_crypto16.default.randomUUID
44393
+ randomUUID: import_crypto17.default.randomUUID
44393
44394
  };
44394
44395
 
44395
44396
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47865,9 +47866,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47865
47866
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47866
47867
  * @returns A promise that resolves to the prepared transaction request.
47867
47868
  */
47868
- async createTransfer(destination, amount, assetId, txParams = {}) {
47869
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47870
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47869
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47870
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47871
47871
  return this.populateTransactionPredicateData(request);
47872
47872
  }
47873
47873
  /**