@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-1976-20240411153008

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 +135 -104
  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 +138 -89
  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);
@@ -1173,7 +1171,7 @@ var MemoryCache = class {
1173
1171
  };
1174
1172
 
1175
1173
  // src/providers/transaction-request/input.ts
1176
- var import_configs2 = require("@fuel-ts/address/configs");
1174
+ var import_configs = require("@fuel-ts/address/configs");
1177
1175
  var import_errors3 = require("@fuel-ts/errors");
1178
1176
  var import_math2 = require("@fuel-ts/math");
1179
1177
  var import_transactions = require("@fuel-ts/transactions");
@@ -1207,10 +1205,10 @@ var inputify = (value) => {
1207
1205
  case import_transactions.InputType.Contract: {
1208
1206
  return {
1209
1207
  type: import_transactions.InputType.Contract,
1210
- txID: import_configs2.ZeroBytes32,
1208
+ txID: import_configs.ZeroBytes32,
1211
1209
  outputIndex: 0,
1212
- balanceRoot: import_configs2.ZeroBytes32,
1213
- stateRoot: import_configs2.ZeroBytes32,
1210
+ balanceRoot: import_configs.ZeroBytes32,
1211
+ stateRoot: import_configs.ZeroBytes32,
1214
1212
  txPointer: {
1215
1213
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1216
1214
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1248,7 +1246,7 @@ var inputify = (value) => {
1248
1246
  };
1249
1247
 
1250
1248
  // src/providers/transaction-request/output.ts
1251
- var import_configs3 = require("@fuel-ts/address/configs");
1249
+ var import_configs2 = require("@fuel-ts/address/configs");
1252
1250
  var import_errors4 = require("@fuel-ts/errors");
1253
1251
  var import_math3 = require("@fuel-ts/math");
1254
1252
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1268,8 +1266,8 @@ var outputify = (value) => {
1268
1266
  return {
1269
1267
  type: import_transactions2.OutputType.Contract,
1270
1268
  inputIndex: value.inputIndex,
1271
- balanceRoot: import_configs3.ZeroBytes32,
1272
- stateRoot: import_configs3.ZeroBytes32
1269
+ balanceRoot: import_configs2.ZeroBytes32,
1270
+ stateRoot: import_configs2.ZeroBytes32
1273
1271
  };
1274
1272
  }
1275
1273
  case import_transactions2.OutputType.Change: {
@@ -1283,9 +1281,9 @@ var outputify = (value) => {
1283
1281
  case import_transactions2.OutputType.Variable: {
1284
1282
  return {
1285
1283
  type: import_transactions2.OutputType.Variable,
1286
- to: import_configs3.ZeroBytes32,
1284
+ to: import_configs2.ZeroBytes32,
1287
1285
  amount: (0, import_math3.bn)(0),
1288
- assetId: import_configs3.ZeroBytes32
1286
+ assetId: import_configs2.ZeroBytes32
1289
1287
  };
1290
1288
  }
1291
1289
  case import_transactions2.OutputType.ContractCreated: {
@@ -1306,7 +1304,7 @@ var outputify = (value) => {
1306
1304
 
1307
1305
  // src/providers/transaction-request/transaction-request.ts
1308
1306
  var import_address = require("@fuel-ts/address");
1309
- var import_configs7 = require("@fuel-ts/address/configs");
1307
+ var import_configs6 = require("@fuel-ts/address/configs");
1310
1308
  var import_math7 = require("@fuel-ts/math");
1311
1309
  var import_transactions6 = require("@fuel-ts/transactions");
1312
1310
  var import_utils9 = require("@fuel-ts/utils");
@@ -1318,13 +1316,13 @@ var isCoin = (resource) => "id" in resource;
1318
1316
  var isMessage = (resource) => "recipient" in resource;
1319
1317
 
1320
1318
  // src/providers/utils/receipts.ts
1321
- var import_configs4 = require("@fuel-ts/address/configs");
1319
+ var import_configs3 = require("@fuel-ts/address/configs");
1322
1320
  var import_errors5 = require("@fuel-ts/errors");
1323
1321
  var import_math4 = require("@fuel-ts/math");
1324
1322
  var import_transactions3 = require("@fuel-ts/transactions");
1325
- var import_configs5 = require("@fuel-ts/transactions/configs");
1323
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1326
1324
  var import_utils5 = require("@fuel-ts/utils");
1327
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1325
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1328
1326
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1329
1327
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1330
1328
  (memo, receipt) => {
@@ -1341,7 +1339,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1341
1339
  missingOutputContractIds: []
1342
1340
  }
1343
1341
  );
1344
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1342
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1345
1343
  function assembleReceiptByType(receipt) {
1346
1344
  const { receiptType } = receipt;
1347
1345
  switch (receiptType) {
@@ -1705,16 +1703,16 @@ function sleep(time) {
1705
1703
  var import_errors7 = require("@fuel-ts/errors");
1706
1704
  var import_math6 = require("@fuel-ts/math");
1707
1705
  var import_transactions5 = require("@fuel-ts/transactions");
1708
- var import_configs6 = require("@fuel-ts/transactions/configs");
1706
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1709
1707
  var assemblePanicError = (status) => {
1710
1708
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1711
1709
  const reason = status.reason;
1712
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1710
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1713
1711
  errorMessage = `${errorMessage}
1714
1712
 
1715
1713
  You can read more about this error at:
1716
1714
 
1717
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1715
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1718
1716
  }
1719
1717
  return { errorMessage, reason };
1720
1718
  };
@@ -1726,28 +1724,28 @@ var assembleRevertError = (receipts, logs) => {
1726
1724
  if (revertReceipt) {
1727
1725
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1728
1726
  switch (reasonHex) {
1729
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1727
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1730
1728
  reason = "require";
1731
1729
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1732
1730
  break;
1733
1731
  }
1734
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1732
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1735
1733
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1736
1734
  reason = "assert_eq";
1737
1735
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1738
1736
  break;
1739
1737
  }
1740
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1738
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1741
1739
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1742
1740
  reason = "assert_ne";
1743
1741
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1744
1742
  break;
1745
1743
  }
1746
- case import_configs6.FAILED_ASSERT_SIGNAL:
1744
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1747
1745
  reason = "assert";
1748
1746
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1749
1747
  break;
1750
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1748
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1751
1749
  reason = "MissingOutputChange";
1752
1750
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1753
1751
  break;
@@ -1821,6 +1819,8 @@ var BaseTransactionRequest = class {
1821
1819
  outputs = [];
1822
1820
  /** List of witnesses */
1823
1821
  witnesses = [];
1822
+ /** Base asset ID - should be fetched from the chain */
1823
+ baseAssetId;
1824
1824
  /**
1825
1825
  * Constructor for initializing a base transaction request.
1826
1826
  *
@@ -1833,8 +1833,9 @@ var BaseTransactionRequest = class {
1833
1833
  witnessLimit,
1834
1834
  inputs,
1835
1835
  outputs,
1836
- witnesses
1837
- } = {}) {
1836
+ witnesses,
1837
+ baseAssetId
1838
+ }) {
1838
1839
  this.gasPrice = (0, import_math7.bn)(gasPrice);
1839
1840
  this.maturity = maturity ?? 0;
1840
1841
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
@@ -1842,6 +1843,7 @@ var BaseTransactionRequest = class {
1842
1843
  this.inputs = inputs ?? [];
1843
1844
  this.outputs = outputs ?? [];
1844
1845
  this.witnesses = witnesses ?? [];
1846
+ this.baseAssetId = baseAssetId;
1845
1847
  }
1846
1848
  static getPolicyMeta(req) {
1847
1849
  let policyTypes = 0;
@@ -1934,7 +1936,7 @@ var BaseTransactionRequest = class {
1934
1936
  * @returns The index of the created witness.
1935
1937
  */
1936
1938
  addEmptyWitness() {
1937
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1939
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1938
1940
  return this.witnesses.length - 1;
1939
1941
  }
1940
1942
  /**
@@ -2035,8 +2037,8 @@ var BaseTransactionRequest = class {
2035
2037
  * @param predicate - Predicate bytes.
2036
2038
  * @param predicateData - Predicate data bytes.
2037
2039
  */
2038
- addCoinInput(coin) {
2039
- const { assetId, owner, amount, id, predicate } = coin;
2040
+ addCoinInput(coin, predicate) {
2041
+ const { assetId, owner, amount } = coin;
2040
2042
  let witnessIndex;
2041
2043
  if (predicate) {
2042
2044
  witnessIndex = 0;
@@ -2047,14 +2049,14 @@ var BaseTransactionRequest = class {
2047
2049
  }
2048
2050
  }
2049
2051
  const input = {
2050
- id,
2052
+ ...coin,
2051
2053
  type: import_transactions6.InputType.Coin,
2052
2054
  owner: owner.toB256(),
2053
2055
  amount,
2054
2056
  assetId,
2055
2057
  txPointer: "0x00000000000000000000000000000000",
2056
2058
  witnessIndex,
2057
- predicate
2059
+ predicate: predicate?.bytes
2058
2060
  };
2059
2061
  this.pushInput(input);
2060
2062
  this.addChangeOutput(owner, assetId);
@@ -2065,11 +2067,9 @@ var BaseTransactionRequest = class {
2065
2067
  *
2066
2068
  * @param message - Message resource.
2067
2069
  * @param predicate - Predicate bytes.
2068
- * @param predicateData - Predicate data bytes.
2069
2070
  */
2070
- addMessageInput(message) {
2071
- const { recipient, sender, amount, predicate, nonce } = message;
2072
- const assetId = import_configs7.BaseAssetId;
2071
+ addMessageInput(message, predicate) {
2072
+ const { recipient, sender, amount } = message;
2073
2073
  let witnessIndex;
2074
2074
  if (predicate) {
2075
2075
  witnessIndex = 0;
@@ -2080,16 +2080,16 @@ var BaseTransactionRequest = class {
2080
2080
  }
2081
2081
  }
2082
2082
  const input = {
2083
- nonce,
2083
+ ...message,
2084
2084
  type: import_transactions6.InputType.Message,
2085
2085
  sender: sender.toB256(),
2086
2086
  recipient: recipient.toB256(),
2087
2087
  amount,
2088
2088
  witnessIndex,
2089
- predicate
2089
+ predicate: predicate?.bytes
2090
2090
  };
2091
2091
  this.pushInput(input);
2092
- this.addChangeOutput(recipient, assetId);
2092
+ this.addChangeOutput(recipient, this.baseAssetId);
2093
2093
  }
2094
2094
  /**
2095
2095
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2117,6 +2117,32 @@ var BaseTransactionRequest = class {
2117
2117
  resources.forEach((resource) => this.addResource(resource));
2118
2118
  return this;
2119
2119
  }
2120
+ /**
2121
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2122
+ * outputs from the related assetIds.
2123
+ *
2124
+ * @param resources - The resources to add.
2125
+ * @returns This transaction.
2126
+ */
2127
+ addPredicateResource(resource, predicate) {
2128
+ if (isCoin(resource)) {
2129
+ this.addCoinInput(resource, predicate);
2130
+ } else {
2131
+ this.addMessageInput(resource, predicate);
2132
+ }
2133
+ return this;
2134
+ }
2135
+ /**
2136
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2137
+ * from the related assetIds.
2138
+ *
2139
+ * @param resources - The resources to add.
2140
+ * @returns This transaction.
2141
+ */
2142
+ addPredicateResources(resources, predicate) {
2143
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2144
+ return this;
2145
+ }
2120
2146
  /**
2121
2147
  * Adds a coin output to the transaction.
2122
2148
  *
@@ -2124,12 +2150,12 @@ var BaseTransactionRequest = class {
2124
2150
  * @param amount - Amount of coin.
2125
2151
  * @param assetId - Asset ID of coin.
2126
2152
  */
2127
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2153
+ addCoinOutput(to, amount, assetId) {
2128
2154
  this.pushOutput({
2129
2155
  type: import_transactions6.OutputType.Coin,
2130
2156
  to: (0, import_address.addressify)(to).toB256(),
2131
2157
  amount,
2132
- assetId
2158
+ assetId: assetId ?? this.baseAssetId
2133
2159
  });
2134
2160
  return this;
2135
2161
  }
@@ -2156,7 +2182,7 @@ var BaseTransactionRequest = class {
2156
2182
  * @param to - Address of the owner.
2157
2183
  * @param assetId - Asset ID of coin.
2158
2184
  */
2159
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2185
+ addChangeOutput(to, assetId) {
2160
2186
  const changeOutput = this.getChangeOutputs().find(
2161
2187
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2162
2188
  );
@@ -2164,7 +2190,7 @@ var BaseTransactionRequest = class {
2164
2190
  this.pushOutput({
2165
2191
  type: import_transactions6.OutputType.Change,
2166
2192
  to: (0, import_address.addressify)(to).toB256(),
2167
- assetId
2193
+ assetId: assetId ?? this.baseAssetId
2168
2194
  });
2169
2195
  }
2170
2196
  }
@@ -2218,7 +2244,7 @@ var BaseTransactionRequest = class {
2218
2244
  let idCounter = 0;
2219
2245
  const generateId = () => {
2220
2246
  const counterString = String(idCounter++);
2221
- const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2247
+ const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2222
2248
  return id;
2223
2249
  };
2224
2250
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2246,7 +2272,7 @@ var BaseTransactionRequest = class {
2246
2272
  ]);
2247
2273
  }
2248
2274
  };
2249
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2275
+ updateAssetInput(this.baseAssetId, (0, import_math7.bn)(1e11));
2250
2276
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2251
2277
  }
2252
2278
  /**
@@ -2296,13 +2322,13 @@ var BaseTransactionRequest = class {
2296
2322
  };
2297
2323
 
2298
2324
  // src/providers/transaction-request/create-transaction-request.ts
2299
- var import_configs9 = require("@fuel-ts/address/configs");
2325
+ var import_configs8 = require("@fuel-ts/address/configs");
2300
2326
  var import_math9 = require("@fuel-ts/math");
2301
2327
  var import_transactions8 = require("@fuel-ts/transactions");
2302
2328
  var import_utils13 = require("@fuel-ts/utils");
2303
2329
 
2304
2330
  // src/providers/transaction-request/hash-transaction.ts
2305
- var import_configs8 = require("@fuel-ts/address/configs");
2331
+ var import_configs7 = require("@fuel-ts/address/configs");
2306
2332
  var import_hasher = require("@fuel-ts/hasher");
2307
2333
  var import_math8 = require("@fuel-ts/math");
2308
2334
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2311,7 +2337,7 @@ var import_ramda2 = require("ramda");
2311
2337
  function hashTransaction(transactionRequest, chainId) {
2312
2338
  const transaction = transactionRequest.toTransaction();
2313
2339
  if (transaction.type === import_transactions7.TransactionType.Script) {
2314
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2340
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2315
2341
  }
2316
2342
  transaction.inputs = transaction.inputs.map((input) => {
2317
2343
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2333,10 +2359,10 @@ function hashTransaction(transactionRequest, chainId) {
2333
2359
  blockHeight: 0,
2334
2360
  txIndex: 0
2335
2361
  };
2336
- inputClone.txID = import_configs8.ZeroBytes32;
2362
+ inputClone.txID = import_configs7.ZeroBytes32;
2337
2363
  inputClone.outputIndex = 0;
2338
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2339
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2364
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2365
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2340
2366
  return inputClone;
2341
2367
  }
2342
2368
  default:
@@ -2347,8 +2373,8 @@ function hashTransaction(transactionRequest, chainId) {
2347
2373
  const outputClone = (0, import_ramda2.clone)(output);
2348
2374
  switch (outputClone.type) {
2349
2375
  case import_transactions7.OutputType.Contract: {
2350
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2351
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2376
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2377
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2352
2378
  return outputClone;
2353
2379
  }
2354
2380
  case import_transactions7.OutputType.Change: {
@@ -2356,9 +2382,9 @@ function hashTransaction(transactionRequest, chainId) {
2356
2382
  return outputClone;
2357
2383
  }
2358
2384
  case import_transactions7.OutputType.Variable: {
2359
- outputClone.to = import_configs8.ZeroBytes32;
2385
+ outputClone.to = import_configs7.ZeroBytes32;
2360
2386
  outputClone.amount = (0, import_math8.bn)(0);
2361
- outputClone.assetId = import_configs8.ZeroBytes32;
2387
+ outputClone.assetId = import_configs7.ZeroBytes32;
2362
2388
  return outputClone;
2363
2389
  }
2364
2390
  default:
@@ -2416,15 +2442,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2416
2442
  *
2417
2443
  * @param createTransactionRequestLike - The initial values for the instance
2418
2444
  */
2419
- constructor({
2420
- bytecodeWitnessIndex,
2421
- salt,
2422
- storageSlots,
2423
- ...rest
2424
- } = {}) {
2445
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2425
2446
  super(rest);
2426
2447
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2427
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2448
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2428
2449
  this.storageSlots = [...storageSlots ?? []];
2429
2450
  }
2430
2451
  /**
@@ -2442,7 +2463,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2442
2463
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2443
2464
  bytecodeWitnessIndex,
2444
2465
  storageSlotsCount: storageSlots.length,
2445
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2466
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2446
2467
  storageSlots
2447
2468
  };
2448
2469
  }
@@ -2492,7 +2513,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2492
2513
  // src/providers/transaction-request/script-transaction-request.ts
2493
2514
  var import_abi_coder = require("@fuel-ts/abi-coder");
2494
2515
  var import_address2 = require("@fuel-ts/address");
2495
- var import_configs10 = require("@fuel-ts/address/configs");
2516
+ var import_configs9 = require("@fuel-ts/address/configs");
2496
2517
  var import_math10 = require("@fuel-ts/math");
2497
2518
  var import_transactions9 = require("@fuel-ts/transactions");
2498
2519
  var import_utils15 = require("@fuel-ts/utils");
@@ -2545,7 +2566,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2545
2566
  *
2546
2567
  * @param scriptTransactionRequestLike - The initial values for the instance.
2547
2568
  */
2548
- constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2569
+ constructor({ script, scriptData, gasLimit, ...rest }) {
2549
2570
  super(rest);
2550
2571
  this.gasLimit = (0, import_math10.bn)(gasLimit);
2551
2572
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
@@ -2566,7 +2587,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2566
2587
  ...super.getBaseTransaction(),
2567
2588
  scriptLength: script.length,
2568
2589
  scriptDataLength: scriptData.length,
2569
- receiptsRoot: import_configs10.ZeroBytes32,
2590
+ receiptsRoot: import_configs9.ZeroBytes32,
2570
2591
  script: (0, import_utils15.hexlify)(script),
2571
2592
  scriptData: (0, import_utils15.hexlify)(scriptData)
2572
2593
  };
@@ -2798,7 +2819,7 @@ var calculateTransactionFee = (params) => {
2798
2819
  };
2799
2820
 
2800
2821
  // src/providers/transaction-summary/operations.ts
2801
- var import_configs11 = require("@fuel-ts/address/configs");
2822
+ var import_configs10 = require("@fuel-ts/address/configs");
2802
2823
  var import_errors11 = require("@fuel-ts/errors");
2803
2824
  var import_math13 = require("@fuel-ts/math");
2804
2825
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -3143,7 +3164,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3143
3164
  const { to: toAddress, assetId, amount } = receipt;
3144
3165
  let { from: fromAddress } = receipt;
3145
3166
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3146
- if (import_configs11.ZeroBytes32 === fromAddress) {
3167
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3147
3168
  const change = changeOutputs.find((output) => output.assetId === assetId);
3148
3169
  fromAddress = change?.to || fromAddress;
3149
3170
  }
@@ -3720,6 +3741,7 @@ var processGqlChain = (chain) => {
3720
3741
  gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3721
3742
  maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3722
3743
  chainId: (0, import_math15.bn)(consensusParameters.chainId),
3744
+ baseAssetId: consensusParameters.baseAssetId,
3723
3745
  gasCosts
3724
3746
  },
3725
3747
  gasCosts,
@@ -3962,6 +3984,17 @@ var _Provider = class {
3962
3984
  } = this.getChain();
3963
3985
  return chainId.toNumber();
3964
3986
  }
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
+ }
3965
3998
  /**
3966
3999
  * Submits a transaction to the chain to be executed.
3967
4000
  *
@@ -4998,8 +5031,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4998
5031
  * @param assetId - The asset ID to check the balance for.
4999
5032
  * @returns A promise that resolves to the balance amount.
5000
5033
  */
5001
- async getBalance(assetId = import_configs12.BaseAssetId) {
5002
- const amount = await this.provider.getBalance(this.address, assetId);
5034
+ async getBalance(assetId) {
5035
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5036
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5003
5037
  return amount;
5004
5038
  }
5005
5039
  /**
@@ -5037,9 +5071,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5037
5071
  * @returns A promise that resolves when the resources are added to the transaction.
5038
5072
  */
5039
5073
  async fund(request, coinQuantities, fee) {
5074
+ const baseAssetId = this.provider.getBaseAssetId();
5040
5075
  const updatedQuantities = addAmountToAsset({
5041
5076
  amount: (0, import_math18.bn)(fee),
5042
- assetId: import_configs12.BaseAssetId,
5077
+ assetId: baseAssetId,
5043
5078
  coinQuantities
5044
5079
  });
5045
5080
  const quantitiesDict = {};
@@ -5063,8 +5098,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5063
5098
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5064
5099
  cachedUtxos.push(input.id);
5065
5100
  }
5066
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5067
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5101
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5102
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5068
5103
  cachedMessages.push(input.nonce);
5069
5104
  }
5070
5105
  }
@@ -5096,11 +5131,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5096
5131
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5097
5132
  * @returns A promise that resolves to the prepared transaction request.
5098
5133
  */
5099
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5134
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5100
5135
  const { minGasPrice } = this.provider.getGasConfig();
5101
- const params = { gasPrice: minGasPrice, ...txParams };
5136
+ const baseAssetId = this.provider.getBaseAssetId();
5137
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5138
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5102
5139
  const request = new ScriptTransactionRequest(params);
5103
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5140
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5104
5141
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5105
5142
  estimateTxDependencies: true,
5106
5143
  resourcesOwner: this
@@ -5126,14 +5163,15 @@ var Account = class extends import_interfaces.AbstractAccount {
5126
5163
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5127
5164
  * @returns A promise that resolves to the transaction response.
5128
5165
  */
5129
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5166
+ async transfer(destination, amount, assetId, txParams = {}) {
5130
5167
  if ((0, import_math18.bn)(amount).lte(0)) {
5131
5168
  throw new import_errors16.FuelError(
5132
5169
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5133
5170
  "Transfer amount must be a positive number."
5134
5171
  );
5135
5172
  }
5136
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5173
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5174
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5137
5175
  return this.sendTransaction(request, { estimateTxDependencies: false });
5138
5176
  }
5139
5177
  /**
@@ -5145,7 +5183,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5145
5183
  * @param txParams - The optional transaction parameters.
5146
5184
  * @returns A promise that resolves to the transaction response.
5147
5185
  */
5148
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5186
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5149
5187
  if ((0, import_math18.bn)(amount).lte(0)) {
5150
5188
  throw new import_errors16.FuelError(
5151
5189
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -5154,11 +5192,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5154
5192
  }
5155
5193
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5156
5194
  const { minGasPrice } = this.provider.getGasConfig();
5157
- const params = { gasPrice: minGasPrice, ...txParams };
5195
+ const baseAssetId = this.provider.getBaseAssetId();
5196
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5197
+ const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5158
5198
  const { script, scriptData } = await assembleTransferToContractScript({
5159
5199
  hexlifiedContractId: contractAddress.toB256(),
5160
5200
  amountToTransfer: (0, import_math18.bn)(amount),
5161
- assetId
5201
+ assetId: assetIdToTransfer
5162
5202
  });
5163
5203
  const request = new ScriptTransactionRequest({
5164
5204
  ...params,
@@ -5168,7 +5208,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5168
5208
  request.addContractInputAndOutput(contractAddress);
5169
5209
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5170
5210
  request,
5171
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5211
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5172
5212
  );
5173
5213
  request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5174
5214
  this.validateGas({
@@ -5190,6 +5230,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5190
5230
  */
5191
5231
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5192
5232
  const { minGasPrice } = this.provider.getGasConfig();
5233
+ const baseAssetId = this.provider.getBaseAssetId();
5193
5234
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5194
5235
  const recipientDataArray = (0, import_utils28.arrayify)(
5195
5236
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5202,9 +5243,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5202
5243
  ...recipientDataArray,
5203
5244
  ...amountDataArray
5204
5245
  ]);
5205
- const params = { script, gasPrice: minGasPrice, ...txParams };
5246
+ const params = {
5247
+ script,
5248
+ gasPrice: minGasPrice,
5249
+ baseAssetId,
5250
+ ...txParams
5251
+ };
5206
5252
  const request = new ScriptTransactionRequest(params);
5207
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5253
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5208
5254
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5209
5255
  request,
5210
5256
  forwardingQuantities
@@ -8767,7 +8813,6 @@ var StorageAbstract = class {
8767
8813
  // src/predicate/predicate.ts
8768
8814
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8769
8815
  var import_address10 = require("@fuel-ts/address");
8770
- var import_configs13 = require("@fuel-ts/address/configs");
8771
8816
  var import_errors25 = require("@fuel-ts/errors");
8772
8817
  var import_transactions20 = require("@fuel-ts/transactions");
8773
8818
  var import_utils37 = require("@fuel-ts/utils");
@@ -8832,7 +8877,6 @@ var Predicate = class extends Account {
8832
8877
  if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8833
8878
  input.predicate = this.bytes;
8834
8879
  input.predicateData = this.getPredicateData(policies.length);
8835
- input.witnessIndex = 0;
8836
8880
  }
8837
8881
  });
8838
8882
  return request;
@@ -8846,8 +8890,9 @@ var Predicate = class extends Account {
8846
8890
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8847
8891
  * @returns A promise that resolves to the prepared transaction request.
8848
8892
  */
8849
- async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8850
- const request = await super.createTransfer(destination, amount, assetId, txParams);
8893
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8894
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8895
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8851
8896
  return this.populateTransactionPredicateData(request);
8852
8897
  }
8853
8898
  /**
@@ -8870,20 +8915,6 @@ var Predicate = class extends Account {
8870
8915
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8871
8916
  return super.simulateTransaction(transactionRequest);
8872
8917
  }
8873
- /**
8874
- * Retrieves resources satisfying the spend query for the account.
8875
- *
8876
- * @param quantities - IDs of coins to exclude.
8877
- * @param excludedIds - IDs of resources to be excluded from the query.
8878
- * @returns A promise that resolves to an array of Resources.
8879
- */
8880
- async getResourcesToSpend(quantities, excludedIds) {
8881
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8882
- return resources.map((resource) => ({
8883
- ...resource,
8884
- predicate: (0, import_utils37.hexlify)(this.bytes)
8885
- }));
8886
- }
8887
8918
  getPredicateData(policiesLength) {
8888
8919
  if (!this.predicateData.length) {
8889
8920
  return new Uint8Array();