@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2037-20240411163513

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +563 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +565 -825
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +400 -659
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +1 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -6
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +30 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1047 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +543 -800
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +394 -651
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToCoinQuantities: () => addAmountToCoinQuantities,
98
+ addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,9 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
109
107
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
108
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
110
  calculateTransactionFee: () => calculateTransactionFee,
112
111
  coinQuantityfy: () => coinQuantityfy,
113
112
  deferPromise: () => deferPromise,
@@ -188,9 +187,8 @@ var import_address4 = require("@fuel-ts/address");
188
187
  var import_configs12 = require("@fuel-ts/address/configs");
189
188
  var import_errors16 = require("@fuel-ts/errors");
190
189
  var import_interfaces = require("@fuel-ts/interfaces");
191
- var import_math19 = require("@fuel-ts/math");
192
- var import_utils27 = require("@fuel-ts/utils");
193
- var import_ramda4 = require("ramda");
190
+ var import_math18 = require("@fuel-ts/math");
191
+ var import_utils28 = require("@fuel-ts/utils");
194
192
 
195
193
  // src/providers/coin-quantity.ts
196
194
  var import_configs = require("@fuel-ts/address/configs");
@@ -199,24 +197,24 @@ var import_utils = require("@fuel-ts/utils");
199
197
  var coinQuantityfy = (coinQuantityLike) => {
200
198
  let assetId;
201
199
  let amount;
202
- let max;
200
+ let max2;
203
201
  if (Array.isArray(coinQuantityLike)) {
204
202
  amount = coinQuantityLike[0];
205
203
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
- max = coinQuantityLike[2] ?? void 0;
204
+ max2 = coinQuantityLike[2] ?? void 0;
207
205
  } else {
208
206
  amount = coinQuantityLike.amount;
209
207
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
210
- max = coinQuantityLike.max ?? void 0;
208
+ max2 = coinQuantityLike.max ?? void 0;
211
209
  }
212
210
  const bnAmount = (0, import_math.bn)(amount);
213
211
  return {
214
212
  assetId: (0, import_utils.hexlify)(assetId),
215
213
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
216
- max: max ? (0, import_math.bn)(max) : void 0
214
+ max: max2 ? (0, import_math.bn)(max2) : void 0
217
215
  };
218
216
  };
219
- var addAmountToCoinQuantities = (params) => {
217
+ var addAmountToAsset = (params) => {
220
218
  const { amount, assetId } = params;
221
219
  const coinQuantities = [...params.coinQuantities];
222
220
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -231,12 +229,12 @@ var addAmountToCoinQuantities = (params) => {
231
229
  // src/providers/provider.ts
232
230
  var import_address3 = require("@fuel-ts/address");
233
231
  var import_errors14 = require("@fuel-ts/errors");
234
- var import_math16 = require("@fuel-ts/math");
235
- var import_transactions19 = require("@fuel-ts/transactions");
236
- var import_utils22 = require("@fuel-ts/utils");
232
+ var import_math15 = require("@fuel-ts/math");
233
+ var import_transactions18 = require("@fuel-ts/transactions");
234
+ var import_utils23 = require("@fuel-ts/utils");
237
235
  var import_versions = require("@fuel-ts/versions");
238
- var import_utils23 = require("@noble/curves/abstract/utils");
239
- var import_ethers2 = require("ethers");
236
+ var import_utils24 = require("@noble/curves/abstract/utils");
237
+ var import_ethers = require("ethers");
240
238
  var import_graphql_request = require("graphql-request");
241
239
  var import_ramda3 = require("ramda");
242
240
 
@@ -244,10 +242,14 @@ var import_ramda3 = require("ramda");
244
242
  var import_graphql_tag = __toESM(require("graphql-tag"));
245
243
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
246
244
  fragment receiptFragment on Receipt {
247
- id
245
+ contract {
246
+ id
247
+ }
248
248
  pc
249
249
  is
250
- to
250
+ to {
251
+ id
252
+ }
251
253
  toAddress
252
254
  amount
253
255
  assetId
@@ -285,16 +287,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
287
  id
286
288
  }
287
289
  time
288
- receipts {
289
- ...receiptFragment
290
- }
291
290
  programState {
292
291
  returnType
293
292
  data
294
293
  }
295
- receipts {
296
- ...receiptFragment
297
- }
298
294
  }
299
295
  ... on FailureStatus {
300
296
  block {
@@ -302,24 +298,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
302
298
  }
303
299
  time
304
300
  reason
305
- receipts {
306
- ...receiptFragment
307
- }
308
301
  }
309
302
  ... on SqueezedOutStatus {
310
303
  reason
311
304
  }
312
305
  }
313
- ${ReceiptFragmentFragmentDoc}`;
306
+ `;
314
307
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
315
308
  fragment transactionFragment on Transaction {
316
309
  id
317
310
  rawPayload
311
+ gasPrice
312
+ receipts {
313
+ ...receiptFragment
314
+ }
318
315
  status {
319
316
  ...transactionStatusFragment
320
317
  }
321
318
  }
322
- ${TransactionStatusFragmentFragmentDoc}`;
319
+ ${ReceiptFragmentFragmentDoc}
320
+ ${TransactionStatusFragmentFragmentDoc}`;
323
321
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
324
322
  fragment inputEstimatePredicatesFragment on Input {
325
323
  ... on InputCoin {
@@ -337,46 +335,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
337
335
  }
338
336
  }
339
337
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
340
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
341
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
342
- reason
343
- programState {
344
- returnType
345
- data
346
- }
347
- }
348
- `;
349
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
350
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
351
- programState {
352
- returnType
353
- data
354
- }
355
- }
356
- `;
357
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
358
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
359
- ... on DryRunFailureStatus {
360
- ...dryRunFailureStatusFragment
361
- }
362
- ... on DryRunSuccessStatus {
363
- ...dryRunSuccessStatusFragment
364
- }
365
- }
366
- ${DryRunFailureStatusFragmentFragmentDoc}
367
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
368
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
369
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
370
- id
371
- status {
372
- ...dryRunTransactionStatusFragment
373
- }
374
- receipts {
375
- ...receiptFragment
376
- }
377
- }
378
- ${DryRunTransactionStatusFragmentFragmentDoc}
379
- ${ReceiptFragmentFragmentDoc}`;
380
338
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
381
339
  fragment coinFragment on Coin {
382
340
  __typename
@@ -384,6 +342,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
384
342
  owner
385
343
  amount
386
344
  assetId
345
+ maturity
387
346
  blockCreated
388
347
  txCreatedIdx
389
348
  }
@@ -422,32 +381,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
422
381
  messageBlockHeader {
423
382
  id
424
383
  daHeight
425
- consensusParametersVersion
426
- stateTransitionBytecodeVersion
427
384
  transactionsCount
428
- messageReceiptCount
429
385
  transactionsRoot
430
- messageOutboxRoot
431
- eventInboxRoot
432
386
  height
433
387
  prevRoot
434
388
  time
435
389
  applicationHash
390
+ messageReceiptRoot
391
+ messageReceiptCount
436
392
  }
437
393
  commitBlockHeader {
438
394
  id
439
395
  daHeight
440
- consensusParametersVersion
441
- stateTransitionBytecodeVersion
442
396
  transactionsCount
443
- messageReceiptCount
444
397
  transactionsRoot
445
- messageOutboxRoot
446
- eventInboxRoot
447
398
  height
448
399
  prevRoot
449
400
  time
450
401
  applicationHash
402
+ messageReceiptRoot
403
+ messageReceiptCount
451
404
  }
452
405
  sender
453
406
  recipient
@@ -466,8 +419,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
466
419
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
467
420
  fragment blockFragment on Block {
468
421
  id
469
- height
470
422
  header {
423
+ height
471
424
  time
472
425
  }
473
426
  transactions {
@@ -525,11 +478,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
525
478
  `;
