@fuel-ts/account 0.0.0-rc-2224-20240503155836 → 0.0.0-rc-2037-20240504194803

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 (53) hide show
  1. package/dist/index.global.js +1357 -485
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +497 -334
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +394 -240
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/predicate/predicate.d.ts +9 -2
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/__generated__/operations.d.ts +186 -80
  10. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  11. package/dist/providers/message.d.ts +2 -2
  12. package/dist/providers/message.d.ts.map +1 -1
  13. package/dist/providers/provider.d.ts +24 -21
  14. package/dist/providers/provider.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/helpers.d.ts +4 -0
  16. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/index.d.ts +1 -0
  18. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  19. package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/transaction-request.d.ts +4 -3
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/utils.d.ts +0 -4
  24. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  25. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
  26. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  27. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
  28. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
  29. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  30. package/dist/providers/transaction-summary/index.d.ts +1 -1
  31. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  32. package/dist/providers/transaction-summary/operations.d.ts +4 -0
  33. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  34. package/dist/providers/transaction-summary/status.d.ts +5 -1
  35. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  36. package/dist/providers/transaction-summary/types.d.ts +6 -1
  37. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  38. package/dist/providers/utils/gas.d.ts +6 -5
  39. package/dist/providers/utils/gas.d.ts.map +1 -1
  40. package/dist/test-utils/launchNode.d.ts.map +1 -1
  41. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  42. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  43. package/dist/test-utils.global.js +1320 -496
  44. package/dist/test-utils.global.js.map +1 -1
  45. package/dist/test-utils.js +422 -326
  46. package/dist/test-utils.js.map +1 -1
  47. package/dist/test-utils.mjs +334 -238
  48. package/dist/test-utils.mjs.map +1 -1
  49. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  50. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  51. package/package.json +16 -16
  52. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
  53. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
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,11 +104,12 @@ __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,
111
- calculateTransactionFee: () => calculateTransactionFee,
112
+ calculateTXFeeForSummary: () => calculateTXFeeForSummary,
112
113
  coinQuantityfy: () => coinQuantityfy,
113
114
  deferPromise: () => deferPromise,
114
115
  dispatchFuelConnectorEvent: () => dispatchFuelConnectorEvent,
