@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.

@@ -32486,7 +32486,8 @@ This unreleased fuel-core build may include features and updates not yet support
32486
32486
  fee_params: {
32487
32487
  gas_price_factor: 92,
32488
32488
  gas_per_byte: 4
32489
- }
32489
+ },
32490
+ base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
32490
32491
  },
32491
32492
  gas_costs: {
32492
32493
  add: 1,
@@ -32710,7 +32711,7 @@ This unreleased fuel-core build may include features and updates not yet support
32710
32711
  var defaultConsensusKey = "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298";
32711
32712
 
32712
32713
  // ../crypto/dist/index.mjs
32713
- var import_crypto9 = __toESM(__require("crypto"), 1);
32714
+ var import_crypto8 = __toESM(__require("crypto"), 1);
32714
32715
 
32715
32716
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
32716
32717
  var version = "6.7.1";
@@ -33782,27 +33783,6 @@ This unreleased fuel-core build may include features and updates not yet support
33782
33783
  };
33783
33784
  Object.freeze(pbkdf22);
33784
33785
 
33785
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
33786
- var locked5 = false;
33787
- var _randomBytes = function(length) {
33788
- return new Uint8Array((0, import_crypto2.randomBytes)(length));
33789
- };
33790
- var __randomBytes = _randomBytes;
33791
- function randomBytes3(length) {
33792
- return __randomBytes(length);
33793
- }
33794
- randomBytes3._ = _randomBytes;
33795
- randomBytes3.lock = function() {
33796
- locked5 = true;
33797
- };
33798
- randomBytes3.register = function(func) {
33799
- if (locked5) {
33800
- throw new Error("randomBytes is locked");
33801
- }
33802
- __randomBytes = func;
33803
- };
33804
- Object.freeze(randomBytes3);
33805
-
33806
33786
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
33807
33787
  var BN_03 = BigInt(0);
33808
33788
  var BN_36 = BigInt(36);
@@ -34387,8 +34367,8 @@ This unreleased fuel-core build may include features and updates not yet support
34387
34367
  }
34388
34368
 
34389
34369
  // ../crypto/dist/index.mjs
34370
+ var import_crypto9 = __toESM(__require("crypto"), 1);
34390
34371
  var import_crypto10 = __toESM(__require("crypto"), 1);
34391
- var import_crypto11 = __toESM(__require("crypto"), 1);
34392
34372
  var scrypt3 = (params) => {
34393
34373
  const { password, salt, n, p, r, dklen } = params;
34394
34374
  const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
@@ -34397,7 +34377,7 @@ This unreleased fuel-core build may include features and updates not yet support
34397
34377
  var keccak2562 = (data) => keccak_256(data);
34398
34378
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
34399
34379
  var randomBytes4 = (length) => {
34400
- const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
34380
+ const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
34401
34381
  return randomValues;
34402
34382
  };
34403
34383
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -34412,7 +34392,7 @@ This unreleased fuel-core build may include features and updates not yet support
34412
34392
  const salt = randomBytes4(32);
34413
34393
  const secret = keyFromPassword(password, salt);
34414
34394
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
34415
- const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
34395
+ const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
34416
34396
  let cipherData = cipher.update(dataBuffer);
34417
34397
  cipherData = Buffer.concat([cipherData, cipher.final()]);
34418
34398
  return {
@@ -34426,7 +34406,7 @@ This unreleased fuel-core build may include features and updates not yet support
34426
34406
  const salt = bufferFromString(keystore.salt);
34427
34407
  const secret = keyFromPassword(password, salt);
34428
34408
  const encryptedText = bufferFromString(keystore.data);
34429
- const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
34409
+ const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
34430
34410
  const decrypted = decipher.update(encryptedText);
34431
34411
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
34432
34412
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -34437,12 +34417,12 @@ This unreleased fuel-core build may include features and updates not yet support
34437
34417
  }
34438
34418
  };
