@fuel-ts/account 0.0.0-rc-1976-20240410143455 → 0.0.0-rc-2034-20240410172045

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.

package/dist/index.js CHANGED
@@ -184,12 +184,14 @@ module.exports = __toCommonJS(src_exports);
184
184
 
185
185
  // src/account.ts
186
186
  var import_address4 = require("@fuel-ts/address");
187
+ var import_configs12 = require("@fuel-ts/address/configs");
187
188
  var import_errors16 = require("@fuel-ts/errors");
188
189
  var import_interfaces = require("@fuel-ts/interfaces");
189
190
  var import_math18 = require("@fuel-ts/math");
190
191
  var import_utils28 = require("@fuel-ts/utils");
191
192
 
192
193
  // src/providers/coin-quantity.ts
194
+ var import_configs = require("@fuel-ts/address/configs");
193
195
  var import_math = require("@fuel-ts/math");
194
196
  var import_utils = require("@fuel-ts/utils");
195
197
  var coinQuantityfy = (coinQuantityLike) => {
@@ -198,11 +200,11 @@ var coinQuantityfy = (coinQuantityLike) => {
198
200
  let max2;
199
201
  if (Array.isArray(coinQuantityLike)) {
200
202
  amount = coinQuantityLike[0];
201
- assetId = coinQuantityLike[1];
202
- max2 = coinQuantityLike[2];
203
+ assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
204
+ max2 = coinQuantityLike[2] ?? void 0;
203
205
  } else {
204
206
  amount = coinQuantityLike.amount;
205
- assetId = coinQuantityLike.assetId;
207
+ assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
206
208
  max2 = coinQuantityLike.max ?? void 0;
207
209
  }
208
210
  const bnAmount = (0, import_math.bn)(amount);
@@ -1171,7 +1173,7 @@ var MemoryCache = class {
1171
1173
  };
1172
1174
 
1173
1175
  // src/providers/transaction-request/input.ts
1174
- var import_configs = require("@fuel-ts/address/configs");
1176
+ var import_configs2 = require("@fuel-ts/address/configs");
1175
1177
  var import_errors3 = require("@fuel-ts/errors");
1176
1178
  var import_math2 = require("@fuel-ts/math");
1177
1179
  var import_transactions = require("@fuel-ts/transactions");
@@ -1185,7 +1187,7 @@ var inputify = (value) => {
1185
1187
  return {
1186
1188
  type: import_transactions.InputType.Coin,
1187
1189
  txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1188
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1190
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 33)),
1189
1191
  owner: (0, import_utils3.hexlify)(value.owner),
1190
1192
  amount: (0, import_math2.bn)(value.amount),
1191
1193
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1205,10 +1207,10 @@ var inputify = (value) => {
1205
1207
  case import_transactions.InputType.Contract: {
1206
1208
  return {
1207
1209
  type: import_transactions.InputType.Contract,
1208
- txID: import_configs.ZeroBytes32,
1210
+ txID: import_configs2.ZeroBytes32,
1209
1211
  outputIndex: 0,
1210
- balanceRoot: import_configs.ZeroBytes32,
1211
- stateRoot: import_configs.ZeroBytes32,
1212
+ balanceRoot: import_configs2.ZeroBytes32,
1213
+ stateRoot: import_configs2.ZeroBytes32,
1212
1214
  txPointer: {
1213
1215
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1214
1216
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1246,7 +1248,7 @@ var inputify = (value) => {
1246
1248
  };
1247
1249
 
1248
1250
  // src/providers/transaction-request/output.ts
1249
- var import_configs2 = require("@fuel-ts/address/configs");
1251
+ var import_configs3 = require("@fuel-ts/address/configs");
1250
1252
  var import_errors4 = require("@fuel-ts/errors");
1251
1253
  var import_math3 = require("@fuel-ts/math");
1252
1254
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1266,8 +1268,8 @@ var outputify = (value) => {
1266
1268
  return {
1267
1269
  type: import_transactions2.OutputType.Contract,
1268
1270
  inputIndex: value.inputIndex,
1269
- balanceRoot: import_configs2.ZeroBytes32,
1270
- stateRoot: import_configs2.ZeroBytes32
1271
+ balanceRoot: import_configs3.ZeroBytes32,
1272
+ stateRoot: import_configs3.ZeroBytes32
1271
1273
  };
1272
1274
  }
1273
1275
  case import_transactions2.OutputType.Change: {
@@ -1281,9 +1283,9 @@ var outputify = (value) => {
1281
1283
  case import_transactions2.OutputType.Variable: {
1282
1284
  return {
1283
1285
  type: import_transactions2.OutputType.Variable,
1284
- to: import_configs2.ZeroBytes32,
1286
+ to: import_configs3.ZeroBytes32,
1285
1287
  amount: (0, import_math3.bn)(0),
1286
- assetId: import_configs2.ZeroBytes32
1288
+ assetId: import_configs3.ZeroBytes32
1287
1289
  };
1288
1290
  }
1289
1291
  case import_transactions2.OutputType.ContractCreated: {
@@ -1304,7 +1306,8 @@ var outputify = (value) => {
1304
1306
 
1305
1307
  // src/providers/transaction-request/transaction-request.ts
1306
1308
  var import_address = require("@fuel-ts/address");
1307
- var import_configs6 = require("@fuel-ts/address/configs");
1309
+ var import_configs7 = require("@fuel-ts/address/configs");
1310
+ var import_crypto = require("@fuel-ts/crypto");
1308
1311
  var import_math7 = require("@fuel-ts/math");
1309
1312
  var import_transactions6 = require("@fuel-ts/transactions");
1310
1313
  var import_utils9 = require("@fuel-ts/utils");
@@ -1316,13 +1319,13 @@ var isCoin = (resource) => "id" in resource;
1316
1319
  var isMessage = (resource) => "recipient" in resource;
1317
1320
 
1318
1321
  // src/providers/utils/receipts.ts
1319
- var import_configs3 = require("@fuel-ts/address/configs");
1322
+ var import_configs4 = require("@fuel-ts/address/configs");
1320
1323
  var import_errors5 = require("@fuel-ts/errors");
1321
1324
  var import_math4 = require("@fuel-ts/math");
1322
1325
  var import_transactions3 = require("@fuel-ts/transactions");
1323
- var import_configs4 = require("@fuel-ts/transactions/configs");
1326
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1324
1327
  var import_utils5 = require("@fuel-ts/utils");
1325
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1328
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1326
1329
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1327
1330
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1328
1331
  (memo, receipt) => {
@@ -1339,7 +1342,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1339
1342
  missingOutputContractIds: []
1340
1343
  }
1341
1344
  );
1342
- var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1345
+ var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1343
1346
  function assembleReceiptByType(receipt) {
1344
1347
  const { receiptType } = receipt;
1345
1348
  switch (receiptType) {
@@ -1703,16 +1706,16 @@ function sleep(time) {
1703
1706
  var import_errors7 = require("@fuel-ts/errors");
1704
1707
  var import_math6 = require("@fuel-ts/math");
1705
1708
  var import_transactions5 = require("@fuel-ts/transactions");
1706
- var import_configs5 = require("@fuel-ts/transactions/configs");
1709
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1707
1710
  var assemblePanicError = (status) => {
1708
1711
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1709
1712
  const reason = status.reason;
1710
- if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1713
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1711
1714
  errorMessage = `${errorMessage}
1712
1715
 
1713
1716
  You can read more about this error at:
1714
1717
 
1715
- ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1718
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1716
1719
  }
1717
1720
  return { errorMessage, reason };
1718
1721
  };
@@ -1724,28 +1727,28 @@ var assembleRevertError = (receipts, logs) => {
1724
1727
  if (revertReceipt) {
1725
1728
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1726
1729
  switch (reasonHex) {
1727
- case import_configs5.FAILED_REQUIRE_SIGNAL: {
1730
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1728
1731
  reason = "require";
1729
1732
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1730
1733
  break;
1731
1734
  }
1732
- case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1735
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1733
1736
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1734
1737
  reason = "assert_eq";
1735
1738
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1736
1739
  break;
1737
1740
  }
1738
- case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1741
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1739
1742
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1740
1743
  reason = "assert_ne";
1741
1744
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1742
1745
  break;
1743
1746
  }
1744
- case import_configs5.FAILED_ASSERT_SIGNAL:
1747
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1745
1748
  reason = "assert";
1746
1749
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1747
1750
  break;
1748
- case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1751
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1749
1752
  reason = "MissingOutputChange";
1750
1753
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1751
1754
  break;
@@ -1819,8 +1822,6 @@ var BaseTransactionRequest = class {
1819
1822
  outputs = [];
1820
1823
  /** List of witnesses */
1821
1824
  witnesses = [];
1822
- /** Base asset ID - should be fetched from the chain */
1823
- baseAssetId;
1824
1825
  /**
1825
1826
  * Constructor for initializing a base transaction request.
1826
1827
  *
@@ -1833,9 +1834,8 @@ var BaseTransactionRequest = class {
1833
1834
  witnessLimit,
1834
1835
  inputs,
1835
1836
  outputs,
1836
- witnesses,
1837
- baseAssetId
1838
- }) {
1837
+ witnesses
1838
+ } = {}) {
1839
1839
  this.gasPrice = (0, import_math7.bn)(gasPrice);
1840
1840
  this.maturity = maturity ?? 0;
1841
1841
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
@@ -1843,7 +1843,6 @@ var BaseTransactionRequest = class {
1843
1843
  this.inputs = inputs ?? [];
1844
1844
  this.outputs = outputs ?? [];
1845
1845
  this.witnesses = witnesses ?? [];
1846
- this.baseAssetId = baseAssetId;
1847
1846
  }
1848
1847
  static getPolicyMeta(req) {
1849
1848
  let policyTypes = 0;
@@ -1936,7 +1935,7 @@ var BaseTransactionRequest = class {
1936
1935
  * @returns The index of the created witness.
1937
1936
  */
1938
1937
  addEmptyWitness() {
1939
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1938
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1940
1939
  return this.witnesses.length - 1;
1941
1940
  }
1942
1941
  /**
@@ -2067,9 +2066,11 @@ var BaseTransactionRequest = class {
2067
2066
  *
2068
2067
  * @param message - Message resource.
2069
2068
  * @param predicate - Predicate bytes.
2069
+ * @param predicateData - Predicate data bytes.
2070
2070
  */
2071
2071
  addMessageInput(message, predicate) {
2072
2072
  const { recipient, sender, amount } = message;
2073
+ const assetId = import_configs7.BaseAssetId;
2073
2074
  let witnessIndex;
2074
2075
  if (predicate) {
2075
2076
  witnessIndex = 0;
@@ -2089,7 +2090,7 @@ var BaseTransactionRequest = class {
2089
2090
  predicate: predicate?.bytes
2090
2091
  };
2091
2092
  this.pushInput(input);
2092
- this.addChangeOutput(recipient, this.baseAssetId);
2093
+ this.addChangeOutput(recipient, assetId);
2093
2094
  }
2094
2095
  /**
2095
2096
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2150,12 +2151,12 @@ var BaseTransactionRequest = class {
2150
2151
  * @param amount - Amount of coin.
2151
2152
  * @param assetId - Asset ID of coin.
2152
2153
  */
2153
- addCoinOutput(to, amount, assetId) {
2154
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2154
2155
  this.pushOutput({
2155
2156
  type: import_transactions6.OutputType.Coin,
2156
2157
  to: (0, import_address.addressify)(to).toB256(),
2157
2158
  amount,
2158
- assetId: assetId ?? this.baseAssetId
2159
+ assetId
2159
2160
  });
2160
2161
  return this;
2161
2162
  }
@@ -2182,7 +2183,7 @@ var BaseTransactionRequest = class {
2182
2183
  * @param to - Address of the owner.
2183
2184
  * @param assetId - Asset ID of coin.
2184
2185
  */
2185
- addChangeOutput(to, assetId) {
2186
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2186
2187
  const changeOutput = this.getChangeOutputs().find(
2187
2188
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2188
2189
  );
@@ -2190,7 +2191,7 @@ var BaseTransactionRequest = class {
2190
2191
  this.pushOutput({
2191
2192
  type: import_transactions6.OutputType.Change,
2192
2193
  to: (0, import_address.addressify)(to).toB256(),
2193
- assetId: assetId ?? this.baseAssetId
2194
+ assetId
2194
2195
  });
2195
2196
  }
2196
2197
  }
@@ -2241,12 +2242,6 @@ var BaseTransactionRequest = class {
2241
2242
  * @param quantities - CoinQuantity Array.
2242
2243
  */
2243
2244
  fundWithFakeUtxos(quantities, resourcesOwner) {
2244
- let idCounter = 0;
2245
- const generateId = () => {
2246
- const counterString = String(idCounter++);
2247
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2248
- return id;
2249
- };
2250
2245
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2251
2246
  if ("assetId" in input) {
2252
2247
  return input.assetId === assetId;
@@ -2256,12 +2251,12 @@ var BaseTransactionRequest = class {
2256
2251
  const updateAssetInput = (assetId, quantity) => {
2257
2252
  const assetInput = findAssetInput(assetId);
2258
2253
  if (assetInput && "assetId" in assetInput) {
2259
- assetInput.id = generateId();
2254
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(33));
2260
2255
  assetInput.amount = quantity;
2261
2256
  } else {
2262
2257
  this.addResources([
2263
2258
  {
2264
- id: generateId(),
2259
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(33)),
2265
2260
  amount: quantity,
2266
2261
  assetId,
2267
2262
  owner: resourcesOwner || import_address.Address.fromRandom(),
@@ -2272,7 +2267,7 @@ var BaseTransactionRequest = class {
2272
2267
  ]);
2273
2268
  }
2274
2269
  };
2275
- updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2270
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2276
2271
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2277
2272
  }
2278
2273
  /**
@@ -2322,13 +2317,13 @@ var BaseTransactionRequest = class {
2322
2317
  };
2323
2318
 
2324
2319
  // src/providers/transaction-request/create-transaction-request.ts
2325
- var import_configs8 = require("@fuel-ts/address/configs");
2320
+ var import_configs9 = require("@fuel-ts/address/configs");
2326
2321
  var import_math9 = require("@fuel-ts/math");
2327
2322
  var import_transactions8 = require("@fuel-ts/transactions");
2328
2323
  var import_utils13 = require("@fuel-ts/utils");
2329
2324
 
2330
2325
  // src/providers/transaction-request/hash-transaction.ts
2331
- var import_configs7 = require("@fuel-ts/address/configs");
2326
+ var import_configs8 = require("@fuel-ts/address/configs");
2332
2327
  var import_hasher = require("@fuel-ts/hasher");
2333
2328
  var import_math8 = require("@fuel-ts/math");
2334
2329
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2337,7 +2332,7 @@ var import_ramda2 = require("ramda");
2337
2332
  function hashTransaction(transactionRequest, chainId) {
2338
2333
  const transaction = transactionRequest.toTransaction();
2339
2334
  if (transaction.type === import_transactions7.TransactionType.Script) {
2340
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2335
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2341
2336
  }
2342
2337
  transaction.inputs = transaction.inputs.map((input) => {
2343
2338
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2359,10 +2354,10 @@ function hashTransaction(transactionRequest, chainId) {
2359
2354
  blockHeight: 0,
2360
2355
  txIndex: 0
2361
2356
  };
2362
- inputClone.txID = import_configs7.ZeroBytes32;
2357
+ inputClone.txID = import_configs8.ZeroBytes32;
2363
2358
  inputClone.outputIndex = 0;
2364
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2365
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2359
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2360
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2366
2361
  return inputClone;
2367
2362
  }
2368
2363
  default:
@@ -2373,8 +2368,8 @@ function hashTransaction(transactionRequest, chainId) {
2373
2368
  const outputClone = (0, import_ramda2.clone)(output);
2374
2369
  switch (outputClone.type) {
2375
2370
  case import_transactions7.OutputType.Contract: {
2376
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2377
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2371
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2372
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2378
2373
  return outputClone;
2379
2374
  }
2380
2375
  case import_transactions7.OutputType.Change: {
@@ -2382,9 +2377,9 @@ function hashTransaction(transactionRequest, chainId) {
2382
2377
  return outputClone;
2383
2378
  }
2384
2379
  case import_transactions7.OutputType.Variable: {
2385
- outputClone.to = import_configs7.ZeroBytes32;
2380
+ outputClone.to = import_configs8.ZeroBytes32;
2386
2381
  outputClone.amount = (0, import_math8.bn)(0);
2387
- outputClone.assetId = import_configs7.ZeroBytes32;
2382
+ outputClone.assetId = import_configs8.ZeroBytes32;
2388
2383
  return outputClone;
2389
2384
  }
2390
2385
  default:
@@ -2442,10 +2437,15 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2442
2437
  *
2443
2438
  * @param createTransactionRequestLike - The initial values for the instance
2444
2439
  */
2445
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2440
+ constructor({
2441
+ bytecodeWitnessIndex,
2442
+ salt,
2443
+ storageSlots,
2444
+ ...rest
2445
+ } = {}) {
2446
2446
  super(rest);
2447
2447
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2448
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2448
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2449
2449
  this.storageSlots = [...storageSlots ?? []];
2450
2450
  }
2451
2451
  /**
@@ -2463,7 +2463,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2463
2463
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2464
2464
  bytecodeWitnessIndex,
2465
2465
  storageSlotsCount: storageSlots.length,
2466
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2466
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2467
2467
  storageSlots
2468
2468
  };
2469
2469
  }
@@ -2513,7 +2513,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2513
2513
  // src/providers/transaction-request/script-transaction-request.ts
2514
2514
  var import_abi_coder = require("@fuel-ts/abi-coder");
2515
2515
  var import_address2 = require("@fuel-ts/address");
2516
- var import_configs9 = require("@fuel-ts/address/configs");
2516
+ var import_configs10 = require("@fuel-ts/address/configs");
2517
2517
  var import_math10 = require("@fuel-ts/math");
2518
2518
  var import_transactions9 = require("@fuel-ts/transactions");
2519
2519
  var import_utils15 = require("@fuel-ts/utils");
@@ -2566,7 +2566,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2566
2566
  *
2567
2567
  * @param scriptTransactionRequestLike - The initial values for the instance.
2568
2568
  */
2569
- constructor({ script, scriptData, gasLimit, ...rest }) {
2569
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2570
2570
  super(rest);
2571
2571
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2572
2572
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2587,7 +2587,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2587
2587
  ...super.getBaseTransaction(),
2588
2588
  scriptLength: script.length,
2589
2589
  scriptDataLength: scriptData.length,
2590
- receiptsRoot: import_configs9.ZeroBytes32,
2590
+ receiptsRoot: import_configs10.ZeroBytes32,
2591
2591
  script: (0, import_utils15.hexlify)(script),
2592
2592
  scriptData: (0, import_utils15.hexlify)(scriptData)
2593
2593
  };
@@ -2819,7 +2819,7 @@ var calculateTransactionFee = (params) => {
2819
2819
  };
2820
2820
 
2821
2821
  // src/providers/transaction-summary/operations.ts
2822
- var import_configs10 = require("@fuel-ts/address/configs");
2822
+ var import_configs11 = require("@fuel-ts/address/configs");
2823
2823
  var import_errors11 = require("@fuel-ts/errors");
2824
2824
  var import_math13 = require("@fuel-ts/math");
2825
2825
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3164,7 +3164,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3164
3164
  const { to: toAddress, assetId, amount } = receipt;
3165
3165
  let { from: fromAddress } = receipt;
3166
3166
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3167
- if (import_configs10.ZeroBytes32 === fromAddress) {
3167
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3168
3168
  const change = changeOutputs.find((output) => output.assetId === assetId);
3169
3169
  fromAddress = change?.to || fromAddress;
3170
3170
  }
@@ -3741,7 +3741,6 @@ var processGqlChain = (chain) => {
3741
3741
  gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3742
3742
  maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3743
3743
  chainId: (0, import_math15.bn)(consensusParameters.chainId),
3744
- baseAssetId: consensusParameters.baseAssetId,
3745
3744
  gasCosts
3746
3745
  },
3747
3746
  gasCosts,
@@ -3984,17 +3983,6 @@ var _Provider = class {
3984
3983
  } = this.getChain();
3985
3984
  return chainId.toNumber();
3986
3985
  }
3987
- /**
3988
- * Returns the base asset ID
3989
- *
3990
- * @returns A promise that resolves to the base asset ID
3991
- */
3992
- getBaseAssetId() {
3993
- const {
3994
- consensusParameters: { baseAssetId }
3995
- } = this.getChain();
3996
- return baseAssetId;
3997
- }
3998
3986
  /**
3999
3987
  * Submits a transaction to the chain to be executed.
4000
3988
  *
@@ -4145,6 +4133,36 @@ var _Provider = class {
4145
4133
  missingContractIds
4146
4134
  };
4147
4135
  }
4136
+ /**
4137
+ * Estimates the transaction gas and fee based on the provided transaction request.
4138
+ * @param transactionRequest - The transaction request object.
4139
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4140
+ */
4141
+ estimateTxGasAndFee(params) {
4142
+ const { transactionRequest } = params;
4143
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4144
+ const chainInfo = this.getChain();
4145
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4146
+ transactionRequest.gasPrice = gasPrice;
4147
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4148
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4149
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4150
+ if (transactionRequest.gasLimit.eq(0)) {
4151
+ transactionRequest.gasLimit = minGas;
4152
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4153
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4154
+ );
4155
+ }
4156
+ }
4157
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4158
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4159
+ return {
4160
+ minGas,
4161
+ minFee,
4162
+ maxGas,
4163
+ maxFee
4164
+ };
4165
+ }
4148
4166
  /**
4149
4167
  * Executes a signed transaction without applying the states changes
4150
4168
  * on the chain.
@@ -4192,17 +4210,16 @@ var _Provider = class {
4192
4210
  signatureCallback
4193
4211
  } = {}) {
4194
4212
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4195
- const chainInfo = this.getChain();
4196
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4197
- const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4213
+ const { minGasPrice } = this.getGasConfig();
4214
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4198
4215
  const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4199
4216
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4200
4217
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4201
4218
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4219
+ if (isScriptTransaction) {
4220
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4221
+ }
4202
4222
  if (estimatePredicates) {
4203
- if (isScriptTransaction) {
4204
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4205
- }
4206
4223
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4207
4224
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4208
4225
  }
@@ -4211,36 +4228,34 @@ var _Provider = class {
4211
4228
  if (signatureCallback && isScriptTransaction) {
4212
4229
  await signatureCallback(txRequestClone);
4213
4230
  }
4214
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4215
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4231
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4232
+ transactionRequest: txRequestClone
4233
+ });
4216
4234
  let receipts = [];
4217
4235
  let missingContractIds = [];
4218
4236
  let outputVariables = 0;
4237
+ let gasUsed = (0, import_math15.bn)(0);
4219
4238
  if (isScriptTransaction && estimateTxDependencies) {
4220
4239
  txRequestClone.gasPrice = (0, import_math15.bn)(0);
4221
- txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4222
4240
  const result = await this.estimateTxDependencies(txRequestClone);
4223
4241
  receipts = result.receipts;
4224
4242
  outputVariables = result.outputVariables;
4225
4243
  missingContractIds = result.missingContractIds;
4244
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4245
+ txRequestClone.gasLimit = gasUsed;
4246
+ txRequestClone.gasPrice = setGasPrice;
4247
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4248
+ transactionRequest: txRequestClone
4249
+ }));
4226
4250
  }
4227
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4228
- const usedFee = calculatePriceWithFactor(
4229
- gasUsed,
4230
- gasPrice,
4231
- gasPriceFactor
4232
- ).normalizeZeroToOne();
4233
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4234
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4235
4251
  return {
4236
4252
  requiredQuantities: allQuantities,
4237
4253
  receipts,
4238
4254
  gasUsed,
4239
4255
  minGasPrice,
4240
- gasPrice,
4256
+ gasPrice: setGasPrice,
4241
4257
  minGas,
4242
4258
  maxGas,
4243
- usedFee,
4244
4259
  minFee,
4245
4260
  maxFee,
4246
4261
  estimatedInputs: txRequestClone.inputs,
@@ -5031,9 +5046,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5031
5046
  * @param assetId - The asset ID to check the balance for.
5032
5047
  * @returns A promise that resolves to the balance amount.
5033
5048
  */
5034
- async getBalance(assetId) {
5035
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5036
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5049
+ async getBalance(assetId = import_configs12.BaseAssetId) {
5050
+ const amount = await this.provider.getBalance(this.address, assetId);
5037
5051
  return amount;
5038
5052
  }
5039
5053
  /**
@@ -5071,10 +5085,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5071
5085
  * @returns A promise that resolves when the resources are added to the transaction.
5072
5086
  */
5073
5087
  async fund(request, coinQuantities, fee) {
5074
- const baseAssetId = this.provider.getBaseAssetId();
5075
5088
  const updatedQuantities = addAmountToAsset({
5076
5089
  amount: (0, import_math18.bn)(fee),
5077
- assetId: baseAssetId,
5090
+ assetId: import_configs12.BaseAssetId,
5078
5091
  coinQuantities
5079
5092
  });
5080
5093
  const quantitiesDict = {};
@@ -5098,8 +5111,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5098
5111
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5099
5112
  cachedUtxos.push(input.id);
5100
5113
  }
5101
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5102
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5114
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5115
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5103
5116
  cachedMessages.push(input.nonce);
5104
5117
  }
5105
5118
  }
@@ -5131,13 +5144,11 @@ var Account = class extends import_interfaces.AbstractAccount {
5131
5144
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5132
5145
  * @returns A promise that resolves to the prepared transaction request.
5133
5146
  */
5134
- async createTransfer(destination, amount, assetId, txParams = {}) {
5147
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5135
5148
  const { minGasPrice } = this.provider.getGasConfig();
5136
- const baseAssetId = this.provider.getBaseAssetId();
5137
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5138
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5149
+ const params = { gasPrice: minGasPrice, ...txParams };
5139
5150
  const request = new ScriptTransactionRequest(params);
5140
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5151
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5141
5152
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5142
5153
  estimateTxDependencies: true,
5143
5154
  resourcesOwner: this
@@ -5163,15 +5174,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5163
5174
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5164
5175
  * @returns A promise that resolves to the transaction response.
5165
5176
  */
5166
- async transfer(destination, amount, assetId, txParams = {}) {
5177
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5167
5178
  if ((0, import_math18.bn)(amount).lte(0)) {
5168
5179
  throw new import_errors16.FuelError(
5169
5180
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5170
5181
  "Transfer amount must be a positive number."
5171
5182
  );
5172
5183
  }
5173
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5174
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5184
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5175
5185
  return this.sendTransaction(request, { estimateTxDependencies: false });
5176
5186
  }
5177
5187
  /**
@@ -5183,7 +5193,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5183
5193
  * @param txParams - The optional transaction parameters.
5184
5194
  * @returns A promise that resolves to the transaction response.
5185
5195
  */
5186
- async transferToContract(contractId, amount, assetId, txParams = {}) {
5196
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5187
5197
  if ((0, import_math18.bn)(amount).lte(0)) {
5188
5198
  throw new import_errors16.FuelError(
5189
5199
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -5192,13 +5202,11 @@ var Account = class extends import_interfaces.AbstractAccount {
5192
5202
  }
5193
5203
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5194
5204
  const { minGasPrice } = this.provider.getGasConfig();
5195
- const baseAssetId = this.provider.getBaseAssetId();
5196
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5197
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5205
+ const params = { gasPrice: minGasPrice, ...txParams };
5198
5206
  const { script, scriptData } = await assembleTransferToContractScript({
5199
5207
  hexlifiedContractId: contractAddress.toB256(),
5200
5208
  amountToTransfer: (0, import_math18.bn)(amount),
5201
- assetId: assetIdToTransfer
5209
+ assetId
5202
5210
  });
5203
5211
  const request = new ScriptTransactionRequest({
5204
5212
  ...params,
@@ -5208,7 +5216,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5208
5216
  request.addContractInputAndOutput(contractAddress);
5209
5217
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5210
5218
  request,
5211
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5219
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5212
5220
  );
5213
5221
  request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5214
5222
  this.validateGas({
@@ -5230,7 +5238,6 @@ var Account = class extends import_interfaces.AbstractAccount {
5230
5238
  */
5231
5239
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5232
5240
  const { minGasPrice } = this.provider.getGasConfig();
5233
- const baseAssetId = this.provider.getBaseAssetId();
5234
5241
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5235
5242
  const recipientDataArray = (0, import_utils28.arrayify)(
5236
5243
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5243,14 +5250,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5243
5250
  ...recipientDataArray,
5244
5251
  ...amountDataArray
5245
5252
  ]);
5246
- const params = {
5247
- script,
5248
- gasPrice: minGasPrice,
5249
- baseAssetId,
5250
- ...txParams
5251
- };
5253
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5252
5254
  const request = new ScriptTransactionRequest(params);
5253
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5255
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5254
5256
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5255
5257
  request,
5256
5258
  forwardingQuantities
@@ -5347,7 +5349,7 @@ var import_utils31 = require("@fuel-ts/utils");
5347
5349
 
5348
5350
  // src/signer/signer.ts
5349
5351
  var import_address5 = require("@fuel-ts/address");
5350
- var import_crypto = require("@fuel-ts/crypto");
5352
+ var import_crypto2 = require("@fuel-ts/crypto");
5351
5353
  var import_hasher2 = require("@fuel-ts/hasher");
5352
5354
  var import_math19 = require("@fuel-ts/math");
5353
5355
  var import_utils29 = require("@fuel-ts/utils");
@@ -5440,7 +5442,7 @@ var Signer = class {
5440
5442
  * @returns random 32-byte hashed
5441
5443
  */
5442
5444
  static generatePrivateKey(entropy) {
5443
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5445
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5444
5446
  }
5445
5447
  /**
5446
5448
  * Extended publicKey from a compact publicKey
@@ -5456,7 +5458,7 @@ var Signer = class {
5456
5458
 
5457
5459
  // src/wallet/keystore-wallet.ts
5458
5460
  var import_address6 = require("@fuel-ts/address");
5459
- var import_crypto2 = require("@fuel-ts/crypto");
5461
+ var import_crypto3 = require("@fuel-ts/crypto");
5460
5462
  var import_errors17 = require("@fuel-ts/errors");
5461
5463
  var import_utils30 = require("@fuel-ts/utils");
5462
5464
  var import_uuid = require("uuid");
@@ -5472,22 +5474,22 @@ var removeHexPrefix = (hexString) => {
5472
5474
  return hexString;
5473
5475
  };
5474
5476
  async function encryptKeystoreWallet(privateKey, address, password) {
5475
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5477
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5476
5478
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5477
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5478
- const key = (0, import_crypto2.scrypt)({
5479
- password: (0, import_crypto2.bufferFromString)(password),
5479
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5480
+ const key = (0, import_crypto3.scrypt)({
5481
+ password: (0, import_crypto3.bufferFromString)(password),
5480
5482
  salt,
5481
5483
  dklen: DEFAULT_KEY_SIZE,
5482
5484
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5483
5485
  r: DEFAULT_KDF_PARAMS_R,
5484
5486
  p: DEFAULT_KDF_PARAMS_P
5485
5487
  });
5486
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5487
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5488
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5489
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5488
5490
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5489
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5490
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5491
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5492
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5491
5493
  const keystore = {
5492
5494
  id: (0, import_uuid.v4)(),
5493
5495
  version: 3,
@@ -5495,15 +5497,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5495
5497
  crypto: {
5496
5498
  cipher: "aes-128-ctr",
5497
5499
  mac,
5498
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5499
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5500
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5501
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5500
5502
  kdf: "scrypt",
5501
5503
  kdfparams: {
5502
5504
  dklen: DEFAULT_KEY_SIZE,
5503
5505
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5504
5506
  p: DEFAULT_KDF_PARAMS_P,
5505
5507
  r: DEFAULT_KDF_PARAMS_R,
5506
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5508
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5507
5509
  }
5508
5510
  }
5509
5511
  };
@@ -5519,11 +5521,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5519
5521
  kdfparams: { dklen, n, r, p, salt }
5520
5522
  }
5521
5523
  } = keystoreWallet;
5522
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5523
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5524
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5525
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5526
- const key = (0, import_crypto2.scrypt)({
5524
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5525
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5526
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5527
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5528
+ const key = (0, import_crypto3.scrypt)({
5527
5529
  password: passwordBuffer,
5528
5530
  salt: saltBuffer,
5529
5531
  n,
@@ -5532,15 +5534,15 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5532
5534
  dklen
5533
5535
  });
5534
5536
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5535
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5536
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5537
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5538
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5537
5539
  if (mac !== macHash) {
5538
5540
  throw new import_errors17.FuelError(
5539
5541
  import_errors17.ErrorCode.INVALID_PASSWORD,
5540
5542
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5541
5543
  );
5542
5544
  }
5543
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5545
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5544
5546
  const privateKey = (0, import_utils30.hexlify)(buffer);
5545
5547
  return privateKey;
5546
5548
  }
@@ -5665,7 +5667,7 @@ var import_utils35 = require("@fuel-ts/utils");
5665
5667
  var import_ethers3 = require("ethers");
5666
5668
 
5667
5669
  // src/mnemonic/mnemonic.ts
5668
- var import_crypto3 = require("@fuel-ts/crypto");
5670
+ var import_crypto4 = require("@fuel-ts/crypto");
5669
5671
  var import_errors19 = require("@fuel-ts/errors");
5670
5672
  var import_hasher5 = require("@fuel-ts/hasher");
5671
5673
  var import_utils33 = require("@fuel-ts/utils");
@@ -8026,7 +8028,7 @@ var Mnemonic = class {
8026
8028
  * @returns A randomly generated mnemonic
8027
8029
  */
8028
8030
  static generate(size = 32, extraEntropy = "") {
8029
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8031
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8030
8032
  return Mnemonic.entropyToMnemonic(entropy);
8031
8033
  }
8032
8034
  };
@@ -8398,7 +8400,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8398
8400
 
8399
8401
  // src/wallet-manager/wallet-manager.ts
8400
8402
  var import_address9 = require("@fuel-ts/address");
8401
- var import_crypto4 = require("@fuel-ts/crypto");
8403
+ var import_crypto5 = require("@fuel-ts/crypto");
8402
8404
  var import_errors23 = require("@fuel-ts/errors");
8403
8405
  var import_events = require("events");
8404
8406
 
@@ -8726,7 +8728,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8726
8728
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8727
8729
  const data = await this.storage.getItem(this.STORAGE_KEY);
8728
8730
  if (data) {
8729
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8731
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8730
8732
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8731
8733
  }
8732
8734
  }
@@ -8735,7 +8737,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8735
8737
  */
8736
8738
  async saveState() {
8737
8739
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8738
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8740
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8739
8741
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8740
8742
  });
8741
8743
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -8813,6 +8815,7 @@ var StorageAbstract = class {
8813
8815
  // src/predicate/predicate.ts
8814
8816
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8815
8817
  var import_address10 = require("@fuel-ts/address");
8818
+ var import_configs13 = require("@fuel-ts/address/configs");
8816
8819
  var import_errors25 = require("@fuel-ts/errors");
8817
8820
  var import_transactions20 = require("@fuel-ts/transactions");
8818
8821
  var import_utils37 = require("@fuel-ts/utils");
@@ -8890,9 +8893,8 @@ var Predicate = class extends Account {
8890
8893
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8891
8894
  * @returns A promise that resolves to the prepared transaction request.
8892
8895
  */
8893
- async createTransfer(destination, amount, assetId, txParams = {}) {
8894
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8895
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8896
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8897
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8896
8898
  return this.populateTransactionPredicateData(request);
8897
8899
  }
8898
8900
  /**