@fuel-ts/account 0.0.0-rc-2034-20240410133013 → 0.0.0-rc-1976-20240410141707

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":"AAGA,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_crypto9 = __toESM(__require("crypto"), 1);
29248
+ var import_crypto8 = __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,27 +30317,6 @@ 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
-
30341
30320
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
30342
30321
  var BN_03 = BigInt(0);
30343
30322
  var BN_36 = BigInt(36);
@@ -30922,8 +30901,8 @@ This unreleased fuel-core build may include features and updates not yet support
30922
30901
  }
30923
30902
 
30924
30903
  // ../crypto/dist/index.mjs
30904
+ var import_crypto9 = __toESM(__require("crypto"), 1);
30925
30905
  var import_crypto10 = __toESM(__require("crypto"), 1);
30926
- var import_crypto11 = __toESM(__require("crypto"), 1);
30927
30906
  var scrypt3 = (params) => {
30928
30907
  const { password, salt, n, p, r, dklen } = params;
30929
30908
  const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
@@ -30932,7 +30911,7 @@ This unreleased fuel-core build may include features and updates not yet support
30932
30911
  var keccak2562 = (data) => keccak_256(data);
30933
30912
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
30934
30913
  var randomBytes4 = (length) => {
30935
- const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
30914
+ const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
30936
30915
  return randomValues;
30937
30916
  };
30938
30917
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -30947,7 +30926,7 @@ This unreleased fuel-core build may include features and updates not yet support
30947
30926
  const salt = randomBytes4(32);
30948
30927
  const secret = keyFromPassword(password, salt);
30949
30928
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
30950
- const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
30929
+ const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
30951
30930
  let cipherData = cipher.update(dataBuffer);
30952
30931
  cipherData = Buffer.concat([cipherData, cipher.final()]);
30953
30932
  return {
@@ -30961,7 +30940,7 @@ This unreleased fuel-core build may include features and updates not yet support
30961
30940
  const salt = bufferFromString(keystore.salt);
30962
30941
  const secret = keyFromPassword(password, salt);
30963
30942
  const encryptedText = bufferFromString(keystore.data);
30964
- const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
30943
+ const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
30965
30944
  const decrypted = decipher.update(encryptedText);
30966
30945
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
30967
30946
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -30972,12 +30951,12 @@ This unreleased fuel-core build may include features and updates not yet support
30972
30951
  }
30973
30952
  };
30974
30953
  async function encryptJsonWalletData(data, key, iv) {
30975
- const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30954
+ const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30976
30955
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
30977
30956
  return new Uint8Array(encrypted);
30978
30957
  }
30979
30958
  async function decryptJsonWalletData(data, key, iv) {
30980
- const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30959
+ const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30981
30960
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
30982
30961
  return new Uint8Array(decrypted);
30983
30962
  }
@@ -31293,10 +31272,6 @@ This unreleased fuel-core build may include features and updates not yet support
31293
31272
  }
31294
31273
  };
31295
31274
 
31296
- // ../address/dist/configs.mjs
31297
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31298
- var BaseAssetId = ZeroBytes32;
31299
-
31300
31275
  // ../math/dist/index.mjs
31301
31276
  var import_bn = __toESM(require_bn(), 1);
31302
31277
  var DEFAULT_PRECISION = 9;
@@ -31527,11 +31502,11 @@ This unreleased fuel-core build may include features and updates not yet support
31527
31502
  let max2;
31528
31503
  if (Array.isArray(coinQuantityLike)) {
31529
31504
  amount = coinQuantityLike[0];
31530
- assetId = coinQuantityLike[1] ?? BaseAssetId;
31531
- max2 = coinQuantityLike[2] ?? void 0;
31505
+ assetId = coinQuantityLike[1];
31506
+ max2 = coinQuantityLike[2];
31532
31507
  } else {
31533
31508
  amount = coinQuantityLike.amount;
31534
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
31509
+ assetId = coinQuantityLike.assetId;
31535
31510
  max2 = coinQuantityLike.max ?? void 0;
31536
31511
  }