@@ -117,6 +118,7 @@ __export(src_exports, {
117
118
  extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
118
119
  extractTxError: () => extractTxError,
119
120
  gasUsedByInputs: () => gasUsedByInputs,
121
+ getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
120
122
  getAssetEth: () => getAssetEth,
121
123
  getAssetFuel: () => getAssetFuel,
122
124
  getAssetNetwork: () => getAssetNetwork,
@@ -151,6 +153,7 @@ __export(src_exports, {
151
153
  getReceiptsMessageOut: () => getReceiptsMessageOut,
152
154
  getReceiptsTransferOut: () => getReceiptsTransferOut,
153
155
  getReceiptsWithMissingData: () => getReceiptsWithMissingData,
156
+ getRequestInputResourceOwner: () => getRequestInputResourceOwner,
154
157
  getTransactionStatusName: () => getTransactionStatusName,
155
158
  getTransactionSummary: () => getTransactionSummary,
156
159
  getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
@@ -164,10 +167,16 @@ __export(src_exports, {
164
167
  isMessage: () => isMessage,
165
168
  isRawCoin: () => isRawCoin,
166
169
  isRawMessage: () => isRawMessage,
170
+ isRequestInputCoin: () => isRequestInputCoin,
171
+ isRequestInputMessage: () => isRequestInputMessage,
172
+ isRequestInputResource: () => isRequestInputResource,
173
+ isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
167
174
  isType: () => isType,
168
175
  isTypeCreate: () => isTypeCreate,
169
176
  isTypeMint: () => isTypeMint,
170
177
  isTypeScript: () => isTypeScript,
178
+ isTypeUpgrade: () => isTypeUpgrade,
179
+ isTypeUpload: () => isTypeUpload,
171
180
  normalizeJSON: () => normalizeJSON,
172
181
  outputify: () => outputify,
173
182
  processGqlReceipt: () => processGqlReceipt,
@@ -187,7 +196,7 @@ module.exports = __toCommonJS(src_exports);
187
196
  var import_address4 = require("@fuel-ts/address");
188
197
  var import_errors16 = require("@fuel-ts/errors");
189
198
  var import_interfaces = require("@fuel-ts/interfaces");
190
- var import_math20 = require("@fuel-ts/math");
199
+ var import_math21 = require("@fuel-ts/math");
191
200
  var import_utils27 = require("@fuel-ts/utils");
192
201
  var import_ramda4 = require("ramda");
193
202
 
@@ -229,8 +238,8 @@ var addAmountToCoinQuantities = (params) => {
229
238
  // src/providers/provider.ts
230
239
  var import_address3 = require("@fuel-ts/address");
231
240
  var import_errors14 = require("@fuel-ts/errors");
232
- var import_math16 = require("@fuel-ts/math");
233
- var import_transactions19 = require("@fuel-ts/transactions");
241
+ var import_math18 = require("@fuel-ts/math");
242
+ var import_transactions20 = require("@fuel-ts/transactions");
234
243
  var import_utils22 = require("@fuel-ts/utils");
235
244
  var import_versions = require("@fuel-ts/versions");
236
245
  var import_utils23 = require("@noble/curves/abstract/utils");
@@ -290,9 +299,6 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
290
299
  id
291
300
  }
292
301
  time
293
- receipts {
294
- ...receiptFragment
295
- }
296
302
  programState {
297
303
  returnType
298
304
  data
@@ -300,11 +306,15 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
300
306
  receipts {
301
307
  ...receiptFragment
302
308
  }
309
+ totalGas
310
+ totalFee
303
311
  }
304
312
  ... on FailureStatus {
305
313
  block {
306
314
  id
307
315
  }
316
+ totalGas
317
+ totalFee
308
318
  time
309
319
  reason
310
320
  receipts {
@@ -344,6 +354,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
344
354
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
345
355
  var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
346
356
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
357
+ totalGas
358
+ totalFee
347
359
  reason
348
360
  programState {
349
361
  returnType
@@ -353,6 +365,8 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
353
365
  `;
354
366
  var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
355
367
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
368
+ totalGas
369
+ totalFee
356
370
  programState {
357
371
  returnType
358
372
  data
@@ -488,6 +502,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
488
502
  maxWitnesses
489
503
  maxGasPerTx
490
504
  maxSize
505
+ maxBytecodeSubsections
491
506
  }
492
507
  `;
493
508
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
@@ -757,6 +772,14 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
757
772
  nodeVersion
758
773
  }
759
774
  `;
775
+ var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
776
+ fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
777
+ ... on RelayedTransactionFailed {
778
+ blockHeight
779
+ failure
780
+ }
781
+ }
782
+ `;
760
783
  var GetVersionDocument = import_graphql_tag.default`
761
784
  query getVersion {
762
785
  nodeInfo {
@@ -986,6 +1009,13 @@ var GetMessageStatusDocument = import_graphql_tag.default`
986
1009
  }
987
1010
  }
988
1011
  `;
1012
+ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1013
+ query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
1014
+ relayedTransactionStatus(id: $relayedTransactionId) {
1015
+ ...relayedTransactionStatusFragment
1016
+ }
1017
+ }
1018
+ ${RelayedTransactionStatusFragmentFragmentDoc}`;
989
1019
  var DryRunDocument = import_graphql_tag.default`
990
1020
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
991
1021
  dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
@@ -1100,6 +1130,9 @@ function getSdk(requester) {
1100
1130
  getMessageStatus(variables, options) {
1101
1131
  return requester(GetMessageStatusDocument, variables, options);
1102
1132
  },
1133
+ getRelayedTransactionStatus(variables, options) {
1134
+ return requester(GetRelayedTransactionStatusDocument, variables, options);
1135
+ },
1103
1136
  dryRun(variables, options) {
1104
1137
  return requester(DryRunDocument, variables, options);
1105
1138
  },
@@ -1396,8 +1429,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1396
1429
  var import_address = require("@fuel-ts/address");
1397
1430
  var import_configs6 = require("@fuel-ts/address/configs");
1398
1431
  var import_crypto = require("@fuel-ts/crypto");
1399
- var import_math7 = require("@fuel-ts/math");
1400
- var import_transactions6 = require("@fuel-ts/transactions");
1432
+ var import_math8 = require("@fuel-ts/math");
1433
+ var import_transactions7 = require("@fuel-ts/transactions");
1401
1434
  var import_utils9 = require("@fuel-ts/utils");
1402
1435
 
1403
1436
  // src/providers/resource.ts
@@ -1905,6 +1938,52 @@ var NoWitnessByOwnerError = class extends Error {
1905
1938
  name = "NoWitnessByOwnerError";
1906
1939
  };
1907
1940
 
1941
+ // src/providers/transaction-request/helpers.ts
1942
+ var import_math7 = require("@fuel-ts/math");
1943
+ var import_transactions6 = require("@fuel-ts/transactions");
1944
+ var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1945
+ var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1946
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1947
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1948
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1949
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1950
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
1951
+ return acc.add(input.amount);
1952
+ }
1953
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
1954
+ return acc.add(input.amount);
1955
+ }
1956
+ return acc;
1957
+ }, (0, import_math7.bn)(0));
1958
+ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
1959
+ (cache2, input) => {
1960
+ if (isRequestInputCoin(input)) {
1961
+ cache2.utxos.push(input.id);
1962
+ } else {
1963
+ cache2.messages.push(input.nonce);
1964
+ }
1965
+ return cache2;
1966
+ },
1967
+ {
1968
+ utxos: [],
1969
+ messages: []
1970
+ }
1971
+ );
1972
+ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
1973
+ (acc, input) => {
1974
+ if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
1975
+ acc.utxos.push(input.id);
1976
+ } else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
1977
+ acc.messages.push(input.nonce);
1978
+ }
1979
+ return acc;
1980
+ },
1981
+ {
1982
+ utxos: [],
1983
+ messages: []
1984
+ }
1985
+ );
1986
+
1908
1987
  // src/providers/transaction-request/witness.ts
1909
1988
  var import_utils8 = require("@fuel-ts/utils");
1910
1989
  var witnessify = (value) => {
@@ -1945,10 +2024,10 @@ var BaseTransactionRequest = class {
1945
2024
  outputs,
1946
2025
  witnesses
1947
2026
  } = {}) {
1948
- this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
2027
+ this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
1949
2028
  this.maturity = maturity && maturity > 0 ? maturity : void 0;
1950
- this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
1951
- this.maxFee = (0, import_math7.bn)(maxFee);
2029
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
2030
+ this.maxFee = (0, import_math8.bn)(maxFee);
1952
2031
  this.inputs = inputs ?? [];
1953
2032
  this.outputs = outputs ?? [];
1954
2033
  this.witnesses = witnesses ?? [];
@@ -1957,20 +2036,20 @@ var BaseTransactionRequest = class {
1957
2036
  let policyTypes = 0;
1958
2037
  const policies = [];
1959
2038
  const { tip, witnessLimit, maturity } = req;
1960
- if ((0, import_math7.bn)(tip).gt(0)) {
1961
- policyTypes += import_transactions6.PolicyType.Tip;
1962
- policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
2039
+ if ((0, import_math8.bn)(tip).gt(0)) {
2040
+ policyTypes += import_transactions7.PolicyType.Tip;
2041
+ policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
1963
2042
  }
1964
- if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
1965
- policyTypes += import_transactions6.PolicyType.WitnessLimit;
1966
- policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
2043
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
2044
+ policyTypes += import_transactions7.PolicyType.WitnessLimit;
2045
+ policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
1967
2046
  }
1968
2047
  if (maturity && maturity > 0) {
1969
- policyTypes += import_transactions6.PolicyType.Maturity;
1970
- policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
2048
+ policyTypes += import_transactions7.PolicyType.Maturity;
2049
+ policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
1971
2050
  }
1972
- policyTypes += import_transactions6.PolicyType.MaxFee;
1973
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
2051
+ policyTypes += import_transactions7.PolicyType.MaxFee;
2052
+ policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
1974
2053
  return {
1975
2054
  policyTypes,
1976
2055
  policies
@@ -2003,7 +2082,7 @@ var BaseTransactionRequest = class {
2003
2082
  * @returns The transaction bytes.
2004
2083
  */
2005
2084
  toTransactionBytes() {
2006
- return new import_transactions6.TransactionCoder().encode(this.toTransaction());
2085
+ return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2007
2086
  }
2008
2087
  /**
2009
2088
  * @hidden
@@ -2094,7 +2173,7 @@ var BaseTransactionRequest = class {
2094
2173
  */
2095
2174
  getCoinInputs() {
2096
2175
  return this.inputs.filter(
2097
- (input) => input.type === import_transactions6.InputType.Coin
2176
+ (input) => input.type === import_transactions7.InputType.Coin
2098
2177
  );
2099
2178
  }
2100
2179
  /**
@@ -2104,7 +2183,7 @@ var BaseTransactionRequest = class {
2104
2183
  */
2105
2184
  getCoinOutputs() {
2106
2185
  return this.outputs.filter(
2107
- (output) => output.type === import_transactions6.OutputType.Coin
2186
+ (output) => output.type === import_transactions7.OutputType.Coin
2108
2187
  );
2109
2188
  }
2110
2189
  /**
@@ -2114,7 +2193,7 @@ var BaseTransactionRequest = class {
2114
2193
  */
2115
2194
  getChangeOutputs() {
2116
2195
  return this.outputs.filter(
2117
- (output) => output.type === import_transactions6.OutputType.Change
2196
+ (output) => output.type === import_transactions7.OutputType.Change
2118
2197
  );
2119
2198
  }
2120
2199
  /**
@@ -2126,9 +2205,9 @@ var BaseTransactionRequest = class {
2126
2205
  const ownerAddress = (0, import_address.addressify)(owner);
2127
2206
  const found = this.inputs.find((input) => {
2128
2207
  switch (input.type) {
2129
- case import_transactions6.InputType.Coin:
2208
+ case import_transactions7.InputType.Coin:
2130
2209
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
2131
- case import_transactions6.InputType.Message:
2210
+ case import_transactions7.InputType.Message:
2132
2211
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
2133
2212
  default:
2134
2213
  return false;
@@ -2143,7 +2222,7 @@ var BaseTransactionRequest = class {
2143
2222
  * @param coin - Coin resource.
2144
2223
  */
2145
2224
  addCoinInput(coin) {
2146
- const { assetId, owner, amount } = coin;
2225
+ const { assetId, owner, amount, id, predicate } = coin;
2147
2226
  let witnessIndex;
2148
2227
  if (coin.predicate) {
2149
2228
  witnessIndex = 0;
@@ -2154,13 +2233,14 @@ var BaseTransactionRequest = class {
2154
2233
  }
2155
2234
  }
2156
2235
  const input = {
2157
- ...coin,
2158
- type: import_transactions6.InputType.Coin,
2236
+ id,
2237
+ type: import_transactions7.InputType.Coin,
2159
2238
  owner: owner.toB256(),
2160
2239
  amount,
2161
2240
  assetId,
2162
2241
  txPointer: "0x00000000000000000000000000000000",
2163
- witnessIndex
2242
+ witnessIndex,
2243
+ predicate
2164
2244
  };
2165
2245
  this.pushInput(input);
2166
2246
  this.addChangeOutput(owner, assetId);
@@ -2172,7 +2252,7 @@ var BaseTransactionRequest = class {
2172
2252
  * @param message - Message resource.
2173
2253
  */
2174
2254
  addMessageInput(message) {
2175
- const { recipient, sender, amount, assetId } = message;
2255
+ const { recipient, sender, amount, predicate, nonce, assetId } = message;
2176
2256
  let witnessIndex;
2177
2257
  if (message.predicate) {
2178
2258
  witnessIndex = 0;
@@ -2183,12 +2263,13 @@ var BaseTransactionRequest = class {
2183
2263
  }
2184
2264
  }
2185
2265
  const input = {
2186
- ...message,
2187
- type: import_transactions6.InputType.Message,
2266
+ nonce,
2267
+ type: import_transactions7.InputType.Message,
2188
2268
  sender: sender.toB256(),
2189
2269
  recipient: recipient.toB256(),
2190
2270
  amount,
2191
- witnessIndex
2271
+ witnessIndex,
2272
+ predicate
2192
2273
  };
2193
2274
  this.pushInput(input);
2194
2275
  this.addChangeOutput(recipient, assetId);
@@ -2228,7 +2309,7 @@ var BaseTransactionRequest = class {
2228
2309
  */
2229
2310
  addCoinOutput(to, amount, assetId) {
2230
2311
  this.pushOutput({
2231
- type: import_transactions6.OutputType.Coin,
2312
+ type: import_transactions7.OutputType.Coin,
2232
2313
  to: (0, import_address.addressify)(to).toB256(),
2233
2314
  amount,
2234
2315
  assetId
@@ -2244,7 +2325,7 @@ var BaseTransactionRequest = class {
2244
2325
  addCoinOutputs(to, quantities) {
2245
2326
  quantities.map(coinQuantityfy).forEach((quantity) => {
2246
2327
  this.pushOutput({
2247
- type: import_transactions6.OutputType.Coin,
2328
+ type: import_transactions7.OutputType.Coin,
2248
2329
  to: (0, import_address.addressify)(to).toB256(),
2249
2330
  amount: quantity.amount,
2250
2331
  assetId: quantity.assetId
@@ -2264,7 +2345,7 @@ var BaseTransactionRequest = class {
2264
2345
  );
2265
2346
  if (!changeOutput) {
2266
2347
  this.pushOutput({
2267
- type: import_transactions6.OutputType.Change,
2348
+ type: import_transactions7.OutputType.Change,
2268
2349
  to: (0, import_address.addressify)(to).toB256(),
2269
2350
  assetId
2270
2351
  });
@@ -2286,8 +2367,11 @@ var BaseTransactionRequest = class {
2286
2367
  * @hidden
2287
2368
  */
2288
2369
  calculateMinGas(chainInfo) {
2289
- const { gasCosts, consensusParameters } = chainInfo;
2290
- const { gasPerByte } = consensusParameters;
2370
+ const { consensusParameters } = chainInfo;
2371
+ const {
2372
+ gasCosts,
2373
+ feeParameters: { gasPerByte }
2374
+ } = consensusParameters;
2291
2375
  return getMinGas({
2292
2376
  gasPerByte,
2293
2377
  gasCosts,
@@ -2298,7 +2382,10 @@ var BaseTransactionRequest = class {
2298
2382
  }
2299
2383
  calculateMaxGas(chainInfo, minGas) {
2300
2384
  const { consensusParameters } = chainInfo;
2301
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2385
+ const {
2386
+ feeParameters: { gasPerByte },
2387
+ txParameters: { maxGasPerTx }
2388
+ } = consensusParameters;
2302
2389
  const witnessesLength = this.toTransaction().witnesses.reduce(
2303
2390
  (acc, wit) => acc + wit.dataLength,
2304
2391
  0
@@ -2329,7 +2416,7 @@ var BaseTransactionRequest = class {
2329
2416
  const assetInput = findAssetInput(assetId);
2330
2417
  let usedQuantity = quantity;
2331
2418
  if (assetId === baseAssetId) {
2332
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2419
+ usedQuantity = (0, import_math8.bn)("1000000000000000000");
2333
2420
  }
2334
2421
  if (assetInput && "assetId" in assetInput) {
2335
2422
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
@@ -2341,13 +2428,13 @@ var BaseTransactionRequest = class {
2341
2428
  amount: usedQuantity,
2342
2429
  assetId,
2343
2430
  owner: resourcesOwner || import_address.Address.fromRandom(),
2344
- blockCreated: (0, import_math7.bn)(1),
2345
- txCreatedIdx: (0, import_math7.bn)(1)
2431
+ blockCreated: (0, import_math8.bn)(1),
2432
+ txCreatedIdx: (0, import_math8.bn)(1)
2346
2433
  }
2347
2434
  ]);
2348
2435
  }
2349
2436
  };
2350
- updateAssetInput(baseAssetId, (0, import_math7.bn)(1e11));
2437
+ updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
2351
2438
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2352
2439
  }
2353
2440
  /**
@@ -2358,7 +2445,7 @@ var BaseTransactionRequest = class {
2358
2445
  */
2359
2446
  getCoinOutputsQuantities() {
2360
2447
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2361
- amount: (0, import_math7.bn)(amount),
2448
+ amount: (0, import_math8.bn)(amount),
2362
2449
  assetId: assetId.toString()
2363
2450
  }));
2364
2451
  return coinsQuantities;
@@ -2372,22 +2459,33 @@ var BaseTransactionRequest = class {
2372
2459
  toJSON() {
2373
2460
  return normalizeJSON(this);
2374
2461
  }
2462
+ removeWitness(index) {
2463
+ this.witnesses.splice(index, 1);
2464
+ this.adjustWitnessIndexes(index);
2465
+ }
2466
+ adjustWitnessIndexes(removedIndex) {
2467
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2468
+ if (input.witnessIndex > removedIndex) {
2469
+ input.witnessIndex -= 1;
2470
+ }
2471
+ });
2472
+ }
2375
2473
  updatePredicateGasUsed(inputs) {
2376
2474
  this.inputs.forEach((i) => {
2377
2475
  let correspondingInput;
2378
2476
  switch (i.type) {
2379
- case import_transactions6.InputType.Coin:
2380
- correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2477
+ case import_transactions7.InputType.Coin:
2478
+ correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2381
2479
  break;
2382
- case import_transactions6.InputType.Message:
2480
+ case import_transactions7.InputType.Message:
2383
2481
  correspondingInput = inputs.find(
2384
- (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2482
+ (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2385
2483
  );
2386
2484
  break;
2387
2485
  default:
2388
2486
  return;
2389
2487
  }
2390
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2488
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2391
2489
  i.predicate = correspondingInput.predicate;
2392
2490
  i.predicateData = correspondingInput.predicateData;
2393
2491
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2407,38 +2505,38 @@ var BaseTransactionRequest = class {
2407
2505
 
2408
2506
  // src/providers/transaction-request/create-transaction-request.ts
2409
2507
  var import_configs8 = require("@fuel-ts/address/configs");
2410
- var import_math9 = require("@fuel-ts/math");
2411
- var import_transactions8 = require("@fuel-ts/transactions");
2508
+ var import_math10 = require("@fuel-ts/math");
2509
+ var import_transactions9 = require("@fuel-ts/transactions");
2412
2510
  var import_utils13 = require("@fuel-ts/utils");
2413
2511
 
2414
2512
  // src/providers/transaction-request/hash-transaction.ts
2415
2513
  var import_configs7 = require("@fuel-ts/address/configs");
2416
2514
  var import_hasher = require("@fuel-ts/hasher");
2417
- var import_math8 = require("@fuel-ts/math");
2418
- var import_transactions7 = require("@fuel-ts/transactions");
2515
+ var import_math9 = require("@fuel-ts/math");
2516
+ var import_transactions8 = require("@fuel-ts/transactions");
2419
2517
  var import_utils11 = require("@fuel-ts/utils");
2420
2518
  var import_ramda2 = require("ramda");
2421
2519
  function hashTransaction(transactionRequest, chainId) {
2422
2520
  const transaction = transactionRequest.toTransaction();
2423
- if (transaction.type === import_transactions7.TransactionType.Script) {
2521
+ if (transaction.type === import_transactions8.TransactionType.Script) {
2424
2522
  transaction.receiptsRoot = import_configs7.ZeroBytes32;
2425
2523
  }
2426
2524
  transaction.inputs = transaction.inputs.map((input) => {
2427
2525
  const inputClone = (0, import_ramda2.clone)(input);
2428
2526
  switch (inputClone.type) {
2429
- case import_transactions7.InputType.Coin: {
2527
+ case import_transactions8.InputType.Coin: {
2430
2528
  inputClone.txPointer = {
2431
2529
  blockHeight: 0,
2432
2530
  txIndex: 0
2433
2531
  };
2434
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2532
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2435
2533
  return inputClone;
2436
2534
  }
2437
- case import_transactions7.InputType.Message: {
2438
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2535
+ case import_transactions8.InputType.Message: {
2536
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2439
2537
  return inputClone;
2440
2538
  }
2441
- case import_transactions7.InputType.Contract: {
2539
+ case import_transactions8.InputType.Contract: {
2442
2540
  inputClone.txPointer = {
2443
2541
  blockHeight: 0,
2444
2542
  txIndex: 0
@@ -2456,18 +2554,18 @@ function hashTransaction(transactionRequest, chainId) {
2456
2554
  transaction.outputs = transaction.outputs.map((output) => {
2457
2555
  const outputClone = (0, import_ramda2.clone)(output);
2458
2556
  switch (outputClone.type) {
2459
- case import_transactions7.OutputType.Contract: {
2557
+ case import_transactions8.OutputType.Contract: {
2460
2558
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
2461
2559
  outputClone.stateRoot = import_configs7.ZeroBytes32;
2462
2560
  return outputClone;
2463
2561
  }
2464
- case import_transactions7.OutputType.Change: {
2465
- outputClone.amount = (0, import_math8.bn)(0);
2562
+ case import_transactions8.OutputType.Change: {
2563
+ outputClone.amount = (0, import_math9.bn)(0);
2466
2564
  return outputClone;
2467
2565
  }
2468
- case import_transactions7.OutputType.Variable: {
2566
+ case import_transactions8.OutputType.Variable: {
2469
2567
  outputClone.to = import_configs7.ZeroBytes32;
2470
- outputClone.amount = (0, import_math8.bn)(0);
2568
+ outputClone.amount = (0, import_math9.bn)(0);
2471
2569
  outputClone.assetId = import_configs7.ZeroBytes32;
2472
2570
  return outputClone;
2473
2571
  }
@@ -2478,7 +2576,7 @@ function hashTransaction(transactionRequest, chainId) {
2478
2576
  transaction.witnessesCount = 0;
2479
2577
  transaction.witnesses = [];
2480
2578
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2481
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2579
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
2482
2580
  return (0, import_hasher.sha256)(concatenatedData);
2483
2581
  }
2484
2582
 
@@ -2514,7 +2612,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2514
2612
  return new this(obj);
2515
2613
  }
2516
2614
  /** Type of the transaction */
2517
- type = import_transactions8.TransactionType.Create;
2615
+ type = import_transactions9.TransactionType.Create;
2518
2616
  /** Witness index of contract bytecode to create */
2519
2617
  bytecodeWitnessIndex;
2520
2618
  /** Salt */
@@ -2542,10 +2640,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2542
2640
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2543
2641
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2544
2642
  return {
2545
- type: import_transactions8.TransactionType.Create,
2643
+ type: import_transactions9.TransactionType.Create,
2546
2644
  ...baseTransaction,
2547
2645
  bytecodeWitnessIndex,
2548
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2646
+ storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
2549
2647
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2550
2648
  storageSlots
2551
2649
  };
@@ -2557,7 +2655,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2557
2655
  */
2558
2656
  getContractCreatedOutputs() {
2559
2657
  return this.outputs.filter(
2560
- (output) => output.type === import_transactions8.OutputType.ContractCreated
2658
+ (output) => output.type === import_transactions9.OutputType.ContractCreated
2561
2659
  );
2562
2660
  }
2563
2661
  /**
@@ -2578,14 +2676,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2578
2676
  */
2579
2677
  addContractCreatedOutput(contractId, stateRoot) {
2580
2678
  this.pushOutput({
2581
- type: import_transactions8.OutputType.ContractCreated,
2679
+ type: import_transactions9.OutputType.ContractCreated,
2582
2680
  contractId,
2583
2681
  stateRoot
2584
2682
  });
2585
2683
  }
2586
2684
  metadataGas(gasCosts) {
2587
2685
  return calculateMetadataGasForTxCreate({
2588
- contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2686
+ contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2589
2687
  gasCosts,
2590
2688
  stateRootSize: this.storageSlots.length,
2591
2689
  txBytesSize: this.byteSize()
@@ -2597,8 +2695,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2597
2695
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2598
2696
  var import_address2 = require("@fuel-ts/address");
2599
2697
  var import_configs9 = require("@fuel-ts/address/configs");
2600
- var import_math10 = require("@fuel-ts/math");
2601
- var import_transactions9 = require("@fuel-ts/transactions");
2698
+ var import_math11 = require("@fuel-ts/math");
2699
+ var import_transactions10 = require("@fuel-ts/transactions");
2602
2700
  var import_utils15 = require("@fuel-ts/utils");
2603
2701
 
2604
2702
  // src/providers/transaction-request/scripts.ts
@@ -2636,7 +2734,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2636
2734
  return new this(obj);
2637
2735
  }
2638
2736
  /** Type of the transaction */
2639
- type = import_transactions9.TransactionType.Script;
2737
+ type = import_transactions10.TransactionType.Script;
2640
2738
  /** Gas limit for transaction */
2641
2739
  gasLimit;
2642
2740
  /** Script to execute */
@@ -2651,7 +2749,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2651
2749
  */
2652
2750
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2653
2751
  super(rest);
2654
- this.gasLimit = (0, import_math10.bn)(gasLimit);
2752
+ this.gasLimit = (0, import_math11.bn)(gasLimit);
2655
2753
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2656
2754
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2657
2755
  this.abis = rest.abis;
@@ -2665,11 +2763,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2665
2763
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2666
2764
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2667
2765
  return {
2668
- type: import_transactions9.TransactionType.Script,
2766
+ type: import_transactions10.TransactionType.Script,
2669
2767
  scriptGasLimit: this.gasLimit,
2670
2768
  ...super.getBaseTransaction(),
2671
- scriptLength: (0, import_math10.bn)(script.length),
2672
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2769
+ scriptLength: (0, import_math11.bn)(script.length),
2770
+ scriptDataLength: (0, import_math11.bn)(scriptData.length),
2673
2771
  receiptsRoot: import_configs9.ZeroBytes32,
2674
2772
  script: (0, import_utils15.hexlify)(script),
2675
2773
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2682,7 +2780,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2682
2780
  */
2683
2781
  getContractInputs() {
2684
2782
  return this.inputs.filter(
2685
- (input) => input.type === import_transactions9.InputType.Contract
2783
+ (input) => input.type === import_transactions10.InputType.Contract
2686
2784
  );
2687
2785
  }
2688
2786
  /**
@@ -2692,7 +2790,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2692
2790
  */
2693
2791
  getContractOutputs() {
2694
2792
  return this.outputs.filter(
2695
- (output) => output.type === import_transactions9.OutputType.Contract
2793
+ (output) => output.type === import_transactions10.OutputType.Contract
2696
2794
  );
2697
2795
  }
2698
2796
  /**
@@ -2702,7 +2800,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2702
2800
  */
2703
2801
  getVariableOutputs() {
2704
2802
  return this.outputs.filter(
2705
- (output) => output.type === import_transactions9.OutputType.Variable
2803
+ (output) => output.type === import_transactions10.OutputType.Variable
2706
2804
  );
2707
2805
  }
2708
2806
  /**
@@ -2725,7 +2823,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2725
2823
  let outputsNumber = numberOfVariables;
2726
2824
  while (outputsNumber) {
2727
2825
  this.pushOutput({
2728
- type: import_transactions9.OutputType.Variable
2826
+ type: import_transactions10.OutputType.Variable
2729
2827
  });
2730
2828
  outputsNumber -= 1;
2731
2829
  }
@@ -2733,7 +2831,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2733
2831
  }
2734
2832
  calculateMaxGas(chainInfo, minGas) {
2735
2833
  const { consensusParameters } = chainInfo;
2736
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2834
+ const {
2835
+ feeParameters: { gasPerByte },
2836
+ txParameters: { maxGasPerTx }
2837
+ } = consensusParameters;
2737
2838
  const witnessesLength = this.toTransaction().witnesses.reduce(
2738
2839
  (acc, wit) => acc + wit.dataLength,
2739
2840
  0
@@ -2759,12 +2860,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2759
2860
  return this;
2760
2861
  }
2761
2862
  const inputIndex = super.pushInput({
2762
- type: import_transactions9.InputType.Contract,
2863
+ type: import_transactions10.InputType.Contract,
2763
2864
  contractId: contractAddress.toB256(),
2764
2865
  txPointer: "0x00000000000000000000000000000000"
2765
2866
  });
2766
2867
  this.pushOutput({
2767
- type: import_transactions9.OutputType.Contract,
2868
+ type: import_transactions10.OutputType.Contract,
2768
2869
  inputIndex
2769
2870
  });
2770
2871
  return this;
@@ -2801,17 +2902,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2801
2902
 
2802
2903
  // src/providers/transaction-request/utils.ts
2803
2904
  var import_errors9 = require("@fuel-ts/errors");
2804
- var import_transactions10 = require("@fuel-ts/transactions");
2905
+ var import_transactions11 = require("@fuel-ts/transactions");
2805
2906
  var transactionRequestify = (obj) => {
2806
2907
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2807
2908
  return obj;
2808
2909
  }
2809
2910
  const { type } = obj;
2810
2911
  switch (obj.type) {
2811
- case import_transactions10.TransactionType.Script: {
2912
+ case import_transactions11.TransactionType.Script: {
2812
2913
  return ScriptTransactionRequest.from(obj);
2813
2914
  }
2814
- case import_transactions10.TransactionType.Create: {
2915
+ case import_transactions11.TransactionType.Create: {
2815
2916
  return CreateTransactionRequest.from(obj);
2816
2917
  }
2817
2918
  default: {
@@ -2819,61 +2920,46 @@ var transactionRequestify = (obj) => {
2819
2920
  }
2820
2921
  }
2821
2922
  };
2822
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2823
- (acc, input) => {
2824
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2825
- acc.utxos.push(input.id);
2826
- }
2827
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2828
- acc.messages.push(input.nonce);
2829
- }
2830
- return acc;
2831
- },
2832
- {
2833
- utxos: [],
2834
- messages: []
2835
- }
2836
- );
2837
2923
 
2838
2924
  // src/providers/transaction-response/transaction-response.ts
2839
2925
  var import_errors13 = require("@fuel-ts/errors");
2840
- var import_math15 = require("@fuel-ts/math");
2841
- var import_transactions18 = require("@fuel-ts/transactions");
2926
+ var import_math17 = require("@fuel-ts/math");
2927
+ var import_transactions19 = require("@fuel-ts/transactions");
2842
2928
  var import_utils20 = require("@fuel-ts/utils");
2843
2929
 
2844
2930
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2845
- var import_math14 = require("@fuel-ts/math");
2846
- var import_transactions16 = require("@fuel-ts/transactions");
2931
+ var import_math16 = require("@fuel-ts/math");
2932
+ var import_transactions17 = require("@fuel-ts/transactions");
2847
2933
  var import_utils18 = require("@fuel-ts/utils");
2848
2934
 
2849
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2850
- var import_math11 = require("@fuel-ts/math");
2851
- var import_transactions11 = require("@fuel-ts/transactions");
2935
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2936
+ var import_math12 = require("@fuel-ts/math");
2937
+ var import_transactions12 = require("@fuel-ts/transactions");
2852
2938
  var import_utils16 = require("@fuel-ts/utils");
2853
- var calculateTransactionFee = (params) => {
2939
+ var calculateTXFeeForSummary = (params) => {
2854
2940
  const {
2855
2941
  gasPrice,
2856
2942
  rawPayload,
2857
2943
  tip,
2944
+ totalFee,
2858
2945
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2859
2946
  } = params;
2860
- const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2861
- const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2862
- const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2863
- const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2864
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2865
- return {
2866
- fee: (0, import_math11.bn)(0),
2867
- minFee: (0, import_math11.bn)(0),
2868
- maxFee: (0, import_math11.bn)(0)
2869
- };
2947
+ if (totalFee) {
2948
+ return totalFee;
2870
2949
  }
2950
+ const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
2951
+ const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
2952
+ const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2953
+ const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
2871
2954
  const { type, witnesses, inputs, policies } = transaction;
2872
- let metadataGas = (0, import_math11.bn)(0);
2873
- let gasLimit = (0, import_math11.bn)(0);
2874
- if (type === import_transactions11.TransactionType.Create) {
2955
+ let metadataGas = (0, import_math12.bn)(0);
2956
+ let gasLimit = (0, import_math12.bn)(0);
2957
+ if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
2958
+ return (0, import_math12.bn)(0);
2959
+ }
2960
+ if (type === import_transactions12.TransactionType.Create) {
2875
2961
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2876
- const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2962
+ const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2877
2963
  metadataGas = calculateMetadataGasForTxCreate({
2878
2964
  contractBytesSize,
2879
2965
  gasCosts,
@@ -2892,12 +2978,12 @@ var calculateTransactionFee = (params) => {
2892
2978
  }
2893
2979
  const minGas = getMinGas({
2894
2980
  gasCosts,
2895
- gasPerByte: (0, import_math11.bn)(gasPerByte),
2981
+ gasPerByte: (0, import_math12.bn)(gasPerByte),
2896
2982
  inputs,
2897
2983
  metadataGas,
2898
2984
  txBytesSize: transactionBytes.length
2899
2985
  });
2900
- const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2986
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
2901
2987
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2902
2988
  const maxGas = getMaxGas({
2903
2989
  gasPerByte,
@@ -2907,34 +2993,24 @@ var calculateTransactionFee = (params) => {
2907
2993
  witnessLimit,
2908
2994
  maxGasPerTx
2909
2995
  });
2910
- const minFee = calculateGasFee({
2911
- gasPrice,
2912
- gas: minGas,
2913
- priceFactor: gasPriceFactor,
2914
- tip
2915
- });
2916
2996
  const maxFee = calculateGasFee({
2917
2997
  gasPrice,
2918
2998
  gas: maxGas,
2919
2999
  priceFactor: gasPriceFactor,
2920
3000
  tip
2921
3001
  });
2922
- return {
2923
- minFee,
2924
- maxFee,
2925
- fee: maxFee
2926
- };
3002
+ return maxFee;
2927
3003
  };
2928
3004
 
2929
3005
  // src/providers/transaction-summary/operations.ts
2930
3006
  var import_configs10 = require("@fuel-ts/address/configs");
2931
3007
  var import_errors11 = require("@fuel-ts/errors");
2932
- var import_math13 = require("@fuel-ts/math");
2933
- var import_transactions14 = require("@fuel-ts/transactions");
3008
+ var import_math14 = require("@fuel-ts/math");
3009
+ var import_transactions15 = require("@fuel-ts/transactions");
2934
3010
 
2935
3011
  // src/providers/transaction-summary/call.ts
2936
3012
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
2937
- var import_math12 = require("@fuel-ts/math");
3013
+ var import_math13 = require("@fuel-ts/math");
2938
3014
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2939
3015
  const abiInterface = new import_abi_coder4.Interface(abi);
2940
3016
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2943,7 +3019,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2943
3019
  let encodedArgs;
2944
3020
  if (functionFragment.isInputDataPointer) {
2945
3021
  if (rawPayload) {
2946
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
3022
+ const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2947
3023
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2948
3024
  }
2949
3025
  } else {
@@ -2978,7 +3054,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2978
3054
 
2979
3055
  // src/providers/transaction-summary/input.ts
2980
3056
  var import_errors10 = require("@fuel-ts/errors");
2981
- var import_transactions12 = require("@fuel-ts/transactions");
3057
+ var import_transactions13 = require("@fuel-ts/transactions");
2982
3058
  function getInputsByTypes(inputs, types) {
2983
3059
  return inputs.filter((i) => types.includes(i.type));
2984
3060
  }
@@ -2986,16 +3062,16 @@ function getInputsByType(inputs, type) {
2986
3062
  return inputs.filter((i) => i.type === type);
2987
3063
  }
2988
3064
  function getInputsCoin(inputs) {
2989
- return getInputsByType(inputs, import_transactions12.InputType.Coin);
3065
+ return getInputsByType(inputs, import_transactions13.InputType.Coin);
2990
3066
  }
2991
3067
  function getInputsMessage(inputs) {
2992
- return getInputsByType(inputs, import_transactions12.InputType.Message);
3068
+ return getInputsByType(inputs, import_transactions13.InputType.Message);
2993
3069
  }
2994
3070
  function getInputsCoinAndMessage(inputs) {
2995
- return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
3071
+ return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
2996
3072
  }
2997
3073
  function getInputsContract(inputs) {
2998
- return getInputsByType(inputs, import_transactions12.InputType.Contract);
3074
+ return getInputsByType(inputs, import_transactions13.InputType.Contract);
2999
3075
  }
3000
3076
  function getInputFromAssetId(inputs, assetId) {
3001
3077
  const coinInputs = getInputsCoin(inputs);
@@ -3014,7 +3090,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
3014
3090
  if (!contractInput) {
3015
3091
  return void 0;
3016
3092
  }
3017
- if (contractInput.type !== import_transactions12.InputType.Contract) {
3093
+ if (contractInput.type !== import_transactions13.InputType.Contract) {
3018
3094
  throw new import_errors10.FuelError(
3019
3095
  import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
3020
3096
  `Contract input should be of type 'contract'.`
@@ -3023,34 +3099,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
3023
3099
  return contractInput;
3024
3100
  }
3025
3101
  function getInputAccountAddress(input) {
3026
- if (input.type === import_transactions12.InputType.Coin) {
3102
+ if (input.type === import_transactions13.InputType.Coin) {
3027
3103
  return input.owner.toString();
3028
3104
  }
3029
- if (input.type === import_transactions12.InputType.Message) {
3105
+ if (input.type === import_transactions13.InputType.Message) {
3030
3106
  return input.recipient.toString();
3031
3107
  }
3032
3108
  return "";
3033
3109
  }
3034
3110
 
3035
3111
  // src/providers/transaction-summary/output.ts
3036
- var import_transactions13 = require("@fuel-ts/transactions");
3112
+ var import_transactions14 = require("@fuel-ts/transactions");
3037
3113
  function getOutputsByType(outputs, type) {
3038
3114
  return outputs.filter((o) => o.type === type);
3039
3115
  }
3040
3116
  function getOutputsContractCreated(outputs) {
3041
- return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
3117
+ return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
3042
3118
  }
3043
3119
  function getOutputsCoin(outputs) {
3044
- return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
3120
+ return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
3045
3121
  }
3046
3122
  function getOutputsChange(outputs) {
3047
- return getOutputsByType(outputs, import_transactions13.OutputType.Change);
3123
+ return getOutputsByType(outputs, import_transactions14.OutputType.Change);
3048
3124
  }
3049
3125
  function getOutputsContract(outputs) {
3050
- return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
3126
+ return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
3051
3127
  }
3052
3128
  function getOutputsVariable(outputs) {
3053
- return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
3129
+ return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
3054
3130
  }
3055
3131
 
3056
3132
  // src/providers/transaction-summary/types.ts
@@ -3058,6 +3134,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
3058
3134
  TransactionTypeName2["Create"] = "Create";
3059
3135
  TransactionTypeName2["Mint"] = "Mint";
3060
3136
  TransactionTypeName2["Script"] = "Script";
3137
+ TransactionTypeName2["Upgrade"] = "Upgrade";
3138
+ TransactionTypeName2["Upload"] = "Upload";
3061
3139
  return TransactionTypeName2;
3062
3140
  })(TransactionTypeName || {});
3063
3141
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
@@ -3097,11 +3175,11 @@ function getReceiptsByType(receipts, type) {
3097
3175
  }
3098
3176
  function getTransactionTypeName(transactionType) {
3099
3177
  switch (transactionType) {
3100
- case import_transactions14.TransactionType.Mint:
3178
+ case import_transactions15.TransactionType.Mint:
3101
3179
  return "Mint" /* Mint */;
3102
- case import_transactions14.TransactionType.Create:
3180
+ case import_transactions15.TransactionType.Create:
3103
3181
  return "Create" /* Create */;
3104
- case import_transactions14.TransactionType.Script:
3182
+ case import_transactions15.TransactionType.Script:
3105
3183
  return "Script" /* Script */;
3106
3184
  default:
3107
3185
  throw new import_errors11.FuelError(
@@ -3123,14 +3201,20 @@ function isTypeCreate(transactionType) {
3123
3201
  function isTypeScript(transactionType) {
3124
3202
  return isType(transactionType, "Script" /* Script */);
3125
3203
  }
3204
+ function isTypeUpgrade(transactionType) {
3205
+ return isType(transactionType, "Upgrade" /* Upgrade */);
3206
+ }
3207
+ function isTypeUpload(transactionType) {
3208
+ return isType(transactionType, "Upload" /* Upload */);
3209
+ }
3126
3210
  function hasSameAssetId(a) {
3127
3211
  return (b) => a.assetId === b.assetId;
3128
3212
  }
3129
3213
  function getReceiptsCall(receipts) {
3130
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
3214
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
3131
3215
  }
3132
3216
  function getReceiptsMessageOut(receipts) {
3133
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
3217
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
3134
3218
  }
3135
3219
  var mergeAssets = (op1, op2) => {
3136
3220
  const assets1 = op1.assetsSent || [];
@@ -3143,7 +3227,7 @@ var mergeAssets = (op1, op2) => {
3143
3227
  if (!matchingAsset) {
3144
3228
  return asset1;
3145
3229
  }
3146
- const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
3230
+ const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
3147
3231
  return { ...asset1, amount: mergedAmount };
3148
3232
  });
3149
3233
  return mergedAssets.concat(filteredAssets);
@@ -3169,7 +3253,7 @@ function addOperation(operations, toAdd) {
3169
3253
  return allOperations;
3170
3254
  }
3171
3255
  function getReceiptsTransferOut(receipts) {
3172
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
3256
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
3173
3257
  }
3174
3258
  function getWithdrawFromFuelOperations({
3175
3259
  inputs,
@@ -3329,11 +3413,11 @@ function getTransferOperations({
3329
3413
  });
3330
3414
  const transferReceipts = getReceiptsByType(
3331
3415
  receipts,
3332
- import_transactions14.ReceiptType.Transfer
3416
+ import_transactions15.ReceiptType.Transfer
3333
3417
  );
3334
3418
  const transferOutReceipts = getReceiptsByType(
3335
3419
  receipts,
3336
- import_transactions14.ReceiptType.TransferOut
3420
+ import_transactions15.ReceiptType.TransferOut
3337
3421
  );
3338
3422
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3339
3423
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3418,17 +3502,17 @@ function getOperations({
3418
3502
  }
3419
3503
 
3420
3504
  // src/providers/transaction-summary/receipt.ts
3421
- var import_transactions15 = require("@fuel-ts/transactions");
3505
+ var import_transactions16 = require("@fuel-ts/transactions");
3422
3506
  var processGqlReceipt = (gqlReceipt) => {
3423
3507
  const receipt = assembleReceiptByType(gqlReceipt);
3424
3508
  switch (receipt.type) {
3425
- case import_transactions15.ReceiptType.ReturnData: {
3509
+ case import_transactions16.ReceiptType.ReturnData: {
3426
3510
  return {
3427
3511
  ...receipt,
3428
3512
  data: gqlReceipt.data || "0x"
3429
3513
  };
3430
3514
  }
3431
- case import_transactions15.ReceiptType.LogData: {
3515
+ case import_transactions16.ReceiptType.LogData: {
3432
3516
  return {
3433
3517
  ...receipt,
3434
3518
  data: gqlReceipt.data || "0x"
@@ -3441,7 +3525,7 @@ var processGqlReceipt = (gqlReceipt) => {
3441
3525
  var extractMintedAssetsFromReceipts = (receipts) => {
3442
3526
  const mintedAssets = [];
3443
3527
  receipts.forEach((receipt) => {
3444
- if (receipt.type === import_transactions15.ReceiptType.Mint) {
3528
+ if (receipt.type === import_transactions16.ReceiptType.Mint) {
3445
3529
  mintedAssets.push({
3446
3530
  subId: receipt.subId,
3447
3531
  contractId: receipt.contractId,
@@ -3455,7 +3539,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3455
3539
  var extractBurnedAssetsFromReceipts = (receipts) => {
3456
3540
  const burnedAssets = [];
3457
3541
  receipts.forEach((receipt) => {
3458
- if (receipt.type === import_transactions15.ReceiptType.Burn) {
3542
+ if (receipt.type === import_transactions16.ReceiptType.Burn) {
3459
3543
  burnedAssets.push({
3460
3544
  subId: receipt.subId,
3461
3545
  contractId: receipt.contractId,
@@ -3469,6 +3553,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3469
3553
 
3470
3554
  // src/providers/transaction-summary/status.ts
3471
3555
  var import_errors12 = require("@fuel-ts/errors");
3556
+ var import_math15 = require("@fuel-ts/math");
3472
3557
  var getTransactionStatusName = (gqlStatus) => {
3473
3558
  switch (gqlStatus) {
3474
3559
  case "FailureStatus":
@@ -3490,6 +3575,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3490
3575
  let time;
3491
3576
  let blockId;
3492
3577
  let status;
3578
+ let totalFee;
3579
+ let totalGas;
3493
3580
  let isStatusFailure = false;
3494
3581
  let isStatusSuccess = false;
3495
3582
  let isStatusPending = false;
@@ -3500,11 +3587,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3500
3587
  time = gqlTransactionStatus.time;
3501
3588
  blockId = gqlTransactionStatus.block.id;
3502
3589
  isStatusSuccess = true;
3590
+ totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
3591
+ totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
3503
3592
  break;
3504
3593
  case "FailureStatus":
3505
3594
  time = gqlTransactionStatus.time;
3506
3595
  blockId = gqlTransactionStatus.block.id;
3507
3596
  isStatusFailure = true;
3597
+ totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
3598
+ totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
3508
3599
  break;
3509
3600
  case "SubmittedStatus":
3510
3601
  time = gqlTransactionStatus.time;
@@ -3517,6 +3608,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3517
3608
  time,
3518
3609
  blockId,
3519
3610
  status,
3611
+ totalFee,
3612
+ totalGas,
3520
3613
  isStatusFailure,
3521
3614
  isStatusSuccess,
3522
3615
  isStatusPending
@@ -3552,8 +3645,10 @@ function assembleTransactionSummary(params) {
3552
3645
  maxInputs
3553
3646
  });
3554
3647
  const typeName = getTransactionTypeName(transaction.type);
3555
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3556
- const { fee } = calculateTransactionFee({
3648
+ const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
3649
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3650
+ const fee = calculateTXFeeForSummary({
3651
+ totalFee,
3557
3652
  gasPrice,
3558
3653
  rawPayload,
3559
3654
  tip,
@@ -3566,7 +3661,6 @@ function assembleTransactionSummary(params) {
3566
3661
  }
3567
3662
  }
3568
3663
  });
3569
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3570
3664
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3571
3665
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3572
3666
  let date;
@@ -3575,6 +3669,7 @@ function assembleTransactionSummary(params) {
3575
3669
  }
3576
3670
  const transactionSummary = {
3577
3671
  id,
3672
+ tip,
3578
3673
  fee,
3579
3674
  gasUsed,
3580
3675
  operations,
@@ -3588,6 +3683,8 @@ function assembleTransactionSummary(params) {
3588
3683
  isTypeMint: isTypeMint(transaction.type),
3589
3684
  isTypeCreate: isTypeCreate(transaction.type),
3590
3685
  isTypeScript: isTypeScript(transaction.type),
3686
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3687
+ isTypeUpload: isTypeUpload(transaction.type),
3591
3688
  isStatusFailure,
3592
3689
  isStatusSuccess,
3593
3690
  isStatusPending,
@@ -3599,12 +3696,12 @@ function assembleTransactionSummary(params) {
3599
3696
 
3600
3697
  // src/providers/transaction-response/getDecodedLogs.ts
3601
3698
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3602
- var import_transactions17 = require("@fuel-ts/transactions");
3699
+ var import_transactions18 = require("@fuel-ts/transactions");
3603
3700
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3604
3701
  return receipts.reduce((logs, receipt) => {
3605
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3702
+ if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
3606
3703
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3607
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3704
+ const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3608
3705
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3609
3706
  logs.push(decodedLog);
3610
3707
  }
@@ -3619,7 +3716,7 @@ var TransactionResponse = class {
3619
3716
  /** Current provider */
3620
3717
  provider;
3621
3718
  /** Gas used on the transaction */
3622
- gasUsed = (0, import_math15.bn)(0);
3719
+ gasUsed = (0, import_math17.bn)(0);
3623
3720
  /** The graphql Transaction with receipts object. */
3624
3721
  gqlTransaction;
3625
3722
  abis;
@@ -3677,7 +3774,7 @@ var TransactionResponse = class {
3677
3774
  * @returns The decoded transaction.
3678
3775
  */
3679
3776
  decodeTransaction(transactionWithReceipts) {
3680
- return new import_transactions18.TransactionCoder().decode(
3777
+ return new import_transactions19.TransactionCoder().decode(
3681
3778
  (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3682
3779
  0
3683
3780
  )?.[0];
@@ -3704,7 +3801,7 @@ var TransactionResponse = class {
3704
3801
  const receipts = txReceipts.map(processGqlReceipt) || [];
3705
3802
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3706
3803
  const gasPrice = await this.provider.getLatestGasPrice();
3707
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3804
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3708
3805
  const transactionSummary = assembleTransactionSummary({
3709
3806
  id: this.id,
3710
3807
  receipts,
@@ -3840,33 +3937,60 @@ var mergeQuantities = (...coinQuantities) => {
3840
3937
  var MAX_RETRIES = 10;
3841
3938
  var processGqlChain = (chain) => {
3842
3939
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3843
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3940
+ const {
3941
+ contractParams,
3942
+ feeParams,
3943
+ predicateParams,
3944
+ scriptParams,
3945
+ txParams,
3946
+ gasCosts,
3947
+ baseAssetId,
3948
+ chainId,
3949
+ version
3950
+ } = consensusParameters;
3844
3951
  return {
3845
3952
  name,
3846
- baseChainHeight: (0, import_math16.bn)(daHeight),
3953
+ baseChainHeight: (0, import_math18.bn)(daHeight),
3847
3954
  consensusParameters: {
3848
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3849
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3850
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3851
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3852
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3853
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3854
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3855
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3856
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3857
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3858
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3859
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3860
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3861
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3862
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3863
- baseAssetId: consensusParameters.baseAssetId,
3955
+ version,
3956
+ chainId: (0, import_math18.bn)(chainId),
3957
+ baseAssetId,
3958
+ feeParameters: {
3959
+ version: feeParams.version,
3960
+ gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
3961
+ gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
3962
+ },
3963
+ contractParameters: {
3964
+ version: contractParams.version,
3965
+ contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
3966
+ maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
3967
+ },
3968
+ txParameters: {
3969
+ version: txParams.version,
3970
+ maxInputs: (0, import_math18.bn)(txParams.maxInputs),
3971
+ maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
3972
+ maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
3973
+ maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
3974
+ maxSize: (0, import_math18.bn)(txParams.maxSize),
3975
+ maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
3976
+ },
3977
+ predicateParameters: {
3978
+ version: predicateParams.version,
3979
+ maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
3980
+ maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
3981
+ maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
3982
+ maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
3983
+ },
3984
+ scriptParameters: {
3985
+ version: scriptParams.version,
3986
+ maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
3987
+ maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
3988
+ },
3864
3989
  gasCosts
3865
3990
  },
3866
- gasCosts,
3867
3991
  latestBlock: {
3868
3992
  id: latestBlock.id,
3869
- height: (0, import_math16.bn)(latestBlock.height),
3993
+ height: (0, import_math18.bn)(latestBlock.height),
3870
3994
  time: latestBlock.header.time,
3871
3995
  transactions: latestBlock.transactions.map((i) => ({
3872
3996
  id: i.id
@@ -3960,7 +4084,12 @@ var _Provider = class {
3960
4084
  * Returns some helpful parameters related to gas fees.
3961
4085
  */
3962
4086
  getGasConfig() {
3963
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
4087
+ const {
4088
+ txParameters: { maxGasPerTx },
4089
+ predicateParameters: { maxGasPerPredicate },
4090
+ feeParameters: { gasPriceFactor, gasPerByte },
4091
+ gasCosts
4092
+ } = this.getChain().consensusParameters;
3964
4093
  return {
3965
4094
  maxGasPerTx,
3966
4095
  maxGasPerPredicate,
@@ -3995,11 +4124,9 @@ var _Provider = class {
3995
4124
  static ensureClientVersionIsSupported(nodeInfo) {
3996
4125
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3997
4126
  if (!isMajorSupported || !isMinorSupported) {
3998
- console.warn(
3999
- `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
4000
- which is not supported by the version of the TS SDK that you are using.
4001
- Things might or might not work as expected.
4002
- Supported fuel-core version: ${supportedVersion}.`
4127
+ throw new import_errors14.FuelError(
4128
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
4129
+ `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
4003
4130
  );
4004
4131
  }
4005
4132
  }
@@ -4057,7 +4184,7 @@ Supported fuel-core version: ${supportedVersion}.`
4057
4184
  */
4058
4185
  async getBlockNumber() {
4059
4186
  const { chain } = await this.operations.getChain();
4060
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
4187
+ return (0, import_math18.bn)(chain.latestBlock.height, 10);
4061
4188
  }
4062
4189
  /**
4063
4190
  * Returns the chain information.
@@ -4067,8 +4194,8 @@ Supported fuel-core version: ${supportedVersion}.`
4067
4194
  async fetchNode() {
4068
4195
  const { nodeInfo } = await this.operations.getNodeInfo();
4069
4196
  const processedNodeInfo = {
4070
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4071
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
4197
+ maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
4198
+ maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
4072
4199
  nodeVersion: nodeInfo.nodeVersion,
4073
4200
  utxoValidation: nodeInfo.utxoValidation,
4074
4201
  vmBacktrace: nodeInfo.vmBacktrace
@@ -4126,7 +4253,7 @@ Supported fuel-core version: ${supportedVersion}.`
4126
4253
  }
4127
4254
  const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4128
4255
  let abis;
4129
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4256
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4130
4257
  abis = transactionRequest.abis;
4131
4258
  }
4132
4259
  if (awaitExecution) {
@@ -4172,9 +4299,9 @@ Supported fuel-core version: ${supportedVersion}.`
4172
4299
  encodedTransactions: encodedTransaction,
4173
4300
  utxoValidation: utxoValidation || false
4174
4301
  });
4175
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4302
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
4176
4303
  const receipts = rawReceipts.map(processGqlReceipt);
4177
- return { receipts, dryrunStatus: status };
4304
+ return { receipts, dryRunStatus };
4178
4305
  }
4179
4306
  /**
4180
4307
  * Verifies whether enough gas is available to complete transaction.
@@ -4185,7 +4312,7 @@ Supported fuel-core version: ${supportedVersion}.`
4185
4312
  async estimatePredicates(transactionRequest) {
4186
4313
  const shouldEstimatePredicates = Boolean(
4187
4314
  transactionRequest.inputs.find(
4188
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
4315
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
4189
4316
  )
4190
4317
  );
4191
4318
  if (!shouldEstimatePredicates) {
@@ -4200,7 +4327,7 @@ Supported fuel-core version: ${supportedVersion}.`
4200
4327
  } = response;
4201
4328
  if (inputs) {
4202
4329
  inputs.forEach((input, index) => {
4203
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4330
+ if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
4204
4331
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4205
4332
  }
4206
4333
  });
@@ -4218,7 +4345,7 @@ Supported fuel-core version: ${supportedVersion}.`
4218
4345
  * @returns A promise.
4219
4346
  */
4220
4347
  async estimateTxDependencies(transactionRequest) {
4221
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4348
+ if (transactionRequest.type === import_transactions20.TransactionType.Create) {
4222
4349
  return {
4223
4350
  receipts: [],
4224
4351
  outputVariables: 0,
@@ -4228,7 +4355,7 @@ Supported fuel-core version: ${supportedVersion}.`
4228
4355
  let receipts = [];
4229
4356
  const missingContractIds = [];
4230
4357
  let outputVariables = 0;
4231
- let dryrunStatus;
4358
+ let dryRunStatus;
4232
4359
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4233
4360
  const {
4234
4361
  dryRun: [{ receipts: rawReceipts, status }]
@@ -4237,7 +4364,7 @@ Supported fuel-core version: ${supportedVersion}.`
4237
4364
  utxoValidation: false
4238
4365
  });
4239
4366
  receipts = rawReceipts.map(processGqlReceipt);
4240
- dryrunStatus = status;
4367
+ dryRunStatus = status;
4241
4368
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4242
4369
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4243
4370
  if (hasMissingOutputs) {
@@ -4259,7 +4386,7 @@ Supported fuel-core version: ${supportedVersion}.`
4259
4386
  receipts,
4260
4387
  outputVariables,
4261
4388
  missingContractIds,
4262
- dryrunStatus
4389
+ dryRunStatus
4263
4390
  };
4264
4391
  }
4265
4392
  /**
@@ -4277,12 +4404,12 @@ Supported fuel-core version: ${supportedVersion}.`
4277
4404
  receipts: [],
4278
4405
  outputVariables: 0,
4279
4406
  missingContractIds: [],
4280
- dryrunStatus: void 0
4407
+ dryRunStatus: void 0
4281
4408
  }));
4282
4409
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4283
4410
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4284
4411
  allRequests.forEach((req, index) => {
4285
- if (req.type === import_transactions19.TransactionType.Script) {
4412
+ if (req.type === import_transactions20.TransactionType.Script) {
4286
4413
  serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4287
4414
  }
4288
4415
  });
@@ -4302,13 +4429,13 @@ Supported fuel-core version: ${supportedVersion}.`
4302
4429
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4303
4430
  const result = results[requestIdx];
4304
4431
  result.receipts = rawReceipts.map(processGqlReceipt);
4305
- result.dryrunStatus = status;
4432
+ result.dryRunStatus = status;
4306
4433
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4307
4434
  result.receipts
4308
4435
  );
4309
4436
  const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4310
4437
  const request = allRequests[requestIdx];
4311
- if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4438
+ if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
4312
4439
  result.outputVariables += missingOutputVariables.length;
4313
4440
  request.addVariableOutputs(missingOutputVariables.length);
4314
4441
  missingOutputContractIds.forEach(({ contractId }) => {
@@ -4339,7 +4466,7 @@ Supported fuel-core version: ${supportedVersion}.`
4339
4466
  });
