@fuel-ts/account 0.85.0 → 0.86.0

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 (42) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  3. package/dist/index.global.js +1694 -2854
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +304 -298
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +194 -201
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  10. package/dist/mnemonic/utils.d.ts +0 -1
  11. package/dist/mnemonic/utils.d.ts.map +1 -1
  12. package/dist/predicate/predicate.d.ts +9 -2
  13. package/dist/predicate/predicate.d.ts.map +1 -1
  14. package/dist/providers/coin.d.ts +0 -1
  15. package/dist/providers/coin.d.ts.map +1 -1
  16. package/dist/providers/message.d.ts +0 -1
  17. package/dist/providers/message.d.ts.map +1 -1
  18. package/dist/providers/provider.d.ts +1 -1
  19. package/dist/providers/provider.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/helpers.d.ts +4 -0
  21. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/index.d.ts +1 -0
  23. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/input.d.ts +0 -2
  25. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  26. package/dist/providers/transaction-request/transaction-request.d.ts +2 -1
  27. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  28. package/dist/providers/transaction-request/utils.d.ts +0 -4
  29. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  30. package/dist/providers/transaction-summary/call.d.ts +1 -1
  31. package/dist/providers/transaction-summary/call.d.ts.map +1 -1
  32. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  33. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  34. package/dist/test-utils.global.js +1422 -2616
  35. package/dist/test-utils.global.js.map +1 -1
  36. package/dist/test-utils.js +247 -288
  37. package/dist/test-utils.js.map +1 -1
  38. package/dist/test-utils.mjs +147 -188
  39. package/dist/test-utils.mjs.map +1 -1
  40. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  41. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  42. package/package.json +15 -16
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
88
88
  StorageAbstract: () => StorageAbstract,
89
89
  TransactionResponse: () => TransactionResponse,
90
90
  TransactionStatus: () => TransactionStatus,
91
- TransactionType: () => import_transactions6.TransactionType,
91
+ TransactionType: () => import_transactions7.TransactionType,
92
92
  TransactionTypeName: () => TransactionTypeName,
93
93
  Vault: () => Vault,
94
94
  Wallet: () => Wallet,
@@ -104,7 +104,8 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
107
+ cacheRequestInputsResources: () => cacheRequestInputsResources,
108
+ cacheRequestInputsResourcesFromOwner: () => cacheRequestInputsResourcesFromOwner,
108
109
  calculateGasFee: () => calculateGasFee,
109
110
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
111
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
@@ -118,6 +119,7 @@ __export(src_exports, {
118
119
  extractTxError: () => extractTxError,
119
120
  fuelAssetsBaseUrl: () => fuelAssetsBaseUrl,
120
121
  gasUsedByInputs: () => gasUsedByInputs,
122
+ getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
121
123
  getAssetEth: () => getAssetEth,
122
124
  getAssetFuel: () => getAssetFuel,
123
125
  getAssetNetwork: () => getAssetNetwork,
@@ -152,6 +154,7 @@ __export(src_exports, {
152
154
  getReceiptsMessageOut: () => getReceiptsMessageOut,
153
155
  getReceiptsTransferOut: () => getReceiptsTransferOut,
154
156
  getReceiptsWithMissingData: () => getReceiptsWithMissingData,
157
+ getRequestInputResourceOwner: () => getRequestInputResourceOwner,
155
158
  getTransactionStatusName: () => getTransactionStatusName,
156
159
  getTransactionSummary: () => getTransactionSummary,
157
160
  getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
@@ -165,6 +168,10 @@ __export(src_exports, {
165
168
  isMessage: () => isMessage,
166
169
  isRawCoin: () => isRawCoin,
167
170
  isRawMessage: () => isRawMessage,
171
+ isRequestInputCoin: () => isRequestInputCoin,
172
+ isRequestInputMessage: () => isRequestInputMessage,
173
+ isRequestInputResource: () => isRequestInputResource,
174
+ isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
168
175
  isType: () => isType,
169
176
  isTypeCreate: () => isTypeCreate,
170
177
  isTypeMint: () => isTypeMint,
@@ -191,7 +198,7 @@ module.exports = __toCommonJS(src_exports);
191
198
  var import_address4 = require("@fuel-ts/address");
192
199
  var import_errors16 = require("@fuel-ts/errors");
193
200
  var import_interfaces = require("@fuel-ts/interfaces");
194
- var import_math21 = require("@fuel-ts/math");
201
+ var import_math20 = require("@fuel-ts/math");
195
202
  var import_utils28 = require("@fuel-ts/utils");
196
203
  var import_ramda4 = require("ramda");
197
204
 
@@ -234,7 +241,7 @@ var addAmountToCoinQuantities = (params) => {
234
241
  var import_address3 = require("@fuel-ts/address");
235
242
  var import_errors14 = require("@fuel-ts/errors");
236
243
  var import_math17 = require("@fuel-ts/math");
237
- var import_transactions19 = require("@fuel-ts/transactions");
244
+ var import_transactions20 = require("@fuel-ts/transactions");
238
245
  var import_utils22 = require("@fuel-ts/utils");
239
246
  var import_versions = require("@fuel-ts/versions");
240
247
  var import_utils23 = require("@noble/curves/abstract/utils");
@@ -1451,8 +1458,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1451
1458
  var import_address = require("@fuel-ts/address");
1452
1459
  var import_configs6 = require("@fuel-ts/address/configs");
1453
1460
  var import_crypto = require("@fuel-ts/crypto");
1454
- var import_math7 = require("@fuel-ts/math");
1455
- var import_transactions6 = require("@fuel-ts/transactions");
1461
+ var import_math8 = require("@fuel-ts/math");
1462
+ var import_transactions7 = require("@fuel-ts/transactions");
1456
1463
  var import_utils9 = require("@fuel-ts/utils");
1457
1464
 
1458
1465
  // src/providers/resource.ts
@@ -1959,6 +1966,52 @@ var NoWitnessByOwnerError = class extends Error {
1959
1966
  name = "NoWitnessByOwnerError";
1960
1967
  };
1961
1968
 
1969
+ // src/providers/transaction-request/helpers.ts
1970
+ var import_math7 = require("@fuel-ts/math");
1971
+ var import_transactions6 = require("@fuel-ts/transactions");
1972
+ var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1973
+ var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1974
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1975
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1976
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1977
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1978
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
1979
+ return acc.add(input.amount);
1980
+ }
1981
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
1982
+ return acc.add(input.amount);
1983
+ }
1984
+ return acc;
1985
+ }, (0, import_math7.bn)(0));
1986
+ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
1987
+ (cache2, input) => {
1988
+ if (isRequestInputCoin(input)) {
1989
+ cache2.utxos.push(input.id);
1990
+ } else {
1991
+ cache2.messages.push(input.nonce);
1992
+ }
1993
+ return cache2;
1994
+ },
1995
+ {
1996
+ utxos: [],
1997
+ messages: []
1998
+ }
1999
+ );
2000
+ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
2001
+ (acc, input) => {
2002
+ if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
2003
+ acc.utxos.push(input.id);
2004
+ } else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
2005
+ acc.messages.push(input.nonce);
2006
+ }
2007
+ return acc;
2008
+ },
2009
+ {
2010
+ utxos: [],
2011
+ messages: []
2012
+ }
2013
+ );
2014
+
1962
2015
  // src/providers/transaction-request/witness.ts
1963
2016
  var import_utils8 = require("@fuel-ts/utils");
