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

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