4340
4467
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4341
4468
  const receipts = rawReceipts.map(processGqlReceipt);
4342
- return { receipts, dryrunStatus: status };
4469
+ return { receipts, dryRunStatus: status };
4343
4470
  });
4344
4471
  return results;
4345
4472
  }
@@ -4358,13 +4485,13 @@ Supported fuel-core version: ${supportedVersion}.`
4358
4485
  gasPrice = await this.estimateGasPrice(10);
4359
4486
  }
4360
4487
  const minFee = calculateGasFee({
4361
- gasPrice: (0, import_math16.bn)(gasPrice),
4488
+ gasPrice: (0, import_math18.bn)(gasPrice),
4362
4489
  gas: minGas,
4363
4490
  priceFactor: gasPriceFactor,
4364
4491
  tip: transactionRequest.tip
4365
4492
  }).add(1);
4366
- let gasLimit = (0, import_math16.bn)(0);
4367
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4493
+ let gasLimit = (0, import_math18.bn)(0);
4494
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4368
4495
  gasLimit = transactionRequest.gasLimit;
4369
4496
  if (transactionRequest.gasLimit.eq(0)) {
4370
4497
  transactionRequest.gasLimit = minGas;
@@ -4376,7 +4503,7 @@ Supported fuel-core version: ${supportedVersion}.`
4376
4503
  }
