@fuel-ts/account 0.0.0-rc-2021-20240423205052 → 0.0.0-rc-2045-20240424064755

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (53) hide show
  1. package/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 +589 -861
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +517 -793
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +398 -673
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +327 -821
  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 +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +29 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1090 -1579
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +515 -774
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +407 -666
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
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,51 +229,27 @@ 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");
236
+ var import_utils24 = require("@noble/curves/abstract/utils");
239
237
  var import_ethers = require("ethers");
240
238
  var import_graphql_request = require("graphql-request");
241
239
  var import_ramda3 = require("ramda");
242
240
 
243
241
  // src/providers/__generated__/operations.ts
244
242
  var import_graphql_tag = __toESM(require("graphql-tag"));
245
- var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
246
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
247
- type: __typename
248
- ... on SubmittedStatus {
249
- time
250
- }
251
- ... on SuccessStatus {
252
- block {
253
- id
254
- }
255
- time
256
- programState {
257
- returnType
258
- data
259
- }
260
- }
261
- ... on FailureStatus {
262
- block {
263
- id
264
- }
265
- time
266
- reason
267
- }
268
- ... on SqueezedOutStatus {
269
- reason
270
- }
271
- }
272
- `;
273
243
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
274
244
  fragment receiptFragment on Receipt {
275
- id
245
+ contract {
246
+ id
247
+ }
276
248
  pc
277
249
  is
278
- to
250
+ to {
251
+ id
252
+ }
279
253
  toAddress
280
254
  amount
281
255
  assetId
@@ -313,16 +287,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
313
287
  id
314
288
  }
315
289
  time
316
- receipts {
317
- ...receiptFragment
318
- }
319
290
  programState {
320
291
  returnType
321
292
  data
322
293
  }
323
- receipts {
324
- ...receiptFragment
325
- }
326
294
  }
327
295
  ... on FailureStatus {
328
296
  block {
@@ -330,24 +298,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
330
298
  }
331
299
  time
332
300
  reason
333
- receipts {
334
- ...receiptFragment
335
- }
336
301
  }
337
302
  ... on SqueezedOutStatus {
338
303
  reason
339
304
  }
340
305
  }
341
- ${ReceiptFragmentFragmentDoc}`;
306
+ `;
342
307
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
343
308
  fragment transactionFragment on Transaction {
344
309
  id
345
310
  rawPayload
311
+ gasPrice
312
+ receipts {
313
+ ...receiptFragment
314
+ }
346
315
  status {
347
316
  ...transactionStatusFragment
348
317
  }
349
318
  }
350
- ${TransactionStatusFragmentFragmentDoc}`;
319
+ ${ReceiptFragmentFragmentDoc}
320
+ ${TransactionStatusFragmentFragmentDoc}`;
351
321
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
352
322
  fragment inputEstimatePredicatesFragment on Input {
353
323
  ... on InputCoin {
@@ -365,46 +335,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
365
335
  }
366
336
  }
367
337
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
368
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
369
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
370
- reason
371
- programState {
372
- returnType
373
- data
374
- }
375
- }
376
- `;
377
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
378
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
379
- programState {
380
- returnType
381
- data
382
- }
383
- }
384
- `;
385
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
386
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
387
- ... on DryRunFailureStatus {
388
- ...dryRunFailureStatusFragment
389
- }
390
- ... on DryRunSuccessStatus {
391
- ...dryRunSuccessStatusFragment
392
- }
393
- }
394
- ${DryRunFailureStatusFragmentFragmentDoc}
395
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
396
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
397
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
398
- id
399
- status {
400
- ...dryRunTransactionStatusFragment
401
- }
402
- receipts {
403
- ...receiptFragment
404
- }
405
- }
406
- ${DryRunTransactionStatusFragmentFragmentDoc}
407
- ${ReceiptFragmentFragmentDoc}`;
408
338
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
409
339
  fragment coinFragment on Coin {
410
340
  __typename
@@ -412,6 +342,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
412
342
  owner
413
343
  amount
414
344
  assetId
345
+ maturity
415
346
  blockCreated
416
347
  txCreatedIdx
417
348
  }
@@ -450,32 +381,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
450
381
  messageBlockHeader {
451
382
  id
452
383
  daHeight
453
- consensusParametersVersion
454
- stateTransitionBytecodeVersion
455
384
  transactionsCount
456
- messageReceiptCount
457
385
  transactionsRoot
458
- messageOutboxRoot
459
- eventInboxRoot
460
386
  height
461
387
  prevRoot
462
388
  time
463
389
  applicationHash
390
+ messageReceiptRoot
391
+ messageReceiptCount
464
392
  }
465
393
  commitBlockHeader {
466
394
  id
467
395
  daHeight
468
- consensusParametersVersion
469
- stateTransitionBytecodeVersion
470
396
  transactionsCount
471
- messageReceiptCount
472
397
  transactionsRoot
473
- messageOutboxRoot
474
- eventInboxRoot
475
398
  height
476
399
  prevRoot
477
400
  time
478
401
  applicationHash
402
+ messageReceiptRoot
403
+ messageReceiptCount
479
404
  }
480
405
  sender
481
406
  recipient
@@ -494,8 +419,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
494
419
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
495
420
  fragment blockFragment on Block {
496
421
  id
497
- height
498
422
  header {
423
+ height
499
424
  time
500
425
  }
501
426
  transactions {
@@ -553,11 +478,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
553
478
  `;
554
479
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
555
480
  fragment GasCostsFragment on GasCosts {
556
- version {
557
- ... on Version {
558
- value
559
- }
560
- }
561
481
  add
562
482
  addi
563
483
  aloc
@@ -570,6 +490,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
570
490
  cb
571
491
  cfei
572
492
  cfsi
493
+ croo
573
494
  div
574
495
  divi
575
496
  ecr1
@@ -652,9 +573,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
652
573
  ccp {
653
574
  ...DependentCostFragment
654
575
  }
655
- croo {
656
- ...DependentCostFragment
657
- }
658
576
  csiz {
659
577
  ...DependentCostFragment
660
578
  }
@@ -714,11 +632,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
714
632
  ${DependentCostFragmentFragmentDoc}`;
715
633
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
716
634
  fragment consensusParametersFragment on ConsensusParameters {
717
- version {
718
- ... on Version {
719
- value
720
- }
721
- }
722
635
  txParams {
723
636
  ...TxParametersFragment
724
637
  }
@@ -778,9 +691,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
778
691
  fragment nodeInfoFragment on NodeInfo {
779
692
  utxoValidation
780
693
  vmBacktrace
694
+ minGasPrice
781
695
  maxTx
782
696
  maxDepth
783
697
  nodeVersion
698
+ peers {
699
+ id
700
+ addresses
701
+ clientVersion
702
+ blockHeight
703
+ lastHeartbeatMs
704
+ appScore
705
+ }
784
706
  }
785
707
  `;
786
708
  var GetVersionDocument = import_graphql_tag.default`
@@ -815,9 +737,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
815
737
  query getTransactionWithReceipts($transactionId: TransactionId!) {
816
738
  transaction(id: $transactionId) {
817
739
  ...transactionFragment
740
+ receipts {
741
+ ...receiptFragment
742
+ }
818
743
  }
819
744
  }
820
- ${TransactionFragmentFragmentDoc}`;
745
+ ${TransactionFragmentFragmentDoc}
746
+ ${ReceiptFragmentFragmentDoc}`;
821
747
  var GetTransactionsDocument = import_graphql_tag.default`
822
748
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
823
749
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -945,20 +871,6 @@ var GetBalanceDocument = import_graphql_tag.default`
945
871
  }
946
872
  }
947
873
  ${BalanceFragmentFragmentDoc}`;
948
- var GetLatestGasPriceDocument = import_graphql_tag.default`
949
- query getLatestGasPrice {
950
- latestGasPrice {
951
- gasPrice
952
- }
953
- }
954
- `;
955
- var EstimateGasPriceDocument = import_graphql_tag.default`
956
- query estimateGasPrice($blockHorizon: U32!) {
957
- estimateGasPrice(blockHorizon: $blockHorizon) {
958
- gasPrice
959
- }
960
- }
961
- `;
962
874
  var GetBalancesDocument = import_graphql_tag.default`
963
875
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
964
876
  balances(
@@ -1013,12 +925,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
1013
925
  }
1014
926
  `;
1015
927
  var DryRunDocument = import_graphql_tag.default`
1016
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
1017
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
1018
- ...dryRunTransactionExecutionStatusFragment
928
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
+ ...receiptFragment
1019
931
  }
1020
932
  }
1021
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
933
+ ${ReceiptFragmentFragmentDoc}`;
1022
934
  var SubmitDocument = import_graphql_tag.default`