34439
34419
  async function encryptJsonWalletData(data, key, iv) {
34440
- const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34420
+ const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34441
34421
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
34442
34422
  return new Uint8Array(encrypted);
34443
34423
  }
34444
34424
  async function decryptJsonWalletData(data, key, iv) {
34445
- const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34425
+ const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34446
34426
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
34447
34427
  return new Uint8Array(decrypted);
34448
34428
  }
@@ -34776,10 +34756,6 @@ This unreleased fuel-core build may include features and updates not yet support
34776
34756
  }
34777
34757
  };
34778
34758
 
34779
- // ../address/dist/configs.mjs
34780
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
34781
- var BaseAssetId = ZeroBytes32;
34782
-
34783
34759
  // ../math/dist/index.mjs
34784
34760
  var import_bn = __toESM(require_bn(), 1);
34785
34761
  var DEFAULT_PRECISION = 9;
@@ -35010,11 +34986,11 @@ This unreleased fuel-core build may include features and updates not yet support
35010
34986
  let max2;
35011
34987
  if (Array.isArray(coinQuantityLike)) {
35012
34988
  amount = coinQuantityLike[0];
35013
- assetId = coinQuantityLike[1] ?? BaseAssetId;
35014
- max2 = coinQuantityLike[2] ?? void 0;
34989
+ assetId = coinQuantityLike[1];
34990
+ max2 = coinQuantityLike[2];
35015
34991
  } else {
35016
34992
  amount = coinQuantityLike.amount;
35017
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
34993
+ assetId = coinQuantityLike.assetId;
35018
34994
  max2 = coinQuantityLike.max ?? void 0;
35019
34995
  }
35020
34996
  const bnAmount = bn(amount);