526
479
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
527
480
  fragment GasCostsFragment on GasCosts {
528
- version {
529
- ... on Version {
530
- value
531
- }
532
- }
533
481
  add
534
482
  addi
535
483
  aloc
@@ -542,6 +490,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
542
490
  cb
543
491
  cfei
544
492
  cfsi
493
+ croo
545
494
  div
546
495
  divi
547
496
  ecr1
@@ -624,9 +573,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
624
573
  ccp {
625
574
  ...DependentCostFragment
626
575
  }
627
- croo {
628
- ...DependentCostFragment
629
- }
630
576
  csiz {
631
577
  ...DependentCostFragment
632
578
  }
@@ -686,11 +632,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
686
632
  ${DependentCostFragmentFragmentDoc}`;
687
633
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
688
634
  fragment consensusParametersFragment on ConsensusParameters {
689
- version {
690
- ... on Version {
691
- value
692
- }
693
- }
694
635
  txParams {
695
636
  ...TxParametersFragment
696
637
  }
@@ -750,9 +691,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
750
691
  fragment nodeInfoFragment on NodeInfo {
751
692
  utxoValidation
752
693
  vmBacktrace
694
+ minGasPrice
753
695
  maxTx
754
696
  maxDepth
755
697
  nodeVersion
698
+ peers {
699
+ id
700
+ addresses
701
+ clientVersion
702
+ blockHeight
703
+ lastHeartbeatMs
704
+ appScore
705
+ }
756
706
  }
757
707
  `;
758
708
  var GetVersionDocument = import_graphql_tag.default`
@@ -787,9 +737,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
787
737
  query getTransactionWithReceipts($transactionId: TransactionId!) {
788
738
  transaction(id: $transactionId) {
789
739
  ...transactionFragment
740
+ receipts {
741
+ ...receiptFragment
742
+ }
790
743
  }
791
744
  }
792
- ${TransactionFragmentFragmentDoc}`;
745
+ ${TransactionFragmentFragmentDoc}
746
+ ${ReceiptFragmentFragmentDoc}`;
793
747
  var GetTransactionsDocument = import_graphql_tag.default`
794
748
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
795
749
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -917,20 +871,6 @@ var GetBalanceDocument = import_graphql_tag.default`
917
871
  }
918
872
  }
919
873
  ${BalanceFragmentFragmentDoc}`;
920
- var GetLatestGasPriceDocument = import_graphql_tag.default`
921
- query getLatestGasPrice {
922
- latestGasPrice {
923
- gasPrice
924
- }
925
- }
926
- `;
927
- var EstimateGasPriceDocument = import_graphql_tag.default`
928
- query estimateGasPrice($blockHorizon: U32!) {
929
- estimateGasPrice(blockHorizon: $blockHorizon) {
930
- gasPrice
931
- }
932
- }
933
- `;
934
874
  var GetBalancesDocument = import_graphql_tag.default`
935
875
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
936
876
  balances(
@@ -985,12 +925,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
985
925
  }
986
926
  `;
987
927
  var DryRunDocument = import_graphql_tag.default`
988
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
989
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
990
- ...dryRunTransactionExecutionStatusFragment
928
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
+ ...receiptFragment
991
931
  }
992
932
  }
993
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
933
+ ${ReceiptFragmentFragmentDoc}`;
994
934
  var SubmitDocument = import_graphql_tag.default`
995
935
  mutation submit($encodedTransaction: HexString!) {
996
936
  submit(tx: $encodedTransaction) {
@@ -1073,12 +1013,6 @@ function getSdk(requester) {
1073
1013
  getBalance(variables, options) {
1074
1014
  return requester(GetBalanceDocument, variables, options);
1075
1015
  },
1076
- getLatestGasPrice(variables, options) {
1077
- return requester(GetLatestGasPriceDocument, variables, options);
1078
- },
1079
- estimateGasPrice(variables, options) {
1080
- return requester(EstimateGasPriceDocument, variables, options);
1081
- },
1082
1016
  getBalances(variables, options) {
1083
1017
  return requester(GetBalancesDocument, variables, options);
1084
1018
  },
@@ -1148,14 +1082,11 @@ var _FuelGraphqlSubscriber = class {
1148
1082
  let data;
1149
1083
  let errors;
1150
1084
  try {
1151
- const sanitizedText = text.replace(/\s/g, "");
1152
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1085
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1153
1086
  } catch (e) {
1154
1087
  throw new import_errors.FuelError(
1155
1088
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1156
- `Error while parsing stream data response: ${text}
1157
-
1158
- Thrown error: ${e}`
1089
+ `Error while parsing stream data response: ${text}`
1159
1090
  );
1160
1091
  }
1161
1092
  if (Array.isArray(errors)) {
@@ -1242,6 +1173,7 @@ var MemoryCache = class {
1242
1173
  };
1243
1174
 
1244
1175
  // src/providers/transaction-request/input.ts
1176
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1245
1177
  var import_configs2 = require("@fuel-ts/address/configs");
1246
1178
  var import_errors3 = require("@fuel-ts/errors");
1247
1179
  var import_math2 = require("@fuel-ts/math");
@@ -1255,8 +1187,8 @@ var inputify = (value) => {
1255
1187
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1256
1188
  return {
1257
1189
  type: import_transactions.InputType.Coin,
1258
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1259
- outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1190
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1191
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1260
1192
  owner: (0, import_utils3.hexlify)(value.owner),
1261
1193
  amount: (0, import_math2.bn)(value.amount),
1262
1194
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1265,9 +1197,10 @@ var inputify = (value) => {
1265
1197
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1266
1198
  },
1267
1199
  witnessIndex: value.witnessIndex,
1200
+ maturity: value.maturity ?? 0,
1268
1201
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1269
- predicateLength: (0, import_math2.bn)(predicate.length),
1270
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1202
+ predicateLength: predicate.length,
1203
+ predicateDataLength: predicateData.length,
1271
1204
  predicate: (0, import_utils3.hexlify)(predicate),
1272
1205
  predicateData: (0, import_utils3.hexlify)(predicateData)
1273
1206
  };
@@ -1298,8 +1231,8 @@ var inputify = (value) => {
1298
1231
  nonce: (0, import_utils3.hexlify)(value.nonce),
1299
1232
  witnessIndex: value.witnessIndex,
1300
1233
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1301
- predicateLength: (0, import_math2.bn)(predicate.length),
1302
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1234
+ predicateLength: predicate.length,
1235
+ predicateDataLength: predicateData.length,
1303
1236
  predicate: (0, import_utils3.hexlify)(predicate),
1304
1237
  predicateData: (0, import_utils3.hexlify)(predicateData),
1305
1238
  data: (0, import_utils3.hexlify)(data),
@@ -1373,12 +1306,13 @@ var outputify = (value) => {
1373
1306
  };
1374
1307
 
1375
1308
  // src/providers/transaction-request/transaction-request.ts
1309
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1376
1310
  var import_address = require("@fuel-ts/address");
1377
1311
  var import_configs7 = require("@fuel-ts/address/configs");
1312
+ var import_crypto = require("@fuel-ts/crypto");
1378
1313
  var import_math7 = require("@fuel-ts/math");
1379
1314
  var import_transactions6 = require("@fuel-ts/transactions");
1380
1315
  var import_utils9 = require("@fuel-ts/utils");
1381
- var import_ethers = require("ethers");
1382
1316
 
1383
1317
  // src/providers/resource.ts
1384
1318
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1417,8 +1351,8 @@ function assembleReceiptByType(receipt) {
1417
1351
  case "CALL" /* Call */: {
1418
1352
  const callReceipt = {
1419
1353
  type: import_transactions3.ReceiptType.Call,
1420
- from: hexOrZero(receipt.id || receipt.contractId),
1421
- to: hexOrZero(receipt?.to),
1354
+ from: hexOrZero(receipt.contract?.id),
1355
+ to: hexOrZero(receipt?.to?.id),
1422
1356
  amount: (0, import_math4.bn)(receipt.amount),
1423
1357
  assetId: hexOrZero(receipt.assetId),
1424
1358
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1432,7 +1366,7 @@ function assembleReceiptByType(receipt) {
1432
1366
  case "RETURN" /* Return */: {
1433
1367
  const returnReceipt = {
1434
1368
  type: import_transactions3.ReceiptType.Return,
1435
- id: hexOrZero(receipt.id || receipt.contractId),
1369
+ id: hexOrZero(receipt.contract?.id),
1436
1370
  val: (0, import_math4.bn)(receipt.val),
1437
1371
  pc: (0, import_math4.bn)(receipt.pc),
1438
1372
  is: (0, import_math4.bn)(receipt.is)
@@ -1442,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1442
1376
  case "RETURN_DATA" /* ReturnData */: {
1443
1377
  const returnDataReceipt = {
1444
1378
  type: import_transactions3.ReceiptType.ReturnData,
1445
- id: hexOrZero(receipt.id || receipt.contractId),
1379
+ id: hexOrZero(receipt.contract?.id),
1446
1380
  ptr: (0, import_math4.bn)(receipt.ptr),
1447
1381
  len: (0, import_math4.bn)(receipt.len),
1448
1382
  digest: hexOrZero(receipt.digest),
@@ -1454,7 +1388,7 @@ function assembleReceiptByType(receipt) {
1454
1388
  case "PANIC" /* Panic */: {
1455
1389
  const panicReceipt = {
1456
1390
  type: import_transactions3.ReceiptType.Panic,
1457
- id: hexOrZero(receipt.id),
1391
+ id: hexOrZero(receipt.contract?.id),
1458
1392
  reason: (0, import_math4.bn)(receipt.reason),
1459
1393
  pc: (0, import_math4.bn)(receipt.pc),
1460
1394
  is: (0, import_math4.bn)(receipt.is),
@@ -1465,7 +1399,7 @@ function assembleReceiptByType(receipt) {
1465
1399
  case "REVERT" /* Revert */: {
1466
1400
  const revertReceipt = {
1467
1401
  type: import_transactions3.ReceiptType.Revert,
1468
- id: hexOrZero(receipt.id || receipt.contractId),
1402
+ id: hexOrZero(receipt.contract?.id),
1469
1403
  val: (0, import_math4.bn)(receipt.ra),
1470
1404
  pc: (0, import_math4.bn)(receipt.pc),
1471
1405
  is: (0, import_math4.bn)(receipt.is)
@@ -1475,7 +1409,7 @@ function assembleReceiptByType(receipt) {
1475
1409
  case "LOG" /* Log */: {
1476
1410
  const logReceipt = {
1477
1411
  type: import_transactions3.ReceiptType.Log,
1478
- id: hexOrZero(receipt.id || receipt.contractId),
1412
+ id: hexOrZero(receipt.contract?.id),
1479
1413
  val0: (0, import_math4.bn)(receipt.ra),
1480
1414
  val1: (0, import_math4.bn)(receipt.rb),
1481
1415
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1488,7 +1422,7 @@ function assembleReceiptByType(receipt) {
1488
1422
  case "LOG_DATA" /* LogData */: {
1489
1423
  const logDataReceipt = {
1490
1424
  type: import_transactions3.ReceiptType.LogData,
1491
- id: hexOrZero(receipt.id || receipt.contractId),
1425
+ id: hexOrZero(receipt.contract?.id),
1492
1426
  val0: (0, import_math4.bn)(receipt.ra),
1493
1427
  val1: (0, import_math4.bn)(receipt.rb),
1494
1428
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1502,8 +1436,8 @@ function assembleReceiptByType(receipt) {
1502
1436
  case "TRANSFER" /* Transfer */: {
1503
1437
  const transferReceipt = {
1504
1438
  type: import_transactions3.ReceiptType.Transfer,
1505
- from: hexOrZero(receipt.id || receipt.contractId),
1506
- to: hexOrZero(receipt.toAddress || receipt?.to),
1439
+ from: hexOrZero(receipt.contract?.id),
1440
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1507
1441
  amount: (0, import_math4.bn)(receipt.amount),
1508
1442
  assetId: hexOrZero(receipt.assetId),
1509
1443
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1514,8 +1448,8 @@ function assembleReceiptByType(receipt) {
1514
1448
  case "TRANSFER_OUT" /* TransferOut */: {
1515
1449
  const transferOutReceipt = {
1516
1450
  type: import_transactions3.ReceiptType.TransferOut,
1517
- from: hexOrZero(receipt.id || receipt.contractId),
1518
- to: hexOrZero(receipt.toAddress || receipt.to),
1451
+ from: hexOrZero(receipt.contract?.id),
1452
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1519
1453
  amount: (0, import_math4.bn)(receipt.amount),
1520
1454
  assetId: hexOrZero(receipt.assetId),
1521
1455
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1558,7 +1492,7 @@ function assembleReceiptByType(receipt) {
1558
1492
  return receiptMessageOut;
1559
1493
  }
1560
1494
  case "MINT" /* Mint */: {
1561
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1495
+ const contractId = hexOrZero(receipt.contract?.id);
1562
1496
  const subId = hexOrZero(receipt.subId);
1563
1497
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1564
1498
  const mintReceipt = {
@@ -1573,7 +1507,7 @@ function assembleReceiptByType(receipt) {
1573
1507
  return mintReceipt;
1574
1508
  }
1575
1509
  case "BURN" /* Burn */: {
1576
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1510
+ const contractId = hexOrZero(receipt.contract?.id);
1577
1511
  const subId = hexOrZero(receipt.subId);
1578
1512
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1579
1513
  const burnReceipt = {
@@ -1658,6 +1592,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1658
1592
  var import_math5 = require("@fuel-ts/math");
1659
1593
  var import_transactions4 = require("@fuel-ts/transactions");
1660
1594
  var import_utils6 = require("@fuel-ts/utils");
1595
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1661
1596
  var getGasUsedFromReceipts = (receipts) => {
1662
1597
  const scriptResult = receipts.filter(
1663
1598
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1678,28 +1613,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1678
1613
  }
1679
1614
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1680
1615
  const witnessCache = [];
1681
- const chargeableInputs = inputs.filter((input) => {
1682
- const isCoinOrMessage = "owner" in input || "sender" in input;
1683
- if (isCoinOrMessage) {
1684
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1685
- return true;
1686
- }
1687
- if (!witnessCache.includes(input.witnessIndex)) {
1688
- witnessCache.push(input.witnessIndex);
1689
- return true;
1690
- }
1691
- }
1692
- return false;
1693
- });
1694
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1695
- const totalGas = chargeableInputs.reduce((total, input) => {
1616
+ const totalGas = inputs.reduce((total, input) => {
1696
1617
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1697
1618
  return total.add(
1698
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1619
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1699
1620
  );
1700
1621
  }
1701
- return total.add(gasCosts.ecr1);
1702
- }, (0, import_math5.bn)(0));
1622
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1623
+ witnessCache.push(input.witnessIndex);
1624
+ return total.add(gasCosts.ecr1);
1625
+ }
1626
+ return total;
1627
+ }, (0, import_math5.bn)());
1703
1628
  return totalGas;
1704
1629
  }
1705
1630
  function getMinGas(params) {
@@ -1711,20 +1636,12 @@ function getMinGas(params) {
1711
1636
  return minGas;
1712
1637
  }
1713
1638
  function getMaxGas(params) {
1714
- const {
1715
- gasPerByte,
1716
- witnessesLength,
1717
- witnessLimit,
1718
- minGas,
1719
- gasLimit = (0, import_math5.bn)(0),
1720
- maxGasPerTx
1721
- } = params;
1639
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1722
1640
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1723
1641
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1724
1642
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1725
1643
  }
1726
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1727
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1644
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1728
1645
  }
1729
1646
  function calculateMetadataGasForTxCreate({
1730
1647
  gasCosts,
@@ -1746,10 +1663,6 @@ function calculateMetadataGasForTxScript({
1746
1663
  }) {
1747
1664
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1748
1665
  }
1749
- var calculateGasFee = (params) => {
1750
- const { gas, gasPrice, priceFactor, tip } = params;
1751
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1752
- };
1753
1666
 
1754
1667
  // src/providers/utils/json.ts
1755
1668
  var import_utils7 = require("@fuel-ts/utils");
@@ -1898,7 +1811,7 @@ var witnessify = (value) => {
1898
1811
  // src/providers/transaction-request/transaction-request.ts
1899
1812
  var BaseTransactionRequest = class {
1900
1813
  /** Gas price for transaction */
1901
- tip;
1814
+ gasPrice;
1902
1815
  /** Block until which tx cannot be included */
1903
1816
  maturity;
1904
1817
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1917,7 +1830,7 @@ var BaseTransactionRequest = class {
1917
1830
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1918
1831
  */
1919
1832
  constructor({
1920
- tip,
1833
+ gasPrice,
1921
1834
  maturity,
1922
1835
  maxFee,
1923
1836
  witnessLimit,
@@ -1925,7 +1838,7 @@ var BaseTransactionRequest = class {
1925
1838
  outputs,
1926
1839
  witnesses
1927
1840
  } = {}) {
1928
- this.tip = (0, import_math7.bn)(tip);
1841
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1929
1842
  this.maturity = maturity ?? 0;
1930
1843
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1931
1844
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1936,9 +1849,9 @@ var BaseTransactionRequest = class {
1936
1849
  static getPolicyMeta(req) {
1937
1850
  let policyTypes = 0;
1938
1851
  const policies = [];
1939
- if (req.tip) {
1940
- policyTypes += import_transactions6.PolicyType.Tip;
1941
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1852
+ if (req.gasPrice) {
1853
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1854
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1942
1855
  }
1943
1856
  if (req.witnessLimit) {
1944
1857
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2126,9 +2039,9 @@ var BaseTransactionRequest = class {
2126
2039
  * @param predicateData - Predicate data bytes.
2127
2040
  */
2128
2041
  addCoinInput(coin) {
2129
- const { assetId, owner, amount } = coin;
2042
+ const { assetId, owner, amount, id, predicate } = coin;
2130
2043
  let witnessIndex;
2131
- if (coin.predicate) {
2044
+ if (predicate) {
2132
2045
  witnessIndex = 0;
2133
2046
  } else {
2134
2047
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2137,13 +2050,14 @@ var BaseTransactionRequest = class {
2137
2050
  }
2138
2051
  }
2139
2052
  const input = {
2140
- ...coin,
2053
+ id,
2141
2054
  type: import_transactions6.InputType.Coin,
2142
2055
  owner: owner.toB256(),
2143
2056
  amount,
2144
2057
  assetId,
2145
2058
  txPointer: "0x00000000000000000000000000000000",
2146
- witnessIndex
2059
+ witnessIndex,
2060
+ predicate
2147
2061
  };
2148
2062
  this.pushInput(input);
2149
2063
  this.addChangeOutput(owner, assetId);
@@ -2157,10 +2071,10 @@ var BaseTransactionRequest = class {
2157
2071
  * @param predicateData - Predicate data bytes.
2158
2072
  */
2159
2073
  addMessageInput(message) {
2160
- const { recipient, sender, amount } = message;
2074
+ const { recipient, sender, amount, predicate, nonce } = message;
2161
2075
  const assetId = import_configs7.BaseAssetId;
2162
2076
  let witnessIndex;
2163
- if (message.predicate) {
2077
+ if (predicate) {
2164
2078
  witnessIndex = 0;
2165
2079
  } else {
2166
2080
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2169,12 +2083,13 @@ var BaseTransactionRequest = class {
2169
2083
  }
2170
2084
  }
2171
2085
  const input = {
2172
- ...message,
2086
+ nonce,
2173
2087
  type: import_transactions6.InputType.Message,
2174
2088
  sender: sender.toB256(),
2175
2089
  recipient: recipient.toB256(),
2176
2090
  amount,
2177
- witnessIndex
2091
+ witnessIndex,
2092
+ predicate
2178
2093
  };
2179
2094
  this.pushInput(input);
2180
2095
  this.addChangeOutput(recipient, assetId);
@@ -2284,7 +2199,7 @@ var BaseTransactionRequest = class {
2284
2199
  }
2285
2200
  calculateMaxGas(chainInfo, minGas) {
2286
2201
  const { consensusParameters } = chainInfo;
2287
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2202
+ const { gasPerByte } = consensusParameters;
2288
2203
  const witnessesLength = this.toTransaction().witnesses.reduce(
2289
2204
  (acc, wit) => acc + wit.dataLength,
2290
2205
  0
@@ -2293,8 +2208,7 @@ var BaseTransactionRequest = class {
2293
2208
  gasPerByte,
2294
2209
  minGas,
2295
2210
  witnessesLength,
2296
- witnessLimit: this.witnessLimit,
2297
- maxGasPerTx
2211
+ witnessLimit: this.witnessLimit
2298
2212
  });
2299
2213
  }
2300
2214
  /**
@@ -2312,20 +2226,17 @@ var BaseTransactionRequest = class {
2312
2226
  });
2313
2227
  const updateAssetInput = (assetId, quantity) => {
2314
2228
  const assetInput = findAssetInput(assetId);
2315
- let usedQuantity = quantity;
2316
- if (assetId === import_configs7.BaseAssetId) {
2317
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2318
- }
2319
2229
  if (assetInput && "assetId" in assetInput) {
2320
- assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2321
- assetInput.amount = usedQuantity;
2230
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2231
+ assetInput.amount = quantity;
2322
2232
  } else {
2323
2233
  this.addResources([
2324
2234
  {
2325
- id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2326
- amount: usedQuantity,
2235
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2236
+ amount: quantity,
2327
2237
  assetId,
2328
2238
  owner: resourcesOwner || import_address.Address.fromRandom(),
2239
+ maturity: 0,
2329
2240
  blockCreated: (0, import_math7.bn)(1),
2330
2241
  txCreatedIdx: (0, import_math7.bn)(1)
2331
2242
  }
@@ -2357,7 +2268,7 @@ var BaseTransactionRequest = class {
2357
2268
  toJSON() {
2358
2269
  return normalizeJSON(this);
2359
2270
  }
2360
- updatePredicateGasUsed(inputs) {
2271
+ updatePredicateInputs(inputs) {
2361
2272
  this.inputs.forEach((i) => {
2362
2273
  let correspondingInput;
2363
2274
  switch (i.type) {
@@ -2379,15 +2290,6 @@ var BaseTransactionRequest = class {
2379
2290
  }
2380
2291
  });
2381
2292
  }
2382
- shiftPredicateData() {
2383
- this.inputs.forEach((input) => {
2384
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2385
- input.predicateData = input.paddPredicateData(
2386
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2387
- );
2388
- }
2389
- });
2390
- }
2391
2293
  };
2392
2294
 
2393
2295
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2534,8 +2436,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2534
2436
  return {
2535
2437
  type: import_transactions8.TransactionType.Create,
2536
2438
  ...baseTransaction,
2439
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2537
2440
  bytecodeWitnessIndex,
2538
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2441
+ storageSlotsCount: storageSlots.length,
2539
2442
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2540
2443
  storageSlots
2541
2444
  };
@@ -2584,7 +2487,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2584
2487
  };
2585
2488
 
2586
2489
  // src/providers/transaction-request/script-transaction-request.ts
2587
- var import_abi_coder = require("@fuel-ts/abi-coder");
2490
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2588
2491
  var import_address2 = require("@fuel-ts/address");
2589
2492
  var import_configs10 = require("@fuel-ts/address/configs");
2590
2493
  var import_math10 = require("@fuel-ts/math");
@@ -2658,8 +2561,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2658
2561
  type: import_transactions9.TransactionType.Script,
2659
2562
  scriptGasLimit: this.gasLimit,
2660
2563
  ...super.getBaseTransaction(),
2661
- scriptLength: (0, import_math10.bn)(script.length),
2662
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2564
+ scriptLength: script.length,
2565
+ scriptDataLength: scriptData.length,
2663
2566
  receiptsRoot: import_configs10.ZeroBytes32,
2664
2567
  script: (0, import_utils15.hexlify)(script),
2665
2568
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2723,7 +2626,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2723
2626
  }
2724
2627
  calculateMaxGas(chainInfo, minGas) {
2725
2628
  const { consensusParameters } = chainInfo;
2726
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2629
+ const { gasPerByte } = consensusParameters;
2727
2630
  const witnessesLength = this.toTransaction().witnesses.reduce(
2728
2631
  (acc, wit) => acc + wit.dataLength,
2729
2632
  0
@@ -2733,8 +2636,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2733
2636
  minGas,
2734
2637
  witnessesLength,
2735
2638
  witnessLimit: this.witnessLimit,
2736
- gasLimit: this.gasLimit,
2737
- maxGasPerTx
2639
+ gasLimit: this.gasLimit
2738
2640
  });
2739
2641
  }
2740
2642
  /**
@@ -2777,7 +2679,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2777
2679
  * @returns The current instance of the `ScriptTransactionRequest`.
2778
2680
  */
2779
2681
  setData(abi, args) {
2780
- const abiInterface = new import_abi_coder.Interface(abi);
2682
+ const abiInterface = new import_abi_coder3.Interface(abi);
2781
2683
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2782
2684
  return this;
2783
2685
  }
@@ -2809,32 +2711,15 @@ var transactionRequestify = (obj) => {
2809
2711
  }
2810
2712
  }
2811
2713
  };
2812
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2813
- (acc, input) => {
2814
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2815
- acc.utxos.push(input.id);
2816
- }
2817
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2818
- acc.messages.push(input.nonce);
2819
- }
2820
- return acc;
2821
- },
2822
- {
2823
- utxos: [],
2824
- messages: []
2825
- }
2826
- );
2827
2714
 
2828
2715
  // src/providers/transaction-response/transaction-response.ts
2829
2716
  var import_errors13 = require("@fuel-ts/errors");
2830
- var import_math15 = require("@fuel-ts/math");
2831
- var import_transactions18 = require("@fuel-ts/transactions");
2832
- var import_utils20 = require("@fuel-ts/utils");
2717
+ var import_math14 = require("@fuel-ts/math");
2718
+ var import_transactions17 = require("@fuel-ts/transactions");
2719
+ var import_utils21 = require("@fuel-ts/utils");
2833
2720
 
2834
2721
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2835
- var import_math14 = require("@fuel-ts/math");
2836
- var import_transactions16 = require("@fuel-ts/transactions");
2837
- var import_utils18 = require("@fuel-ts/utils");
2722
+ var import_utils19 = require("@fuel-ts/utils");
2838
2723
 
2839
2724
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2840
2725
  var import_math11 = require("@fuel-ts/math");
@@ -2842,10 +2727,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2842
2727
  var import_utils16 = require("@fuel-ts/utils");
2843
2728
  var calculateTransactionFee = (params) => {
2844
2729
  const {
2845
- gasPrice,
2730
+ gasUsed,
2846
2731
  rawPayload,
2847
- tip,
2848
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2732
+ consensusParameters: { gasCosts, feeParams }
2849
2733
  } = params;
2850
2734
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2851
2735
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2855,7 +2739,8 @@ var calculateTransactionFee = (params) => {
2855
2739
  return {
2856
2740
  fee: (0, import_math11.bn)(0),
2857
2741
  minFee: (0, import_math11.bn)(0),
2858
- maxFee: (0, import_math11.bn)(0)
2742
+ maxFee: (0, import_math11.bn)(0),
2743
+ feeFromGasUsed: (0, import_math11.bn)(0)
2859
2744
  };
2860
2745
  }
2861
2746
  const { type, witnesses, inputs, policies } = transaction;
@@ -2887,6 +2772,7 @@ var calculateTransactionFee = (params) => {
2887
2772
  metadataGas,
2888
2773
  txBytesSize: transactionBytes.length
2889
2774
  });
2775
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2890
2776
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2891
2777
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2892
2778
  const maxGas = getMaxGas({
@@ -2894,25 +2780,17 @@ var calculateTransactionFee = (params) => {
2894
2780
  minGas,
2895
2781
  witnessesLength,
2896
2782
  gasLimit,
2897
- witnessLimit,
2898
- maxGasPerTx
2899
- });
2900
- const minFee = calculateGasFee({
2901
- gasPrice,
2902
- gas: minGas,
2903
- priceFactor: gasPriceFactor,
2904
- tip
2905
- });
2906
- const maxFee = calculateGasFee({
2907
- gasPrice,
2908
- gas: maxGas,
2909
- priceFactor: gasPriceFactor,
2910
- tip
2783
+ witnessLimit
2911
2784
  });
2785
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2786
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2787
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2788
+ const fee = minFee.add(feeFromGasUsed);
2912
2789
  return {
2790
+ fee,
2913
2791
  minFee,
2914
2792
  maxFee,
2915
- fee: maxFee
2793
+ feeFromGasUsed
2916
2794
  };
2917
2795
  };
2918
2796
 
@@ -2923,17 +2801,17 @@ var import_math13 = require("@fuel-ts/math");
2923
2801
  var import_transactions14 = require("@fuel-ts/transactions");
2924
2802
 
2925
2803
  // src/providers/transaction-summary/call.ts
2926
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2804
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2927
2805
  var import_math12 = require("@fuel-ts/math");
2928
2806
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2929
- const abiInterface = new import_abi_coder2.Interface(abi);
2807
+ const abiInterface = new import_abi_coder4.Interface(abi);
2930
2808
  const callFunctionSelector = receipt.param1.toHex(8);
2931
2809
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2932
2810
  const inputs = functionFragment.jsonFn.inputs;
2933
2811
  let encodedArgs;
2934
2812
  if (functionFragment.isInputDataPointer) {
2935
2813
  if (rawPayload) {
2936
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2814
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2937
2815
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2938
2816
  }
2939
2817
  } else {
@@ -3526,12 +3404,10 @@ function assembleTransactionSummary(params) {
3526
3404
  gqlTransactionStatus,
3527
3405
  abiMap = {},
3528
3406
  maxInputs,
3529
- gasCosts,
3530
- maxGasPerTx,
3531
- gasPrice
3407
+ gasCosts
3532
3408
  } = params;
3533
3409
  const gasUsed = getGasUsedFromReceipts(receipts);
3534
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3410
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3535
3411
  const operations = getOperations({
3536
3412
  transactionType: transaction.type,
3537
3413
  inputs: transaction.inputs || [],
@@ -3542,14 +3418,11 @@ function assembleTransactionSummary(params) {
3542
3418
  maxInputs
3543
3419
  });
3544
3420
  const typeName = getTransactionTypeName(transaction.type);
3545
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3546
3421
  const { fee } = calculateTransactionFee({
3547
- gasPrice,
3422
+ gasUsed,
3548
3423
  rawPayload,
3549
- tip,
3550
3424
  consensusParameters: {
3551
3425
  gasCosts,
3552
- maxGasPerTx,
3553
3426
  feeParams: {
3554
3427
  gasPerByte,
3555
3428
  gasPriceFactor
@@ -3561,7 +3434,7 @@ function assembleTransactionSummary(params) {
3561
3434
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3562
3435
  let date;
3563
3436
  if (time) {
3564
- date = import_utils18.DateTime.fromTai64(time);
3437
+ date = import_utils19.DateTime.fromTai64(time);
3565
3438
  }
3566
3439
  const transactionSummary = {
3567
3440
  id,
@@ -3588,13 +3461,13 @@ function assembleTransactionSummary(params) {
3588
3461
  }
3589
3462
 
3590
3463
  // src/providers/transaction-response/getDecodedLogs.ts
3591
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3592
- var import_transactions17 = require("@fuel-ts/transactions");
3464
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3465
+ var import_transactions16 = require("@fuel-ts/transactions");
3593
3466
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3594
3467
  return receipts.reduce((logs, receipt) => {
3595
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3596
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3597
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3468
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3469
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3470
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3598
3471
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3599
3472
  logs.push(decodedLog);
3600
3473
  }
@@ -3609,7 +3482,7 @@ var TransactionResponse = class {
3609
3482
  /** Current provider */
3610
3483
  provider;
3611
3484
  /** Gas used on the transaction */
3612
- gasUsed = (0, import_math15.bn)(0);
3485
+ gasUsed = (0, import_math14.bn)(0);
3613
3486
  /** The graphql Transaction with receipts object. */
3614
3487
  gqlTransaction;
3615
3488
  abis;
@@ -3667,8 +3540,8 @@ var TransactionResponse = class {
3667
3540
  * @returns The decoded transaction.
3668
3541
  */
3669
3542
  decodeTransaction(transactionWithReceipts) {
3670
- return new import_transactions18.TransactionCoder().decode(
3671
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3543
+ return new import_transactions17.TransactionCoder().decode(
3544
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3672
3545
  0
3673
3546
  )?.[0];
3674
3547
  }
@@ -3687,27 +3560,20 @@ var TransactionResponse = class {
3687
3560
  const decodedTransaction = this.decodeTransaction(
3688
3561
  transaction
3689
3562
  );
3690
- let txReceipts = [];
3691
- if (transaction?.status && "receipts" in transaction.status) {
3692
- txReceipts = transaction.status.receipts;
3693
- }
3694
- const receipts = txReceipts.map(processGqlReceipt) || [];
3695
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3696
- const gasPrice = await this.provider.getLatestGasPrice();
3563
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3564
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3697
3565
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3698
3566
  const transactionSummary = assembleTransactionSummary({
3699
3567
  id: this.id,
3700
3568
  receipts,
3701
3569
  transaction: decodedTransaction,
3702
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3570
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3703
3571
  gqlTransactionStatus: transaction.status,
3704
3572
  gasPerByte,
3705
3573
  gasPriceFactor,
3706
3574
  abiMap: contractsAbiMap,
3707
3575
  maxInputs,
3708
- gasCosts,
3709
- maxGasPerTx,
3710
- gasPrice
3576
+ gasCosts
3711
3577
  });
3712
3578
  return transactionSummary;
3713
3579
  }
@@ -3834,29 +3700,29 @@ var processGqlChain = (chain) => {
3834
3700
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3835
3701
  return {
3836
3702
  name,
3837
- baseChainHeight: (0, import_math16.bn)(daHeight),
3703
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3838
3704
  consensusParameters: {
3839
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3840
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3841
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3842
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3843
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3844
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3845
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3846
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3847
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3848
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3849
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3850
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3851
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3852
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3853
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3705
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3706
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3707
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3708
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3709
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3710
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3711
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3712
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3713
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3714
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3715
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3716
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3717
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3718
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3719
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3854
3720
  gasCosts
3855
3721
  },
3856
3722
  gasCosts,
3857
3723
  latestBlock: {
3858
3724
  id: latestBlock.id,
3859
- height: (0, import_math16.bn)(latestBlock.height),
3725
+ height: (0, import_math15.bn)(latestBlock.header.height),
3860
3726
  time: latestBlock.header.time,
3861
3727
  transactions: latestBlock.transactions.map((i) => ({
3862
3728
  id: i.id
@@ -3950,8 +3816,10 @@ var _Provider = class {
3950
3816
  * Returns some helpful parameters related to gas fees.
3951
3817
  */
3952
3818
  getGasConfig() {
3819
+ const { minGasPrice } = this.getNode();
3953
3820
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3954
3821
  return {
3822
+ minGasPrice,
3955
3823
  maxGasPerTx,
3956
3824
  maxGasPerPredicate,
3957
3825
  gasPriceFactor,
@@ -4039,7 +3907,7 @@ var _Provider = class {
4039
3907
  name,
4040
3908
  consensusParameters: { chainId }
4041
3909
  } = await this.getChain();
4042
- const network = new import_ethers2.Network(name, chainId.toNumber());
3910
+ const network = new import_ethers.Network(name, chainId.toNumber());
4043
3911
  return Promise.resolve(network);
4044
3912
  }
4045
3913
  /**
@@ -4049,7 +3917,7 @@ var _Provider = class {
4049
3917
  */
4050
3918
  async getBlockNumber() {
4051
3919
  const { chain } = await this.operations.getChain();
4052
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3920
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4053
3921
  }
4054
3922
  /**
4055
3923
  * Returns the chain information.
@@ -4059,11 +3927,13 @@ var _Provider = class {
4059
3927
  async fetchNode() {
4060
3928
  const { nodeInfo } = await this.operations.getNodeInfo();
4061
3929
  const processedNodeInfo = {
4062
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4063
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3930
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3931
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3932
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4064
3933
  nodeVersion: nodeInfo.nodeVersion,
4065
3934
  utxoValidation: nodeInfo.utxoValidation,
4066
- vmBacktrace: nodeInfo.vmBacktrace
3935
+ vmBacktrace: nodeInfo.vmBacktrace,
3936
+ peers: nodeInfo.peers
4067
3937
  };
4068
3938
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4069
3939
  return processedNodeInfo;
@@ -4105,9 +3975,9 @@ var _Provider = class {
4105
3975
  if (estimateTxDependencies) {
4106
3976
  await this.estimateTxDependencies(transactionRequest);
4107
3977
  }
4108
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3978
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4109
3979
  let abis;
4110
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3980
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4111
3981
  abis = transactionRequest.abis;
4112
3982
  }
4113
3983
  if (awaitExecution) {
@@ -4148,14 +4018,15 @@ var _Provider = class {
4148
4018
  if (estimateTxDependencies) {
4149
4019
  return this.estimateTxDependencies(transactionRequest);
4150
4020
  }
4151
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4152
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4153
- encodedTransactions: encodedTransaction,
4021
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4022
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4023
+ encodedTransaction,
4154
4024
  utxoValidation: utxoValidation || false
4155
4025
  });
4156
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4157
- const receipts = rawReceipts.map(processGqlReceipt);
4158
- return { receipts, dryrunStatus: status };
4026
+ const receipts = gqlReceipts.map(processGqlReceipt);
4027
+ return {
4028
+ receipts
4029
+ };
4159
4030
  }
4160
4031
  /**
4161
4032
  * Verifies whether enough gas is available to complete transaction.
@@ -4166,13 +4037,13 @@ var _Provider = class {
4166
4037
  async estimatePredicates(transactionRequest) {
4167
4038
  const shouldEstimatePredicates = Boolean(
4168
4039
  transactionRequest.inputs.find(
4169
- (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()
4040
+ (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
4170
4041
  )
4171
4042
  );
4172
4043
  if (!shouldEstimatePredicates) {
4173
4044
  return transactionRequest;
4174
4045
  }
4175
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4046
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4176
4047
  const response = await this.operations.estimatePredicates({
4177
4048
  encodedTransaction
4178
4049
  });
@@ -4181,7 +4052,7 @@ var _Provider = class {
4181
4052
  } = response;
4182
4053
  if (inputs) {
4183
4054
  inputs.forEach((input, index) => {
4184
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4055
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4185
4056
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4186
4057
  }
4187
4058
  });
@@ -4194,31 +4065,31 @@ var _Provider = class {
4194
4065
  * If there are missing variable outputs,
4195
4066
  * `addVariableOutputs` is called on the transaction.
4196
4067
  *
4068
+ * @privateRemarks
4069
+ * TODO: Investigate support for missing contract IDs
4070
+ * TODO: Add support for missing output messages
4197
4071
  *
4198
4072
  * @param transactionRequest - The transaction request object.
4199
4073
  * @returns A promise.
4200
4074
  */
4201
4075
  async estimateTxDependencies(transactionRequest) {
4202
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4076
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4203
4077
  return {
4204
4078
  receipts: [],
4205
4079
  outputVariables: 0,
4206
4080
  missingContractIds: []
4207
4081
  };
4208
4082
  }
4083
+ await this.estimatePredicates(transactionRequest);
4209
4084
  let receipts = [];
4210
4085
  const missingContractIds = [];
4211
4086
  let outputVariables = 0;
4212
- let dryrunStatus;
4213
4087
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4214
- const {
4215
- dryRun: [{ receipts: rawReceipts, status }]
4216
- } = await this.operations.dryRun({
4217
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4088
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4089
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4218
4090
  utxoValidation: false
4219
4091
  });
4220
- receipts = rawReceipts.map(processGqlReceipt);
4221
- dryrunStatus = status;
4092
+ receipts = gqlReceipts.map(processGqlReceipt);
4222
4093
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4223
4094
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4224
4095
  if (hasMissingOutputs) {
@@ -4228,11 +4099,6 @@ var _Provider = class {
4228
4099
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4229
4100
  missingContractIds.push(contractId);
4230
4101
  });
4231
- const { maxFee } = await this.estimateTxGasAndFee({
4232
- transactionRequest,
4233
- optimizeGas: false
4234
- });
4235
- transactionRequest.maxFee = maxFee;
4236
4102
  } else {
4237
4103
  break;
4238
4104
  }
@@ -4240,133 +4106,37 @@ var _Provider = class {
4240
4106
  return {
4241
4107
  receipts,
4242
4108
  outputVariables,
4243
- missingContractIds,
4244
- dryrunStatus
4109
+ missingContractIds
4245
4110
  };
4246
4111
  }
4247
4112
  /**
4248
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4249
- *
4250
- * Transactions are dry run in batches. After each dry run, transactions requiring
4251
- * further modifications are identified. The method iteratively updates these transactions
4252
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4253
- *
4254
- * @param transactionRequests - Array of transaction request objects.
4255
- * @returns A promise that resolves to an array of results for each transaction.
4113
+ * Estimates the transaction gas and fee based on the provided transaction request.
4114
+ * @param transactionRequest - The transaction request object.
4115
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4256
4116
  */
4257
- async estimateMultipleTxDependencies(transactionRequests) {
4258
- const results = transactionRequests.map(() => ({
4259
- receipts: [],
4260
- outputVariables: 0,
4261
- missingContractIds: [],
4262
- dryrunStatus: void 0
4263
- }));
4264
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4265
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4266
- allRequests.forEach((req, index) => {
4267
- if (req.type === import_transactions19.TransactionType.Script) {
4268
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4269
- }
4270
- });
4271
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4272
- let attempt = 0;
4273
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4274
- const encodedTransactions = transactionsToProcess.map(
4275
- (index) => serializedTransactionsMap.get(index)
4276
- );
4277
- const dryRunResults = await this.operations.dryRun({
4278
- encodedTransactions,
4279
- utxoValidation: false
4280
- });
4281
- const nextRoundTransactions = [];
4282
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4283
- const currentResultIndex = transactionsToProcess[i];
4284
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4285
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4286
- results[currentResultIndex].dryrunStatus = status;
4287
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4288
- results[currentResultIndex].receipts
4289
- );
4290
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4291
- const requestToProcess = allRequests[currentResultIndex];
4292
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4293
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4294
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4295
- missingOutputContractIds.forEach(({ contractId }) => {
4296
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4297
- results[currentResultIndex].missingContractIds.push(contractId);
4298
- });
4299
- const { maxFee } = await this.estimateTxGasAndFee({
4300
- transactionRequest: requestToProcess,
4301
- optimizeGas: false
4302
- });
4303
- requestToProcess.maxFee = maxFee;
4304
- serializedTransactionsMap.set(
4305
- currentResultIndex,
4306
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4307
- );
4308
- nextRoundTransactions.push(currentResultIndex);
4309
- allRequests[currentResultIndex] = requestToProcess;
4310
- }
4311
- }
4312
- transactionsToProcess = nextRoundTransactions;
4313
- attempt += 1;
4314
- }
4315
- return results;
4316
- }
4317
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4318
- if (estimateTxDependencies) {
4319
- return this.estimateMultipleTxDependencies(transactionRequests);
4320
- }
4321
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4322
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4323
- encodedTransactions,
4324
- utxoValidation: utxoValidation || false
4325
- });
4326
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4327
- const receipts = rawReceipts.map(processGqlReceipt);
4328
- return { receipts, dryrunStatus: status };
4329
- });
4330
- return results;
4331
- }
4332
- async estimateTxGasAndFee(params) {
4333
- const { transactionRequest, optimizeGas = true } = params;
4334
- let { gasPrice } = params;
4117
+ estimateTxGasAndFee(params) {
4118
+ const { transactionRequest } = params;
4119
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4335
4120
  const chainInfo = this.getChain();
4336
- const { gasPriceFactor } = this.getGasConfig();
4121
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4122
+ transactionRequest.gasPrice = gasPrice;
4337
4123
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4338
- if (!gasPrice) {
4339
- gasPrice = await this.estimateGasPrice(10);
4340
- }
4341
- const minFee = calculateGasFee({
4342
- gasPrice: (0, import_math16.bn)(gasPrice),
4343
- gas: minGas,
4344
- priceFactor: gasPriceFactor,
4345
- tip: transactionRequest.tip
4346
- }).add(1);
4347
- let gasLimit = (0, import_math16.bn)(0);
4348
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4349
- gasLimit = transactionRequest.gasLimit;
4350
- if (!optimizeGas) {
4124
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4125
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4126
+ if (transactionRequest.gasLimit.eq(0)) {
4351
4127
  transactionRequest.gasLimit = minGas;
4352
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4353
- transactionRequest.gasLimit = gasLimit;
4128
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4129
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4130
+ );
4354
4131
  }
4355
4132
  }
4356
4133
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4357
- const maxFee = calculateGasFee({
4358
- gasPrice: (0, import_math16.bn)(gasPrice),
4359
- gas: maxGas,
4360
- priceFactor: gasPriceFactor,
4361
- tip: transactionRequest.tip
4362
- }).add(1);
4134
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4363
4135
  return {
4364
4136
  minGas,
4365
4137
  minFee,
4366
4138
  maxGas,
4367
- maxFee,
4368
- gasPrice,
4369
- gasLimit
4139
+ maxFee
4370
4140
  };
4371
4141
  }
4372
4142
  /**
@@ -4384,17 +4154,15 @@ var _Provider = class {
4384
4154
  if (estimateTxDependencies) {
4385
4155
  return this.estimateTxDependencies(transactionRequest);
4386
4156
  }
4387
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4388
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4389
- encodedTransactions,
4157
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4158
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4159
+ encodedTransaction,
4390
4160
  utxoValidation: true
4391
4161
  });
4392
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4393
- const { id, receipts, status } = dryRunStatus;
4394
- const processedReceipts = receipts.map(processGqlReceipt);
4395
- return { id, receipts: processedReceipts, status };
4396
- });
4397
- return { receipts: callResult[0].receipts };
4162
+ const receipts = gqlReceipts.map(processGqlReceipt);
4163
+ return {
4164
+ receipts
4165
+ };
4398
4166
  }
4399
4167
  /**
4400
4168
  * Returns a transaction cost to enable user
@@ -4411,80 +4179,77 @@ var _Provider = class {
4411
4179
  * @param tolerance - The tolerance to add on top of the gasUsed.
4412
4180
  * @returns A promise that resolves to the transaction cost object.
4413
4181
  */
4414
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4182
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4183
+ estimateTxDependencies = true,
4184
+ estimatePredicates = true,
4185
+ resourcesOwner,
4186
+ signatureCallback
4187
+ } = {}) {
4415
4188
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4416
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4189
+ const { minGasPrice } = this.getGasConfig();
4190
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4191
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4417
4192
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4418
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4193
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4419
4194
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4420
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4421
4195
  if (isScriptTransaction) {
4422
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4196
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4423
4197
  }
4424
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4425
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4198
+ if (estimatePredicates) {
4199
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4200
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4201
+ }
4202
+ await this.estimatePredicates(txRequestClone);
4426
4203
  }
4427
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4428
- let addedSignatures = 0;
4429
4204
  if (signatureCallback && isScriptTransaction) {
4430
- const lengthBefore = signedRequest.witnesses.length;
4431
- await signatureCallback(signedRequest);
4432
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4433
- }
4434
- await this.estimatePredicates(signedRequest);
4435
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4436
- transactionRequest: signedRequest,
4437
- optimizeGas: false
4205
+ await signatureCallback(txRequestClone);
4206
+ }
4207
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4208
+ transactionRequest: txRequestClone
4438
4209
  });
4439
- txRequestClone.maxFee = maxFee;
4440
4210
  let receipts = [];
4441
4211
  let missingContractIds = [];
4442
4212
  let outputVariables = 0;
4443
- let gasUsed = (0, import_math16.bn)(0);
4444
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4445
- if (isScriptTransaction) {
4446
- if (signatureCallback) {
4447
- await signatureCallback(txRequestClone);
4448
- }
4449
- txRequestClone.gasLimit = gasLimit;
4213
+ let gasUsed = (0, import_math15.bn)(0);
4214
+ if (isScriptTransaction && estimateTxDependencies) {
4215
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4450
4216
  const result = await this.estimateTxDependencies(txRequestClone);
4451
4217
  receipts = result.receipts;
4452
4218
  outputVariables = result.outputVariables;
4453
4219
  missingContractIds = result.missingContractIds;
4454
- gasUsed = getGasUsedFromReceipts(receipts);
4220
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4455
4221
  txRequestClone.gasLimit = gasUsed;
4456
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4457
- transactionRequest: txRequestClone,
4458
- gasPrice
4222
+ txRequestClone.gasPrice = setGasPrice;
4223
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4224
+ transactionRequest: txRequestClone
4459
4225
  }));
4460
4226
  }
4461
4227
  return {
4462
4228
  requiredQuantities: allQuantities,
4463
4229
  receipts,
4464
4230
  gasUsed,
4465
- gasPrice,
4231
+ minGasPrice,
4232
+ gasPrice: setGasPrice,
4466
4233
  minGas,
4467
4234
  maxGas,
4468
4235
  minFee,
4469
4236
  maxFee,
4237
+ estimatedInputs: txRequestClone.inputs,
4470
4238
  outputVariables,
4471
- missingContractIds,
4472
- addedSignatures,
4473
- estimatedPredicates: txRequestClone.inputs
4239
+ missingContractIds
4474
4240
  };
4475
4241
  }
4476
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4242
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4477
4243
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4478
4244
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4479
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4480
- quantitiesToContract
4481
- });
4245
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4482
4246
  transactionRequest.addResources(
4483
4247
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4484
4248
  );
4485
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4486
- quantitiesToContract
4487
- });
4249
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4250
+ transactionRequest,
4251
+ forwardingQuantities
4252
+ );
4488
4253
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4489
4254
  return {
4490
4255
  resources,
@@ -4500,16 +4265,17 @@ var _Provider = class {
4500
4265
  const result = await this.operations.getCoins({
4501
4266
  first: 10,
4502
4267
  ...paginationArgs,
4503
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4268
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4504
4269
  });
4505
4270
  const coins = result.coins.edges.map((edge) => edge.node);
4506
4271
  return coins.map((coin) => ({
4507
4272
  id: coin.utxoId,
4508
4273
  assetId: coin.assetId,
4509
- amount: (0, import_math16.bn)(coin.amount),
4274
+ amount: (0, import_math15.bn)(coin.amount),
4510
4275
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4511
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4512
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4276
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4277
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4278
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4513
4279
  }));
4514
4280
  }
4515
4281
  /**
@@ -4523,19 +4289,19 @@ var _Provider = class {
4523
4289
  async getResourcesToSpend(owner, quantities, excludedIds) {
4524
4290
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4525
4291
  const excludeInput = {
4526
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4527
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4292
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4293
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4528
4294
  };
4529
4295
  if (this.cache) {
4530
4296
  const uniqueUtxos = new Set(
4531
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4297
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4532
4298
  );
4533
4299
  excludeInput.utxos = Array.from(uniqueUtxos);
4534
4300
  }
4535
4301
  const coinsQuery = {
4536
4302
  owner: ownerAddress.toB256(),
4537
4303
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4538
- assetId: (0, import_utils22.hexlify)(assetId),
4304
+ assetId: (0, import_utils23.hexlify)(assetId),
4539
4305
  amount: amount.toString(10),
4540
4306
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4541
4307
  })),
@@ -4546,9 +4312,9 @@ var _Provider = class {
4546
4312
  switch (coin.__typename) {
4547
4313
  case "MessageCoin":
4548
4314
  return {
4549
- amount: (0, import_math16.bn)(coin.amount),
4315
+ amount: (0, import_math15.bn)(coin.amount),
4550
4316
  assetId: coin.assetId,
4551
- daHeight: (0, import_math16.bn)(coin.daHeight),
4317
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4552
4318
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4553
4319
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4554
4320
  nonce: coin.nonce
@@ -4556,11 +4322,12 @@ var _Provider = class {
4556
4322
  case "Coin":
4557
4323
  return {
4558
4324
  id: coin.utxoId,
4559
- amount: (0, import_math16.bn)(coin.amount),
4325
+ amount: (0, import_math15.bn)(coin.amount),
4560
4326
  assetId: coin.assetId,
4561
4327
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4562
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4563
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4328
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4329
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4330
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4564
4331
  };
4565
4332
  default:
4566
4333
  return null;
@@ -4577,13 +4344,13 @@ var _Provider = class {
4577
4344
  async getBlock(idOrHeight) {
4578
4345
  let variables;
4579
4346
  if (typeof idOrHeight === "number") {
4580
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4347
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4581
4348
  } else if (idOrHeight === "latest") {
4582
4349
  variables = { height: (await this.getBlockNumber()).toString(10) };
4583
4350
  } else if (idOrHeight.length === 66) {
4584
4351
  variables = { blockId: idOrHeight };
4585
4352
  } else {
4586
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4353
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4587
4354
  }
4588
4355
  const { block } = await this.operations.getBlock(variables);
4589
4356
  if (!block) {
@@ -4591,7 +4358,7 @@ var _Provider = class {
4591
4358
  }
4592
4359
  return {
4593
4360
  id: block.id,
4594
- height: (0, import_math16.bn)(block.height),
4361
+ height: (0, import_math15.bn)(block.header.height),
4595
4362
  time: block.header.time,
4596
4363
  transactionIds: block.transactions.map((tx) => tx.id)
4597
4364
  };
@@ -4606,7 +4373,7 @@ var _Provider = class {
4606
4373
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4607
4374
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4608
4375
  id: block.id,
4609
- height: (0, import_math16.bn)(block.height),
4376
+ height: (0, import_math15.bn)(block.header.height),
4610
4377
  time: block.header.time,
4611
4378
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4379
  }));
@@ -4621,7 +4388,7 @@ var _Provider = class {
4621
4388
  async getBlockWithTransactions(idOrHeight) {
4622
4389
  let variables;
4623
4390
  if (typeof idOrHeight === "number") {
4624
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4391
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4625
4392
  } else if (idOrHeight === "latest") {
4626
4393
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4627
4394
  } else {
@@ -4633,11 +4400,11 @@ var _Provider = class {
4633
4400
  }
4634
4401
  return {
4635
4402
  id: block.id,
4636
- height: (0, import_math16.bn)(block.height, 10),
4403
+ height: (0, import_math15.bn)(block.header.height, 10),
4637
4404
  time: block.header.time,
4638
4405
  transactionIds: block.transactions.map((tx) => tx.id),
4639
4406
  transactions: block.transactions.map(
4640
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4407
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4641
4408
  )
4642
4409
  };
4643
4410
  }
@@ -4652,8 +4419,8 @@ var _Provider = class {
4652
4419
  if (!transaction) {
4653
4420
  return null;
4654
4421
  }
4655
- return new import_transactions19.TransactionCoder().decode(
4656
- (0, import_utils22.arrayify)(transaction.rawPayload),
4422
+ return new import_transactions18.TransactionCoder().decode(
4423
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4657
4424
  0
4658
4425
  )?.[0];
4659
4426
  }
@@ -4680,9 +4447,9 @@ var _Provider = class {
4680
4447
  async getContractBalance(contractId, assetId) {
4681
4448
  const { contractBalance } = await this.operations.getContractBalance({
4682
4449
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4683
- asset: (0, import_utils22.hexlify)(assetId)
4450
+ asset: (0, import_utils23.hexlify)(assetId)
4684
4451
  });
4685
- return (0, import_math16.bn)(contractBalance.amount, 10);
4452
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4686
4453
  }
4687
4454
  /**
4688
4455
  * Returns the balance for the given owner for the given asset ID.
@@ -4694,9 +4461,9 @@ var _Provider = class {
4694
4461
  async getBalance(owner, assetId) {
4695
4462
  const { balance } = await this.operations.getBalance({
4696
4463
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4697
- assetId: (0, import_utils22.hexlify)(assetId)
4464
+ assetId: (0, import_utils23.hexlify)(assetId)
4698
4465
  });
4699
- return (0, import_math16.bn)(balance.amount, 10);
4466
+ return (0, import_math15.bn)(balance.amount, 10);
4700
4467
  }
4701
4468
  /**
4702
4469
  * Returns balances for the given owner.
@@ -4714,7 +4481,7 @@ var _Provider = class {
4714
4481
  const balances = result.balances.edges.map((edge) => edge.node);
4715
4482
  return balances.map((balance) => ({
4716
4483
  assetId: balance.assetId,
4717
- amount: (0, import_math16.bn)(balance.amount)
4484
+ amount: (0, import_math15.bn)(balance.amount)
4718
4485
  }));
4719
4486
  }
4720
4487
  /**
@@ -4732,19 +4499,19 @@ var _Provider = class {
4732
4499
  });
4733
4500
  const messages = result.messages.edges.map((edge) => edge.node);
4734
4501
  return messages.map((message) => ({
4735
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4502
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4736
4503
  sender: message.sender,
4737
4504
  recipient: message.recipient,
4738
4505
  nonce: message.nonce,
4739
- amount: (0, import_math16.bn)(message.amount),
4506
+ amount: (0, import_math15.bn)(message.amount),
4740
4507
  data: message.data
4741
4508
  }),
4742
4509
  sender: import_address3.Address.fromAddressOrString(message.sender),
4743
4510
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4744
4511
  nonce: message.nonce,
4745
- amount: (0, import_math16.bn)(message.amount),
4746
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4747
- daHeight: (0, import_math16.bn)(message.daHeight)
4512
+ amount: (0, import_math15.bn)(message.amount),
4513
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4514
+ daHeight: (0, import_math15.bn)(message.daHeight)
4748
4515
  }));
4749
4516
  }
4750
4517
  /**
@@ -4797,60 +4564,44 @@ var _Provider = class {
4797
4564
  } = result.messageProof;
4798
4565
  return {
4799
4566
  messageProof: {
4800
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4567
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4801
4568
  proofSet: messageProof.proofSet
4802
4569
  },
4803
4570
  blockProof: {
4804
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4571
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4805
4572
  proofSet: blockProof.proofSet
4806
4573
  },
4807
4574
  messageBlockHeader: {
4808
4575
  id: messageBlockHeader.id,
4809
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4810
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4576
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4577
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4811
4578
  transactionsRoot: messageBlockHeader.transactionsRoot,
4812
- height: (0, import_math16.bn)(messageBlockHeader.height),
4579
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4813
4580
  prevRoot: messageBlockHeader.prevRoot,
4814
4581
  time: messageBlockHeader.time,
4815
4582
  applicationHash: messageBlockHeader.applicationHash,
4816
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4817
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4818
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4819
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4820
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4583
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4584
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4821
4585
  },
4822
4586
  commitBlockHeader: {
4823
4587
  id: commitBlockHeader.id,
4824
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4825
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4588
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4589
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4826
4590
  transactionsRoot: commitBlockHeader.transactionsRoot,
4827
- height: (0, import_math16.bn)(commitBlockHeader.height),
4591
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4828
4592
  prevRoot: commitBlockHeader.prevRoot,
4829
4593
  time: commitBlockHeader.time,
4830
4594
  applicationHash: commitBlockHeader.applicationHash,
4831
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4832
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4833
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4834
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4835
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4595
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4596
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4836
4597
  },
4837
4598
  sender: import_address3.Address.fromAddressOrString(sender),
4838
4599
  recipient: import_address3.Address.fromAddressOrString(recipient),
4839
4600
  nonce,
4840
- amount: (0, import_math16.bn)(amount),
4601
+ amount: (0, import_math15.bn)(amount),
4841
4602
  data
4842
4603
  };
4843
4604
  }
4844
- async getLatestGasPrice() {
4845
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4846
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4847
- }
4848
- async estimateGasPrice(blockHorizon) {
4849
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4850
- blockHorizon: String(blockHorizon)
4851
- });
4852
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4853
- }
4854
4605
  /**
4855
4606
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4856
4607
  *
@@ -4870,10 +4621,10 @@ var _Provider = class {
4870
4621
  */
4871
4622
  async produceBlocks(amount, startTime) {
4872
4623
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4873
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4874
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4624
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4625
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4875
4626
  });
4876
- return (0, import_math16.bn)(latestBlockHeight);
4627
+ return (0, import_math15.bn)(latestBlockHeight);
4877
4628
  }
4878
4629
  // eslint-disable-next-line @typescript-eslint/require-await
4879
4630
  async getTransactionResponse(transactionId) {
@@ -4887,7 +4638,7 @@ cacheInputs_fn = function(inputs) {
4887
4638
  return;
4888
4639
  }
4889
4640
  inputs.forEach((input) => {
4890
- if (input.type === import_transactions19.InputType.Coin) {
4641
+ if (input.type === import_transactions18.InputType.Coin) {
4891
4642
  this.cache?.set(input.id);
4892
4643
  }
4893
4644
  });
@@ -4897,9 +4648,9 @@ __publicField(Provider, "nodeInfoCache", {});
4897
4648
 
4898
4649
  // src/providers/transaction-summary/get-transaction-summary.ts
4899
4650
  var import_errors15 = require("@fuel-ts/errors");
4900
- var import_math17 = require("@fuel-ts/math");
4901
- var import_transactions20 = require("@fuel-ts/transactions");
4902
- var import_utils25 = require("@fuel-ts/utils");
4651
+ var import_math16 = require("@fuel-ts/math");
4652
+ var import_transactions19 = require("@fuel-ts/transactions");
4653
+ var import_utils26 = require("@fuel-ts/utils");
4903
4654
  async function getTransactionSummary(params) {
4904
4655
  const { id, provider, abiMap } = params;
4905
4656
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4911,32 +4662,25 @@ async function getTransactionSummary(params) {
4911
4662
  `Transaction not found for given id: ${id}.`
4912
4663
  );
4913
4664
  }
4914
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4915
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4665
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4666
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4916
4667
  0
4917
4668
  );
4918
- let txReceipts = [];
4919
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4920
- txReceipts = gqlTransaction.status.receipts;
4921
- }
4922
- const receipts = txReceipts.map(processGqlReceipt);
4669
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4923
4670
  const {
4924
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4671
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4925
4672
  } = provider.getChain();
4926
- const gasPrice = await provider.getLatestGasPrice();
4927
4673
  const transactionInfo = assembleTransactionSummary({
4928
4674
  id: gqlTransaction.id,
4929
4675
  receipts,
4930
4676
  transaction: decodedTransaction,
4931
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4677
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4932
4678
  gqlTransactionStatus: gqlTransaction.status,
4933
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4934
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4679
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4680
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4935
4681
  abiMap,
4936
4682
  maxInputs,
4937
- gasCosts,
4938
- maxGasPerTx,
4939
- gasPrice
4683
+ gasCosts
4940
4684
  });
4941
4685
  return {
4942
4686
  gqlTransaction,
@@ -4946,11 +4690,10 @@ async function getTransactionSummary(params) {
4946
4690
  async function getTransactionSummaryFromRequest(params) {
4947
4691
  const { provider, transactionRequest, abiMap } = params;
4948
4692
  const { receipts } = await provider.call(transactionRequest);
4949
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4693
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4950
4694
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4951
4695
  const transaction = transactionRequest.toTransaction();
4952
4696
  const transactionBytes = transactionRequest.toTransactionBytes();
4953
- const gasPrice = await provider.getLatestGasPrice();
4954
4697
  const transactionSummary = assembleTransactionSummary({
4955
4698
  receipts,
4956
4699
  transaction,
@@ -4959,9 +4702,7 @@ async function getTransactionSummaryFromRequest(params) {
4959
4702
  gasPerByte,
4960
4703
  gasPriceFactor,
4961
4704
  maxInputs,
4962
- gasCosts,
4963
- maxGasPerTx,
4964
- gasPrice
4705
+ gasCosts
4965
4706
  });
4966
4707
  return transactionSummary;
4967
4708
  }
@@ -4970,31 +4711,24 @@ async function getTransactionsSummaries(params) {
4970
4711
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4971
4712
  const { edges, pageInfo } = transactionsByOwner;
4972
4713
  const {
4973
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4714
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4974
4715
  } = provider.getChain();
4975
- const gasPrice = await provider.getLatestGasPrice();
4976
4716
  const transactions = edges.map((edge) => {
4977
4717
  const { node: gqlTransaction } = edge;
4978
- const { id, rawPayload, status } = gqlTransaction;
4979
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4980
- let txReceipts = [];
4981
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4982
- txReceipts = gqlTransaction.status.receipts;
4983
- }
4984
- const receipts = txReceipts.map(processGqlReceipt);
4718
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4719
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4720
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4985
4721
  const transactionSummary = assembleTransactionSummary({
4986
4722
  id,
4987
4723
  receipts,
4988
4724
  transaction: decodedTransaction,
4989
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4725
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4990
4726
  gqlTransactionStatus: status,
4991
4727
  abiMap,
4992
4728
  gasPerByte,
4993
4729
  gasPriceFactor,
4994
4730
  maxInputs,
4995
- gasCosts,
4996
- maxGasPerTx,
4997
- gasPrice
4731
+ gasCosts
4998
4732
  });
4999
4733
  const output = {
5000
4734
  gqlTransaction,
@@ -5130,18 +4864,18 @@ var assets = [
5130
4864
  ];
5131
4865
 
5132
4866
  // src/utils/formatTransferToContractScriptData.ts
5133
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
5134
- var import_math18 = require("@fuel-ts/math");
5135
- var import_utils26 = require("@fuel-ts/utils");
4867
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4868
+ var import_math17 = require("@fuel-ts/math");
4869
+ var import_utils27 = require("@fuel-ts/utils");
5136
4870
  var asm = __toESM(require("@fuels/vm-asm"));
5137
4871
  var formatTransferToContractScriptData = (params) => {
5138
4872
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5139
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
5140
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4873
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4874
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5141
4875
  const scriptData = Uint8Array.from([
5142
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4876
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5143
4877
  ...encoded,
5144
- ...(0, import_utils26.arrayify)(assetId)
4878
+ ...(0, import_utils27.arrayify)(assetId)
5145
4879
  ]);
5146
4880
  return scriptData;
5147
4881
  };
@@ -5326,33 +5060,36 @@ var Account = class extends import_interfaces.AbstractAccount {
5326
5060
  * @param fee - The estimated transaction fee.
5327
5061
  * @returns A promise that resolves when the resources are added to the transaction.
5328
5062
  */
5329
- async fund(request, params) {
5330
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5331
- const txRequest = request;
5332
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5333
- amount: (0, import_math19.bn)(fee),
5063
+ async fund(request, coinQuantities, fee) {
5064
+ const updatedQuantities = addAmountToAsset({
5065
+ amount: (0, import_math18.bn)(fee),
5334
5066
  assetId: import_configs12.BaseAssetId,
5335
- coinQuantities: requiredQuantities
5067
+ coinQuantities
5336
5068
  });
5337
5069
  const quantitiesDict = {};
5338
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5070
+ updatedQuantities.forEach(({ amount, assetId }) => {
5339
5071
  quantitiesDict[assetId] = {
5340
5072
  required: amount,
5341
- owned: (0, import_math19.bn)(0)
5073
+ owned: (0, import_math18.bn)(0)
5342
5074
  };
5343
5075
  });
5344
- txRequest.inputs.forEach((input) => {
5076
+ const cachedUtxos = [];
5077
+ const cachedMessages = [];
5078
+ const owner = this.address.toB256();
5079
+ request.inputs.forEach((input) => {
5345
5080
  const isResource = "amount" in input;
5346
5081
  if (isResource) {
5347
5082
  const isCoin2 = "owner" in input;
5348
5083
  if (isCoin2) {
5349
5084
  const assetId = String(input.assetId);
5350
- if (quantitiesDict[assetId]) {
5351
- const amount = (0, import_math19.bn)(input.amount);
5085
+ if (input.owner === owner && quantitiesDict[assetId]) {
5086
+ const amount = (0, import_math18.bn)(input.amount);
5352
5087
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5088
+ cachedUtxos.push(input.id);
5353
5089
  }
5354
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5090
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5355
5091
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5092
+ cachedMessages.push(input.nonce);
5356
5093
  }
5357
5094
  }
5358
5095
  });
@@ -5367,23 +5104,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5367
5104
  });
5368
5105
  const needsToBeFunded = missingQuantities.length;
5369
5106
  if (needsToBeFunded) {
5370
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5371
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5372
- txRequest.addResources(resources);
5373
- }
5374
- txRequest.shiftPredicateData();
5375
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5376
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5377
- if (addedSignatures) {
5378
- Array.from({ length: addedSignatures }).forEach(
5379
- () => requestToBeReEstimate.addEmptyWitness()
5380
- );
5107
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5108
+ messages: cachedMessages,
5109
+ utxos: cachedUtxos
5110
+ });
5111
+ request.addResources(resources);
5381
5112
  }
5382
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5383
- transactionRequest: requestToBeReEstimate
5384
- });
5385
- txRequest.maxFee = maxFee;
5386
- return txRequest;
5387
5113
  }
5388
5114
  /**
5389
5115
  * A helper that creates a transfer transaction request and returns it.
@@ -5391,25 +5117,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5391
5117
  * @param destination - The address of the destination.
5392
5118
  * @param amount - The amount of coins to transfer.
5393
5119
  * @param assetId - The asset ID of the coins to transfer.
5394
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5120
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5395
5121
  * @returns A promise that resolves to the prepared transaction request.
5396
5122
  */
5397
5123
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5398
- const request = new ScriptTransactionRequest(txParams);
5124
+ const { minGasPrice } = this.provider.getGasConfig();
5125
+ const params = { gasPrice: minGasPrice, ...txParams };
5126
+ const request = new ScriptTransactionRequest(params);
5399
5127
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5400
- const txCost = await this.provider.getTransactionCost(request, {
5128
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5401
5129
  estimateTxDependencies: true,
5402
5130
  resourcesOwner: this
5403
5131
  });
5404
- if ("gasLimit" in txParams) {
5405
- this.validateGas({
5406
- gasUsed: txCost.gasUsed,
5407
- gasLimit: request.gasLimit
5408
- });
5409
- }
5410
- request.gasLimit = txCost.gasUsed;
5411
- request.maxFee = txCost.maxFee;
5412
- await this.fund(request, txCost);
5132
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5133
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5134
+ this.validateGas({
5135
+ gasUsed,
5136
+ gasPrice: request.gasPrice,
5137
+ gasLimit: request.gasLimit,
5138
+ minGasPrice
5139
+ });
5140
+ await this.fund(request, requiredQuantities, maxFee);
5141
+ request.updatePredicateInputs(estimatedInputs);
5413
5142
  return request;
5414
5143
  }
5415
5144
  /**
@@ -5422,7 +5151,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5422
5151
  * @returns A promise that resolves to the transaction response.
5423
5152
  */
5424
5153
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5425
- if ((0, import_math19.bn)(amount).lte(0)) {
5154
+ if ((0, import_math18.bn)(amount).lte(0)) {
5426
5155
  throw new import_errors16.FuelError(
5427
5156
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5428
5157
  "Transfer amount must be a positive number."
@@ -5441,37 +5170,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5441
5170
  * @returns A promise that resolves to the transaction response.
5442
5171
  */
5443
5172
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5444
- if ((0, import_math19.bn)(amount).lte(0)) {
5173
+ if ((0, import_math18.bn)(amount).lte(0)) {
5445
5174
  throw new import_errors16.FuelError(
5446
5175
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5447
5176
  "Transfer amount must be a positive number."
5448
5177
  );
5449
5178
  }
5450
5179
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5180
+ const { minGasPrice } = this.provider.getGasConfig();
5181
+ const params = { gasPrice: minGasPrice, ...txParams };
5451
5182
  const { script, scriptData } = await assembleTransferToContractScript({
5452
5183
  hexlifiedContractId: contractAddress.toB256(),
5453
- amountToTransfer: (0, import_math19.bn)(amount),
5184
+ amountToTransfer: (0, import_math18.bn)(amount),
5454
5185
  assetId
5455
5186
  });
5456
5187
  const request = new ScriptTransactionRequest({
5457
- ...txParams,
5188
+ ...params,
5458
5189
  script,
5459
5190
  scriptData
5460
5191
  });
5461
5192
  request.addContractInputAndOutput(contractAddress);
5462
- const txCost = await this.provider.getTransactionCost(request, {
5463
- resourcesOwner: this,
5464
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5193
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5194
+ request,
5195
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5196
+ );
5197
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5198
+ this.validateGas({
5199
+ gasUsed,
5200
+ gasPrice: request.gasPrice,
5201
+ gasLimit: request.gasLimit,
5202
+ minGasPrice
5465
5203
  });
5466
- if (txParams.gasLimit) {
5467
- this.validateGas({
5468
- gasUsed: txCost.gasUsed,
5469
- gasLimit: request.gasLimit
5470
- });
5471
- }
5472
- request.gasLimit = txCost.gasUsed;
5473
- request.maxFee = txCost.maxFee;
5474
- await this.fund(request, txCost);
5204
+ await this.fund(request, requiredQuantities, maxFee);
5475
5205
  return this.sendTransaction(request);
5476
5206
  }
5477
5207
  /**
@@ -5483,31 +5213,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5483
5213
  * @returns A promise that resolves to the transaction response.
5484
5214
  */
5485
5215
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5216
+ const { minGasPrice } = this.provider.getGasConfig();
5486
5217
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5487
- const recipientDataArray = (0, import_utils27.arrayify)(
5218
+ const recipientDataArray = (0, import_utils28.arrayify)(
5488
5219
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5489
5220
  );
5490
- const amountDataArray = (0, import_utils27.arrayify)(
5491
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5221
+ const amountDataArray = (0, import_utils28.arrayify)(
5222
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5492
5223
  );
5493
5224
  const script = new Uint8Array([
5494
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5225
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5495
5226
  ...recipientDataArray,
5496
5227
  ...amountDataArray
5497
5228
  ]);
5498
- const params = { script, ...txParams };
5229
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5499
5230
  const request = new ScriptTransactionRequest(params);
5500
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5501
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5502
- if (txParams.gasLimit) {
5503
- this.validateGas({
5504
- gasUsed: txCost.gasUsed,
5505
- gasLimit: request.gasLimit
5506
- });
5507
- }
5508
- request.maxFee = txCost.maxFee;
5509
- request.gasLimit = txCost.gasUsed;
5510
- await this.fund(request, txCost);
5231
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5232
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5233
+ request,
5234
+ forwardingQuantities
5235
+ );
5236
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5237
+ this.validateGas({
5238
+ gasUsed,
5239
+ gasPrice: request.gasPrice,
5240
+ gasLimit: request.gasLimit,
5241
+ minGasPrice
5242
+ });
5243
+ await this.fund(request, requiredQuantities, maxFee);
5511
5244
  return this.sendTransaction(request);
5512
5245
  }
5513
5246
  async signMessage(message) {
@@ -5565,7 +5298,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5565
5298
  }
5566
5299
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5567
5300
  }
5568
- validateGas({ gasUsed, gasLimit }) {
5301
+ validateGas({
5302
+ gasUsed,
5303
+ gasPrice,
5304
+ gasLimit,
5305
+ minGasPrice
5306
+ }) {
5307
+ if (minGasPrice.gt(gasPrice)) {
5308
+ throw new import_errors16.FuelError(
5309
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5310
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5311
+ );
5312
+ }
5569
5313
  if (gasUsed.gt(gasLimit)) {
5570
5314
  throw new import_errors16.FuelError(
5571
5315
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5577,14 +5321,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5577
5321
 
5578
5322
  // src/wallet/base-wallet-unlocked.ts
5579
5323
  var import_hasher3 = require("@fuel-ts/hasher");
5580
- var import_utils30 = require("@fuel-ts/utils");
5324
+ var import_utils31 = require("@fuel-ts/utils");
5581
5325
 
5582
5326
  // src/signer/signer.ts
5583
5327
  var import_address5 = require("@fuel-ts/address");
5584
- var import_crypto = require("@fuel-ts/crypto");
5328
+ var import_crypto2 = require("@fuel-ts/crypto");
5585
5329
  var import_hasher2 = require("@fuel-ts/hasher");
5586
- var import_math20 = require("@fuel-ts/math");
5587
- var import_utils28 = require("@fuel-ts/utils");
5330
+ var import_math19 = require("@fuel-ts/math");
5331
+ var import_utils29 = require("@fuel-ts/utils");
5588
5332
  var import_secp256k1 = require("@noble/curves/secp256k1");
5589
5333
  var Signer = class {
5590
5334
  address;
@@ -5603,10 +5347,10 @@ var Signer = class {
5603
5347
  privateKey = `0x${privateKey}`;
5604
5348
  }
5605
5349
  }
5606
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5607
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5608
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5609
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5350
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5351
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5352
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5353
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5610
5354
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5611
5355
  }
5612
5356
  /**
@@ -5620,11 +5364,11 @@ var Signer = class {
5620
5364
  * @returns hashed signature
5621
5365
  */
5622
5366
  sign(data) {
5623
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5624
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5625
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5367
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5368
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5369
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5626
5370
  s[0] |= (signature.recovery || 0) << 7;
5627
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5371
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5628
5372
  }
5629
5373
  /**
5630
5374
  * Add point on the current elliptic curve
@@ -5633,8 +5377,8 @@ var Signer = class {
5633
5377
  * @returns compressed point on the curve
5634
5378
  */
5635
5379
  addPoint(point) {
5636
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5637
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5380
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5381
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5638
5382
  const result = p0.add(p1);
5639
5383
  return `0x${result.toHex(true)}`;
5640
5384
  }
@@ -5646,16 +5390,16 @@ var Signer = class {
5646
5390
  * @returns public key from signature from the
5647
5391
  */
5648
5392
  static recoverPublicKey(data, signature) {
5649
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5393
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5650
5394
  const r = signedMessageBytes.slice(0, 32);
5651
5395
  const s = signedMessageBytes.slice(32, 64);
5652
5396
  const recoveryParam = (s[0] & 128) >> 7;
5653
5397
  s[0] &= 127;
5654
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5398
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5655
5399
  recoveryParam
5656
5400
  );
5657
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5658
- return (0, import_utils28.hexlify)(publicKey);
5401
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5402
+ return (0, import_utils29.hexlify)(publicKey);
5659
5403
  }
5660
5404
  /**
5661
5405
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5674,7 +5418,7 @@ var Signer = class {
5674
5418
  * @returns random 32-byte hashed
5675
5419
  */
5676
5420
  static generatePrivateKey(entropy) {
5677
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5421
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5678
5422
  }
5679
5423
  /**
5680
5424
  * Extended publicKey from a compact publicKey
@@ -5683,16 +5427,16 @@ var Signer = class {
5683
5427
  * @returns extended publicKey
5684
5428
  */
5685
5429
  static extendPublicKey(publicKey) {
5686
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5687
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5430
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5431
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5688
5432
  }
5689
5433
  };
5690
5434
 
5691
5435
  // src/wallet/keystore-wallet.ts
5692
5436
  var import_address6 = require("@fuel-ts/address");
5693
- var import_crypto2 = require("@fuel-ts/crypto");
5437
+ var import_crypto3 = require("@fuel-ts/crypto");
5694
5438
  var import_errors17 = require("@fuel-ts/errors");
5695
- var import_utils29 = require("@fuel-ts/utils");
5439
+ var import_utils30 = require("@fuel-ts/utils");
5696
5440
  var import_uuid = require("uuid");
5697
5441
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5698
5442
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5706,22 +5450,22 @@ var removeHexPrefix = (hexString) => {
5706
5450
  return hexString;
5707
5451
  };
5708
5452
  async function encryptKeystoreWallet(privateKey, address, password) {
5709
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5453
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5710
5454
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5711
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5712
- const key = (0, import_crypto2.scrypt)({
5713
- password: (0, import_crypto2.bufferFromString)(password),
5455
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5456
+ const key = (0, import_crypto3.scrypt)({
5457
+ password: (0, import_crypto3.bufferFromString)(password),
5714
5458
  salt,
5715
5459
  dklen: DEFAULT_KEY_SIZE,
5716
5460
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5717
5461
  r: DEFAULT_KDF_PARAMS_R,
5718
5462
  p: DEFAULT_KDF_PARAMS_P
5719
5463
  });
5720
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5721
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5464
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5465
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5722
5466
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5723
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5724
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5467
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5468
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5725
5469
  const keystore = {
5726
5470
  id: (0, import_uuid.v4)(),
5727
5471
  version: 3,
@@ -5729,15 +5473,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5729
5473
  crypto: {
5730
5474
  cipher: "aes-128-ctr",
5731
5475
  mac,
5732
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5733
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5476
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5477
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5734
5478
  kdf: "scrypt",
5735
5479
  kdfparams: {
5736
5480
  dklen: DEFAULT_KEY_SIZE,
5737
5481
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5738
5482
  p: DEFAULT_KDF_PARAMS_P,
5739
5483
  r: DEFAULT_KDF_PARAMS_R,
5740
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5484
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5741
5485
  }
5742
5486
  }
5743
5487
  };
@@ -5753,11 +5497,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5753
5497
  kdfparams: { dklen, n, r, p, salt }
5754
5498
  }
5755
5499
  } = keystoreWallet;
5756
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5757
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5758
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5759
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5760
- const key = (0, import_crypto2.scrypt)({
5500
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5501
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5502
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5503
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5504
+ const key = (0, import_crypto3.scrypt)({
5761
5505
  password: passwordBuffer,
5762
5506
  salt: saltBuffer,
5763
5507
  n,
@@ -5766,16 +5510,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5766
5510
  dklen
5767
5511
  });
5768
5512
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5769
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5770
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5513
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5514
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5771
5515
  if (mac !== macHash) {
5772
5516
  throw new import_errors17.FuelError(
5773
5517
  import_errors17.ErrorCode.INVALID_PASSWORD,
5774
5518
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5775
5519
  );
5776
5520
  }
5777
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5778
- const privateKey = (0, import_utils29.hexlify)(buffer);
5521
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5522
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5779
5523
  return privateKey;
5780
5524
  }
5781
5525
 
@@ -5820,7 +5564,7 @@ var BaseWalletUnlocked = class extends Account {
5820
5564
  */
5821
5565
  async signMessage(message) {
5822
5566
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5823
- return (0, import_utils30.hexlify)(signedMessage);
5567
+ return (0, import_utils31.hexlify)(signedMessage);
5824
5568
  }
5825
5569
  /**
5826
5570
  * Signs a transaction with the wallet's private key.
@@ -5833,7 +5577,7 @@ var BaseWalletUnlocked = class extends Account {
5833
5577
  const chainId = this.provider.getChainId();
5834
5578
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5835
5579
  const signature = await this.signer().sign(hashedTransaction);
5836
- return (0, import_utils30.hexlify)(signature);
5580
+ return (0, import_utils31.hexlify)(signature);
5837
5581
  }
5838
5582
  /**
5839
5583
  * Populates a transaction with the witnesses signature.
@@ -5853,7 +5597,7 @@ var BaseWalletUnlocked = class extends Account {
5853
5597
  * @param transactionRequestLike - The transaction request to send.
5854
5598
  * @returns A promise that resolves to the TransactionResponse object.
5855
5599
  */
5856
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5600
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5857
5601
  const transactionRequest = transactionRequestify(transactionRequestLike);
5858
5602
  if (estimateTxDependencies) {
5859
5603
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5894,16 +5638,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5894
5638
  // src/hdwallet/hdwallet.ts
5895
5639
  var import_errors20 = require("@fuel-ts/errors");
5896
5640
  var import_hasher6 = require("@fuel-ts/hasher");
5897
- var import_math21 = require("@fuel-ts/math");
5898
- var import_utils34 = require("@fuel-ts/utils");
5899
- var import_ethers4 = require("ethers");
5641
+ var import_math20 = require("@fuel-ts/math");
5642
+ var import_utils35 = require("@fuel-ts/utils");
5643
+ var import_ethers3 = require("ethers");
5900
5644
 
5901
5645
  // src/mnemonic/mnemonic.ts
5902
- var import_crypto3 = require("@fuel-ts/crypto");
5646
+ var import_crypto4 = require("@fuel-ts/crypto");
5903
5647
  var import_errors19 = require("@fuel-ts/errors");
5904
5648
  var import_hasher5 = require("@fuel-ts/hasher");
5905
- var import_utils32 = require("@fuel-ts/utils");
5906
- var import_ethers3 = require("ethers");
5649
+ var import_utils33 = require("@fuel-ts/utils");
5650
+ var import_ethers2 = require("ethers");
5907
5651
 
5908
5652
  // src/wordlists/words/english.ts
5909
5653
  var english = [
@@ -7966,7 +7710,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7966
7710
  // src/mnemonic/utils.ts
7967
7711
  var import_errors18 = require("@fuel-ts/errors");
7968
7712
  var import_hasher4 = require("@fuel-ts/hasher");
7969
- var import_utils31 = require("@fuel-ts/utils");
7713
+ var import_utils32 = require("@fuel-ts/utils");
7970
7714
  function toUtf8Bytes(stri) {
7971
7715
  const str = stri.normalize("NFKD");
7972
7716
  const result = [];
@@ -8033,14 +7777,14 @@ function entropyToMnemonicIndices(entropy) {
8033
7777
  }
8034
7778
  }
8035
7779
  const checksumBits = entropy.length / 4;
8036
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7780
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8037
7781
  indices[indices.length - 1] <<= checksumBits;
8038
7782
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8039
7783
  return indices;
8040
7784
  }
8041
7785
  function mnemonicWordsToEntropy(words, wordlist) {
8042
7786
  const size = Math.ceil(11 * words.length / 8);
8043
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7787
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8044
7788
  let offset = 0;
8045
7789
  for (let i = 0; i < words.length; i += 1) {
8046
7790
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8060,7 +7804,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8060
7804
  const entropyBits = 32 * words.length / 3;
8061
7805
  const checksumBits = words.length / 3;
8062
7806
  const checksumMask = getUpperMask(checksumBits);
8063
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7807
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8064
7808
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8065
7809
  throw new import_errors18.FuelError(
8066
7810
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8135,7 +7879,7 @@ var Mnemonic = class {
8135
7879
  static mnemonicToEntropy(phrase, wordlist = english) {
8136
7880
  const words = getWords(phrase);
8137
7881
  assertMnemonic(words);
8138
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7882
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8139
7883
  }
8140
7884
  /**
8141
7885
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8143,7 +7887,7 @@ var Mnemonic = class {
8143
7887
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8144
7888
  */
8145
7889
  static entropyToMnemonic(entropy, wordlist = english) {
8146
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7890
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8147
7891
  assertWordList(wordlist);
8148
7892
  assertEntropy(entropyBytes);
8149
7893
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8157,7 +7901,7 @@ var Mnemonic = class {
8157
7901
  assertMnemonic(getWords(phrase));
8158
7902
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8159
7903
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8160
- return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7904
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8161
7905
  }
8162
7906
  /**
8163
7907
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8212,14 +7956,14 @@ var Mnemonic = class {
8212
7956
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8213
7957
  */
8214
7958
  static masterKeysFromSeed(seed) {
8215
- const seedArray = (0, import_utils32.arrayify)(seed);
7959
+ const seedArray = (0, import_utils33.arrayify)(seed);
8216
7960
  if (seedArray.length < 16 || seedArray.length > 64) {
8217
7961
  throw new import_errors19.FuelError(
8218
7962
  import_errors19.ErrorCode.INVALID_SEED,
8219
7963
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8220
7964
  );
8221
7965
  }
8222
- return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7966
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8223
7967
  }
8224
7968
  /**
8225
7969
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8230,22 +7974,22 @@ var Mnemonic = class {
8230
7974
  */
8231
7975
  static seedToExtendedKey(seed, testnet = false) {
8232
7976
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8233
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7977
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8234
7978
  const depth = "0x00";
8235
7979
  const fingerprint = "0x00000000";
8236
7980
  const index = "0x00000000";
8237
7981
  const chainCode = masterKey.slice(32);
8238
7982
  const privateKey = masterKey.slice(0, 32);
8239
- const extendedKey = (0, import_utils32.concat)([
7983
+ const extendedKey = (0, import_utils33.concat)([
8240
7984
  prefix,
8241
7985
  depth,
8242
7986
  fingerprint,
8243
7987
  index,
8244
7988
  chainCode,
8245
- (0, import_utils32.concat)(["0x00", privateKey])
7989
+ (0, import_utils33.concat)(["0x00", privateKey])
8246
7990
  ]);
8247
- const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8248
- return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7991
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7992
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8249
7993
  }
8250
7994
  /**
8251
7995
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8260,7 +8004,7 @@ var Mnemonic = class {
8260
8004
  * @returns A randomly generated mnemonic
8261
8005
  */
8262
8006
  static generate(size = 32, extraEntropy = "") {
8263
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8007
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8264
8008
  return Mnemonic.entropyToMnemonic(entropy);
8265
8009
  }
8266
8010
  };
@@ -8268,12 +8012,12 @@ var mnemonic_default = Mnemonic;
8268
8012
 
8269
8013
  // src/hdwallet/hdwallet.ts
8270
8014
  var HARDENED_INDEX = 2147483648;
8271
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8272
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8273
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8274
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8015
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8016
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8017
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8018
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8275
8019
  function base58check(data) {
8276
- return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8020
+ return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8277
8021
  }
8278
8022
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8279
8023
  if (isPublic) {
@@ -8282,11 +8026,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8282
8026
  return testnet ? TestnetPRV2 : MainnetPRV2;
8283
8027
  }
8284
8028
  function isPublicExtendedKey(extendedKey) {
8285
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8029
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8286
8030
  }
8287
8031
  function isValidExtendedKey(extendedKey) {
8288
8032
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8289
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8033
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8290
8034
  );
8291
8035
  }
8292
8036
  function parsePath(path, depth = 0) {
@@ -8304,8 +8048,8 @@ function parsePath(path, depth = 0) {
8304
8048
  var HDWallet = class {
8305
8049
  depth = 0;
8306
8050
  index = 0;
8307
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8308
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8051
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8052
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8309
8053
  privateKey;
8310
8054
  publicKey;
8311
8055
  chainCode;
@@ -8317,8 +8061,8 @@ var HDWallet = class {
8317
8061
  constructor(config) {
8318
8062
  if (config.privateKey) {
8319
8063
  const signer = new Signer(config.privateKey);
8320
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8321
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8064
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8065
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8322
8066
  } else {
8323
8067
  if (!config.publicKey) {
8324
8068
  throw new import_errors20.FuelError(
@@ -8326,10 +8070,10 @@ var HDWallet = class {
8326
8070
  "Both public and private Key cannot be missing. At least one should be provided."
8327
8071
  );
8328
8072
  }
8329
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8073
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8330
8074
  }
8331
8075
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8332
- this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8076
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8333
8077
  this.depth = config.depth || this.depth;
8334
8078
  this.index = config.index || this.index;
8335
8079
  this.chainCode = config.chainCode;
@@ -8345,9 +8089,9 @@ var HDWallet = class {
8345
8089
  * @returns A new instance of HDWallet on the derived index
8346
8090
  */
8347
8091
  deriveIndex(index) {
8348
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8349
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8350
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8092
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8093
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8094
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8351
8095
  const data = new Uint8Array(37);
8352
8096
  if (index & HARDENED_INDEX) {
8353
8097
  if (!privateKey) {
@@ -8358,15 +8102,15 @@ var HDWallet = class {
8358
8102
  }
8359
8103
  data.set(privateKey, 1);
8360
8104
  } else {
8361
- data.set((0, import_utils34.arrayify)(this.publicKey));
8105
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8362
8106
  }
8363
- data.set((0, import_math21.toBytes)(index, 4), 33);
8364
- const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
8107
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8108
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8365
8109
  const IL = bytes.slice(0, 32);
8366
8110
  const IR = bytes.slice(32);
8367
8111
  if (privateKey) {
8368
8112
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8369
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8113
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8370
8114
  return new HDWallet({
8371
8115
  privateKey: ki,
8372
8116
  chainCode: IR,
@@ -8375,7 +8119,7 @@ var HDWallet = class {
8375
8119
  parentFingerprint: this.fingerprint
8376
8120
  });
8377
8121
  }
8378
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8122
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8379
8123
  const Ki = signer.addPoint(publicKey);
8380
8124
  return new HDWallet({
8381
8125
  publicKey: Ki,
@@ -8410,12 +8154,12 @@ var HDWallet = class {
8410
8154
  );
8411
8155
  }
8412
8156
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8413
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8157
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8414
8158
  const parentFingerprint = this.parentFingerprint;
8415
- const index = (0, import_math21.toHex)(this.index, 4);
8159
+ const index = (0, import_math20.toHex)(this.index, 4);
8416
8160
  const chainCode = this.chainCode;
8417
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8418
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8161
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8162
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8419
8163
  return base58check(extendedKey);
8420
8164
  }
8421
8165
  /**
@@ -8427,13 +8171,13 @@ var HDWallet = class {
8427
8171
  static fromSeed(seed) {
8428
8172
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8429
8173
  return new HDWallet({
8430
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8431
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8174
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8175
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8432
8176
  });
8433
8177
  }
8434
8178
  static fromExtendedKey(extendedKey) {
8435
- const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
8436
- const bytes = (0, import_utils34.arrayify)(decoded);
8179
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8180
+ const bytes = (0, import_utils35.arrayify)(decoded);
8437
8181
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8438
8182
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8439
8183
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8442,9 +8186,9 @@ var HDWallet = class {
8442
8186
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8443
8187
  }
8444
8188
  const depth = bytes[4];
8445
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8446
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8447
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8189
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8190
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8191
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8448
8192
  const key = bytes.slice(45, 78);
8449
8193
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8450
8194
  throw new import_errors20.FuelError(
@@ -8632,7 +8376,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8632
8376
 
8633
8377
  // src/wallet-manager/wallet-manager.ts
8634
8378
  var import_address9 = require("@fuel-ts/address");
8635
- var import_crypto4 = require("@fuel-ts/crypto");
8379
+ var import_crypto5 = require("@fuel-ts/crypto");
8636
8380
  var import_errors23 = require("@fuel-ts/errors");
8637
8381
  var import_events = require("events");
8638
8382
 
@@ -8960,7 +8704,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8960
8704
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8961
8705
  const data = await this.storage.getItem(this.STORAGE_KEY);
8962
8706
  if (data) {
8963
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8707
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8964
8708
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8965
8709
  }
8966
8710
  }
@@ -8969,7 +8713,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8969
8713
  */
8970
8714
  async saveState() {
8971
8715
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8972
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8716
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8973
8717
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8974
8718
  });
8975
8719
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -9045,23 +8789,23 @@ var StorageAbstract = class {
9045
8789
  };
9046
8790
 
9047
8791
  // src/predicate/predicate.ts
9048
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
8792
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
9049
8793
  var import_address10 = require("@fuel-ts/address");
9050
8794
  var import_configs13 = require("@fuel-ts/address/configs");
9051
8795
  var import_errors25 = require("@fuel-ts/errors");
9052
- var import_transactions21 = require("@fuel-ts/transactions");
9053
- var import_utils36 = require("@fuel-ts/utils");
8796
+ var import_transactions20 = require("@fuel-ts/transactions");
8797
+ var import_utils37 = require("@fuel-ts/utils");
9054
8798
 
9055
8799
  // src/predicate/utils/getPredicateRoot.ts
9056
8800
  var import_hasher7 = require("@fuel-ts/hasher");
9057
8801
  var import_merkle = require("@fuel-ts/merkle");
9058
- var import_utils35 = require("@fuel-ts/utils");
8802
+ var import_utils36 = require("@fuel-ts/utils");
9059
8803
  var getPredicateRoot = (bytecode) => {
9060
8804
  const chunkSize = 16 * 1024;
9061
- const bytes = (0, import_utils35.arrayify)(bytecode);
9062
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9063
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9064
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8805
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8806
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8807
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8808
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9065
8809
  return predicateRoot;
9066
8810
  };
9067
8811
 
@@ -9109,9 +8853,10 @@ var Predicate = class extends Account {
9109
8853
  const request = transactionRequestify(transactionRequestLike);
9110
8854
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9111
8855
  request.inputs?.forEach((input) => {
9112
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9113
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9114
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8856
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8857
+ input.predicate = this.bytes;
8858
+ input.predicateData = this.getPredicateData(policies.length);
8859
+ input.witnessIndex = 0;
9115
8860
  }
9116
8861
  });
9117
8862
  return request;
@@ -9126,7 +8871,8 @@ var Predicate = class extends Account {
9126
8871
  * @returns A promise that resolves to the prepared transaction request.
9127
8872
  */
9128
8873
  async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9129
- return super.createTransfer(destination, amount, assetId, txParams);
8874
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8875
+ return this.populateTransactionPredicateData(request);
9130
8876
  }
9131
8877
  /**
9132
8878
  * Sends a transaction with the populated predicate data.
@@ -9134,9 +8880,9 @@ var Predicate = class extends Account {
9134
8880
  * @param transactionRequestLike - The transaction request-like object.
9135
8881
  * @returns A promise that resolves to the transaction response.
9136
8882
  */
9137
- sendTransaction(transactionRequestLike) {
9138
- const transactionRequest = transactionRequestify(transactionRequestLike);
9139
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8883
+ sendTransaction(transactionRequestLike, options) {
8884
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8885
+ return super.sendTransaction(transactionRequest, options);
9140
8886
  }
9141
8887
  /**
9142
8888
  * Simulates a transaction with the populated predicate data.
@@ -9145,19 +8891,33 @@ var Predicate = class extends Account {
9145
8891
  * @returns A promise that resolves to the call result.
9146
8892
  */
9147
8893
  simulateTransaction(transactionRequestLike) {
9148
- const transactionRequest = transactionRequestify(transactionRequestLike);
9149
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8894
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8895
+ return super.simulateTransaction(transactionRequest);
8896
+ }
8897
+ /**
8898
+ * Retrieves resources satisfying the spend query for the account.
8899
+ *
8900
+ * @param quantities - IDs of coins to exclude.
8901
+ * @param excludedIds - IDs of resources to be excluded from the query.
8902
+ * @returns A promise that resolves to an array of Resources.
8903
+ */
8904
+ async getResourcesToSpend(quantities, excludedIds) {
8905
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
8906
+ return resources.map((resource) => ({
8907
+ ...resource,
8908
+ predicate: (0, import_utils37.hexlify)(this.bytes)
8909
+ }));
9150
8910
  }
9151
8911
  getPredicateData(policiesLength) {
9152
8912
  if (!this.predicateData.length) {
9153
8913
  return new Uint8Array();
9154
8914
  }
9155
8915
  const mainFn = this.interface?.functions.main;
9156
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9157
- const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8916
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8917
+ const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9158
8918
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9159
8919
  });
9160
- const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8920
+ 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;
9161
8921
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
9162
8922
  }
9163
8923
  /**
@@ -9169,10 +8929,10 @@ var Predicate = class extends Account {
9169
8929
  * @returns An object containing the new predicate bytes and interface.
9170
8930
  */
9171
8931
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9172
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8932
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9173
8933
  let abiInterface;
9174
8934
  if (jsonAbi) {
9175
- abiInterface = new import_abi_coder5.Interface(jsonAbi);
8935
+ abiInterface = new import_abi_coder7.Interface(jsonAbi);
9176
8936
  if (abiInterface.functions.main === void 0) {
9177
8937
  throw new import_errors25.FuelError(
9178
8938
  import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
@@ -9192,25 +8952,6 @@ var Predicate = class extends Account {
9192
8952
  predicateInterface: abiInterface
9193
8953
  };
9194
8954
  }
9195
- /**
9196
- * Retrieves resources satisfying the spend query for the account.
9197
- *
9198
- * @param quantities - IDs of coins to exclude.
9199
- * @param excludedIds - IDs of resources to be excluded from the query.
9200
- * @returns A promise that resolves to an array of Resources.
9201
- */
9202
- async getResourcesToSpend(quantities, excludedIds) {
9203
- const resources = await this.provider.getResourcesToSpend(
9204
- this.address,
9205
- quantities,
9206
- excludedIds
9207
- );
9208
- return resources.map((resource) => ({
9209
- ...resource,
9210
- predicate: (0, import_utils36.hexlify)(this.bytes),
9211
- paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9212
- }));
9213
- }
9214
8955
  /**
9215
8956
  * Sets the configurable constants for the predicate.
9216
8957
  *
@@ -9960,7 +9701,7 @@ __publicField(Fuel, "defaultConfig", {});
9960
9701
  WalletLocked,
9961
9702
  WalletManager,
9962
9703
  WalletUnlocked,
9963
- addAmountToCoinQuantities,
9704
+ addAmountToAsset,
9964
9705
  addOperation,
9965
9706
  assemblePanicError,
9966
9707
  assembleReceiptByType,
@@ -9969,10 +9710,9 @@ __publicField(Fuel, "defaultConfig", {});
9969
9710
  assets,
9970
9711
  buildBlockExplorerUrl,
9971
9712
  cacheFor,
9972
- cacheTxInputsFromOwner,
9973
- calculateGasFee,
9974
9713
  calculateMetadataGasForTxCreate,
9975
9714
  calculateMetadataGasForTxScript,
9715
+ calculatePriceWithFactor,
9976
9716
  calculateTransactionFee,
9977
9717
  coinQuantityfy,
9978
9718
  deferPromise,