1023
935
  mutation submit($encodedTransaction: HexString!) {
1024
936
  submit(tx: $encodedTransaction) {
@@ -1037,17 +949,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
1037
949
  var SubmitAndAwaitDocument = import_graphql_tag.default`
1038
950
  subscription submitAndAwait($encodedTransaction: HexString!) {
1039
951
  submitAndAwait(tx: $encodedTransaction) {
1040
- ...transactionStatusSubscriptionFragment
952
+ ...transactionStatusFragment
1041
953
  }
1042
954
  }
1043
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
955
+ ${TransactionStatusFragmentFragmentDoc}`;
1044
956
  var StatusChangeDocument = import_graphql_tag.default`
1045
957
  subscription statusChange($transactionId: TransactionId!) {
1046
958
  statusChange(id: $transactionId) {
1047
- ...transactionStatusSubscriptionFragment
959
+ ...transactionStatusFragment
1048
960
  }
1049
961
  }
1050
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
962
+ ${TransactionStatusFragmentFragmentDoc}`;
1051
963
  function getSdk(requester) {
1052
964
  return {
1053
965
  getVersion(variables, options) {
@@ -1101,12 +1013,6 @@ function getSdk(requester) {
1101
1013
  getBalance(variables, options) {
1102
1014
  return requester(GetBalanceDocument, variables, options);
1103
1015
  },
1104
- getLatestGasPrice(variables, options) {
1105
- return requester(GetLatestGasPriceDocument, variables, options);
1106
- },
1107
- estimateGasPrice(variables, options) {
1108
- return requester(EstimateGasPriceDocument, variables, options);
1109
- },
1110
1016
  getBalances(variables, options) {
1111
1017
  return requester(GetBalancesDocument, variables, options);
1112
1018
  },
@@ -1300,9 +1206,10 @@ var inputify = (value) => {
1300
1206
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1301
1207
  },
1302
1208
  witnessIndex: value.witnessIndex,
1209
+ maturity: value.maturity ?? 0,
1303
1210
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1304
- predicateLength: (0, import_math2.bn)(predicate.length),
1305
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1211
+ predicateLength: predicate.length,
1212
+ predicateDataLength: predicateData.length,
1306
1213
  predicate: (0, import_utils3.hexlify)(predicate),
1307
1214
  predicateData: (0, import_utils3.hexlify)(predicateData)
1308
1215
  };
@@ -1333,8 +1240,8 @@ var inputify = (value) => {
1333
1240
  nonce: (0, import_utils3.hexlify)(value.nonce),
1334
1241
  witnessIndex: value.witnessIndex,
1335
1242
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1336
- predicateLength: (0, import_math2.bn)(predicate.length),
1337
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1243
+ predicateLength: predicate.length,
1244
+ predicateDataLength: predicateData.length,
1338
1245
  predicate: (0, import_utils3.hexlify)(predicate),
1339
1246
  predicateData: (0, import_utils3.hexlify)(predicateData),
1340
1247
  data: (0, import_utils3.hexlify)(data),
@@ -1453,8 +1360,8 @@ function assembleReceiptByType(receipt) {
1453
1360
  case "CALL" /* Call */: {
1454
1361
  const callReceipt = {
1455
1362
  type: import_transactions3.ReceiptType.Call,
1456
- from: hexOrZero(receipt.id || receipt.contractId),
1457
- to: hexOrZero(receipt?.to),
1363
+ from: hexOrZero(receipt.contract?.id),
1364
+ to: hexOrZero(receipt?.to?.id),
1458
1365
  amount: (0, import_math4.bn)(receipt.amount),
1459
1366
  assetId: hexOrZero(receipt.assetId),
1460
1367
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1468,7 +1375,7 @@ function assembleReceiptByType(receipt) {
1468
1375
  case "RETURN" /* Return */: {
1469
1376
  const returnReceipt = {
1470
1377
  type: import_transactions3.ReceiptType.Return,
1471
- id: hexOrZero(receipt.id || receipt.contractId),
1378
+ id: hexOrZero(receipt.contract?.id),
1472
1379
  val: (0, import_math4.bn)(receipt.val),
1473
1380
  pc: (0, import_math4.bn)(receipt.pc),
1474
1381
  is: (0, import_math4.bn)(receipt.is)
@@ -1478,7 +1385,7 @@ function assembleReceiptByType(receipt) {
1478
1385
  case "RETURN_DATA" /* ReturnData */: {
1479
1386
  const returnDataReceipt = {
1480
1387
  type: import_transactions3.ReceiptType.ReturnData,
1481
- id: hexOrZero(receipt.id || receipt.contractId),
1388
+ id: hexOrZero(receipt.contract?.id),
1482
1389
  ptr: (0, import_math4.bn)(receipt.ptr),
1483
1390
  len: (0, import_math4.bn)(receipt.len),
1484
1391
  digest: hexOrZero(receipt.digest),
@@ -1490,7 +1397,7 @@ function assembleReceiptByType(receipt) {
1490
1397
  case "PANIC" /* Panic */: {
1491
1398
  const panicReceipt = {
1492
1399
  type: import_transactions3.ReceiptType.Panic,
1493
- id: hexOrZero(receipt.id),
1400
+ id: hexOrZero(receipt.contract?.id),
1494
1401
  reason: (0, import_math4.bn)(receipt.reason),
1495
1402
  pc: (0, import_math4.bn)(receipt.pc),
1496
1403
  is: (0, import_math4.bn)(receipt.is),
@@ -1501,7 +1408,7 @@ function assembleReceiptByType(receipt) {
1501
1408
  case "REVERT" /* Revert */: {
1502
1409
  const revertReceipt = {
1503
1410
  type: import_transactions3.ReceiptType.Revert,
1504
- id: hexOrZero(receipt.id || receipt.contractId),
1411
+ id: hexOrZero(receipt.contract?.id),
1505
1412
  val: (0, import_math4.bn)(receipt.ra),
1506
1413
  pc: (0, import_math4.bn)(receipt.pc),
1507
1414
  is: (0, import_math4.bn)(receipt.is)
@@ -1511,7 +1418,7 @@ function assembleReceiptByType(receipt) {
1511
1418
  case "LOG" /* Log */: {
1512
1419
  const logReceipt = {
1513
1420
  type: import_transactions3.ReceiptType.Log,
1514
- id: hexOrZero(receipt.id || receipt.contractId),
1421
+ id: hexOrZero(receipt.contract?.id),
1515
1422
  val0: (0, import_math4.bn)(receipt.ra),
1516
1423
  val1: (0, import_math4.bn)(receipt.rb),
1517
1424
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1524,7 +1431,7 @@ function assembleReceiptByType(receipt) {
1524
1431
  case "LOG_DATA" /* LogData */: {
1525
1432
  const logDataReceipt = {
1526
1433
  type: import_transactions3.ReceiptType.LogData,
1527
- id: hexOrZero(receipt.id || receipt.contractId),
1434
+ id: hexOrZero(receipt.contract?.id),
1528
1435
  val0: (0, import_math4.bn)(receipt.ra),
1529
1436
  val1: (0, import_math4.bn)(receipt.rb),
1530
1437
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1538,8 +1445,8 @@ function assembleReceiptByType(receipt) {
1538
1445
  case "TRANSFER" /* Transfer */: {
1539
1446
  const transferReceipt = {
1540
1447
  type: import_transactions3.ReceiptType.Transfer,
1541
- from: hexOrZero(receipt.id || receipt.contractId),
1542
- to: hexOrZero(receipt.toAddress || receipt?.to),
1448
+ from: hexOrZero(receipt.contract?.id),
1449
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1543
1450
  amount: (0, import_math4.bn)(receipt.amount),
1544
1451
  assetId: hexOrZero(receipt.assetId),
1545
1452
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1550,8 +1457,8 @@ function assembleReceiptByType(receipt) {
1550
1457
  case "TRANSFER_OUT" /* TransferOut */: {
1551
1458
  const transferOutReceipt = {
1552
1459
  type: import_transactions3.ReceiptType.TransferOut,
1553
- from: hexOrZero(receipt.id || receipt.contractId),
1554
- to: hexOrZero(receipt.toAddress || receipt.to),
1460
+ from: hexOrZero(receipt.contract?.id),
1461
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1555
1462
  amount: (0, import_math4.bn)(receipt.amount),
1556
1463
  assetId: hexOrZero(receipt.assetId),
1557
1464
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1594,7 +1501,7 @@ function assembleReceiptByType(receipt) {
1594
1501
  return receiptMessageOut;
1595
1502
  }
1596
1503
  case "MINT" /* Mint */: {
1597
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1504
+ const contractId = hexOrZero(receipt.contract?.id);
1598
1505
  const subId = hexOrZero(receipt.subId);
1599
1506
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1600
1507
  const mintReceipt = {
@@ -1609,7 +1516,7 @@ function assembleReceiptByType(receipt) {
1609
1516
  return mintReceipt;
1610
1517
  }
1611
1518
  case "BURN" /* Burn */: {
1612
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1519
+ const contractId = hexOrZero(receipt.contract?.id);
1613
1520
  const subId = hexOrZero(receipt.subId);
1614
1521
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1615
1522
  const burnReceipt = {
@@ -1694,6 +1601,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1694
1601
  var import_math5 = require("@fuel-ts/math");
1695
1602
  var import_transactions4 = require("@fuel-ts/transactions");
1696
1603
  var import_utils6 = require("@fuel-ts/utils");
1604
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1697
1605
  var getGasUsedFromReceipts = (receipts) => {
1698
1606
  const scriptResult = receipts.filter(
1699
1607
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1714,28 +1622,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1714
1622
  }
1715
1623
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1716
1624
  const witnessCache = [];
1717
- const chargeableInputs = inputs.filter((input) => {
1718
- const isCoinOrMessage = "owner" in input || "sender" in input;
1719
- if (isCoinOrMessage) {
1720
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1721
- return true;
1722
- }
1723
- if (!witnessCache.includes(input.witnessIndex)) {
1724
- witnessCache.push(input.witnessIndex);
1725
- return true;
1726
- }
1727
- }
1728
- return false;
1729
- });
1730
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1731
- const totalGas = chargeableInputs.reduce((total, input) => {
1625
+ const totalGas = inputs.reduce((total, input) => {
1732
1626
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1733
1627
  return total.add(
1734
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1628
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1735
1629
  );
1736
1630
  }
1737
- return total.add(gasCosts.ecr1);
1738
- }, (0, import_math5.bn)(0));
1631
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1632
+ witnessCache.push(input.witnessIndex);
1633
+ return total.add(gasCosts.ecr1);
1634
+ }
1635
+ return total;
1636
+ }, (0, import_math5.bn)());
1739
1637
  return totalGas;
1740
1638
  }
1741
1639
  function getMinGas(params) {
@@ -1747,20 +1645,12 @@ function getMinGas(params) {
1747
1645
  return minGas;
1748
1646
  }
1749
1647
  function getMaxGas(params) {
1750
- const {
1751
- gasPerByte,
1752
- witnessesLength,
1753
- witnessLimit,
1754
- minGas,
1755
- gasLimit = (0, import_math5.bn)(0),
1756
- maxGasPerTx
1757
- } = params;
1648
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1758
1649
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1759
1650
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1760
1651
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1761
1652
  }
1762
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1763
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1653
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1764
1654
  }
1765
1655
  function calculateMetadataGasForTxCreate({
1766
1656
  gasCosts,
@@ -1782,10 +1672,6 @@ function calculateMetadataGasForTxScript({
1782
1672
  }) {
1783
1673
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1784
1674
  }
1785
- var calculateGasFee = (params) => {
1786
- const { gas, gasPrice, priceFactor, tip } = params;
1787
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1788
- };
1789
1675
 
1790
1676
  // src/providers/utils/json.ts
1791
1677
  var import_utils7 = require("@fuel-ts/utils");
@@ -1934,7 +1820,7 @@ var witnessify = (value) => {
1934
1820
  // src/providers/transaction-request/transaction-request.ts
1935
1821
  var BaseTransactionRequest = class {
1936
1822
  /** Gas price for transaction */
1937
- tip;
1823
+ gasPrice;
1938
1824
  /** Block until which tx cannot be included */
1939
1825
  maturity;
1940
1826
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1953,7 +1839,7 @@ var BaseTransactionRequest = class {
1953
1839
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1954
1840
  */
1955
1841
  constructor({
1956
- tip,
1842
+ gasPrice,
1957
1843
  maturity,
1958
1844
  maxFee,
1959
1845
  witnessLimit,
@@ -1961,7 +1847,7 @@ var BaseTransactionRequest = class {
1961
1847
  outputs,
1962
1848
  witnesses
1963
1849
  } = {}) {
1964
- this.tip = (0, import_math7.bn)(tip);
1850
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1965
1851
  this.maturity = maturity ?? 0;
1966
1852
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1967
1853
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1972,9 +1858,9 @@ var BaseTransactionRequest = class {
1972
1858
  static getPolicyMeta(req) {
1973
1859
  let policyTypes = 0;
1974
1860
  const policies = [];
1975
- if (req.tip) {
1976
- policyTypes += import_transactions6.PolicyType.Tip;
1977
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1861
+ if (req.gasPrice) {
1862
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1863
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1978
1864
  }
1979
1865
  if (req.witnessLimit) {
1980
1866
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2158,11 +2044,13 @@ var BaseTransactionRequest = class {
2158
2044
  * assetId, if one it was not added yet.
2159
2045
  *
2160
2046
  * @param coin - Coin resource.
2047
+ * @param predicate - Predicate bytes.
2048
+ * @param predicateData - Predicate data bytes.
2161
2049
  */
2162
- addCoinInput(coin) {
2050
+ addCoinInput(coin, predicate) {
2163
2051
  const { assetId, owner, amount } = coin;
2164
2052
  let witnessIndex;
2165
- if (coin.predicate) {
2053
+ if (predicate) {
2166
2054
  witnessIndex = 0;
2167
2055
  } else {
2168
2056
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2177,7 +2065,8 @@ var BaseTransactionRequest = class {
2177
2065
  amount,
2178
2066
  assetId,
2179
2067
  txPointer: "0x00000000000000000000000000000000",
2180
- witnessIndex
2068
+ witnessIndex,
2069
+ predicate: predicate?.bytes
2181
2070
  };
2182
2071
  this.pushInput(input);
2183
2072
  this.addChangeOutput(owner, assetId);
@@ -2187,12 +2076,14 @@ var BaseTransactionRequest = class {
2187
2076
  * baseAssetId, if one it was not added yet.
2188
2077
  *
2189
2078
  * @param message - Message resource.
2079
+ * @param predicate - Predicate bytes.
2080
+ * @param predicateData - Predicate data bytes.
2190
2081
  */
2191
- addMessageInput(message) {
2082
+ addMessageInput(message, predicate) {
2192
2083
  const { recipient, sender, amount } = message;
2193
2084
  const assetId = import_configs7.BaseAssetId;
2194
2085
  let witnessIndex;
2195
- if (message.predicate) {
2086
+ if (predicate) {
2196
2087
  witnessIndex = 0;
2197
2088
  } else {
2198
2089
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2206,7 +2097,8 @@ var BaseTransactionRequest = class {
2206
2097
  sender: sender.toB256(),
2207
2098
  recipient: recipient.toB256(),
2208
2099
  amount,
2209
- witnessIndex
2100
+ witnessIndex,
2101
+ predicate: predicate?.bytes
2210
2102
  };
2211
2103
  this.pushInput(input);
2212
2104
  this.addChangeOutput(recipient, assetId);
@@ -2237,6 +2129,32 @@ var BaseTransactionRequest = class {
2237
2129
  resources.forEach((resource) => this.addResource(resource));
2238
2130
  return this;
2239
2131
  }
2132
+ /**
2133
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2134
+ * outputs from the related assetIds.
2135
+ *
2136
+ * @param resources - The resources to add.
2137
+ * @returns This transaction.
2138
+ */
2139
+ addPredicateResource(resource, predicate) {
2140
+ if (isCoin(resource)) {
2141
+ this.addCoinInput(resource, predicate);
2142
+ } else {
2143
+ this.addMessageInput(resource, predicate);
2144
+ }
2145
+ return this;
2146
+ }
2147
+ /**
2148
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2149
+ * from the related assetIds.
2150
+ *
2151
+ * @param resources - The resources to add.
2152
+ * @returns This transaction.
2153
+ */
2154
+ addPredicateResources(resources, predicate) {
2155
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2156
+ return this;
2157
+ }
2240
2158
  /**
2241
2159
  * Adds a coin output to the transaction.
2242
2160
  *
@@ -2316,7 +2234,7 @@ var BaseTransactionRequest = class {
2316
2234
  }
2317
2235
  calculateMaxGas(chainInfo, minGas) {
2318
2236
  const { consensusParameters } = chainInfo;
2319
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2237
+ const { gasPerByte } = consensusParameters;
2320
2238
  const witnessesLength = this.toTransaction().witnesses.reduce(
2321
2239
  (acc, wit) => acc + wit.dataLength,
2322
2240
  0
@@ -2325,8 +2243,7 @@ var BaseTransactionRequest = class {
2325
2243
  gasPerByte,
2326
2244
  minGas,
2327
2245
  witnessesLength,
2328
- witnessLimit: this.witnessLimit,
2329
- maxGasPerTx
2246
+ witnessLimit: this.witnessLimit
2330
2247
  });
2331
2248
  }
2332
2249
  /**
@@ -2344,20 +2261,17 @@ var BaseTransactionRequest = class {
2344
2261
  });
2345
2262
  const updateAssetInput = (assetId, quantity) => {
2346
2263
  const assetInput = findAssetInput(assetId);
2347
- let usedQuantity = quantity;
2348
- if (assetId === import_configs7.BaseAssetId) {
2349
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2350
- }
2351
2264
  if (assetInput && "assetId" in assetInput) {
2352
2265
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2353
- assetInput.amount = usedQuantity;
2266
+ assetInput.amount = quantity;
2354
2267
  } else {
2355
2268
  this.addResources([
2356
2269
  {
2357
2270
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2358
- amount: usedQuantity,
2271
+ amount: quantity,
2359
2272
  assetId,
2360
2273
  owner: resourcesOwner || import_address.Address.fromRandom(),
2274
+ maturity: 0,
2361
2275
  blockCreated: (0, import_math7.bn)(1),
2362
2276
  txCreatedIdx: (0, import_math7.bn)(1)
2363
2277
  }
@@ -2389,7 +2303,7 @@ var BaseTransactionRequest = class {
2389
2303
  toJSON() {
2390
2304
  return normalizeJSON(this);
2391
2305
  }
2392
- updatePredicateGasUsed(inputs) {
2306
+ updatePredicateInputs(inputs) {
2393
2307
  this.inputs.forEach((i) => {
2394
2308
  let correspondingInput;
2395
2309
  switch (i.type) {
@@ -2411,15 +2325,6 @@ var BaseTransactionRequest = class {
2411
2325
  }
2412
2326
  });
2413
2327
  }
2414
- shiftPredicateData() {
2415
- this.inputs.forEach((input) => {
2416
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2417
- input.predicateData = input.paddPredicateData(
2418
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2419
- );
2420
- }
2421
- });
2422
- }
2423
2328
  };
2424
2329
 
2425
2330
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2566,8 +2471,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2566
2471
  return {
2567
2472
  type: import_transactions8.TransactionType.Create,
2568
2473
  ...baseTransaction,
2474
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2569
2475
  bytecodeWitnessIndex,
2570
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2476
+ storageSlotsCount: storageSlots.length,
2571
2477
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2572
2478
  storageSlots
2573
2479
  };
@@ -2690,8 +2596,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2690
2596
  type: import_transactions9.TransactionType.Script,
2691
2597
  scriptGasLimit: this.gasLimit,
2692
2598
  ...super.getBaseTransaction(),
2693
- scriptLength: (0, import_math10.bn)(script.length),
2694
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2599
+ scriptLength: script.length,
2600
+ scriptDataLength: scriptData.length,
2695
2601
  receiptsRoot: import_configs10.ZeroBytes32,
2696
2602
  script: (0, import_utils15.hexlify)(script),
2697
2603
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2755,7 +2661,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2755
2661
  }
2756
2662
  calculateMaxGas(chainInfo, minGas) {
2757
2663
  const { consensusParameters } = chainInfo;
2758
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2664
+ const { gasPerByte } = consensusParameters;
2759
2665
  const witnessesLength = this.toTransaction().witnesses.reduce(
2760
2666
  (acc, wit) => acc + wit.dataLength,
2761
2667
  0
@@ -2765,8 +2671,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2765
2671
  minGas,
2766
2672
  witnessesLength,
2767
2673
  witnessLimit: this.witnessLimit,
2768
- gasLimit: this.gasLimit,
2769
- maxGasPerTx
2674
+ gasLimit: this.gasLimit
2770
2675
  });
2771
2676
  }
2772
2677
  /**
@@ -2841,32 +2746,15 @@ var transactionRequestify = (obj) => {
2841
2746
  }
2842
2747
  }
2843
2748
  };
2844
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2845
- (acc, input) => {
2846
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2847
- acc.utxos.push(input.id);
2848
- }
2849
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2850
- acc.messages.push(input.nonce);
2851
- }
2852
- return acc;
2853
- },
2854
- {
2855
- utxos: [],
2856
- messages: []
2857
- }
2858
- );
2859
2749
 
2860
2750
  // src/providers/transaction-response/transaction-response.ts
2861
2751
  var import_errors13 = require("@fuel-ts/errors");
2862
- var import_math15 = require("@fuel-ts/math");
2863
- var import_transactions18 = require("@fuel-ts/transactions");
2864
- var import_utils20 = require("@fuel-ts/utils");
2752
+ var import_math14 = require("@fuel-ts/math");
2753
+ var import_transactions17 = require("@fuel-ts/transactions");
2754
+ var import_utils21 = require("@fuel-ts/utils");
2865
2755
 
2866
2756
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2867
- var import_math14 = require("@fuel-ts/math");
2868
- var import_transactions16 = require("@fuel-ts/transactions");
2869
- var import_utils18 = require("@fuel-ts/utils");
2757
+ var import_utils19 = require("@fuel-ts/utils");
2870
2758
 
2871
2759
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2872
2760
  var import_math11 = require("@fuel-ts/math");
@@ -2874,10 +2762,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2874
2762
  var import_utils16 = require("@fuel-ts/utils");
2875
2763
  var calculateTransactionFee = (params) => {
2876
2764
  const {
2877
- gasPrice,
2765
+ gasUsed,
2878
2766
  rawPayload,
2879
- tip,
2880
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2767
+ consensusParameters: { gasCosts, feeParams }
2881
2768
  } = params;
2882
2769
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2883
2770
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2887,7 +2774,8 @@ var calculateTransactionFee = (params) => {
2887
2774
  return {
2888
2775
  fee: (0, import_math11.bn)(0),
2889
2776
  minFee: (0, import_math11.bn)(0),
2890
- maxFee: (0, import_math11.bn)(0)
2777
+ maxFee: (0, import_math11.bn)(0),
2778
+ feeFromGasUsed: (0, import_math11.bn)(0)
2891
2779
  };
2892
2780
  }
2893
2781
  const { type, witnesses, inputs, policies } = transaction;
@@ -2919,6 +2807,7 @@ var calculateTransactionFee = (params) => {
2919
2807
  metadataGas,
2920
2808
  txBytesSize: transactionBytes.length
2921
2809
  });
2810
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2922
2811
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2923
2812
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2924
2813
  const maxGas = getMaxGas({
@@ -2926,25 +2815,17 @@ var calculateTransactionFee = (params) => {
2926
2815
  minGas,
2927
2816
  witnessesLength,
2928
2817
  gasLimit,
2929
- witnessLimit,
2930
- maxGasPerTx
2931
- });
2932
- const minFee = calculateGasFee({
2933
- gasPrice,
2934
- gas: minGas,
2935
- priceFactor: gasPriceFactor,
2936
- tip
2937
- });
2938
- const maxFee = calculateGasFee({
2939
- gasPrice,
2940
- gas: maxGas,
2941
- priceFactor: gasPriceFactor,
2942
- tip
2818
+ witnessLimit
2943
2819
  });
2820
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2821
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2822
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2823
+ const fee = minFee.add(feeFromGasUsed);
2944
2824
  return {
2825
+ fee,
2945
2826
  minFee,
2946
2827
  maxFee,
2947
- fee: maxFee
2828
+ feeFromGasUsed
2948
2829
  };
2949
2830
  };
2950
2831
 
@@ -3558,12 +3439,10 @@ function assembleTransactionSummary(params) {
3558
3439
  gqlTransactionStatus,
3559
3440
  abiMap = {},
3560
3441
  maxInputs,
3561
- gasCosts,
3562
- maxGasPerTx,
3563
- gasPrice
3442
+ gasCosts
3564
3443
  } = params;
3565
3444
  const gasUsed = getGasUsedFromReceipts(receipts);
3566
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3445
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3567
3446
  const operations = getOperations({
3568
3447
  transactionType: transaction.type,
3569
3448
  inputs: transaction.inputs || [],
@@ -3574,14 +3453,11 @@ function assembleTransactionSummary(params) {
3574
3453
  maxInputs
3575
3454
  });
3576
3455
  const typeName = getTransactionTypeName(transaction.type);
3577
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3578
3456
  const { fee } = calculateTransactionFee({
3579
- gasPrice,
3457
+ gasUsed,
3580
3458
  rawPayload,
3581
- tip,
3582
3459
  consensusParameters: {
3583
3460
  gasCosts,
3584
- maxGasPerTx,
3585
3461
  feeParams: {
3586
3462
  gasPerByte,
3587
3463
  gasPriceFactor
@@ -3593,7 +3469,7 @@ function assembleTransactionSummary(params) {
3593
3469
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3594
3470
  let date;
3595
3471
  if (time) {
3596
- date = import_utils18.DateTime.fromTai64(time);
3472
+ date = import_utils19.DateTime.fromTai64(time);
3597
3473
  }
3598
3474
  const transactionSummary = {
3599
3475
  id,
@@ -3621,12 +3497,12 @@ function assembleTransactionSummary(params) {
3621
3497
 
3622
3498
  // src/providers/transaction-response/getDecodedLogs.ts
3623
3499
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3624
- var import_transactions17 = require("@fuel-ts/transactions");
3500
+ var import_transactions16 = require("@fuel-ts/transactions");
3625
3501
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3626
3502
  return receipts.reduce((logs, receipt) => {
3627
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3503
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3628
3504
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3629
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3505
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3630
3506
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3631
3507
  logs.push(decodedLog);
3632
3508
  }
@@ -3641,7 +3517,7 @@ var TransactionResponse = class {
3641
3517
  /** Current provider */
3642
3518
  provider;
3643
3519
  /** Gas used on the transaction */
3644
- gasUsed = (0, import_math15.bn)(0);
3520
+ gasUsed = (0, import_math14.bn)(0);
3645
3521
  /** The graphql Transaction with receipts object. */
3646
3522
  gqlTransaction;
3647
3523
  abis;
@@ -3699,8 +3575,8 @@ var TransactionResponse = class {
3699
3575
  * @returns The decoded transaction.
3700
3576
  */
3701
3577
  decodeTransaction(transactionWithReceipts) {
3702
- return new import_transactions18.TransactionCoder().decode(
3703
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3578
+ return new import_transactions17.TransactionCoder().decode(
3579
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3704
3580
  0
3705
3581
  )?.[0];
3706
3582
  }
@@ -3719,27 +3595,20 @@ var TransactionResponse = class {
3719
3595
  const decodedTransaction = this.decodeTransaction(
3720
3596
  transaction
3721
3597
  );
3722
- let txReceipts = [];
3723
- if (transaction?.status && "receipts" in transaction.status) {
3724
- txReceipts = transaction.status.receipts;
3725
- }
3726
- const receipts = txReceipts.map(processGqlReceipt) || [];
3727
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3728
- const gasPrice = await this.provider.getLatestGasPrice();
3598
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3599
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3729
3600
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3730
3601
  const transactionSummary = assembleTransactionSummary({
3731
3602
  id: this.id,
3732
3603
  receipts,
3733
3604
  transaction: decodedTransaction,
3734
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3605
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3735
3606
  gqlTransactionStatus: transaction.status,
3736
3607
  gasPerByte,
3737
3608
  gasPriceFactor,
3738
3609
  abiMap: contractsAbiMap,
3739
3610
  maxInputs,
3740
- gasCosts,
3741
- maxGasPerTx,
3742
- gasPrice
3611
+ gasCosts
3743
3612
  });
3744
3613
  return transactionSummary;
3745
3614
  }
@@ -3866,29 +3735,29 @@ var processGqlChain = (chain) => {
3866
3735
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3867
3736
  return {
3868
3737
  name,
3869
- baseChainHeight: (0, import_math16.bn)(daHeight),
3738
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3870
3739
  consensusParameters: {
3871
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3872
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3873
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3874
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3875
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3876
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3877
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3878
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3879
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3880
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3881
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3882
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3883
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3884
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3885
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3740
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3741
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3742
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3743
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3744
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3745
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3746
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3747
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3748
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3749
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3750
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3751
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3752
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3753
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3754
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3886
3755
  gasCosts
3887
3756
  },
3888
3757
  gasCosts,
3889
3758
  latestBlock: {
3890
3759
  id: latestBlock.id,
3891
- height: (0, import_math16.bn)(latestBlock.height),
3760
+ height: (0, import_math15.bn)(latestBlock.header.height),
3892
3761
  time: latestBlock.header.time,
3893
3762
  transactions: latestBlock.transactions.map((i) => ({
3894
3763
  id: i.id
@@ -3982,8 +3851,10 @@ var _Provider = class {
3982
3851
  * Returns some helpful parameters related to gas fees.
3983
3852
  */
3984
3853
  getGasConfig() {
3854
+ const { minGasPrice } = this.getNode();
3985
3855
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3986
3856
  return {
3857
+ minGasPrice,
3987
3858
  maxGasPerTx,
3988
3859
  maxGasPerPredicate,
3989
3860
  gasPriceFactor,
@@ -4081,7 +3952,7 @@ var _Provider = class {
4081
3952
  */
4082
3953
  async getBlockNumber() {
4083
3954
  const { chain } = await this.operations.getChain();
4084
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3955
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4085
3956
  }
4086
3957
  /**
4087
3958
  * Returns the chain information.
@@ -4091,11 +3962,13 @@ var _Provider = class {
4091
3962
  async fetchNode() {
4092
3963
  const { nodeInfo } = await this.operations.getNodeInfo();
4093
3964
  const processedNodeInfo = {
4094
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4095
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3965
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3966
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3967
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4096
3968
  nodeVersion: nodeInfo.nodeVersion,
4097
3969
  utxoValidation: nodeInfo.utxoValidation,
4098
- vmBacktrace: nodeInfo.vmBacktrace
3970
+ vmBacktrace: nodeInfo.vmBacktrace,
3971
+ peers: nodeInfo.peers
4099
3972
  };
4100
3973
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4101
3974
  return processedNodeInfo;
@@ -4137,9 +4010,9 @@ var _Provider = class {
4137
4010
  if (estimateTxDependencies) {
4138
4011
  await this.estimateTxDependencies(transactionRequest);
4139
4012
  }
4140
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4013
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4141
4014
  let abis;
4142
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4015
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4143
4016
  abis = transactionRequest.abis;
4144
4017
  }
4145
4018
  if (awaitExecution) {
@@ -4180,14 +4053,15 @@ var _Provider = class {
4180
4053
  if (estimateTxDependencies) {
4181
4054
  return this.estimateTxDependencies(transactionRequest);
4182
4055
  }
4183
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4184
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4185
- encodedTransactions: encodedTransaction,
4056
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4057
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4058
+ encodedTransaction,
4186
4059
  utxoValidation: utxoValidation || false
4187
4060
  });
4188
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4189
- const receipts = rawReceipts.map(processGqlReceipt);
4190
- return { receipts, dryrunStatus: status };
4061
+ const receipts = gqlReceipts.map(processGqlReceipt);
4062
+ return {
4063
+ receipts
4064
+ };
4191
4065
  }
4192
4066
  /**
4193
4067
  * Verifies whether enough gas is available to complete transaction.
@@ -4198,13 +4072,13 @@ var _Provider = class {
4198
4072
  async estimatePredicates(transactionRequest) {
4199
4073
  const shouldEstimatePredicates = Boolean(
4200
4074
  transactionRequest.inputs.find(
4201
- (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()
4075
+ (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()
4202
4076
  )
4203
4077
  );
4204
4078
  if (!shouldEstimatePredicates) {
4205
4079
  return transactionRequest;
4206
4080
  }
4207
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4081
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4208
4082
  const response = await this.operations.estimatePredicates({
4209
4083
  encodedTransaction
4210
4084
  });
@@ -4213,7 +4087,7 @@ var _Provider = class {
4213
4087
  } = response;
4214
4088
  if (inputs) {
4215
4089
  inputs.forEach((input, index) => {
4216
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4090
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4217
4091
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4218
4092
  }
4219
4093
  });
@@ -4226,31 +4100,31 @@ var _Provider = class {
4226
4100
  * If there are missing variable outputs,
4227
4101
  * `addVariableOutputs` is called on the transaction.
4228
4102
  *
4103
+ * @privateRemarks
4104
+ * TODO: Investigate support for missing contract IDs
4105
+ * TODO: Add support for missing output messages
4229
4106
  *
4230
4107
  * @param transactionRequest - The transaction request object.
4231
4108
  * @returns A promise.
4232
4109
  */
4233
4110
  async estimateTxDependencies(transactionRequest) {
4234
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4111
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4235
4112
  return {
4236
4113
  receipts: [],
4237
4114
  outputVariables: 0,
4238
4115
  missingContractIds: []
4239
4116
  };
4240
4117
  }
4118
+ await this.estimatePredicates(transactionRequest);
4241
4119
  let receipts = [];
4242
4120
  const missingContractIds = [];
4243
4121
  let outputVariables = 0;
4244
- let dryrunStatus;
4245
4122
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4246
- const {
4247
- dryRun: [{ receipts: rawReceipts, status }]
4248
- } = await this.operations.dryRun({
4249
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4123
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4124
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4250
4125
  utxoValidation: false
4251
4126
  });
4252
- receipts = rawReceipts.map(processGqlReceipt);
4253
- dryrunStatus = status;
4127
+ receipts = gqlReceipts.map(processGqlReceipt);
4254
4128
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4255
4129
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4256
4130
  if (hasMissingOutputs) {
@@ -4260,10 +4134,6 @@ var _Provider = class {
4260
4134
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4261
4135
  missingContractIds.push(contractId);
4262
4136
  });
4263
- const { maxFee } = await this.estimateTxGasAndFee({
4264
- transactionRequest
4265
- });
4266
- transactionRequest.maxFee = maxFee;
4267
4137
  } else {
4268
4138
  break;
4269
4139
  }
@@ -4271,139 +4141,37 @@ var _Provider = class {
4271
4141
  return {
4272
4142
  receipts,
4273
4143
  outputVariables,
4274
- missingContractIds,
4275
- dryrunStatus
4144
+ missingContractIds
4276
4145
  };
4277
4146
  }
4278
- /**
4279
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4280
- *
4281
- * Transactions are dry run in batches. After each dry run, transactions requiring
4282
- * further modifications are identified. The method iteratively updates these transactions
4283
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4284
- *
4285
- * @param transactionRequests - Array of transaction request objects.
4286
- * @returns A promise that resolves to an array of results for each transaction.
4287
- */
4288
- async estimateMultipleTxDependencies(transactionRequests) {
4289
- const results = transactionRequests.map(() => ({
4290
- receipts: [],
4291
- outputVariables: 0,
4292
- missingContractIds: [],
4293
- dryrunStatus: void 0
4294
- }));
4295
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4296
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4297
- allRequests.forEach((req, index) => {
4298
- if (req.type === import_transactions19.TransactionType.Script) {
4299
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4300
- }
4301
- });
4302
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4303
- let attempt = 0;
4304
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4305
- const encodedTransactions = transactionsToProcess.map(
4306
- (index) => serializedTransactionsMap.get(index)
4307
- );
4308
- const dryRunResults = await this.operations.dryRun({
4309
- encodedTransactions,
4310
- utxoValidation: false
4311
- });
4312
- const nextRoundTransactions = [];
4313
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4314
- const currentResultIndex = transactionsToProcess[i];
4315
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4316
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4317
- results[currentResultIndex].dryrunStatus = status;
4318
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4319
- results[currentResultIndex].receipts
4320
- );
4321
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4322
- const requestToProcess = allRequests[currentResultIndex];
4323
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4324
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4325
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4326
- missingOutputContractIds.forEach(({ contractId }) => {
4327
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4328
- results[currentResultIndex].missingContractIds.push(contractId);
4329
- });
4330
- const { maxFee } = await this.estimateTxGasAndFee({
4331
- transactionRequest: requestToProcess
4332
- });
4333
- requestToProcess.maxFee = maxFee;
4334
- serializedTransactionsMap.set(
4335
- currentResultIndex,
4336
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4337
- );
4338
- nextRoundTransactions.push(currentResultIndex);
4339
- allRequests[currentResultIndex] = requestToProcess;
4340
- }
4341
- }
4342
- transactionsToProcess = nextRoundTransactions;
4343
- attempt += 1;
4344
- }
4345
- return results;
4346
- }
4347
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4348
- if (estimateTxDependencies) {
4349
- return this.estimateMultipleTxDependencies(transactionRequests);
4350
- }
4351
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4352
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4353
- encodedTransactions,
4354
- utxoValidation: utxoValidation || false
4355
- });
4356
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4357
- const receipts = rawReceipts.map(processGqlReceipt);
4358
- return { receipts, dryrunStatus: status };
4359
- });
4360
- return results;
4361
- }
4362
4147
  /**
4363
4148
  * Estimates the transaction gas and fee based on the provided transaction request.
4364
4149
  * @param transactionRequest - The transaction request object.
4365
4150
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4366
4151
  */
4367
- async estimateTxGasAndFee(params) {
4152
+ estimateTxGasAndFee(params) {
4368
4153
  const { transactionRequest } = params;
4369
- let { gasPrice } = params;
4154
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4370
4155
  const chainInfo = this.getChain();
4371
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4156
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4157
+ transactionRequest.gasPrice = gasPrice;
4372
4158
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4373
- if (!gasPrice) {
4374
- gasPrice = await this.estimateGasPrice(10);
4375
- }
4376
- const minFee = calculateGasFee({
4377
- gasPrice: (0, import_math16.bn)(gasPrice),
4378
- gas: minGas,
4379
- priceFactor: gasPriceFactor,
4380
- tip: transactionRequest.tip
4381
- }).add(1);
4382
- let gasLimit = (0, import_math16.bn)(0);
4383
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4384
- gasLimit = transactionRequest.gasLimit;
4159
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4160
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4385
4161
  if (transactionRequest.gasLimit.eq(0)) {
4386
4162
  transactionRequest.gasLimit = minGas;
4387
4163
  transactionRequest.gasLimit = maxGasPerTx.sub(
4388
4164
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4389
4165
  );
4390
- gasLimit = transactionRequest.gasLimit;
4391
4166
  }
4392
4167
  }
4393
4168
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4394
- const maxFee = calculateGasFee({
4395
- gasPrice: (0, import_math16.bn)(gasPrice),
4396
- gas: maxGas,
4397
- priceFactor: gasPriceFactor,
4398
- tip: transactionRequest.tip
4399
- }).add(1);
4169
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4400
4170
  return {
4401
4171
  minGas,
4402
4172
  minFee,
4403
4173
  maxGas,
4404
- maxFee,
4405
- gasPrice,
4406
- gasLimit
4174
+ maxFee
4407
4175
  };
4408
4176
  }
4409
4177
  /**
@@ -4421,17 +4189,15 @@ var _Provider = class {
4421
4189
  if (estimateTxDependencies) {
4422
4190
  return this.estimateTxDependencies(transactionRequest);
4423
4191
  }
4424
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4425
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4426
- encodedTransactions,
4192
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4193
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4194
+ encodedTransaction,
4427
4195
  utxoValidation: true
4428
4196
  });
4429
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4430
- const { id, receipts, status } = dryRunStatus;
4431
- const processedReceipts = receipts.map(processGqlReceipt);
4432
- return { id, receipts: processedReceipts, status };
4433
- });
4434
- return { receipts: callResult[0].receipts };
4197
+ const receipts = gqlReceipts.map(processGqlReceipt);
4198
+ return {
4199
+ receipts
4200
+ };
4435
4201
  }
4436
4202
  /**
4437
4203
  * Returns a transaction cost to enable user
@@ -4448,79 +4214,77 @@ var _Provider = class {
4448
4214
  * @param tolerance - The tolerance to add on top of the gasUsed.
4449
4215
  * @returns A promise that resolves to the transaction cost object.
4450
4216
  */
4451
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4217
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4218
+ estimateTxDependencies = true,
4219
+ estimatePredicates = true,
4220
+ resourcesOwner,
4221
+ signatureCallback
4222
+ } = {}) {
4452
4223
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4453
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4224
+ const { minGasPrice } = this.getGasConfig();
4225
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4226
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4454
4227
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4455
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4228
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4456
4229
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4457
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4458
4230
  if (isScriptTransaction) {
4459
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4231
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4460
4232
  }
4461
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4462
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4233
+ if (estimatePredicates) {
4234
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4235
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4236
+ }
4237
+ await this.estimatePredicates(txRequestClone);
4463
4238
  }
4464
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4465
- let addedSignatures = 0;
4466
4239
  if (signatureCallback && isScriptTransaction) {
4467
- const lengthBefore = signedRequest.witnesses.length;
4468
- await signatureCallback(signedRequest);
4469
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4240
+ await signatureCallback(txRequestClone);
4470
4241
  }
4471
- await this.estimatePredicates(signedRequest);
4472
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4473
- transactionRequest: signedRequest
4242
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4243
+ transactionRequest: txRequestClone
4474
4244
  });
4475
4245
  let receipts = [];
4476
4246
  let missingContractIds = [];
4477
4247
  let outputVariables = 0;
4478
- let gasUsed = (0, import_math16.bn)(0);
4479
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4480
- txRequestClone.maxFee = maxFee;
4481
- if (isScriptTransaction) {
4482
- txRequestClone.gasLimit = gasLimit;
4483
- if (signatureCallback) {
4484
- await signatureCallback(txRequestClone);
4485
- }
4248
+ let gasUsed = (0, import_math15.bn)(0);
4249
+ if (isScriptTransaction && estimateTxDependencies) {
4250
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4486
4251
  const result = await this.estimateTxDependencies(txRequestClone);
4487
4252
  receipts = result.receipts;
4488
4253
  outputVariables = result.outputVariables;
4489
4254
  missingContractIds = result.missingContractIds;
4490
4255
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4491
4256
  txRequestClone.gasLimit = gasUsed;
4492
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4493
- transactionRequest: txRequestClone,
4494
- gasPrice
4257
+ txRequestClone.gasPrice = setGasPrice;
4258
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4259
+ transactionRequest: txRequestClone
4495
4260
  }));
4496
4261
  }
4497
4262
  return {
4498
4263
  requiredQuantities: allQuantities,
4499
4264
  receipts,
4500
4265
  gasUsed,
4501
- gasPrice,
4266
+ minGasPrice,
4267
+ gasPrice: setGasPrice,
4502
4268
  minGas,
4503
4269
  maxGas,
4504
4270
  minFee,
4505
4271
  maxFee,
4272
+ estimatedInputs: txRequestClone.inputs,
4506
4273
  outputVariables,
4507
- missingContractIds,
4508
- addedSignatures,
4509
- estimatedPredicates: txRequestClone.inputs
4274
+ missingContractIds
4510
4275
  };
4511
4276
  }
4512
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4277
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4513
4278
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4514
4279
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4515
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4516
- quantitiesToContract
4517
- });
4280
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4518
4281
  transactionRequest.addResources(
4519
4282
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4520
4283
  );
4521
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4522
- quantitiesToContract
4523
- });
4284
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4285
+ transactionRequest,
4286
+ forwardingQuantities
4287
+ );
4524
4288
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4525
4289
  return {
4526
4290
  resources,
@@ -4536,16 +4300,17 @@ var _Provider = class {
4536
4300
  const result = await this.operations.getCoins({
4537
4301
  first: 10,
4538
4302
  ...paginationArgs,
4539
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4303
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4540
4304
  });
4541
4305
  const coins = result.coins.edges.map((edge) => edge.node);
4542
4306
  return coins.map((coin) => ({
4543
4307
  id: coin.utxoId,
4544
4308
  assetId: coin.assetId,
4545
- amount: (0, import_math16.bn)(coin.amount),
4309
+ amount: (0, import_math15.bn)(coin.amount),
4546
4310
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4547
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4548
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4311
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4312
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4313
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4549
4314
  }));
4550
4315
  }
4551
4316
  /**
@@ -4559,19 +4324,19 @@ var _Provider = class {
4559
4324
  async getResourcesToSpend(owner, quantities, excludedIds) {
4560
4325
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4561
4326
  const excludeInput = {
4562
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4563
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4327
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4328
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4564
4329
  };
4565
4330
  if (this.cache) {
4566
4331
  const uniqueUtxos = new Set(
4567
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4332
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4568
4333
  );
4569
4334
  excludeInput.utxos = Array.from(uniqueUtxos);
4570
4335
  }
4571
4336
  const coinsQuery = {
4572
4337
  owner: ownerAddress.toB256(),
4573
4338
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4574
- assetId: (0, import_utils22.hexlify)(assetId),
4339
+ assetId: (0, import_utils23.hexlify)(assetId),
4575
4340
  amount: amount.toString(10),
4576
4341
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4577
4342
  })),
@@ -4582,9 +4347,9 @@ var _Provider = class {
4582
4347
  switch (coin.__typename) {
4583
4348
  case "MessageCoin":
4584
4349
  return {
4585
- amount: (0, import_math16.bn)(coin.amount),
4350
+ amount: (0, import_math15.bn)(coin.amount),
4586
4351
  assetId: coin.assetId,
4587
- daHeight: (0, import_math16.bn)(coin.daHeight),
4352
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4588
4353
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4589
4354
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4590
4355
  nonce: coin.nonce
@@ -4592,11 +4357,12 @@ var _Provider = class {
4592
4357
  case "Coin":
4593
4358
  return {
4594
4359
  id: coin.utxoId,
4595
- amount: (0, import_math16.bn)(coin.amount),
4360
+ amount: (0, import_math15.bn)(coin.amount),
4596
4361
  assetId: coin.assetId,
4597
4362
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4598
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4599
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4363
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4364
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4365
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4600
4366
  };
4601
4367
  default:
4602
4368
  return null;
@@ -4613,13 +4379,13 @@ var _Provider = class {
4613
4379
  async getBlock(idOrHeight) {
4614
4380
  let variables;
4615
4381
  if (typeof idOrHeight === "number") {
4616
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4382
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4617
4383
  } else if (idOrHeight === "latest") {
4618
4384
  variables = { height: (await this.getBlockNumber()).toString(10) };
4619
4385
  } else if (idOrHeight.length === 66) {
4620
4386
  variables = { blockId: idOrHeight };
4621
4387
  } else {
4622
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4388
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4623
4389
  }
4624
4390
  const { block } = await this.operations.getBlock(variables);
4625
4391
  if (!block) {
@@ -4627,7 +4393,7 @@ var _Provider = class {
4627
4393
  }
4628
4394
  return {
4629
4395
  id: block.id,
4630
- height: (0, import_math16.bn)(block.height),
4396
+ height: (0, import_math15.bn)(block.header.height),
4631
4397
  time: block.header.time,
4632
4398
  transactionIds: block.transactions.map((tx) => tx.id)
4633
4399
  };
@@ -4642,7 +4408,7 @@ var _Provider = class {
4642
4408
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4643
4409
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4644
4410
  id: block.id,
4645
- height: (0, import_math16.bn)(block.height),
4411
+ height: (0, import_math15.bn)(block.header.height),
4646
4412
  time: block.header.time,
4647
4413
  transactionIds: block.transactions.map((tx) => tx.id)
4648
4414
  }));
@@ -4657,7 +4423,7 @@ var _Provider = class {
4657
4423
  async getBlockWithTransactions(idOrHeight) {
4658
4424
  let variables;
4659
4425
  if (typeof idOrHeight === "number") {
4660
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4426
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4661
4427
  } else if (idOrHeight === "latest") {
4662
4428
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4663
4429
  } else {
@@ -4669,11 +4435,11 @@ var _Provider = class {
4669
4435
  }
4670
4436
  return {
4671
4437
  id: block.id,
4672
- height: (0, import_math16.bn)(block.height, 10),
4438
+ height: (0, import_math15.bn)(block.header.height, 10),
4673
4439
  time: block.header.time,
4674
4440
  transactionIds: block.transactions.map((tx) => tx.id),
4675
4441
  transactions: block.transactions.map(
4676
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4442
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4677
4443
  )
4678
4444
  };
4679
4445
  }
@@ -4688,8 +4454,8 @@ var _Provider = class {
4688
4454
  if (!transaction) {
4689
4455
  return null;
4690
4456
  }
4691
- return new import_transactions19.TransactionCoder().decode(
4692
- (0, import_utils22.arrayify)(transaction.rawPayload),
4457
+ return new import_transactions18.TransactionCoder().decode(
4458
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4693
4459
  0
4694
4460
  )?.[0];
4695
4461
  }
@@ -4716,9 +4482,9 @@ var _Provider = class {
4716
4482
  async getContractBalance(contractId, assetId) {
4717
4483
  const { contractBalance } = await this.operations.getContractBalance({
4718
4484
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4719
- asset: (0, import_utils22.hexlify)(assetId)
4485
+ asset: (0, import_utils23.hexlify)(assetId)
4720
4486
  });
4721
- return (0, import_math16.bn)(contractBalance.amount, 10);
4487
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4722
4488
  }
4723
4489
  /**
4724
4490
  * Returns the balance for the given owner for the given asset ID.
@@ -4730,9 +4496,9 @@ var _Provider = class {
4730
4496
  async getBalance(owner, assetId) {
4731
4497
  const { balance } = await this.operations.getBalance({
4732
4498
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4733
- assetId: (0, import_utils22.hexlify)(assetId)
4499
+ assetId: (0, import_utils23.hexlify)(assetId)
4734
4500
  });
4735
- return (0, import_math16.bn)(balance.amount, 10);
4501
+ return (0, import_math15.bn)(balance.amount, 10);
4736
4502
  }
4737
4503
  /**
4738
4504
  * Returns balances for the given owner.
@@ -4750,7 +4516,7 @@ var _Provider = class {
4750
4516
  const balances = result.balances.edges.map((edge) => edge.node);
4751
4517
  return balances.map((balance) => ({
4752
4518
  assetId: balance.assetId,
4753
- amount: (0, import_math16.bn)(balance.amount)
4519
+ amount: (0, import_math15.bn)(balance.amount)
4754
4520
  }));
4755
4521
  }
4756
4522
  /**
@@ -4768,19 +4534,19 @@ var _Provider = class {
4768
4534
  });
4769
4535
  const messages = result.messages.edges.map((edge) => edge.node);
4770
4536
  return messages.map((message) => ({
4771
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4537
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4772
4538
  sender: message.sender,
4773
4539
  recipient: message.recipient,
4774
4540
  nonce: message.nonce,
4775
- amount: (0, import_math16.bn)(message.amount),
4541
+ amount: (0, import_math15.bn)(message.amount),
4776
4542
  data: message.data
4777
4543
  }),
4778
4544
  sender: import_address3.Address.fromAddressOrString(message.sender),
4779
4545
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4780
4546
  nonce: message.nonce,
4781
- amount: (0, import_math16.bn)(message.amount),
4782
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4783
- daHeight: (0, import_math16.bn)(message.daHeight)
4547
+ amount: (0, import_math15.bn)(message.amount),
4548
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4549
+ daHeight: (0, import_math15.bn)(message.daHeight)
4784
4550
  }));
4785
4551
  }
4786
4552
  /**
@@ -4833,60 +4599,44 @@ var _Provider = class {
4833
4599
  } = result.messageProof;
4834
4600
  return {
4835
4601
  messageProof: {
4836
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4602
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4837
4603
  proofSet: messageProof.proofSet
4838
4604
  },
4839
4605
  blockProof: {
4840
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4606
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4841
4607
  proofSet: blockProof.proofSet
4842
4608
  },
4843
4609
  messageBlockHeader: {
4844
4610
  id: messageBlockHeader.id,
4845
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4846
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4611
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4612
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4847
4613
  transactionsRoot: messageBlockHeader.transactionsRoot,
4848
- height: (0, import_math16.bn)(messageBlockHeader.height),
4614
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4849
4615
  prevRoot: messageBlockHeader.prevRoot,
4850
4616
  time: messageBlockHeader.time,
4851
4617
  applicationHash: messageBlockHeader.applicationHash,
4852
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4853
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4854
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4855
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4856
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4618
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4619
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4857
4620
  },
4858
4621
  commitBlockHeader: {
4859
4622
  id: commitBlockHeader.id,
4860
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4861
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4623
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4624
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4862
4625
  transactionsRoot: commitBlockHeader.transactionsRoot,
4863
- height: (0, import_math16.bn)(commitBlockHeader.height),
4626
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4864
4627
  prevRoot: commitBlockHeader.prevRoot,
4865
4628
  time: commitBlockHeader.time,
4866
4629
  applicationHash: commitBlockHeader.applicationHash,
4867
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4868
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4869
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4870
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4871
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4630
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4631
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4872
4632
  },
4873
4633
  sender: import_address3.Address.fromAddressOrString(sender),
4874
4634
  recipient: import_address3.Address.fromAddressOrString(recipient),
4875
4635
  nonce,
4876
- amount: (0, import_math16.bn)(amount),
4636
+ amount: (0, import_math15.bn)(amount),
4877
4637
  data
4878
4638
  };
4879
4639
  }
4880
- async getLatestGasPrice() {
4881
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4882
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4883
- }
4884
- async estimateGasPrice(blockHorizon) {
4885
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4886
- blockHorizon: String(blockHorizon)
4887
- });
4888
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4889
- }
4890
4640
  /**
4891
4641
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4892
4642
  *
@@ -4906,10 +4656,10 @@ var _Provider = class {
4906
4656
  */
4907
4657
  async produceBlocks(amount, startTime) {
4908
4658
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4909
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4910
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4659
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4660
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4911
4661
  });
4912
- return (0, import_math16.bn)(latestBlockHeight);
4662
+ return (0, import_math15.bn)(latestBlockHeight);
4913
4663
  }
4914
4664
  // eslint-disable-next-line @typescript-eslint/require-await
4915
4665
  async getTransactionResponse(transactionId) {
@@ -4923,7 +4673,7 @@ cacheInputs_fn = function(inputs) {
4923
4673
  return;
4924
4674
  }
4925
4675
  inputs.forEach((input) => {
4926
- if (input.type === import_transactions19.InputType.Coin) {
4676
+ if (input.type === import_transactions18.InputType.Coin) {
4927
4677
  this.cache?.set(input.id);
4928
4678
  }
4929
4679
  });
@@ -4933,9 +4683,9 @@ __publicField(Provider, "nodeInfoCache", {});
4933
4683
 
4934
4684
  // src/providers/transaction-summary/get-transaction-summary.ts
4935
4685
  var import_errors15 = require("@fuel-ts/errors");
4936
- var import_math17 = require("@fuel-ts/math");
4937
- var import_transactions20 = require("@fuel-ts/transactions");
4938
- var import_utils25 = require("@fuel-ts/utils");
4686
+ var import_math16 = require("@fuel-ts/math");
4687
+ var import_transactions19 = require("@fuel-ts/transactions");
4688
+ var import_utils26 = require("@fuel-ts/utils");
4939
4689
  async function getTransactionSummary(params) {
4940
4690
  const { id, provider, abiMap } = params;
4941
4691
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4947,32 +4697,25 @@ async function getTransactionSummary(params) {
4947
4697
  `Transaction not found for given id: ${id}.`
4948
4698
  );
4949
4699
  }
4950
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4951
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4700
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4701
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4952
4702
  0
4953
4703
  );
4954
- let txReceipts = [];
4955
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4956
- txReceipts = gqlTransaction.status.receipts;
4957
- }
4958
- const receipts = txReceipts.map(processGqlReceipt);
4704
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4959
4705
  const {
4960
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4706
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4961
4707
  } = provider.getChain();
4962
- const gasPrice = await provider.getLatestGasPrice();
4963
4708
  const transactionInfo = assembleTransactionSummary({
4964
4709
  id: gqlTransaction.id,
4965
4710
  receipts,
4966
4711
  transaction: decodedTransaction,
4967
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4712
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4968
4713
  gqlTransactionStatus: gqlTransaction.status,
4969
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4970
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4714
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4715
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4971
4716
  abiMap,
4972
4717
  maxInputs,
4973
- gasCosts,
4974
- maxGasPerTx,
4975
- gasPrice
4718
+ gasCosts
4976
4719
  });
4977
4720
  return {
4978
4721
  gqlTransaction,
@@ -4982,11 +4725,10 @@ async function getTransactionSummary(params) {
4982
4725
  async function getTransactionSummaryFromRequest(params) {
4983
4726
  const { provider, transactionRequest, abiMap } = params;
4984
4727
  const { receipts } = await provider.call(transactionRequest);
4985
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4728
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4986
4729
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4987
4730
  const transaction = transactionRequest.toTransaction();
4988
4731
  const transactionBytes = transactionRequest.toTransactionBytes();
4989
- const gasPrice = await provider.getLatestGasPrice();
4990
4732
  const transactionSummary = assembleTransactionSummary({
4991
4733
  receipts,
4992
4734
  transaction,
@@ -4995,9 +4737,7 @@ async function getTransactionSummaryFromRequest(params) {
4995
4737
  gasPerByte,
4996
4738
  gasPriceFactor,
4997
4739
  maxInputs,
4998
- gasCosts,
4999
- maxGasPerTx,
5000
- gasPrice
4740
+ gasCosts
5001
4741
  });
5002
4742
  return transactionSummary;
5003
4743
  }
@@ -5006,31 +4746,24 @@ async function getTransactionsSummaries(params) {
5006
4746
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
5007
4747
  const { edges, pageInfo } = transactionsByOwner;
5008
4748
  const {
5009
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4749
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
5010
4750
  } = provider.getChain();
5011
- const gasPrice = await provider.getLatestGasPrice();
5012
4751
  const transactions = edges.map((edge) => {
5013
4752
  const { node: gqlTransaction } = edge;
5014
- const { id, rawPayload, status } = gqlTransaction;
5015
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5016
- let txReceipts = [];
5017
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5018
- txReceipts = gqlTransaction.status.receipts;
5019
- }
5020
- const receipts = txReceipts.map(processGqlReceipt);
4753
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4754
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4755
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
5021
4756
  const transactionSummary = assembleTransactionSummary({
5022
4757
  id,
5023
4758
  receipts,
5024
4759
  transaction: decodedTransaction,
5025
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4760
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
5026
4761
  gqlTransactionStatus: status,
5027
4762
  abiMap,
5028
4763
  gasPerByte,
5029
4764
  gasPriceFactor,
5030
4765
  maxInputs,
5031
- gasCosts,
5032
- maxGasPerTx,
5033
- gasPrice
4766
+ gasCosts
5034
4767
  });
5035
4768
  const output = {
5036
4769
  gqlTransaction,
@@ -5167,17 +4900,17 @@ var assets = [
5167
4900
 
5168
4901
  // src/utils/formatTransferToContractScriptData.ts
5169
4902
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5170
- var import_math18 = require("@fuel-ts/math");
5171
- var import_utils26 = require("@fuel-ts/utils");
4903
+ var import_math17 = require("@fuel-ts/math");
4904
+ var import_utils27 = require("@fuel-ts/utils");
5172
4905
  var asm = __toESM(require("@fuels/vm-asm"));
5173
4906
  var formatTransferToContractScriptData = (params) => {
5174
4907
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5175
4908
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5176
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4909
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5177
4910
  const scriptData = Uint8Array.from([
5178
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4911
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5179
4912
  ...encoded,
5180
- ...(0, import_utils26.arrayify)(assetId)
4913
+ ...(0, import_utils27.arrayify)(assetId)
5181
4914
  ]);
5182
4915
  return scriptData;
5183
4916
  };
@@ -5362,33 +5095,36 @@ var Account = class extends import_interfaces.AbstractAccount {
5362
5095
  * @param fee - The estimated transaction fee.
5363
5096
  * @returns A promise that resolves when the resources are added to the transaction.
5364
5097
  */
5365
- async fund(request, params) {
5366
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5367
- const txRequest = request;
5368
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5369
- amount: (0, import_math19.bn)(fee),
5098
+ async fund(request, coinQuantities, fee) {
5099
+ const updatedQuantities = addAmountToAsset({
5100
+ amount: (0, import_math18.bn)(fee),
5370
5101
  assetId: import_configs12.BaseAssetId,
5371
- coinQuantities: requiredQuantities
5102
+ coinQuantities
5372
5103
  });
5373
5104
  const quantitiesDict = {};
5374
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5105
+ updatedQuantities.forEach(({ amount, assetId }) => {
5375
5106
  quantitiesDict[assetId] = {
5376
5107
  required: amount,
5377
- owned: (0, import_math19.bn)(0)
5108
+ owned: (0, import_math18.bn)(0)
5378
5109
  };
5379
5110
  });
5380
- txRequest.inputs.forEach((input) => {
5111
+ const cachedUtxos = [];
5112
+ const cachedMessages = [];
5113
+ const owner = this.address.toB256();
5114
+ request.inputs.forEach((input) => {
5381
5115
  const isResource = "amount" in input;
5382
5116
  if (isResource) {
5383
5117
  const isCoin2 = "owner" in input;
5384
5118
  if (isCoin2) {
5385
5119
  const assetId = String(input.assetId);
5386
- if (quantitiesDict[assetId]) {
5387
- const amount = (0, import_math19.bn)(input.amount);
5120
+ if (input.owner === owner && quantitiesDict[assetId]) {
5121
+ const amount = (0, import_math18.bn)(input.amount);
5388
5122
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5123
+ cachedUtxos.push(input.id);
5389
5124
  }
5390
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5125
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5391
5126
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5127
+ cachedMessages.push(input.nonce);
5392
5128
  }
5393
5129
  }
5394
5130
  });
@@ -5403,23 +5139,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5403
5139
  });
5404
5140
  const needsToBeFunded = missingQuantities.length;
5405
5141
  if (needsToBeFunded) {
5406
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5407
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5408
- txRequest.addResources(resources);
5409
- }
5410
- txRequest.shiftPredicateData();
5411
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5412
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5413
- if (addedSignatures) {
5414
- Array.from({ length: addedSignatures }).forEach(
5415
- () => requestToBeReEstimate.addEmptyWitness()
5416
- );
5142
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5143
+ messages: cachedMessages,
5144
+ utxos: cachedUtxos
5145
+ });
5146
+ request.addResources(resources);
5417
5147
  }
5418
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5419
- transactionRequest: requestToBeReEstimate
5420
- });
5421
- txRequest.maxFee = maxFee;
5422
- return txRequest;
5423
5148
  }
5424
5149
  /**
5425
5150
  * A helper that creates a transfer transaction request and returns it.
@@ -5427,25 +5152,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5427
5152
  * @param destination - The address of the destination.
5428
5153
  * @param amount - The amount of coins to transfer.
5429
5154
  * @param assetId - The asset ID of the coins to transfer.
5430
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5155
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5431
5156
  * @returns A promise that resolves to the prepared transaction request.
5432
5157
  */
5433
5158
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5434
- const request = new ScriptTransactionRequest(txParams);
5159
+ const { minGasPrice } = this.provider.getGasConfig();
5160
+ const params = { gasPrice: minGasPrice, ...txParams };
5161
+ const request = new ScriptTransactionRequest(params);
5435
5162
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5436
- const txCost = await this.provider.getTransactionCost(request, {
5163
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5437
5164
  estimateTxDependencies: true,
5438
5165
  resourcesOwner: this
5439
5166
  });
5440
- if ("gasLimit" in txParams) {
5441
- this.validateGas({
5442
- gasUsed: txCost.gasUsed,
5443
- gasLimit: request.gasLimit
5444
- });
5445
- }
5446
- request.gasLimit = txCost.gasUsed;
5447
- request.maxFee = txCost.maxFee;
5448
- await this.fund(request, txCost);
5167
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5168
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5169
+ this.validateGas({
5170
+ gasUsed,
5171
+ gasPrice: request.gasPrice,
5172
+ gasLimit: request.gasLimit,
5173
+ minGasPrice
5174
+ });
5175
+ await this.fund(request, requiredQuantities, maxFee);
5176
+ request.updatePredicateInputs(estimatedInputs);
5449
5177
  return request;
5450
5178
  }
5451
5179
  /**
@@ -5458,7 +5186,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5458
5186
  * @returns A promise that resolves to the transaction response.
5459
5187
  */
5460
5188
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5461
- if ((0, import_math19.bn)(amount).lte(0)) {
5189
+ if ((0, import_math18.bn)(amount).lte(0)) {
5462
5190
  throw new import_errors16.FuelError(
5463
5191
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5464
5192
  "Transfer amount must be a positive number."
@@ -5477,37 +5205,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5477
5205
  * @returns A promise that resolves to the transaction response.
5478
5206
  */
5479
5207
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5480
- if ((0, import_math19.bn)(amount).lte(0)) {
5208
+ if ((0, import_math18.bn)(amount).lte(0)) {
5481
5209
  throw new import_errors16.FuelError(
5482
5210
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5483
5211
  "Transfer amount must be a positive number."
5484
5212
  );
5485
5213
  }
5486
5214
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5215
+ const { minGasPrice } = this.provider.getGasConfig();
5216
+ const params = { gasPrice: minGasPrice, ...txParams };
5487
5217
  const { script, scriptData } = await assembleTransferToContractScript({
5488
5218
  hexlifiedContractId: contractAddress.toB256(),
5489
- amountToTransfer: (0, import_math19.bn)(amount),
5219
+ amountToTransfer: (0, import_math18.bn)(amount),
5490
5220
  assetId
5491
5221
  });
5492
5222
  const request = new ScriptTransactionRequest({
5493
- ...txParams,
5223
+ ...params,
5494
5224
  script,
5495
5225
  scriptData
5496
5226
  });
5497
5227
  request.addContractInputAndOutput(contractAddress);
5498
- const txCost = await this.provider.getTransactionCost(request, {
5499
- resourcesOwner: this,
5500
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5228
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5229
+ request,
5230
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5231
+ );
5232
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5233
+ this.validateGas({
5234
+ gasUsed,
5235
+ gasPrice: request.gasPrice,
5236
+ gasLimit: request.gasLimit,
5237
+ minGasPrice
5501
5238
  });
5502
- if (txParams.gasLimit) {
5503
- this.validateGas({
5504
- gasUsed: txCost.gasUsed,
5505
- gasLimit: request.gasLimit
5506
- });
5507
- }
5508
- request.gasLimit = txCost.gasUsed;
5509
- request.maxFee = txCost.maxFee;
5510
- await this.fund(request, txCost);
5239
+ await this.fund(request, requiredQuantities, maxFee);
5511
5240
  return this.sendTransaction(request);
5512
5241
  }
5513
5242
  /**
@@ -5519,31 +5248,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5519
5248
  * @returns A promise that resolves to the transaction response.
5520
5249
  */
5521
5250
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5251
+ const { minGasPrice } = this.provider.getGasConfig();
5522
5252
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5523
- const recipientDataArray = (0, import_utils27.arrayify)(
5253
+ const recipientDataArray = (0, import_utils28.arrayify)(
5524
5254
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5525
5255
  );
5526
- const amountDataArray = (0, import_utils27.arrayify)(
5527
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5256
+ const amountDataArray = (0, import_utils28.arrayify)(
5257
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5528
5258
  );
5529
5259
  const script = new Uint8Array([
5530
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5260
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5531
5261
  ...recipientDataArray,
5532
5262
  ...amountDataArray
5533
5263
  ]);
5534
- const params = { script, ...txParams };
5264
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5535
5265
  const request = new ScriptTransactionRequest(params);
5536
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5537
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5538
- if (txParams.gasLimit) {
5539
- this.validateGas({
5540
- gasUsed: txCost.gasUsed,
5541
- gasLimit: request.gasLimit
5542
- });
5543
- }
5544
- request.maxFee = txCost.maxFee;
5545
- request.gasLimit = txCost.gasUsed;
5546
- await this.fund(request, txCost);
5266
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5267
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5268
+ request,
5269
+ forwardingQuantities
5270
+ );
5271
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5272
+ this.validateGas({
5273
+ gasUsed,
5274
+ gasPrice: request.gasPrice,
5275
+ gasLimit: request.gasLimit,
5276
+ minGasPrice
5277
+ });
5278
+ await this.fund(request, requiredQuantities, maxFee);
5547
5279
  return this.sendTransaction(request);
5548
5280
  }
5549
5281
  async signMessage(message) {
@@ -5601,7 +5333,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5601
5333
  }
5602
5334
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5603
5335
  }
5604
- validateGas({ gasUsed, gasLimit }) {
5336
+ validateGas({
5337
+ gasUsed,
5338
+ gasPrice,
5339
+ gasLimit,
5340
+ minGasPrice
5341
+ }) {
5342
+ if (minGasPrice.gt(gasPrice)) {
5343
+ throw new import_errors16.FuelError(
5344
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5345
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5346
+ );
5347
+ }
5605
5348
  if (gasUsed.gt(gasLimit)) {
5606
5349
  throw new import_errors16.FuelError(
5607
5350
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5613,14 +5356,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5613
5356
 
5614
5357
  // src/wallet/base-wallet-unlocked.ts
5615
5358
  var import_hasher3 = require("@fuel-ts/hasher");
5616
- var import_utils30 = require("@fuel-ts/utils");
5359
+ var import_utils31 = require("@fuel-ts/utils");
5617
5360
 
5618
5361
  // src/signer/signer.ts
5619
5362
  var import_address5 = require("@fuel-ts/address");
5620
5363
  var import_crypto2 = require("@fuel-ts/crypto");
5621
5364
  var import_hasher2 = require("@fuel-ts/hasher");
5622
- var import_math20 = require("@fuel-ts/math");
5623
- var import_utils28 = require("@fuel-ts/utils");
5365
+ var import_math19 = require("@fuel-ts/math");
5366
+ var import_utils29 = require("@fuel-ts/utils");
5624
5367
  var import_secp256k1 = require("@noble/curves/secp256k1");
5625
5368
  var Signer = class {
5626
5369
  address;
@@ -5639,10 +5382,10 @@ var Signer = class {
5639
5382
  privateKey = `0x${privateKey}`;
5640
5383
  }
5641
5384
  }
5642
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5643
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5644
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5645
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5385
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5386
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5387
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5388
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5646
5389
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5647
5390
  }
5648
5391
  /**
@@ -5656,11 +5399,11 @@ var Signer = class {
5656
5399
  * @returns hashed signature
5657
5400
  */
5658
5401
  sign(data) {
5659
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5660
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5661
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5402
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5403
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5404
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5662
5405
  s[0] |= (signature.recovery || 0) << 7;
5663
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5406
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5664
5407
  }
5665
5408
  /**
5666
5409
  * Add point on the current elliptic curve
@@ -5669,8 +5412,8 @@ var Signer = class {
5669
5412
  * @returns compressed point on the curve
5670
5413
  */
5671
5414
  addPoint(point) {
5672
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5673
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5415
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5416
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5674
5417
  const result = p0.add(p1);
5675
5418
  return `0x${result.toHex(true)}`;
5676
5419
  }
@@ -5682,16 +5425,16 @@ var Signer = class {
5682
5425
  * @returns public key from signature from the
5683
5426
  */
5684
5427
  static recoverPublicKey(data, signature) {
5685
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5428
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5686
5429
  const r = signedMessageBytes.slice(0, 32);
5687
5430
  const s = signedMessageBytes.slice(32, 64);
5688
5431
  const recoveryParam = (s[0] & 128) >> 7;
5689
5432
  s[0] &= 127;
5690
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5433
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5691
5434
  recoveryParam
5692
5435
  );
5693
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5694
- return (0, import_utils28.hexlify)(publicKey);
5436
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5437
+ return (0, import_utils29.hexlify)(publicKey);
5695
5438
  }
5696
5439
  /**
5697
5440
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5710,7 +5453,7 @@ var Signer = class {
5710
5453
  * @returns random 32-byte hashed
5711
5454
  */
5712
5455
  static generatePrivateKey(entropy) {
5713
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5456
+ 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);
5714
5457
  }
5715
5458
  /**
5716
5459
  * Extended publicKey from a compact publicKey
@@ -5719,8 +5462,8 @@ var Signer = class {
5719
5462
  * @returns extended publicKey
5720
5463
  */
5721
5464
  static extendPublicKey(publicKey) {
5722
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5723
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5465
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5466
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5724
5467
  }
5725
5468
  };
5726
5469
 
@@ -5728,7 +5471,7 @@ var Signer = class {
5728
5471
  var import_address6 = require("@fuel-ts/address");
5729
5472
  var import_crypto3 = require("@fuel-ts/crypto");
5730
5473
  var import_errors17 = require("@fuel-ts/errors");
5731
- var import_utils29 = require("@fuel-ts/utils");
5474
+ var import_utils30 = require("@fuel-ts/utils");
5732
5475
  var import_uuid = require("uuid");
5733
5476
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5734
5477
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5811,7 +5554,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5811
5554
  );
5812
5555
  }
5813
5556
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5814
- const privateKey = (0, import_utils29.hexlify)(buffer);
5557
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5815
5558
  return privateKey;
5816
5559
  }
5817
5560
 
@@ -5856,7 +5599,7 @@ var BaseWalletUnlocked = class extends Account {
5856
5599
  */
5857
5600
  async signMessage(message) {
5858
5601
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5859
- return (0, import_utils30.hexlify)(signedMessage);
5602
+ return (0, import_utils31.hexlify)(signedMessage);
5860
5603
  }
5861
5604
  /**
5862
5605
  * Signs a transaction with the wallet's private key.
@@ -5869,7 +5612,7 @@ var BaseWalletUnlocked = class extends Account {
5869
5612
  const chainId = this.provider.getChainId();
5870
5613
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5871
5614
  const signature = await this.signer().sign(hashedTransaction);
5872
- return (0, import_utils30.hexlify)(signature);
5615
+ return (0, import_utils31.hexlify)(signature);
5873
5616
  }
5874
5617
  /**
5875
5618
  * Populates a transaction with the witnesses signature.
@@ -5889,7 +5632,7 @@ var BaseWalletUnlocked = class extends Account {
5889
5632
  * @param transactionRequestLike - The transaction request to send.
5890
5633
  * @returns A promise that resolves to the TransactionResponse object.
5891
5634
  */
5892
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5635
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5893
5636
  const transactionRequest = transactionRequestify(transactionRequestLike);
5894
5637
  if (estimateTxDependencies) {
5895
5638
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5930,15 +5673,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5930
5673
  // src/hdwallet/hdwallet.ts
5931
5674
  var import_errors20 = require("@fuel-ts/errors");
5932
5675
  var import_hasher6 = require("@fuel-ts/hasher");
5933
- var import_math21 = require("@fuel-ts/math");
5934
- var import_utils34 = require("@fuel-ts/utils");
5676
+ var import_math20 = require("@fuel-ts/math");
5677
+ var import_utils35 = require("@fuel-ts/utils");
5935
5678
  var import_ethers3 = require("ethers");
5936
5679
 
5937
5680
  // src/mnemonic/mnemonic.ts
5938
5681
  var import_crypto4 = require("@fuel-ts/crypto");
5939
5682
  var import_errors19 = require("@fuel-ts/errors");
5940
5683
  var import_hasher5 = require("@fuel-ts/hasher");
5941
- var import_utils32 = require("@fuel-ts/utils");
5684
+ var import_utils33 = require("@fuel-ts/utils");
5942
5685
  var import_ethers2 = require("ethers");
5943
5686
 
5944
5687
  // src/wordlists/words/english.ts
@@ -8002,7 +7745,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
8002
7745
  // src/mnemonic/utils.ts
8003
7746
  var import_errors18 = require("@fuel-ts/errors");
8004
7747
  var import_hasher4 = require("@fuel-ts/hasher");
8005
- var import_utils31 = require("@fuel-ts/utils");
7748
+ var import_utils32 = require("@fuel-ts/utils");
8006
7749
  function toUtf8Bytes(stri) {
8007
7750
  const str = stri.normalize("NFKD");
8008
7751
  const result = [];
@@ -8069,14 +7812,14 @@ function entropyToMnemonicIndices(entropy) {
8069
7812
  }
8070
7813
  }
8071
7814
  const checksumBits = entropy.length / 4;
8072
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7815
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8073
7816
  indices[indices.length - 1] <<= checksumBits;
8074
7817
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8075
7818
  return indices;
8076
7819
  }
8077
7820
  function mnemonicWordsToEntropy(words, wordlist) {
8078
7821
  const size = Math.ceil(11 * words.length / 8);
8079
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7822
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8080
7823
  let offset = 0;
8081
7824
  for (let i = 0; i < words.length; i += 1) {
8082
7825
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8096,7 +7839,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8096
7839
  const entropyBits = 32 * words.length / 3;
8097
7840
  const checksumBits = words.length / 3;
8098
7841
  const checksumMask = getUpperMask(checksumBits);
8099
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7842
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8100
7843
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8101
7844
  throw new import_errors18.FuelError(
8102
7845
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8171,7 +7914,7 @@ var Mnemonic = class {
8171
7914
  static mnemonicToEntropy(phrase, wordlist = english) {
8172
7915
  const words = getWords(phrase);
8173
7916
  assertMnemonic(words);
8174
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7917
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8175
7918
  }
8176
7919
  /**
8177
7920
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8179,7 +7922,7 @@ var Mnemonic = class {
8179
7922
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8180
7923
  */
8181
7924
  static entropyToMnemonic(entropy, wordlist = english) {
8182
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7925
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8183
7926
  assertWordList(wordlist);
8184
7927
  assertEntropy(entropyBytes);
8185
7928
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8248,14 +7991,14 @@ var Mnemonic = class {
8248
7991
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8249
7992
  */
8250
7993
  static masterKeysFromSeed(seed) {
8251
- const seedArray = (0, import_utils32.arrayify)(seed);
7994
+ const seedArray = (0, import_utils33.arrayify)(seed);
8252
7995
  if (seedArray.length < 16 || seedArray.length > 64) {
8253
7996
  throw new import_errors19.FuelError(
8254
7997
  import_errors19.ErrorCode.INVALID_SEED,
8255
7998
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8256
7999
  );
8257
8000
  }
8258
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8001
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8259
8002
  }
8260
8003
  /**
8261
8004
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8266,22 +8009,22 @@ var Mnemonic = class {
8266
8009
  */
8267
8010
  static seedToExtendedKey(seed, testnet = false) {
8268
8011
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8269
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8012
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8270
8013
  const depth = "0x00";
8271
8014
  const fingerprint = "0x00000000";
8272
8015
  const index = "0x00000000";
8273
8016
  const chainCode = masterKey.slice(32);
8274
8017
  const privateKey = masterKey.slice(0, 32);
8275
- const extendedKey = (0, import_utils32.concat)([
8018
+ const extendedKey = (0, import_utils33.concat)([
8276
8019
  prefix,
8277
8020
  depth,
8278
8021
  fingerprint,
8279
8022
  index,
8280
8023
  chainCode,
8281
- (0, import_utils32.concat)(["0x00", privateKey])
8024
+ (0, import_utils33.concat)(["0x00", privateKey])
8282
8025
  ]);
8283
8026
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8284
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8027
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8285
8028
  }
8286
8029
  /**
8287
8030
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8296,7 +8039,7 @@ var Mnemonic = class {
8296
8039
  * @returns A randomly generated mnemonic
8297
8040
  */
8298
8041
  static generate(size = 32, extraEntropy = "") {
8299
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8042
+ 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);
8300
8043
  return Mnemonic.entropyToMnemonic(entropy);
8301
8044
  }
8302
8045
  };
@@ -8304,12 +8047,12 @@ var mnemonic_default = Mnemonic;
8304
8047
 
8305
8048
  // src/hdwallet/hdwallet.ts
8306
8049
  var HARDENED_INDEX = 2147483648;
8307
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8308
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8309
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8310
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8050
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8051
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8052
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8053
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8311
8054
  function base58check(data) {
8312
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8055
+ 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)]));
8313
8056
  }
8314
8057
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8315
8058
  if (isPublic) {
@@ -8318,11 +8061,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8318
8061
  return testnet ? TestnetPRV2 : MainnetPRV2;
8319
8062
  }
8320
8063
  function isPublicExtendedKey(extendedKey) {
8321
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8064
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8322
8065
  }
8323
8066
  function isValidExtendedKey(extendedKey) {
8324
8067
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8325
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8068
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8326
8069
  );
8327
8070
  }
8328
8071
  function parsePath(path, depth = 0) {
@@ -8340,8 +8083,8 @@ function parsePath(path, depth = 0) {
8340
8083
  var HDWallet = class {
8341
8084
  depth = 0;
8342
8085
  index = 0;
8343
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8344
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8086
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8087
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8345
8088
  privateKey;
8346
8089
  publicKey;
8347
8090
  chainCode;
@@ -8353,8 +8096,8 @@ var HDWallet = class {
8353
8096
  constructor(config) {
8354
8097
  if (config.privateKey) {
8355
8098
  const signer = new Signer(config.privateKey);
8356
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8357
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8099
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8100
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8358
8101
  } else {
8359
8102
  if (!config.publicKey) {
8360
8103
  throw new import_errors20.FuelError(
@@ -8362,7 +8105,7 @@ var HDWallet = class {
8362
8105
  "Both public and private Key cannot be missing. At least one should be provided."
8363
8106
  );
8364
8107
  }
8365
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8108
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8366
8109
  }
8367
8110
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8368
8111
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8381,9 +8124,9 @@ var HDWallet = class {
8381
8124
  * @returns A new instance of HDWallet on the derived index
8382
8125
  */
8383
8126
  deriveIndex(index) {
8384
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8385
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8386
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8127
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8128
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8129
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8387
8130
  const data = new Uint8Array(37);
8388
8131
  if (index & HARDENED_INDEX) {
8389
8132
  if (!privateKey) {
@@ -8394,15 +8137,15 @@ var HDWallet = class {
8394
8137
  }
8395
8138
  data.set(privateKey, 1);
8396
8139
  } else {
8397
- data.set((0, import_utils34.arrayify)(this.publicKey));
8140
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8398
8141
  }
8399
- data.set((0, import_math21.toBytes)(index, 4), 33);
8400
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8142
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8143
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8401
8144
  const IL = bytes.slice(0, 32);
8402
8145
  const IR = bytes.slice(32);
8403
8146
  if (privateKey) {
8404
8147
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8405
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8148
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8406
8149
  return new HDWallet({
8407
8150
  privateKey: ki,
8408
8151
  chainCode: IR,
@@ -8411,7 +8154,7 @@ var HDWallet = class {
8411
8154
  parentFingerprint: this.fingerprint
8412
8155
  });
8413
8156
  }
8414
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8157
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8415
8158
  const Ki = signer.addPoint(publicKey);
8416
8159
  return new HDWallet({
8417
8160
  publicKey: Ki,
@@ -8446,12 +8189,12 @@ var HDWallet = class {
8446
8189
  );
8447
8190
  }
8448
8191
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8449
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8192
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8450
8193
  const parentFingerprint = this.parentFingerprint;
8451
- const index = (0, import_math21.toHex)(this.index, 4);
8194
+ const index = (0, import_math20.toHex)(this.index, 4);
8452
8195
  const chainCode = this.chainCode;
8453
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8454
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8196
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8197
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8455
8198
  return base58check(extendedKey);
8456
8199
  }
8457
8200
  /**
@@ -8463,13 +8206,13 @@ var HDWallet = class {
8463
8206
  static fromSeed(seed) {
8464
8207
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8465
8208
  return new HDWallet({
8466
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8467
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8209
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8210
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8468
8211
  });
8469
8212
  }
8470
8213
  static fromExtendedKey(extendedKey) {
8471
8214
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8472
- const bytes = (0, import_utils34.arrayify)(decoded);
8215
+ const bytes = (0, import_utils35.arrayify)(decoded);
8473
8216
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8474
8217
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8475
8218
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8478,9 +8221,9 @@ var HDWallet = class {
8478
8221
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8479
8222
  }
8480
8223
  const depth = bytes[4];
8481
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8482
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8483
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8224
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8225
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8226
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8484
8227
  const key = bytes.slice(45, 78);
8485
8228
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8486
8229
  throw new import_errors20.FuelError(
@@ -9085,19 +8828,19 @@ var import_abi_coder7 = require("@fuel-ts/abi-coder");
9085
8828
  var import_address10 = require("@fuel-ts/address");
9086
8829
  var import_configs13 = require("@fuel-ts/address/configs");
9087
8830
  var import_errors25 = require("@fuel-ts/errors");
9088
- var import_transactions21 = require("@fuel-ts/transactions");
9089
- var import_utils36 = require("@fuel-ts/utils");
8831
+ var import_transactions20 = require("@fuel-ts/transactions");
8832
+ var import_utils37 = require("@fuel-ts/utils");
9090
8833
 
9091
8834
  // src/predicate/utils/getPredicateRoot.ts
9092
8835
  var import_hasher7 = require("@fuel-ts/hasher");
9093
8836
  var import_merkle = require("@fuel-ts/merkle");
9094
- var import_utils35 = require("@fuel-ts/utils");
8837
+ var import_utils36 = require("@fuel-ts/utils");
9095
8838
  var getPredicateRoot = (bytecode) => {
9096
8839
  const chunkSize = 16 * 1024;
9097
- const bytes = (0, import_utils35.arrayify)(bytecode);
9098
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9099
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9100
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8840
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8841
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8842
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8843
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9101
8844
  return predicateRoot;
9102
8845
  };
9103
8846
 
@@ -9145,9 +8888,9 @@ var Predicate = class extends Account {
9145
8888
  const request = transactionRequestify(transactionRequestLike);
9146
8889
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9147
8890
  request.inputs?.forEach((input) => {
9148
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9149
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9150
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8891
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8892
+ input.predicate = this.bytes;
8893
+ input.predicateData = this.getPredicateData(policies.length);
9151
8894
  }
9152
8895
  });
9153
8896
  return request;
@@ -9162,7 +8905,8 @@ var Predicate = class extends Account {
9162
8905
  * @returns A promise that resolves to the prepared transaction request.
9163
8906
  */
9164
8907
  async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9165
- return super.createTransfer(destination, amount, assetId, txParams);
8908
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8909
+ return this.populateTransactionPredicateData(request);
9166
8910
  }
9167
8911
  /**
9168
8912
  * Sends a transaction with the populated predicate data.
@@ -9170,9 +8914,9 @@ var Predicate = class extends Account {
9170
8914
  * @param transactionRequestLike - The transaction request-like object.
9171
8915
  * @returns A promise that resolves to the transaction response.
9172
8916
  */
9173
- sendTransaction(transactionRequestLike) {
9174
- const transactionRequest = transactionRequestify(transactionRequestLike);
9175
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8917
+ sendTransaction(transactionRequestLike, options) {
8918
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8919
+ return super.sendTransaction(transactionRequest, options);
9176
8920
  }
9177
8921
  /**
9178
8922
  * Simulates a transaction with the populated predicate data.
@@ -9181,15 +8925,15 @@ var Predicate = class extends Account {
9181
8925
  * @returns A promise that resolves to the call result.
9182
8926
  */
9183
8927
  simulateTransaction(transactionRequestLike) {
9184
- const transactionRequest = transactionRequestify(transactionRequestLike);
9185
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8928
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8929
+ return super.simulateTransaction(transactionRequest);
9186
8930
  }
9187
8931
  getPredicateData(policiesLength) {
9188
8932
  if (!this.predicateData.length) {
9189
8933
  return new Uint8Array();
9190
8934
  }
9191
8935
  const mainFn = this.interface?.functions.main;
9192
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8936
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9193
8937
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9194
8938
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9195
8939
  });
@@ -9205,7 +8949,7 @@ var Predicate = class extends Account {
9205
8949
  * @returns An object containing the new predicate bytes and interface.
9206
8950
  */
9207
8951
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9208
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8952
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9209
8953
  let abiInterface;
9210
8954
  if (jsonAbi) {
9211
8955
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9228,25 +8972,6 @@ var Predicate = class extends Account {
9228
8972
  predicateInterface: abiInterface
9229
8973
  };
9230
8974
  }
9231
- /**
9232
- * Retrieves resources satisfying the spend query for the account.
9233
- *
9234
- * @param quantities - IDs of coins to exclude.
9235
- * @param excludedIds - IDs of resources to be excluded from the query.
9236
- * @returns A promise that resolves to an array of Resources.
9237
- */
9238
- async getResourcesToSpend(quantities, excludedIds) {
9239
- const resources = await this.provider.getResourcesToSpend(
9240
- this.address,
9241
- quantities,
9242
- excludedIds
9243
- );
9244
- return resources.map((resource) => ({
9245
- ...resource,
9246
- predicate: (0, import_utils36.hexlify)(this.bytes),
9247
- paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9248
- }));
9249
- }
9250
8975
  /**
9251
8976
  * Sets the configurable constants for the predicate.
9252
8977
  *
@@ -9996,7 +9721,7 @@ __publicField(Fuel, "defaultConfig", {});
9996
9721
  WalletLocked,
9997
9722
  WalletManager,
9998
9723
  WalletUnlocked,
9999
- addAmountToCoinQuantities,
9724
+ addAmountToAsset,
10000
9725
  addOperation,
10001
9726
  assemblePanicError,
10002
9727
  assembleReceiptByType,
@@ -10005,10 +9730,9 @@ __publicField(Fuel, "defaultConfig", {});
10005
9730
  assets,
10006
9731
  buildBlockExplorerUrl,
10007
9732
  cacheFor,
10008
- cacheTxInputsFromOwner,
10009
- calculateGasFee,
10010
9733
  calculateMetadataGasForTxCreate,
10011
9734
  calculateMetadataGasForTxScript,
9735
+ calculatePriceWithFactor,
10012
9736
  calculateTransactionFee,
10013
9737
  coinQuantityfy,
10014
9738
  deferPromise,