@fuel-ts/account 0.0.0-rc-2021-20240424175107 → 0.0.0-rc-2037-20240424175231

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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +6 -7
  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 +622 -814
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +659 -837
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +478 -661
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +39 -12
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +359 -810
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +1 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -6
  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/helpers.d.ts +10 -0
  31. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  32. package/dist/providers/transaction-request/index.d.ts +1 -0
  33. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/input.d.ts +2 -2
  35. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/transaction-request.d.ts +11 -6
  38. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  39. package/dist/providers/transaction-request/utils.d.ts +0 -3
  40. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  41. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  43. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  45. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  46. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  47. package/dist/providers/utils/gas.d.ts +2 -8
  48. package/dist/providers/utils/gas.d.ts.map +1 -1
  49. package/dist/test-utils/index.d.ts +1 -0
  50. package/dist/test-utils/index.d.ts.map +1 -1
  51. package/dist/test-utils/launchNode.d.ts.map +1 -1
  52. package/dist/test-utils/resources.d.ts +4 -0
  53. package/dist/test-utils/resources.d.ts.map +1 -0
  54. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  55. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  56. package/dist/test-utils/transactionRequest.d.ts +5 -0
  57. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  58. package/dist/test-utils.global.js +1089 -1533
  59. package/dist/test-utils.global.js.map +1 -1
  60. package/dist/test-utils.js +624 -820
  61. package/dist/test-utils.js.map +1 -1
  62. package/dist/test-utils.mjs +457 -656
  63. package/dist/test-utils.mjs.map +1 -1
  64. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  65. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  66. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -88,14 +88,14 @@ __export(src_exports, {
88
88
  StorageAbstract: () => StorageAbstract,
89
89
  TransactionResponse: () => TransactionResponse,
90
90
  TransactionStatus: () => TransactionStatus,
91
- TransactionType: () => import_transactions6.TransactionType,
91
+ TransactionType: () => import_transactions7.TransactionType,
92
92
  TransactionTypeName: () => TransactionTypeName,
93
93
  Vault: () => Vault,
94
94
  Wallet: () => Wallet,
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,10 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
107
+ cacheResources: () => cacheResources,
109
108
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
109
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
110
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
111
  calculateTransactionFee: () => calculateTransactionFee,
112
112
  coinQuantityfy: () => coinQuantityfy,
113
113
  deferPromise: () => deferPromise,
@@ -151,6 +151,7 @@ __export(src_exports, {
151
151
  getReceiptsMessageOut: () => getReceiptsMessageOut,
152
152
  getReceiptsTransferOut: () => getReceiptsTransferOut,
153
153
  getReceiptsWithMissingData: () => getReceiptsWithMissingData,
154
+ getRequestInputResourceOwner: () => getRequestInputResourceOwner,
154
155
  getTransactionStatusName: () => getTransactionStatusName,
155
156
  getTransactionSummary: () => getTransactionSummary,
156
157
  getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
@@ -164,6 +165,10 @@ __export(src_exports, {
164
165
  isMessage: () => isMessage,
165
166
  isRawCoin: () => isRawCoin,
166
167
  isRawMessage: () => isRawMessage,
168
+ isRequestInputCoin: () => isRequestInputCoin,
169
+ isRequestInputMessage: () => isRequestInputMessage,
170
+ isRequestInputResource: () => isRequestInputResource,
171
+ isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
167
172
  isType: () => isType,
168
173
  isTypeCreate: () => isTypeCreate,
169
174
  isTypeMint: () => isTypeMint,
@@ -188,9 +193,8 @@ var import_address4 = require("@fuel-ts/address");
188
193
  var import_configs12 = require("@fuel-ts/address/configs");
189
194
  var import_errors16 = require("@fuel-ts/errors");
190
195
  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");
196
+ var import_math18 = require("@fuel-ts/math");
197
+ var import_utils28 = require("@fuel-ts/utils");
194
198
 
195
199
  // src/providers/coin-quantity.ts
196
200
  var import_configs = require("@fuel-ts/address/configs");
@@ -199,24 +203,24 @@ var import_utils = require("@fuel-ts/utils");
199
203
  var coinQuantityfy = (coinQuantityLike) => {
200
204
  let assetId;
201
205
  let amount;
202
- let max;
206
+ let max2;
203
207
  if (Array.isArray(coinQuantityLike)) {
204
208
  amount = coinQuantityLike[0];
205
209
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
206
- max = coinQuantityLike[2] ?? void 0;
210
+ max2 = coinQuantityLike[2] ?? void 0;
207
211
  } else {
208
212
  amount = coinQuantityLike.amount;
209
213
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
210
- max = coinQuantityLike.max ?? void 0;
214
+ max2 = coinQuantityLike.max ?? void 0;
211
215
  }
212
216
  const bnAmount = (0, import_math.bn)(amount);
213
217
  return {
214
218
  assetId: (0, import_utils.hexlify)(assetId),
215
219
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
216
- max: max ? (0, import_math.bn)(max) : void 0
220
+ max: max2 ? (0, import_math.bn)(max2) : void 0
217
221
  };
218
222
  };
219
- var addAmountToCoinQuantities = (params) => {
223
+ var addAmountToAsset = (params) => {
220
224
  const { amount, assetId } = params;
221
225
  const coinQuantities = [...params.coinQuantities];
222
226
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -231,31 +235,27 @@ var addAmountToCoinQuantities = (params) => {
231
235
  // src/providers/provider.ts
232
236
  var import_address3 = require("@fuel-ts/address");
233
237
  var import_errors14 = require("@fuel-ts/errors");
234
- var import_math16 = require("@fuel-ts/math");
238
+ var import_math15 = require("@fuel-ts/math");
235
239
  var import_transactions19 = require("@fuel-ts/transactions");
236
- var import_utils22 = require("@fuel-ts/utils");
240
+ var import_utils23 = require("@fuel-ts/utils");
237
241
  var import_versions = require("@fuel-ts/versions");
238
- var import_utils23 = require("@noble/curves/abstract/utils");
242
+ var import_utils24 = require("@noble/curves/abstract/utils");
239
243
  var import_ethers = require("ethers");
240
244
  var import_graphql_request = require("graphql-request");
241
245
  var import_ramda3 = require("ramda");
242
246
 
243
247
  // src/providers/__generated__/operations.ts
244
248
  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 SqueezedOutStatus {
249
- reason
250
- }
251
- }
252
- `;
253
249
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
254
250
  fragment receiptFragment on Receipt {
255
- id
251
+ contract {
252
+ id
253
+ }
256
254
  pc
257
255
  is
258
- to
256
+ to {
257
+ id
258
+ }
259
259
  toAddress
260
260
  amount
261
261
  assetId
@@ -293,16 +293,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
293
293
  id
294
294
  }
295
295
  time
296
- receipts {
297
- ...receiptFragment
298
- }
299
296
  programState {
300
297
  returnType
301
298
  data
302
299
  }
303
- receipts {
304
- ...receiptFragment
305
- }
306
300
  }
307
301
  ... on FailureStatus {
308
302
  block {
@@ -310,24 +304,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
310
304
  }
311
305
  time
312
306
  reason
313
- receipts {
314
- ...receiptFragment
315
- }
316
307
  }
317
308
  ... on SqueezedOutStatus {
318
309
  reason
319
310
  }
320
311
  }
321
- ${ReceiptFragmentFragmentDoc}`;
312
+ `;
322
313
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
323
314
  fragment transactionFragment on Transaction {
324
315
  id
325
316
  rawPayload
317
+ gasPrice
318
+ receipts {
319
+ ...receiptFragment
320
+ }
326
321
  status {
327
322
  ...transactionStatusFragment
328
323
  }
329
324
  }
330
- ${TransactionStatusFragmentFragmentDoc}`;
325
+ ${ReceiptFragmentFragmentDoc}
326
+ ${TransactionStatusFragmentFragmentDoc}`;
331
327
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
332
328
  fragment inputEstimatePredicatesFragment on Input {
333
329
  ... on InputCoin {
@@ -345,46 +341,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
345
341
  }
346
342
  }
347
343
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
348
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
349
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
350
- reason
351
- programState {
352
- returnType
353
- data
354
- }
355
- }
356
- `;
357
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
358
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
359
- programState {
360
- returnType
361
- data
362
- }
363
- }
364
- `;
365
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
366
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
367
- ... on DryRunFailureStatus {
368
- ...dryRunFailureStatusFragment
369
- }
370
- ... on DryRunSuccessStatus {
371
- ...dryRunSuccessStatusFragment
372
- }
373
- }
374
- ${DryRunFailureStatusFragmentFragmentDoc}
375
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
376
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
377
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
378
- id
379
- status {
380
- ...dryRunTransactionStatusFragment
381
- }
382
- receipts {
383
- ...receiptFragment
384
- }
385
- }
386
- ${DryRunTransactionStatusFragmentFragmentDoc}
387
- ${ReceiptFragmentFragmentDoc}`;
388
344
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
389
345
  fragment coinFragment on Coin {
390
346
  __typename
@@ -392,6 +348,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
392
348
  owner
393
349
  amount
394
350
  assetId
351
+ maturity
395
352
  blockCreated
396
353
  txCreatedIdx
397
354
  }
@@ -430,32 +387,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
430
387
  messageBlockHeader {
431
388
  id
432
389
  daHeight
433
- consensusParametersVersion
434
- stateTransitionBytecodeVersion
435
390
  transactionsCount
436
- messageReceiptCount
437
391
  transactionsRoot
438
- messageOutboxRoot
439
- eventInboxRoot
440
392
  height
441
393
  prevRoot
442
394
  time
443
395
  applicationHash
396
+ messageReceiptRoot
397
+ messageReceiptCount
444
398
  }
445
399
  commitBlockHeader {
446
400
  id
447
401
  daHeight
448
- consensusParametersVersion
449
- stateTransitionBytecodeVersion
450
402
  transactionsCount
451
- messageReceiptCount
452
403
  transactionsRoot
453
- messageOutboxRoot
454
- eventInboxRoot
455
404
  height
456
405
  prevRoot
457
406
  time
458
407
  applicationHash
408
+ messageReceiptRoot
409
+ messageReceiptCount
459
410
  }
460
411
  sender
461
412
  recipient
@@ -474,8 +425,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
474
425
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
475
426
  fragment blockFragment on Block {
476
427
  id
477
- height
478
428
  header {
429
+ height
479
430
  time
480
431
  }
481
432
  transactions {
@@ -485,7 +436,6 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
485
436
  `;
486
437
  var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
487
438
  fragment TxParametersFragment on TxParameters {
488
- version
489
439
  maxInputs
490
440
  maxOutputs
491
441
  maxWitnesses
@@ -495,7 +445,6 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
495
445
  `;
496
446
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
497
447
  fragment PredicateParametersFragment on PredicateParameters {
498
- version
499
448
  maxPredicateLength
500
449
  maxPredicateDataLength
501
450
  maxGasPerPredicate
@@ -504,21 +453,18 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
504
453
  `;
505
454
  var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
506
455
  fragment ScriptParametersFragment on ScriptParameters {
507
- version
508
456
  maxScriptLength
509
457
  maxScriptDataLength
510
458
  }
511
459
  `;
512
460
  var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
513
461
  fragment ContractParametersFragment on ContractParameters {
514
- version
515
462
  contractMaxSize
516
463
  maxStorageSlots
517
464
  }
518
465
  `;
519
466
  var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
520
467
  fragment FeeParametersFragment on FeeParameters {
521
- version
522
468
  gasPriceFactor
523
469
  gasPerByte
524
470
  }
@@ -538,7 +484,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
538
484
  `;
539
485
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
540
486
  fragment GasCostsFragment on GasCosts {
541
- version
542
487
  add
543
488
  addi
544
489
  aloc
@@ -551,6 +496,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
551
496
  cb
552
497
  cfei
553
498
  cfsi
499
+ croo
554
500
  div
555
501
  divi
556
502
  ecr1
@@ -633,9 +579,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
633
579
  ccp {
634
580
  ...DependentCostFragment
635
581
  }
636
- croo {
637
- ...DependentCostFragment
638
- }
639
582
  csiz {
640
583
  ...DependentCostFragment
641
584
  }
@@ -695,7 +638,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
695
638
  ${DependentCostFragmentFragmentDoc}`;
696
639
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
697
640
  fragment consensusParametersFragment on ConsensusParameters {
698
- version
699
641
  txParams {
700
642
  ...TxParametersFragment
701
643
  }
@@ -755,9 +697,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
755
697
  fragment nodeInfoFragment on NodeInfo {
756
698
  utxoValidation
757
699
  vmBacktrace
700
+ minGasPrice
758
701
  maxTx
759
702
  maxDepth
760
703
  nodeVersion
704
+ peers {
705
+ id
706
+ addresses
707
+ clientVersion
708
+ blockHeight
709
+ lastHeartbeatMs
710
+ appScore
711
+ }
761
712
  }
762
713
  `;
763
714
  var GetVersionDocument = import_graphql_tag.default`
@@ -792,9 +743,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
792
743
  query getTransactionWithReceipts($transactionId: TransactionId!) {
793
744
  transaction(id: $transactionId) {
794
745
  ...transactionFragment
746
+ receipts {
747
+ ...receiptFragment
748
+ }
795
749
  }
796
750
  }
797
- ${TransactionFragmentFragmentDoc}`;
751
+ ${TransactionFragmentFragmentDoc}
752
+ ${ReceiptFragmentFragmentDoc}`;
798
753
  var GetTransactionsDocument = import_graphql_tag.default`
799
754
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
800
755
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -922,20 +877,6 @@ var GetBalanceDocument = import_graphql_tag.default`
922
877
  }
923
878
  }
924
879
  ${BalanceFragmentFragmentDoc}`;
925
- var GetLatestGasPriceDocument = import_graphql_tag.default`
926
- query getLatestGasPrice {
927
- latestGasPrice {
928
- gasPrice
929
- }
930
- }
931
- `;
932
- var EstimateGasPriceDocument = import_graphql_tag.default`
933
- query estimateGasPrice($blockHorizon: U32!) {
934
- estimateGasPrice(blockHorizon: $blockHorizon) {
935
- gasPrice
936
- }
937
- }
938
- `;
939
880
  var GetBalancesDocument = import_graphql_tag.default`
940
881
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
941
882
  balances(
@@ -990,12 +931,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
990
931
  }
991
932
  `;
992
933
  var DryRunDocument = import_graphql_tag.default`
993
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
994
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
995
- ...dryRunTransactionExecutionStatusFragment
934
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
935
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
936
+ ...receiptFragment
996
937
  }
997
938
  }
998
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
939
+ ${ReceiptFragmentFragmentDoc}`;
999
940
  var SubmitDocument = import_graphql_tag.default`
1000
941
  mutation submit($encodedTransaction: HexString!) {
1001
942
  submit(tx: $encodedTransaction) {
@@ -1014,17 +955,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
1014
955
  var SubmitAndAwaitDocument = import_graphql_tag.default`
1015
956
  subscription submitAndAwait($encodedTransaction: HexString!) {
1016
957
  submitAndAwait(tx: $encodedTransaction) {
1017
- ...transactionStatusSubscriptionFragment
958
+ ...transactionStatusFragment
1018
959
  }
1019
960
  }
1020
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
961
+ ${TransactionStatusFragmentFragmentDoc}`;
1021
962
  var StatusChangeDocument = import_graphql_tag.default`
1022
963
  subscription statusChange($transactionId: TransactionId!) {
1023
964
  statusChange(id: $transactionId) {
1024
- ...transactionStatusSubscriptionFragment
965
+ ...transactionStatusFragment
1025
966
  }
1026
967
  }
1027
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
968
+ ${TransactionStatusFragmentFragmentDoc}`;
1028
969
  function getSdk(requester) {
1029
970
  return {
1030
971
  getVersion(variables, options) {
@@ -1078,12 +1019,6 @@ function getSdk(requester) {
1078
1019
  getBalance(variables, options) {
1079
1020
  return requester(GetBalanceDocument, variables, options);
1080
1021
  },
1081
- getLatestGasPrice(variables, options) {
1082
- return requester(GetLatestGasPriceDocument, variables, options);
1083
- },
1084
- estimateGasPrice(variables, options) {
1085
- return requester(EstimateGasPriceDocument, variables, options);
1086
- },
1087
1022
  getBalances(variables, options) {
1088
1023
  return requester(GetBalancesDocument, variables, options);
1089
1024
  },
@@ -1277,9 +1212,10 @@ var inputify = (value) => {
1277
1212
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1278
1213
  },
1279
1214
  witnessIndex: value.witnessIndex,
1215
+ maturity: value.maturity ?? 0,
1280
1216
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1281
- predicateLength: (0, import_math2.bn)(predicate.length),
1282
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1217
+ predicateLength: predicate.length,
1218
+ predicateDataLength: predicateData.length,
1283
1219
  predicate: (0, import_utils3.hexlify)(predicate),
1284
1220
  predicateData: (0, import_utils3.hexlify)(predicateData)
1285
1221
  };
@@ -1310,8 +1246,8 @@ var inputify = (value) => {
1310
1246
  nonce: (0, import_utils3.hexlify)(value.nonce),
1311
1247
  witnessIndex: value.witnessIndex,
1312
1248
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1313
- predicateLength: (0, import_math2.bn)(predicate.length),
1314
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1249
+ predicateLength: predicate.length,
1250
+ predicateDataLength: predicateData.length,
1315
1251
  predicate: (0, import_utils3.hexlify)(predicate),
1316
1252
  predicateData: (0, import_utils3.hexlify)(predicateData),
1317
1253
  data: (0, import_utils3.hexlify)(data),
@@ -1390,7 +1326,7 @@ var import_address = require("@fuel-ts/address");
1390
1326
  var import_configs7 = require("@fuel-ts/address/configs");
1391
1327
  var import_crypto = require("@fuel-ts/crypto");
1392
1328
  var import_math7 = require("@fuel-ts/math");
1393
- var import_transactions6 = require("@fuel-ts/transactions");
1329
+ var import_transactions7 = require("@fuel-ts/transactions");
1394
1330
  var import_utils9 = require("@fuel-ts/utils");
1395
1331
 
1396
1332
  // src/providers/resource.ts
@@ -1430,8 +1366,8 @@ function assembleReceiptByType(receipt) {
1430
1366
  case "CALL" /* Call */: {
1431
1367
  const callReceipt = {
1432
1368
  type: import_transactions3.ReceiptType.Call,
1433
- from: hexOrZero(receipt.id || receipt.contractId),
1434
- to: hexOrZero(receipt?.to),
1369
+ from: hexOrZero(receipt.contract?.id),
1370
+ to: hexOrZero(receipt?.to?.id),
1435
1371
  amount: (0, import_math4.bn)(receipt.amount),
1436
1372
  assetId: hexOrZero(receipt.assetId),
1437
1373
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1445,7 +1381,7 @@ function assembleReceiptByType(receipt) {
1445
1381
  case "RETURN" /* Return */: {
1446
1382
  const returnReceipt = {
1447
1383
  type: import_transactions3.ReceiptType.Return,
1448
- id: hexOrZero(receipt.id || receipt.contractId),
1384
+ id: hexOrZero(receipt.contract?.id),
1449
1385
  val: (0, import_math4.bn)(receipt.val),
1450
1386
  pc: (0, import_math4.bn)(receipt.pc),
1451
1387
  is: (0, import_math4.bn)(receipt.is)
@@ -1455,7 +1391,7 @@ function assembleReceiptByType(receipt) {
1455
1391
  case "RETURN_DATA" /* ReturnData */: {
1456
1392
  const returnDataReceipt = {
1457
1393
  type: import_transactions3.ReceiptType.ReturnData,
1458
- id: hexOrZero(receipt.id || receipt.contractId),
1394
+ id: hexOrZero(receipt.contract?.id),
1459
1395
  ptr: (0, import_math4.bn)(receipt.ptr),
1460
1396
  len: (0, import_math4.bn)(receipt.len),
1461
1397
  digest: hexOrZero(receipt.digest),
@@ -1467,7 +1403,7 @@ function assembleReceiptByType(receipt) {
1467
1403
  case "PANIC" /* Panic */: {
1468
1404
  const panicReceipt = {
1469
1405
  type: import_transactions3.ReceiptType.Panic,
1470
- id: hexOrZero(receipt.id),
1406
+ id: hexOrZero(receipt.contract?.id),
1471
1407
  reason: (0, import_math4.bn)(receipt.reason),
1472
1408
  pc: (0, import_math4.bn)(receipt.pc),
1473
1409
  is: (0, import_math4.bn)(receipt.is),
@@ -1478,7 +1414,7 @@ function assembleReceiptByType(receipt) {
1478
1414
  case "REVERT" /* Revert */: {
1479
1415
  const revertReceipt = {
1480
1416
  type: import_transactions3.ReceiptType.Revert,
1481
- id: hexOrZero(receipt.id || receipt.contractId),
1417
+ id: hexOrZero(receipt.contract?.id),
1482
1418
  val: (0, import_math4.bn)(receipt.ra),
1483
1419
  pc: (0, import_math4.bn)(receipt.pc),
1484
1420
  is: (0, import_math4.bn)(receipt.is)
@@ -1488,7 +1424,7 @@ function assembleReceiptByType(receipt) {
1488
1424
  case "LOG" /* Log */: {
1489
1425
  const logReceipt = {
1490
1426
  type: import_transactions3.ReceiptType.Log,
1491
- id: hexOrZero(receipt.id || receipt.contractId),
1427
+ id: hexOrZero(receipt.contract?.id),
1492
1428
  val0: (0, import_math4.bn)(receipt.ra),
1493
1429
  val1: (0, import_math4.bn)(receipt.rb),
1494
1430
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1501,7 +1437,7 @@ function assembleReceiptByType(receipt) {
1501
1437
  case "LOG_DATA" /* LogData */: {
1502
1438
  const logDataReceipt = {
1503
1439
  type: import_transactions3.ReceiptType.LogData,
1504
- id: hexOrZero(receipt.id || receipt.contractId),
1440
+ id: hexOrZero(receipt.contract?.id),
1505
1441
  val0: (0, import_math4.bn)(receipt.ra),
1506
1442
  val1: (0, import_math4.bn)(receipt.rb),
1507
1443
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1515,8 +1451,8 @@ function assembleReceiptByType(receipt) {
1515
1451
  case "TRANSFER" /* Transfer */: {
1516
1452
  const transferReceipt = {
1517
1453
  type: import_transactions3.ReceiptType.Transfer,
1518
- from: hexOrZero(receipt.id || receipt.contractId),
1519
- to: hexOrZero(receipt.toAddress || receipt?.to),
1454
+ from: hexOrZero(receipt.contract?.id),
1455
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1520
1456
  amount: (0, import_math4.bn)(receipt.amount),
1521
1457
  assetId: hexOrZero(receipt.assetId),
1522
1458
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1527,8 +1463,8 @@ function assembleReceiptByType(receipt) {
1527
1463
  case "TRANSFER_OUT" /* TransferOut */: {
1528
1464
  const transferOutReceipt = {
1529
1465
  type: import_transactions3.ReceiptType.TransferOut,
1530
- from: hexOrZero(receipt.id || receipt.contractId),
1531
- to: hexOrZero(receipt.toAddress || receipt.to),
1466
+ from: hexOrZero(receipt.contract?.id),
1467
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1532
1468
  amount: (0, import_math4.bn)(receipt.amount),
1533
1469
  assetId: hexOrZero(receipt.assetId),
1534
1470
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1571,7 +1507,7 @@ function assembleReceiptByType(receipt) {
1571
1507
  return receiptMessageOut;
1572
1508
  }
1573
1509
  case "MINT" /* Mint */: {
1574
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1510
+ const contractId = hexOrZero(receipt.contract?.id);
1575
1511
  const subId = hexOrZero(receipt.subId);
1576
1512
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1577
1513
  const mintReceipt = {
@@ -1586,7 +1522,7 @@ function assembleReceiptByType(receipt) {
1586
1522
  return mintReceipt;
1587
1523
  }
1588
1524
  case "BURN" /* Burn */: {
1589
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1525
+ const contractId = hexOrZero(receipt.contract?.id);
1590
1526
  const subId = hexOrZero(receipt.subId);
1591
1527
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1592
1528
  const burnReceipt = {
@@ -1671,6 +1607,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1671
1607
  var import_math5 = require("@fuel-ts/math");
1672
1608
  var import_transactions4 = require("@fuel-ts/transactions");
1673
1609
  var import_utils6 = require("@fuel-ts/utils");
1610
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1674
1611
  var getGasUsedFromReceipts = (receipts) => {
1675
1612
  const scriptResult = receipts.filter(
1676
1613
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1691,28 +1628,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1691
1628
  }
1692
1629
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1693
1630
  const witnessCache = [];
1694
- const chargeableInputs = inputs.filter((input) => {
1695
- const isCoinOrMessage = "owner" in input || "sender" in input;
1696
- if (isCoinOrMessage) {
1697
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1698
- return true;
1699
- }
1700
- if (!witnessCache.includes(input.witnessIndex)) {
1701
- witnessCache.push(input.witnessIndex);
1702
- return true;
1703
- }
1704
- }
1705
- return false;
1706
- });
1707
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1708
- const totalGas = chargeableInputs.reduce((total, input) => {
1631
+ const totalGas = inputs.reduce((total, input) => {
1709
1632
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1710
1633
  return total.add(
1711
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1634
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1712
1635
  );
1713
1636
  }
1714
- return total.add(gasCosts.ecr1);
1715
- }, (0, import_math5.bn)(0));
1637
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1638
+ witnessCache.push(input.witnessIndex);
1639
+ return total.add(gasCosts.ecr1);
1640
+ }
1641
+ return total;
1642
+ }, (0, import_math5.bn)());
1716
1643
  return totalGas;
1717
1644
  }
1718
1645
  function getMinGas(params) {
@@ -1724,20 +1651,12 @@ function getMinGas(params) {
1724
1651
  return minGas;
1725
1652
  }
1726
1653
  function getMaxGas(params) {
1727
- const {
1728
- gasPerByte,
1729
- witnessesLength,
1730
- witnessLimit,
1731
- minGas,
1732
- gasLimit = (0, import_math5.bn)(0),
1733
- maxGasPerTx
1734
- } = params;
1654
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1735
1655
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1736
1656
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1737
1657
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1738
1658
  }
1739
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1740
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1659
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1741
1660
  }
1742
1661
  function calculateMetadataGasForTxCreate({
1743
1662
  gasCosts,
@@ -1759,10 +1678,6 @@ function calculateMetadataGasForTxScript({
1759
1678
  }) {
1760
1679
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1761
1680
  }
1762
- var calculateGasFee = (params) => {
1763
- const { gas, gasPrice, priceFactor, tip } = params;
1764
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1765
- };
1766
1681
 
1767
1682
  // src/providers/utils/json.ts
1768
1683
  var import_utils7 = require("@fuel-ts/utils");
@@ -1898,6 +1813,28 @@ var NoWitnessByOwnerError = class extends Error {
1898
1813
  name = "NoWitnessByOwnerError";
1899
1814
  };
1900
1815
 
1816
+ // src/providers/transaction-request/helpers.ts
1817
+ var import_transactions6 = require("@fuel-ts/transactions");
1818
+ var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1819
+ var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1820
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1821
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1822
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1823
+ var cacheResources = (resources) => resources.reduce(
1824
+ (cache2, resource) => {
1825
+ if (isCoin(resource)) {
1826
+ cache2.utxos.push(resource.id);
1827
+ } else {
1828
+ cache2.messages.push(resource.nonce);
1829
+ }
1830
+ return cache2;
1831
+ },
1832
+ {
1833
+ utxos: [],
1834
+ messages: []
1835
+ }
1836
+ );
1837
+
1901
1838
  // src/providers/transaction-request/witness.ts
1902
1839
  var import_utils8 = require("@fuel-ts/utils");
1903
1840
  var witnessify = (value) => {
@@ -1911,7 +1848,7 @@ var witnessify = (value) => {
1911
1848
  // src/providers/transaction-request/transaction-request.ts
1912
1849
  var BaseTransactionRequest = class {
1913
1850
  /** Gas price for transaction */
1914
- tip;
1851
+ gasPrice;
1915
1852
  /** Block until which tx cannot be included */
1916
1853
  maturity;
1917
1854
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1930,7 +1867,7 @@ var BaseTransactionRequest = class {
1930
1867
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1931
1868
  */
1932
1869
  constructor({
1933
- tip,
1870
+ gasPrice,
1934
1871
  maturity,
1935
1872
  maxFee,
1936
1873
  witnessLimit,
@@ -1938,7 +1875,7 @@ var BaseTransactionRequest = class {
1938
1875
  outputs,
1939
1876
  witnesses
1940
1877
  } = {}) {
1941
- this.tip = (0, import_math7.bn)(tip);
1878
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1942
1879
  this.maturity = maturity ?? 0;
1943
1880
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1944
1881
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1949,21 +1886,21 @@ var BaseTransactionRequest = class {
1949
1886
  static getPolicyMeta(req) {
1950
1887
  let policyTypes = 0;
1951
1888
  const policies = [];
1952
- if (req.tip) {
1953
- policyTypes += import_transactions6.PolicyType.Tip;
1954
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1889
+ if (req.gasPrice) {
1890
+ policyTypes += import_transactions7.PolicyType.GasPrice;
1891
+ policies.push({ data: req.gasPrice, type: import_transactions7.PolicyType.GasPrice });
1955
1892
  }
1956
1893
  if (req.witnessLimit) {
1957
- policyTypes += import_transactions6.PolicyType.WitnessLimit;
1958
- policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1894
+ policyTypes += import_transactions7.PolicyType.WitnessLimit;
1895
+ policies.push({ data: req.witnessLimit, type: import_transactions7.PolicyType.WitnessLimit });
1959
1896
  }
1960
1897
  if (req.maturity > 0) {
1961
- policyTypes += import_transactions6.PolicyType.Maturity;
1962
- policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1898
+ policyTypes += import_transactions7.PolicyType.Maturity;
1899
+ policies.push({ data: req.maturity, type: import_transactions7.PolicyType.Maturity });
1963
1900
  }
1964
1901
  if (req.maxFee) {
1965
- policyTypes += import_transactions6.PolicyType.MaxFee;
1966
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1902
+ policyTypes += import_transactions7.PolicyType.MaxFee;
1903
+ policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
1967
1904
  }
1968
1905
  return {
1969
1906
  policyTypes,
@@ -1997,7 +1934,7 @@ var BaseTransactionRequest = class {
1997
1934
  * @returns The transaction bytes.
1998
1935
  */
1999
1936
  toTransactionBytes() {
2000
- return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1937
+ return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2001
1938
  }
2002
1939
  /**
2003
1940
  * @hidden
@@ -2088,7 +2025,7 @@ var BaseTransactionRequest = class {
2088
2025
  */
2089
2026
  getCoinInputs() {
2090
2027
  return this.inputs.filter(
2091
- (input) => input.type === import_transactions6.InputType.Coin
2028
+ (input) => input.type === import_transactions7.InputType.Coin
2092
2029
  );
2093
2030
  }
2094
2031
  /**
@@ -2098,7 +2035,7 @@ var BaseTransactionRequest = class {
2098
2035
  */
2099
2036
  getCoinOutputs() {
2100
2037
  return this.outputs.filter(
2101
- (output) => output.type === import_transactions6.OutputType.Coin
2038
+ (output) => output.type === import_transactions7.OutputType.Coin
2102
2039
  );
2103
2040
  }
2104
2041
  /**
@@ -2108,7 +2045,7 @@ var BaseTransactionRequest = class {
2108
2045
  */
2109
2046
  getChangeOutputs() {
2110
2047
  return this.outputs.filter(
2111
- (output) => output.type === import_transactions6.OutputType.Change
2048
+ (output) => output.type === import_transactions7.OutputType.Change
2112
2049
  );
2113
2050
  }
2114
2051
  /**
@@ -2120,9 +2057,9 @@ var BaseTransactionRequest = class {
2120
2057
  const ownerAddress = (0, import_address.addressify)(owner);
2121
2058
  const found = this.inputs.find((input) => {
2122
2059
  switch (input.type) {
2123
- case import_transactions6.InputType.Coin:
2060
+ case import_transactions7.InputType.Coin:
2124
2061
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
2125
- case import_transactions6.InputType.Message:
2062
+ case import_transactions7.InputType.Message:
2126
2063
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
2127
2064
  default:
2128
2065
  return false;
@@ -2135,11 +2072,13 @@ var BaseTransactionRequest = class {
2135
2072
  * assetId, if one it was not added yet.
2136
2073
  *
2137
2074
  * @param coin - Coin resource.
2075
+ * @param predicate - Predicate bytes.
2076
+ * @param predicateData - Predicate data bytes.
2138
2077
  */
2139
2078
  addCoinInput(coin) {
2140
- const { assetId, owner, amount } = coin;
2079
+ const { assetId, owner, amount, id, predicate } = coin;
2141
2080
  let witnessIndex;
2142
- if (coin.predicate) {
2081
+ if (predicate) {
2143
2082
  witnessIndex = 0;
2144
2083
  } else {
2145
2084
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2148,13 +2087,14 @@ var BaseTransactionRequest = class {
2148
2087
  }
2149
2088
  }
2150
2089
  const input = {
2151
- ...coin,
2152
- type: import_transactions6.InputType.Coin,
2090
+ id,
2091
+ type: import_transactions7.InputType.Coin,
2153
2092
  owner: owner.toB256(),
2154
2093
  amount,
2155
2094
  assetId,
2156
2095
  txPointer: "0x00000000000000000000000000000000",
2157
- witnessIndex
2096
+ witnessIndex,
2097
+ predicate
2158
2098
  };
2159
2099
  this.pushInput(input);
2160
2100
  this.addChangeOutput(owner, assetId);
@@ -2164,12 +2104,14 @@ var BaseTransactionRequest = class {
2164
2104
  * baseAssetId, if one it was not added yet.
2165
2105
  *
2166
2106
  * @param message - Message resource.
2107
+ * @param predicate - Predicate bytes.
2108
+ * @param predicateData - Predicate data bytes.
2167
2109
  */
2168
2110
  addMessageInput(message) {
2169
- const { recipient, sender, amount } = message;
2111
+ const { recipient, sender, amount, predicate, nonce } = message;
2170
2112
  const assetId = import_configs7.BaseAssetId;
2171
2113
  let witnessIndex;
2172
- if (message.predicate) {
2114
+ if (predicate) {
2173
2115
  witnessIndex = 0;
2174
2116
  } else {
2175
2117
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2178,12 +2120,13 @@ var BaseTransactionRequest = class {
2178
2120
  }
2179
2121
  }
2180
2122
  const input = {
2181
- ...message,
2182
- type: import_transactions6.InputType.Message,
2123
+ nonce,
2124
+ type: import_transactions7.InputType.Message,
2183
2125
  sender: sender.toB256(),
2184
2126
  recipient: recipient.toB256(),
2185
2127
  amount,
2186
- witnessIndex
2128
+ witnessIndex,
2129
+ predicate
2187
2130
  };
2188
2131
  this.pushInput(input);
2189
2132
  this.addChangeOutput(recipient, assetId);
@@ -2223,7 +2166,7 @@ var BaseTransactionRequest = class {
2223
2166
  */
2224
2167
  addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2225
2168
  this.pushOutput({
2226
- type: import_transactions6.OutputType.Coin,
2169
+ type: import_transactions7.OutputType.Coin,
2227
2170
  to: (0, import_address.addressify)(to).toB256(),
2228
2171
  amount,
2229
2172
  assetId
@@ -2239,7 +2182,7 @@ var BaseTransactionRequest = class {
2239
2182
  addCoinOutputs(to, quantities) {
2240
2183
  quantities.map(coinQuantityfy).forEach((quantity) => {
2241
2184
  this.pushOutput({
2242
- type: import_transactions6.OutputType.Coin,
2185
+ type: import_transactions7.OutputType.Coin,
2243
2186
  to: (0, import_address.addressify)(to).toB256(),
2244
2187
  amount: quantity.amount,
2245
2188
  assetId: quantity.assetId
@@ -2259,7 +2202,7 @@ var BaseTransactionRequest = class {
2259
2202
  );
2260
2203
  if (!changeOutput) {
2261
2204
  this.pushOutput({
2262
- type: import_transactions6.OutputType.Change,
2205
+ type: import_transactions7.OutputType.Change,
2263
2206
  to: (0, import_address.addressify)(to).toB256(),
2264
2207
  assetId
2265
2208
  });
@@ -2293,7 +2236,7 @@ var BaseTransactionRequest = class {
2293
2236
  }
2294
2237
  calculateMaxGas(chainInfo, minGas) {
2295
2238
  const { consensusParameters } = chainInfo;
2296
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2239
+ const { gasPerByte } = consensusParameters;
2297
2240
  const witnessesLength = this.toTransaction().witnesses.reduce(
2298
2241
  (acc, wit) => acc + wit.dataLength,
2299
2242
  0
@@ -2302,8 +2245,7 @@ var BaseTransactionRequest = class {
2302
2245
  gasPerByte,
2303
2246
  minGas,
2304
2247
  witnessesLength,
2305
- witnessLimit: this.witnessLimit,
2306
- maxGasPerTx
2248
+ witnessLimit: this.witnessLimit
2307
2249
  });
2308
2250
  }
2309
2251
  /**
@@ -2321,20 +2263,17 @@ var BaseTransactionRequest = class {
2321
2263
  });
2322
2264
  const updateAssetInput = (assetId, quantity) => {
2323
2265
  const assetInput = findAssetInput(assetId);
2324
- let usedQuantity = quantity;
2325
- if (assetId === import_configs7.BaseAssetId) {
2326
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2327
- }
2328
2266
  if (assetInput && "assetId" in assetInput) {
2329
2267
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2330
- assetInput.amount = usedQuantity;
2268
+ assetInput.amount = quantity;
2331
2269
  } else {
2332
2270
  this.addResources([
2333
2271
  {
2334
2272
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2335
- amount: usedQuantity,
2273
+ amount: quantity,
2336
2274
  assetId,
2337
2275
  owner: resourcesOwner || import_address.Address.fromRandom(),
2276
+ maturity: 0,
2338
2277
  blockCreated: (0, import_math7.bn)(1),
2339
2278
  txCreatedIdx: (0, import_math7.bn)(1)
2340
2279
  }
@@ -2366,16 +2305,20 @@ var BaseTransactionRequest = class {
2366
2305
  toJSON() {
2367
2306
  return normalizeJSON(this);
2368
2307
  }
2369
- updatePredicateGasUsed(inputs) {
2308
+ removeWitness(index) {
2309
+ this.witnesses.splice(index, 1);
2310
+ this.adjustWitnessIndexes(index);
2311
+ }
2312
+ updatePredicateInputs(inputs) {
2370
2313
  this.inputs.forEach((i) => {
2371
2314
  let correspondingInput;
2372
2315
  switch (i.type) {
2373
- case import_transactions6.InputType.Coin:
2374
- correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2316
+ case import_transactions7.InputType.Coin:
2317
+ correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2375
2318
  break;
2376
- case import_transactions6.InputType.Message:
2319
+ case import_transactions7.InputType.Message:
2377
2320
  correspondingInput = inputs.find(
2378
- (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2321
+ (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2379
2322
  );
2380
2323
  break;
2381
2324
  default:
@@ -2388,12 +2331,10 @@ var BaseTransactionRequest = class {
2388
2331
  }
2389
2332
  });
2390
2333
  }
2391
- shiftPredicateData() {
2392
- this.inputs.forEach((input) => {
2393
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2394
- input.predicateData = input.padPredicateData(
2395
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2396
- );
2334
+ adjustWitnessIndexes(removedIndex) {
2335
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2336
+ if (input.witnessIndex > removedIndex) {
2337
+ input.witnessIndex -= 1;
2397
2338
  }
2398
2339
  });
2399
2340
  }
@@ -2402,25 +2343,25 @@ var BaseTransactionRequest = class {
2402
2343
  // src/providers/transaction-request/create-transaction-request.ts
2403
2344
  var import_configs9 = require("@fuel-ts/address/configs");
2404
2345
  var import_math9 = require("@fuel-ts/math");
2405
- var import_transactions8 = require("@fuel-ts/transactions");
2346
+ var import_transactions9 = require("@fuel-ts/transactions");
2406
2347
  var import_utils13 = require("@fuel-ts/utils");
2407
2348
 
2408
2349
  // src/providers/transaction-request/hash-transaction.ts
2409
2350
  var import_configs8 = require("@fuel-ts/address/configs");
2410
2351
  var import_hasher = require("@fuel-ts/hasher");
2411
2352
  var import_math8 = require("@fuel-ts/math");
2412
- var import_transactions7 = require("@fuel-ts/transactions");
2353
+ var import_transactions8 = require("@fuel-ts/transactions");
2413
2354
  var import_utils11 = require("@fuel-ts/utils");
2414
2355
  var import_ramda2 = require("ramda");
2415
2356
  function hashTransaction(transactionRequest, chainId) {
2416
2357
  const transaction = transactionRequest.toTransaction();
2417
- if (transaction.type === import_transactions7.TransactionType.Script) {
2358
+ if (transaction.type === import_transactions8.TransactionType.Script) {
2418
2359
  transaction.receiptsRoot = import_configs8.ZeroBytes32;
2419
2360
  }
2420
2361
  transaction.inputs = transaction.inputs.map((input) => {
2421
2362
  const inputClone = (0, import_ramda2.clone)(input);
2422
2363
  switch (inputClone.type) {
2423
- case import_transactions7.InputType.Coin: {
2364
+ case import_transactions8.InputType.Coin: {
2424
2365
  inputClone.txPointer = {
2425
2366
  blockHeight: 0,
2426
2367
  txIndex: 0
@@ -2428,11 +2369,11 @@ function hashTransaction(transactionRequest, chainId) {
2428
2369
  inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2429
2370
  return inputClone;
2430
2371
  }
2431
- case import_transactions7.InputType.Message: {
2372
+ case import_transactions8.InputType.Message: {
2432
2373
  inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2433
2374
  return inputClone;
2434
2375
  }
2435
- case import_transactions7.InputType.Contract: {
2376
+ case import_transactions8.InputType.Contract: {
2436
2377
  inputClone.txPointer = {
2437
2378
  blockHeight: 0,
2438
2379
  txIndex: 0
@@ -2450,16 +2391,16 @@ function hashTransaction(transactionRequest, chainId) {
2450
2391
  transaction.outputs = transaction.outputs.map((output) => {
2451
2392
  const outputClone = (0, import_ramda2.clone)(output);
2452
2393
  switch (outputClone.type) {
2453
- case import_transactions7.OutputType.Contract: {
2394
+ case import_transactions8.OutputType.Contract: {
2454
2395
  outputClone.balanceRoot = import_configs8.ZeroBytes32;
2455
2396
  outputClone.stateRoot = import_configs8.ZeroBytes32;
2456
2397
  return outputClone;
2457
2398
  }
2458
- case import_transactions7.OutputType.Change: {
2399
+ case import_transactions8.OutputType.Change: {
2459
2400
  outputClone.amount = (0, import_math8.bn)(0);
2460
2401
  return outputClone;
2461
2402
  }
2462
- case import_transactions7.OutputType.Variable: {
2403
+ case import_transactions8.OutputType.Variable: {
2463
2404
  outputClone.to = import_configs8.ZeroBytes32;
2464
2405
  outputClone.amount = (0, import_math8.bn)(0);
2465
2406
  outputClone.assetId = import_configs8.ZeroBytes32;
@@ -2472,7 +2413,7 @@ function hashTransaction(transactionRequest, chainId) {
2472
2413
  transaction.witnessesCount = 0;
2473
2414
  transaction.witnesses = [];
2474
2415
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2475
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2416
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
2476
2417
  return (0, import_hasher.sha256)(concatenatedData);
2477
2418
  }
2478
2419
 
@@ -2508,7 +2449,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2508
2449
  return new this(obj);
2509
2450
  }
2510
2451
  /** Type of the transaction */
2511
- type = import_transactions8.TransactionType.Create;
2452
+ type = import_transactions9.TransactionType.Create;
2512
2453
  /** Witness index of contract bytecode to create */
2513
2454
  bytecodeWitnessIndex;
2514
2455
  /** Salt */
@@ -2541,10 +2482,11 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2541
2482
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2542
2483
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2543
2484
  return {
2544
- type: import_transactions8.TransactionType.Create,
2485
+ type: import_transactions9.TransactionType.Create,
2545
2486
  ...baseTransaction,
2487
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2546
2488
  bytecodeWitnessIndex,
2547
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2489
+ storageSlotsCount: storageSlots.length,
2548
2490
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2549
2491
  storageSlots
2550
2492
  };
@@ -2556,7 +2498,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2556
2498
  */
2557
2499
  getContractCreatedOutputs() {
2558
2500
  return this.outputs.filter(
2559
- (output) => output.type === import_transactions8.OutputType.ContractCreated
2501
+ (output) => output.type === import_transactions9.OutputType.ContractCreated
2560
2502
  );
2561
2503
  }
2562
2504
  /**
@@ -2577,7 +2519,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2577
2519
  */
2578
2520
  addContractCreatedOutput(contractId, stateRoot) {
2579
2521
  this.pushOutput({
2580
- type: import_transactions8.OutputType.ContractCreated,
2522
+ type: import_transactions9.OutputType.ContractCreated,
2581
2523
  contractId,
2582
2524
  stateRoot
2583
2525
  });
@@ -2597,7 +2539,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2597
2539
  var import_address2 = require("@fuel-ts/address");
2598
2540
  var import_configs10 = require("@fuel-ts/address/configs");
2599
2541
  var import_math10 = require("@fuel-ts/math");
2600
- var import_transactions9 = require("@fuel-ts/transactions");
2542
+ var import_transactions10 = require("@fuel-ts/transactions");
2601
2543
  var import_utils15 = require("@fuel-ts/utils");
2602
2544
 
2603
2545
  // src/providers/transaction-request/scripts.ts
@@ -2635,7 +2577,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2635
2577
  return new this(obj);
2636
2578
  }
2637
2579
  /** Type of the transaction */
2638
- type = import_transactions9.TransactionType.Script;
2580
+ type = import_transactions10.TransactionType.Script;
2639
2581
  /** Gas limit for transaction */
2640
2582
  gasLimit;
2641
2583
  /** Script to execute */
@@ -2664,11 +2606,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2664
2606
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2665
2607
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2666
2608
  return {
2667
- type: import_transactions9.TransactionType.Script,
2609
+ type: import_transactions10.TransactionType.Script,
2668
2610
  scriptGasLimit: this.gasLimit,
2669
2611
  ...super.getBaseTransaction(),
2670
- scriptLength: (0, import_math10.bn)(script.length),
2671
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2612
+ scriptLength: script.length,
2613
+ scriptDataLength: scriptData.length,
2672
2614
  receiptsRoot: import_configs10.ZeroBytes32,
2673
2615
  script: (0, import_utils15.hexlify)(script),
2674
2616
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2681,7 +2623,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2681
2623
  */
2682
2624
  getContractInputs() {
2683
2625
  return this.inputs.filter(
2684
- (input) => input.type === import_transactions9.InputType.Contract
2626
+ (input) => input.type === import_transactions10.InputType.Contract
2685
2627
  );
2686
2628
  }
2687
2629
  /**
@@ -2691,7 +2633,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2691
2633
  */
2692
2634
  getContractOutputs() {
2693
2635
  return this.outputs.filter(
2694
- (output) => output.type === import_transactions9.OutputType.Contract
2636
+ (output) => output.type === import_transactions10.OutputType.Contract
2695
2637
  );
2696
2638
  }
2697
2639
  /**
@@ -2701,7 +2643,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2701
2643
  */
2702
2644
  getVariableOutputs() {
2703
2645
  return this.outputs.filter(
2704
- (output) => output.type === import_transactions9.OutputType.Variable
2646
+ (output) => output.type === import_transactions10.OutputType.Variable
2705
2647
  );
2706
2648
  }
2707
2649
  /**
@@ -2724,7 +2666,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2724
2666
  let outputsNumber = numberOfVariables;
2725
2667
  while (outputsNumber) {
2726
2668
  this.pushOutput({
2727
- type: import_transactions9.OutputType.Variable
2669
+ type: import_transactions10.OutputType.Variable
2728
2670
  });
2729
2671
  outputsNumber -= 1;
2730
2672
  }
@@ -2732,7 +2674,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2732
2674
  }
2733
2675
  calculateMaxGas(chainInfo, minGas) {
2734
2676
  const { consensusParameters } = chainInfo;
2735
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2677
+ const { gasPerByte } = consensusParameters;
2736
2678
  const witnessesLength = this.toTransaction().witnesses.reduce(
2737
2679
  (acc, wit) => acc + wit.dataLength,
2738
2680
  0
@@ -2742,8 +2684,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2742
2684
  minGas,
2743
2685
  witnessesLength,
2744
2686
  witnessLimit: this.witnessLimit,
2745
- gasLimit: this.gasLimit,
2746
- maxGasPerTx
2687
+ gasLimit: this.gasLimit
2747
2688
  });
2748
2689
  }
2749
2690
  /**
@@ -2758,12 +2699,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2758
2699
  return this;
2759
2700
  }
2760
2701
  const inputIndex = super.pushInput({
2761
- type: import_transactions9.InputType.Contract,
2702
+ type: import_transactions10.InputType.Contract,
2762
2703
  contractId: contractAddress.toB256(),
2763
2704
  txPointer: "0x00000000000000000000000000000000"
2764
2705
  });
2765
2706
  this.pushOutput({
2766
- type: import_transactions9.OutputType.Contract,
2707
+ type: import_transactions10.OutputType.Contract,
2767
2708
  inputIndex
2768
2709
  });
2769
2710
  return this;
@@ -2800,17 +2741,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2800
2741
 
2801
2742
  // src/providers/transaction-request/utils.ts
2802
2743
  var import_errors9 = require("@fuel-ts/errors");
2803
- var import_transactions10 = require("@fuel-ts/transactions");
2744
+ var import_transactions11 = require("@fuel-ts/transactions");
2804
2745
  var transactionRequestify = (obj) => {
2805
2746
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2806
2747
  return obj;
2807
2748
  }
2808
2749
  const { type } = obj;
2809
2750
  switch (obj.type) {
2810
- case import_transactions10.TransactionType.Script: {
2751
+ case import_transactions11.TransactionType.Script: {
2811
2752
  return ScriptTransactionRequest.from(obj);
2812
2753
  }
2813
- case import_transactions10.TransactionType.Create: {
2754
+ case import_transactions11.TransactionType.Create: {
2814
2755
  return CreateTransactionRequest.from(obj);
2815
2756
  }
2816
2757
  default: {
@@ -2818,59 +2759,42 @@ var transactionRequestify = (obj) => {
2818
2759
  }
2819
2760
  }
2820
2761
  };
2821
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2822
- (acc, input) => {
2823
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2824
- acc.utxos.push(input.id);
2825
- }
2826
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2827
- acc.messages.push(input.nonce);
2828
- }
2829
- return acc;
2830
- },
2831
- {
2832
- utxos: [],
2833
- messages: []
2834
- }
2835
- );
2836
2762
 
2837
2763
  // src/providers/transaction-response/transaction-response.ts
2838
2764
  var import_errors13 = require("@fuel-ts/errors");
2839
- var import_math15 = require("@fuel-ts/math");
2765
+ var import_math14 = require("@fuel-ts/math");
2840
2766
  var import_transactions18 = require("@fuel-ts/transactions");
2841
- var import_utils20 = require("@fuel-ts/utils");
2767
+ var import_utils21 = require("@fuel-ts/utils");
2842
2768
 
2843
2769
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2844
- var import_math14 = require("@fuel-ts/math");
2845
- var import_transactions16 = require("@fuel-ts/transactions");
2846
- var import_utils18 = require("@fuel-ts/utils");
2770
+ var import_utils19 = require("@fuel-ts/utils");
2847
2771
 
2848
2772
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2849
2773
  var import_math11 = require("@fuel-ts/math");
2850
- var import_transactions11 = require("@fuel-ts/transactions");
2774
+ var import_transactions12 = require("@fuel-ts/transactions");
2851
2775
  var import_utils16 = require("@fuel-ts/utils");
2852
2776
  var calculateTransactionFee = (params) => {
2853
2777
  const {
2854
- gasPrice,
2778
+ gasUsed,
2855
2779
  rawPayload,
2856
- tip,
2857
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2780
+ consensusParameters: { gasCosts, feeParams }
2858
2781
  } = params;
2859
2782
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2860
2783
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2861
2784
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2862
- const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2863
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2785
+ const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
2786
+ if (transaction.type === import_transactions12.TransactionType.Mint) {
2864
2787
  return {
2865
2788
  fee: (0, import_math11.bn)(0),
2866
2789
  minFee: (0, import_math11.bn)(0),
2867
- maxFee: (0, import_math11.bn)(0)
2790
+ maxFee: (0, import_math11.bn)(0),
2791
+ feeFromGasUsed: (0, import_math11.bn)(0)
2868
2792
  };
2869
2793
  }
2870
2794
  const { type, witnesses, inputs, policies } = transaction;
2871
2795
  let metadataGas = (0, import_math11.bn)(0);
2872
2796
  let gasLimit = (0, import_math11.bn)(0);
2873
- if (type === import_transactions11.TransactionType.Create) {
2797
+ if (type === import_transactions12.TransactionType.Create) {
2874
2798
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2875
2799
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2876
2800
  metadataGas = calculateMetadataGasForTxCreate({
@@ -2896,32 +2820,25 @@ var calculateTransactionFee = (params) => {
2896
2820
  metadataGas,
2897
2821
  txBytesSize: transactionBytes.length
2898
2822
  });
2899
- const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2823
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions12.PolicyType.GasPrice)?.data);
2824
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
2900
2825
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2901
2826
  const maxGas = getMaxGas({
2902
2827
  gasPerByte,
2903
2828
  minGas,
2904
2829
  witnessesLength,
2905
2830
  gasLimit,
2906
- witnessLimit,
2907
- maxGasPerTx
2908
- });
2909
- const minFee = calculateGasFee({
2910
- gasPrice,
2911
- gas: minGas,
2912
- priceFactor: gasPriceFactor,
2913
- tip
2914
- });
2915
- const maxFee = calculateGasFee({
2916
- gasPrice,
2917
- gas: maxGas,
2918
- priceFactor: gasPriceFactor,
2919
- tip
2831
+ witnessLimit
2920
2832
  });
2833
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2834
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2835
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2836
+ const fee = minFee.add(feeFromGasUsed);
2921
2837
  return {
2838
+ fee,
2922
2839
  minFee,
2923
2840
  maxFee,
2924
- fee: maxFee
2841
+ feeFromGasUsed
2925
2842
  };
2926
2843
  };
2927
2844
 
@@ -2929,7 +2846,7 @@ var calculateTransactionFee = (params) => {
2929
2846
  var import_configs11 = require("@fuel-ts/address/configs");
2930
2847
  var import_errors11 = require("@fuel-ts/errors");
2931
2848
  var import_math13 = require("@fuel-ts/math");
2932
- var import_transactions14 = require("@fuel-ts/transactions");
2849
+ var import_transactions15 = require("@fuel-ts/transactions");
2933
2850
 
2934
2851
  // src/providers/transaction-summary/call.ts
2935
2852
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
@@ -2977,7 +2894,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2977
2894
 
2978
2895
  // src/providers/transaction-summary/input.ts
2979
2896
  var import_errors10 = require("@fuel-ts/errors");
2980
- var import_transactions12 = require("@fuel-ts/transactions");
2897
+ var import_transactions13 = require("@fuel-ts/transactions");
2981
2898
  function getInputsByTypes(inputs, types) {
2982
2899
  return inputs.filter((i) => types.includes(i.type));
2983
2900
  }
@@ -2985,16 +2902,16 @@ function getInputsByType(inputs, type) {
2985
2902
  return inputs.filter((i) => i.type === type);
2986
2903
  }
2987
2904
  function getInputsCoin(inputs) {
2988
- return getInputsByType(inputs, import_transactions12.InputType.Coin);
2905
+ return getInputsByType(inputs, import_transactions13.InputType.Coin);
2989
2906
  }
2990
2907
  function getInputsMessage(inputs) {
2991
- return getInputsByType(inputs, import_transactions12.InputType.Message);
2908
+ return getInputsByType(inputs, import_transactions13.InputType.Message);
2992
2909
  }
2993
2910
  function getInputsCoinAndMessage(inputs) {
2994
- return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2911
+ return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
2995
2912
  }
2996
2913
  function getInputsContract(inputs) {
2997
- return getInputsByType(inputs, import_transactions12.InputType.Contract);
2914
+ return getInputsByType(inputs, import_transactions13.InputType.Contract);
2998
2915
  }
2999
2916
  function getInputFromAssetId(inputs, assetId) {
3000
2917
  const coinInputs = getInputsCoin(inputs);
@@ -3013,7 +2930,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
3013
2930
  if (!contractInput) {
3014
2931
  return void 0;
3015
2932
  }
3016
- if (contractInput.type !== import_transactions12.InputType.Contract) {
2933
+ if (contractInput.type !== import_transactions13.InputType.Contract) {
3017
2934
  throw new import_errors10.FuelError(
3018
2935
  import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
3019
2936
  `Contract input should be of type 'contract'.`
@@ -3022,34 +2939,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
3022
2939
  return contractInput;
3023
2940
  }
3024
2941
  function getInputAccountAddress(input) {
3025
- if (input.type === import_transactions12.InputType.Coin) {
2942
+ if (input.type === import_transactions13.InputType.Coin) {
3026
2943
  return input.owner.toString();
3027
2944
  }
3028
- if (input.type === import_transactions12.InputType.Message) {
2945
+ if (input.type === import_transactions13.InputType.Message) {
3029
2946
  return input.recipient.toString();
3030
2947
  }
3031
2948
  return "";
3032
2949
  }
3033
2950
 
3034
2951
  // src/providers/transaction-summary/output.ts
3035
- var import_transactions13 = require("@fuel-ts/transactions");
2952
+ var import_transactions14 = require("@fuel-ts/transactions");
3036
2953
  function getOutputsByType(outputs, type) {
3037
2954
  return outputs.filter((o) => o.type === type);
3038
2955
  }
3039
2956
  function getOutputsContractCreated(outputs) {
3040
- return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2957
+ return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
3041
2958
  }
3042
2959
  function getOutputsCoin(outputs) {
3043
- return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2960
+ return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
3044
2961
  }
3045
2962
  function getOutputsChange(outputs) {
3046
- return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2963
+ return getOutputsByType(outputs, import_transactions14.OutputType.Change);
3047
2964
  }
3048
2965
  function getOutputsContract(outputs) {
3049
- return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2966
+ return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
3050
2967
  }
3051
2968
  function getOutputsVariable(outputs) {
3052
- return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
2969
+ return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
3053
2970
  }
3054
2971
 
3055
2972
  // src/providers/transaction-summary/types.ts
@@ -3096,11 +3013,11 @@ function getReceiptsByType(receipts, type) {
3096
3013
  }
3097
3014
  function getTransactionTypeName(transactionType) {
3098
3015
  switch (transactionType) {
3099
- case import_transactions14.TransactionType.Mint:
3016
+ case import_transactions15.TransactionType.Mint:
3100
3017
  return "Mint" /* Mint */;
3101
- case import_transactions14.TransactionType.Create:
3018
+ case import_transactions15.TransactionType.Create:
3102
3019
  return "Create" /* Create */;
3103
- case import_transactions14.TransactionType.Script:
3020
+ case import_transactions15.TransactionType.Script:
3104
3021
  return "Script" /* Script */;
3105
3022
  default:
3106
3023
  throw new import_errors11.FuelError(
@@ -3126,10 +3043,10 @@ function hasSameAssetId(a) {
3126
3043
  return (b) => a.assetId === b.assetId;
3127
3044
  }
3128
3045
  function getReceiptsCall(receipts) {
3129
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
3046
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
3130
3047
  }
3131
3048
  function getReceiptsMessageOut(receipts) {
3132
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
3049
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
3133
3050
  }
3134
3051
  var mergeAssets = (op1, op2) => {
3135
3052
  const assets1 = op1.assetsSent || [];
@@ -3168,7 +3085,7 @@ function addOperation(operations, toAdd) {
3168
3085
  return allOperations;
3169
3086
  }
3170
3087
  function getReceiptsTransferOut(receipts) {
3171
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
3088
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
3172
3089
  }
3173
3090
  function getWithdrawFromFuelOperations({
3174
3091
  inputs,
@@ -3328,11 +3245,11 @@ function getTransferOperations({
3328
3245
  });
3329
3246
  const transferReceipts = getReceiptsByType(
3330
3247
  receipts,
3331
- import_transactions14.ReceiptType.Transfer
3248
+ import_transactions15.ReceiptType.Transfer
3332
3249
  );
3333
3250
  const transferOutReceipts = getReceiptsByType(
3334
3251
  receipts,
3335
- import_transactions14.ReceiptType.TransferOut
3252
+ import_transactions15.ReceiptType.TransferOut
3336
3253
  );
3337
3254
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3338
3255
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3417,17 +3334,17 @@ function getOperations({
3417
3334
  }
3418
3335
 
3419
3336
  // src/providers/transaction-summary/receipt.ts
3420
- var import_transactions15 = require("@fuel-ts/transactions");
3337
+ var import_transactions16 = require("@fuel-ts/transactions");
3421
3338
  var processGqlReceipt = (gqlReceipt) => {
3422
3339
  const receipt = assembleReceiptByType(gqlReceipt);
3423
3340
  switch (receipt.type) {
3424
- case import_transactions15.ReceiptType.ReturnData: {
3341
+ case import_transactions16.ReceiptType.ReturnData: {
3425
3342
  return {
3426
3343
  ...receipt,
3427
3344
  data: gqlReceipt.data || "0x"
3428
3345
  };
3429
3346
  }
3430
- case import_transactions15.ReceiptType.LogData: {
3347
+ case import_transactions16.ReceiptType.LogData: {
3431
3348
  return {
3432
3349
  ...receipt,
3433
3350
  data: gqlReceipt.data || "0x"
@@ -3440,7 +3357,7 @@ var processGqlReceipt = (gqlReceipt) => {
3440
3357
  var extractMintedAssetsFromReceipts = (receipts) => {
3441
3358
  const mintedAssets = [];
3442
3359
  receipts.forEach((receipt) => {
3443
- if (receipt.type === import_transactions15.ReceiptType.Mint) {
3360
+ if (receipt.type === import_transactions16.ReceiptType.Mint) {
3444
3361
  mintedAssets.push({
3445
3362
  subId: receipt.subId,
3446
3363
  contractId: receipt.contractId,
@@ -3454,7 +3371,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3454
3371
  var extractBurnedAssetsFromReceipts = (receipts) => {
3455
3372
  const burnedAssets = [];
3456
3373
  receipts.forEach((receipt) => {
3457
- if (receipt.type === import_transactions15.ReceiptType.Burn) {
3374
+ if (receipt.type === import_transactions16.ReceiptType.Burn) {
3458
3375
  burnedAssets.push({
3459
3376
  subId: receipt.subId,
3460
3377
  contractId: receipt.contractId,
@@ -3535,12 +3452,10 @@ function assembleTransactionSummary(params) {
3535
3452
  gqlTransactionStatus,
3536
3453
  abiMap = {},
3537
3454
  maxInputs,
3538
- gasCosts,
3539
- maxGasPerTx,
3540
- gasPrice
3455
+ gasCosts
3541
3456
  } = params;
3542
3457
  const gasUsed = getGasUsedFromReceipts(receipts);
3543
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3458
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3544
3459
  const operations = getOperations({
3545
3460
  transactionType: transaction.type,
3546
3461
  inputs: transaction.inputs || [],
@@ -3551,14 +3466,11 @@ function assembleTransactionSummary(params) {
3551
3466
  maxInputs
3552
3467
  });
3553
3468
  const typeName = getTransactionTypeName(transaction.type);
3554
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3555
3469
  const { fee } = calculateTransactionFee({
3556
- gasPrice,
3470
+ gasUsed,
3557
3471
  rawPayload,
3558
- tip,
3559
3472
  consensusParameters: {
3560
3473
  gasCosts,
3561
- maxGasPerTx,
3562
3474
  feeParams: {
3563
3475
  gasPerByte,
3564
3476
  gasPriceFactor
@@ -3570,7 +3482,7 @@ function assembleTransactionSummary(params) {
3570
3482
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3571
3483
  let date;
3572
3484
  if (time) {
3573
- date = import_utils18.DateTime.fromTai64(time);
3485
+ date = import_utils19.DateTime.fromTai64(time);
3574
3486
  }
3575
3487
  const transactionSummary = {
3576
3488
  id,
@@ -3618,7 +3530,7 @@ var TransactionResponse = class {
3618
3530
  /** Current provider */
3619
3531
  provider;
3620
3532
  /** Gas used on the transaction */
3621
- gasUsed = (0, import_math15.bn)(0);
3533
+ gasUsed = (0, import_math14.bn)(0);
3622
3534
  /** The graphql Transaction with receipts object. */
3623
3535
  gqlTransaction;
3624
3536
  abis;
@@ -3677,7 +3589,7 @@ var TransactionResponse = class {
3677
3589
  */
3678
3590
  decodeTransaction(transactionWithReceipts) {
3679
3591
  return new import_transactions18.TransactionCoder().decode(
3680
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3592
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3681
3593
  0
3682
3594
  )?.[0];
3683
3595
  }
@@ -3696,27 +3608,20 @@ var TransactionResponse = class {
3696
3608
  const decodedTransaction = this.decodeTransaction(
3697
3609
  transaction
3698
3610
  );
3699
- let txReceipts = [];
3700
- if (transaction?.status && "receipts" in transaction.status) {
3701
- txReceipts = transaction.status.receipts;
3702
- }
3703
- const receipts = txReceipts.map(processGqlReceipt) || [];
3704
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3705
- const gasPrice = await this.provider.getLatestGasPrice();
3611
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3612
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3706
3613
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3707
3614
  const transactionSummary = assembleTransactionSummary({
3708
3615
  id: this.id,
3709
3616
  receipts,
3710
3617
  transaction: decodedTransaction,
3711
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3618
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3712
3619
  gqlTransactionStatus: transaction.status,
3713
3620
  gasPerByte,
3714
3621
  gasPriceFactor,
3715
3622
  abiMap: contractsAbiMap,
3716
3623
  maxInputs,
3717
- gasCosts,
3718
- maxGasPerTx,
3719
- gasPrice
3624
+ gasCosts
3720
3625
  });
3721
3626
  return transactionSummary;
3722
3627
  }
@@ -3843,29 +3748,29 @@ var processGqlChain = (chain) => {
3843
3748
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3844
3749
  return {
3845
3750
  name,
3846
- baseChainHeight: (0, import_math16.bn)(daHeight),
3751
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3847
3752
  consensusParameters: {
3848
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3849
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3850
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3851
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3852
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3853
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3854
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3855
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3856
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3857
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3858
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3859
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3860
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3861
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3862
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3753
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3754
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3755
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3756
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3757
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3758
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3759
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3760
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3761
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3762
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3763
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3764
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3765
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3766
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3767
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3863
3768
  gasCosts
3864
3769
  },
3865
3770
  gasCosts,
3866
3771
  latestBlock: {
3867
3772
  id: latestBlock.id,
3868
- height: (0, import_math16.bn)(latestBlock.height),
3773
+ height: (0, import_math15.bn)(latestBlock.header.height),
3869
3774
  time: latestBlock.header.time,
3870
3775
  transactions: latestBlock.transactions.map((i) => ({
3871
3776
  id: i.id
@@ -3959,8 +3864,10 @@ var _Provider = class {
3959
3864
  * Returns some helpful parameters related to gas fees.
3960
3865
  */
3961
3866
  getGasConfig() {
3867
+ const { minGasPrice } = this.getNode();
3962
3868
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3963
3869
  return {
3870
+ minGasPrice,
3964
3871
  maxGasPerTx,
3965
3872
  maxGasPerPredicate,
3966
3873
  gasPriceFactor,
@@ -4058,7 +3965,7 @@ var _Provider = class {
4058
3965
  */
4059
3966
  async getBlockNumber() {
4060
3967
  const { chain } = await this.operations.getChain();
4061
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3968
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4062
3969
  }
4063
3970
  /**
4064
3971
  * Returns the chain information.
@@ -4068,11 +3975,13 @@ var _Provider = class {
4068
3975
  async fetchNode() {
4069
3976
  const { nodeInfo } = await this.operations.getNodeInfo();
4070
3977
  const processedNodeInfo = {
4071
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4072
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3978
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3979
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3980
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4073
3981
  nodeVersion: nodeInfo.nodeVersion,
4074
3982
  utxoValidation: nodeInfo.utxoValidation,
4075
- vmBacktrace: nodeInfo.vmBacktrace
3983
+ vmBacktrace: nodeInfo.vmBacktrace,
3984
+ peers: nodeInfo.peers
4076
3985
  };
4077
3986
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4078
3987
  return processedNodeInfo;
@@ -4114,7 +4023,7 @@ var _Provider = class {
4114
4023
  if (estimateTxDependencies) {
4115
4024
  await this.estimateTxDependencies(transactionRequest);
4116
4025
  }
4117
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4026
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4118
4027
  let abis;
4119
4028
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4120
4029
  abis = transactionRequest.abis;
@@ -4157,14 +4066,15 @@ var _Provider = class {
4157
4066
  if (estimateTxDependencies) {
4158
4067
  return this.estimateTxDependencies(transactionRequest);
4159
4068
  }
4160
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4161
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4162
- encodedTransactions: encodedTransaction,
4069
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4070
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4071
+ encodedTransaction,
4163
4072
  utxoValidation: utxoValidation || false
4164
4073
  });
4165
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4166
- const receipts = rawReceipts.map(processGqlReceipt);
4167
- return { receipts, dryrunStatus: status };
4074
+ const receipts = gqlReceipts.map(processGqlReceipt);
4075
+ return {
4076
+ receipts
4077
+ };
4168
4078
  }
4169
4079
  /**
4170
4080
  * Verifies whether enough gas is available to complete transaction.
@@ -4175,13 +4085,13 @@ var _Provider = class {
4175
4085
  async estimatePredicates(transactionRequest) {
4176
4086
  const shouldEstimatePredicates = Boolean(
4177
4087
  transactionRequest.inputs.find(
4178
- (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()
4088
+ (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()
4179
4089
  )
4180
4090
  );
4181
4091
  if (!shouldEstimatePredicates) {
4182
4092
  return transactionRequest;
4183
4093
  }
4184
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4094
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4185
4095
  const response = await this.operations.estimatePredicates({
4186
4096
  encodedTransaction
4187
4097
  });
@@ -4190,7 +4100,7 @@ var _Provider = class {
4190
4100
  } = response;
4191
4101
  if (inputs) {
4192
4102
  inputs.forEach((input, index) => {
4193
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4103
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4194
4104
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4195
4105
  }
4196
4106
  });
@@ -4203,6 +4113,9 @@ var _Provider = class {
4203
4113
  * If there are missing variable outputs,
4204
4114
  * `addVariableOutputs` is called on the transaction.
4205
4115
  *
4116
+ * @privateRemarks
4117
+ * TODO: Investigate support for missing contract IDs
4118
+ * TODO: Add support for missing output messages
4206
4119
  *
4207
4120
  * @param transactionRequest - The transaction request object.
4208
4121
  * @returns A promise.
@@ -4215,19 +4128,16 @@ var _Provider = class {
4215
4128
  missingContractIds: []
4216
4129
  };
4217
4130
  }
4131
+ await this.estimatePredicates(transactionRequest);
4218
4132
  let receipts = [];
4219
4133
  const missingContractIds = [];
4220
4134
  let outputVariables = 0;
4221
- let dryrunStatus;
4222
4135
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4223
- const {
4224
- dryRun: [{ receipts: rawReceipts, status }]
4225
- } = await this.operations.dryRun({
4226
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4136
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4137
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4227
4138
  utxoValidation: false
4228
4139
  });
4229
- receipts = rawReceipts.map(processGqlReceipt);
4230
- dryrunStatus = status;
4140
+ receipts = gqlReceipts.map(processGqlReceipt);
4231
4141
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4232
4142
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4233
4143
  if (hasMissingOutputs) {
@@ -4237,10 +4147,6 @@ var _Provider = class {
4237
4147
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4238
4148
  missingContractIds.push(contractId);
4239
4149
  });
4240
- const { maxFee } = await this.estimateTxGasAndFee({
4241
- transactionRequest
4242
- });
4243
- transactionRequest.maxFee = maxFee;
4244
4150
  } else {
4245
4151
  break;
4246
4152
  }
@@ -4248,136 +4154,37 @@ var _Provider = class {
4248
4154
  return {
4249
4155
  receipts,
4250
4156
  outputVariables,
4251
- missingContractIds,
4252
- dryrunStatus
4157
+ missingContractIds
4253
4158
  };
4254
4159
  }
4255
- /**
4256
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4257
- *
4258
- * Transactions are dry run in batches. After each dry run, transactions requiring
4259
- * further modifications are identified. The method iteratively updates these transactions
4260
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4261
- *
4262
- * @param transactionRequests - Array of transaction request objects.
4263
- * @returns A promise that resolves to an array of results for each transaction.
4264
- */
4265
- async estimateMultipleTxDependencies(transactionRequests) {
4266
- const results = transactionRequests.map(() => ({
4267
- receipts: [],
4268
- outputVariables: 0,
4269
- missingContractIds: [],
4270
- dryrunStatus: void 0
4271
- }));
4272
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4273
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4274
- allRequests.forEach((req, index) => {
4275
- if (req.type === import_transactions19.TransactionType.Script) {
4276
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4277
- }
4278
- });
4279
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4280
- let attempt = 0;
4281
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4282
- const encodedTransactions = transactionsToProcess.map(
4283
- (index) => serializedTransactionsMap.get(index)
4284
- );
4285
- const dryRunResults = await this.operations.dryRun({
4286
- encodedTransactions,
4287
- utxoValidation: false
4288
- });
4289
- const nextRoundTransactions = [];
4290
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4291
- const requestIdx = transactionsToProcess[i];
4292
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4293
- const result = results[requestIdx];
4294
- result.receipts = rawReceipts.map(processGqlReceipt);
4295
- result.dryrunStatus = status;
4296
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4297
- result.receipts
4298
- );
4299
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4300
- const request = allRequests[requestIdx];
4301
- if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4302
- result.outputVariables += missingOutputVariables.length;
4303
- request.addVariableOutputs(missingOutputVariables.length);
4304
- missingOutputContractIds.forEach(({ contractId }) => {
4305
- request.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4306
- result.missingContractIds.push(contractId);
4307
- });
4308
- const { maxFee } = await this.estimateTxGasAndFee({
4309
- transactionRequest: request
4310
- });
4311
- request.maxFee = maxFee;
4312
- serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4313
- nextRoundTransactions.push(requestIdx);
4314
- }
4315
- }
4316
- transactionsToProcess = nextRoundTransactions;
4317
- attempt += 1;
4318
- }
4319
- return results;
4320
- }
4321
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4322
- if (estimateTxDependencies) {
4323
- return this.estimateMultipleTxDependencies(transactionRequests);
4324
- }
4325
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4326
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4327
- encodedTransactions,
4328
- utxoValidation: utxoValidation || false
4329
- });
4330
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4331
- const receipts = rawReceipts.map(processGqlReceipt);
4332
- return { receipts, dryrunStatus: status };
4333
- });
4334
- return results;
4335
- }
4336
4160
  /**
4337
4161
  * Estimates the transaction gas and fee based on the provided transaction request.
4338
4162
  * @param transactionRequest - The transaction request object.
4339
4163
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4340
4164
  */
4341
- async estimateTxGasAndFee(params) {
4165
+ estimateTxGasAndFee(params) {
4342
4166
  const { transactionRequest } = params;
4343
- let { gasPrice } = params;
4167
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4344
4168
  const chainInfo = this.getChain();
4345
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4169
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4170
+ transactionRequest.gasPrice = gasPrice;
4346
4171
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4347
- if (!gasPrice) {
4348
- gasPrice = await this.estimateGasPrice(10);
4349
- }
4350
- const minFee = calculateGasFee({
4351
- gasPrice: (0, import_math16.bn)(gasPrice),
4352
- gas: minGas,
4353
- priceFactor: gasPriceFactor,
4354
- tip: transactionRequest.tip
4355
- }).add(1);
4356
- let gasLimit = (0, import_math16.bn)(0);
4172
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4357
4173
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4358
- gasLimit = transactionRequest.gasLimit;
4359
4174
  if (transactionRequest.gasLimit.eq(0)) {
4360
4175
  transactionRequest.gasLimit = minGas;
4361
4176
  transactionRequest.gasLimit = maxGasPerTx.sub(
4362
4177
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4363
4178
  );
4364
- gasLimit = transactionRequest.gasLimit;
4365
4179
  }
4366
4180
  }
4367
4181
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4368
- const maxFee = calculateGasFee({
4369
- gasPrice: (0, import_math16.bn)(gasPrice),
4370
- gas: maxGas,
4371
- priceFactor: gasPriceFactor,
4372
- tip: transactionRequest.tip
4373
- }).add(1);
4182
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4374
4183
  return {
4375
4184
  minGas,
4376
4185
  minFee,
4377
4186
  maxGas,
4378
- maxFee,
4379
- gasPrice,
4380
- gasLimit
4187
+ maxFee
4381
4188
  };
4382
4189
  }
4383
4190
  /**
@@ -4395,17 +4202,15 @@ var _Provider = class {
4395
4202
  if (estimateTxDependencies) {
4396
4203
  return this.estimateTxDependencies(transactionRequest);
4397
4204
  }
4398
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4399
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4400
- encodedTransactions,
4205
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4206
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4207
+ encodedTransaction,
4401
4208
  utxoValidation: true
4402
4209
  });
4403
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4404
- const { id, receipts, status } = dryRunStatus;
4405
- const processedReceipts = receipts.map(processGqlReceipt);
4406
- return { id, receipts: processedReceipts, status };
4407
- });
4408
- return { receipts: callResult[0].receipts };
4210
+ const receipts = gqlReceipts.map(processGqlReceipt);
4211
+ return {
4212
+ receipts
4213
+ };
4409
4214
  }
4410
4215
  /**
4411
4216
  * Returns a transaction cost to enable user
@@ -4422,79 +4227,77 @@ var _Provider = class {
4422
4227
  * @param tolerance - The tolerance to add on top of the gasUsed.
4423
4228
  * @returns A promise that resolves to the transaction cost object.
4424
4229
  */
4425
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4230
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4231
+ estimateTxDependencies = true,
4232
+ estimatePredicates = true,
4233
+ resourcesOwner,
4234
+ signatureCallback
4235
+ } = {}) {
4426
4236
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4237
+ const { minGasPrice } = this.getGasConfig();
4238
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4427
4239
  const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4428
4240
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4429
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4241
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4430
4242
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4431
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4432
4243
  if (isScriptTransaction) {
4433
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4244
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4434
4245
  }
4435
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4436
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4246
+ if (estimatePredicates) {
4247
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4248
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4249
+ }
4250
+ await this.estimatePredicates(txRequestClone);
4437
4251
  }
4438
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4439
- let addedSignatures = 0;
4440
4252
  if (signatureCallback && isScriptTransaction) {
4441
- const lengthBefore = signedRequest.witnesses.length;
4442
- await signatureCallback(signedRequest);
4443
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4253
+ await signatureCallback(txRequestClone);
4444
4254
  }
4445
- await this.estimatePredicates(signedRequest);
4446
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4447
- transactionRequest: signedRequest
4255
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4256
+ transactionRequest: txRequestClone
4448
4257
  });
4449
4258
  let receipts = [];
4450
4259
  let missingContractIds = [];
4451
4260
  let outputVariables = 0;
4452
- let gasUsed = (0, import_math16.bn)(0);
4453
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4454
- txRequestClone.maxFee = maxFee;
4455
- if (isScriptTransaction) {
4456
- txRequestClone.gasLimit = gasLimit;
4457
- if (signatureCallback) {
4458
- await signatureCallback(txRequestClone);
4459
- }
4261
+ let gasUsed = (0, import_math15.bn)(0);
4262
+ if (isScriptTransaction && estimateTxDependencies) {
4263
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4460
4264
  const result = await this.estimateTxDependencies(txRequestClone);
4461
4265
  receipts = result.receipts;
4462
4266
  outputVariables = result.outputVariables;
4463
4267
  missingContractIds = result.missingContractIds;
4464
4268
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4465
4269
  txRequestClone.gasLimit = gasUsed;
4466
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4467
- transactionRequest: txRequestClone,
4468
- gasPrice
4270
+ txRequestClone.gasPrice = setGasPrice;
4271
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4272
+ transactionRequest: txRequestClone
4469
4273
  }));
4470
4274
  }
4471
4275
  return {
4472
4276
  requiredQuantities: allQuantities,
4473
4277
  receipts,
4474
4278
  gasUsed,
4475
- gasPrice,
4279
+ minGasPrice,
4280
+ gasPrice: setGasPrice,
4476
4281
  minGas,
4477
4282
  maxGas,
4478
4283
  minFee,
4479
4284
  maxFee,
4285
+ estimatedInputs: txRequestClone.inputs,
4480
4286
  outputVariables,
4481
- missingContractIds,
4482
- addedSignatures,
4483
- estimatedPredicates: txRequestClone.inputs
4287
+ missingContractIds
4484
4288
  };
4485
4289
  }
4486
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4290
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4487
4291
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4488
4292
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4489
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4490
- quantitiesToContract
4491
- });
4293
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4492
4294
  transactionRequest.addResources(
4493
4295
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4494
4296
  );
4495
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4496
- quantitiesToContract
4497
- });
4297
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4298
+ transactionRequest,
4299
+ forwardingQuantities
4300
+ );
4498
4301
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4499
4302
  return {
4500
4303
  resources,
@@ -4510,16 +4313,17 @@ var _Provider = class {
4510
4313
  const result = await this.operations.getCoins({
4511
4314
  first: 10,
4512
4315
  ...paginationArgs,
4513
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4316
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4514
4317
  });
4515
4318
  const coins = result.coins.edges.map((edge) => edge.node);
4516
4319
  return coins.map((coin) => ({
4517
4320
  id: coin.utxoId,
4518
4321
  assetId: coin.assetId,
4519
- amount: (0, import_math16.bn)(coin.amount),
4322
+ amount: (0, import_math15.bn)(coin.amount),
4520
4323
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4521
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4522
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4324
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4325
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4326
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4523
4327
  }));
4524
4328
  }
4525
4329
  /**
@@ -4533,19 +4337,19 @@ var _Provider = class {
4533
4337
  async getResourcesToSpend(owner, quantities, excludedIds) {
4534
4338
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4535
4339
  const excludeInput = {
4536
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4537
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4340
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4341
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4538
4342
  };
4539
4343
  if (this.cache) {
4540
4344
  const uniqueUtxos = new Set(
4541
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4345
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4542
4346
  );
4543
4347
  excludeInput.utxos = Array.from(uniqueUtxos);
4544
4348
  }
4545
4349
  const coinsQuery = {
4546
4350
  owner: ownerAddress.toB256(),
4547
4351
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4548
- assetId: (0, import_utils22.hexlify)(assetId),
4352
+ assetId: (0, import_utils23.hexlify)(assetId),
4549
4353
  amount: amount.toString(10),
4550
4354
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4551
4355
  })),
@@ -4556,9 +4360,9 @@ var _Provider = class {
4556
4360
  switch (coin.__typename) {
4557
4361
  case "MessageCoin":
4558
4362
  return {
4559
- amount: (0, import_math16.bn)(coin.amount),
4363
+ amount: (0, import_math15.bn)(coin.amount),
4560
4364
  assetId: coin.assetId,
4561
- daHeight: (0, import_math16.bn)(coin.daHeight),
4365
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4562
4366
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4563
4367
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4564
4368
  nonce: coin.nonce
@@ -4566,11 +4370,12 @@ var _Provider = class {
4566
4370
  case "Coin":
4567
4371
  return {
4568
4372
  id: coin.utxoId,
4569
- amount: (0, import_math16.bn)(coin.amount),
4373
+ amount: (0, import_math15.bn)(coin.amount),
4570
4374
  assetId: coin.assetId,
4571
4375
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4572
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4573
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4376
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4377
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4378
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4574
4379
  };
4575
4380
  default:
4576
4381
  return null;
@@ -4587,13 +4392,13 @@ var _Provider = class {
4587
4392
  async getBlock(idOrHeight) {
4588
4393
  let variables;
4589
4394
  if (typeof idOrHeight === "number") {
4590
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4395
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4591
4396
  } else if (idOrHeight === "latest") {
4592
4397
  variables = { height: (await this.getBlockNumber()).toString(10) };
4593
4398
  } else if (idOrHeight.length === 66) {
4594
4399
  variables = { blockId: idOrHeight };
4595
4400
  } else {
4596
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4401
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4597
4402
  }
4598
4403
  const { block } = await this.operations.getBlock(variables);
4599
4404
  if (!block) {
@@ -4601,7 +4406,7 @@ var _Provider = class {
4601
4406
  }
4602
4407
  return {
4603
4408
  id: block.id,
4604
- height: (0, import_math16.bn)(block.height),
4409
+ height: (0, import_math15.bn)(block.header.height),
4605
4410
  time: block.header.time,
4606
4411
  transactionIds: block.transactions.map((tx) => tx.id)
4607
4412
  };
@@ -4616,7 +4421,7 @@ var _Provider = class {
4616
4421
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4617
4422
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4618
4423
  id: block.id,
4619
- height: (0, import_math16.bn)(block.height),
4424
+ height: (0, import_math15.bn)(block.header.height),
4620
4425
  time: block.header.time,
4621
4426
  transactionIds: block.transactions.map((tx) => tx.id)
4622
4427
  }));
@@ -4631,7 +4436,7 @@ var _Provider = class {
4631
4436
  async getBlockWithTransactions(idOrHeight) {
4632
4437
  let variables;
4633
4438
  if (typeof idOrHeight === "number") {
4634
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4439
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4635
4440
  } else if (idOrHeight === "latest") {
4636
4441
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4637
4442
  } else {
@@ -4643,11 +4448,11 @@ var _Provider = class {
4643
4448
  }
4644
4449
  return {
4645
4450
  id: block.id,
4646
- height: (0, import_math16.bn)(block.height, 10),
4451
+ height: (0, import_math15.bn)(block.header.height, 10),
4647
4452
  time: block.header.time,
4648
4453
  transactionIds: block.transactions.map((tx) => tx.id),
4649
4454
  transactions: block.transactions.map(
4650
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4455
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4651
4456
  )
4652
4457
  };
4653
4458
  }
@@ -4663,7 +4468,7 @@ var _Provider = class {
4663
4468
  return null;
4664
4469
  }
4665
4470
  return new import_transactions19.TransactionCoder().decode(
4666
- (0, import_utils22.arrayify)(transaction.rawPayload),
4471
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4667
4472
  0
4668
4473
  )?.[0];
4669
4474
  }
@@ -4690,9 +4495,9 @@ var _Provider = class {
4690
4495
  async getContractBalance(contractId, assetId) {
4691
4496
  const { contractBalance } = await this.operations.getContractBalance({
4692
4497
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4693
- asset: (0, import_utils22.hexlify)(assetId)
4498
+ asset: (0, import_utils23.hexlify)(assetId)
4694
4499
  });
4695
- return (0, import_math16.bn)(contractBalance.amount, 10);
4500
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4696
4501
  }
4697
4502
  /**
4698
4503
  * Returns the balance for the given owner for the given asset ID.
@@ -4704,9 +4509,9 @@ var _Provider = class {
4704
4509
  async getBalance(owner, assetId) {
4705
4510
  const { balance } = await this.operations.getBalance({
4706
4511
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4707
- assetId: (0, import_utils22.hexlify)(assetId)
4512
+ assetId: (0, import_utils23.hexlify)(assetId)
4708
4513
  });
4709
- return (0, import_math16.bn)(balance.amount, 10);
4514
+ return (0, import_math15.bn)(balance.amount, 10);
4710
4515
  }
4711
4516
  /**
4712
4517
  * Returns balances for the given owner.
@@ -4724,7 +4529,7 @@ var _Provider = class {
4724
4529
  const balances = result.balances.edges.map((edge) => edge.node);
4725
4530
  return balances.map((balance) => ({
4726
4531
  assetId: balance.assetId,
4727
- amount: (0, import_math16.bn)(balance.amount)
4532
+ amount: (0, import_math15.bn)(balance.amount)
4728
4533
  }));
4729
4534
  }
4730
4535
  /**
@@ -4746,15 +4551,15 @@ var _Provider = class {
4746
4551
  sender: message.sender,
4747
4552
  recipient: message.recipient,
4748
4553
  nonce: message.nonce,
4749
- amount: (0, import_math16.bn)(message.amount),
4554
+ amount: (0, import_math15.bn)(message.amount),
4750
4555
  data: message.data
4751
4556
  }),
4752
4557
  sender: import_address3.Address.fromAddressOrString(message.sender),
4753
4558
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4754
4559
  nonce: message.nonce,
4755
- amount: (0, import_math16.bn)(message.amount),
4560
+ amount: (0, import_math15.bn)(message.amount),
4756
4561
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4757
- daHeight: (0, import_math16.bn)(message.daHeight)
4562
+ daHeight: (0, import_math15.bn)(message.daHeight)
4758
4563
  }));
4759
4564
  }
4760
4565
  /**
@@ -4807,60 +4612,44 @@ var _Provider = class {
4807
4612
  } = result.messageProof;
4808
4613
  return {
4809
4614
  messageProof: {
4810
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4615
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4811
4616
  proofSet: messageProof.proofSet
4812
4617
  },
4813
4618
  blockProof: {
4814
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4619
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4815
4620
  proofSet: blockProof.proofSet
4816
4621
  },
4817
4622
  messageBlockHeader: {
4818
4623
  id: messageBlockHeader.id,
4819
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4820
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4624
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4625
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4821
4626
  transactionsRoot: messageBlockHeader.transactionsRoot,
4822
- height: (0, import_math16.bn)(messageBlockHeader.height),
4627
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4823
4628
  prevRoot: messageBlockHeader.prevRoot,
4824
4629
  time: messageBlockHeader.time,
4825
4630
  applicationHash: messageBlockHeader.applicationHash,
4826
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4827
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4828
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4829
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4830
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4631
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4632
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4831
4633
  },
4832
4634
  commitBlockHeader: {
4833
4635
  id: commitBlockHeader.id,
4834
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4835
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4636
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4637
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4836
4638
  transactionsRoot: commitBlockHeader.transactionsRoot,
4837
- height: (0, import_math16.bn)(commitBlockHeader.height),
4639
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4838
4640
  prevRoot: commitBlockHeader.prevRoot,
4839
4641
  time: commitBlockHeader.time,
4840
4642
  applicationHash: commitBlockHeader.applicationHash,
4841
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4842
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4843
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4844
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4845
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4643
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4644
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4846
4645
  },
4847
4646
  sender: import_address3.Address.fromAddressOrString(sender),
4848
4647
  recipient: import_address3.Address.fromAddressOrString(recipient),
4849
4648
  nonce,
4850
- amount: (0, import_math16.bn)(amount),
4649
+ amount: (0, import_math15.bn)(amount),
4851
4650
  data
4852
4651
  };
4853
4652
  }
4854
- async getLatestGasPrice() {
4855
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4856
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4857
- }
4858
- async estimateGasPrice(blockHorizon) {
4859
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4860
- blockHorizon: String(blockHorizon)
4861
- });
4862
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4863
- }
4864
4653
  /**
4865
4654
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4866
4655
  *
@@ -4880,10 +4669,10 @@ var _Provider = class {
4880
4669
  */
4881
4670
  async produceBlocks(amount, startTime) {
4882
4671
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4883
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4884
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4672
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4673
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4885
4674
  });
4886
- return (0, import_math16.bn)(latestBlockHeight);
4675
+ return (0, import_math15.bn)(latestBlockHeight);
4887
4676
  }
4888
4677
  // eslint-disable-next-line @typescript-eslint/require-await
4889
4678
  async getTransactionResponse(transactionId) {
@@ -4907,9 +4696,9 @@ __publicField(Provider, "nodeInfoCache", {});
4907
4696
 
4908
4697
  // src/providers/transaction-summary/get-transaction-summary.ts
4909
4698
  var import_errors15 = require("@fuel-ts/errors");
4910
- var import_math17 = require("@fuel-ts/math");
4699
+ var import_math16 = require("@fuel-ts/math");
4911
4700
  var import_transactions20 = require("@fuel-ts/transactions");
4912
- var import_utils25 = require("@fuel-ts/utils");
4701
+ var import_utils26 = require("@fuel-ts/utils");
4913
4702
  async function getTransactionSummary(params) {
4914
4703
  const { id, provider, abiMap } = params;
4915
4704
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4922,31 +4711,24 @@ async function getTransactionSummary(params) {
4922
4711
  );
4923
4712
  }
4924
4713
  const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4925
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4714
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4926
4715
  0
4927
4716
  );
4928
- let txReceipts = [];
4929
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4930
- txReceipts = gqlTransaction.status.receipts;
4931
- }
4932
- const receipts = txReceipts.map(processGqlReceipt);
4717
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4933
4718
  const {
4934
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4719
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4935
4720
  } = provider.getChain();
4936
- const gasPrice = await provider.getLatestGasPrice();
4937
4721
  const transactionInfo = assembleTransactionSummary({
4938
4722
  id: gqlTransaction.id,
4939
4723
  receipts,
4940
4724
  transaction: decodedTransaction,
4941
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4725
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4942
4726
  gqlTransactionStatus: gqlTransaction.status,
4943
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4944
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4727
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4728
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4945
4729
  abiMap,
4946
4730
  maxInputs,
4947
- gasCosts,
4948
- maxGasPerTx,
4949
- gasPrice
4731
+ gasCosts
4950
4732
  });
4951
4733
  return {
4952
4734
  gqlTransaction,
@@ -4956,11 +4738,10 @@ async function getTransactionSummary(params) {
4956
4738
  async function getTransactionSummaryFromRequest(params) {
4957
4739
  const { provider, transactionRequest, abiMap } = params;
4958
4740
  const { receipts } = await provider.call(transactionRequest);
4959
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4741
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4960
4742
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4961
4743
  const transaction = transactionRequest.toTransaction();
4962
4744
  const transactionBytes = transactionRequest.toTransactionBytes();
4963
- const gasPrice = await provider.getLatestGasPrice();
4964
4745
  const transactionSummary = assembleTransactionSummary({
4965
4746
  receipts,
4966
4747
  transaction,
@@ -4969,9 +4750,7 @@ async function getTransactionSummaryFromRequest(params) {
4969
4750
  gasPerByte,
4970
4751
  gasPriceFactor,
4971
4752
  maxInputs,
4972
- gasCosts,
4973
- maxGasPerTx,
4974
- gasPrice
4753
+ gasCosts
4975
4754
  });
4976
4755
  return transactionSummary;
4977
4756
  }
@@ -4980,31 +4759,24 @@ async function getTransactionsSummaries(params) {
4980
4759
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4981
4760
  const { edges, pageInfo } = transactionsByOwner;
4982
4761
  const {
4983
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4762
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4984
4763
  } = provider.getChain();
4985
- const gasPrice = await provider.getLatestGasPrice();
4986
4764
  const transactions = edges.map((edge) => {
4987
4765
  const { node: gqlTransaction } = edge;
4988
- const { id, rawPayload, status } = gqlTransaction;
4989
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4990
- let txReceipts = [];
4991
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4992
- txReceipts = gqlTransaction.status.receipts;
4993
- }
4994
- const receipts = txReceipts.map(processGqlReceipt);
4766
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4767
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4768
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4995
4769
  const transactionSummary = assembleTransactionSummary({
4996
4770
  id,
4997
4771
  receipts,
4998
4772
  transaction: decodedTransaction,
4999
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4773
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
5000
4774
  gqlTransactionStatus: status,
5001
4775
  abiMap,
5002
4776
  gasPerByte,
5003
4777
  gasPriceFactor,
5004
4778
  maxInputs,
5005
- gasCosts,
5006
- maxGasPerTx,
5007
- gasPrice
4779
+ gasCosts
5008
4780
  });
5009
4781
  const output = {
5010
4782
  gqlTransaction,
@@ -5141,17 +4913,17 @@ var assets = [
5141
4913
 
5142
4914
  // src/utils/formatTransferToContractScriptData.ts
5143
4915
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5144
- var import_math18 = require("@fuel-ts/math");
5145
- var import_utils26 = require("@fuel-ts/utils");
4916
+ var import_math17 = require("@fuel-ts/math");
4917
+ var import_utils27 = require("@fuel-ts/utils");
5146
4918
  var asm = __toESM(require("@fuels/vm-asm"));
5147
4919
  var formatTransferToContractScriptData = (params) => {
5148
4920
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5149
4921
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5150
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4922
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5151
4923
  const scriptData = Uint8Array.from([
5152
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4924
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5153
4925
  ...encoded,
5154
- ...(0, import_utils26.arrayify)(assetId)
4926
+ ...(0, import_utils27.arrayify)(assetId)
5155
4927
  ]);
5156
4928
  return scriptData;
5157
4929
  };
@@ -5336,30 +5108,37 @@ var Account = class extends import_interfaces.AbstractAccount {
5336
5108
  * @param fee - The estimated transaction fee.
5337
5109
  * @returns A promise that resolves when the resources are added to the transaction.
5338
5110
  */
5339
- async fund(request, params) {
5340
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5341
- const txRequest = request;
5342
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5343
- amount: (0, import_math19.bn)(fee),
5111
+ async fund(request, coinQuantities, fee) {
5112
+ const updatedQuantities = addAmountToAsset({
5113
+ amount: (0, import_math18.bn)(fee),
5344
5114
  assetId: import_configs12.BaseAssetId,
5345
- coinQuantities: requiredQuantities
5115
+ coinQuantities
5346
5116
  });
5347
5117
  const quantitiesDict = {};
5348
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5118
+ updatedQuantities.forEach(({ amount, assetId }) => {
5349
5119
  quantitiesDict[assetId] = {
5350
5120
  required: amount,
5351
- owned: (0, import_math19.bn)(0)
5121
+ owned: (0, import_math18.bn)(0)
5352
5122
  };
5353
5123
  });
5354
- txRequest.inputs.forEach((input) => {
5124
+ const cachedUtxos = [];
5125
+ const cachedMessages = [];
5126
+ const owner = this.address.toB256();
5127
+ request.inputs.forEach((input) => {
5355
5128
  const isResource = "amount" in input;
5356
- if (!isResource) {
5357
- return;
5358
- }
5359
- const isCoin2 = "owner" in input;
5360
- const assetId = isCoin2 ? String(input.assetId) : import_configs12.BaseAssetId;
5361
- if (quantitiesDict[assetId]) {
5362
- quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
5129
+ if (isResource) {
5130
+ const isCoin2 = "owner" in input;
5131
+ if (isCoin2) {
5132
+ const assetId = String(input.assetId);
5133
+ if (input.owner === owner && quantitiesDict[assetId]) {
5134
+ const amount = (0, import_math18.bn)(input.amount);
5135
+ quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5136
+ cachedUtxos.push(input.id);
5137
+ }
5138
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5139
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5140
+ cachedMessages.push(input.nonce);
5141
+ }
5363
5142
  }
5364
5143
  });
5365
5144
  const missingQuantities = [];
@@ -5373,21 +5152,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5373
5152
  });
5374
5153
  const needsToBeFunded = missingQuantities.length;
5375
5154
  if (needsToBeFunded) {
5376
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5377
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5378
- txRequest.addResources(resources);
5379
- }
5380
- txRequest.shiftPredicateData();
5381
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5382
- const requestToReestimate = (0, import_ramda4.clone)(txRequest);
5383
- if (addedSignatures) {
5384
- Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5385
- }
5386
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5387
- transactionRequest: requestToReestimate
5388
- });
5389
- txRequest.maxFee = maxFee;
5390
- return txRequest;
5155
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5156
+ messages: cachedMessages,
5157
+ utxos: cachedUtxos
5158
+ });
5159
+ request.addResources(resources);
5160
+ }
5391
5161
  }
5392
5162
  /**
5393
5163
  * A helper that creates a transfer transaction request and returns it.
@@ -5395,24 +5165,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5395
5165
  * @param destination - The address of the destination.
5396
5166
  * @param amount - The amount of coins to transfer.
5397
5167
  * @param assetId - The asset ID of the coins to transfer.
5398
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5168
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5399
5169
  * @returns A promise that resolves to the prepared transaction request.
5400
5170
  */
5401
5171
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5402
- const request = new ScriptTransactionRequest(txParams);
5172
+ const { minGasPrice } = this.provider.getGasConfig();
5173
+ const params = { gasPrice: minGasPrice, ...txParams };
5174
+ const request = new ScriptTransactionRequest(params);
5403
5175
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5404
- const txCost = await this.provider.getTransactionCost(request, {
5176
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5405
5177
  estimateTxDependencies: true,
5406
5178
  resourcesOwner: this
5407
5179
  });
5408
- this.validateGasLimitAndMaxFee({
5409
- gasUsed: txCost.gasUsed,
5410
- maxFee: txCost.maxFee,
5411
- txParams
5180
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5181
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5182
+ this.validateGas({
5183
+ gasUsed,
5184
+ gasPrice: request.gasPrice,
5185
+ gasLimit: request.gasLimit,
5186
+ minGasPrice
5412
5187
  });
5413
- request.gasLimit = txCost.gasUsed;
5414
- request.maxFee = txCost.maxFee;
5415
- await this.fund(request, txCost);
5188
+ await this.fund(request, requiredQuantities, maxFee);
5189
+ request.updatePredicateInputs(estimatedInputs);
5416
5190
  return request;
5417
5191
  }
5418
5192
  /**
@@ -5421,11 +5195,11 @@ var Account = class extends import_interfaces.AbstractAccount {
5421
5195
  * @param destination - The address of the destination.
5422
5196
  * @param amount - The amount of coins to transfer.
5423
5197
  * @param assetId - The asset ID of the coins to transfer.
5424
- * @param txParams - The transaction parameters (gasLimit, maturity).
5198
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5425
5199
  * @returns A promise that resolves to the transaction response.
5426
5200
  */
5427
5201
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5428
- if ((0, import_math19.bn)(amount).lte(0)) {
5202
+ if ((0, import_math18.bn)(amount).lte(0)) {
5429
5203
  throw new import_errors16.FuelError(
5430
5204
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5431
5205
  "Transfer amount must be a positive number."
@@ -5444,36 +5218,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5444
5218
  * @returns A promise that resolves to the transaction response.
5445
5219
  */
5446
5220
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5447
- if ((0, import_math19.bn)(amount).lte(0)) {
5221
+ if ((0, import_math18.bn)(amount).lte(0)) {
5448
5222
  throw new import_errors16.FuelError(
5449
5223
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5450
5224
  "Transfer amount must be a positive number."
5451
5225
  );
5452
5226
  }
5453
5227
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5228
+ const { minGasPrice } = this.provider.getGasConfig();
5229
+ const params = { gasPrice: minGasPrice, ...txParams };
5454
5230
  const { script, scriptData } = await assembleTransferToContractScript({
5455
5231
  hexlifiedContractId: contractAddress.toB256(),
5456
- amountToTransfer: (0, import_math19.bn)(amount),
5232
+ amountToTransfer: (0, import_math18.bn)(amount),
5457
5233
  assetId
5458
5234
  });
5459
5235
  const request = new ScriptTransactionRequest({
5460
- ...txParams,
5236
+ ...params,
5461
5237
  script,
5462
5238
  scriptData
5463
5239
  });
5464
5240
  request.addContractInputAndOutput(contractAddress);
5465
- const txCost = await this.provider.getTransactionCost(request, {
5466
- resourcesOwner: this,
5467
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5468
- });
5469
- this.validateGasLimitAndMaxFee({
5470
- gasUsed: txCost.gasUsed,
5471
- maxFee: txCost.maxFee,
5472
- txParams
5241
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5242
+ request,
5243
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5244
+ );
5245
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5246
+ this.validateGas({
5247
+ gasUsed,
5248
+ gasPrice: request.gasPrice,
5249
+ gasLimit: request.gasLimit,
5250
+ minGasPrice
5473
5251
  });
5474
- request.gasLimit = txCost.gasUsed;
5475
- request.maxFee = txCost.maxFee;
5476
- await this.fund(request, txCost);
5252
+ await this.fund(request, requiredQuantities, maxFee);
5477
5253
  return this.sendTransaction(request);
5478
5254
  }
5479
5255
  /**
@@ -5485,30 +5261,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5485
5261
  * @returns A promise that resolves to the transaction response.
5486
5262
  */
5487
5263
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5264
+ const { minGasPrice } = this.provider.getGasConfig();
5488
5265
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5489
- const recipientDataArray = (0, import_utils27.arrayify)(
5266
+ const recipientDataArray = (0, import_utils28.arrayify)(
5490
5267
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5491
5268
  );
5492
- const amountDataArray = (0, import_utils27.arrayify)(
5493
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5269
+ const amountDataArray = (0, import_utils28.arrayify)(
5270
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5494
5271
  );
5495
5272
  const script = new Uint8Array([
5496
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5273
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5497
5274
  ...recipientDataArray,
5498
5275
  ...amountDataArray
5499
5276
  ]);
5500
- const params = { script, ...txParams };
5277
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5501
5278
  const request = new ScriptTransactionRequest(params);
5502
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5503
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5504
- this.validateGasLimitAndMaxFee({
5505
- gasUsed: txCost.gasUsed,
5506
- maxFee: txCost.maxFee,
5507
- txParams
5279
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5280
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5281
+ request,
5282
+ forwardingQuantities
5283
+ );
5284
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5285
+ this.validateGas({
5286
+ gasUsed,
5287
+ gasPrice: request.gasPrice,
5288
+ gasLimit: request.gasLimit,
5289
+ minGasPrice
5508
5290
  });
5509
- request.maxFee = txCost.maxFee;
5510
- request.gasLimit = txCost.gasUsed;
5511
- await this.fund(request, txCost);
5291
+ await this.fund(request, requiredQuantities, maxFee);
5512
5292
  return this.sendTransaction(request);
5513
5293
  }
5514
5294
  async signMessage(message) {
@@ -5566,21 +5346,22 @@ var Account = class extends import_interfaces.AbstractAccount {
5566
5346
  }
5567
5347
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5568
5348
  }
5569
- validateGasLimitAndMaxFee({
5570
- txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
5349
+ validateGas({
5571
5350
  gasUsed,
5572
- maxFee
5351
+ gasPrice,
5352
+ gasLimit,
5353
+ minGasPrice
5573
5354
  }) {
5574
- if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
5355
+ if (minGasPrice.gt(gasPrice)) {
5575
5356
  throw new import_errors16.FuelError(
5576
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5577
- `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5357
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5358
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5578
5359
  );
5579
5360
  }
5580
- if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
5361
+ if (gasUsed.gt(gasLimit)) {
5581
5362
  throw new import_errors16.FuelError(
5582
- import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5583
- `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5363
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5364
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5584
5365
  );
5585
5366
  }
5586
5367
  }
@@ -5588,14 +5369,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5588
5369
 
5589
5370
  // src/wallet/base-wallet-unlocked.ts
5590
5371
  var import_hasher3 = require("@fuel-ts/hasher");
5591
- var import_utils30 = require("@fuel-ts/utils");
5372
+ var import_utils31 = require("@fuel-ts/utils");
5592
5373
 
5593
5374
  // src/signer/signer.ts
5594
5375
  var import_address5 = require("@fuel-ts/address");
5595
5376
  var import_crypto2 = require("@fuel-ts/crypto");
5596
5377
  var import_hasher2 = require("@fuel-ts/hasher");
5597
- var import_math20 = require("@fuel-ts/math");
5598
- var import_utils28 = require("@fuel-ts/utils");
5378
+ var import_math19 = require("@fuel-ts/math");
5379
+ var import_utils29 = require("@fuel-ts/utils");
5599
5380
  var import_secp256k1 = require("@noble/curves/secp256k1");
5600
5381
  var Signer = class {
5601
5382
  address;
@@ -5614,10 +5395,10 @@ var Signer = class {
5614
5395
  privateKey = `0x${privateKey}`;
5615
5396
  }
5616
5397
  }
5617
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5618
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5619
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5620
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5398
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5399
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5400
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5401
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5621
5402
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5622
5403
  }
5623
5404
  /**
@@ -5631,11 +5412,11 @@ var Signer = class {
5631
5412
  * @returns hashed signature
5632
5413
  */
5633
5414
  sign(data) {
5634
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5635
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5636
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5415
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5416
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5417
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5637
5418
  s[0] |= (signature.recovery || 0) << 7;
5638
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5419
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5639
5420
  }
5640
5421
  /**
5641
5422
  * Add point on the current elliptic curve
@@ -5644,8 +5425,8 @@ var Signer = class {
5644
5425
  * @returns compressed point on the curve
5645
5426
  */
5646
5427
  addPoint(point) {
5647
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5648
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5428
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5429
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5649
5430
  const result = p0.add(p1);
5650
5431
  return `0x${result.toHex(true)}`;
5651
5432
  }
@@ -5657,16 +5438,16 @@ var Signer = class {
5657
5438
  * @returns public key from signature from the
5658
5439
  */
5659
5440
  static recoverPublicKey(data, signature) {
5660
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5441
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5661
5442
  const r = signedMessageBytes.slice(0, 32);
5662
5443
  const s = signedMessageBytes.slice(32, 64);
5663
5444
  const recoveryParam = (s[0] & 128) >> 7;
5664
5445
  s[0] &= 127;
5665
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5446
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5666
5447
  recoveryParam
5667
5448
  );
5668
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5669
- return (0, import_utils28.hexlify)(publicKey);
5449
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5450
+ return (0, import_utils29.hexlify)(publicKey);
5670
5451
  }
5671
5452
  /**
5672
5453
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5685,7 +5466,7 @@ var Signer = class {
5685
5466
  * @returns random 32-byte hashed
5686
5467
  */
5687
5468
  static generatePrivateKey(entropy) {
5688
- 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);
5469
+ 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);
5689
5470
  }
5690
5471
  /**
5691
5472
  * Extended publicKey from a compact publicKey
@@ -5694,8 +5475,8 @@ var Signer = class {
5694
5475
  * @returns extended publicKey
5695
5476
  */
5696
5477
  static extendPublicKey(publicKey) {
5697
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5698
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5478
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5479
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5699
5480
  }
5700
5481
  };
5701
5482
 
@@ -5703,7 +5484,7 @@ var Signer = class {
5703
5484
  var import_address6 = require("@fuel-ts/address");
5704
5485
  var import_crypto3 = require("@fuel-ts/crypto");
5705
5486
  var import_errors17 = require("@fuel-ts/errors");
5706
- var import_utils29 = require("@fuel-ts/utils");
5487
+ var import_utils30 = require("@fuel-ts/utils");
5707
5488
  var import_uuid = require("uuid");
5708
5489
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5709
5490
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5786,7 +5567,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5786
5567
  );
5787
5568
  }
5788
5569
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5789
- const privateKey = (0, import_utils29.hexlify)(buffer);
5570
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5790
5571
  return privateKey;
5791
5572
  }
5792
5573
 
@@ -5831,7 +5612,7 @@ var BaseWalletUnlocked = class extends Account {
5831
5612
  */
5832
5613
  async signMessage(message) {
5833
5614
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5834
- return (0, import_utils30.hexlify)(signedMessage);
5615
+ return (0, import_utils31.hexlify)(signedMessage);
5835
5616
  }
5836
5617
  /**
5837
5618
  * Signs a transaction with the wallet's private key.
@@ -5844,7 +5625,7 @@ var BaseWalletUnlocked = class extends Account {
5844
5625
  const chainId = this.provider.getChainId();
5845
5626
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5846
5627
  const signature = await this.signer().sign(hashedTransaction);
5847
- return (0, import_utils30.hexlify)(signature);
5628
+ return (0, import_utils31.hexlify)(signature);
5848
5629
  }
5849
5630
  /**
5850
5631
  * Populates a transaction with the witnesses signature.
@@ -5864,7 +5645,7 @@ var BaseWalletUnlocked = class extends Account {
5864
5645
  * @param transactionRequestLike - The transaction request to send.
5865
5646
  * @returns A promise that resolves to the TransactionResponse object.
5866
5647
  */
5867
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5648
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5868
5649
  const transactionRequest = transactionRequestify(transactionRequestLike);
5869
5650
  if (estimateTxDependencies) {
5870
5651
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5905,15 +5686,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5905
5686
  // src/hdwallet/hdwallet.ts
5906
5687
  var import_errors20 = require("@fuel-ts/errors");
5907
5688
  var import_hasher6 = require("@fuel-ts/hasher");
5908
- var import_math21 = require("@fuel-ts/math");
5909
- var import_utils34 = require("@fuel-ts/utils");
5689
+ var import_math20 = require("@fuel-ts/math");
5690
+ var import_utils35 = require("@fuel-ts/utils");
5910
5691
  var import_ethers3 = require("ethers");
5911
5692
 
5912
5693
  // src/mnemonic/mnemonic.ts
5913
5694
  var import_crypto4 = require("@fuel-ts/crypto");
5914
5695
  var import_errors19 = require("@fuel-ts/errors");
5915
5696
  var import_hasher5 = require("@fuel-ts/hasher");
5916
- var import_utils32 = require("@fuel-ts/utils");
5697
+ var import_utils33 = require("@fuel-ts/utils");
5917
5698
  var import_ethers2 = require("ethers");
5918
5699
 
5919
5700
  // src/wordlists/words/english.ts
@@ -7977,7 +7758,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7977
7758
  // src/mnemonic/utils.ts
7978
7759
  var import_errors18 = require("@fuel-ts/errors");
7979
7760
  var import_hasher4 = require("@fuel-ts/hasher");
7980
- var import_utils31 = require("@fuel-ts/utils");
7761
+ var import_utils32 = require("@fuel-ts/utils");
7981
7762
  function toUtf8Bytes(stri) {
7982
7763
  const str = stri.normalize("NFKD");
7983
7764
  const result = [];
@@ -8044,14 +7825,14 @@ function entropyToMnemonicIndices(entropy) {
8044
7825
  }
8045
7826
  }
8046
7827
  const checksumBits = entropy.length / 4;
8047
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7828
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8048
7829
  indices[indices.length - 1] <<= checksumBits;
8049
7830
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8050
7831
  return indices;
8051
7832
  }
8052
7833
  function mnemonicWordsToEntropy(words, wordlist) {
8053
7834
  const size = Math.ceil(11 * words.length / 8);
8054
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7835
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8055
7836
  let offset = 0;
8056
7837
  for (let i = 0; i < words.length; i += 1) {
8057
7838
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8071,7 +7852,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8071
7852
  const entropyBits = 32 * words.length / 3;
8072
7853
  const checksumBits = words.length / 3;
8073
7854
  const checksumMask = getUpperMask(checksumBits);
8074
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7855
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8075
7856
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8076
7857
  throw new import_errors18.FuelError(
8077
7858
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8146,7 +7927,7 @@ var Mnemonic = class {
8146
7927
  static mnemonicToEntropy(phrase, wordlist = english) {
8147
7928
  const words = getWords(phrase);
8148
7929
  assertMnemonic(words);
8149
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7930
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8150
7931
  }
8151
7932
  /**
8152
7933
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8154,7 +7935,7 @@ var Mnemonic = class {
8154
7935
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8155
7936
  */
8156
7937
  static entropyToMnemonic(entropy, wordlist = english) {
8157
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7938
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8158
7939
  assertWordList(wordlist);
8159
7940
  assertEntropy(entropyBytes);
8160
7941
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8223,14 +8004,14 @@ var Mnemonic = class {
8223
8004
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8224
8005
  */
8225
8006
  static masterKeysFromSeed(seed) {
8226
- const seedArray = (0, import_utils32.arrayify)(seed);
8007
+ const seedArray = (0, import_utils33.arrayify)(seed);
8227
8008
  if (seedArray.length < 16 || seedArray.length > 64) {
8228
8009
  throw new import_errors19.FuelError(
8229
8010
  import_errors19.ErrorCode.INVALID_SEED,
8230
8011
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8231
8012
  );
8232
8013
  }
8233
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8014
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8234
8015
  }
8235
8016
  /**
8236
8017
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8241,22 +8022,22 @@ var Mnemonic = class {
8241
8022
  */
8242
8023
  static seedToExtendedKey(seed, testnet = false) {
8243
8024
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8244
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8025
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8245
8026
  const depth = "0x00";
8246
8027
  const fingerprint = "0x00000000";
8247
8028
  const index = "0x00000000";
8248
8029
  const chainCode = masterKey.slice(32);
8249
8030
  const privateKey = masterKey.slice(0, 32);
8250
- const extendedKey = (0, import_utils32.concat)([
8031
+ const extendedKey = (0, import_utils33.concat)([
8251
8032
  prefix,
8252
8033
  depth,
8253
8034
  fingerprint,
8254
8035
  index,
8255
8036
  chainCode,
8256
- (0, import_utils32.concat)(["0x00", privateKey])
8037
+ (0, import_utils33.concat)(["0x00", privateKey])
8257
8038
  ]);
8258
8039
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8259
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8040
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8260
8041
  }
8261
8042
  /**
8262
8043
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8271,7 +8052,7 @@ var Mnemonic = class {
8271
8052
  * @returns A randomly generated mnemonic
8272
8053
  */
8273
8054
  static generate(size = 32, extraEntropy = "") {
8274
- 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);
8055
+ 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);
8275
8056
  return Mnemonic.entropyToMnemonic(entropy);
8276
8057
  }
8277
8058
  };
@@ -8279,12 +8060,12 @@ var mnemonic_default = Mnemonic;
8279
8060
 
8280
8061
  // src/hdwallet/hdwallet.ts
8281
8062
  var HARDENED_INDEX = 2147483648;
8282
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8283
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8284
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8285
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8063
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8064
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8065
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8066
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8286
8067
  function base58check(data) {
8287
- 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)]));
8068
+ 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)]));
8288
8069
  }
8289
8070
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8290
8071
  if (isPublic) {
@@ -8293,11 +8074,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8293
8074
  return testnet ? TestnetPRV2 : MainnetPRV2;
8294
8075
  }
8295
8076
  function isPublicExtendedKey(extendedKey) {
8296
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8077
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8297
8078
  }
8298
8079
  function isValidExtendedKey(extendedKey) {
8299
8080
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8300
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8081
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8301
8082
  );
8302
8083
  }
8303
8084
  function parsePath(path, depth = 0) {
@@ -8315,8 +8096,8 @@ function parsePath(path, depth = 0) {
8315
8096
  var HDWallet = class {
8316
8097
  depth = 0;
8317
8098
  index = 0;
8318
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8319
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8099
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8100
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8320
8101
  privateKey;
8321
8102
  publicKey;
8322
8103
  chainCode;
@@ -8328,8 +8109,8 @@ var HDWallet = class {
8328
8109
  constructor(config) {
8329
8110
  if (config.privateKey) {
8330
8111
  const signer = new Signer(config.privateKey);
8331
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8332
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8112
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8113
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8333
8114
  } else {
8334
8115
  if (!config.publicKey) {
8335
8116
  throw new import_errors20.FuelError(
@@ -8337,7 +8118,7 @@ var HDWallet = class {
8337
8118
  "Both public and private Key cannot be missing. At least one should be provided."
8338
8119
  );
8339
8120
  }
8340
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8121
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8341
8122
  }
8342
8123
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8343
8124
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8356,9 +8137,9 @@ var HDWallet = class {
8356
8137
  * @returns A new instance of HDWallet on the derived index
8357
8138
  */
8358
8139
  deriveIndex(index) {
8359
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8360
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8361
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8140
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8141
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8142
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8362
8143
  const data = new Uint8Array(37);
8363
8144
  if (index & HARDENED_INDEX) {
8364
8145
  if (!privateKey) {
@@ -8369,15 +8150,15 @@ var HDWallet = class {
8369
8150
  }
8370
8151
  data.set(privateKey, 1);
8371
8152
  } else {
8372
- data.set((0, import_utils34.arrayify)(this.publicKey));
8153
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8373
8154
  }
8374
- data.set((0, import_math21.toBytes)(index, 4), 33);
8375
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8155
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8156
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8376
8157
  const IL = bytes.slice(0, 32);
8377
8158
  const IR = bytes.slice(32);
8378
8159
  if (privateKey) {
8379
8160
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8380
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8161
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8381
8162
  return new HDWallet({
8382
8163
  privateKey: ki,
8383
8164
  chainCode: IR,
@@ -8386,7 +8167,7 @@ var HDWallet = class {
8386
8167
  parentFingerprint: this.fingerprint
8387
8168
  });
8388
8169
  }
8389
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8170
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8390
8171
  const Ki = signer.addPoint(publicKey);
8391
8172
  return new HDWallet({
8392
8173
  publicKey: Ki,
@@ -8421,12 +8202,12 @@ var HDWallet = class {
8421
8202
  );
8422
8203
  }
8423
8204
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8424
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8205
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8425
8206
  const parentFingerprint = this.parentFingerprint;
8426
- const index = (0, import_math21.toHex)(this.index, 4);
8207
+ const index = (0, import_math20.toHex)(this.index, 4);
8427
8208
  const chainCode = this.chainCode;
8428
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8429
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8209
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8210
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8430
8211
  return base58check(extendedKey);
8431
8212
  }
8432
8213
  /**
@@ -8438,13 +8219,13 @@ var HDWallet = class {
8438
8219
  static fromSeed(seed) {
8439
8220
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8440
8221
  return new HDWallet({
8441
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8442
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8222
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8223
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8443
8224
  });
8444
8225
  }
8445
8226
  static fromExtendedKey(extendedKey) {
8446
8227
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8447
- const bytes = (0, import_utils34.arrayify)(decoded);
8228
+ const bytes = (0, import_utils35.arrayify)(decoded);
8448
8229
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8449
8230
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8450
8231
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8453,9 +8234,9 @@ var HDWallet = class {
8453
8234
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8454
8235
  }
8455
8236
  const depth = bytes[4];
8456
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8457
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8458
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8237
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8238
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8239
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8459
8240
  const key = bytes.slice(45, 78);
8460
8241
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8461
8242
  throw new import_errors20.FuelError(
@@ -9058,20 +8839,21 @@ var StorageAbstract = class {
9058
8839
  // src/predicate/predicate.ts
9059
8840
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9060
8841
  var import_address10 = require("@fuel-ts/address");
8842
+ var import_configs13 = require("@fuel-ts/address/configs");
9061
8843
  var import_errors25 = require("@fuel-ts/errors");
9062
8844
  var import_transactions21 = require("@fuel-ts/transactions");
9063
- var import_utils36 = require("@fuel-ts/utils");
8845
+ var import_utils37 = require("@fuel-ts/utils");
9064
8846
 
9065
8847
  // src/predicate/utils/getPredicateRoot.ts
9066
8848
  var import_hasher7 = require("@fuel-ts/hasher");
9067
8849
  var import_merkle = require("@fuel-ts/merkle");
9068
- var import_utils35 = require("@fuel-ts/utils");
8850
+ var import_utils36 = require("@fuel-ts/utils");
9069
8851
  var getPredicateRoot = (bytecode) => {
9070
8852
  const chunkSize = 16 * 1024;
9071
- const bytes = (0, import_utils35.arrayify)(bytecode);
9072
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9073
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9074
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8853
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8854
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8855
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8856
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9075
8857
  return predicateRoot;
9076
8858
  };
9077
8859
 
@@ -9118,23 +8900,41 @@ var Predicate = class extends Account {
9118
8900
  populateTransactionPredicateData(transactionRequestLike) {
9119
8901
  const request = transactionRequestify(transactionRequestLike);
9120
8902
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9121
- request.inputs?.forEach((input) => {
9122
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9123
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9124
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8903
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
8904
+ if (placeholderIndex !== -1) {
8905
+ request.removeWitness(placeholderIndex);
8906
+ }
8907
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
8908
+ if (isRequestInputResourceFromOwner(input, this.address)) {
8909
+ input.predicate = this.bytes;
8910
+ input.predicateData = this.getPredicateData(policies.length);
8911
+ input.witnessIndex = 0;
9125
8912
  }
9126
8913
  });
9127
8914
  return request;
9128
8915
  }
8916
+ /**
8917
+ * A helper that creates a transfer transaction request and returns it.
8918
+ *
8919
+ * @param destination - The address of the destination.
8920
+ * @param amount - The amount of coins to transfer.
8921
+ * @param assetId - The asset ID of the coins to transfer.
8922
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8923
+ * @returns A promise that resolves to the prepared transaction request.
8924
+ */
8925
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8926
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8927
+ return this.populateTransactionPredicateData(request);
8928
+ }
9129
8929
  /**
9130
8930
  * Sends a transaction with the populated predicate data.
9131
8931
  *
9132
8932
  * @param transactionRequestLike - The transaction request-like object.
9133
8933
  * @returns A promise that resolves to the transaction response.
9134
8934
  */
9135
- sendTransaction(transactionRequestLike) {
9136
- const transactionRequest = transactionRequestify(transactionRequestLike);
9137
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8935
+ sendTransaction(transactionRequestLike, options) {
8936
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8937
+ return super.sendTransaction(transactionRequest, options);
9138
8938
  }
9139
8939
  /**
9140
8940
  * Simulates a transaction with the populated predicate data.
@@ -9143,8 +8943,22 @@ var Predicate = class extends Account {
9143
8943
  * @returns A promise that resolves to the call result.
9144
8944
  */
9145
8945
  simulateTransaction(transactionRequestLike) {
9146
- const transactionRequest = transactionRequestify(transactionRequestLike);
9147
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8946
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8947
+ return super.simulateTransaction(transactionRequest);
8948
+ }
8949
+ /**
8950
+ * Retrieves resources satisfying the spend query for the account.
8951
+ *
8952
+ * @param quantities - Coins to retrieve.
8953
+ * @param excludedIds - IDs of resources to be excluded from the query.
8954
+ * @returns A promise that resolves to an array of Resources.
8955
+ */
8956
+ async getResourcesToSpend(quantities, excludedIds) {
8957
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
8958
+ return resources.map((resource) => ({
8959
+ ...resource,
8960
+ predicate: (0, import_utils37.hexlify)(this.bytes)
8961
+ }));
9148
8962
  }
9149
8963
  getPredicateData(policiesLength) {
9150
8964
  if (!this.predicateData.length) {
@@ -9167,7 +8981,7 @@ var Predicate = class extends Account {
9167
8981
  * @returns An object containing the new predicate bytes and interface.
9168
8982
  */
9169
8983
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9170
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8984
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9171
8985
  let abiInterface;
9172
8986
  if (jsonAbi) {
9173
8987
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9190,25 +9004,6 @@ var Predicate = class extends Account {
9190
9004
  predicateInterface: abiInterface
9191
9005
  };
9192
9006
  }
9193
- /**
9194
- * Retrieves resources satisfying the spend query for the account.
9195
- *
9196
- * @param quantities - IDs of coins to exclude.
9197
- * @param excludedIds - IDs of resources to be excluded from the query.
9198
- * @returns A promise that resolves to an array of Resources.
9199
- */
9200
- async getResourcesToSpend(quantities, excludedIds) {
9201
- const resources = await this.provider.getResourcesToSpend(
9202
- this.address,
9203
- quantities,
9204
- excludedIds
9205
- );
9206
- return resources.map((resource) => ({
9207
- ...resource,
9208
- predicate: (0, import_utils36.hexlify)(this.bytes),
9209
- padPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9210
- }));
9211
- }
9212
9007
  /**
9213
9008
  * Sets the configurable constants for the predicate.
9214
9009
  *
@@ -9244,6 +9039,28 @@ var Predicate = class extends Account {
9244
9039
  }
9245
9040
  return mutatedBytes;
9246
9041
  }
9042
+ /**
9043
+ * Returns the index of the witness placeholder that was added to this predicate.
9044
+ * If no witness placeholder was added, it returns -1.
9045
+ * @param request - The transaction request.
9046
+ * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
9047
+ */
9048
+ getIndexFromPlaceholderWitness(request) {
9049
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
9050
+ let index = -1;
9051
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
9052
+ if (hasEmptyPredicateInputs) {
9053
+ index = hasEmptyPredicateInputs.witnessIndex;
9054
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
9055
+ if (!allInputsAreEmpty) {
9056
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
9057
+ if (wasFilledInputAddedFirst) {
9058
+ index = -1;
9059
+ }
9060
+ }
9061
+ }
9062
+ return index;
9063
+ }
9247
9064
  };
9248
9065
 
9249
9066
  // src/connectors/fuel.ts
@@ -9958,7 +9775,7 @@ __publicField(Fuel, "defaultConfig", {});
9958
9775
  WalletLocked,
9959
9776
  WalletManager,
9960
9777
  WalletUnlocked,
9961
- addAmountToCoinQuantities,
9778
+ addAmountToAsset,
9962
9779
  addOperation,
9963
9780
  assemblePanicError,
9964
9781
  assembleReceiptByType,
@@ -9967,10 +9784,10 @@ __publicField(Fuel, "defaultConfig", {});
9967
9784
  assets,
9968
9785
  buildBlockExplorerUrl,
9969
9786
  cacheFor,
9970
- cacheTxInputsFromOwner,
9971
- calculateGasFee,
9787
+ cacheResources,
9972
9788
  calculateMetadataGasForTxCreate,
9973
9789
  calculateMetadataGasForTxScript,
9790
+ calculatePriceWithFactor,
9974
9791
  calculateTransactionFee,
9975
9792
  coinQuantityfy,
9976
9793
  deferPromise,
@@ -10014,6 +9831,7 @@ __publicField(Fuel, "defaultConfig", {});
10014
9831
  getReceiptsMessageOut,
10015
9832
  getReceiptsTransferOut,
10016
9833
  getReceiptsWithMissingData,
9834
+ getRequestInputResourceOwner,
10017
9835
  getTransactionStatusName,
10018
9836
  getTransactionSummary,
10019
9837
  getTransactionSummaryFromRequest,
@@ -10027,6 +9845,10 @@ __publicField(Fuel, "defaultConfig", {});
10027
9845
  isMessage,
10028
9846
  isRawCoin,
10029
9847
  isRawMessage,
9848
+ isRequestInputCoin,
9849
+ isRequestInputMessage,
9850
+ isRequestInputResource,
9851
+ isRequestInputResourceFromOwner,
10030
9852
  isType,
10031
9853
  isTypeCreate,
10032
9854
  isTypeMint,