4377
4504
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4378
4505
  const maxFee = calculateGasFee({
4379
- gasPrice: (0, import_math16.bn)(gasPrice),
4506
+ gasPrice: (0, import_math18.bn)(gasPrice),
4380
4507
  gas: maxGas,
4381
4508
  priceFactor: gasPriceFactor,
4382
4509
  tip: transactionRequest.tip
@@ -4434,14 +4561,14 @@ Supported fuel-core version: ${supportedVersion}.`
4434
4561
  */
4435
4562
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4436
4563
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4437
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4564
+ const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
4438
4565
  const baseAssetId = this.getBaseAssetId();
4439
4566
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4440
4567
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4441
4568
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4442
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4569
+ txRequestClone.maxFee = (0, import_math18.bn)(0);
4443
4570
  if (isScriptTransaction) {
4444
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4571
+ txRequestClone.gasLimit = (0, import_math18.bn)(0);
4445
4572
  }
4446
4573
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4447
4574
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4458,9 +4585,10 @@ Supported fuel-core version: ${supportedVersion}.`
4458
4585
  transactionRequest: signedRequest
4459
4586
  });
4460
4587
  let receipts = [];
4588
+ let dryRunStatus;
4461
4589
  let missingContractIds = [];
4462
4590
  let outputVariables = 0;
