@fuel-ts/account 0.0.0-rc-2037-20240412171107 → 0.0.0-rc-1976-20240415100843

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.

Files changed (32) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +98 -65
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +134 -103
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +96 -65
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts +1 -9
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/coin-quantity.d.ts +2 -2
  11. package/dist/providers/coin-quantity.d.ts.map +1 -1
  12. package/dist/providers/coin.d.ts +1 -2
  13. package/dist/providers/coin.d.ts.map +1 -1
  14. package/dist/providers/message.d.ts +0 -1
  15. package/dist/providers/message.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +7 -0
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  19. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts +25 -4
  23. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  24. package/dist/test-utils/launchNode.d.ts.map +1 -1
  25. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  26. package/dist/test-utils.global.js +102 -51
  27. package/dist/test-utils.global.js.map +1 -1
  28. package/dist/test-utils.js +137 -88
  29. package/dist/test-utils.js.map +1 -1
  30. package/dist/test-utils.mjs +99 -50
  31. package/dist/test-utils.mjs.map +1 -1
  32. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -184,14 +184,12 @@ 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");
188
187
  var import_errors16 = require("@fuel-ts/errors");
189
188
  var import_interfaces = require("@fuel-ts/interfaces");
190
189
  var import_math18 = require("@fuel-ts/math");
191
190
  var import_utils28 = require("@fuel-ts/utils");
192
191
 
193
192
  // src/providers/coin-quantity.ts
194
- var import_configs = require("@fuel-ts/address/configs");
195
193
  var import_math = require("@fuel-ts/math");
196
194
  var import_utils = require("@fuel-ts/utils");
