@fuel-ts/account 0.0.0-rc-1976-20240415100843 → 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.

@@ -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,7 +31605,6 @@ 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;
31604
- var UTXO_ID_LEN = BYTES_32 + 1;
31605
31608
  var ASSET_ID_LEN = BYTES_32;
31606
31609
  var ADDRESS_LEN = BYTES_32;
31607
31610
  var NONCE_LEN = BYTES_32;
@@ -38861,9 +38864,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38861
38864
  }
38862
38865
  };
38863
38866
 
38864
- // ../address/dist/configs.mjs
38865
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38866
-
38867
38867
  // src/providers/transaction-request/input.ts
38868
38868
  var inputify = (value) => {
38869
38869
  const { type: type3 } = value;
@@ -38873,8 +38873,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38873
38873
  const predicateData = arrayify(value.predicateData ?? "0x");
38874
38874
  return {
38875
38875
  type: InputType.Coin,
38876
- txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38877
- 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],
38878
38878
  owner: hexlify(value.owner),
38879
38879
  amount: bn(value.amount),
38880
38880
  assetId: hexlify(value.assetId),
@@ -39540,8 +39540,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39540
39540
  outputs = [];
39541
39541
  /** List of witnesses */
39542
39542
  witnesses = [];
39543
- /** Base asset ID - should be fetched from the chain */
39544
- baseAssetId;
39545
39543
  /**
39546
39544
  * Constructor for initializing a base transaction request.
39547
39545
  *
@@ -39554,9 +39552,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39554
39552
  witnessLimit,
39555
39553
  inputs,
39556
39554
  outputs,
39557
- witnesses,
39558
- baseAssetId
39559
- }) {
39555
+ witnesses
39556
+ } = {}) {
39560
39557
  this.gasPrice = bn(gasPrice);
39561
39558
  this.maturity = maturity ?? 0;
39562
39559
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
@@ -39564,7 +39561,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39564
39561
  this.inputs = inputs ?? [];
39565
39562
  this.outputs = outputs ?? [];
39566
39563
  this.witnesses = witnesses ?? [];
39567
- this.baseAssetId = baseAssetId;
39568
39564
  }
39569
39565
  static getPolicyMeta(req) {
39570
39566
  let policyTypes = 0;
@@ -39788,9 +39784,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39788
39784
  *
39789
39785
  * @param message - Message resource.
39790
39786
  * @param predicate - Predicate bytes.
39787
+ * @param predicateData - Predicate data bytes.
39791
39788
  */
39792
39789
  addMessageInput(message, predicate) {
39793
39790
  const { recipient, sender, amount } = message;
39791
+ const assetId = BaseAssetId;
39794
39792
  let witnessIndex;
39795
39793
  if (predicate) {
39796
39794
  witnessIndex = 0;
@@ -39810,7 +39808,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39810
39808
  predicate: predicate?.bytes
39811
39809
  };
39812
39810
  this.pushInput(input);
39813
- this.addChangeOutput(recipient, this.baseAssetId);
39811
+ this.addChangeOutput(recipient, assetId);
39814
39812
  }
39815
39813
  /**
39816
39814
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39871,12 +39869,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39871
39869
  * @param amount - Amount of coin.
39872
39870
  * @param assetId - Asset ID of coin.
39873
39871
  */
39874
- addCoinOutput(to, amount, assetId) {
39872
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39875
39873
  this.pushOutput({
39876
39874
  type: OutputType.Coin,
39877
39875
  to: addressify(to).toB256(),
39878
39876
  amount,
39879
- assetId: assetId ?? this.baseAssetId
39877
+ assetId
39880
39878
  });
39881
39879
  return this;
39882
39880
  }
@@ -39903,7 +39901,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39903
39901
  * @param to - Address of the owner.
39904
39902
  * @param assetId - Asset ID of coin.
39905
39903
  */
39906
- addChangeOutput(to, assetId) {
39904
+ addChangeOutput(to, assetId = BaseAssetId) {
39907
39905
  const changeOutput = this.getChangeOutputs().find(
39908
39906
  (output3) => hexlify(output3.assetId) === assetId
39909
39907
  );
@@ -39911,7 +39909,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39911
39909
  this.pushOutput({
39912
39910
  type: OutputType.Change,
39913
39911
  to: addressify(to).toB256(),
39914
- assetId: assetId ?? this.baseAssetId
39912
+ assetId
39915
39913
  });
39916
39914
  }
39917
39915
  }
@@ -39962,6 +39960,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39962
39960
  * @param quantities - CoinQuantity Array.
39963
39961
  */
39964
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
+ };
39965
39969
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39966
39970
  if ("assetId" in input) {
39967
39971
  return input.assetId === assetId;
@@ -39971,12 +39975,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39971
39975
  const updateAssetInput = (assetId, quantity) => {
39972
39976
  const assetInput = findAssetInput(assetId);
39973
39977
  if (assetInput && "assetId" in assetInput) {
39974
- assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39978
+ assetInput.id = generateId();
39975
39979
  assetInput.amount = quantity;
39976
39980
  } else {
39977
39981
  this.addResources([
39978
39982
  {
39979
- id: hexlify(randomBytes22(UTXO_ID_LEN)),
39983
+ id: generateId(),
39980
39984
  amount: quantity,
39981
39985
  assetId,
39982
39986
  owner: resourcesOwner || Address.fromRandom(),
@@ -39987,7 +39991,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39987
39991
  ]);
39988
39992
  }
39989
39993
  };
39990
- updateAssetInput(this.baseAssetId, bn(1e11));
39994
+ updateAssetInput(BaseAssetId, bn(1e11));
39991
39995
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
39992
39996
  }
39993
39997
  /**
@@ -40144,7 +40148,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40144
40148
  *
40145
40149
  * @param createTransactionRequestLike - The initial values for the instance
40146
40150
  */
40147
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40151
+ constructor({
40152
+ bytecodeWitnessIndex,
40153
+ salt,
40154
+ storageSlots,
40155
+ ...rest
40156
+ } = {}) {
40148
40157
  super(rest);
40149
40158
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40150
40159
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40259,7 +40268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40259
40268
  *
40260
40269
  * @param scriptTransactionRequestLike - The initial values for the instance.
40261
40270
  */
40262
- constructor({ script, scriptData, gasLimit, ...rest }) {
40271
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40263
40272
  super(rest);
40264
40273
  this.gasLimit = bn(gasLimit);
40265
40274
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -41405,7 +41414,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41405
41414
  gasPerByte: bn(feeParams.gasPerByte),
41406
41415
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41407
41416
  chainId: bn(consensusParameters.chainId),
41408
- baseAssetId: consensusParameters.baseAssetId,
41409
41417
  gasCosts
41410
41418
  },
41411
41419
  gasCosts,
@@ -41648,17 +41656,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41648
41656
  } = this.getChain();
41649
41657
  return chainId.toNumber();
41650
41658
  }