4463
- let gasUsed = (0, import_math16.bn)(0);
4591
+ let gasUsed = (0, import_math18.bn)(0);
4464
4592
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4465
4593
  txRequestClone.maxFee = maxFee;
4466
4594
  if (isScriptTransaction) {
@@ -4468,10 +4596,7 @@ Supported fuel-core version: ${supportedVersion}.`
4468
4596
  if (signatureCallback) {
4469
4597
  await signatureCallback(txRequestClone);
4470
4598
  }
4471
- const result = await this.estimateTxDependencies(txRequestClone);
4472
- receipts = result.receipts;
4473
- outputVariables = result.outputVariables;
4474
- missingContractIds = result.missingContractIds;
4599
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4475
4600
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4476
4601
  txRequestClone.gasLimit = gasUsed;
4477
4602
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4491,7 +4616,8 @@ Supported fuel-core version: ${supportedVersion}.`
4491
4616
  outputVariables,
4492
4617
  missingContractIds,
4493
4618
  addedSignatures,
4494
- estimatedPredicates: txRequestClone.inputs
4619
+ estimatedPredicates: txRequestClone.inputs,
4620
+ dryRunStatus
4495
4621
  };
4496
4622
  }
4497
4623
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4527,10 +4653,10 @@ Supported fuel-core version: ${supportedVersion}.`
4527
4653
  return coins.map((coin) => ({
4528
4654
  id: coin.utxoId,
4529
4655
  assetId: coin.assetId,
4530
- amount: (0, import_math16.bn)(coin.amount),
4656
+ amount: (0, import_math18.bn)(coin.amount),
4531
4657
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4532
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4533
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4658
+ blockCreated: (0, import_math18.bn)(coin.blockCreated),
4659
+ txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
4534
4660
  }));
4535
4661
  }
4536
4662
  /**
@@ -4567,9 +4693,9 @@ Supported fuel-core version: ${supportedVersion}.`
4567
4693
  switch (coin.__typename) {
4568
4694
  case "MessageCoin":
4569
4695
  return {
4570
- amount: (0, import_math16.bn)(coin.amount),
4696
+ amount: (0, import_math18.bn)(coin.amount),
4571
4697
  assetId: coin.assetId,
4572
- daHeight: (0, import_math16.bn)(coin.daHeight),
4698
+ daHeight: (0, import_math18.bn)(coin.daHeight),
4573
4699
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4574
4700
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4575
4701
  nonce: coin.nonce
@@ -4577,11 +4703,11 @@ Supported fuel-core version: ${supportedVersion}.`
4577
4703
  case "Coin":
4578
4704
  return {
4579
4705
  id: coin.utxoId,
4580
- amount: (0, import_math16.bn)(coin.amount),
4706
+ amount: (0, import_math18.bn)(coin.amount),
4581
4707
  assetId: coin.assetId,
4582
4708
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4583
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4584
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4709
+ blockCreated: (0, import_math18.bn)(coin.blockCreated),
4710
+ txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
4585
4711
  };
4586
4712
  default:
4587
4713
  return null;
@@ -4598,13 +4724,13 @@ Supported fuel-core version: ${supportedVersion}.`
4598
4724
  async getBlock(idOrHeight) {
4599
4725
  let variables;
4600
4726
  if (typeof idOrHeight === "number") {
4601
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4727
+ variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
4602
4728
  } else if (idOrHeight === "latest") {
4603
4729
  variables = { height: (await this.getBlockNumber()).toString(10) };
4604
4730
  } else if (idOrHeight.length === 66) {
4605
4731
  variables = { blockId: idOrHeight };
4606
4732
  } else {
4607
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4733
+ variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
4608
4734
  }
4609
4735
  const { block } = await this.operations.getBlock(variables);
4610
4736
  if (!block) {
@@ -4612,7 +4738,7 @@ Supported fuel-core version: ${supportedVersion}.`
4612
4738
  }
4613
4739
  return {
4614
4740
  id: block.id,
4615
- height: (0, import_math16.bn)(block.height),
4741
+ height: (0, import_math18.bn)(block.height),
4616
4742
  time: block.header.time,
4617
4743
  transactionIds: block.transactions.map((tx) => tx.id)
4618
4744
  };
@@ -4627,7 +4753,7 @@ Supported fuel-core version: ${supportedVersion}.`
4627
4753
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4628
4754
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4629
4755
  id: block.id,
4630
- height: (0, import_math16.bn)(block.height),
4756
+ height: (0, import_math18.bn)(block.height),
4631
4757
  time: block.header.time,
4632
4758
  transactionIds: block.transactions.map((tx) => tx.id)
4633
4759
  }));
@@ -4642,7 +4768,7 @@ Supported fuel-core version: ${supportedVersion}.`
4642
4768
  async getBlockWithTransactions(idOrHeight) {
4643
4769
  let variables;
4644
4770
  if (typeof idOrHeight === "number") {
4645
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4771
+ variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
4646
4772
  } else if (idOrHeight === "latest") {
4647
4773
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4648
4774
  } else {
@@ -4654,11 +4780,11 @@ Supported fuel-core version: ${supportedVersion}.`
4654
4780
  }