197
195
  var coinQuantityfy = (coinQuantityLike) => {
@@ -200,11 +198,11 @@ var coinQuantityfy = (coinQuantityLike) => {
200
198
  let max2;
201
199
  if (Array.isArray(coinQuantityLike)) {
202
200
  amount = coinQuantityLike[0];
203
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
204
- max2 = coinQuantityLike[2] ?? void 0;
201
+ assetId = coinQuantityLike[1];
202
+ max2 = coinQuantityLike[2];
205
203
  } else {
206
204
  amount = coinQuantityLike.amount;
207
- assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
205
+ assetId = coinQuantityLike.assetId;
208
206
  max2 = coinQuantityLike.max ?? void 0;
209
207
  }
210
208
  const bnAmount = (0, import_math.bn)(amount);
@@ -1174,7 +1172,7 @@ var MemoryCache = class {
1174
1172
 
1175
1173
  // src/providers/transaction-request/input.ts
1176
1174
  var import_abi_coder = require("@fuel-ts/abi-coder");
1177
- var import_configs2 = require("@fuel-ts/address/configs");
1175
+ var import_configs = require("@fuel-ts/address/configs");
1178
1176
  var import_errors3 = require("@fuel-ts/errors");
1179
1177
  var import_math2 = require("@fuel-ts/math");
1180
1178
  var import_transactions = require("@fuel-ts/transactions");
@@ -1208,10 +1206,10 @@ var inputify = (value) => {
1208
1206
  case import_transactions.InputType.Contract: {
1209
1207
  return {
1210
1208
  type: import_transactions.InputType.Contract,
1211
- txID: import_configs2.ZeroBytes32,
1209
+ txID: import_configs.ZeroBytes32,
1212
1210
  outputIndex: 0,
1213
- balanceRoot: import_configs2.ZeroBytes32,
1214
- stateRoot: import_configs2.ZeroBytes32,
1211
+ balanceRoot: import_configs.ZeroBytes32,
1212
+ stateRoot: import_configs.ZeroBytes32,
1215
1213
  txPointer: {
1216
1214
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1217
1215
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1249,7 +1247,7 @@ var inputify = (value) => {
1249
1247
  };
1250
1248
 
1251
1249
  // src/providers/transaction-request/output.ts
1252
- var import_configs3 = require("@fuel-ts/address/configs");
1250
+ var import_configs2 = require("@fuel-ts/address/configs");
1253
1251
  var import_errors4 = require("@fuel-ts/errors");
1254
1252
  var import_math3 = require("@fuel-ts/math");
1255
1253
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1269,8 +1267,8 @@ var outputify = (value) => {
1269
1267
  return {
1270
1268
  type: import_transactions2.OutputType.Contract,
1271
1269
  inputIndex: value.inputIndex,
1272
- balanceRoot: import_configs3.ZeroBytes32,
1273
- stateRoot: import_configs3.ZeroBytes32
1270
+ balanceRoot: import_configs2.ZeroBytes32,
1271
+ stateRoot: import_configs2.ZeroBytes32
1274
1272
  };
1275
1273
  }
1276
1274
  case import_transactions2.OutputType.Change: {
@@ -1284,9 +1282,9 @@ var outputify = (value) => {
1284
1282
  case import_transactions2.OutputType.Variable: {
1285
1283
  return {
1286
1284
  type: import_transactions2.OutputType.Variable,
1287
- to: import_configs3.ZeroBytes32,
1285
+ to: import_configs2.ZeroBytes32,
1288
1286
  amount: (0, import_math3.bn)(0),
1289
- assetId: import_configs3.ZeroBytes32
1287
+ assetId: import_configs2.ZeroBytes32
1290
1288
  };
1291
1289
  }
1292
1290
  case import_transactions2.OutputType.ContractCreated: {
@@ -1308,7 +1306,7 @@ var outputify = (value) => {
1308
1306
  // src/providers/transaction-request/transaction-request.ts
1309
1307
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1310
1308
  var import_address = require("@fuel-ts/address");
1311
- var import_configs7 = require("@fuel-ts/address/configs");
1309
+ var import_configs6 = require("@fuel-ts/address/configs");
1312
1310
  var import_crypto = require("@fuel-ts/crypto");
1313
1311
  var import_math7 = require("@fuel-ts/math");
1314
1312
  var import_transactions6 = require("@fuel-ts/transactions");
@@ -1321,13 +1319,13 @@ var isCoin = (resource) => "id" in resource;
1321
1319
  var isMessage = (resource) => "recipient" in resource;
1322
1320
 
1323
1321
  // src/providers/utils/receipts.ts
1324
- var import_configs4 = require("@fuel-ts/address/configs");
1322
+ var import_configs3 = require("@fuel-ts/address/configs");
1325
1323
  var import_errors5 = require("@fuel-ts/errors");
1326
1324
  var import_math4 = require("@fuel-ts/math");
1327
1325
  var import_transactions3 = require("@fuel-ts/transactions");
1328
- var import_configs5 = require("@fuel-ts/transactions/configs");
1326
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1329
1327
  var import_utils5 = require("@fuel-ts/utils");
1330
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1328
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1331
1329
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1332
1330
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1333
1331
  (memo, receipt) => {
@@ -1344,7 +1342,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1344
1342
  missingOutputContractIds: []
1345
1343
  }
1346
1344
  );
1347
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1345
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1348
1346
  function assembleReceiptByType(receipt) {
1349
1347
  const { receiptType } = receipt;
1350
1348
  switch (receiptType) {
@@ -1708,16 +1706,16 @@ function sleep(time) {
1708
1706
  var import_errors7 = require("@fuel-ts/errors");
1709
1707
  var import_math6 = require("@fuel-ts/math");
1710
1708
  var import_transactions5 = require("@fuel-ts/transactions");
1711
- var import_configs6 = require("@fuel-ts/transactions/configs");
1709
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1712
1710
  var assemblePanicError = (status) => {
1713
1711
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1714
1712
  const reason = status.reason;
1715
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1713
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1716
1714
  errorMessage = `${errorMessage}
1717
1715
 
1718
1716
  You can read more about this error at:
1719
1717
 
1720
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1718
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1721
1719
  }
1722
1720
  return { errorMessage, reason };
1723
1721
  };
@@ -1729,28 +1727,28 @@ var assembleRevertError = (receipts, logs) => {
1729
1727
  if (revertReceipt) {
1730
1728
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1731
1729
  switch (reasonHex) {
1732
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1730
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1733
1731
  reason = "require";
1734
1732
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1735
1733
  break;
1736
1734
  }
1737
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1735
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1738
1736
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1739
1737
  reason = "assert_eq";
1740
1738
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1741
1739
  break;
1742
1740
  }
1743
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1741
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1744
1742
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1745
1743
  reason = "assert_ne";
1746
1744
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1747
1745
  break;
1748
1746
  }
1749
- case import_configs6.FAILED_ASSERT_SIGNAL:
1747
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1750
1748
  reason = "assert";
1751
1749
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1752
1750
  break;
1753
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1751
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1754
1752
  reason = "MissingOutputChange";
1755
1753
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1756
1754
  break;
@@ -1824,6 +1822,8 @@ var BaseTransactionRequest = class {
1824
1822
  outputs = [];
1825
1823
  /** List of witnesses */
1826
1824
  witnesses = [];
1825
+ /** Base asset ID - should be fetched from the chain */
1826
+ baseAssetId;
1827
1827
  /**
1828
1828
  * Constructor for initializing a base transaction request.
1829
1829
  *
@@ -1836,8 +1836,9 @@ var BaseTransactionRequest = class {
1836
1836
  witnessLimit,
1837
1837
  inputs,
1838
1838
  outputs,
1839
- witnesses
1840
- } = {}) {
1839
+ witnesses,
1840
+ baseAssetId
1841
+ }) {
1841
1842
  this.gasPrice = (0, import_math7.bn)(gasPrice);
1842
1843
  this.maturity = maturity ?? 0;
1843
1844
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
@@ -1845,6 +1846,7 @@ var BaseTransactionRequest = class {
1845
1846
  this.inputs = inputs ?? [];
1846
1847
  this.outputs = outputs ?? [];
1847
1848
  this.witnesses = witnesses ?? [];
1849
+ this.baseAssetId = baseAssetId;
1848
1850
  }
1849
1851
  static getPolicyMeta(req) {
1850
1852
  let policyTypes = 0;
@@ -1937,7 +1939,7 @@ var BaseTransactionRequest = class {
1937
1939
  * @returns The index of the created witness.
1938
1940
  */
1939
1941
  addEmptyWitness() {
1940
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1942
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1941
1943
  return this.witnesses.length - 1;
1942
1944
  }
1943
1945
  /**
@@ -2038,8 +2040,8 @@ var BaseTransactionRequest = class {
2038
2040
  * @param predicate - Predicate bytes.
2039
2041
  * @param predicateData - Predicate data bytes.
2040
2042
  */
2041
- addCoinInput(coin) {
2042
- const { assetId, owner, amount, id, predicate } = coin;
2043
+ addCoinInput(coin, predicate) {
2044
+ const { assetId, owner, amount } = coin;
2043
2045
  let witnessIndex;
2044
2046
  if (predicate) {
2045
2047
  witnessIndex = 0;
@@ -2050,14 +2052,14 @@ var BaseTransactionRequest = class {
2050
2052
  }
2051
2053
  }
2052
2054
  const input = {
2053
- id,
2055
+ ...coin,
2054
2056
  type: import_transactions6.InputType.Coin,
2055
2057
  owner: owner.toB256(),
2056
2058
  amount,
2057
2059
  assetId,
2058
2060
  txPointer: "0x00000000000000000000000000000000",
2059
2061
  witnessIndex,
2060
- predicate
2062
+ predicate: predicate?.bytes
2061
2063
  };
2062
2064
  this.pushInput(input);
2063
2065
  this.addChangeOutput(owner, assetId);
@@ -2068,11 +2070,9 @@ var BaseTransactionRequest = class {
2068
2070
  *
2069
2071
  * @param message - Message resource.
2070
2072
  * @param predicate - Predicate bytes.
2071
- * @param predicateData - Predicate data bytes.
2072
2073
  */
2073
- addMessageInput(message) {
2074
- const { recipient, sender, amount, predicate, nonce } = message;
2075
- const assetId = import_configs7.BaseAssetId;
2074
+ addMessageInput(message, predicate) {
2075
+ const { recipient, sender, amount } = message;
2076
2076
  let witnessIndex;
2077
2077
  if (predicate) {
2078
2078
  witnessIndex = 0;
@@ -2083,16 +2083,16 @@ var BaseTransactionRequest = class {
2083
2083
  }
2084
2084
  }
2085
2085
  const input = {
2086
- nonce,
2086
+ ...message,
2087
2087
  type: import_transactions6.InputType.Message,
2088
2088
  sender: sender.toB256(),
2089
2089
  recipient: recipient.toB256(),
2090
2090
  amount,
2091
2091
  witnessIndex,
2092
- predicate
2092
+ predicate: predicate?.bytes
2093
2093
  };
2094
2094
  this.pushInput(input);
2095
- this.addChangeOutput(recipient, assetId);
2095
+ this.addChangeOutput(recipient, this.baseAssetId);
2096
2096
  }
2097
2097
  /**
2098
2098
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2120,6 +2120,32 @@ var BaseTransactionRequest = class {
2120
2120
  resources.forEach((resource) => this.addResource(resource));
2121
2121
  return this;
2122
2122
  }
2123
+ /**
2124
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2125
+ * outputs from the related assetIds.
2126
+ *
2127
+ * @param resources - The resources to add.
2128
+ * @returns This transaction.
2129
+ */
2130
+ addPredicateResource(resource, predicate) {
2131
+ if (isCoin(resource)) {
2132
+ this.addCoinInput(resource, predicate);
2133
+ } else {
2134
+ this.addMessageInput(resource, predicate);
2135
+ }
2136
+ return this;
2137
+ }
2138
+ /**
2139
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2140
+ * from the related assetIds.
2141
+ *
2142
+ * @param resources - The resources to add.
2143
+ * @returns This transaction.
2144
+ */
2145
+ addPredicateResources(resources, predicate) {
2146
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2147
+ return this;
2148
+ }
2123
2149
  /**
2124
2150
  * Adds a coin output to the transaction.
2125
2151
  *
@@ -2127,12 +2153,12 @@ var BaseTransactionRequest = class {
2127
2153
  * @param amount - Amount of coin.
2128
2154
  * @param assetId - Asset ID of coin.
2129
2155
  */
2130
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2156
+ addCoinOutput(to, amount, assetId) {
2131
2157
  this.pushOutput({
2132
2158
  type: import_transactions6.OutputType.Coin,
2133
2159
  to: (0, import_address.addressify)(to).toB256(),
2134
2160
  amount,
2135
- assetId
2161
+ assetId: assetId ?? this.baseAssetId
2136
2162
  });
2137
2163
  return this;
2138
2164
  }
@@ -2159,7 +2185,7 @@ var BaseTransactionRequest = class {
2159
2185
  * @param to - Address of the owner.
2160
2186
  * @param assetId - Asset ID of coin.
2161
2187
  */
2162
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2188
+ addChangeOutput(to, assetId) {
2163
2189
  const changeOutput = this.getChangeOutputs().find(
2164
2190
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2165
2191
  );
@@ -2167,7 +2193,7 @@ var BaseTransactionRequest = class {
2167
2193
  this.pushOutput({
2168
2194
  type: import_transactions6.OutputType.Change,
2169
2195
  to: (0, import_address.addressify)(to).toB256(),
2170
- assetId
2196
+ assetId: assetId ?? this.baseAssetId
2171
2197
  });
2172
2198
  }
2173
2199
  }
@@ -2243,7 +2269,7 @@ var BaseTransactionRequest = class {
2243
2269
  ]);
2244
2270
  }
2245
2271
  };
2246
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2272
+ updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2247
2273
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2248
2274
  }
2249
2275
  /**
@@ -2293,13 +2319,13 @@ var BaseTransactionRequest = class {
2293
2319
  };
2294
2320
 
2295
2321
  // src/providers/transaction-request/create-transaction-request.ts
2296
- var import_configs9 = require("@fuel-ts/address/configs");
2322
+ var import_configs8 = require("@fuel-ts/address/configs");
2297
2323
  var import_math9 = require("@fuel-ts/math");
2298
2324
  var import_transactions8 = require("@fuel-ts/transactions");
2299
2325
  var import_utils13 = require("@fuel-ts/utils");
2300
2326
 
2301
2327
  // src/providers/transaction-request/hash-transaction.ts
2302
- var import_configs8 = require("@fuel-ts/address/configs");
2328
+ var import_configs7 = require("@fuel-ts/address/configs");
2303
2329
  var import_hasher = require("@fuel-ts/hasher");
2304
2330
  var import_math8 = require("@fuel-ts/math");
2305
2331
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2308,7 +2334,7 @@ var import_ramda2 = require("ramda");
2308
2334
  function hashTransaction(transactionRequest, chainId) {
2309
2335
  const transaction = transactionRequest.toTransaction();
2310
2336
  if (transaction.type === import_transactions7.TransactionType.Script) {
2311
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2337
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2312
2338
  }
2313
2339
  transaction.inputs = transaction.inputs.map((input) => {
2314
2340
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2330,10 +2356,10 @@ function hashTransaction(transactionRequest, chainId) {
2330
2356
  blockHeight: 0,
2331
2357
  txIndex: 0
2332
2358
  };
2333
- inputClone.txID = import_configs8.ZeroBytes32;
2359
+ inputClone.txID = import_configs7.ZeroBytes32;
2334
2360
  inputClone.outputIndex = 0;
2335
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2336
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2361
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2362
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2337
2363
  return inputClone;
2338
2364
  }
2339
2365
  default:
@@ -2344,8 +2370,8 @@ function hashTransaction(transactionRequest, chainId) {
2344
2370
  const outputClone = (0, import_ramda2.clone)(output);
2345
2371
  switch (outputClone.type) {
2346
2372
  case import_transactions7.OutputType.Contract: {
2347
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2348
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2373
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2374
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2349
2375
  return outputClone;
2350
2376
  }
2351
2377
  case import_transactions7.OutputType.Change: {
@@ -2353,9 +2379,9 @@ function hashTransaction(transactionRequest, chainId) {
2353
2379
  return outputClone;
2354
2380
  }
2355
2381
  case import_transactions7.OutputType.Variable: {
2356
- outputClone.to = import_configs8.ZeroBytes32;
2382
+ outputClone.to = import_configs7.ZeroBytes32;
2357
2383
  outputClone.amount = (0, import_math8.bn)(0);
2358
- outputClone.assetId = import_configs8.ZeroBytes32;
2384
+ outputClone.assetId = import_configs7.ZeroBytes32;
2359
2385
  return outputClone;
2360
2386
  }
2361
2387
  default:
@@ -2413,15 +2439,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2413
2439
  *
2414
2440
  * @param createTransactionRequestLike - The initial values for the instance
2415
2441
  */
2416
- constructor({
2417
- bytecodeWitnessIndex,
2418
- salt,
2419
- storageSlots,
2420
- ...rest
2421
- } = {}) {
2442
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2422
2443
  super(rest);
2423
2444
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2424
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2445
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2425
2446
  this.storageSlots = [...storageSlots ?? []];
2426
2447
  }
2427
2448
  /**
@@ -2439,7 +2460,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2439
2460
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2440
2461
  bytecodeWitnessIndex,
2441
2462
  storageSlotsCount: storageSlots.length,
2442
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2463
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2443
2464
  storageSlots
2444
2465
  };
2445
2466
  }
@@ -2489,7 +2510,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2489
2510
  // src/providers/transaction-request/script-transaction-request.ts
2490
2511
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2491
2512
  var import_address2 = require("@fuel-ts/address");
2492
- var import_configs10 = require("@fuel-ts/address/configs");
2513
+ var import_configs9 = require("@fuel-ts/address/configs");
2493
2514
  var import_math10 = require("@fuel-ts/math");
2494
2515
  var import_transactions9 = require("@fuel-ts/transactions");
2495
2516
  var import_utils15 = require("@fuel-ts/utils");
@@ -2542,7 +2563,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2542
2563
  *
2543
2564
  * @param scriptTransactionRequestLike - The initial values for the instance.
2544
2565
  */
2545
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2566
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2546
2567
  super(rest);
2547
2568
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2548
2569
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2563,7 +2584,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2563
2584
  ...super.getBaseTransaction(),
2564
2585
  scriptLength: script.length,
2565
2586
  scriptDataLength: scriptData.length,
2566
- receiptsRoot: import_configs10.ZeroBytes32,
2587
+ receiptsRoot: import_configs9.ZeroBytes32,
2567
2588
  script: (0, import_utils15.hexlify)(script),
2568
2589
  scriptData: (0, import_utils15.hexlify)(scriptData)
2569
2590
  };
@@ -2795,7 +2816,7 @@ var calculateTransactionFee = (params) => {
2795
2816
  };
2796
2817
 
2797
2818
  // src/providers/transaction-summary/operations.ts
2798
- var import_configs11 = require("@fuel-ts/address/configs");
2819
+ var import_configs10 = require("@fuel-ts/address/configs");
2799
2820
  var import_errors11 = require("@fuel-ts/errors");
2800
2821
  var import_math13 = require("@fuel-ts/math");
2801
2822
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3140,7 +3161,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3140
3161
  const { to: toAddress, assetId, amount } = receipt;
3141
3162
  let { from: fromAddress } = receipt;
3142
3163
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3143
- if (import_configs11.ZeroBytes32 === fromAddress) {
3164
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3144
3165
  const change = changeOutputs.find((output) => output.assetId === assetId);
3145
3166
  fromAddress = change?.to || fromAddress;
3146
3167
  }
@@ -3717,6 +3738,7 @@ var processGqlChain = (chain) => {
3717
3738
  gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3718
3739
  maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3719
3740
  chainId: (0, import_math15.bn)(consensusParameters.chainId),
3741
+ baseAssetId: consensusParameters.baseAssetId,
3720
3742
  gasCosts
3721
3743
  },
3722
3744
  gasCosts,
@@ -3959,6 +3981,17 @@ var _Provider = class {
3959
3981
  } = this.getChain();
3960
3982
  return chainId.toNumber();
3961
3983
  }
3984
+ /**
3985
+ * Returns the base asset ID
3986
+ *
3987
+ * @returns A promise that resolves to the base asset ID
3988
+ */
3989
+ getBaseAssetId() {
3990
+ const {
3991
+ consensusParameters: { baseAssetId }
3992
+ } = this.getChain();
3993
+ return baseAssetId;
3994
+ }
3962
3995
  /**
3963
3996
  * Submits a transaction to the chain to be executed.
3964
3997
  *
@@ -5022,8 +5055,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5022
5055
  * @param assetId - The asset ID to check the balance for.
5023
5056
  * @returns A promise that resolves to the balance amount.
5024
5057
  */
5025
- async getBalance(assetId = import_configs12.BaseAssetId) {
5026
- const amount = await this.provider.getBalance(this.address, assetId);
5058
+ async getBalance(assetId) {
5059
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5060
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5027
5061
  return amount;
5028
5062
  }
5029
5063
  /**
@@ -5061,9 +5095,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5061
5095
  * @returns A promise that resolves when the resources are added to the transaction.
5062
5096
  */
5063
5097
  async fund(request, coinQuantities, fee) {
5098
+ const baseAssetId = this.provider.getBaseAssetId();
5064
5099
  const updatedQuantities = addAmountToAsset({
5065
5100
  amount: (0, import_math18.bn)(fee),
5066
- assetId: import_configs12.BaseAssetId,
5101
+ assetId: baseAssetId,
5067
5102
  coinQuantities
5068
5103
  });
5069
5104
  const quantitiesDict = {};
@@ -5087,8 +5122,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5087
5122
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5088
5123
  cachedUtxos.push(input.id);
5089
5124
  }
5090
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5091
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5125
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5126
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5092
5127
  cachedMessages.push(input.nonce);
5093
5128
  }
5094
5129
  }
@@ -5120,11 +5155,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5120
5155
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5121
5156
  * @returns A promise that resolves to the prepared transaction request.
5122
5157
  */
5123
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5158
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5124
5159
  const { minGasPrice } = this.provider.getGasConfig();
5125
- const params = { gasPrice: minGasPrice, ...txParams };
5160
+ const baseAssetId = this.provider.getBaseAssetId();
5161
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5162
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5126
5163
  const request = new ScriptTransactionRequest(params);
5127
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5164
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5128
5165
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5129
5166
  estimateTxDependencies: true,
5130
5167
  resourcesOwner: this
@@ -5150,14 +5187,15 @@ var Account = class extends import_interfaces.AbstractAccount {
5150
5187
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5151
5188
  * @returns A promise that resolves to the transaction response.
5152
5189
  */
5153
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5190
+ async transfer(destination, amount, assetId, txParams = {}) {
5154
5191
  if ((0, import_math18.bn)(amount).lte(0)) {
5155
5192
  throw new import_errors16.FuelError(
5156
5193
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5157
5194
  "Transfer amount must be a positive number."
5158
5195
  );
5159
5196
  }
5160
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5197
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5198
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5161
5199
  return this.sendTransaction(request, { estimateTxDependencies: false });
5162
5200
  }
5163
5201
  /**
@@ -5169,7 +5207,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5169
5207
  * @param txParams - The optional transaction parameters.
5170
5208
  * @returns A promise that resolves to the transaction response.
5171
5209
  */
5172
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5210
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5173
5211
  if ((0, import_math18.bn)(amount).lte(0)) {
5174
5212
  throw new import_errors16.FuelError(
5175
5213
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -5178,11 +5216,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5178
5216
  }
5179
5217
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5180
5218
  const { minGasPrice } = this.provider.getGasConfig();
5181
- const params = { gasPrice: minGasPrice, ...txParams };
5219
+ const baseAssetId = this.provider.getBaseAssetId();
5220
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5221
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5182
5222
  const { script, scriptData } = await assembleTransferToContractScript({
5183
5223
  hexlifiedContractId: contractAddress.toB256(),
5184
5224
  amountToTransfer: (0, import_math18.bn)(amount),
5185
- assetId
5225
+ assetId: assetIdToTransfer
5186
5226
  });
5187
5227
  const request = new ScriptTransactionRequest({
5188
5228
  ...params,
@@ -5192,7 +5232,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5192
5232
  request.addContractInputAndOutput(contractAddress);
5193
5233
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5194
5234
  request,
5195
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5235
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5196
5236
  );
5197
5237
  request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5198
5238
  this.validateGas({
@@ -5214,6 +5254,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5214
5254
  */
5215
5255
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5216
5256
  const { minGasPrice } = this.provider.getGasConfig();
5257
+ const baseAssetId = this.provider.getBaseAssetId();
5217
5258
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5218
5259
  const recipientDataArray = (0, import_utils28.arrayify)(
5219
5260
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5226,9 +5267,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5226
5267
  ...recipientDataArray,
5227
5268
  ...amountDataArray
5228
5269
  ]);
5229
- const params = { script, gasPrice: minGasPrice, ...txParams };
5270
+ const params = {
5271
+ script,
5272
+ gasPrice: minGasPrice,
5273
+ baseAssetId,
5274
+ ...txParams
5275
+ };
5230
5276
  const request = new ScriptTransactionRequest(params);
5231
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5277
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5232
5278
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5233
5279
  request,
5234
5280
  forwardingQuantities
@@ -8791,7 +8837,6 @@ var StorageAbstract = class {
8791
8837
  // src/predicate/predicate.ts
8792
8838
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8793
8839
  var import_address10 = require("@fuel-ts/address");
8794
- var import_configs13 = require("@fuel-ts/address/configs");
8795
8840
  var import_errors25 = require("@fuel-ts/errors");
8796
8841
  var import_transactions20 = require("@fuel-ts/transactions");
8797
8842
  var import_utils37 = require("@fuel-ts/utils");
@@ -8856,7 +8901,6 @@ var Predicate = class extends Account {
8856
8901
  if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8857
8902
  input.predicate = this.bytes;
8858
8903
  input.predicateData = this.getPredicateData(policies.length);
8859
- input.witnessIndex = 0;
8860
8904
  }
8861
8905
  });
8862
8906
  return request;
@@ -8870,8 +8914,9 @@ var Predicate = class extends Account {
8870
8914
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8871
8915
  * @returns A promise that resolves to the prepared transaction request.
8872
8916
  */
8873
- async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8874
- const request = await super.createTransfer(destination, amount, assetId, txParams);
8917
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8918
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8919
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8875
8920
  return this.populateTransactionPredicateData(request);
8876
8921
  }
8877
8922
  /**
@@ -8894,20 +8939,6 @@ var Predicate = class extends Account {
8894
8939
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8895
8940
  return super.simulateTransaction(transactionRequest);
8896
8941
  }
8897
- /**
8898
- * Retrieves resources satisfying the spend query for the account.
8899
- *
8900
- * @param quantities - IDs of coins to exclude.
8901
- * @param excludedIds - IDs of resources to be excluded from the query.
8902
- * @returns A promise that resolves to an array of Resources.
8903
- */
8904
- async getResourcesToSpend(quantities, excludedIds) {
8905
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8906
- return resources.map((resource) => ({
8907
- ...resource,
8908
- predicate: (0, import_utils37.hexlify)(this.bytes)
8909
- }));
8910
- }
8911
8942
  getPredicateData(policiesLength) {
8912
8943
  if (!this.predicateData.length) {
8913
8944
  return new Uint8Array();