41651
- /**
41652
- * Returns the base asset ID
41653
- *
41654
- * @returns A promise that resolves to the base asset ID
41655
- */
41656
- getBaseAssetId() {
41657
- const {
41658
- consensusParameters: { baseAssetId }
41659
- } = this.getChain();
41660
- return baseAssetId;
41661
- }
41662
41659
  /**
41663
41660
  * Submits a transaction to the chain to be executed.
41664
41661
  *
@@ -41809,36 +41806,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41809
41806
  missingContractIds
41810
41807
  };
41811
41808
  }
41812
- /**
41813
- * Estimates the transaction gas and fee based on the provided transaction request.
41814
- * @param transactionRequest - The transaction request object.
41815
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41816
- */
41817
- estimateTxGasAndFee(params) {
41818
- const { transactionRequest } = params;
41819
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41820
- const chainInfo = this.getChain();
41821
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41822
- transactionRequest.gasPrice = gasPrice;
41823
- const minGas = transactionRequest.calculateMinGas(chainInfo);
41824
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41825
- if (transactionRequest.type === TransactionType.Script) {
41826
- if (transactionRequest.gasLimit.eq(0)) {
41827
- transactionRequest.gasLimit = minGas;
41828
- transactionRequest.gasLimit = maxGasPerTx.sub(
41829
- transactionRequest.calculateMaxGas(chainInfo, minGas)
41830
- );
41831
- }
41832
- }
41833
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41834
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41835
- return {
41836
- minGas,
41837
- minFee,
41838
- maxGas,
41839
- maxFee
41840
- };
41841
- }
41842
41809
  /**
41843
41810
  * Executes a signed transaction without applying the states changes
41844
41811
  * on the chain.
@@ -41886,16 +41853,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41886
41853
  signatureCallback
41887
41854
  } = {}) {
41888
41855
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41889
- const { minGasPrice } = this.getGasConfig();
41890
- 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);
41891
41859
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41892
41860
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41893
41861
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41894
41862
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41895
- if (isScriptTransaction) {
41896
- txRequestClone.gasLimit = bn(0);
41897
- }
41898
41863
  if (estimatePredicates) {
41864
+ if (isScriptTransaction) {
41865
+ txRequestClone.gasLimit = bn(0);
41866
+ }
41899
41867
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41900
41868
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41901
41869
  }
@@ -41904,34 +41872,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41904
41872
  if (signatureCallback && isScriptTransaction) {
41905
41873
  await signatureCallback(txRequestClone);
41906
41874
  }
41907
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41908
- transactionRequest: txRequestClone
41909
- });
41875
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
41876
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41910
41877
  let receipts = [];
41911
41878
  let missingContractIds = [];
41912
41879
  let outputVariables = 0;
41913
- let gasUsed = bn(0);
41914
41880
  if (isScriptTransaction && estimateTxDependencies) {
41915
41881
  txRequestClone.gasPrice = bn(0);
41882
+ txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41916
41883
  const result = await this.estimateTxDependencies(txRequestClone);
41917
41884
  receipts = result.receipts;
41918
41885
  outputVariables = result.outputVariables;
41919
41886
  missingContractIds = result.missingContractIds;
41920
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41921
- txRequestClone.gasLimit = gasUsed;
41922
- txRequestClone.gasPrice = setGasPrice;
41923
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41924
- transactionRequest: txRequestClone
41925
- }));
41926
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();
41927
41896
  return {
41928
41897
  requiredQuantities: allQuantities,
41929
41898
  receipts,
41930
41899
  gasUsed,
41931
41900
  minGasPrice,
41932
- gasPrice: setGasPrice,
41901
+ gasPrice,
41933
41902
  minGas,
41934
41903
  maxGas,
41904
+ usedFee,
41935
41905
  minFee,
41936
41906
  maxFee,
41937
41907
  estimatedInputs: txRequestClone.inputs,
@@ -42715,9 +42685,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42715
42685
  * @param assetId - The asset ID to check the balance for.
42716
42686
  * @returns A promise that resolves to the balance amount.
42717
42687
  */