31537
31512
  const bnAmount = bn(amount);
@@ -38875,6 +38850,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38875
38850
  }
38876
38851
  };
38877
38852
 
38853
+ // ../address/dist/configs.mjs
38854
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38855
+
38878
38856
  // src/providers/transaction-request/input.ts
38879
38857
  var inputify = (value) => {
38880
38858
  const { type: type3 } = value;
@@ -38885,7 +38863,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38885
38863
  return {
38886
38864
  type: InputType.Coin,
38887
38865
  txID: hexlify(arrayify(value.id).slice(0, 32)),
38888
- outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
38866
+ outputIndex: arrayify(value.id)[32],
38889
38867
  owner: hexlify(value.owner),
38890
38868
  amount: bn(value.amount),
38891
38869
  assetId: hexlify(value.assetId),
@@ -39551,6 +39529,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39551
39529
  outputs = [];
39552
39530
  /** List of witnesses */
39553
39531
  witnesses = [];
39532
+ /** Base asset ID - should be fetched from the chain */
39533
+ baseAssetId = ZeroBytes32;
39554
39534
  /**
39555
39535
  * Constructor for initializing a base transaction request.
39556
39536
  *
@@ -39563,7 +39543,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39563
39543
  witnessLimit,
39564
39544
  inputs,
39565
39545
  outputs,
39566
- witnesses
39546
+ witnesses,
39547
+ baseAssetId
39567
39548
  } = {}) {
39568
39549
  this.gasPrice = bn(gasPrice);
39569
39550
  this.maturity = maturity ?? 0;
@@ -39572,6 +39553,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39572
39553
  this.inputs = inputs ?? [];
39573
39554
  this.outputs = outputs ?? [];
39574
39555
  this.witnesses = witnesses ?? [];
39556
+ this.baseAssetId = baseAssetId ?? ZeroBytes32;
39575
39557
  }
39576
39558
  static getPolicyMeta(req) {
39577
39559
  let policyTypes = 0;
@@ -39795,11 +39777,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39795
39777
  *
39796
39778
  * @param message - Message resource.
39797
39779
  * @param predicate - Predicate bytes.
39798
- * @param predicateData - Predicate data bytes.
39799
39780
  */
39800
39781
  addMessageInput(message, predicate) {
39801
39782
  const { recipient, sender, amount } = message;
39802
- const assetId = BaseAssetId;
39803
39783
  let witnessIndex;
39804
39784
  if (predicate) {
39805
39785
  witnessIndex = 0;
@@ -39819,7 +39799,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39819
39799
  predicate: predicate?.bytes
39820
39800
  };
39821
39801
  this.pushInput(input);
39822
- this.addChangeOutput(recipient, assetId);
39802
+ this.addChangeOutput(recipient, this.baseAssetId);
39823
39803
  }
39824
39804
  /**
39825
39805
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39880,12 +39860,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39880
39860
  * @param amount - Amount of coin.
39881
39861
  * @param assetId - Asset ID of coin.
39882
39862
  */
39883
- addCoinOutput(to, amount, assetId = BaseAssetId) {
39863
+ addCoinOutput(to, amount, assetId) {
39884
39864
  this.pushOutput({
39885
39865
  type: OutputType.Coin,
39886
39866
  to: addressify(to).toB256(),
39887
39867
  amount,
39888
- assetId
39868
+ assetId: assetId ?? this.baseAssetId
39889
39869
  });
39890
39870
  return this;
39891
39871
  }
@@ -39912,7 +39892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39912
39892
  * @param to - Address of the owner.
39913
39893
  * @param assetId - Asset ID of coin.
39914
39894
  */
39915
- addChangeOutput(to, assetId = BaseAssetId) {
39895
+ addChangeOutput(to, assetId) {
39916
39896
  const changeOutput = this.getChangeOutputs().find(
39917
39897
  (output3) => hexlify(output3.assetId) === assetId
39918
39898
  );
@@ -39920,7 +39900,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39920
39900
  this.pushOutput({
39921
39901
  type: OutputType.Change,
39922
39902
  to: addressify(to).toB256(),
39923
- assetId
39903
+ assetId: assetId ?? this.baseAssetId
39924
39904
  });
39925
39905
  }
39926
39906
  }
@@ -39971,6 +39951,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39971
39951
  * @param quantities - CoinQuantity Array.
39972
39952
  */
39973
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
+ };
39974
39960
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39975
39961
  if ("assetId" in input) {
39976
39962
  return input.assetId === assetId;
@@ -39980,12 +39966,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39980
39966
  const updateAssetInput = (assetId, quantity) => {
39981
39967
  const assetInput = findAssetInput(assetId);
39982
39968
  if (assetInput && "assetId" in assetInput) {
39983
- assetInput.id = hexlify(randomBytes3(33));
39969
+ assetInput.id = generateId();
39984
39970
  assetInput.amount = quantity;
39985
39971
  } else {
39986
39972
  this.addResources([
39987
39973
  {
39988
- id: hexlify(randomBytes3(33)),
39974
+ id: generateId(),
39989
39975
  amount: quantity,
39990
39976
  assetId,
39991
39977
  owner: resourcesOwner || Address.fromRandom(),
@@ -39996,7 +39982,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39996
39982
  ]);
39997
39983
  }
39998
39984
  };
39999
- updateAssetInput(BaseAssetId, bn(1e11));
39985
+ updateAssetInput(this.baseAssetId, bn(1e11));
40000
39986
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
40001
39987
  }
40002
39988
  /**
@@ -41419,6 +41405,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41419
41405
  gasPerByte: bn(feeParams.gasPerByte),
41420
41406
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41421
41407
  chainId: bn(consensusParameters.chainId),
41408
+ baseAssetId: consensusParameters.baseAssetId,
41422
41409
  gasCosts
41423
41410
  },
41424
41411
  gasCosts,
@@ -41661,6 +41648,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41661
41648
  } = this.getChain();
41662
41649
  return chainId.toNumber();
41663
41650
  }
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
+ }
41664
41662
  /**
41665
41663
  * Submits a transaction to the chain to be executed.
41666
41664
  *
@@ -41811,37 +41809,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41811
41809
  missingContractIds
41812
41810
  };
41813
41811
  }
41814
- /**
41815
- * Estimates the transaction gas and fee based on the provided transaction request.
41816
- * @param transactionRequest - The transaction request object.
41817
- * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
41818
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41819
- */
41820
- estimateTxGasAndFee(params) {
41821
- const { transactionRequest } = params;
41822
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41823
- const chainInfo = this.getChain();
41824
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41825
- transactionRequest.gasPrice = gasPrice;
41826
- const minGas = transactionRequest.calculateMinGas(chainInfo);
41827
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41828
- if (transactionRequest.type === TransactionType.Script) {
41829
- if (transactionRequest.gasLimit.eq(0)) {
41830
- transactionRequest.gasLimit = minGas;
41831
- transactionRequest.gasLimit = maxGasPerTx.sub(
41832
- transactionRequest.calculateMaxGas(chainInfo, minGas)
41833
- );
41834
- }
41835
- }
41836
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41837
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41838
- return {
41839
- minGas,
41840
- minFee,
41841
- maxGas,
41842
- maxFee
41843
- };
41844
- }
41845
41812
  /**
41846
41813
  * Executes a signed transaction without applying the states changes
41847
41814
  * on the chain.
@@ -41889,16 +41856,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41889
41856
  signatureCallback
41890
41857
  } = {}) {
41891
41858
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41892
- const { minGasPrice } = this.getGasConfig();
41893
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41859
+ const chainInfo = this.getChain();
41860
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41861
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
41894
41862
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41895
41863
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41896
41864
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41897
41865
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
41898
- if (isScriptTransaction) {
41899
- txRequestClone.gasLimit = bn(0);
41900
- }
41901
41866
  if (estimatePredicates) {
41867
+ if (isScriptTransaction) {
41868
+ txRequestClone.gasLimit = bn(0);
41869
+ }
41902
41870
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41903
41871
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
41904
41872
  }
@@ -41907,34 +41875,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41907
41875
  if (signatureCallback && isScriptTransaction) {
41908
41876
  await signatureCallback(txRequestClone);
41909
41877
  }
41910
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41911
- transactionRequest: txRequestClone
41912
- });
41878
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
41879
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
41913
41880
  let receipts = [];
41914
41881
  let missingContractIds = [];
41915
41882
  let outputVariables = 0;
41916
- let gasUsed = bn(0);
41917
41883
  if (isScriptTransaction && estimateTxDependencies) {
41918
41884
  txRequestClone.gasPrice = bn(0);
41885
+ txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
41919
41886
  const result = await this.estimateTxDependencies(txRequestClone);
41920
41887
  receipts = result.receipts;
41921
41888
  outputVariables = result.outputVariables;
41922
41889
  missingContractIds = result.missingContractIds;
41923
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41924
- txRequestClone.gasLimit = gasUsed;
41925
- txRequestClone.gasPrice = setGasPrice;
41926
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41927
- transactionRequest: txRequestClone
41928
- }));
41929
41890
  }
41891
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
41892
+ const usedFee = calculatePriceWithFactor(
41893
+ gasUsed,
41894
+ gasPrice,
41895
+ gasPriceFactor
41896
+ ).normalizeZeroToOne();
41897
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41898
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
41930
41899
  return {
41931
41900
  requiredQuantities: allQuantities,
41932
41901
  receipts,
41933
41902
  gasUsed,
41934
41903
  minGasPrice,
41935
- gasPrice: setGasPrice,
41904
+ gasPrice,
41936
41905
  minGas,
41937
41906
  maxGas,
41907
+ usedFee,
41938
41908
  minFee,
41939
41909
  maxFee,
41940
41910
  estimatedInputs: txRequestClone.inputs,
@@ -42718,8 +42688,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42718
42688
  * @param assetId - The asset ID to check the balance for.
42719
42689
  * @returns A promise that resolves to the balance amount.
42720
42690
  */
42721
- async getBalance(assetId = BaseAssetId) {
42722
- const amount = await this.provider.getBalance(this.address, assetId);
42691
+ async getBalance(assetId) {
42692
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42693
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42723
42694
  return amount;
42724
42695
  }
42725
42696
  /**
@@ -42757,9 +42728,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42757
42728
  * @returns A promise that resolves when the resources are added to the transaction.
42758
42729
  */
42759
42730
  async fund(request, coinQuantities, fee) {
42731
+ const baseAssetId = this.provider.getBaseAssetId();
42760
42732
  const updatedQuantities = addAmountToAsset({
42761
42733
  amount: bn(fee),
42762
- assetId: BaseAssetId,
42734
+ assetId: baseAssetId,
42763
42735
  coinQuantities
42764
42736
  });
42765
42737
  const quantitiesDict = {};
@@ -42783,8 +42755,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42783
42755
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42784
42756
  cachedUtxos.push(input.id);
42785
42757
  }
42786
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42787
- quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42758
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42759
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42788
42760
  cachedMessages.push(input.nonce);
42789
42761
  }
42790
42762
  }
@@ -42816,11 +42788,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42816
42788
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42817
42789
  * @returns A promise that resolves to the prepared transaction request.
42818
42790
  */
42819
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42791
+ async createTransfer(destination, amount, assetId, txParams = {}) {
42820
42792
  const { minGasPrice } = this.provider.getGasConfig();
42793
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42821
42794
  const params = { gasPrice: minGasPrice, ...txParams };
42822
42795
  const request = new ScriptTransactionRequest(params);
42823
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42796
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42824
42797
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
42825
42798
  estimateTxDependencies: true,
42826
42799
  resourcesOwner: this
@@ -42846,14 +42819,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42846
42819
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42847
42820
  * @returns A promise that resolves to the transaction response.
42848
42821
  */
42849
- async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42822
+ async transfer(destination, amount, assetId, txParams = {}) {
42850
42823
  if (bn(amount).lte(0)) {
42851
42824
  throw new FuelError(
42852
42825
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42853
42826
  "Transfer amount must be a positive number."
42854
42827
  );
42855
42828
  }
42856
- const request = await this.createTransfer(destination, amount, assetId, txParams);
42829
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42830
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42857
42831
  return this.sendTransaction(request, { estimateTxDependencies: false });
42858
42832
  }
42859
42833
  /**
@@ -42865,7 +42839,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42865
42839
  * @param txParams - The optional transaction parameters.
42866
42840
  * @returns A promise that resolves to the transaction response.
42867
42841
  */
42868
- async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42842
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
42869
42843
  if (bn(amount).lte(0)) {
42870
42844
  throw new FuelError(
42871
42845
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42874,11 +42848,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42874
42848
  }
42875
42849
  const contractAddress = Address.fromAddressOrString(contractId);
42876
42850
  const { minGasPrice } = this.provider.getGasConfig();
42851
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42877
42852
  const params = { gasPrice: minGasPrice, ...txParams };
42878
42853
  const { script, scriptData } = await assembleTransferToContractScript({
42879
42854
  hexlifiedContractId: contractAddress.toB256(),
42880
42855
  amountToTransfer: bn(amount),
42881
- assetId
42856
+ assetId: assetIdToTransfer
42882
42857
  });
42883
42858
  const request = new ScriptTransactionRequest({
42884
42859
  ...params,
@@ -42888,7 +42863,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42888
42863
  request.addContractInputAndOutput(contractAddress);
42889
42864
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42890
42865
  request,
42891
- [{ amount: bn(amount), assetId: String(assetId) }]
42866
+ [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42892
42867
  );
42893
42868
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
42894
42869
  this.validateGas({
@@ -42910,6 +42885,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42910
42885
  */
42911
42886
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42912
42887
  const { minGasPrice } = this.provider.getGasConfig();
42888
+ const baseAssetId = this.provider.getBaseAssetId();
42913
42889
  const recipientAddress = Address.fromAddressOrString(recipient);
42914
42890
  const recipientDataArray = arrayify(
42915
42891
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42924,7 +42900,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42924
42900
  ]);
42925
42901
  const params = { script, gasPrice: minGasPrice, ...txParams };
42926
42902
  const request = new ScriptTransactionRequest(params);
42927
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42903
+ const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42928
42904
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42929
42905
  request,
42930
42906
  forwardingQuantities
@@ -44388,12 +44364,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44388
44364
  };
44389
44365
 
44390
44366
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
44391
- var import_crypto16 = __toESM(__require("crypto"));
44367
+ var import_crypto15 = __toESM(__require("crypto"));
44392
44368
  var rnds8Pool = new Uint8Array(256);
44393
44369
  var poolPtr = rnds8Pool.length;
44394
44370
  function rng() {
44395
44371
  if (poolPtr > rnds8Pool.length - 16) {
44396
- import_crypto16.default.randomFillSync(rnds8Pool);
44372
+ import_crypto15.default.randomFillSync(rnds8Pool);
44397
44373
  poolPtr = 0;
44398
44374
  }
44399
44375
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -44409,9 +44385,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44409
44385
  }
44410
44386
 
44411
44387
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
44412
- var import_crypto17 = __toESM(__require("crypto"));
44388
+ var import_crypto16 = __toESM(__require("crypto"));
44413
44389
  var native_default = {
44414
- randomUUID: import_crypto17.default.randomUUID
44390
+ randomUUID: import_crypto16.default.randomUUID
44415
44391
  };
44416
44392
 
44417
44393
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -47887,8 +47863,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47887
47863
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47888
47864
  * @returns A promise that resolves to the prepared transaction request.
47889
47865
  */
47890
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47891
- const request = await super.createTransfer(destination, amount, assetId, txParams);
47866
+ async createTransfer(destination, amount, assetId, txParams = {}) {
47867
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47868
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47892
47869
  return this.populateTransactionPredicateData(request);
47893
47870
  }
47894
47871
  /**