4655
4781
  return {
4656
4782
  id: block.id,
4657
- height: (0, import_math16.bn)(block.height, 10),
4783
+ height: (0, import_math18.bn)(block.height, 10),
4658
4784
  time: block.header.time,
4659
4785
  transactionIds: block.transactions.map((tx) => tx.id),
4660
4786
  transactions: block.transactions.map(
4661
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4787
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4662
4788
  )
4663
4789
  };
4664
4790
  }
@@ -4673,7 +4799,7 @@ Supported fuel-core version: ${supportedVersion}.`
4673
4799
  if (!transaction) {
4674
4800
  return null;
4675
4801
  }
4676
- return new import_transactions19.TransactionCoder().decode(
4802
+ return new import_transactions20.TransactionCoder().decode(
4677
4803
  (0, import_utils22.arrayify)(transaction.rawPayload),
4678
4804
  0
4679
4805
  )?.[0];
@@ -4703,7 +4829,7 @@ Supported fuel-core version: ${supportedVersion}.`
4703
4829
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4704
4830
  asset: (0, import_utils22.hexlify)(assetId)
4705
4831
  });
4706
- return (0, import_math16.bn)(contractBalance.amount, 10);
4832
+ return (0, import_math18.bn)(contractBalance.amount, 10);
4707
4833
  }