42718
- async getBalance(assetId) {
42719
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42720
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42688
+ async getBalance(assetId = BaseAssetId) {
42689
+ const amount = await this.provider.getBalance(this.address, assetId);
42721
42690
  return amount;
42722
42691
  }
42723
42692
  /**
@@ -42755,10 +42724,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42755
42724
  * @returns A promise that resolves when the resources are added to the transaction.
42756
42725
  */
42757
42726
  async fund(request, coinQuantities, fee) {
42758
- const baseAssetId = this.provider.getBaseAssetId();
42759
42727
  const updatedQuantities = addAmountToAsset({
42760
42728
  amount: bn(fee),
42761
- assetId: baseAssetId,
42729
+ assetId: BaseAssetId,
42762
42730
  coinQuantities
42763
42731
  });
42764
42732
  const quantitiesDict = {};
@@ -42782,8 +42750,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42782
42750
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42783
42751
  cachedUtxos.push(input.id);
42784
42752
  }
42785
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42786
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42753
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42754
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42787
42755
  cachedMessages.push(input.nonce);
42788
42756
  }
42789
42757
  }
@@ -42815,13 +42783,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42815
42783
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42816
42784
  * @returns A promise that resolves to the prepared transaction request.
42817
42785
  */
42818
- async createTransfer(destination, amount, assetId, txParams = {}) {
42786
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42819
42787
  const { minGasPrice } = this.provider.getGasConfig();
42820
- const baseAssetId = this.provider.getBaseAssetId();
42821
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42822
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42788
+ const params = { gasPrice: minGasPrice, ...txParams };
42823
42789
  const request = new ScriptTransactionRequest(params);
42824
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42790
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42825
42791
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42826
42792
  estimateTxDependencies: true,
42827
42793
  resourcesOwner: this
@@ -42847,15 +42813,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42847
42813
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42848
42814
  * @returns A promise that resolves to the transaction response.
42849
42815
  */
42850
- async transfer(destination, amount, assetId, txParams = {}) {
42816
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42851
42817
  if (bn(amount).lte(0)) {
42852
42818
  throw new FuelError(
42853
42819
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42854
42820
  "Transfer amount must be a positive number."
42855
42821
  );
42856
42822
  }
42857
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42858
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42823
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42859
42824
  return this.sendTransaction(request, { estimateTxDependencies: false });
42860
42825
  }
42861
42826
  /**
@@ -42867,7 +42832,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42867
42832
  * @param txParams - The optional transaction parameters.
42868
42833
  * @returns A promise that resolves to the transaction response.
42869
42834
  */
42870
- async transferToContract(contractId, amount, assetId, txParams = {}) {
42835
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42871
42836
  if (bn(amount).lte(0)) {
42872
42837
  throw new FuelError(
42873
42838
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42876,13 +42841,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42876
42841
  }
42877
42842
  const contractAddress = Address.fromAddressOrString(contractId);
42878
42843
  const { minGasPrice } = this.provider.getGasConfig();
42879
- const baseAssetId = this.provider.getBaseAssetId();
42880
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42881
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42844
+ const params = { gasPrice: minGasPrice, ...txParams };
42882
42845
  const { script, scriptData } = await assembleTransferToContractScript({
42883
42846
  hexlifiedContractId: contractAddress.toB256(),
42884
42847
  amountToTransfer: bn(amount),
42885
- assetId: assetIdToTransfer
42848
+ assetId
42886
42849
  });
42887
42850
  const request = new ScriptTransactionRequest({
42888
42851
  ...params,
@@ -42892,7 +42855,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42892
42855
  request.addContractInputAndOutput(contractAddress);
42893
42856
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42894
42857
  request,
42895
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42858
+ [{ amount: bn(amount), assetId: String(assetId) }]
42896
42859
  );
42897
42860
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42898
42861
  this.validateGas({
@@ -42914,7 +42877,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42914
42877
  */
42915
42878
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42916
42879
  const { minGasPrice } = this.provider.getGasConfig();
42917
- const baseAssetId = this.provider.getBaseAssetId();
42918
42880
  const recipientAddress = Address.fromAddressOrString(recipient);
42919
42881
  const recipientDataArray = arrayify(
42920
42882
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42927,14 +42889,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42927
42889
  ...recipientDataArray,
42928
42890
  ...amountDataArray
42929
42891
  ]);
42930
- const params = {
42931
- script,
42932
- gasPrice: minGasPrice,
42933
- baseAssetId,
42934
- ...txParams
42935
- };
42892
+ const params = { script, gasPrice: minGasPrice, ...txParams };
42936
42893
  const request = new ScriptTransactionRequest(params);
42937
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42894
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42938
42895
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42939
42896
  request,
42940
42897
  forwardingQuantities
@@ -44398,12 +44355,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44398
44355
  };
44399
44356
 
44400
44357
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44401
- var import_crypto16 = __toESM(__require("crypto"));
44358
+ var import_crypto15 = __toESM(__require("crypto"));
44402
44359
  var rnds8Pool = new Uint8Array(256);
44403
44360
  var poolPtr = rnds8Pool.length;
44404
44361
  function rng() {
44405
44362
  if (poolPtr > rnds8Pool.length - 16) {
44406
- import_crypto16.default.randomFillSync(rnds8Pool);
44363
+ import_crypto15.default.randomFillSync(rnds8Pool);
44407
44364
  poolPtr = 0;
44408
44365
  }
44409
44366
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44419,9 +44376,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44419
44376
  }
44420
44377
 
44421
44378
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44422
- var import_crypto17 = __toESM(__require("crypto"));
44379
+ var import_crypto16 = __toESM(__require("crypto"));
44423
44380
  var native_default = {
44424
- randomUUID: import_crypto17.default.randomUUID
44381
+ randomUUID: import_crypto16.default.randomUUID
44425
44382
  };
44426
44383
 
44427
44384
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47897,9 +47854,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47897
47854
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47898
47855
  * @returns A promise that resolves to the prepared transaction request.
47899
47856
  */
47900
- async createTransfer(destination, amount, assetId, txParams = {}) {
47901
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47902
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47857
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47858
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47903
47859
  return this.populateTransactionPredicateData(request);
47904
47860
  }
47905
47861
  /**