@fuel-ts/account 0.0.0-rc-2143-20240424152333 → 0.0.0-rc-1976-20240424153519

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.

@@ -62,14 +62,12 @@ var import_utils31 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
- var import_configs12 = require("@fuel-ts/address/configs");
66
65
  var import_errors16 = require("@fuel-ts/errors");
67
66
  var import_interfaces = require("@fuel-ts/interfaces");
68
67
  var import_math18 = require("@fuel-ts/math");
69
68
  var import_utils28 = require("@fuel-ts/utils");
70
69
 
71
70
  // src/providers/coin-quantity.ts
72
- var import_configs = require("@fuel-ts/address/configs");
73
71
  var import_math = require("@fuel-ts/math");
74
72
  var import_utils = require("@fuel-ts/utils");
75
73
  var coinQuantityfy = (coinQuantityLike) => {
@@ -78,11 +76,11 @@ var coinQuantityfy = (coinQuantityLike) => {
78
76
  let max2;
79
77
  if (Array.isArray(coinQuantityLike)) {
80
78
  amount = coinQuantityLike[0];
81
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
82
- max2 = coinQuantityLike[2] ?? void 0;
79
+ assetId = coinQuantityLike[1];
80
+ max2 = coinQuantityLike[2];
83
81
  } else {
84
82
  amount = coinQuantityLike.amount;
85
- assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
83
+ assetId = coinQuantityLike.assetId;
86
84
  max2 = coinQuantityLike.max ?? void 0;
87
85
  }
88
86
  const bnAmount = (0, import_math.bn)(amount);
@@ -1061,7 +1059,7 @@ var MemoryCache = class {
1061
1059
 
1062
1060
  // src/providers/transaction-request/input.ts
1063
1061
  var import_abi_coder = require("@fuel-ts/abi-coder");
1064
- var import_configs2 = require("@fuel-ts/address/configs");
1062
+ var import_configs = require("@fuel-ts/address/configs");
1065
1063
  var import_errors3 = require("@fuel-ts/errors");
1066
1064
  var import_math2 = require("@fuel-ts/math");
1067
1065
  var import_transactions = require("@fuel-ts/transactions");
@@ -1095,10 +1093,10 @@ var inputify = (value) => {
1095
1093
  case import_transactions.InputType.Contract: {
1096
1094
  return {
1097
1095
  type: import_transactions.InputType.Contract,
1098
- txID: import_configs2.ZeroBytes32,
1096
+ txID: import_configs.ZeroBytes32,
1099
1097
  outputIndex: 0,
1100
- balanceRoot: import_configs2.ZeroBytes32,
1101
- stateRoot: import_configs2.ZeroBytes32,
1098
+ balanceRoot: import_configs.ZeroBytes32,
1099
+ stateRoot: import_configs.ZeroBytes32,
1102
1100
  txPointer: {
1103
1101
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1104
1102
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1136,7 +1134,7 @@ var inputify = (value) => {
1136
1134
  };
1137
1135
 
1138
1136
  // src/providers/transaction-request/output.ts
1139
- var import_configs3 = require("@fuel-ts/address/configs");
1137
+ var import_configs2 = require("@fuel-ts/address/configs");
1140
1138
  var import_errors4 = require("@fuel-ts/errors");
1141
1139
  var import_math3 = require("@fuel-ts/math");
1142
1140
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1156,8 +1154,8 @@ var outputify = (value) => {
1156
1154
  return {
1157
1155
  type: import_transactions2.OutputType.Contract,
1158
1156
  inputIndex: value.inputIndex,
1159
- balanceRoot: import_configs3.ZeroBytes32,
1160
- stateRoot: import_configs3.ZeroBytes32
1157
+ balanceRoot: import_configs2.ZeroBytes32,
1158
+ stateRoot: import_configs2.ZeroBytes32
1161
1159
  };
1162
1160
  }
1163
1161
  case import_transactions2.OutputType.Change: {
@@ -1171,9 +1169,9 @@ var outputify = (value) => {
1171
1169
  case import_transactions2.OutputType.Variable: {
1172
1170
  return {
1173
1171
  type: import_transactions2.OutputType.Variable,
1174
- to: import_configs3.ZeroBytes32,
1172
+ to: import_configs2.ZeroBytes32,
1175
1173
  amount: (0, import_math3.bn)(0),
1176
- assetId: import_configs3.ZeroBytes32
1174
+ assetId: import_configs2.ZeroBytes32
1177
1175
  };
1178
1176
  }
1179
1177
  case import_transactions2.OutputType.ContractCreated: {
@@ -1195,7 +1193,7 @@ var outputify = (value) => {
1195
1193
  // src/providers/transaction-request/transaction-request.ts
1196
1194
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1197
1195
  var import_address = require("@fuel-ts/address");
1198
- var import_configs7 = require("@fuel-ts/address/configs");
1196
+ var import_configs6 = require("@fuel-ts/address/configs");
1199
1197
  var import_crypto = require("@fuel-ts/crypto");
1200
1198
  var import_math7 = require("@fuel-ts/math");
1201
1199
  var import_transactions6 = require("@fuel-ts/transactions");
@@ -1205,13 +1203,13 @@ var import_utils9 = require("@fuel-ts/utils");
1205
1203
  var isCoin = (resource) => "id" in resource;
1206
1204
 
1207
1205
  // src/providers/utils/receipts.ts
1208
- var import_configs4 = require("@fuel-ts/address/configs");
1206
+ var import_configs3 = require("@fuel-ts/address/configs");
1209
1207
  var import_errors5 = require("@fuel-ts/errors");
1210
1208
  var import_math4 = require("@fuel-ts/math");
1211
1209
  var import_transactions3 = require("@fuel-ts/transactions");
1212
- var import_configs5 = require("@fuel-ts/transactions/configs");
1210
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1213
1211
  var import_utils5 = require("@fuel-ts/utils");
1214
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1212
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1215
1213
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1216
1214
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1217
1215
  (memo, receipt) => {
@@ -1228,7 +1226,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1228
1226
  missingOutputContractIds: []
1229
1227
  }
1230
1228
  );
1231
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1229
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1232
1230
  function assembleReceiptByType(receipt) {
1233
1231
  const { receiptType } = receipt;
1234
1232
  switch (receiptType) {
@@ -1533,16 +1531,16 @@ function sleep(time) {
1533
1531
  var import_errors7 = require("@fuel-ts/errors");
1534
1532
  var import_math6 = require("@fuel-ts/math");
1535
1533
  var import_transactions5 = require("@fuel-ts/transactions");
1536
- var import_configs6 = require("@fuel-ts/transactions/configs");
1534
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1537
1535
  var assemblePanicError = (status) => {
1538
1536
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1539
1537
  const reason = status.reason;
1540
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1538
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1541
1539
  errorMessage = `${errorMessage}
1542
1540
 
1543
1541
  You can read more about this error at:
1544
1542
 
1545
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1543
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1546
1544
  }
1547
1545
  return { errorMessage, reason };
1548
1546
  };
@@ -1554,28 +1552,28 @@ var assembleRevertError = (receipts, logs) => {
1554
1552
  if (revertReceipt) {
1555
1553
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1556
1554
  switch (reasonHex) {
1557
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1555
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1558
1556
  reason = "require";
1559
1557
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1560
1558
  break;
1561
1559
  }
1562
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1560
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1563
1561
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1564
1562
  reason = "assert_eq";
1565
1563
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1566
1564
  break;
1567
1565
  }
1568
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1566
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1569
1567
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1570
1568
  reason = "assert_ne";
1571
1569
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1572
1570
  break;
1573
1571
  }
1574
- case import_configs6.FAILED_ASSERT_SIGNAL:
1572
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1575
1573
  reason = "assert";
1576
1574
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1577
1575
  break;
1578
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1576
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1579
1577
  reason = "MissingOutputChange";
1580
1578
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1581
1579
  break;
@@ -1750,7 +1748,7 @@ var BaseTransactionRequest = class {
1750
1748
  * @returns The index of the created witness.
1751
1749
  */
1752
1750
  addEmptyWitness() {
1753
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1751
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1754
1752
  return this.witnesses.length - 1;
1755
1753
  }
1756
1754
  /**
@@ -1877,15 +1875,13 @@ var BaseTransactionRequest = class {
1877
1875
  }
1878
1876
  /**
1879
1877
  * Adds a single message input to the transaction and a change output for the
1880
- * baseAssetId, if one it was not added yet.
1878
+ * asset against the message
1881
1879
  *
1882
1880
  * @param message - Message resource.
1883
1881
  * @param predicate - Predicate bytes.
1884
- * @param predicateData - Predicate data bytes.
1885
1882
  */
1886
1883
  addMessageInput(message, predicate) {
1887
- const { recipient, sender, amount } = message;
1888
- const assetId = import_configs7.BaseAssetId;
1884
+ const { recipient, sender, amount, assetId } = message;
1889
1885
  let witnessIndex;
1890
1886
  if (predicate) {
1891
1887
  witnessIndex = 0;
@@ -1966,7 +1962,7 @@ var BaseTransactionRequest = class {
1966
1962
  * @param amount - Amount of coin.
1967
1963
  * @param assetId - Asset ID of coin.
1968
1964
  */
1969
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1965
+ addCoinOutput(to, amount, assetId) {
1970
1966
  this.pushOutput({
1971
1967
  type: import_transactions6.OutputType.Coin,
1972
1968
  to: (0, import_address.addressify)(to).toB256(),
@@ -1998,7 +1994,7 @@ var BaseTransactionRequest = class {
1998
1994
  * @param to - Address of the owner.
1999
1995
  * @param assetId - Asset ID of coin.
2000
1996
  */
2001
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
1997
+ addChangeOutput(to, assetId) {
2002
1998
  const changeOutput = this.getChangeOutputs().find(
2003
1999
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2004
2000
  );
@@ -2055,8 +2051,9 @@ var BaseTransactionRequest = class {
2055
2051
  * quantities array.
2056
2052
  *
2057
2053
  * @param quantities - CoinQuantity Array.
2054
+ * @param baseAssetId - The base asset to fund the transaction.
2058
2055
  */
2059
- fundWithFakeUtxos(quantities, resourcesOwner) {
2056
+ fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
2060
2057
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2061
2058
  if ("assetId" in input) {
2062
2059
  return input.assetId === assetId;
@@ -2082,7 +2079,7 @@ var BaseTransactionRequest = class {
2082
2079
  ]);
2083
2080
  }
2084
2081
  };
2085
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2082
+ updateAssetInput(baseAssetId, (0, import_math7.bn)(1e11));
2086
2083
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2087
2084
  }
2088
2085
  /**
@@ -2132,13 +2129,13 @@ var BaseTransactionRequest = class {
2132
2129
  };
2133
2130
 
2134
2131
  // src/providers/transaction-request/create-transaction-request.ts
2135
- var import_configs9 = require("@fuel-ts/address/configs");
2132
+ var import_configs8 = require("@fuel-ts/address/configs");
2136
2133
  var import_math9 = require("@fuel-ts/math");
2137
2134
  var import_transactions8 = require("@fuel-ts/transactions");
2138
2135
  var import_utils13 = require("@fuel-ts/utils");
2139
2136
 
2140
2137
  // src/providers/transaction-request/hash-transaction.ts
2141
- var import_configs8 = require("@fuel-ts/address/configs");
2138
+ var import_configs7 = require("@fuel-ts/address/configs");
2142
2139
  var import_hasher = require("@fuel-ts/hasher");
2143
2140
  var import_math8 = require("@fuel-ts/math");
2144
2141
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2147,7 +2144,7 @@ var import_ramda2 = require("ramda");
2147
2144
  function hashTransaction(transactionRequest, chainId) {
2148
2145
  const transaction = transactionRequest.toTransaction();
2149
2146
  if (transaction.type === import_transactions7.TransactionType.Script) {
2150
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2147
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2151
2148
  }
2152
2149
  transaction.inputs = transaction.inputs.map((input) => {
2153
2150
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2169,10 +2166,10 @@ function hashTransaction(transactionRequest, chainId) {
2169
2166
  blockHeight: 0,
2170
2167
  txIndex: 0
2171
2168
  };
2172
- inputClone.txID = import_configs8.ZeroBytes32;
2169
+ inputClone.txID = import_configs7.ZeroBytes32;
2173
2170
  inputClone.outputIndex = 0;
2174
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2175
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2171
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2172
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2176
2173
  return inputClone;
2177
2174
  }
2178
2175
  default:
@@ -2183,8 +2180,8 @@ function hashTransaction(transactionRequest, chainId) {
2183
2180
  const outputClone = (0, import_ramda2.clone)(output);
2184
2181
  switch (outputClone.type) {
2185
2182
  case import_transactions7.OutputType.Contract: {
2186
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2187
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2183
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2184
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2188
2185
  return outputClone;
2189
2186
  }
2190
2187
  case import_transactions7.OutputType.Change: {
@@ -2192,9 +2189,9 @@ function hashTransaction(transactionRequest, chainId) {
2192
2189
  return outputClone;
2193
2190
  }
2194
2191
  case import_transactions7.OutputType.Variable: {
2195
- outputClone.to = import_configs8.ZeroBytes32;
2192
+ outputClone.to = import_configs7.ZeroBytes32;
2196
2193
  outputClone.amount = (0, import_math8.bn)(0);
2197
- outputClone.assetId = import_configs8.ZeroBytes32;
2194
+ outputClone.assetId = import_configs7.ZeroBytes32;
2198
2195
  return outputClone;
2199
2196
  }
2200
2197
  default:
@@ -2252,15 +2249,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2252
2249
  *
2253
2250
  * @param createTransactionRequestLike - The initial values for the instance
2254
2251
  */
2255
- constructor({
2256
- bytecodeWitnessIndex,
2257
- salt,
2258
- storageSlots,
2259
- ...rest
2260
- } = {}) {
2252
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2261
2253
  super(rest);
2262
2254
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2263
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2255
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2264
2256
  this.storageSlots = [...storageSlots ?? []];
2265
2257
  }
2266
2258
  /**
@@ -2278,7 +2270,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2278
2270
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2279
2271
  bytecodeWitnessIndex,
2280
2272
  storageSlotsCount: storageSlots.length,
2281
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2273
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2282
2274
  storageSlots
2283
2275
  };
2284
2276
  }
@@ -2328,7 +2320,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2328
2320
  // src/providers/transaction-request/script-transaction-request.ts
2329
2321
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2330
2322
  var import_address2 = require("@fuel-ts/address");
2331
- var import_configs10 = require("@fuel-ts/address/configs");
2323
+ var import_configs9 = require("@fuel-ts/address/configs");
2332
2324
  var import_math10 = require("@fuel-ts/math");
2333
2325
  var import_transactions9 = require("@fuel-ts/transactions");
2334
2326
  var import_utils15 = require("@fuel-ts/utils");
@@ -2402,7 +2394,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2402
2394
  ...super.getBaseTransaction(),
2403
2395
  scriptLength: script.length,
2404
2396
  scriptDataLength: scriptData.length,
2405
- receiptsRoot: import_configs10.ZeroBytes32,
2397
+ receiptsRoot: import_configs9.ZeroBytes32,
2406
2398
  script: (0, import_utils15.hexlify)(script),
2407
2399
  scriptData: (0, import_utils15.hexlify)(scriptData)
2408
2400
  };
@@ -2634,7 +2626,7 @@ var calculateTransactionFee = (params) => {
2634
2626
  };
2635
2627
 
2636
2628
  // src/providers/transaction-summary/operations.ts
2637
- var import_configs11 = require("@fuel-ts/address/configs");
2629
+ var import_configs10 = require("@fuel-ts/address/configs");
2638
2630
  var import_errors11 = require("@fuel-ts/errors");
2639
2631
  var import_math13 = require("@fuel-ts/math");
2640
2632
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -2932,7 +2924,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
2932
2924
  const { to: toAddress, assetId, amount } = receipt;
2933
2925
  let { from: fromAddress } = receipt;
2934
2926
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2935
- if (import_configs11.ZeroBytes32 === fromAddress) {
2927
+ if (import_configs10.ZeroBytes32 === fromAddress) {
2936
2928
  const change = changeOutputs.find((output) => output.assetId === assetId);
2937
2929
  fromAddress = change?.to || fromAddress;
2938
2930
  }
@@ -3471,7 +3463,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3471
3463
  }
3472
3464
 
3473
3465
  // src/providers/utils/merge-quantities.ts
3474
- var mergeQuantities = (arr1, arr2) => {
3466
+ var mergeQuantities = (...coinQuantities) => {
3475
3467
  const resultMap = {};
3476
3468
  function addToMap({ amount, assetId }) {
3477
3469
  if (resultMap[assetId]) {
@@ -3480,8 +3472,7 @@ var mergeQuantities = (arr1, arr2) => {
3480
3472
  resultMap[assetId] = amount;
3481
3473
  }
3482
3474
  }
3483
- arr1.forEach(addToMap);
3484
- arr2.forEach(addToMap);
3475
+ coinQuantities.forEach((arr) => arr.forEach(addToMap));
3485
3476
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
3486
3477
  };
3487
3478
 
@@ -3509,6 +3500,7 @@ var processGqlChain = (chain) => {
3509
3500
  gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3510
3501
  maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3511
3502
  chainId: (0, import_math15.bn)(consensusParameters.chainId),
3503
+ baseAssetId: consensusParameters.baseAssetId,
3512
3504
  gasCosts
3513
3505
  },
3514
3506
  gasCosts,
@@ -3751,6 +3743,17 @@ var _Provider = class {
3751
3743
  } = this.getChain();
3752
3744
  return chainId.toNumber();
3753
3745
  }
3746
+ /**
3747
+ * Returns the base asset ID
3748
+ *
3749
+ * @returns A promise that resolves to the base asset ID
3750
+ */
3751
+ getBaseAssetId() {
3752
+ const {
3753
+ consensusParameters: { baseAssetId }
3754
+ } = this.getChain();
3755
+ return baseAssetId;
3756
+ }
3754
3757
  /**
3755
3758
  * Submits a transaction to the chain to be executed.
3756
3759
  *
@@ -3981,9 +3984,10 @@ var _Provider = class {
3981
3984
  const { minGasPrice } = this.getGasConfig();
3982
3985
  const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3983
3986
  const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
3987
+ const baseAssetId = this.getBaseAssetId();
3984
3988
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3985
3989
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3986
- txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3990
+ txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
3987
3991
  if (isScriptTransaction) {
3988
3992
  txRequestClone.gasLimit = (0, import_math15.bn)(0);
3989
3993
  }
@@ -4648,8 +4652,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4648
4652
  * @param assetId - The asset ID to check the balance for.
4649
4653
  * @returns A promise that resolves to the balance amount.
4650
4654
  */
4651
- async getBalance(assetId = import_configs12.BaseAssetId) {
4652
- const amount = await this.provider.getBalance(this.address, assetId);
4655
+ async getBalance(assetId) {
4656
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4657
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4653
4658
  return amount;
4654
4659
  }
4655
4660
  /**
@@ -4687,9 +4692,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4687
4692
  * @returns A promise that resolves when the resources are added to the transaction.
4688
4693
  */
4689
4694
  async fund(request, coinQuantities, fee) {
4695
+ const baseAssetId = this.provider.getBaseAssetId();
4690
4696
  const updatedQuantities = addAmountToAsset({
4691
4697
  amount: (0, import_math18.bn)(fee),
4692
- assetId: import_configs12.BaseAssetId,
4698
+ assetId: baseAssetId,
4693
4699
  coinQuantities
4694
4700
  });
4695
4701
  const quantitiesDict = {};
@@ -4713,8 +4719,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4713
4719
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4714
4720
  cachedUtxos.push(input.id);
4715
4721
  }
4716
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4717
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4722
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4723
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4718
4724
  cachedMessages.push(input.nonce);
4719
4725
  }
4720
4726
  }
@@ -4746,11 +4752,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4746
4752
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4747
4753
  * @returns A promise that resolves to the prepared transaction request.
4748
4754
  */
4749
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4755
+ async createTransfer(destination, amount, assetId, txParams = {}) {
4750
4756
  const { minGasPrice } = this.provider.getGasConfig();
4757
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4751
4758
  const params = { gasPrice: minGasPrice, ...txParams };
4752
4759
  const request = new ScriptTransactionRequest(params);
4753
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4760
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
4754
4761
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4755
4762
  estimateTxDependencies: true,
4756
4763
  resourcesOwner: this
@@ -4776,14 +4783,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4776
4783
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4777
4784
  * @returns A promise that resolves to the transaction response.
4778
4785
  */
4779
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4786
+ async transfer(destination, amount, assetId, txParams = {}) {
4780
4787
  if ((0, import_math18.bn)(amount).lte(0)) {
4781
4788
  throw new import_errors16.FuelError(
4782
4789
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4783
4790
  "Transfer amount must be a positive number."
4784
4791
  );
4785
4792
  }
4786
- const request = await this.createTransfer(destination, amount, assetId, txParams);
4793
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4794
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4787
4795
  return this.sendTransaction(request, { estimateTxDependencies: false });
4788
4796
  }
4789
4797
  /**
@@ -4795,7 +4803,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4795
4803
  * @param txParams - The optional transaction parameters.
4796
4804
  * @returns A promise that resolves to the transaction response.
4797
4805
  */
4798
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4806
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
4799
4807
  if ((0, import_math18.bn)(amount).lte(0)) {
4800
4808
  throw new import_errors16.FuelError(
4801
4809
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -4804,11 +4812,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4804
4812
  }
4805
4813
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4806
4814
  const { minGasPrice } = this.provider.getGasConfig();
4815
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4807
4816
  const params = { gasPrice: minGasPrice, ...txParams };
4808
4817
  const { script, scriptData } = await assembleTransferToContractScript({
4809
4818
  hexlifiedContractId: contractAddress.toB256(),
4810
4819
  amountToTransfer: (0, import_math18.bn)(amount),
4811
- assetId
4820
+ assetId: assetIdToTransfer
4812
4821
  });
4813
4822
  const request = new ScriptTransactionRequest({
4814
4823
  ...params,
@@ -4818,7 +4827,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4818
4827
  request.addContractInputAndOutput(contractAddress);
4819
4828
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4820
4829
  request,
4821
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4830
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
4822
4831
  );
4823
4832
  request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4824
4833
  this.validateGas({
@@ -4840,6 +4849,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4840
4849
  */
4841
4850
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
4851
  const { minGasPrice } = this.provider.getGasConfig();
4852
+ const baseAssetId = this.provider.getBaseAssetId();
4843
4853
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4844
4854
  const recipientDataArray = (0, import_utils28.arrayify)(
4845
4855
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4852,9 +4862,13 @@ var Account = class extends import_interfaces.AbstractAccount {
4852
4862
  ...recipientDataArray,
4853
4863
  ...amountDataArray
4854
4864
  ]);
4855
- const params = { script, gasPrice: minGasPrice, ...txParams };
4865
+ const params = {
4866
+ script,
4867
+ gasPrice: minGasPrice,
4868
+ ...txParams
4869
+ };
4856
4870
  const request = new ScriptTransactionRequest(params);
4857
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4871
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
4858
4872
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4859
4873
  request,
4860
4874
  forwardingQuantities
@@ -8018,7 +8032,7 @@ var generateTestWallet = async (provider, quantities) => {
8018
8032
  };
8019
8033
 
8020
8034
  // src/test-utils/launchNode.ts
8021
- var import_configs13 = require("@fuel-ts/address/configs");
8035
+ var import_configs11 = require("@fuel-ts/address/configs");
8022
8036
  var import_math21 = require("@fuel-ts/math");
8023
8037
  var import_utils36 = require("@fuel-ts/utils");
8024
8038
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
@@ -8064,7 +8078,6 @@ var launchNode = async ({
8064
8078
  ip,
8065
8079
  port,
8066
8080
  args = [],
8067
- fuelCorePath = void 0,
8068
8081
  useSystemFuelCore = false,
8069
8082
  loggingEnabled = true,
8070
8083
  debugEnabled = false,
@@ -8085,7 +8098,7 @@ var launchNode = async ({
8085
8098
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8086
8099
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8087
8100
  const graphQLStartSubstring = "Binding GraphQL provider to";
8088
- const binPath = fuelCorePath ?? (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8101
+ const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8089
8102
  const command = useSystemFuelCore ? "fuel-core" : binPath;
8090
8103
  const ipToUse = ip || "0.0.0.0";
8091
8104
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
@@ -8119,7 +8132,7 @@ var launchNode = async ({
8119
8132
  {
8120
8133
  owner: signer.address.toHexString(),
8121
8134
  amount: (0, import_math21.toHex)(1e9),
8122
- asset_id: import_configs13.BaseAssetId
8135
+ asset_id: import_utils36.defaultChainConfig?.consensus_parameters?.base_asset_id ?? import_configs11.ZeroBytes32
8123
8136
  }
8124
8137
  ]
8125
8138
  }
@@ -8185,9 +8198,10 @@ var launchNode = async ({
8185
8198
  })
8186
8199
  );
8187
8200
  var generateWallets = async (count, provider) => {
8201
+ const baseAssetId = provider.getBaseAssetId();
8188
8202
  const wallets = [];
8189
8203
  for (let i = 0; i < count; i += 1) {
8190
- const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
8204
+ const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8191
8205
  wallets.push(wallet);
8192
8206
  }
8193
8207
  return wallets;