4708
4834
  /**
4709
4835
  * Returns the balance for the given owner for the given asset ID.
@@ -4717,7 +4843,7 @@ Supported fuel-core version: ${supportedVersion}.`
4717
4843
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4718
4844
  assetId: (0, import_utils22.hexlify)(assetId)
4719
4845
  });
4720
- return (0, import_math16.bn)(balance.amount, 10);
4846
+ return (0, import_math18.bn)(balance.amount, 10);
4721
4847
  }
4722
4848
  /**
4723
4849
  * Returns balances for the given owner.
@@ -4735,7 +4861,7 @@ Supported fuel-core version: ${supportedVersion}.`
4735
4861
  const balances = result.balances.edges.map((edge) => edge.node);
4736
4862
  return balances.map((balance) => ({
4737
4863
  assetId: balance.assetId,
4738
- amount: (0, import_math16.bn)(balance.amount)
4864
+ amount: (0, import_math18.bn)(balance.amount)
4739
4865
  }));
4740
4866
  }
4741
4867
  /**
@@ -4753,19 +4879,19 @@ Supported fuel-core version: ${supportedVersion}.`
4753
4879
  });
4754
4880
  const messages = result.messages.edges.map((edge) => edge.node);
4755
4881
  return messages.map((message) => ({
4756
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4882
+ messageId: import_transactions20.InputMessageCoder.getMessageId({
4757
4883
  sender: message.sender,
4758
4884
  recipient: message.recipient,
4759
4885
  nonce: message.nonce,
4760
- amount: (0, import_math16.bn)(message.amount),
4886
+ amount: (0, import_math18.bn)(message.amount),
4761
4887
  data: message.data
4762
4888
  }),
4763
4889
  sender: import_address3.Address.fromAddressOrString(message.sender),
4764
4890
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4765
4891
  nonce: message.nonce,
4766
- amount: (0, import_math16.bn)(message.amount),
4767
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4768
- daHeight: (0, import_math16.bn)(message.daHeight)
4892
+ amount: (0, import_math18.bn)(message.amount),
4893
+ data: import_transactions20.InputMessageCoder.decodeData(message.data),
4894
+ daHeight: (0, import_math18.bn)(message.daHeight)
4769
4895
  }));
4770
4896
  }
4771
4897
  /**
@@ -4818,59 +4944,59 @@ Supported fuel-core version: ${supportedVersion}.`
4818
4944
  } = result.messageProof;
4819
4945
  return {
4820
4946
  messageProof: {
4821
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4947
+ proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
4822
4948
  proofSet: messageProof.proofSet
4823
4949
  },
4824
4950
  blockProof: {
4825
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4951
+ proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
4826
4952
  proofSet: blockProof.proofSet
4827
4953
  },
4828
4954
  messageBlockHeader: {
4829
4955
  id: messageBlockHeader.id,
4830
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4831
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4956
+ daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
4957
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4832
4958
  transactionsRoot: messageBlockHeader.transactionsRoot,
4833
- height: (0, import_math16.bn)(messageBlockHeader.height),
4959
+ height: (0, import_math18.bn)(messageBlockHeader.height),
4834
4960
  prevRoot: messageBlockHeader.prevRoot,
4835
4961
  time: messageBlockHeader.time,
4836
4962
  applicationHash: messageBlockHeader.applicationHash,
4837
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4963
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4838
4964
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4839
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4965
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4840
4966
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4841
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4967
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4842
4968
  },
4843
4969
  commitBlockHeader: {
4844
4970
  id: commitBlockHeader.id,
4845
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4846
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4971
+ daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
4972
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4847
4973
  transactionsRoot: commitBlockHeader.transactionsRoot,
4848
- height: (0, import_math16.bn)(commitBlockHeader.height),
4974
+ height: (0, import_math18.bn)(commitBlockHeader.height),
4849
4975
  prevRoot: commitBlockHeader.prevRoot,
4850
4976
  time: commitBlockHeader.time,
4851
4977
  applicationHash: commitBlockHeader.applicationHash,
4852
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4978
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4853
4979
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4854
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4980
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4855
4981
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4856
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4982
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4857
4983
  },
4858
4984
  sender: import_address3.Address.fromAddressOrString(sender),
4859
4985
  recipient: import_address3.Address.fromAddressOrString(recipient),
4860
4986
  nonce,
4861
- amount: (0, import_math16.bn)(amount),
4987
+ amount: (0, import_math18.bn)(amount),
4862
4988
  data
4863
4989
  };
4864
4990
  }
4865
4991
  async getLatestGasPrice() {
4866
4992
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4867
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4993
+ return (0, import_math18.bn)(latestGasPrice.gasPrice);
4868
4994
  }
4869
4995
  async estimateGasPrice(blockHorizon) {
4870
4996
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4871
4997
  blockHorizon: String(blockHorizon)
4872
4998
  });
4873
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4999
+ return (0, import_math18.bn)(estimateGasPrice.gasPrice);
4874
5000
  }
4875
5001
  /**
4876
5002
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4891,10 +5017,10 @@ Supported fuel-core version: ${supportedVersion}.`
4891
5017
  */
4892
5018
  async produceBlocks(amount, startTime) {
4893
5019
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4894
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
5020
+ blocksToProduce: (0, import_math18.bn)(amount).toString(10),
4895
5021
  startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4896
5022
  });
4897
- return (0, import_math16.bn)(latestBlockHeight);
5023
+ return (0, import_math18.bn)(latestBlockHeight);
4898
5024
  }
4899
5025
  // eslint-disable-next-line @typescript-eslint/require-await