@@ -42340,6 +42316,9 @@ ${MessageCoinFragmentFragmentDoc}`;
42340
42316
  }
42341
42317
  };
42342
42318
 
42319
+ // ../address/dist/configs.mjs
42320
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
42321
+
42343
42322
  // src/providers/transaction-request/input.ts
42344
42323
  var inputify = (value) => {
42345
42324
  const { type: type3 } = value;
@@ -42350,7 +42329,7 @@ ${MessageCoinFragmentFragmentDoc}`;
42350
42329
  return {
42351
42330
  type: InputType.Coin,
42352
42331
  txID: hexlify(arrayify(value.id).slice(0, 32)),
42353
- outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
42332
+ outputIndex: arrayify(value.id)[32],
42354
42333
  owner: hexlify(value.owner),
42355
42334
  amount: bn(value.amount),
42356
42335
  assetId: hexlify(value.assetId),
@@ -42940,6 +42919,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42940
42919
  outputs = [];
42941
42920
  /** List of witnesses */
42942
42921
  witnesses = [];
42922
+ /** Base asset ID - should be fetched from the chain */
42923
+ baseAssetId = ZeroBytes32;
42943
42924
  /**
42944
42925
  * Constructor for initializing a base transaction request.
42945
42926
  *
@@ -42952,7 +42933,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42952
42933
  witnessLimit,
42953
42934
  inputs,
42954
42935
  outputs,
42955
- witnesses
42936
+ witnesses,
42937
+ baseAssetId
42956
42938
  } = {}) {
42957
42939
  this.gasPrice = bn(gasPrice);
42958
42940
  this.maturity = maturity ?? 0;
@@ -42961,6 +42943,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42961
42943
  this.inputs = inputs ?? [];
42962
42944
  this.outputs = outputs ?? [];
42963
42945
  this.witnesses = witnesses ?? [];
42946
+ this.baseAssetId = baseAssetId ?? ZeroBytes32;
42964
42947
  }
42965
42948
  static getPolicyMeta(req) {
42966
42949
  let policyTypes = 0;
@@ -43184,11 +43167,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43184
43167
  *
43185
43168
  * @param message - Message resource.
43186
43169
  * @param predicate - Predicate bytes.
43187
- * @param predicateData - Predicate data bytes.
43188
43170
  */
43189
43171
  addMessageInput(message, predicate) {
43190
43172
  const { recipient, sender, amount } = message;
43191
- const assetId = BaseAssetId;
43192
43173
  let witnessIndex;
43193
43174
  if (predicate) {
43194
43175
  witnessIndex = 0;
@@ -43208,7 +43189,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43208
43189
  predicate: predicate?.bytes
43209
43190
  };
43210
43191
  this.pushInput(input);
43211
- this.addChangeOutput(recipient, assetId);
43192
+ this.addChangeOutput(recipient, this.baseAssetId);
43212
43193
  }
43213
43194
  /**
43214
43195
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -43269,12 +43250,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43269
43250
  * @param amount - Amount of coin.
43270
43251
  * @param assetId - Asset ID of coin.
43271
43252
  */
43272
- addCoinOutput(to, amount, assetId = BaseAssetId) {
43253
+ addCoinOutput(to, amount, assetId) {
43273
43254
  this.pushOutput({
43274
43255
  type: OutputType.Coin,
43275
43256
  to: addressify(to).toB256(),
43276
43257
  amount,
43277
- assetId
43258
+ assetId: assetId ?? this.baseAssetId
43278
43259
  });
43279
43260
  return this;
43280
43261
  }
@@ -43301,7 +43282,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43301
43282
  * @param to - Address of the owner.
43302
43283
  * @param assetId - Asset ID of coin.
43303
43284
  */
43304
- addChangeOutput(to, assetId = BaseAssetId) {
43285
+ addChangeOutput(to, assetId) {
43305
43286
  const changeOutput = this.getChangeOutputs().find(
43306
43287
  (output3) => hexlify(output3.assetId) === assetId
43307
43288
  );
@@ -43309,7 +43290,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43309
43290
  this.pushOutput({
43310
43291
  type: OutputType.Change,
43311
43292
  to: addressify(to).toB256(),
43312
- assetId
43293
+ assetId: assetId ?? this.baseAssetId
43313
43294
  });
43314
43295
  }
43315
43296
  }
@@ -43360,6 +43341,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43360
43341
  * @param quantities - CoinQuantity Array.
43361
43342
  */
43362
43343
  fundWithFakeUtxos(quantities, resourcesOwner) {
43344
+ let idCounter = 0;
43345
+ const generateId = () => {
43346
+ const counterString = String(idCounter++);
43347
+ const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
43348
+ return id;
43349
+ };
43363
43350
  const findAssetInput = (assetId) => this.inputs.find((input) => {
43364
43351
  if ("assetId" in input) {
43365
43352
  return input.assetId === assetId;
@@ -43369,12 +43356,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43369
43356
  const updateAssetInput = (assetId, quantity) => {
43370
43357
  const assetInput = findAssetInput(assetId);
43371
43358
  if (assetInput && "assetId" in assetInput) {
43372
- assetInput.id = hexlify(randomBytes3(33));
43359
+ assetInput.id = generateId();
43373
43360
  assetInput.amount = quantity;
43374
43361
  } else {
43375
43362
  this.addResources([
43376
43363
  {
43377
- id: hexlify(randomBytes3(33)),
43364
+ id: generateId(),
43378
43365
  amount: quantity,
43379
43366
  assetId,
43380
43367
  owner: resourcesOwner || Address.fromRandom(),
@@ -43385,7 +43372,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43385
43372
  ]);
43386
43373
  }
43387
43374
  };
43388
- updateAssetInput(BaseAssetId, bn(1e11));
43375
+ updateAssetInput(this.baseAssetId, bn(1e11));
43389
43376
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
43390
43377
  }
43391
43378
  /**
@@ -44761,6 +44748,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44761
44748
  gasPerByte: bn(feeParams.gasPerByte),
44762
44749
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
44763
44750
  chainId: bn(consensusParameters.chainId),
44751
+ baseAssetId: consensusParameters.baseAssetId,
44764
44752
  gasCosts
44765
44753
  },
44766
44754
  gasCosts,
@@ -45003,6 +44991,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45003
44991
  } = this.getChain();
45004
44992
  return chainId.toNumber();
45005
44993
  }
44994
+ /**
44995
+ * Returns the base asset ID
44996
+ *
44997
+ * @returns A promise that resolves to the base asset ID
44998
+ */
44999
+ getBaseAssetId() {
45000
+ const {
45001
+ consensusParameters: { baseAssetId }
45002
+ } = this.getChain();
45003
+ return baseAssetId;
45004
+ }
45006
45005
  /**
45007
45006
  * Submits a transaction to the chain to be executed.
45008
45007
  *
@@ -45153,37 +45152,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45153
45152
  missingContractIds
45154
45153
  };
45155
45154
  }
45156
- /**
45157
- * Estimates the transaction gas and fee based on the provided transaction request.
45158
- * @param transactionRequest - The transaction request object.
45159
- * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
45160
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
45161
- */
45162
- estimateTxGasAndFee(params) {
45163
- const { transactionRequest } = params;
45164
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
45165
- const chainInfo = this.getChain();
45166
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
45167
- transactionRequest.gasPrice = gasPrice;
45168
- const minGas = transactionRequest.calculateMinGas(chainInfo);
45169
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45170
- if (transactionRequest.type === TransactionType.Script) {
45171
- if (transactionRequest.gasLimit.eq(0)) {
45172
- transactionRequest.gasLimit = minGas;
45173
- transactionRequest.gasLimit = maxGasPerTx.sub(
45174
- transactionRequest.calculateMaxGas(chainInfo, minGas)
45175
- );
45176
- }
45177
- }
45178
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
45179
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45180
- return {
45181
- minGas,
45182
- minFee,
45183
- maxGas,
45184
- maxFee
45185
- };
45186
- }
45187
45155
  /**
45188
45156
  * Executes a signed transaction without applying the states changes
45189
45157
  * on the chain.
@@ -45231,16 +45199,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45231
45199
  signatureCallback
45232
45200
  } = {}) {
45233
45201
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
45234
- const { minGasPrice } = this.getGasConfig();
45235
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
45202
+ const chainInfo = this.getChain();
45203
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
45204
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
45236
45205
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
45237
45206
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
45238
45207
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
45239
45208
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
45240
- if (isScriptTransaction) {
45241
- txRequestClone.gasLimit = bn(0);
45242
- }
45243
45209
  if (estimatePredicates) {
45210
+ if (isScriptTransaction) {
45211
+ txRequestClone.gasLimit = bn(0);
45212
+ }
45244
45213
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
45245
45214
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
45246
45215
  }
@@ -45249,34 +45218,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45249
45218
  if (signatureCallback && isScriptTransaction) {
45250
45219
  await signatureCallback(txRequestClone);
45251
45220
  }
45252
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
45253
- transactionRequest: txRequestClone
45254
- });
45221
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
45222
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
45255
45223
  let receipts = [];
45256
45224
  let missingContractIds = [];
45257
45225
  let outputVariables = 0;
45258
- let gasUsed = bn(0);
45259
45226
  if (isScriptTransaction && estimateTxDependencies) {
45260
45227
  txRequestClone.gasPrice = bn(0);
45228
+ txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
45261
45229
  const result = await this.estimateTxDependencies(txRequestClone);
45262
45230
  receipts = result.receipts;
45263
45231
  outputVariables = result.outputVariables;
45264
45232
  missingContractIds = result.missingContractIds;
45265
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
45266
- txRequestClone.gasLimit = gasUsed;
45267
- txRequestClone.gasPrice = setGasPrice;
45268
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
45269
- transactionRequest: txRequestClone
45270
- }));
45271
45233
  }
45234
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
45235
+ const usedFee = calculatePriceWithFactor(
45236
+ gasUsed,
45237
+ gasPrice,
45238
+ gasPriceFactor
45239
+ ).normalizeZeroToOne();
45240
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45241
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
45272
45242
  return {
45273
45243
  requiredQuantities: allQuantities,
45274
45244
  receipts,
45275
45245
  gasUsed,
45276
45246
  minGasPrice,
45277
- gasPrice: setGasPrice,
45247
+ gasPrice,
45278
45248
  minGas,
45279
45249
  maxGas,
45250
+ usedFee,
45280
45251
  minFee,
45281
45252
  maxFee,
45282
45253
  estimatedInputs: txRequestClone.inputs,
@@ -45892,8 +45863,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45892
45863
  * @param assetId - The asset ID to check the balance for.
45893
45864
  * @returns A promise that resolves to the balance amount.
45894
45865
  */
45895
- async getBalance(assetId = BaseAssetId) {
45896
- const amount = await this.provider.getBalance(this.address, assetId);
45866
+ async getBalance(assetId) {
45867
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
45868
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
45897
45869
  return amount;
45898
45870
  }
45899
45871
  /**
@@ -45931,9 +45903,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45931
45903
  * @returns A promise that resolves when the resources are added to the transaction.
45932
45904
  */
45933
45905
  async fund(request, coinQuantities, fee) {
45906
+ const baseAssetId = this.provider.getBaseAssetId();
45934
45907
  const updatedQuantities = addAmountToAsset({
45935
45908
  amount: bn(fee),
45936
- assetId: BaseAssetId,
45909
+ assetId: baseAssetId,
45937
45910
  coinQuantities
45938
45911
  });
45939
45912
  const quantitiesDict = {};
@@ -45957,8 +45930,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45957
45930
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
45958
45931
  cachedUtxos.push(input.id);
45959
45932
  }
45960
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
45961
- quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
45933
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
45934
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
45962
45935
  cachedMessages.push(input.nonce);
45963
45936
  }
45964
45937
  }
@@ -45990,11 +45963,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
45990
45963
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
45991
45964
  * @returns A promise that resolves to the prepared transaction request.
45992
45965
  */
45993
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
45966
+ async createTransfer(destination, amount, assetId, txParams = {}) {
45994
45967
  const { minGasPrice } = this.provider.getGasConfig();
45968
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
45995
45969
  const params = { gasPrice: minGasPrice, ...txParams };
45996
45970
  const request = new ScriptTransactionRequest(params);
45997
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
45971
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
45998
45972
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
45999
45973
  estimateTxDependencies: true,
46000
45974
  resourcesOwner: this
@@ -46020,14 +45994,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46020
45994
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
46021
45995
  * @returns A promise that resolves to the transaction response.
46022
45996
  */
46023
- async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
45997
+ async transfer(destination, amount, assetId, txParams = {}) {
46024
45998
  if (bn(amount).lte(0)) {
46025
45999
  throw new FuelError(
46026
46000
  ErrorCode.INVALID_TRANSFER_AMOUNT,
46027
46001
  "Transfer amount must be a positive number."
46028
46002
  );
46029
46003
  }
46030
- const request = await this.createTransfer(destination, amount, assetId, txParams);
46004
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
46005
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
46031
46006
  return this.sendTransaction(request, { estimateTxDependencies: false });
46032
46007
  }
46033
46008
  /**
@@ -46039,7 +46014,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46039
46014
  * @param txParams - The optional transaction parameters.
46040
46015
  * @returns A promise that resolves to the transaction response.
46041
46016
  */
46042
- async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
46017
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
46043
46018
  if (bn(amount).lte(0)) {
46044
46019
  throw new FuelError(
46045
46020
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -46048,11 +46023,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46048
46023
  }
46049
46024
  const contractAddress = Address.fromAddressOrString(contractId);
46050
46025
  const { minGasPrice } = this.provider.getGasConfig();
46026
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
46051
46027
  const params = { gasPrice: minGasPrice, ...txParams };
46052
46028
  const { script, scriptData } = await assembleTransferToContractScript({
46053
46029
  hexlifiedContractId: contractAddress.toB256(),
46054
46030
  amountToTransfer: bn(amount),
46055
- assetId
46031
+ assetId: assetIdToTransfer
46056
46032
  });
46057
46033
  const request = new ScriptTransactionRequest({
46058
46034
  ...params,
@@ -46062,7 +46038,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46062
46038
  request.addContractInputAndOutput(contractAddress);
46063
46039
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
46064
46040
  request,
46065
- [{ amount: bn(amount), assetId: String(assetId) }]
46041
+ [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
46066
46042
  );
46067
46043
  request.gasLimit = bn(params.gasLimit ?? gasUsed);
46068
46044
  this.validateGas({
@@ -46084,6 +46060,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46084
46060
  */
46085
46061
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
46086
46062
  const { minGasPrice } = this.provider.getGasConfig();
46063
+ const baseAssetId = this.provider.getBaseAssetId();
46087
46064
  const recipientAddress = Address.fromAddressOrString(recipient);
46088
46065
  const recipientDataArray = arrayify(
46089
46066
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -46098,7 +46075,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
46098
46075
  ]);
46099
46076
  const params = { script, gasPrice: minGasPrice, ...txParams };
46100
46077
  const request = new ScriptTransactionRequest(params);
46101
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
46078
+ const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
46102
46079
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
46103
46080
  request,
46104
46081
  forwardingQuantities
@@ -47562,12 +47539,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47562
47539
  };
47563
47540
 
47564
47541
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
47565
- var import_crypto16 = __toESM(__require("crypto"));
47542
+ var import_crypto15 = __toESM(__require("crypto"));
47566
47543
  var rnds8Pool = new Uint8Array(256);
47567
47544
  var poolPtr = rnds8Pool.length;
47568
47545
  function rng() {
47569
47546
  if (poolPtr > rnds8Pool.length - 16) {
47570
- import_crypto16.default.randomFillSync(rnds8Pool);
47547
+ import_crypto15.default.randomFillSync(rnds8Pool);
47571
47548
  poolPtr = 0;
47572
47549
  }
47573
47550
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -47583,9 +47560,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47583
47560
  }
47584
47561
 
47585
47562
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
47586
- var import_crypto17 = __toESM(__require("crypto"));
47563
+ var import_crypto16 = __toESM(__require("crypto"));
47587
47564
  var native_default = {
47588
- randomUUID: import_crypto17.default.randomUUID
47565
+ randomUUID: import_crypto16.default.randomUUID
47589
47566
  };
47590
47567
 
47591
47568
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -50565,7 +50542,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50565
50542
 
50566
50543
  // src/test-utils/launchNode.ts
50567
50544
  var import_child_process = __require("child_process");
50568
- var import_crypto21 = __require("crypto");
50545
+ var import_crypto20 = __require("crypto");
50569
50546
  var import_fs2 = __require("fs");
50570
50547
  var import_os = __toESM(__require("os"));
50571
50548
  var import_path8 = __toESM(__require("path"));
@@ -50637,7 +50614,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50637
50614
  })).toString();
50638
50615
  let chainConfigPathToUse;
50639
50616
  const prefix = basePath || import_os.default.tmpdir();
50640
- const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
50617
+ const suffix = basePath ? "" : (0, import_crypto20.randomUUID)();
50641
50618
  const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
50642
50619
  if (chainConfigPath) {
50643
50620
  chainConfigPathToUse = chainConfigPath;
@@ -50660,7 +50637,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50660
50637
  {
50661
50638
  owner: signer.address.toHexString(),
50662
50639
  amount: toHex(1e9),
50663
- asset_id: BaseAssetId
50640
+ asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes32
50664
50641
  }
50665
50642
  ]
50666
50643
  }
@@ -50726,9 +50703,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
50726
50703
  })
50727
50704
  );
50728
50705
  var generateWallets = async (count, provider) => {
50706
+ const baseAssetId = provider.getBaseAssetId();
50729
50707
  const wallets = [];
50730
50708
  for (let i = 0; i < count; i += 1) {
50731
- const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
50709
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
50732
50710
  wallets.push(wallet);
50733
50711
  }
50734
50712
  return wallets;