1964
2017
  var witnessify = (value) => {
@@ -1999,10 +2052,10 @@ var BaseTransactionRequest = class {
1999
2052
  outputs,
2000
2053
  witnesses
2001
2054
  } = {}) {
2002
- this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
2055
+ this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
2003
2056
  this.maturity = maturity && maturity > 0 ? maturity : void 0;
2004
- this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
2005
- this.maxFee = (0, import_math7.bn)(maxFee);
2057
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
2058
+ this.maxFee = (0, import_math8.bn)(maxFee);
2006
2059
  this.inputs = inputs ?? [];
2007
2060
  this.outputs = outputs ?? [];
2008
2061
  this.witnesses = witnesses ?? [];
@@ -2011,20 +2064,20 @@ var BaseTransactionRequest = class {
2011
2064
  let policyTypes = 0;
2012
2065
  const policies = [];
2013
2066
  const { tip, witnessLimit, maturity } = req;
2014
- if ((0, import_math7.bn)(tip).gt(0)) {
2015
- policyTypes += import_transactions6.PolicyType.Tip;
2016
- policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
2067
+ if ((0, import_math8.bn)(tip).gt(0)) {
2068
+ policyTypes += import_transactions7.PolicyType.Tip;
2069
+ policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
2017
2070
  }
2018
- if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
2019
- policyTypes += import_transactions6.PolicyType.WitnessLimit;
2020
- policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
2071
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
2072
+ policyTypes += import_transactions7.PolicyType.WitnessLimit;
2073
+ policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
2021
2074
  }
2022
2075
  if (maturity && maturity > 0) {
2023
- policyTypes += import_transactions6.PolicyType.Maturity;
2024
- policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
2076
+ policyTypes += import_transactions7.PolicyType.Maturity;
2077
+ policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
2025
2078
  }
2026
- policyTypes += import_transactions6.PolicyType.MaxFee;
2027
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
2079
+ policyTypes += import_transactions7.PolicyType.MaxFee;
2080
+ policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
2028
2081
  return {
2029
2082
  policyTypes,
2030
2083
  policies
@@ -2057,7 +2110,7 @@ var BaseTransactionRequest = class {
2057
2110
  * @returns The transaction bytes.
2058
2111
  */
2059
2112
  toTransactionBytes() {
2060
- return new import_transactions6.TransactionCoder().encode(this.toTransaction());
2113
+ return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2061
2114
  }
2062
2115
  /**
2063
2116
  * @hidden
@@ -2148,7 +2201,7 @@ var BaseTransactionRequest = class {
2148
2201
  */
2149
2202
  getCoinInputs() {
2150
2203
  return this.inputs.filter(
2151
- (input) => input.type === import_transactions6.InputType.Coin
2204
+ (input) => input.type === import_transactions7.InputType.Coin
2152
2205
  );
2153
2206
  }
2154
2207
  /**
@@ -2158,7 +2211,7 @@ var BaseTransactionRequest = class {
2158
2211
  */
2159
2212
  getCoinOutputs() {
2160
2213
  return this.outputs.filter(
2161
- (output) => output.type === import_transactions6.OutputType.Coin
2214
+ (output) => output.type === import_transactions7.OutputType.Coin
2162
2215
  );
2163
2216
  }
2164
2217
  /**
@@ -2168,7 +2221,7 @@ var BaseTransactionRequest = class {
2168
2221
  */
2169
2222
  getChangeOutputs() {
2170
2223
  return this.outputs.filter(
2171
- (output) => output.type === import_transactions6.OutputType.Change
2224
+ (output) => output.type === import_transactions7.OutputType.Change
2172
2225
  );
2173
2226
  }
2174
2227
  /**
@@ -2180,9 +2233,9 @@ var BaseTransactionRequest = class {
2180
2233
  const ownerAddress = (0, import_address.addressify)(owner);
2181
2234
  const found = this.inputs.find((input) => {
2182
2235
  switch (input.type) {
2183
- case import_transactions6.InputType.Coin:
2236
+ case import_transactions7.InputType.Coin:
2184
2237
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
2185
- case import_transactions6.InputType.Message:
2238
+ case import_transactions7.InputType.Message:
2186
2239
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
2187
2240
  default:
2188
2241
  return false;
@@ -2197,7 +2250,7 @@ var BaseTransactionRequest = class {
2197
2250
  * @param coin - Coin resource.
2198
2251
  */
2199
2252
  addCoinInput(coin) {
2200
- const { assetId, owner, amount } = coin;
2253
+ const { assetId, owner, amount, id, predicate } = coin;
2201
2254
  let witnessIndex;
2202
2255
  if (coin.predicate) {
2203
2256
  witnessIndex = 0;
@@ -2208,13 +2261,14 @@ var BaseTransactionRequest = class {
2208
2261
  }
2209
2262
  }
2210
2263
  const input = {
2211
- ...coin,
2212
- type: import_transactions6.InputType.Coin,
2264
+ id,
2265
+ type: import_transactions7.InputType.Coin,
2213
2266
  owner: owner.toB256(),
2214
2267
  amount,
2215
2268
  assetId,
2216
2269
  txPointer: "0x00000000000000000000000000000000",
2217
- witnessIndex
2270
+ witnessIndex,
2271
+ predicate
2218
2272
  };
2219
2273
  this.pushInput(input);
2220
2274
  this.addChangeOutput(owner, assetId);
@@ -2226,7 +2280,7 @@ var BaseTransactionRequest = class {
2226
2280
  * @param message - Message resource.
2227
2281
  */
2228
2282
  addMessageInput(message) {
2229
- const { recipient, sender, amount, assetId } = message;
2283
+ const { recipient, sender, amount, predicate, nonce, assetId } = message;
2230
2284
  let witnessIndex;
2231
2285
  if (message.predicate) {
2232
2286
  witnessIndex = 0;
@@ -2237,12 +2291,13 @@ var BaseTransactionRequest = class {
2237
2291
  }
2238
2292
  }
2239
2293
  const input = {
2240
- ...message,
2241
- type: import_transactions6.InputType.Message,
2294
+ nonce,
2295
+ type: import_transactions7.InputType.Message,
2242
2296
  sender: sender.toB256(),
2243
2297
  recipient: recipient.toB256(),
2244
2298
  amount,
2245
- witnessIndex
2299
+ witnessIndex,
2300
+ predicate
2246
2301
  };
2247
2302
  this.pushInput(input);
2248
2303
  this.addChangeOutput(recipient, assetId);
@@ -2282,7 +2337,7 @@ var BaseTransactionRequest = class {
2282
2337
  */
2283
2338
  addCoinOutput(to, amount, assetId) {
2284
2339
  this.pushOutput({
2285
- type: import_transactions6.OutputType.Coin,
2340
+ type: import_transactions7.OutputType.Coin,
2286
2341
  to: (0, import_address.addressify)(to).toB256(),
2287
2342
  amount,
2288
2343
  assetId
@@ -2298,7 +2353,7 @@ var BaseTransactionRequest = class {
2298
2353
  addCoinOutputs(to, quantities) {
2299
2354
  quantities.map(coinQuantityfy).forEach((quantity) => {
2300
2355
  this.pushOutput({
2301
- type: import_transactions6.OutputType.Coin,
2356
+ type: import_transactions7.OutputType.Coin,
2302
2357
  to: (0, import_address.addressify)(to).toB256(),
2303
2358
  amount: quantity.amount,
2304
2359
  assetId: quantity.assetId
@@ -2318,7 +2373,7 @@ var BaseTransactionRequest = class {
2318
2373
  );
2319
2374
  if (!changeOutput) {
2320
2375
  this.pushOutput({
2321
- type: import_transactions6.OutputType.Change,
2376
+ type: import_transactions7.OutputType.Change,
2322
2377
  to: (0, import_address.addressify)(to).toB256(),
2323
2378
  assetId
2324
2379
  });
@@ -2389,7 +2444,7 @@ var BaseTransactionRequest = class {
2389
2444
  const assetInput = findAssetInput(assetId);
2390
2445
  let usedQuantity = quantity;
2391
2446
  if (assetId === baseAssetId) {
2392
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2447
+ usedQuantity = (0, import_math8.bn)("1000000000000000000");
2393
2448
  }
2394
2449
  if (assetInput && "assetId" in assetInput) {
2395
2450
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
@@ -2401,13 +2456,13 @@ var BaseTransactionRequest = class {
2401
2456
  amount: usedQuantity,
2402
2457
  assetId,
2403
2458
  owner: resourcesOwner || import_address.Address.fromRandom(),
2404
- blockCreated: (0, import_math7.bn)(1),
2405
- txCreatedIdx: (0, import_math7.bn)(1)
2459
+ blockCreated: (0, import_math8.bn)(1),
2460
+ txCreatedIdx: (0, import_math8.bn)(1)
2406
2461
  }
2407
2462
  ]);
2408
2463
  }
2409
2464
  };
2410
- updateAssetInput(baseAssetId, (0, import_math7.bn)(1e11));
2465
+ updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
2411
2466
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2412
2467
  }
2413
2468
  /**
@@ -2418,7 +2473,7 @@ var BaseTransactionRequest = class {
2418
2473
  */
2419
2474
  getCoinOutputsQuantities() {
2420
2475
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2421
- amount: (0, import_math7.bn)(amount),
2476
+ amount: (0, import_math8.bn)(amount),
2422
2477
  assetId: assetId.toString()
2423
2478
  }));
2424
2479
  return coinsQuantities;
@@ -2432,73 +2487,75 @@ var BaseTransactionRequest = class {
2432
2487
  toJSON() {
2433
2488
  return normalizeJSON(this);
2434
2489
  }
2490
+ removeWitness(index) {
2491
+ this.witnesses.splice(index, 1);
2492
+ this.adjustWitnessIndexes(index);
2493
+ }
2494
+ adjustWitnessIndexes(removedIndex) {
2495
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2496
+ if (input.witnessIndex > removedIndex) {
2497
+ input.witnessIndex -= 1;
2498
+ }
2499
+ });
2500
+ }
2435
2501
  updatePredicateGasUsed(inputs) {
2436
2502
  this.inputs.forEach((i) => {
2437
2503
  let correspondingInput;
2438
2504
  switch (i.type) {
2439
- case import_transactions6.InputType.Coin:
2440
- correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2505
+ case import_transactions7.InputType.Coin:
2506
+ correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2441
2507
  break;
2442
- case import_transactions6.InputType.Message:
2508
+ case import_transactions7.InputType.Message:
2443
2509
  correspondingInput = inputs.find(
2444
- (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2510
+ (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2445
2511
  );
2446
2512
  break;
2447
2513
  default:
2448
2514
  return;
2449
2515
  }
2450
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2516
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2451
2517
  i.predicate = correspondingInput.predicate;
2452
2518
  i.predicateData = correspondingInput.predicateData;
2453
2519
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
2454
2520
  }
2455
2521
  });
2456
2522
  }
2457
- shiftPredicateData() {
2458
- this.inputs.forEach((input) => {
2459
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2460
- input.predicateData = input.padPredicateData(
2461
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2462
- );
2463
- }
2464
- });
2465
- }
2466
2523
  };
2467
2524
 
2468
2525
  // src/providers/transaction-request/create-transaction-request.ts
2469
2526
  var import_configs8 = require("@fuel-ts/address/configs");
2470
- var import_math9 = require("@fuel-ts/math");
2471
- var import_transactions8 = require("@fuel-ts/transactions");
2527
+ var import_math10 = require("@fuel-ts/math");
2528
+ var import_transactions9 = require("@fuel-ts/transactions");
2472
2529
  var import_utils13 = require("@fuel-ts/utils");
2473
2530
 
2474
2531
  // src/providers/transaction-request/hash-transaction.ts
2475
2532
  var import_configs7 = require("@fuel-ts/address/configs");
2476
2533
  var import_hasher = require("@fuel-ts/hasher");
2477
- var import_math8 = require("@fuel-ts/math");
2478
- var import_transactions7 = require("@fuel-ts/transactions");
2534
+ var import_math9 = require("@fuel-ts/math");
2535
+ var import_transactions8 = require("@fuel-ts/transactions");
2479
2536
  var import_utils11 = require("@fuel-ts/utils");
2480
2537
  var import_ramda2 = require("ramda");
2481
2538
  function hashTransaction(transactionRequest, chainId) {
2482
2539
  const transaction = transactionRequest.toTransaction();
2483
- if (transaction.type === import_transactions7.TransactionType.Script) {
2540
+ if (transaction.type === import_transactions8.TransactionType.Script) {
2484
2541
  transaction.receiptsRoot = import_configs7.ZeroBytes32;
2485
2542
  }
2486
2543
  transaction.inputs = transaction.inputs.map((input) => {
2487
2544
  const inputClone = (0, import_ramda2.clone)(input);
2488
2545
  switch (inputClone.type) {
2489
- case import_transactions7.InputType.Coin: {
2546
+ case import_transactions8.InputType.Coin: {
2490
2547
  inputClone.txPointer = {
2491
2548
  blockHeight: 0,
2492
2549
  txIndex: 0
2493
2550
  };
2494
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2551
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2495
2552
  return inputClone;
2496
2553
  }
2497
- case import_transactions7.InputType.Message: {
2498
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2554
+ case import_transactions8.InputType.Message: {
2555
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2499
2556
  return inputClone;
2500
2557
  }
2501
- case import_transactions7.InputType.Contract: {
2558
+ case import_transactions8.InputType.Contract: {
2502
2559
  inputClone.txPointer = {
2503
2560
  blockHeight: 0,
2504
2561
  txIndex: 0
@@ -2516,18 +2573,18 @@ function hashTransaction(transactionRequest, chainId) {
2516
2573
  transaction.outputs = transaction.outputs.map((output) => {
2517
2574
  const outputClone = (0, import_ramda2.clone)(output);
2518
2575
  switch (outputClone.type) {
2519
- case import_transactions7.OutputType.Contract: {
2576
+ case import_transactions8.OutputType.Contract: {
2520
2577
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
2521
2578
  outputClone.stateRoot = import_configs7.ZeroBytes32;
2522
2579
  return outputClone;
2523
2580
  }
2524
- case import_transactions7.OutputType.Change: {
2525
- outputClone.amount = (0, import_math8.bn)(0);
2581
+ case import_transactions8.OutputType.Change: {
2582
+ outputClone.amount = (0, import_math9.bn)(0);
2526
2583
  return outputClone;
2527
2584
  }
2528
- case import_transactions7.OutputType.Variable: {
2585
+ case import_transactions8.OutputType.Variable: {
2529
2586
  outputClone.to = import_configs7.ZeroBytes32;
2530
- outputClone.amount = (0, import_math8.bn)(0);
2587
+ outputClone.amount = (0, import_math9.bn)(0);
2531
2588
  outputClone.assetId = import_configs7.ZeroBytes32;
2532
2589
  return outputClone;
2533
2590
  }
@@ -2538,7 +2595,7 @@ function hashTransaction(transactionRequest, chainId) {
2538
2595
  transaction.witnessesCount = 0;
2539
2596
  transaction.witnesses = [];
2540
2597
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2541
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2598
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
2542
2599
  return (0, import_hasher.sha256)(concatenatedData);
2543
2600
  }
2544
2601
 
@@ -2574,7 +2631,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2574
2631
  return new this(obj);
2575
2632
  }
2576
2633
  /** Type of the transaction */
2577
- type = import_transactions8.TransactionType.Create;
2634
+ type = import_transactions9.TransactionType.Create;
2578
2635
  /** Witness index of contract bytecode to create */
2579
2636
  bytecodeWitnessIndex;
2580
2637
  /** Salt */
@@ -2602,10 +2659,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2602
2659
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2603
2660
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2604
2661
  return {
2605
- type: import_transactions8.TransactionType.Create,
2662
+ type: import_transactions9.TransactionType.Create,
2606
2663
  ...baseTransaction,
2607
2664
  bytecodeWitnessIndex,
2608
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2665
+ storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
2609
2666
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2610
2667
  storageSlots
2611
2668
  };
@@ -2617,7 +2674,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2617
2674
  */
2618
2675
  getContractCreatedOutputs() {
2619
2676
  return this.outputs.filter(
2620
- (output) => output.type === import_transactions8.OutputType.ContractCreated
2677
+ (output) => output.type === import_transactions9.OutputType.ContractCreated
2621
2678
  );
2622
2679
  }
2623
2680
  /**
@@ -2638,14 +2695,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2638
2695
  */
2639
2696
  addContractCreatedOutput(contractId, stateRoot) {
2640
2697
  this.pushOutput({
2641
- type: import_transactions8.OutputType.ContractCreated,
2698
+ type: import_transactions9.OutputType.ContractCreated,
2642
2699
  contractId,
2643
2700
  stateRoot
2644
2701
  });
2645
2702
  }
2646
2703
  metadataGas(gasCosts) {
2647
2704
  return calculateMetadataGasForTxCreate({
2648
- contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2705
+ contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2649
2706
  gasCosts,
2650
2707
  stateRootSize: this.storageSlots.length,
2651
2708
  txBytesSize: this.byteSize()
@@ -2657,8 +2714,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2657
2714
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2658
2715
  var import_address2 = require("@fuel-ts/address");
2659
2716
  var import_configs9 = require("@fuel-ts/address/configs");
2660
- var import_math10 = require("@fuel-ts/math");
2661
- var import_transactions9 = require("@fuel-ts/transactions");
2717
+ var import_math11 = require("@fuel-ts/math");
2718
+ var import_transactions10 = require("@fuel-ts/transactions");
2662
2719
  var import_utils15 = require("@fuel-ts/utils");
2663
2720
 
2664
2721
  // src/providers/transaction-request/scripts.ts
@@ -2696,7 +2753,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2696
2753
  return new this(obj);
2697
2754
  }
2698
2755
  /** Type of the transaction */
2699
- type = import_transactions9.TransactionType.Script;
2756
+ type = import_transactions10.TransactionType.Script;
2700
2757
  /** Gas limit for transaction */
2701
2758
  gasLimit;
2702
2759
  /** Script to execute */
@@ -2711,7 +2768,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2711
2768
  */
2712
2769
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2713
2770
  super(rest);
2714
- this.gasLimit = (0, import_math10.bn)(gasLimit);
2771
+ this.gasLimit = (0, import_math11.bn)(gasLimit);
2715
2772
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2716
2773
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2717
2774
  this.abis = rest.abis;
@@ -2725,11 +2782,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2725
2782
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2726
2783
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2727
2784
  return {
2728
- type: import_transactions9.TransactionType.Script,
2785
+ type: import_transactions10.TransactionType.Script,
2729
2786
  scriptGasLimit: this.gasLimit,
2730
2787
  ...super.getBaseTransaction(),
2731
- scriptLength: (0, import_math10.bn)(script.length),
2732
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2788
+ scriptLength: (0, import_math11.bn)(script.length),
2789
+ scriptDataLength: (0, import_math11.bn)(scriptData.length),
2733
2790
  receiptsRoot: import_configs9.ZeroBytes32,
2734
2791
  script: (0, import_utils15.hexlify)(script),
2735
2792
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2742,7 +2799,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2742
2799
  */
2743
2800
  getContractInputs() {
2744
2801
  return this.inputs.filter(
2745
- (input) => input.type === import_transactions9.InputType.Contract
2802
+ (input) => input.type === import_transactions10.InputType.Contract
2746
2803
  );
2747
2804
  }
2748
2805
  /**
@@ -2752,7 +2809,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2752
2809
  */
2753
2810
  getContractOutputs() {
2754
2811
  return this.outputs.filter(
2755
- (output) => output.type === import_transactions9.OutputType.Contract
2812
+ (output) => output.type === import_transactions10.OutputType.Contract
2756
2813
  );
2757
2814
  }
2758
2815
  /**
@@ -2762,7 +2819,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2762
2819
  */
2763
2820
  getVariableOutputs() {
2764
2821
  return this.outputs.filter(
2765
- (output) => output.type === import_transactions9.OutputType.Variable
2822
+ (output) => output.type === import_transactions10.OutputType.Variable
2766
2823
  );
2767
2824
  }
2768
2825
  /**
@@ -2785,7 +2842,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2785
2842
  let outputsNumber = numberOfVariables;
2786
2843
  while (outputsNumber) {
2787
2844
  this.pushOutput({
2788
- type: import_transactions9.OutputType.Variable
2845
+ type: import_transactions10.OutputType.Variable
2789
2846
  });
2790
2847
  outputsNumber -= 1;
2791
2848
  }
@@ -2822,12 +2879,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2822
2879
  return this;
2823
2880
  }
2824
2881
  const inputIndex = super.pushInput({
2825
- type: import_transactions9.InputType.Contract,
2882
+ type: import_transactions10.InputType.Contract,
2826
2883
  contractId: contractAddress.toB256(),
2827
2884
  txPointer: "0x00000000000000000000000000000000"
2828
2885
  });
2829
2886
  this.pushOutput({
2830
- type: import_transactions9.OutputType.Contract,
2887
+ type: import_transactions10.OutputType.Contract,
2831
2888
  inputIndex
2832
2889
  });
2833
2890
  return this;
@@ -2864,17 +2921,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2864
2921
 
2865
2922
  // src/providers/transaction-request/utils.ts
2866
2923
  var import_errors9 = require("@fuel-ts/errors");
2867
- var import_transactions10 = require("@fuel-ts/transactions");
2924
+ var import_transactions11 = require("@fuel-ts/transactions");
2868
2925
  var transactionRequestify = (obj) => {
2869
2926
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2870
2927
  return obj;
2871
2928
  }
2872
2929
  const { type } = obj;
2873
2930
  switch (obj.type) {
2874
- case import_transactions10.TransactionType.Script: {
2931
+ case import_transactions11.TransactionType.Script: {
2875
2932
  return ScriptTransactionRequest.from(obj);
2876
2933
  }
2877
- case import_transactions10.TransactionType.Create: {
2934
+ case import_transactions11.TransactionType.Create: {
2878
2935
  return CreateTransactionRequest.from(obj);
2879
2936
  }
2880
2937
  default: {
@@ -2882,36 +2939,21 @@ var transactionRequestify = (obj) => {
2882
2939
  }
2883
2940
  }
2884
2941
  };
2885
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2886
- (acc, input) => {
2887
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2888
- acc.utxos.push(input.id);
2889
- }
2890
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2891
- acc.messages.push(input.nonce);
2892
- }
2893
- return acc;
2894
- },
2895
- {
2896
- utxos: [],
2897
- messages: []
2898
- }
2899
- );
2900
2942
 
2901
2943
  // src/providers/transaction-response/transaction-response.ts
2902
2944
  var import_errors13 = require("@fuel-ts/errors");
2903
2945
  var import_math16 = require("@fuel-ts/math");
2904
- var import_transactions18 = require("@fuel-ts/transactions");
2946
+ var import_transactions19 = require("@fuel-ts/transactions");
2905
2947
  var import_utils20 = require("@fuel-ts/utils");
2906
2948
 
2907
2949
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2908
2950
  var import_math15 = require("@fuel-ts/math");
2909
- var import_transactions16 = require("@fuel-ts/transactions");
2951
+ var import_transactions17 = require("@fuel-ts/transactions");
2910
2952
  var import_utils18 = require("@fuel-ts/utils");
2911
2953
 
2912
2954
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2913
- var import_math11 = require("@fuel-ts/math");
2914
- var import_transactions11 = require("@fuel-ts/transactions");
2955
+ var import_math12 = require("@fuel-ts/math");
2956
+ var import_transactions12 = require("@fuel-ts/transactions");
2915
2957
  var import_utils16 = require("@fuel-ts/utils");
2916
2958
  var calculateTXFeeForSummary = (params) => {
2917
2959
  const {
@@ -2924,19 +2966,19 @@ var calculateTXFeeForSummary = (params) => {
2924
2966
  if (totalFee) {
2925
2967
  return totalFee;
2926
2968
  }
2927
- const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2928
- const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2969
+ const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
2970
+ const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
2929
2971
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2930
- const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2972
+ const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
2931
2973
  const { type, witnesses, inputs, policies } = transaction;
2932
- let metadataGas = (0, import_math11.bn)(0);
2933
- let gasLimit = (0, import_math11.bn)(0);
2934
- if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2935
- return (0, import_math11.bn)(0);
2974
+ let metadataGas = (0, import_math12.bn)(0);
2975
+ let gasLimit = (0, import_math12.bn)(0);
2976
+ if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
2977
+ return (0, import_math12.bn)(0);
2936
2978
  }
2937
- if (type === import_transactions11.TransactionType.Create) {
2979
+ if (type === import_transactions12.TransactionType.Create) {
2938
2980
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2939
- const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2981
+ const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2940
2982
  metadataGas = calculateMetadataGasForTxCreate({
2941
2983
  contractBytesSize,
2942
2984
  gasCosts,
@@ -2955,12 +2997,12 @@ var calculateTXFeeForSummary = (params) => {
2955
2997
  }
2956
2998
  const minGas = getMinGas({
2957
2999
  gasCosts,
2958
- gasPerByte: (0, import_math11.bn)(gasPerByte),
3000
+ gasPerByte: (0, import_math12.bn)(gasPerByte),
2959
3001
  inputs,
2960
3002
  metadataGas,
2961
3003
  txBytesSize: transactionBytes.length
2962
3004
  });
2963
- const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
3005
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
2964
3006
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2965
3007
  const maxGas = getMaxGas({
2966
3008
  gasPerByte,
@@ -2983,42 +3025,31 @@ var calculateTXFeeForSummary = (params) => {
2983
3025
  var import_configs10 = require("@fuel-ts/address/configs");
2984
3026
  var import_errors11 = require("@fuel-ts/errors");
2985
3027
  var import_math13 = require("@fuel-ts/math");
2986
- var import_transactions14 = require("@fuel-ts/transactions");
3028
+ var import_transactions15 = require("@fuel-ts/transactions");
2987
3029
 
2988
3030
  // src/providers/transaction-summary/call.ts
2989
3031
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
2990
- var import_math12 = require("@fuel-ts/math");
2991
- var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
3032
+ var getFunctionCall = ({ abi, receipt }) => {
2992
3033
  const abiInterface = new import_abi_coder4.Interface(abi);
2993
3034
  const callFunctionSelector = receipt.param1.toHex(8);
2994
3035
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2995
3036
  const inputs = functionFragment.jsonFn.inputs;
2996
- let encodedArgs;
2997
- if (functionFragment.isInputDataPointer) {
2998
- if (rawPayload) {
2999
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
3000
- encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
3001
- }
3002
- } else {
3003
- encodedArgs = receipt.param2.toHex();
3004
- }
3037
+ const encodedArgs = receipt.param2.toHex();
3005
3038
  let argumentsProvided;
3006
- if (encodedArgs) {
3007
- const data = functionFragment.decodeArguments(encodedArgs);
3008
- if (data) {
3009
- argumentsProvided = inputs.reduce((prev, input, index) => {
3010
- const value = data[index];
3011
- const name = input.name;
3012
- if (name) {
3013
- return {
3014
- ...prev,
3015
- // reparse to remove bn
3016
- [name]: JSON.parse(JSON.stringify(value))
3017
- };
3018
- }
3019
- return prev;
3020
- }, {});
3021
- }
3039
+ const data = functionFragment.decodeArguments(encodedArgs);
3040
+ if (data) {
3041
+ argumentsProvided = inputs.reduce((prev, input, index) => {
3042
+ const value = data[index];
3043
+ const name = input.name;
3044
+ if (name) {
3045
+ return {
3046
+ ...prev,
3047
+ // reparse to remove bn
3048
+ [name]: JSON.parse(JSON.stringify(value))
3049
+ };
3050
+ }
3051
+ return prev;
3052
+ }, {});
3022
3053
  }
3023
3054
  const call = {
3024
3055
  functionSignature: functionFragment.signature,
@@ -3031,7 +3062,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
3031
3062
 
3032
3063
  // src/providers/transaction-summary/input.ts
3033
3064
  var import_errors10 = require("@fuel-ts/errors");
3034
- var import_transactions12 = require("@fuel-ts/transactions");
3065
+ var import_transactions13 = require("@fuel-ts/transactions");
3035
3066
  function getInputsByTypes(inputs, types) {
3036
3067
  return inputs.filter((i) => types.includes(i.type));
3037
3068
  }
@@ -3039,16 +3070,16 @@ function getInputsByType(inputs, type) {
3039
3070
  return inputs.filter((i) => i.type === type);
3040
3071
  }
3041
3072
  function getInputsCoin(inputs) {
3042
- return getInputsByType(inputs, import_transactions12.InputType.Coin);
3073
+ return getInputsByType(inputs, import_transactions13.InputType.Coin);
3043
3074
  }
3044
3075
  function getInputsMessage(inputs) {
3045
- return getInputsByType(inputs, import_transactions12.InputType.Message);
3076
+ return getInputsByType(inputs, import_transactions13.InputType.Message);
3046
3077
  }
3047
3078
  function getInputsCoinAndMessage(inputs) {
3048
- return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
3079
+ return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
3049
3080
  }
3050
3081
  function getInputsContract(inputs) {
3051
- return getInputsByType(inputs, import_transactions12.InputType.Contract);
3082
+ return getInputsByType(inputs, import_transactions13.InputType.Contract);
3052
3083
  }
3053
3084
  function getInputFromAssetId(inputs, assetId) {
3054
3085
  const coinInputs = getInputsCoin(inputs);
@@ -3067,7 +3098,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
3067
3098
  if (!contractInput) {
3068
3099
  return void 0;
3069
3100
  }
3070
- if (contractInput.type !== import_transactions12.InputType.Contract) {
3101
+ if (contractInput.type !== import_transactions13.InputType.Contract) {
3071
3102
  throw new import_errors10.FuelError(
3072
3103
  import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
3073
3104
  `Contract input should be of type 'contract'.`
@@ -3076,34 +3107,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
3076
3107
  return contractInput;
3077
3108
  }
3078
3109
  function getInputAccountAddress(input) {
3079
- if (input.type === import_transactions12.InputType.Coin) {
3110
+ if (input.type === import_transactions13.InputType.Coin) {
3080
3111
  return input.owner.toString();
3081
3112
  }
3082
- if (input.type === import_transactions12.InputType.Message) {
3113
+ if (input.type === import_transactions13.InputType.Message) {
3083
3114
  return input.recipient.toString();
3084
3115
  }
3085
3116
  return "";
3086
3117
  }
3087
3118
 
3088
3119
  // src/providers/transaction-summary/output.ts
3089
- var import_transactions13 = require("@fuel-ts/transactions");
3120
+ var import_transactions14 = require("@fuel-ts/transactions");
3090
3121
  function getOutputsByType(outputs, type) {
3091
3122
  return outputs.filter((o) => o.type === type);
3092
3123
  }
3093
3124
  function getOutputsContractCreated(outputs) {
3094
- return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
3125
+ return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
3095
3126
  }
3096
3127
  function getOutputsCoin(outputs) {
3097
- return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
3128
+ return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
3098
3129
  }
3099
3130
  function getOutputsChange(outputs) {
3100
- return getOutputsByType(outputs, import_transactions13.OutputType.Change);
3131
+ return getOutputsByType(outputs, import_transactions14.OutputType.Change);
3101
3132
  }
3102
3133
  function getOutputsContract(outputs) {
3103
- return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
3134
+ return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
3104
3135
  }
3105
3136
  function getOutputsVariable(outputs) {
3106
- return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
3137
+ return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
3107
3138
  }
3108
3139
 
3109
3140
  // src/providers/transaction-summary/types.ts
@@ -3152,11 +3183,11 @@ function getReceiptsByType(receipts, type) {
3152
3183
  }
3153
3184
  function getTransactionTypeName(transactionType) {
3154
3185
  switch (transactionType) {
3155
- case import_transactions14.TransactionType.Mint:
3186
+ case import_transactions15.TransactionType.Mint:
3156
3187
  return "Mint" /* Mint */;
3157
- case import_transactions14.TransactionType.Create:
3188
+ case import_transactions15.TransactionType.Create:
3158
3189
  return "Create" /* Create */;
3159
- case import_transactions14.TransactionType.Script:
3190
+ case import_transactions15.TransactionType.Script:
3160
3191
  return "Script" /* Script */;
3161
3192
  default:
3162
3193
  throw new import_errors11.FuelError(
@@ -3188,10 +3219,10 @@ function hasSameAssetId(a) {
3188
3219
  return (b) => a.assetId === b.assetId;
3189
3220
  }
3190
3221
  function getReceiptsCall(receipts) {
3191
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
3222
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
3192
3223
  }
3193
3224
  function getReceiptsMessageOut(receipts) {
3194
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
3225
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
3195
3226
  }
3196
3227
  var mergeAssets = (op1, op2) => {
3197
3228
  const assets1 = op1.assetsSent || [];
@@ -3230,7 +3261,7 @@ function addOperation(operations, toAdd) {
3230
3261
  return allOperations;
3231
3262
  }
3232
3263
  function getReceiptsTransferOut(receipts) {
3233
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
3264
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
3234
3265
  }
3235
3266
  function getWithdrawFromFuelOperations({
3236
3267
  inputs,
@@ -3390,11 +3421,11 @@ function getTransferOperations({
3390
3421
  });
3391
3422
  const transferReceipts = getReceiptsByType(
3392
3423
  receipts,
3393
- import_transactions14.ReceiptType.Transfer
3424
+ import_transactions15.ReceiptType.Transfer
3394
3425
  );
3395
3426
  const transferOutReceipts = getReceiptsByType(
3396
3427
  receipts,
3397
- import_transactions14.ReceiptType.TransferOut
3428
+ import_transactions15.ReceiptType.TransferOut
3398
3429
  );
3399
3430
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3400
3431
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3479,17 +3510,17 @@ function getOperations({
3479
3510
  }
3480
3511
 
3481
3512
  // src/providers/transaction-summary/receipt.ts
3482
- var import_transactions15 = require("@fuel-ts/transactions");
3513
+ var import_transactions16 = require("@fuel-ts/transactions");
3483
3514
  var processGqlReceipt = (gqlReceipt) => {
3484
3515
  const receipt = assembleReceiptByType(gqlReceipt);
3485
3516
  switch (receipt.type) {
3486
- case import_transactions15.ReceiptType.ReturnData: {
3517
+ case import_transactions16.ReceiptType.ReturnData: {
3487
3518
  return {
3488
3519
  ...receipt,
3489
3520
  data: gqlReceipt.data || "0x"
3490
3521
  };
3491
3522
  }
3492
- case import_transactions15.ReceiptType.LogData: {
3523
+ case import_transactions16.ReceiptType.LogData: {
3493
3524
  return {
3494
3525
  ...receipt,
3495
3526
  data: gqlReceipt.data || "0x"
@@ -3502,7 +3533,7 @@ var processGqlReceipt = (gqlReceipt) => {
3502
3533
  var extractMintedAssetsFromReceipts = (receipts) => {
3503
3534
  const mintedAssets = [];
3504
3535
  receipts.forEach((receipt) => {
3505
- if (receipt.type === import_transactions15.ReceiptType.Mint) {
3536
+ if (receipt.type === import_transactions16.ReceiptType.Mint) {
3506
3537
  mintedAssets.push({
3507
3538
  subId: receipt.subId,
3508
3539
  contractId: receipt.contractId,
@@ -3516,7 +3547,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3516
3547
  var extractBurnedAssetsFromReceipts = (receipts) => {
3517
3548
  const burnedAssets = [];
3518
3549
  receipts.forEach((receipt) => {
3519
- if (receipt.type === import_transactions15.ReceiptType.Burn) {
3550
+ if (receipt.type === import_transactions16.ReceiptType.Burn) {
3520
3551
  burnedAssets.push({
3521
3552
  subId: receipt.subId,
3522
3553
  contractId: receipt.contractId,
@@ -3622,7 +3653,7 @@ function assembleTransactionSummary(params) {
3622
3653
  maxInputs
3623
3654
  });
3624
3655
  const typeName = getTransactionTypeName(transaction.type);
3625
- const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3656
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
3626
3657
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3627
3658
  const fee = calculateTXFeeForSummary({
3628
3659
  totalFee,
@@ -3673,12 +3704,12 @@ function assembleTransactionSummary(params) {
3673
3704
 
3674
3705
  // src/providers/transaction-response/getDecodedLogs.ts
3675
3706
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3676
- var import_transactions17 = require("@fuel-ts/transactions");
3707
+ var import_transactions18 = require("@fuel-ts/transactions");
3677
3708
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3678
3709
  return receipts.reduce((logs, receipt) => {
3679
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3710
+ if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
3680
3711
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3681
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3712
+ const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3682
3713
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3683
3714
  logs.push(decodedLog);
3684
3715
  }
@@ -3751,7 +3782,7 @@ var TransactionResponse = class {
3751
3782
  * @returns The decoded transaction.
3752
3783
  */
3753
3784
  decodeTransaction(transactionWithReceipts) {
3754
- return new import_transactions18.TransactionCoder().decode(
3785
+ return new import_transactions19.TransactionCoder().decode(
3755
3786
  (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3756
3787
  0
3757
3788
  )?.[0];
@@ -4232,7 +4263,7 @@ Supported fuel-core version: ${supportedVersion}.`
4232
4263
  }
4233
4264
  const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4234
4265
  let abis;
4235
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4266
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4236
4267
  abis = transactionRequest.abis;
4237
4268
  }
4238
4269
  if (awaitExecution) {
@@ -4324,7 +4355,7 @@ Supported fuel-core version: ${supportedVersion}.`
4324
4355
  * @returns A promise.
4325
4356
  */
4326
4357
  async estimateTxDependencies(transactionRequest) {
4327
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4358
+ if (transactionRequest.type === import_transactions20.TransactionType.Create) {
4328
4359
  return {
4329
4360
  receipts: [],
4330
4361
  outputVariables: 0,
@@ -4388,7 +4419,7 @@ Supported fuel-core version: ${supportedVersion}.`
4388
4419
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4389
4420
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4390
4421
  allRequests.forEach((req, index) => {
4391
- if (req.type === import_transactions19.TransactionType.Script) {
4422
+ if (req.type === import_transactions20.TransactionType.Script) {
4392
4423
  serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4393
4424
  }
4394
4425
  });
@@ -4414,7 +4445,7 @@ Supported fuel-core version: ${supportedVersion}.`
4414
4445
  );
4415
4446
  const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4416
4447
  const request = allRequests[requestIdx];
4417
- if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4448
+ if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
4418
4449
  result.outputVariables += missingOutputVariables.length;
4419
4450
  request.addVariableOutputs(missingOutputVariables.length);
4420
4451
  missingOutputContractIds.forEach(({ contractId }) => {
@@ -4470,7 +4501,7 @@ Supported fuel-core version: ${supportedVersion}.`
4470
4501
  tip: transactionRequest.tip
4471
4502
  }).add(1);
4472
4503
  let gasLimit = (0, import_math17.bn)(0);
4473
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4504
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4474
4505
  gasLimit = transactionRequest.gasLimit;
4475
4506
  if (transactionRequest.gasLimit.eq(0)) {
4476
4507
  transactionRequest.gasLimit = minGas;
@@ -4540,7 +4571,7 @@ Supported fuel-core version: ${supportedVersion}.`
4540
4571
  */
4541
4572
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4542
4573
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4543
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4574
+ const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
4544
4575
  const baseAssetId = this.getBaseAssetId();
4545
4576
  const updateMaxFee = txRequestClone.maxFee.eq(0);
4546
4577
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
@@ -4764,7 +4795,7 @@ Supported fuel-core version: ${supportedVersion}.`
4764
4795
  time: block.header.time,
4765
4796
  transactionIds: block.transactions.map((tx) => tx.id),
4766
4797
  transactions: block.transactions.map(
4767
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4798
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4768
4799
  )
4769
4800
  };
4770
4801
  }
@@ -4779,7 +4810,7 @@ Supported fuel-core version: ${supportedVersion}.`
4779
4810
  if (!transaction) {
4780
4811
  return null;
4781
4812
  }
4782
- return new import_transactions19.TransactionCoder().decode(
4813
+ return new import_transactions20.TransactionCoder().decode(
4783
4814
  (0, import_utils22.arrayify)(transaction.rawPayload),
4784
4815
  0
4785
4816
  )?.[0];
@@ -4859,7 +4890,7 @@ Supported fuel-core version: ${supportedVersion}.`
4859
4890
  });
4860
4891
  const messages = result.messages.edges.map((edge) => edge.node);
4861
4892
  return messages.map((message) => ({
4862
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4893
+ messageId: import_transactions20.InputMessageCoder.getMessageId({
4863
4894
  sender: message.sender,
4864
4895
  recipient: message.recipient,
4865
4896
  nonce: message.nonce,
@@ -4870,7 +4901,7 @@ Supported fuel-core version: ${supportedVersion}.`
4870
4901
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4871
4902
  nonce: message.nonce,
4872
4903
  amount: (0, import_math17.bn)(message.amount),
4873
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4904
+ data: import_transactions20.InputMessageCoder.decodeData(message.data),
4874
4905
  daHeight: (0, import_math17.bn)(message.daHeight)
4875
4906
  }));
4876
4907
  }
@@ -5036,7 +5067,7 @@ cacheInputs_fn = function(inputs) {
5036
5067
  return;
5037
5068
  }
5038
5069
  inputs.forEach((input) => {
5039
- if (input.type === import_transactions19.InputType.Coin) {
5070
+ if (input.type === import_transactions20.InputType.Coin) {
5040
5071
  this.cache?.set(input.id);
5041
5072
  }
5042
5073
  });
@@ -5047,7 +5078,7 @@ __publicField(Provider, "nodeInfoCache", {});
5047
5078
  // src/providers/transaction-summary/get-transaction-summary.ts
5048
5079
  var import_errors15 = require("@fuel-ts/errors");
5049
5080
  var import_math18 = require("@fuel-ts/math");
5050
- var import_transactions20 = require("@fuel-ts/transactions");
5081
+ var import_transactions21 = require("@fuel-ts/transactions");
5051
5082
  var import_utils25 = require("@fuel-ts/utils");
5052
5083
  async function getTransactionSummary(params) {
5053
5084
  const { id, provider, abiMap } = params;
@@ -5060,7 +5091,7 @@ async function getTransactionSummary(params) {
5060
5091
  `Transaction not found for given id: ${id}.`
5061
5092
  );
5062
5093
  }
5063
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
5094
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
5064
5095
  (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
5065
5096
  0
5066
5097
  );
@@ -5133,7 +5164,7 @@ async function getTransactionsSummaries(params) {
5133
5164
  const transactions = edges.map((edge) => {
5134
5165
  const { node: gqlTransaction } = edge;
5135
5166
  const { id, rawPayload, status } = gqlTransaction;
5136
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5167
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5137
5168
  let txReceipts = [];
5138
5169
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5139
5170
  txReceipts = gqlTransaction.status.receipts;
@@ -5290,31 +5321,15 @@ var rawAssets = [
5290
5321
  ];
5291
5322
  var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
5292
5323
 
5293
- // src/providers/transaction-request/helpers.ts
5294
- var import_math19 = require("@fuel-ts/math");
5295
- var import_transactions21 = require("@fuel-ts/transactions");
5296
- var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
5297
- var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
5298
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
5299
- var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
5300
- if (isRequestInputCoin(input) && input.assetId === assetId) {
5301
- return acc.add(input.amount);
5302
- }
5303
- if (isRequestInputMessage(input) && assetId === baseAsset) {
5304
- return acc.add(input.amount);
5305
- }
5306
- return acc;
5307
- }, (0, import_math19.bn)(0));
5308
-
5309
5324
  // src/utils/formatTransferToContractScriptData.ts
5310
5325
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5311
- var import_math20 = require("@fuel-ts/math");
5326
+ var import_math19 = require("@fuel-ts/math");
5312
5327
  var import_utils27 = require("@fuel-ts/utils");
5313
5328
  var asm = __toESM(require("@fuels/vm-asm"));
5314
5329
  var formatTransferToContractScriptData = (params) => {
5315
5330
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5316
5331
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5317
- const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
5332
+ const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
5318
5333
  const scriptData = Uint8Array.from([
5319
5334
  ...(0, import_utils27.arrayify)(hexlifiedContractId),
5320
5335
  ...encoded,
@@ -5509,9 +5524,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5509
5524
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
5510
5525
  const fee = request.maxFee;
5511
5526
  const baseAssetId = this.provider.getBaseAssetId();
5512
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5527
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
5513
5528
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5514
- amount: (0, import_math21.bn)(fee),
5529
+ amount: (0, import_math20.bn)(fee),
5515
5530
  assetId: baseAssetId,
5516
5531
  coinQuantities: requiredQuantities
5517
5532
  });
@@ -5519,7 +5534,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5519
5534
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5520
5535
  quantitiesDict[assetId] = {
5521
5536
  required: amount,
5522
- owned: (0, import_math21.bn)(0)
5537
+ owned: (0, import_math20.bn)(0)
5523
5538
  };
5524
5539
  });
5525
5540
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -5543,10 +5558,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5543
5558
  while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5544
5559
  const resources = await this.getResourcesToSpend(
5545
5560
  missingQuantities,
5546
- cacheTxInputsFromOwner(request.inputs, this.address)
5561
+ cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5547
5562
  );
5548
5563
  request.addResources(resources);
5549
- request.shiftPredicateData();
5550
5564
  request.updatePredicateGasUsed(estimatedPredicates);
5551
5565
  const requestToReestimate2 = (0, import_ramda4.clone)(request);
5552
5566
  if (addedSignatures) {
@@ -5578,7 +5592,6 @@ var Account = class extends import_interfaces.AbstractAccount {
5578
5592
  }
5579
5593
  fundingAttempts += 1;
5580
5594
  }
5581
- request.shiftPredicateData();
5582
5595
  request.updatePredicateGasUsed(estimatedPredicates);
5583
5596
  const requestToReestimate = (0, import_ramda4.clone)(request);
5584
5597
  if (addedSignatures) {
@@ -5629,7 +5642,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5629
5642
  * @returns A promise that resolves to the transaction response.
5630
5643
  */
5631
5644
  async transfer(destination, amount, assetId, txParams = {}) {
5632
- if ((0, import_math21.bn)(amount).lte(0)) {
5645
+ if ((0, import_math20.bn)(amount).lte(0)) {
5633
5646
  throw new import_errors16.FuelError(
5634
5647
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5635
5648
  "Transfer amount must be a positive number."
@@ -5649,7 +5662,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5649
5662
  * @returns A promise that resolves to the transaction response.
5650
5663
  */
5651
5664
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5652
- if ((0, import_math21.bn)(amount).lte(0)) {
5665
+ if ((0, import_math20.bn)(amount).lte(0)) {
5653
5666
  throw new import_errors16.FuelError(
5654
5667
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5655
5668
  "Transfer amount must be a positive number."
@@ -5659,7 +5672,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5659
5672
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5660
5673
  const { script, scriptData } = await assembleTransferToContractScript({
5661
5674
  hexlifiedContractId: contractAddress.toB256(),
5662
- amountToTransfer: (0, import_math21.bn)(amount),
5675
+ amountToTransfer: (0, import_math20.bn)(amount),
5663
5676
  assetId: assetIdToTransfer
5664
5677
  });
5665
5678
  let request = new ScriptTransactionRequest({
@@ -5670,7 +5683,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5670
5683
  request.addContractInputAndOutput(contractAddress);
5671
5684
  const txCost = await this.provider.getTransactionCost(request, {
5672
5685
  resourcesOwner: this,
5673
- quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5686
+ quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
5674
5687
  });
5675
5688
  request = this.validateGasLimitAndMaxFee({
5676
5689
  transactionRequest: request,
@@ -5695,7 +5708,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5695
5708
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5696
5709
  );
5697
5710
  const amountDataArray = (0, import_utils28.arrayify)(
5698
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5711
+ "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5699
5712
  );
5700
5713
  const script = new Uint8Array([
5701
5714
  ...(0, import_utils28.arrayify)(withdrawScript.bytes),
@@ -5705,7 +5718,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5705
5718
  const params = { script, ...txParams };
5706
5719
  const baseAssetId = this.provider.getBaseAssetId();
5707
5720
  let request = new ScriptTransactionRequest(params);
5708
- const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5721
+ const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
5709
5722
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5710
5723
  request = this.validateGasLimitAndMaxFee({
5711
5724
  transactionRequest: request,
@@ -5806,7 +5819,7 @@ var import_utils31 = require("@fuel-ts/utils");
5806
5819
  var import_address5 = require("@fuel-ts/address");
5807
5820
  var import_crypto2 = require("@fuel-ts/crypto");
5808
5821
  var import_hasher2 = require("@fuel-ts/hasher");
5809
- var import_math22 = require("@fuel-ts/math");
5822
+ var import_math21 = require("@fuel-ts/math");
5810
5823
  var import_utils29 = require("@fuel-ts/utils");
5811
5824
  var import_secp256k1 = require("@noble/curves/secp256k1");
5812
5825
  var Signer = class {
@@ -5826,7 +5839,7 @@ var Signer = class {
5826
5839
  privateKey = `0x${privateKey}`;
5827
5840
  }
5828
5841
  }
5829
- const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5842
+ const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5830
5843
  this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5831
5844
  this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5832
5845
  this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5844,8 +5857,8 @@ var Signer = class {
5844
5857
  */
5845
5858
  sign(data) {
5846
5859
  const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5847
- const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5848
- const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5860
+ const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5861
+ const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5849
5862
  s[0] |= (signature.recovery || 0) << 7;
5850
5863
  return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5851
5864
  }
@@ -6115,18 +6128,17 @@ var BaseWalletUnlocked = class extends Account {
6115
6128
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6116
6129
 
6117
6130
  // src/hdwallet/hdwallet.ts
6131
+ var import_crypto5 = require("@fuel-ts/crypto");
6118
6132
  var import_errors20 = require("@fuel-ts/errors");
6119
6133
  var import_hasher6 = require("@fuel-ts/hasher");
6120
- var import_math23 = require("@fuel-ts/math");
6134
+ var import_math22 = require("@fuel-ts/math");
6121
6135
  var import_utils35 = require("@fuel-ts/utils");
6122
- var import_ethers2 = require("ethers");
6123
6136
 
6124
6137
  // src/mnemonic/mnemonic.ts
6125
6138
  var import_crypto4 = require("@fuel-ts/crypto");
6126
6139
  var import_errors19 = require("@fuel-ts/errors");
6127
6140
  var import_hasher5 = require("@fuel-ts/hasher");
6128
6141
  var import_utils33 = require("@fuel-ts/utils");
6129
- var import_ethers = require("ethers");
6130
6142
 
6131
6143
  // src/wordlists/words/english.ts
6132
6144
  var english = [
@@ -8190,38 +8202,6 @@ var Language = /* @__PURE__ */ ((Language2) => {
8190
8202
  var import_errors18 = require("@fuel-ts/errors");
8191
8203
  var import_hasher4 = require("@fuel-ts/hasher");
8192
8204
  var import_utils32 = require("@fuel-ts/utils");
8193
- function toUtf8Bytes(stri) {
8194
- const str = stri.normalize("NFKD");
8195
- const result = [];
8196
- for (let i = 0; i < str.length; i += 1) {
8197
- const c = str.charCodeAt(i);
8198
- if (c < 128) {
8199
- result.push(c);
8200
- } else if (c < 2048) {
8201
- result.push(c >> 6 | 192);
8202
- result.push(c & 63 | 128);
8203
- } else if ((c & 64512) === 55296) {
8204
- i += 1;
8205
- const c2 = str.charCodeAt(i);
8206
- if (i >= str.length || (c2 & 64512) !== 56320) {
8207
- throw new import_errors18.FuelError(
8208
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
8209
- "Invalid UTF-8 in the input string."
8210
- );
8211
- }
8212
- const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
8213
- result.push(pair >> 18 | 240);
8214
- result.push(pair >> 12 & 63 | 128);
8215
- result.push(pair >> 6 & 63 | 128);
8216
- result.push(pair & 63 | 128);
8217
- } else {
8218
- result.push(c >> 12 | 224);
8219
- result.push(c >> 6 & 63 | 128);
8220
- result.push(c & 63 | 128);
8221
- }
8222
- }
8223
- return Uint8Array.from(result);
8224
- }
8225
8205
  function getLowerMask(bits) {
8226
8206
  return (1 << bits) - 1;
8227
8207
  }
@@ -8294,7 +8274,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8294
8274
  }
8295
8275
 
8296
8276
  // src/mnemonic/mnemonic.ts
8297
- var MasterSecret = toUtf8Bytes("Bitcoin seed");
8277
+ var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
8298
8278
  var MainnetPRV = "0x0488ade4";
8299
8279
  var TestnetPRV = "0x04358394";
8300
8280
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -8378,9 +8358,9 @@ var Mnemonic = class {
8378
8358
  */
8379
8359
  static mnemonicToSeed(phrase, passphrase = "") {
8380
8360
  assertMnemonic(getWords(phrase));
8381
- const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8382
- const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8383
- return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8361
+ const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
8362
+ const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
8363
+ return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8384
8364
  }
8385
8365
  /**
8386
8366
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8442,7 +8422,7 @@ var Mnemonic = class {
8442
8422
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8443
8423
  );
8444
8424
  }
8445
- return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8425
+ return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8446
8426
  }
8447
8427
  /**
8448
8428
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8467,8 +8447,8 @@ var Mnemonic = class {
8467
8447
  chainCode,
8468
8448
  (0, import_utils33.concat)(["0x00", privateKey])
8469
8449
  ]);
8470
- const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8471
- return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8450
+ const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8451
+ return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8472
8452
  }
8473
8453
  /**
8474
8454
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8496,7 +8476,7 @@ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8496
8476
  var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8497
8477
  var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8498
8478
  function base58check(data) {
8499
- return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8479
+ return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8500
8480
  }
8501
8481
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8502
8482
  if (isPublic) {
@@ -8552,7 +8532,7 @@ var HDWallet = class {
8552
8532
  this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8553
8533
  }
8554
8534
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8555
- this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8535
+ this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8556
8536
  this.depth = config.depth || this.depth;
8557
8537
  this.index = config.index || this.index;
8558
8538
  this.chainCode = config.chainCode;
@@ -8583,13 +8563,13 @@ var HDWallet = class {
8583
8563
  } else {
8584
8564
  data.set((0, import_utils35.arrayify)(this.publicKey));
8585
8565
  }
8586
- data.set((0, import_math23.toBytes)(index, 4), 33);
8587
- const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8566
+ data.set((0, import_math22.toBytes)(index, 4), 33);
8567
+ const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8588
8568
  const IL = bytes.slice(0, 32);
8589
8569
  const IR = bytes.slice(32);
8590
8570
  if (privateKey) {
8591
8571
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8592
- const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8572
+ const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
8593
8573
  return new HDWallet({
8594
8574
  privateKey: ki,
8595
8575
  chainCode: IR,
@@ -8635,7 +8615,7 @@ var HDWallet = class {
8635
8615
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8636
8616
  const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8637
8617
  const parentFingerprint = this.parentFingerprint;
8638
- const index = (0, import_math23.toHex)(this.index, 4);
8618
+ const index = (0, import_math22.toHex)(this.index, 4);
8639
8619
  const chainCode = this.chainCode;
8640
8620
  const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8641
8621
  const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -8655,7 +8635,7 @@ var HDWallet = class {
8655
8635
  });
8656
8636
  }
8657
8637
  static fromExtendedKey(extendedKey) {
8658
- const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8638
+ const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8659
8639
  const bytes = (0, import_utils35.arrayify)(decoded);
8660
8640
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8661
8641
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8855,7 +8835,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8855
8835
 
8856
8836
  // src/wallet-manager/wallet-manager.ts
8857
8837
  var import_address9 = require("@fuel-ts/address");
8858
- var import_crypto5 = require("@fuel-ts/crypto");
8838
+ var import_crypto6 = require("@fuel-ts/crypto");
8859
8839
  var import_errors23 = require("@fuel-ts/errors");
8860
8840
  var import_events = require("events");
8861
8841
 
@@ -9183,7 +9163,7 @@ var _WalletManager = class extends import_events.EventEmitter {
9183
9163
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
9184
9164
  const data = await this.storage.getItem(this.STORAGE_KEY);
9185
9165
  if (data) {
9186
- const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
9166
+ const state = await (0, import_crypto6.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
9187
9167
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
9188
9168
  }
9189
9169
  }
@@ -9192,7 +9172,7 @@ var _WalletManager = class extends import_events.EventEmitter {
9192
9172
  */
9193
9173
  async saveState() {
9194
9174
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
9195
- const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
9175
+ const encryptedData = await (0, import_crypto6.encrypt)(__privateGet(this, _passphrase), {
9196
9176
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
9197
9177
  });
9198
9178
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -9271,7 +9251,6 @@ var StorageAbstract = class {
9271
9251
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9272
9252
  var import_address10 = require("@fuel-ts/address");
9273
9253
  var import_errors25 = require("@fuel-ts/errors");
9274
- var import_transactions22 = require("@fuel-ts/transactions");
9275
9254
  var import_utils37 = require("@fuel-ts/utils");
9276
9255
 
9277
9256
  // src/predicate/utils/getPredicateRoot.ts
@@ -9329,11 +9308,15 @@ var Predicate = class extends Account {
9329
9308
  */
9330
9309
  populateTransactionPredicateData(transactionRequestLike) {
9331
9310
  const request = transactionRequestify(transactionRequestLike);
9332
- const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9333
- request.inputs?.forEach((input) => {
9334
- if (input.type === import_transactions22.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
9311
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
9312
+ if (placeholderIndex !== -1) {
9313
+ request.removeWitness(placeholderIndex);
9314
+ }
9315
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
9316
+ if (isRequestInputResourceFromOwner(input, this.address)) {
9335
9317
  input.predicate = (0, import_utils37.hexlify)(this.bytes);
9336
- input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData(policies.length));
9318
+ input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
9319
+ input.witnessIndex = 0;
9337
9320
  }
9338
9321
  });
9339
9322
  return request;
@@ -9358,17 +9341,12 @@ var Predicate = class extends Account {
9358
9341
  const transactionRequest = transactionRequestify(transactionRequestLike);
9359
9342
  return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
9360
9343
  }
9361
- getPredicateData(policiesLength) {
9344
+ getPredicateData() {
9362
9345
  if (!this.predicateData.length) {
9363
9346
  return new Uint8Array();
9364
9347
  }
9365
9348
  const mainFn = this.interface?.functions.main;
9366
- const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9367
- const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9368
- maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9369
- });
9370
- const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
9371
- return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
9349
+ return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
9372
9350
  }
9373
9351
  /**
9374
9352
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -9417,8 +9395,7 @@ var Predicate = class extends Account {
9417
9395
  );
9418
9396
  return resources.map((resource) => ({
9419
9397
  ...resource,
9420
- predicate: (0, import_utils37.hexlify)(this.bytes),
9421
- padPredicateData: (policiesLength) => (0, import_utils37.hexlify)(this.getPredicateData(policiesLength))
9398
+ predicate: (0, import_utils37.hexlify)(this.bytes)
9422
9399
  }));
9423
9400
  }
9424
9401
  /**
@@ -9456,6 +9433,28 @@ var Predicate = class extends Account {
9456
9433
  }
9457
9434
  return mutatedBytes;
9458
9435
  }
9436
+ /**
9437
+ * Returns the index of the witness placeholder that was added to this predicate.
9438
+ * If no witness placeholder was added, it returns -1.
9439
+ * @param request - The transaction request.
9440
+ * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
9441
+ */
9442
+ getIndexFromPlaceholderWitness(request) {
9443
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
9444
+ let index = -1;
9445
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
9446
+ if (hasEmptyPredicateInputs) {
9447
+ index = hasEmptyPredicateInputs.witnessIndex;
9448
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
9449
+ if (!allInputsAreEmpty) {
9450
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
9451
+ if (wasFilledInputAddedFirst) {
9452
+ index = -1;
9453
+ }
9454
+ }
9455
+ }
9456
+ return index;
9457
+ }
9459
9458
  };
9460
9459
 
9461
9460
  // src/connectors/fuel.ts
@@ -10179,7 +10178,8 @@ __publicField(Fuel, "defaultConfig", {});
10179
10178
  assets,
10180
10179
  buildBlockExplorerUrl,
10181
10180
  cacheFor,
10182
- cacheTxInputsFromOwner,
10181
+ cacheRequestInputsResources,
10182
+ cacheRequestInputsResourcesFromOwner,
10183
10183
  calculateGasFee,
10184
10184
  calculateMetadataGasForTxCreate,
10185
10185
  calculateMetadataGasForTxScript,
@@ -10193,6 +10193,7 @@ __publicField(Fuel, "defaultConfig", {});
10193
10193
  extractTxError,
10194
10194
  fuelAssetsBaseUrl,
10195
10195
  gasUsedByInputs,
10196
+ getAssetAmountInRequestInputs,
10196
10197
  getAssetEth,
10197
10198
  getAssetFuel,
10198
10199
  getAssetNetwork,
@@ -10227,6 +10228,7 @@ __publicField(Fuel, "defaultConfig", {});
10227
10228
  getReceiptsMessageOut,
10228
10229
  getReceiptsTransferOut,
10229
10230
  getReceiptsWithMissingData,
10231
+ getRequestInputResourceOwner,
10230
10232
  getTransactionStatusName,
10231
10233
  getTransactionSummary,
10232
10234
  getTransactionSummaryFromRequest,
@@ -10240,6 +10242,10 @@ __publicField(Fuel, "defaultConfig", {});
10240
10242
  isMessage,
10241
10243
  isRawCoin,
10242
10244
  isRawMessage,
10245
+ isRequestInputCoin,
10246
+ isRequestInputMessage,
10247
+ isRequestInputResource,
10248
+ isRequestInputResourceFromOwner,
10243
10249
  isType,
10244
10250
  isTypeCreate,
10245
10251
  isTypeMint,