4900
5026
  async getTransactionResponse(transactionId) {
@@ -4913,6 +5039,15 @@ Supported fuel-core version: ${supportedVersion}.`
4913
5039
  }
4914
5040
  return message;
4915
5041
  }
5042
+ async getRelayedTransactionStatus(relayedTransactionId) {
5043
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
5044
+ relayedTransactionId
5045
+ });
5046
+ if (!relayedTransactionStatus) {
5047
+ return null;
5048
+ }
5049
+ return relayedTransactionStatus;
5050
+ }
4916
5051
  };
4917
5052
  var Provider = _Provider;
4918
5053
  _cacheInputs = new WeakSet();
@@ -4921,7 +5056,7 @@ cacheInputs_fn = function(inputs) {
4921
5056
  return;
4922
5057
  }
4923
5058
  inputs.forEach((input) => {
4924
- if (input.type === import_transactions19.InputType.Coin) {
5059
+ if (input.type === import_transactions20.InputType.Coin) {
4925
5060
  this.cache?.set(input.id);
4926
5061
  }
4927
5062
  });
@@ -4931,8 +5066,8 @@ __publicField(Provider, "nodeInfoCache", {});
4931
5066
 
4932
5067
  // src/providers/transaction-summary/get-transaction-summary.ts
4933
5068
  var import_errors15 = require("@fuel-ts/errors");
4934
- var import_math17 = require("@fuel-ts/math");
4935
- var import_transactions20 = require("@fuel-ts/transactions");
5069
+ var import_math19 = require("@fuel-ts/math");
5070
+ var import_transactions21 = require("@fuel-ts/transactions");
4936
5071
  var import_utils25 = require("@fuel-ts/utils");
4937
5072
  async function getTransactionSummary(params) {
4938
5073
  const { id, provider, abiMap } = params;
@@ -4945,7 +5080,7 @@ async function getTransactionSummary(params) {
4945
5080
  `Transaction not found for given id: ${id}.`
4946
5081
  );
4947
5082
  }
4948
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
5083
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
4949
5084
  (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4950
5085
  0
4951
5086
  );
@@ -4955,7 +5090,11 @@ async function getTransactionSummary(params) {
4955
5090
  }
4956
5091
  const receipts = txReceipts.map(processGqlReceipt);
4957
5092
  const {
4958
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5093
+ consensusParameters: {
5094
+ feeParameters: { gasPerByte, gasPriceFactor },
5095
+ txParameters: { maxInputs, maxGasPerTx },
5096
+ gasCosts
5097
+ }
4959
5098
  } = provider.getChain();
4960
5099
  const gasPrice = await provider.getLatestGasPrice();
4961
5100
  const transactionInfo = assembleTransactionSummary({
@@ -4964,8 +5103,8 @@ async function getTransactionSummary(params) {
4964
5103
  transaction: decodedTransaction,
4965
5104
  transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4966
5105
  gqlTransactionStatus: gqlTransaction.status,
4967
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4968
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
5106
+ gasPerByte: (0, import_math19.bn)(gasPerByte),
5107
+ gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
4969
5108
  abiMap,
4970
5109
  maxInputs,
4971
5110
  gasCosts,
@@ -4981,7 +5120,7 @@ async function getTransactionSummaryFromRequest(params) {
4981
5120
  const { provider, transactionRequest, abiMap } = params;
4982
5121
  const { receipts } = await provider.call(transactionRequest);
4983
5122
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4984
- const maxInputs = provider.getChain().consensusParameters.maxInputs;
5123
+ const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
4985
5124
  const transaction = transactionRequest.toTransaction();
4986
5125
  const transactionBytes = transactionRequest.toTransactionBytes();
4987
5126
  const gasPrice = await provider.getLatestGasPrice();
@@ -5004,13 +5143,17 @@ async function getTransactionsSummaries(params) {
5004
5143
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
5005
5144
  const { edges, pageInfo } = transactionsByOwner;
5006
5145
  const {
5007
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5146
+ consensusParameters: {
5147
+ feeParameters: { gasPerByte, gasPriceFactor },
5148
+ txParameters: { maxInputs, maxGasPerTx },
5149
+ gasCosts
5150
+ }
5008
5151
  } = provider.getChain();
5009
5152
  const gasPrice = await provider.getLatestGasPrice();
5010
5153
  const transactions = edges.map((edge) => {
5011
5154
  const { node: gqlTransaction } = edge;
5012
5155
  const { id, rawPayload, status } = gqlTransaction;
5013
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5156
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5014
5157
  let txReceipts = [];
5015
5158
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5016
5159
  txReceipts = gqlTransaction.status.receipts;
@@ -5163,31 +5306,15 @@ var assets = [
5163
5306
  }
5164
5307
  ];
5165
5308
 
5166
- // src/providers/transaction-request/helpers.ts
5167
- var import_math18 = require("@fuel-ts/math");
5168
- var import_transactions21 = require("@fuel-ts/transactions");
5169
- var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
5170
- var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
5171
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
5172
- var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
5173
- if (isRequestInputCoin(input) && input.assetId === assetId) {
5174
- return acc.add(input.amount);
5175
- }
5176
- if (isRequestInputMessage(input) && assetId === baseAsset) {
5177
- return acc.add(input.amount);
5178
- }
5179
- return acc;
5180
- }, (0, import_math18.bn)(0));
5181
-
5182
5309
  // src/utils/formatTransferToContractScriptData.ts
5183
5310
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5184
- var import_math19 = require("@fuel-ts/math");
5311
+ var import_math20 = require("@fuel-ts/math");
5185
5312
  var import_utils26 = require("@fuel-ts/utils");
5186
5313
  var asm = __toESM(require("@fuels/vm-asm"));
5187
5314
  var formatTransferToContractScriptData = (params) => {
5188
5315
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5189
5316
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5190
- const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
5317
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
5191
5318
  const scriptData = Uint8Array.from([
5192
5319
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
5193
5320
  ...encoded,
@@ -5381,10 +5508,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5381
5508
  async fund(request, params) {
5382
5509
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5383
5510
  const baseAssetId = this.provider.getBaseAssetId();
5384
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
5511
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5385
5512
  const txRequest = request;
5386
5513
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5387
- amount: (0, import_math20.bn)(fee),
5514
+ amount: (0, import_math21.bn)(fee),
5388
5515
  assetId: baseAssetId,
5389
5516
  coinQuantities: requiredQuantities
5390
5517
  });
@@ -5392,7 +5519,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5392
5519
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5393
5520
  quantitiesDict[assetId] = {
5394
5521
  required: amount,
5395
- owned: (0, import_math20.bn)(0)
5522
+ owned: (0, import_math21.bn)(0)
5396
5523
  };
5397
5524
  });
5398
5525
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -5416,7 +5543,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5416
5543
  while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5417
5544
  const resources = await this.getResourcesToSpend(
5418
5545
  missingQuantities,
5419
- cacheTxInputsFromOwner(request.inputs, this.address)
5546
+ cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5420
5547
  );
5421
5548
  request.addResources(resources);
5422
5549
  txRequest.shiftPredicateData();
@@ -5497,7 +5624,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5497
5624
  * @returns A promise that resolves to the transaction response.
5498
5625
  */
5499
5626
  async transfer(destination, amount, assetId, txParams = {}) {
5500
- if ((0, import_math20.bn)(amount).lte(0)) {
5627
+ if ((0, import_math21.bn)(amount).lte(0)) {
5501
5628
  throw new import_errors16.FuelError(
5502
5629
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5503
5630
  "Transfer amount must be a positive number."
@@ -5517,7 +5644,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5517
5644
  * @returns A promise that resolves to the transaction response.
5518
5645
  */
5519
5646
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5520
- if ((0, import_math20.bn)(amount).lte(0)) {
5647
+ if ((0, import_math21.bn)(amount).lte(0)) {
5521
5648
  throw new import_errors16.FuelError(
5522
5649
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5523
5650
  "Transfer amount must be a positive number."
@@ -5527,7 +5654,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5527
5654
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5528
5655
  const { script, scriptData } = await assembleTransferToContractScript({
5529
5656
  hexlifiedContractId: contractAddress.toB256(),
5530
- amountToTransfer: (0, import_math20.bn)(amount),
5657
+ amountToTransfer: (0, import_math21.bn)(amount),
5531
5658
  assetId: assetIdToTransfer
5532
5659
  });
5533
5660
  const request = new ScriptTransactionRequest({
@@ -5538,7 +5665,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5538
5665
  request.addContractInputAndOutput(contractAddress);
5539
5666
  const txCost = await this.provider.getTransactionCost(request, {
5540
5667
  resourcesOwner: this,
5541
- quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
5668
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5542
5669
  });
5543
5670
  this.validateGasLimitAndMaxFee({
5544
5671
  gasUsed: txCost.gasUsed,
@@ -5564,7 +5691,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5564
5691
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5565
5692
  );
5566
5693
  const amountDataArray = (0, import_utils27.arrayify)(
5567
- "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5694
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5568
5695
  );
5569
5696
  const script = new Uint8Array([
5570
5697
  ...(0, import_utils27.arrayify)(withdrawScript.bytes),
@@ -5574,7 +5701,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5574
5701
  const params = { script, ...txParams };
5575
5702
  const baseAssetId = this.provider.getBaseAssetId();
5576
5703
  const request = new ScriptTransactionRequest(params);
5577
- const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
5704
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5578
5705
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5579
5706
  this.validateGasLimitAndMaxFee({
5580
5707
  gasUsed: txCost.gasUsed,
@@ -5669,7 +5796,7 @@ var import_utils30 = require("@fuel-ts/utils");
5669
5796
  var import_address5 = require("@fuel-ts/address");
5670
5797
  var import_crypto2 = require("@fuel-ts/crypto");
5671
5798
  var import_hasher2 = require("@fuel-ts/hasher");
5672
- var import_math21 = require("@fuel-ts/math");
5799
+ var import_math22 = require("@fuel-ts/math");
5673
5800
  var import_utils28 = require("@fuel-ts/utils");
5674
5801
  var import_secp256k1 = require("@noble/curves/secp256k1");
5675
5802
  var Signer = class {
@@ -5689,7 +5816,7 @@ var Signer = class {
5689
5816
  privateKey = `0x${privateKey}`;
5690
5817
  }
5691
5818
  }
5692
- const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5819
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5693
5820
  this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5694
5821
  this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5695
5822
  this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5707,8 +5834,8 @@ var Signer = class {
5707
5834
  */
5708
5835
  sign(data) {
5709
5836
  const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5710
- const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5711
- const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5837
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5838
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5712
5839
  s[0] |= (signature.recovery || 0) << 7;
5713
5840
  return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5714
5841
  }
@@ -5980,7 +6107,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5980
6107
  // src/hdwallet/hdwallet.ts
5981
6108
  var import_errors20 = require("@fuel-ts/errors");
5982
6109
  var import_hasher6 = require("@fuel-ts/hasher");
5983
- var import_math22 = require("@fuel-ts/math");
6110
+ var import_math23 = require("@fuel-ts/math");
5984
6111
  var import_utils34 = require("@fuel-ts/utils");
5985
6112
  var import_ethers2 = require("ethers");
5986
6113
 
@@ -8446,13 +8573,13 @@ var HDWallet = class {
8446
8573
  } else {
8447
8574
  data.set((0, import_utils34.arrayify)(this.publicKey));
8448
8575
  }
8449
- data.set((0, import_math22.toBytes)(index, 4), 33);
8576
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8450
8577
  const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8451
8578
  const IL = bytes.slice(0, 32);
8452
8579
  const IR = bytes.slice(32);
8453
8580
  if (privateKey) {
8454
8581
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8455
- const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
8582
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8456
8583
  return new HDWallet({
8457
8584
  privateKey: ki,
8458
8585
  chainCode: IR,
@@ -8498,7 +8625,7 @@ var HDWallet = class {
8498
8625
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8499
8626
  const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8500
8627
  const parentFingerprint = this.parentFingerprint;
8501
- const index = (0, import_math22.toHex)(this.index, 4);
8628
+ const index = (0, import_math23.toHex)(this.index, 4);
8502
8629
  const chainCode = this.chainCode;
8503
8630
  const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8504
8631
  const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -9193,10 +9320,15 @@ var Predicate = class extends Account {
9193
9320
  populateTransactionPredicateData(transactionRequestLike) {
9194
9321
  const request = transactionRequestify(transactionRequestLike);
9195
9322
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9196
- request.inputs?.forEach((input) => {
9197
- if (input.type === import_transactions22.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9323
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
9324
+ if (placeholderIndex !== -1) {
9325
+ request.removeWitness(placeholderIndex);
9326
+ }
9327
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
9328
+ if (isRequestInputResourceFromOwner(input, this.address)) {
9198
9329
  input.predicate = (0, import_utils36.hexlify)(this.bytes);
9199
9330
  input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
9331
+ input.witnessIndex = 0;
9200
9332
  }
9201
9333
  });
9202
9334
  return request;
@@ -9228,7 +9360,7 @@ var Predicate = class extends Account {
9228
9360
  const mainFn = this.interface?.functions.main;
9229
9361
  const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9230
9362
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9231
- maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9363
+ maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9232
9364
  });
9233
9365
  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;
9234
9366
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
@@ -9319,6 +9451,28 @@ var Predicate = class extends Account {
9319
9451
  }
9320
9452
  return mutatedBytes;
9321
9453
  }
9454
+ /**
9455
+ * Returns the index of the witness placeholder that was added to this predicate.
9456
+ * If no witness placeholder was added, it returns -1.
9457
+ * @param request - The transaction request.
9458
+ * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
9459
+ */
9460
+ getIndexFromPlaceholderWitness(request) {
9461
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
9462
+ let index = -1;
9463
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
9464
+ if (hasEmptyPredicateInputs) {
9465
+ index = hasEmptyPredicateInputs.witnessIndex;
9466
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
9467
+ if (!allInputsAreEmpty) {
9468
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
9469
+ if (wasFilledInputAddedFirst) {
9470
+ index = -1;
9471
+ }
9472
+ }
9473
+ }
9474
+ return index;
9475
+ }
9322
9476
  };
9323
9477
 
9324
9478
  // src/connectors/fuel.ts
@@ -10042,11 +10196,12 @@ __publicField(Fuel, "defaultConfig", {});
10042
10196
  assets,
10043
10197
  buildBlockExplorerUrl,
10044
10198
  cacheFor,
10045
- cacheTxInputsFromOwner,
10199
+ cacheRequestInputsResources,
10200
+ cacheRequestInputsResourcesFromOwner,
10046
10201
  calculateGasFee,
10047
10202
  calculateMetadataGasForTxCreate,
10048
10203
  calculateMetadataGasForTxScript,
10049
- calculateTransactionFee,
10204
+ calculateTXFeeForSummary,
10050
10205
  coinQuantityfy,
10051
10206
  deferPromise,
10052
10207
  dispatchFuelConnectorEvent,
@@ -10055,6 +10210,7 @@ __publicField(Fuel, "defaultConfig", {});
10055
10210
  extractMintedAssetsFromReceipts,
10056
10211
  extractTxError,
10057
10212
  gasUsedByInputs,
10213
+ getAssetAmountInRequestInputs,
10058
10214
  getAssetEth,
10059
10215
  getAssetFuel,
10060
10216
  getAssetNetwork,
@@ -10089,6 +10245,7 @@ __publicField(Fuel, "defaultConfig", {});
10089
10245
  getReceiptsMessageOut,
10090
10246
  getReceiptsTransferOut,
10091
10247
  getReceiptsWithMissingData,
10248
+ getRequestInputResourceOwner,
10092
10249
  getTransactionStatusName,
10093
10250
  getTransactionSummary,
10094
10251
  getTransactionSummaryFromRequest,
@@ -10102,10 +10259,16 @@ __publicField(Fuel, "defaultConfig", {});
10102
10259
  isMessage,
10103
10260
  isRawCoin,
10104
10261
  isRawMessage,
10262
+ isRequestInputCoin,
10263
+ isRequestInputMessage,
10264
+ isRequestInputResource,
10265
+ isRequestInputResourceFromOwner,
10105
10266
  isType,
10106
10267
  isTypeCreate,
10107
10268
  isTypeMint,
10108
10269
  isTypeScript,
10270
+ isTypeUpgrade,
10271
+ isTypeUpload,
10109
10272
  normalizeJSON,
10110
10273
  outputify,
10111
10274
  processGqlReceipt,