@fuel-ts/account 0.82.0 → 0.84.0

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

Potentially problematic release.


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

Files changed (76) hide show
  1. package/README.md +18 -15
  2. package/dist/account.d.ts +8 -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 +2445 -2185
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +1074 -667
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +909 -505
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +12 -24
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +950 -376
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +9 -3
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +72 -54
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/resource.d.ts +0 -1
  30. package/dist/providers/resource.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  32. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/helpers.d.ts +8 -0
  34. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  35. package/dist/providers/transaction-request/input.d.ts +2 -2
  36. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
  38. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  39. package/dist/providers/transaction-request/transaction-request.d.ts +17 -38
  40. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  41. package/dist/providers/transaction-request/utils.d.ts +4 -0
  42. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  43. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +4 -2
  45. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  46. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
  47. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
  48. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  49. package/dist/providers/transaction-summary/index.d.ts +1 -1
  50. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  51. package/dist/providers/transaction-summary/operations.d.ts +4 -0
  52. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  53. package/dist/providers/transaction-summary/status.d.ts +5 -1
  54. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  55. package/dist/providers/transaction-summary/types.d.ts +6 -1
  56. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  57. package/dist/providers/utils/gas.d.ts +14 -7
  58. package/dist/providers/utils/gas.d.ts.map +1 -1
  59. package/dist/providers/utils/merge-quantities.d.ts +1 -1
  60. package/dist/providers/utils/merge-quantities.d.ts.map +1 -1
  61. package/dist/test-utils/launchNode.d.ts +1 -1
  62. package/dist/test-utils/launchNode.d.ts.map +1 -1
  63. package/dist/test-utils/resources.d.ts +4 -0
  64. package/dist/test-utils/resources.d.ts.map +1 -0
  65. package/dist/test-utils/transactionRequest.d.ts +5 -0
  66. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  67. package/dist/test-utils.global.js +3171 -2680
  68. package/dist/test-utils.global.js.map +1 -1
  69. package/dist/test-utils.js +1046 -655
  70. package/dist/test-utils.js.map +1 -1
  71. package/dist/test-utils.mjs +896 -505
  72. package/dist/test-utils.mjs.map +1 -1
  73. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  74. package/package.json +18 -18
  75. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -21
  76. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToAsset: () => addAmountToAsset,
98
+ addAmountToCoinQuantities: () => addAmountToCoinQuantities,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,11 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
+ cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
+ calculateGasFee: () => calculateGasFee,
107
109
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
108
110
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
- calculatePriceWithFactor: () => calculatePriceWithFactor,
110
- calculateTransactionFee: () => calculateTransactionFee,
111
+ calculateTXFeeForSummary: () => calculateTXFeeForSummary,
111
112
  coinQuantityfy: () => coinQuantityfy,
112
113
  deferPromise: () => deferPromise,
113
114
  dispatchFuelConnectorEvent: () => dispatchFuelConnectorEvent,
@@ -167,6 +168,8 @@ __export(src_exports, {
167
168
  isTypeCreate: () => isTypeCreate,
168
169
  isTypeMint: () => isTypeMint,
169
170
  isTypeScript: () => isTypeScript,
171
+ isTypeUpgrade: () => isTypeUpgrade,
172
+ isTypeUpload: () => isTypeUpload,
170
173
  normalizeJSON: () => normalizeJSON,
171
174
  outputify: () => outputify,
172
175
  processGqlReceipt: () => processGqlReceipt,
@@ -184,37 +187,36 @@ module.exports = __toCommonJS(src_exports);
184
187
 
185
188
  // src/account.ts
186
189
  var import_address4 = require("@fuel-ts/address");
187
- var import_configs12 = require("@fuel-ts/address/configs");
188
190
  var import_errors16 = require("@fuel-ts/errors");
189
191
  var import_interfaces = require("@fuel-ts/interfaces");
190
- var import_math18 = require("@fuel-ts/math");
191
- var import_utils28 = require("@fuel-ts/utils");
192
+ var import_math21 = require("@fuel-ts/math");
193
+ var import_utils27 = require("@fuel-ts/utils");
194
+ var import_ramda4 = require("ramda");
192
195
 
193
196
  // src/providers/coin-quantity.ts
194
- var import_configs = require("@fuel-ts/address/configs");
195
197
  var import_math = require("@fuel-ts/math");
196
198
  var import_utils = require("@fuel-ts/utils");
197
199
  var coinQuantityfy = (coinQuantityLike) => {
198
200
  let assetId;
199
201
  let amount;
200
- let max2;
202
+ let max;
201
203
  if (Array.isArray(coinQuantityLike)) {
202
204
  amount = coinQuantityLike[0];
203
- assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
204
- max2 = coinQuantityLike[2] ?? void 0;
205
+ assetId = coinQuantityLike[1];
206
+ max = coinQuantityLike[2] ?? void 0;
205
207
  } else {
206
208
  amount = coinQuantityLike.amount;
207
- assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
208
- max2 = coinQuantityLike.max ?? void 0;
209
+ assetId = coinQuantityLike.assetId;
210
+ max = coinQuantityLike.max ?? void 0;
209
211
  }
210
212
  const bnAmount = (0, import_math.bn)(amount);
211
213
  return {
212
214
  assetId: (0, import_utils.hexlify)(assetId),
213
215
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
214
- max: max2 ? (0, import_math.bn)(max2) : void 0
216
+ max: max ? (0, import_math.bn)(max) : void 0
215
217
  };
216
218
  };
217
- var addAmountToAsset = (params) => {
219
+ var addAmountToCoinQuantities = (params) => {
218
220
  const { amount, assetId } = params;
219
221
  const coinQuantities = [...params.coinQuantities];
220
222
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -229,27 +231,30 @@ var addAmountToAsset = (params) => {
229
231
  // src/providers/provider.ts
230
232
  var import_address3 = require("@fuel-ts/address");
231
233
  var import_errors14 = require("@fuel-ts/errors");
232
- var import_math15 = require("@fuel-ts/math");
233
- var import_transactions18 = require("@fuel-ts/transactions");
234
- var import_utils23 = require("@fuel-ts/utils");
234
+ var import_math17 = require("@fuel-ts/math");
235
+ var import_transactions19 = require("@fuel-ts/transactions");
236
+ var import_utils22 = require("@fuel-ts/utils");
235
237
  var import_versions = require("@fuel-ts/versions");
236
- var import_utils24 = require("@noble/curves/abstract/utils");
237
- var import_ethers = require("ethers");
238
+ var import_utils23 = require("@noble/curves/abstract/utils");
238
239
  var import_graphql_request = require("graphql-request");
239
240
  var import_ramda3 = require("ramda");
240
241
 
241
242
  // src/providers/__generated__/operations.ts
242
243
  var import_graphql_tag = __toESM(require("graphql-tag"));
244
+ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
245
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
246
+ type: __typename
247
+ ... on SqueezedOutStatus {
248
+ reason
249
+ }
250
+ }
251
+ `;
243
252
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
244
253
  fragment receiptFragment on Receipt {
245
- contract {
246
- id
247
- }
254
+ id
248
255
  pc
249
256
  is
250
- to {
251
- id
252
- }
257
+ to
253
258
  toAddress
254
259
  amount
255
260
  assetId
@@ -291,33 +296,38 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
291
296
  returnType
292
297
  data
293
298
  }
299
+ receipts {
300
+ ...receiptFragment
301
+ }
302
+ totalGas
303
+ totalFee
294
304
  }
295
305
  ... on FailureStatus {
296
306
  block {
297
307
  id
298
308
  }
309
+ totalGas
310
+ totalFee
299
311
  time
300
312
  reason
313
+ receipts {
314
+ ...receiptFragment
315
+ }
301
316
  }
302
317
  ... on SqueezedOutStatus {
303
318
  reason
304
319
  }
305
320
  }
306
- `;
321
+ ${ReceiptFragmentFragmentDoc}`;
307
322
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
308
323
  fragment transactionFragment on Transaction {
309
324
  id
310
325
  rawPayload
311
- gasPrice
312
- receipts {
313
- ...receiptFragment
314
- }
315
326
  status {
316
327
  ...transactionStatusFragment
317
328
  }
318
329
  }
319
- ${ReceiptFragmentFragmentDoc}
320
- ${TransactionStatusFragmentFragmentDoc}`;
330
+ ${TransactionStatusFragmentFragmentDoc}`;
321
331
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
322
332
  fragment inputEstimatePredicatesFragment on Input {
323
333
  ... on InputCoin {
@@ -335,6 +345,50 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
335
345
  }
336
346
  }
337
347
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
348
+ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
349
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
350
+ totalGas
351
+ totalFee
352
+ reason
353
+ programState {
354
+ returnType
355
+ data
356
+ }
357
+ }
358
+ `;
359
+ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
360
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
361
+ totalGas
362
+ totalFee
363
+ programState {
364
+ returnType
365
+ data
366
+ }
367
+ }
368
+ `;
369
+ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
370
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
371
+ ... on DryRunFailureStatus {
372
+ ...dryRunFailureStatusFragment
373
+ }
374
+ ... on DryRunSuccessStatus {
375
+ ...dryRunSuccessStatusFragment
376
+ }
377
+ }
378
+ ${DryRunFailureStatusFragmentFragmentDoc}
379
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
380
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
381
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
382
+ id
383
+ status {
384
+ ...dryRunTransactionStatusFragment
385
+ }
386
+ receipts {
387
+ ...receiptFragment
388
+ }
389
+ }
390
+ ${DryRunTransactionStatusFragmentFragmentDoc}
391
+ ${ReceiptFragmentFragmentDoc}`;
338
392
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
339
393
  fragment coinFragment on Coin {
340
394
  __typename
@@ -342,7 +396,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
342
396
  owner
343
397
  amount
344
398
  assetId
345
- maturity
346
399
  blockCreated
347
400
  txCreatedIdx
348
401
  }
@@ -381,26 +434,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
381
434
  messageBlockHeader {
382
435
  id
383
436
  daHeight
437
+ consensusParametersVersion
438
+ stateTransitionBytecodeVersion
384
439
  transactionsCount
440
+ messageReceiptCount
385
441
  transactionsRoot
442
+ messageOutboxRoot
443
+ eventInboxRoot
386
444
  height
387
445
  prevRoot
388
446
  time
389
447
  applicationHash
390
- messageReceiptRoot
391
- messageReceiptCount
392
448
  }
393
449
  commitBlockHeader {
394
450
  id
395
451
  daHeight
452
+ consensusParametersVersion
453
+ stateTransitionBytecodeVersion
396
454
  transactionsCount
455
+ messageReceiptCount
397
456
  transactionsRoot
457
+ messageOutboxRoot
458
+ eventInboxRoot
398
459
  height
399
460
  prevRoot
400
461
  time
401
462
  applicationHash
402
- messageReceiptRoot
403
- messageReceiptCount
404
463
  }
405
464
  sender
406
465
  recipient
@@ -419,8 +478,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
419
478
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
420
479
  fragment blockFragment on Block {
421
480
  id
481
+ height
422
482
  header {
423
- height
424
483
  time
425
484
  }
426
485
  transactions {
@@ -430,15 +489,18 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
430
489
  `;
431
490
  var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
432
491
  fragment TxParametersFragment on TxParameters {
492
+ version
433
493
  maxInputs
434
494
  maxOutputs
435
495
  maxWitnesses
436
496
  maxGasPerTx
437
497
  maxSize
498
+ maxBytecodeSubsections
438
499
  }
439
500
  `;
440
501
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
441
502
  fragment PredicateParametersFragment on PredicateParameters {
503
+ version
442
504
  maxPredicateLength
443
505
  maxPredicateDataLength
444
506
  maxGasPerPredicate
@@ -447,18 +509,21 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
447
509
  `;
448
510
  var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
449
511
  fragment ScriptParametersFragment on ScriptParameters {
512
+ version
450
513
  maxScriptLength
451
514
  maxScriptDataLength
452
515
  }
453
516
  `;
454
517
  var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
455
518
  fragment ContractParametersFragment on ContractParameters {
519
+ version
456
520
  contractMaxSize
457
521
  maxStorageSlots
458
522
  }
459
523
  `;
460
524
  var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
461
525
  fragment FeeParametersFragment on FeeParameters {
526
+ version
462
527
  gasPriceFactor
463
528
  gasPerByte
464
529
  }
@@ -478,6 +543,7 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
478
543
  `;
479
544
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
480
545
  fragment GasCostsFragment on GasCosts {
546
+ version
481
547
  add
482
548
  addi
483
549
  aloc
@@ -490,7 +556,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
490
556
  cb
491
557
  cfei
492
558
  cfsi
493
- croo
494
559
  div
495
560
  divi
496
561
  ecr1
@@ -573,6 +638,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
573
638
  ccp {
574
639
  ...DependentCostFragment
575
640
  }
641
+ croo {
642
+ ...DependentCostFragment
643
+ }
576
644
  csiz {
577
645
  ...DependentCostFragment
578
646
  }
@@ -632,6 +700,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
632
700
  ${DependentCostFragmentFragmentDoc}`;
633
701
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
634
702
  fragment consensusParametersFragment on ConsensusParameters {
703
+ version
635
704
  txParams {
636
705
  ...TxParametersFragment
637
706
  }
@@ -691,17 +760,16 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
691
760
  fragment nodeInfoFragment on NodeInfo {
692
761
  utxoValidation
693
762
  vmBacktrace
694
- minGasPrice
695
763
  maxTx
696
764
  maxDepth
697
765
  nodeVersion
698
- peers {
699
- id
700
- addresses
701
- clientVersion
766
+ }
767
+ `;
768
+ var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
769
+ fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
770
+ ... on RelayedTransactionFailed {
702
771
  blockHeight
703
- lastHeartbeatMs
704
- appScore
772
+ failure
705
773
  }
706
774
  }
707
775
  `;
@@ -737,13 +805,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
737
805
  query getTransactionWithReceipts($transactionId: TransactionId!) {
738
806
  transaction(id: $transactionId) {
739
807
  ...transactionFragment
740
- receipts {
741
- ...receiptFragment
742
- }
743
808
  }
744
809
  }
745
- ${TransactionFragmentFragmentDoc}
746
- ${ReceiptFragmentFragmentDoc}`;
810
+ ${TransactionFragmentFragmentDoc}`;
747
811
  var GetTransactionsDocument = import_graphql_tag.default`
748
812
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
749
813
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -871,6 +935,20 @@ var GetBalanceDocument = import_graphql_tag.default`
871
935
  }
872
936
  }
873
937
  ${BalanceFragmentFragmentDoc}`;
938
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
939
+ query getLatestGasPrice {
940
+ latestGasPrice {
941
+ gasPrice
942
+ }
943
+ }
944
+ `;
945
+ var EstimateGasPriceDocument = import_graphql_tag.default`
946
+ query estimateGasPrice($blockHorizon: U32!) {
947
+ estimateGasPrice(blockHorizon: $blockHorizon) {
948
+ gasPrice
949
+ }
950
+ }
951
+ `;
874
952
  var GetBalancesDocument = import_graphql_tag.default`
875
953
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
876
954
  balances(
@@ -924,13 +1002,20 @@ var GetMessageStatusDocument = import_graphql_tag.default`
924
1002
  }
925
1003
  }
926
1004
  `;
1005
+ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1006
+ query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
1007
+ relayedTransactionStatus(id: $relayedTransactionId) {
1008
+ ...relayedTransactionStatusFragment
1009
+ }
1010
+ }
1011
+ ${RelayedTransactionStatusFragmentFragmentDoc}`;
927
1012
  var DryRunDocument = import_graphql_tag.default`
928
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
- ...receiptFragment
1013
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
1014
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
1015
+ ...dryRunTransactionExecutionStatusFragment
931
1016
  }
932
1017
  }
933
- ${ReceiptFragmentFragmentDoc}`;
1018
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
934
1019
  var SubmitDocument = import_graphql_tag.default`
935
1020
  mutation submit($encodedTransaction: HexString!) {
936
1021
  submit(tx: $encodedTransaction) {
@@ -946,20 +1031,27 @@ var ProduceBlocksDocument = import_graphql_tag.default`
946
1031
  )
947
1032
  }
948
1033
  `;
1034
+ var GetMessageByNonceDocument = import_graphql_tag.default`
1035
+ query getMessageByNonce($nonce: Nonce!) {
1036
+ message(nonce: $nonce) {
1037
+ ...messageFragment
1038
+ }
1039
+ }
1040
+ ${MessageFragmentFragmentDoc}`;
949
1041
  var SubmitAndAwaitDocument = import_graphql_tag.default`
950
1042
  subscription submitAndAwait($encodedTransaction: HexString!) {
951
1043
  submitAndAwait(tx: $encodedTransaction) {
952
- ...transactionStatusFragment
1044
+ ...transactionStatusSubscriptionFragment
953
1045
  }
954
1046
  }
955
- ${TransactionStatusFragmentFragmentDoc}`;
1047
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
956
1048
  var StatusChangeDocument = import_graphql_tag.default`
957
1049
  subscription statusChange($transactionId: TransactionId!) {
958
1050
  statusChange(id: $transactionId) {
959
- ...transactionStatusFragment
1051
+ ...transactionStatusSubscriptionFragment
960
1052
  }
961
1053
  }
962
- ${TransactionStatusFragmentFragmentDoc}`;
1054
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
963
1055
  function getSdk(requester) {
964
1056
  return {
965
1057
  getVersion(variables, options) {
@@ -1013,6 +1105,12 @@ function getSdk(requester) {
1013
1105
  getBalance(variables, options) {
1014
1106
  return requester(GetBalanceDocument, variables, options);
1015
1107
  },
1108
+ getLatestGasPrice(variables, options) {
1109
+ return requester(GetLatestGasPriceDocument, variables, options);
1110
+ },
1111
+ estimateGasPrice(variables, options) {
1112
+ return requester(EstimateGasPriceDocument, variables, options);
1113
+ },
1016
1114
  getBalances(variables, options) {
1017
1115
  return requester(GetBalancesDocument, variables, options);
1018
1116
  },
@@ -1025,6 +1123,9 @@ function getSdk(requester) {
1025
1123
  getMessageStatus(variables, options) {
1026
1124
  return requester(GetMessageStatusDocument, variables, options);
1027
1125
  },
1126
+ getRelayedTransactionStatus(variables, options) {
1127
+ return requester(GetRelayedTransactionStatusDocument, variables, options);
1128
+ },
1028
1129
  dryRun(variables, options) {
1029
1130
  return requester(DryRunDocument, variables, options);
1030
1131
  },
@@ -1034,6 +1135,9 @@ function getSdk(requester) {
1034
1135
  produceBlocks(variables, options) {
1035
1136
  return requester(ProduceBlocksDocument, variables, options);
1036
1137
  },
1138
+ getMessageByNonce(variables, options) {
1139
+ return requester(GetMessageByNonceDocument, variables, options);
1140
+ },
1037
1141
  submitAndAwait(variables, options) {
1038
1142
  return requester(SubmitAndAwaitDocument, variables, options);
1039
1143
  },
@@ -1183,7 +1287,7 @@ var MemoryCache = class {
1183
1287
 
1184
1288
  // src/providers/transaction-request/input.ts
1185
1289
  var import_abi_coder = require("@fuel-ts/abi-coder");
1186
- var import_configs2 = require("@fuel-ts/address/configs");
1290
+ var import_configs = require("@fuel-ts/address/configs");
1187
1291
  var import_errors3 = require("@fuel-ts/errors");
1188
1292
  var import_math2 = require("@fuel-ts/math");
1189
1293
  var import_transactions = require("@fuel-ts/transactions");
@@ -1206,10 +1310,9 @@ var inputify = (value) => {
1206
1310
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1207
1311
  },
1208
1312
  witnessIndex: value.witnessIndex,
1209
- maturity: value.maturity ?? 0,
1210
1313
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1211
- predicateLength: predicate.length,
1212
- predicateDataLength: predicateData.length,
1314
+ predicateLength: (0, import_math2.bn)(predicate.length),
1315
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1213
1316
  predicate: (0, import_utils3.hexlify)(predicate),
1214
1317
  predicateData: (0, import_utils3.hexlify)(predicateData)
1215
1318
  };
@@ -1217,10 +1320,10 @@ var inputify = (value) => {
1217
1320
  case import_transactions.InputType.Contract: {
1218
1321
  return {
1219
1322
  type: import_transactions.InputType.Contract,
1220
- txID: import_configs2.ZeroBytes32,
1323
+ txID: import_configs.ZeroBytes32,
1221
1324
  outputIndex: 0,
1222
- balanceRoot: import_configs2.ZeroBytes32,
1223
- stateRoot: import_configs2.ZeroBytes32,
1325
+ balanceRoot: import_configs.ZeroBytes32,
1326
+ stateRoot: import_configs.ZeroBytes32,
1224
1327
  txPointer: {
1225
1328
  blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1226
1329
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
@@ -1240,8 +1343,8 @@ var inputify = (value) => {
1240
1343
  nonce: (0, import_utils3.hexlify)(value.nonce),
1241
1344
  witnessIndex: value.witnessIndex,
1242
1345
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1243
- predicateLength: predicate.length,
1244
- predicateDataLength: predicateData.length,
1346
+ predicateLength: (0, import_math2.bn)(predicate.length),
1347
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1245
1348
  predicate: (0, import_utils3.hexlify)(predicate),
1246
1349
  predicateData: (0, import_utils3.hexlify)(predicateData),
1247
1350
  data: (0, import_utils3.hexlify)(data),
@@ -1258,7 +1361,7 @@ var inputify = (value) => {
1258
1361
  };
1259
1362
 
1260
1363
  // src/providers/transaction-request/output.ts
1261
- var import_configs3 = require("@fuel-ts/address/configs");
1364
+ var import_configs2 = require("@fuel-ts/address/configs");
1262
1365
  var import_errors4 = require("@fuel-ts/errors");
1263
1366
  var import_math3 = require("@fuel-ts/math");
1264
1367
  var import_transactions2 = require("@fuel-ts/transactions");
@@ -1278,8 +1381,8 @@ var outputify = (value) => {
1278
1381
  return {
1279
1382
  type: import_transactions2.OutputType.Contract,
1280
1383
  inputIndex: value.inputIndex,
1281
- balanceRoot: import_configs3.ZeroBytes32,
1282
- stateRoot: import_configs3.ZeroBytes32
1384
+ balanceRoot: import_configs2.ZeroBytes32,
1385
+ stateRoot: import_configs2.ZeroBytes32
1283
1386
  };
1284
1387
  }
1285
1388
  case import_transactions2.OutputType.Change: {
@@ -1293,9 +1396,9 @@ var outputify = (value) => {
1293
1396
  case import_transactions2.OutputType.Variable: {
1294
1397
  return {
1295
1398
  type: import_transactions2.OutputType.Variable,
1296
- to: import_configs3.ZeroBytes32,
1399
+ to: import_configs2.ZeroBytes32,
1297
1400
  amount: (0, import_math3.bn)(0),
1298
- assetId: import_configs3.ZeroBytes32
1401
+ assetId: import_configs2.ZeroBytes32
1299
1402
  };
1300
1403
  }
1301
1404
  case import_transactions2.OutputType.ContractCreated: {
@@ -1317,7 +1420,7 @@ var outputify = (value) => {
1317
1420
  // src/providers/transaction-request/transaction-request.ts
1318
1421
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1319
1422
  var import_address = require("@fuel-ts/address");
1320
- var import_configs7 = require("@fuel-ts/address/configs");
1423
+ var import_configs6 = require("@fuel-ts/address/configs");
1321
1424
  var import_crypto = require("@fuel-ts/crypto");
1322
1425
  var import_math7 = require("@fuel-ts/math");
1323
1426
  var import_transactions6 = require("@fuel-ts/transactions");
@@ -1330,13 +1433,13 @@ var isCoin = (resource) => "id" in resource;
1330
1433
  var isMessage = (resource) => "recipient" in resource;
1331
1434
 
1332
1435
  // src/providers/utils/receipts.ts
1333
- var import_configs4 = require("@fuel-ts/address/configs");
1436
+ var import_configs3 = require("@fuel-ts/address/configs");
1334
1437
  var import_errors5 = require("@fuel-ts/errors");
1335
1438
  var import_math4 = require("@fuel-ts/math");
1336
1439
  var import_transactions3 = require("@fuel-ts/transactions");
1337
- var import_configs5 = require("@fuel-ts/transactions/configs");
1440
+ var import_configs4 = require("@fuel-ts/transactions/configs");
1338
1441
  var import_utils5 = require("@fuel-ts/utils");
1339
- var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1442
+ var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs4.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1340
1443
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1341
1444
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1342
1445
  (memo, receipt) => {
@@ -1353,15 +1456,15 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
1353
1456
  missingOutputContractIds: []
1354
1457
  }
1355
1458
  );
1356
- var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
1459
+ var hexOrZero = (hex) => hex || import_configs3.ZeroBytes32;
1357
1460
  function assembleReceiptByType(receipt) {
1358
1461
  const { receiptType } = receipt;
1359
1462
  switch (receiptType) {
1360
1463
  case "CALL" /* Call */: {
1361
1464
  const callReceipt = {
1362
1465
  type: import_transactions3.ReceiptType.Call,
1363
- from: hexOrZero(receipt.contract?.id),
1364
- to: hexOrZero(receipt?.to?.id),
1466
+ from: hexOrZero(receipt.id || receipt.contractId),
1467
+ to: hexOrZero(receipt?.to),
1365
1468
  amount: (0, import_math4.bn)(receipt.amount),
1366
1469
  assetId: hexOrZero(receipt.assetId),
1367
1470
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1375,7 +1478,7 @@ function assembleReceiptByType(receipt) {
1375
1478
  case "RETURN" /* Return */: {
1376
1479
  const returnReceipt = {
1377
1480
  type: import_transactions3.ReceiptType.Return,
1378
- id: hexOrZero(receipt.contract?.id),
1481
+ id: hexOrZero(receipt.id || receipt.contractId),
1379
1482
  val: (0, import_math4.bn)(receipt.val),
1380
1483
  pc: (0, import_math4.bn)(receipt.pc),
1381
1484
  is: (0, import_math4.bn)(receipt.is)
@@ -1385,7 +1488,7 @@ function assembleReceiptByType(receipt) {
1385
1488
  case "RETURN_DATA" /* ReturnData */: {
1386
1489
  const returnDataReceipt = {
1387
1490
  type: import_transactions3.ReceiptType.ReturnData,
1388
- id: hexOrZero(receipt.contract?.id),
1491
+ id: hexOrZero(receipt.id || receipt.contractId),
1389
1492
  ptr: (0, import_math4.bn)(receipt.ptr),
1390
1493
  len: (0, import_math4.bn)(receipt.len),
1391
1494
  digest: hexOrZero(receipt.digest),
@@ -1397,7 +1500,7 @@ function assembleReceiptByType(receipt) {
1397
1500
  case "PANIC" /* Panic */: {
1398
1501
  const panicReceipt = {
1399
1502
  type: import_transactions3.ReceiptType.Panic,
1400
- id: hexOrZero(receipt.contract?.id),
1503
+ id: hexOrZero(receipt.id),
1401
1504
  reason: (0, import_math4.bn)(receipt.reason),
1402
1505
  pc: (0, import_math4.bn)(receipt.pc),
1403
1506
  is: (0, import_math4.bn)(receipt.is),
@@ -1408,7 +1511,7 @@ function assembleReceiptByType(receipt) {
1408
1511
  case "REVERT" /* Revert */: {
1409
1512
  const revertReceipt = {
1410
1513
  type: import_transactions3.ReceiptType.Revert,
1411
- id: hexOrZero(receipt.contract?.id),
1514
+ id: hexOrZero(receipt.id || receipt.contractId),
1412
1515
  val: (0, import_math4.bn)(receipt.ra),
1413
1516
  pc: (0, import_math4.bn)(receipt.pc),
1414
1517
  is: (0, import_math4.bn)(receipt.is)
@@ -1418,7 +1521,7 @@ function assembleReceiptByType(receipt) {
1418
1521
  case "LOG" /* Log */: {
1419
1522
  const logReceipt = {
1420
1523
  type: import_transactions3.ReceiptType.Log,
1421
- id: hexOrZero(receipt.contract?.id),
1524
+ id: hexOrZero(receipt.id || receipt.contractId),
1422
1525
  val0: (0, import_math4.bn)(receipt.ra),
1423
1526
  val1: (0, import_math4.bn)(receipt.rb),
1424
1527
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1431,7 +1534,7 @@ function assembleReceiptByType(receipt) {
1431
1534
  case "LOG_DATA" /* LogData */: {
1432
1535
  const logDataReceipt = {
1433
1536
  type: import_transactions3.ReceiptType.LogData,
1434
- id: hexOrZero(receipt.contract?.id),
1537
+ id: hexOrZero(receipt.id || receipt.contractId),
1435
1538
  val0: (0, import_math4.bn)(receipt.ra),
1436
1539
  val1: (0, import_math4.bn)(receipt.rb),
1437
1540
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1445,8 +1548,8 @@ function assembleReceiptByType(receipt) {
1445
1548
  case "TRANSFER" /* Transfer */: {
1446
1549
  const transferReceipt = {
1447
1550
  type: import_transactions3.ReceiptType.Transfer,
1448
- from: hexOrZero(receipt.contract?.id),
1449
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1551
+ from: hexOrZero(receipt.id || receipt.contractId),
1552
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1450
1553
  amount: (0, import_math4.bn)(receipt.amount),
1451
1554
  assetId: hexOrZero(receipt.assetId),
1452
1555
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1457,8 +1560,8 @@ function assembleReceiptByType(receipt) {
1457
1560
  case "TRANSFER_OUT" /* TransferOut */: {
1458
1561
  const transferOutReceipt = {
1459
1562
  type: import_transactions3.ReceiptType.TransferOut,
1460
- from: hexOrZero(receipt.contract?.id),
1461
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1563
+ from: hexOrZero(receipt.id || receipt.contractId),
1564
+ to: hexOrZero(receipt.toAddress || receipt.to),
1462
1565
  amount: (0, import_math4.bn)(receipt.amount),
1463
1566
  assetId: hexOrZero(receipt.assetId),
1464
1567
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1501,7 +1604,7 @@ function assembleReceiptByType(receipt) {
1501
1604
  return receiptMessageOut;
1502
1605
  }
1503
1606
  case "MINT" /* Mint */: {
1504
- const contractId = hexOrZero(receipt.contract?.id);
1607
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1505
1608
  const subId = hexOrZero(receipt.subId);
1506
1609
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1507
1610
  const mintReceipt = {
@@ -1516,7 +1619,7 @@ function assembleReceiptByType(receipt) {
1516
1619
  return mintReceipt;
1517
1620
  }
1518
1621
  case "BURN" /* Burn */: {
1519
- const contractId = hexOrZero(receipt.contract?.id);
1622
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1520
1623
  const subId = hexOrZero(receipt.subId);
1521
1624
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1522
1625
  const burnReceipt = {
@@ -1601,7 +1704,6 @@ var buildBlockExplorerUrl = (options = {}) => {
1601
1704
  var import_math5 = require("@fuel-ts/math");
1602
1705
  var import_transactions4 = require("@fuel-ts/transactions");
1603
1706
  var import_utils6 = require("@fuel-ts/utils");
1604
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1605
1707
  var getGasUsedFromReceipts = (receipts) => {
1606
1708
  const scriptResult = receipts.filter(
1607
1709
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1622,18 +1724,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1622
1724
  }
1623
1725
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1624
1726
  const witnessCache = [];
1625
- const totalGas = inputs.reduce((total, input) => {
1727
+ const chargeableInputs = inputs.filter((input) => {
1728
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1729
+ if (isCoinOrMessage) {
1730
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1731
+ return true;
1732
+ }
1733
+ if (!witnessCache.includes(input.witnessIndex)) {
1734
+ witnessCache.push(input.witnessIndex);
1735
+ return true;
1736
+ }
1737
+ }
1738
+ return false;
1739
+ });
1740
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1741
+ const totalGas = chargeableInputs.reduce((total, input) => {
1626
1742
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1627
1743
  return total.add(
1628
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1744
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1629
1745
  );
1630
1746
  }
1631
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1632
- witnessCache.push(input.witnessIndex);
1633
- return total.add(gasCosts.ecr1);
1634
- }
1635
- return total;
1636
- }, (0, import_math5.bn)());
1747
+ return total.add(gasCosts.ecr1);
1748
+ }, (0, import_math5.bn)(0));
1637
1749
  return totalGas;
1638
1750
  }
1639
1751
  function getMinGas(params) {
@@ -1645,12 +1757,20 @@ function getMinGas(params) {
1645
1757
  return minGas;
1646
1758
  }
1647
1759
  function getMaxGas(params) {
1648
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1760
+ const {
1761
+ gasPerByte,
1762
+ witnessesLength,
1763
+ witnessLimit,
1764
+ minGas,
1765
+ gasLimit = (0, import_math5.bn)(0),
1766
+ maxGasPerTx
1767
+ } = params;
1649
1768
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1650
1769
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1651
1770
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1652
1771
  }
1653
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1772
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1773
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1654
1774
  }
1655
1775
  function calculateMetadataGasForTxCreate({
1656
1776
  gasCosts,
@@ -1672,6 +1792,10 @@ function calculateMetadataGasForTxScript({
1672
1792
  }) {
1673
1793
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1674
1794
  }
1795
+ var calculateGasFee = (params) => {
1796
+ const { gas, gasPrice, priceFactor, tip } = params;
1797
+ return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
1798
+ };
1675
1799
 
1676
1800
  // src/providers/utils/json.ts
1677
1801
  var import_utils7 = require("@fuel-ts/utils");
@@ -1717,16 +1841,16 @@ function sleep(time) {
1717
1841
  var import_errors7 = require("@fuel-ts/errors");
1718
1842
  var import_math6 = require("@fuel-ts/math");
1719
1843
  var import_transactions5 = require("@fuel-ts/transactions");
1720
- var import_configs6 = require("@fuel-ts/transactions/configs");
1844
+ var import_configs5 = require("@fuel-ts/transactions/configs");
1721
1845
  var assemblePanicError = (status) => {
1722
1846
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1723
1847
  const reason = status.reason;
1724
- if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1848
+ if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1725
1849
  errorMessage = `${errorMessage}
1726
1850
 
1727
1851
  You can read more about this error at:
1728
1852
 
1729
- ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1853
+ ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1730
1854
  }
1731
1855
  return { errorMessage, reason };
1732
1856
  };
@@ -1738,28 +1862,28 @@ var assembleRevertError = (receipts, logs) => {
1738
1862
  if (revertReceipt) {
1739
1863
  const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1740
1864
  switch (reasonHex) {
1741
- case import_configs6.FAILED_REQUIRE_SIGNAL: {
1865
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
1742
1866
  reason = "require";
1743
1867
  errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1744
1868
  break;
1745
1869
  }
1746
- case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1870
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
1747
1871
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1748
1872
  reason = "assert_eq";
1749
1873
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1750
1874
  break;
1751
1875
  }
1752
- case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1876
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
1753
1877
  const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1754
1878
  reason = "assert_ne";
1755
1879
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1756
1880
  break;
1757
1881
  }
1758
- case import_configs6.FAILED_ASSERT_SIGNAL:
1882
+ case import_configs5.FAILED_ASSERT_SIGNAL:
1759
1883
  reason = "assert";
1760
1884
  errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1761
1885
  break;
1762
- case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1886
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1763
1887
  reason = "MissingOutputChange";
1764
1888
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1765
1889
  break;
@@ -1820,7 +1944,7 @@ var witnessify = (value) => {
1820
1944
  // src/providers/transaction-request/transaction-request.ts
1821
1945
  var BaseTransactionRequest = class {
1822
1946
  /** Gas price for transaction */
1823
- gasPrice;
1947
+ tip;
1824
1948
  /** Block until which tx cannot be included */
1825
1949
  maturity;
1826
1950
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1839,7 +1963,7 @@ var BaseTransactionRequest = class {
1839
1963
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1840
1964
  */
1841
1965
  constructor({
1842
- gasPrice,
1966
+ tip,
1843
1967
  maturity,
1844
1968
  maxFee,
1845
1969
  witnessLimit,
@@ -1847,10 +1971,10 @@ var BaseTransactionRequest = class {
1847
1971
  outputs,
1848
1972
  witnesses
1849
1973
  } = {}) {
1850
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1851
- this.maturity = maturity ?? 0;
1852
- this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1853
- this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1974
+ this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
1975
+ this.maturity = maturity && maturity > 0 ? maturity : void 0;
1976
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
1977
+ this.maxFee = (0, import_math7.bn)(maxFee);
1854
1978
  this.inputs = inputs ?? [];
1855
1979
  this.outputs = outputs ?? [];
1856
1980
  this.witnesses = witnesses ?? [];
@@ -1858,22 +1982,21 @@ var BaseTransactionRequest = class {
1858
1982
  static getPolicyMeta(req) {
1859
1983
  let policyTypes = 0;
1860
1984
  const policies = [];
1861
- if (req.gasPrice) {
1862
- policyTypes += import_transactions6.PolicyType.GasPrice;
1863
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1985
+ const { tip, witnessLimit, maturity } = req;
1986
+ if ((0, import_math7.bn)(tip).gt(0)) {
1987
+ policyTypes += import_transactions6.PolicyType.Tip;
1988
+ policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
1864
1989
  }
1865
- if (req.witnessLimit) {
1990
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
1866
1991
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
1867
- policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1992
+ policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
1868
1993
  }
1869
- if (req.maturity > 0) {
1994
+ if (maturity && maturity > 0) {
1870
1995
  policyTypes += import_transactions6.PolicyType.Maturity;
1871
- policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1872
- }
1873
- if (req.maxFee) {
1874
- policyTypes += import_transactions6.PolicyType.MaxFee;
1875
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1996
+ policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
1876
1997
  }
1998
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1999
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1877
2000
  return {
1878
2001
  policyTypes,
1879
2002
  policies
@@ -1946,7 +2069,7 @@ var BaseTransactionRequest = class {
1946
2069
  * @returns The index of the created witness.
1947
2070
  */
1948
2071
  addEmptyWitness() {
1949
- this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
2072
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1950
2073
  return this.witnesses.length - 1;
1951
2074
  }
1952
2075
  /**
@@ -2044,13 +2167,11 @@ var BaseTransactionRequest = class {
2044
2167
  * assetId, if one it was not added yet.
2045
2168
  *
2046
2169
  * @param coin - Coin resource.
2047
- * @param predicate - Predicate bytes.
2048
- * @param predicateData - Predicate data bytes.
2049
2170
  */
2050
- addCoinInput(coin, predicate) {
2171
+ addCoinInput(coin) {
2051
2172
  const { assetId, owner, amount } = coin;
2052
2173
  let witnessIndex;
2053
- if (predicate) {
2174
+ if (coin.predicate) {
2054
2175
  witnessIndex = 0;
2055
2176
  } else {
2056
2177
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2065,25 +2186,21 @@ var BaseTransactionRequest = class {
2065
2186
  amount,
2066
2187
  assetId,
2067
2188
  txPointer: "0x00000000000000000000000000000000",
2068
- witnessIndex,
2069
- predicate: predicate?.bytes
2189
+ witnessIndex
2070
2190
  };
2071
2191
  this.pushInput(input);
2072
2192
  this.addChangeOutput(owner, assetId);
2073
2193
  }
2074
2194
  /**
2075
2195
  * Adds a single message input to the transaction and a change output for the
2076
- * baseAssetId, if one it was not added yet.
2196
+ * asset against the message
2077
2197
  *
2078
2198
  * @param message - Message resource.
2079
- * @param predicate - Predicate bytes.
2080
- * @param predicateData - Predicate data bytes.
2081
2199
  */
2082
- addMessageInput(message, predicate) {
2083
- const { recipient, sender, amount } = message;
2084
- const assetId = import_configs7.BaseAssetId;
2200
+ addMessageInput(message) {
2201
+ const { recipient, sender, amount, assetId } = message;
2085
2202
  let witnessIndex;
2086
- if (predicate) {
2203
+ if (message.predicate) {
2087
2204
  witnessIndex = 0;
2088
2205
  } else {
2089
2206
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2097,8 +2214,7 @@ var BaseTransactionRequest = class {
2097
2214
  sender: sender.toB256(),
2098
2215
  recipient: recipient.toB256(),
2099
2216
  amount,
2100
- witnessIndex,
2101
- predicate: predicate?.bytes
2217
+ witnessIndex
2102
2218
  };
2103
2219
  this.pushInput(input);
2104
2220
  this.addChangeOutput(recipient, assetId);
@@ -2129,32 +2245,6 @@ var BaseTransactionRequest = class {
2129
2245
  resources.forEach((resource) => this.addResource(resource));
2130
2246
  return this;
2131
2247
  }
2132
- /**
2133
- * Adds multiple resources to the transaction by adding coin/message inputs and change
2134
- * outputs from the related assetIds.
2135
- *
2136
- * @param resources - The resources to add.
2137
- * @returns This transaction.
2138
- */
2139
- addPredicateResource(resource, predicate) {
2140
- if (isCoin(resource)) {
2141
- this.addCoinInput(resource, predicate);
2142
- } else {
2143
- this.addMessageInput(resource, predicate);
2144
- }
2145
- return this;
2146
- }
2147
- /**
2148
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
2149
- * from the related assetIds.
2150
- *
2151
- * @param resources - The resources to add.
2152
- * @returns This transaction.
2153
- */
2154
- addPredicateResources(resources, predicate) {
2155
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2156
- return this;
2157
- }
2158
2248
  /**
2159
2249
  * Adds a coin output to the transaction.
2160
2250
  *
@@ -2162,7 +2252,7 @@ var BaseTransactionRequest = class {
2162
2252
  * @param amount - Amount of coin.
2163
2253
  * @param assetId - Asset ID of coin.
2164
2254
  */
2165
- addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2255
+ addCoinOutput(to, amount, assetId) {
2166
2256
  this.pushOutput({
2167
2257
  type: import_transactions6.OutputType.Coin,
2168
2258
  to: (0, import_address.addressify)(to).toB256(),
@@ -2194,7 +2284,7 @@ var BaseTransactionRequest = class {
2194
2284
  * @param to - Address of the owner.
2195
2285
  * @param assetId - Asset ID of coin.
2196
2286
  */
2197
- addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2287
+ addChangeOutput(to, assetId) {
2198
2288
  const changeOutput = this.getChangeOutputs().find(
2199
2289
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2200
2290
  );
@@ -2222,8 +2312,11 @@ var BaseTransactionRequest = class {
2222
2312
  * @hidden
2223
2313
  */
2224
2314
  calculateMinGas(chainInfo) {
2225
- const { gasCosts, consensusParameters } = chainInfo;
2226
- const { gasPerByte } = consensusParameters;
2315
+ const { consensusParameters } = chainInfo;
2316
+ const {
2317
+ gasCosts,
2318
+ feeParameters: { gasPerByte }
2319
+ } = consensusParameters;
2227
2320
  return getMinGas({
2228
2321
  gasPerByte,
2229
2322
  gasCosts,
@@ -2234,7 +2327,10 @@ var BaseTransactionRequest = class {
2234
2327
  }
2235
2328
  calculateMaxGas(chainInfo, minGas) {
2236
2329
  const { consensusParameters } = chainInfo;
2237
- const { gasPerByte } = consensusParameters;
2330
+ const {
2331
+ feeParameters: { gasPerByte },
2332
+ txParameters: { maxGasPerTx }
2333
+ } = consensusParameters;
2238
2334
  const witnessesLength = this.toTransaction().witnesses.reduce(
2239
2335
  (acc, wit) => acc + wit.dataLength,
2240
2336
  0
@@ -2243,7 +2339,8 @@ var BaseTransactionRequest = class {
2243
2339
  gasPerByte,
2244
2340
  minGas,
2245
2341
  witnessesLength,
2246
- witnessLimit: this.witnessLimit
2342
+ witnessLimit: this.witnessLimit,
2343
+ maxGasPerTx
2247
2344
  });
2248
2345
  }
2249
2346
  /**
@@ -2251,8 +2348,9 @@ var BaseTransactionRequest = class {
2251
2348
  * quantities array.
2252
2349
  *
2253
2350
  * @param quantities - CoinQuantity Array.
2351
+ * @param baseAssetId - The base asset to fund the transaction.
2254
2352
  */
2255
- fundWithFakeUtxos(quantities, resourcesOwner) {
2353
+ fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
2256
2354
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2257
2355
  if ("assetId" in input) {
2258
2356
  return input.assetId === assetId;
@@ -2261,24 +2359,27 @@ var BaseTransactionRequest = class {
2261
2359
  });
2262
2360
  const updateAssetInput = (assetId, quantity) => {
2263
2361
  const assetInput = findAssetInput(assetId);
2362
+ let usedQuantity = quantity;
2363
+ if (assetId === baseAssetId) {
2364
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2365
+ }
2264
2366
  if (assetInput && "assetId" in assetInput) {
2265
2367
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2266
- assetInput.amount = quantity;
2368
+ assetInput.amount = usedQuantity;
2267
2369
  } else {
2268
2370
  this.addResources([
2269
2371
  {
2270
2372
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2271
- amount: quantity,
2373
+ amount: usedQuantity,
2272
2374
  assetId,
2273
2375
  owner: resourcesOwner || import_address.Address.fromRandom(),
2274
- maturity: 0,
2275
2376
  blockCreated: (0, import_math7.bn)(1),
2276
2377
  txCreatedIdx: (0, import_math7.bn)(1)
2277
2378
  }
2278
2379
  ]);
2279
2380
  }
2280
2381
  };
2281
- updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2382
+ updateAssetInput(baseAssetId, (0, import_math7.bn)(1e11));
2282
2383
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2283
2384
  }
2284
2385
  /**
@@ -2303,7 +2404,7 @@ var BaseTransactionRequest = class {
2303
2404
  toJSON() {
2304
2405
  return normalizeJSON(this);
2305
2406
  }
2306
- updatePredicateInputs(inputs) {
2407
+ updatePredicateGasUsed(inputs) {
2307
2408
  this.inputs.forEach((i) => {
2308
2409
  let correspondingInput;
2309
2410
  switch (i.type) {
@@ -2325,16 +2426,25 @@ var BaseTransactionRequest = class {
2325
2426
  }
2326
2427
  });
2327
2428
  }
2429
+ shiftPredicateData() {
2430
+ this.inputs.forEach((input) => {
2431
+ if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2432
+ input.predicateData = input.padPredicateData(
2433
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2434
+ );
2435
+ }
2436
+ });
2437
+ }
2328
2438
  };
2329
2439
 
2330
2440
  // src/providers/transaction-request/create-transaction-request.ts
2331
- var import_configs9 = require("@fuel-ts/address/configs");
2441
+ var import_configs8 = require("@fuel-ts/address/configs");
2332
2442
  var import_math9 = require("@fuel-ts/math");
2333
2443
  var import_transactions8 = require("@fuel-ts/transactions");
2334
2444
  var import_utils13 = require("@fuel-ts/utils");
2335
2445
 
2336
2446
  // src/providers/transaction-request/hash-transaction.ts
2337
- var import_configs8 = require("@fuel-ts/address/configs");
2447
+ var import_configs7 = require("@fuel-ts/address/configs");
2338
2448
  var import_hasher = require("@fuel-ts/hasher");
2339
2449
  var import_math8 = require("@fuel-ts/math");
2340
2450
  var import_transactions7 = require("@fuel-ts/transactions");
@@ -2343,7 +2453,7 @@ var import_ramda2 = require("ramda");
2343
2453
  function hashTransaction(transactionRequest, chainId) {
2344
2454
  const transaction = transactionRequest.toTransaction();
2345
2455
  if (transaction.type === import_transactions7.TransactionType.Script) {
2346
- transaction.receiptsRoot = import_configs8.ZeroBytes32;
2456
+ transaction.receiptsRoot = import_configs7.ZeroBytes32;
2347
2457
  }
2348
2458
  transaction.inputs = transaction.inputs.map((input) => {
2349
2459
  const inputClone = (0, import_ramda2.clone)(input);
@@ -2365,10 +2475,10 @@ function hashTransaction(transactionRequest, chainId) {
2365
2475
  blockHeight: 0,
2366
2476
  txIndex: 0
2367
2477
  };
2368
- inputClone.txID = import_configs8.ZeroBytes32;
2478
+ inputClone.txID = import_configs7.ZeroBytes32;
2369
2479
  inputClone.outputIndex = 0;
2370
- inputClone.balanceRoot = import_configs8.ZeroBytes32;
2371
- inputClone.stateRoot = import_configs8.ZeroBytes32;
2480
+ inputClone.balanceRoot = import_configs7.ZeroBytes32;
2481
+ inputClone.stateRoot = import_configs7.ZeroBytes32;
2372
2482
  return inputClone;
2373
2483
  }
2374
2484
  default:
@@ -2379,8 +2489,8 @@ function hashTransaction(transactionRequest, chainId) {
2379
2489
  const outputClone = (0, import_ramda2.clone)(output);
2380
2490
  switch (outputClone.type) {
2381
2491
  case import_transactions7.OutputType.Contract: {
2382
- outputClone.balanceRoot = import_configs8.ZeroBytes32;
2383
- outputClone.stateRoot = import_configs8.ZeroBytes32;
2492
+ outputClone.balanceRoot = import_configs7.ZeroBytes32;
2493
+ outputClone.stateRoot = import_configs7.ZeroBytes32;
2384
2494
  return outputClone;
2385
2495
  }
2386
2496
  case import_transactions7.OutputType.Change: {
@@ -2388,9 +2498,9 @@ function hashTransaction(transactionRequest, chainId) {
2388
2498
  return outputClone;
2389
2499
  }
2390
2500
  case import_transactions7.OutputType.Variable: {
2391
- outputClone.to = import_configs8.ZeroBytes32;
2501
+ outputClone.to = import_configs7.ZeroBytes32;
2392
2502
  outputClone.amount = (0, import_math8.bn)(0);
2393
- outputClone.assetId = import_configs8.ZeroBytes32;
2503
+ outputClone.assetId = import_configs7.ZeroBytes32;
2394
2504
  return outputClone;
2395
2505
  }
2396
2506
  default:
@@ -2448,15 +2558,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2448
2558
  *
2449
2559
  * @param createTransactionRequestLike - The initial values for the instance
2450
2560
  */
2451
- constructor({
2452
- bytecodeWitnessIndex,
2453
- salt,
2454
- storageSlots,
2455
- ...rest
2456
- } = {}) {
2561
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2457
2562
  super(rest);
2458
2563
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2459
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2564
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2460
2565
  this.storageSlots = [...storageSlots ?? []];
2461
2566
  }
2462
2567
  /**
@@ -2471,10 +2576,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2471
2576
  return {
2472
2577
  type: import_transactions8.TransactionType.Create,
2473
2578
  ...baseTransaction,
2474
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2475
2579
  bytecodeWitnessIndex,
2476
- storageSlotsCount: storageSlots.length,
2477
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2580
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2581
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2478
2582
  storageSlots
2479
2583
  };
2480
2584
  }
@@ -2524,7 +2628,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2524
2628
  // src/providers/transaction-request/script-transaction-request.ts
2525
2629
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2526
2630
  var import_address2 = require("@fuel-ts/address");
2527
- var import_configs10 = require("@fuel-ts/address/configs");
2631
+ var import_configs9 = require("@fuel-ts/address/configs");
2528
2632
  var import_math10 = require("@fuel-ts/math");
2529
2633
  var import_transactions9 = require("@fuel-ts/transactions");
2530
2634
  var import_utils15 = require("@fuel-ts/utils");
@@ -2596,9 +2700,9 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2596
2700
  type: import_transactions9.TransactionType.Script,
2597
2701
  scriptGasLimit: this.gasLimit,
2598
2702
  ...super.getBaseTransaction(),
2599
- scriptLength: script.length,
2600
- scriptDataLength: scriptData.length,
2601
- receiptsRoot: import_configs10.ZeroBytes32,
2703
+ scriptLength: (0, import_math10.bn)(script.length),
2704
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2705
+ receiptsRoot: import_configs9.ZeroBytes32,
2602
2706
  script: (0, import_utils15.hexlify)(script),
2603
2707
  scriptData: (0, import_utils15.hexlify)(scriptData)
2604
2708
  };
@@ -2661,7 +2765,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2661
2765
  }
2662
2766
  calculateMaxGas(chainInfo, minGas) {
2663
2767
  const { consensusParameters } = chainInfo;
2664
- const { gasPerByte } = consensusParameters;
2768
+ const {
2769
+ feeParameters: { gasPerByte },
2770
+ txParameters: { maxGasPerTx }
2771
+ } = consensusParameters;
2665
2772
  const witnessesLength = this.toTransaction().witnesses.reduce(
2666
2773
  (acc, wit) => acc + wit.dataLength,
2667
2774
  0
@@ -2671,7 +2778,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2671
2778
  minGas,
2672
2779
  witnessesLength,
2673
2780
  witnessLimit: this.witnessLimit,
2674
- gasLimit: this.gasLimit
2781
+ gasLimit: this.gasLimit,
2782
+ maxGasPerTx
2675
2783
  });
2676
2784
  }
2677
2785
  /**
@@ -2746,41 +2854,58 @@ var transactionRequestify = (obj) => {
2746
2854
  }
2747
2855
  }
2748
2856
  };
2857
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2858
+ (acc, input) => {
2859
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2860
+ acc.utxos.push(input.id);
2861
+ }
2862
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2863
+ acc.messages.push(input.nonce);
2864
+ }
2865
+ return acc;
2866
+ },
2867
+ {
2868
+ utxos: [],
2869
+ messages: []
2870
+ }
2871
+ );
2749
2872
 
2750
2873
  // src/providers/transaction-response/transaction-response.ts
2751
2874
  var import_errors13 = require("@fuel-ts/errors");
2752
- var import_math14 = require("@fuel-ts/math");
2753
- var import_transactions17 = require("@fuel-ts/transactions");
2754
- var import_utils21 = require("@fuel-ts/utils");
2875
+ var import_math16 = require("@fuel-ts/math");
2876
+ var import_transactions18 = require("@fuel-ts/transactions");
2877
+ var import_utils20 = require("@fuel-ts/utils");
2755
2878
 
2756
2879
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2757
- var import_utils19 = require("@fuel-ts/utils");
2880
+ var import_math15 = require("@fuel-ts/math");
2881
+ var import_transactions16 = require("@fuel-ts/transactions");
2882
+ var import_utils18 = require("@fuel-ts/utils");
2758
2883
 
2759
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2884
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2760
2885
  var import_math11 = require("@fuel-ts/math");
2761
2886
  var import_transactions11 = require("@fuel-ts/transactions");
2762
2887
  var import_utils16 = require("@fuel-ts/utils");
2763
- var calculateTransactionFee = (params) => {
2888
+ var calculateTXFeeForSummary = (params) => {
2764
2889
  const {
2765
- gasUsed,
2890
+ gasPrice,
2766
2891
  rawPayload,
2767
- consensusParameters: { gasCosts, feeParams }
2892
+ tip,
2893
+ totalFee,
2894
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2768
2895
  } = params;
2896
+ if (totalFee) {
2897
+ return totalFee;
2898
+ }
2769
2899
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2770
2900
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2771
2901
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2772
2902
  const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2773
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2774
- return {
2775
- fee: (0, import_math11.bn)(0),
2776
- minFee: (0, import_math11.bn)(0),
2777
- maxFee: (0, import_math11.bn)(0),
2778
- feeFromGasUsed: (0, import_math11.bn)(0)
2779
- };
2780
- }
2781
2903
  const { type, witnesses, inputs, policies } = transaction;
2782
2904
  let metadataGas = (0, import_math11.bn)(0);
2783
2905
  let gasLimit = (0, import_math11.bn)(0);
2906
+ if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2907
+ return (0, import_math11.bn)(0);
2908
+ }
2784
2909
  if (type === import_transactions11.TransactionType.Create) {
2785
2910
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2786
2911
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
@@ -2807,7 +2932,6 @@ var calculateTransactionFee = (params) => {
2807
2932
  metadataGas,
2808
2933
  txBytesSize: transactionBytes.length
2809
2934
  });
2810
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2811
2935
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2812
2936
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2813
2937
  const maxGas = getMaxGas({
@@ -2815,22 +2939,20 @@ var calculateTransactionFee = (params) => {
2815
2939
  minGas,
2816
2940
  witnessesLength,
2817
2941
  gasLimit,
2818
- witnessLimit
2942
+ witnessLimit,
2943
+ maxGasPerTx
2819
2944
  });
2820
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2821
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2822
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2823
- const fee = minFee.add(feeFromGasUsed);
2824
- return {
2825
- fee,
2826
- minFee,
2827
- maxFee,
2828
- feeFromGasUsed
2829
- };
2945
+ const maxFee = calculateGasFee({
2946
+ gasPrice,
2947
+ gas: maxGas,
2948
+ priceFactor: gasPriceFactor,
2949
+ tip
2950
+ });
2951
+ return maxFee;
2830
2952
  };
2831
2953
 
2832
2954
  // src/providers/transaction-summary/operations.ts
2833
- var import_configs11 = require("@fuel-ts/address/configs");
2955
+ var import_configs10 = require("@fuel-ts/address/configs");
2834
2956
  var import_errors11 = require("@fuel-ts/errors");
2835
2957
  var import_math13 = require("@fuel-ts/math");
2836
2958
  var import_transactions14 = require("@fuel-ts/transactions");
@@ -2961,6 +3083,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
2961
3083
  TransactionTypeName2["Create"] = "Create";
2962
3084
  TransactionTypeName2["Mint"] = "Mint";
2963
3085
  TransactionTypeName2["Script"] = "Script";
3086
+ TransactionTypeName2["Upgrade"] = "Upgrade";
3087
+ TransactionTypeName2["Upload"] = "Upload";
2964
3088
  return TransactionTypeName2;
2965
3089
  })(TransactionTypeName || {});
2966
3090
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
@@ -3026,6 +3150,12 @@ function isTypeCreate(transactionType) {
3026
3150
  function isTypeScript(transactionType) {
3027
3151
  return isType(transactionType, "Script" /* Script */);
3028
3152
  }
3153
+ function isTypeUpgrade(transactionType) {
3154
+ return isType(transactionType, "Upgrade" /* Upgrade */);
3155
+ }
3156
+ function isTypeUpload(transactionType) {
3157
+ return isType(transactionType, "Upload" /* Upload */);
3158
+ }
3029
3159
  function hasSameAssetId(a) {
3030
3160
  return (b) => a.assetId === b.assetId;
3031
3161
  }
@@ -3175,7 +3305,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3175
3305
  const { to: toAddress, assetId, amount } = receipt;
3176
3306
  let { from: fromAddress } = receipt;
3177
3307
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3178
- if (import_configs11.ZeroBytes32 === fromAddress) {
3308
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3179
3309
  const change = changeOutputs.find((output) => output.assetId === assetId);
3180
3310
  fromAddress = change?.to || fromAddress;
3181
3311
  }
@@ -3372,6 +3502,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3372
3502
 
3373
3503
  // src/providers/transaction-summary/status.ts
3374
3504
  var import_errors12 = require("@fuel-ts/errors");
3505
+ var import_math14 = require("@fuel-ts/math");
3375
3506
  var getTransactionStatusName = (gqlStatus) => {
3376
3507
  switch (gqlStatus) {
3377
3508
  case "FailureStatus":
@@ -3393,6 +3524,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3393
3524
  let time;
3394
3525
  let blockId;
3395
3526
  let status;
3527
+ let totalFee;
3528
+ let totalGas;
3396
3529
  let isStatusFailure = false;
3397
3530
  let isStatusSuccess = false;
3398
3531
  let isStatusPending = false;
@@ -3403,11 +3536,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3403
3536
  time = gqlTransactionStatus.time;
3404
3537
  blockId = gqlTransactionStatus.block.id;
3405
3538
  isStatusSuccess = true;
3539
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3540
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3406
3541
  break;
3407
3542
  case "FailureStatus":
3408
3543
  time = gqlTransactionStatus.time;
3409
3544
  blockId = gqlTransactionStatus.block.id;
3410
3545
  isStatusFailure = true;
3546
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3547
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3411
3548
  break;
3412
3549
  case "SubmittedStatus":
3413
3550
  time = gqlTransactionStatus.time;
@@ -3420,6 +3557,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3420
3557
  time,
3421
3558
  blockId,
3422
3559
  status,
3560
+ totalFee,
3561
+ totalGas,
3423
3562
  isStatusFailure,
3424
3563
  isStatusSuccess,
3425
3564
  isStatusPending
@@ -3439,10 +3578,12 @@ function assembleTransactionSummary(params) {
3439
3578
  gqlTransactionStatus,
3440
3579
  abiMap = {},
3441
3580
  maxInputs,
3442
- gasCosts
3581
+ gasCosts,
3582
+ maxGasPerTx,
3583
+ gasPrice
3443
3584
  } = params;
3444
3585
  const gasUsed = getGasUsedFromReceipts(receipts);
3445
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3586
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3446
3587
  const operations = getOperations({
3447
3588
  transactionType: transaction.type,
3448
3589
  inputs: transaction.inputs || [],
@@ -3453,26 +3594,31 @@ function assembleTransactionSummary(params) {
3453
3594
  maxInputs
3454
3595
  });
3455
3596
  const typeName = getTransactionTypeName(transaction.type);
3456
- const { fee } = calculateTransactionFee({
3457
- gasUsed,
3597
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3598
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3599
+ const fee = calculateTXFeeForSummary({
3600
+ totalFee,
3601
+ gasPrice,
3458
3602
  rawPayload,
3603
+ tip,
3459
3604
  consensusParameters: {
3460
3605
  gasCosts,
3606
+ maxGasPerTx,
3461
3607
  feeParams: {
3462
3608
  gasPerByte,
3463
3609
  gasPriceFactor
3464
3610
  }
3465
3611
  }
3466
3612
  });
3467
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3468
3613
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3469
3614
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3470
3615
  let date;
3471
3616
  if (time) {
3472
- date = import_utils19.DateTime.fromTai64(time);
3617
+ date = import_utils18.DateTime.fromTai64(time);
3473
3618
  }
3474
3619
  const transactionSummary = {
3475
3620
  id,
3621
+ tip,
3476
3622
  fee,
3477
3623
  gasUsed,
3478
3624
  operations,
@@ -3486,6 +3632,8 @@ function assembleTransactionSummary(params) {
3486
3632
  isTypeMint: isTypeMint(transaction.type),
3487
3633
  isTypeCreate: isTypeCreate(transaction.type),
3488
3634
  isTypeScript: isTypeScript(transaction.type),
3635
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3636
+ isTypeUpload: isTypeUpload(transaction.type),
3489
3637
  isStatusFailure,
3490
3638
  isStatusSuccess,
3491
3639
  isStatusPending,
@@ -3497,12 +3645,12 @@ function assembleTransactionSummary(params) {
3497
3645
 
3498
3646
  // src/providers/transaction-response/getDecodedLogs.ts
3499
3647
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3500
- var import_transactions16 = require("@fuel-ts/transactions");
3648
+ var import_transactions17 = require("@fuel-ts/transactions");
3501
3649
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3502
3650
  return receipts.reduce((logs, receipt) => {
3503
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3651
+ if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3504
3652
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3505
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3653
+ const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3506
3654
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3507
3655
  logs.push(decodedLog);
3508
3656
  }
@@ -3517,7 +3665,7 @@ var TransactionResponse = class {
3517
3665
  /** Current provider */
3518
3666
  provider;
3519
3667
  /** Gas used on the transaction */
3520
- gasUsed = (0, import_math14.bn)(0);
3668
+ gasUsed = (0, import_math16.bn)(0);
3521
3669
  /** The graphql Transaction with receipts object. */
3522
3670
  gqlTransaction;
3523
3671
  abis;
@@ -3575,8 +3723,8 @@ var TransactionResponse = class {
3575
3723
  * @returns The decoded transaction.
3576
3724
  */
3577
3725
  decodeTransaction(transactionWithReceipts) {
3578
- return new import_transactions17.TransactionCoder().decode(
3579
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3726
+ return new import_transactions18.TransactionCoder().decode(
3727
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3580
3728
  0
3581
3729
  )?.[0];
3582
3730
  }
@@ -3595,20 +3743,27 @@ var TransactionResponse = class {
3595
3743
  const decodedTransaction = this.decodeTransaction(
3596
3744
  transaction
3597
3745
  );
3598
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3599
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3600
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3746
+ let txReceipts = [];
3747
+ if (transaction?.status && "receipts" in transaction.status) {
3748
+ txReceipts = transaction.status.receipts;
3749
+ }
3750
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3751
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3752
+ const gasPrice = await this.provider.getLatestGasPrice();
3753
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3601
3754
  const transactionSummary = assembleTransactionSummary({
3602
3755
  id: this.id,
3603
3756
  receipts,
3604
3757
  transaction: decodedTransaction,
3605
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3758
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3606
3759
  gqlTransactionStatus: transaction.status,
3607
3760
  gasPerByte,
3608
3761
  gasPriceFactor,
3609
3762
  abiMap: contractsAbiMap,
3610
3763
  maxInputs,
3611
- gasCosts
3764
+ gasCosts,
3765
+ maxGasPerTx,
3766
+ gasPrice
3612
3767
  });
3613
3768
  return transactionSummary;
3614
3769
  }
@@ -3714,7 +3869,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3714
3869
  }
3715
3870
 
3716
3871
  // src/providers/utils/merge-quantities.ts
3717
- var mergeQuantities = (arr1, arr2) => {
3872
+ var mergeQuantities = (...coinQuantities) => {
3718
3873
  const resultMap = {};
3719
3874
  function addToMap({ amount, assetId }) {
3720
3875
  if (resultMap[assetId]) {
@@ -3723,8 +3878,7 @@ var mergeQuantities = (arr1, arr2) => {
3723
3878
  resultMap[assetId] = amount;
3724
3879
  }
3725
3880
  }
3726
- arr1.forEach(addToMap);
3727
- arr2.forEach(addToMap);
3881
+ coinQuantities.forEach((arr) => arr.forEach(addToMap));
3728
3882
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
3729
3883
  };
3730
3884
 
@@ -3732,32 +3886,60 @@ var mergeQuantities = (arr1, arr2) => {
3732
3886
  var MAX_RETRIES = 10;
3733
3887
  var processGqlChain = (chain) => {
3734
3888
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3735
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3889
+ const {
3890
+ contractParams,
3891
+ feeParams,
3892
+ predicateParams,
3893
+ scriptParams,
3894
+ txParams,
3895
+ gasCosts,
3896
+ baseAssetId,
3897
+ chainId,
3898
+ version
3899
+ } = consensusParameters;
3736
3900
  return {
3737
3901
  name,
3738
- baseChainHeight: (0, import_math15.bn)(daHeight),
3902
+ baseChainHeight: (0, import_math17.bn)(daHeight),
3739
3903
  consensusParameters: {
3740
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3741
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3742
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3743
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3744
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3745
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3746
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3747
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3748
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3749
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3750
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3751
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3752
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3753
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3754
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3904
+ version,
3905
+ chainId: (0, import_math17.bn)(chainId),
3906
+ baseAssetId,
3907
+ feeParameters: {
3908
+ version: feeParams.version,
3909
+ gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3910
+ gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3911
+ },
3912
+ contractParameters: {
3913
+ version: contractParams.version,
3914
+ contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3915
+ maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3916
+ },
3917
+ txParameters: {
3918
+ version: txParams.version,
3919
+ maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3920
+ maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3921
+ maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3922
+ maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3923
+ maxSize: (0, import_math17.bn)(txParams.maxSize),
3924
+ maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3925
+ },
3926
+ predicateParameters: {
3927
+ version: predicateParams.version,
3928
+ maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3929
+ maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3930
+ maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3931
+ maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3932
+ },
3933
+ scriptParameters: {
3934
+ version: scriptParams.version,
3935
+ maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3936
+ maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3937
+ },
3755
3938
  gasCosts
3756
3939
  },
3757
- gasCosts,
3758
3940
  latestBlock: {
3759
3941
  id: latestBlock.id,
3760
- height: (0, import_math15.bn)(latestBlock.header.height),
3942
+ height: (0, import_math17.bn)(latestBlock.height),
3761
3943
  time: latestBlock.header.time,
3762
3944
  transactions: latestBlock.transactions.map((i) => ({
3763
3945
  id: i.id
@@ -3851,10 +4033,13 @@ var _Provider = class {
3851
4033
  * Returns some helpful parameters related to gas fees.
3852
4034
  */
3853
4035
  getGasConfig() {
3854
- const { minGasPrice } = this.getNode();
3855
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
4036
+ const {
4037
+ txParameters: { maxGasPerTx },
4038
+ predicateParameters: { maxGasPerPredicate },
4039
+ feeParameters: { gasPriceFactor, gasPerByte },
4040
+ gasCosts
4041
+ } = this.getChain().consensusParameters;
3856
4042
  return {
3857
- minGasPrice,
3858
4043
  maxGasPerTx,
3859
4044
  maxGasPerPredicate,
3860
4045
  gasPriceFactor,
@@ -3902,7 +4087,18 @@ var _Provider = class {
3902
4087
  createOperations() {
3903
4088
  const fetchFn = _Provider.getFetchFn(this.options);
3904
4089
  const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
3905
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
4090
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4091
+ responseMiddleware: (response) => {
4092
+ if ("response" in response) {
4093
+ const graphQlResponse = response.response;
4094
+ if (Array.isArray(graphQlResponse?.errors)) {
4095
+ throw new import_errors14.FuelError(
4096
+ import_errors14.FuelError.CODES.INVALID_REQUEST,
4097
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
4098
+ );
4099
+ }
4100
+ }
4101
+ }
3906
4102
  });
3907
4103
  const executeQuery = (query, vars) => {
3908
4104
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -3930,21 +4126,6 @@ var _Provider = class {
3930
4126
  } = await this.operations.getVersion();
3931
4127
  return nodeVersion;
3932
4128
  }
3933
- /**
3934
- * @hidden
3935
- *
3936
- * Returns the network configuration of the connected Fuel node.
3937
- *
3938
- * @returns A promise that resolves to the network configuration object
3939
- */
3940
- async getNetwork() {
3941
- const {
3942
- name,
3943
- consensusParameters: { chainId }
3944
- } = await this.getChain();
3945
- const network = new import_ethers.Network(name, chainId.toNumber());
3946
- return Promise.resolve(network);
3947
- }
3948
4129
  /**
3949
4130
  * Returns the block number.
3950
4131
  *
@@ -3952,7 +4133,7 @@ var _Provider = class {
3952
4133
  */
3953
4134
  async getBlockNumber() {
3954
4135
  const { chain } = await this.operations.getChain();
3955
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4136
+ return (0, import_math17.bn)(chain.latestBlock.height, 10);
3956
4137
  }
3957
4138
  /**
3958
4139
  * Returns the chain information.
@@ -3962,13 +4143,11 @@ var _Provider = class {
3962
4143
  async fetchNode() {
3963
4144
  const { nodeInfo } = await this.operations.getNodeInfo();
3964
4145
  const processedNodeInfo = {
3965
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3966
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3967
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4146
+ maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
4147
+ maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
3968
4148
  nodeVersion: nodeInfo.nodeVersion,
3969
4149
  utxoValidation: nodeInfo.utxoValidation,
3970
- vmBacktrace: nodeInfo.vmBacktrace,
3971
- peers: nodeInfo.peers
4150
+ vmBacktrace: nodeInfo.vmBacktrace
3972
4151
  };
3973
4152
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3974
4153
  return processedNodeInfo;
@@ -3994,6 +4173,17 @@ var _Provider = class {
3994
4173
  } = this.getChain();
3995
4174
  return chainId.toNumber();
3996
4175
  }
4176
+ /**
4177
+ * Returns the base asset ID for the current provider network
4178
+ *
4179
+ * @returns the base asset ID
4180
+ */
4181
+ getBaseAssetId() {
4182
+ const {
4183
+ consensusParameters: { baseAssetId }
4184
+ } = this.getChain();
4185
+ return baseAssetId;
4186
+ }
3997
4187
  /**
3998
4188
  * Submits a transaction to the chain to be executed.
3999
4189
  *
@@ -4010,9 +4200,9 @@ var _Provider = class {
4010
4200
  if (estimateTxDependencies) {
4011
4201
  await this.estimateTxDependencies(transactionRequest);
4012
4202
  }
4013
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4203
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4014
4204
  let abis;
4015
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4205
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4016
4206
  abis = transactionRequest.abis;
4017
4207
  }
4018
4208
  if (awaitExecution) {
@@ -4053,15 +4243,14 @@ var _Provider = class {
4053
4243
  if (estimateTxDependencies) {
4054
4244
  return this.estimateTxDependencies(transactionRequest);
4055
4245
  }
4056
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4057
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4058
- encodedTransaction,
4246
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4247
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4248
+ encodedTransactions: encodedTransaction,
4059
4249
  utxoValidation: utxoValidation || false
4060
4250
  });
4061
- const receipts = gqlReceipts.map(processGqlReceipt);
4062
- return {
4063
- receipts
4064
- };
4251
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
4252
+ const receipts = rawReceipts.map(processGqlReceipt);
4253
+ return { receipts, dryRunStatus };
4065
4254
  }
4066
4255
  /**
4067
4256
  * Verifies whether enough gas is available to complete transaction.
@@ -4072,13 +4261,13 @@ var _Provider = class {
4072
4261
  async estimatePredicates(transactionRequest) {
4073
4262
  const shouldEstimatePredicates = Boolean(
4074
4263
  transactionRequest.inputs.find(
4075
- (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
4264
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
4076
4265
  )
4077
4266
  );
4078
4267
  if (!shouldEstimatePredicates) {
4079
4268
  return transactionRequest;
4080
4269
  }
4081
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4270
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4082
4271
  const response = await this.operations.estimatePredicates({
4083
4272
  encodedTransaction
4084
4273
  });
@@ -4087,7 +4276,7 @@ var _Provider = class {
4087
4276
  } = response;
4088
4277
  if (inputs) {
4089
4278
  inputs.forEach((input, index) => {
4090
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4279
+ if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
4091
4280
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4092
4281
  }
4093
4282
  });
@@ -4100,31 +4289,31 @@ var _Provider = class {
4100
4289
  * If there are missing variable outputs,
4101
4290
  * `addVariableOutputs` is called on the transaction.
4102
4291
  *
4103
- * @privateRemarks
4104
- * TODO: Investigate support for missing contract IDs
4105
- * TODO: Add support for missing output messages
4106
4292
  *
4107
4293
  * @param transactionRequest - The transaction request object.
4108
4294
  * @returns A promise.
4109
4295
  */
4110
4296
  async estimateTxDependencies(transactionRequest) {
4111
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4297
+ if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4112
4298
  return {
4113
4299
  receipts: [],
4114
4300
  outputVariables: 0,
4115
4301
  missingContractIds: []
4116
4302
  };
4117
4303
  }
4118
- await this.estimatePredicates(transactionRequest);
4119
4304
  let receipts = [];
4120
4305
  const missingContractIds = [];
4121
4306
  let outputVariables = 0;
4307
+ let dryRunStatus;
4122
4308
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4123
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4124
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4309
+ const {
4310
+ dryRun: [{ receipts: rawReceipts, status }]
4311
+ } = await this.operations.dryRun({
4312
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4125
4313
  utxoValidation: false
4126
4314
  });
4127
- receipts = gqlReceipts.map(processGqlReceipt);
4315
+ receipts = rawReceipts.map(processGqlReceipt);
4316
+ dryRunStatus = status;
4128
4317
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4129
4318
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4130
4319
  if (hasMissingOutputs) {
@@ -4134,6 +4323,10 @@ var _Provider = class {
4134
4323
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4135
4324
  missingContractIds.push(contractId);
4136
4325
  });
4326
+ const { maxFee } = await this.estimateTxGasAndFee({
4327
+ transactionRequest
4328
+ });
4329
+ transactionRequest.maxFee = maxFee;
4137
4330
  } else {
4138
4331
  break;
4139
4332
  }
@@ -4141,37 +4334,136 @@ var _Provider = class {
4141
4334
  return {
4142
4335
  receipts,
4143
4336
  outputVariables,
4144
- missingContractIds
4337
+ missingContractIds,
4338
+ dryRunStatus
4145
4339
  };
4146
4340
  }
4341
+ /**
4342
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4343
+ *
4344
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4345
+ * further modifications are identified. The method iteratively updates these transactions
4346
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4347
+ *
4348
+ * @param transactionRequests - Array of transaction request objects.
4349
+ * @returns A promise that resolves to an array of results for each transaction.
4350
+ */
4351
+ async estimateMultipleTxDependencies(transactionRequests) {
4352
+ const results = transactionRequests.map(() => ({
4353
+ receipts: [],
4354
+ outputVariables: 0,
4355
+ missingContractIds: [],
4356
+ dryRunStatus: void 0
4357
+ }));
4358
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4359
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4360
+ allRequests.forEach((req, index) => {
4361
+ if (req.type === import_transactions19.TransactionType.Script) {
4362
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4363
+ }
4364
+ });
4365
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4366
+ let attempt = 0;
4367
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4368
+ const encodedTransactions = transactionsToProcess.map(
4369
+ (index) => serializedTransactionsMap.get(index)
4370
+ );
4371
+ const dryRunResults = await this.operations.dryRun({
4372
+ encodedTransactions,
4373
+ utxoValidation: false
4374
+ });
4375
+ const nextRoundTransactions = [];
4376
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4377
+ const requestIdx = transactionsToProcess[i];
4378
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4379
+ const result = results[requestIdx];
4380
+ result.receipts = rawReceipts.map(processGqlReceipt);
4381
+ result.dryRunStatus = status;
4382
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4383
+ result.receipts
4384
+ );
4385
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4386
+ const request = allRequests[requestIdx];
4387
+ if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4388
+ result.outputVariables += missingOutputVariables.length;
4389
+ request.addVariableOutputs(missingOutputVariables.length);
4390
+ missingOutputContractIds.forEach(({ contractId }) => {
4391
+ request.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4392
+ result.missingContractIds.push(contractId);
4393
+ });
4394
+ const { maxFee } = await this.estimateTxGasAndFee({
4395
+ transactionRequest: request
4396
+ });
4397
+ request.maxFee = maxFee;
4398
+ serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4399
+ nextRoundTransactions.push(requestIdx);
4400
+ }
4401
+ }
4402
+ transactionsToProcess = nextRoundTransactions;
4403
+ attempt += 1;
4404
+ }
4405
+ return results;
4406
+ }
4407
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4408
+ if (estimateTxDependencies) {
4409
+ return this.estimateMultipleTxDependencies(transactionRequests);
4410
+ }
4411
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4412
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4413
+ encodedTransactions,
4414
+ utxoValidation: utxoValidation || false
4415
+ });
4416
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4417
+ const receipts = rawReceipts.map(processGqlReceipt);
4418
+ return { receipts, dryRunStatus: status };
4419
+ });
4420
+ return results;
4421
+ }
4147
4422
  /**
4148
4423
  * Estimates the transaction gas and fee based on the provided transaction request.
4149
4424
  * @param transactionRequest - The transaction request object.
4150
4425
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4151
4426
  */
4152
- estimateTxGasAndFee(params) {
4427
+ async estimateTxGasAndFee(params) {
4153
4428
  const { transactionRequest } = params;
4154
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4429
+ let { gasPrice } = params;
4155
4430
  const chainInfo = this.getChain();
4156
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4157
- transactionRequest.gasPrice = gasPrice;
4431
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4158
4432
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4159
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4160
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4433
+ if (!gasPrice) {
4434
+ gasPrice = await this.estimateGasPrice(10);
4435
+ }
4436
+ const minFee = calculateGasFee({
4437
+ gasPrice: (0, import_math17.bn)(gasPrice),
4438
+ gas: minGas,
4439
+ priceFactor: gasPriceFactor,
4440
+ tip: transactionRequest.tip
4441
+ }).add(1);
4442
+ let gasLimit = (0, import_math17.bn)(0);
4443
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4444
+ gasLimit = transactionRequest.gasLimit;
4161
4445
  if (transactionRequest.gasLimit.eq(0)) {
4162
4446
  transactionRequest.gasLimit = minGas;
4163
4447
  transactionRequest.gasLimit = maxGasPerTx.sub(
4164
4448
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4165
4449
  );
4450
+ gasLimit = transactionRequest.gasLimit;
4166
4451
  }
4167
4452
  }
4168
4453
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4169
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4454
+ const maxFee = calculateGasFee({
4455
+ gasPrice: (0, import_math17.bn)(gasPrice),
4456
+ gas: maxGas,
4457
+ priceFactor: gasPriceFactor,
4458
+ tip: transactionRequest.tip
4459
+ }).add(1);
4170
4460
  return {
4171
4461
  minGas,
4172
4462
  minFee,
4173
4463
  maxGas,
4174
- maxFee
4464
+ maxFee,
4465
+ gasPrice,
4466
+ gasLimit
4175
4467
  };
4176
4468
  }
4177
4469
  /**
@@ -4189,15 +4481,17 @@ var _Provider = class {
4189
4481
  if (estimateTxDependencies) {
4190
4482
  return this.estimateTxDependencies(transactionRequest);
4191
4483
  }
4192
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4193
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4194
- encodedTransaction,
4484
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4485
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4486
+ encodedTransactions,
4195
4487
  utxoValidation: true
4196
4488
  });
4197
- const receipts = gqlReceipts.map(processGqlReceipt);
4198
- return {
4199
- receipts
4200
- };
4489
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4490
+ const { id, receipts, status } = dryRunStatus;
4491
+ const processedReceipts = receipts.map(processGqlReceipt);
4492
+ return { id, receipts: processedReceipts, status };
4493
+ });
4494
+ return { receipts: callResult[0].receipts };
4201
4495
  }
4202
4496
  /**
4203
4497
  * Returns a transaction cost to enable user
@@ -4214,77 +4508,79 @@ var _Provider = class {
4214
4508
  * @param tolerance - The tolerance to add on top of the gasUsed.
4215
4509
  * @returns A promise that resolves to the transaction cost object.
4216
4510
  */
4217
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4218
- estimateTxDependencies = true,
4219
- estimatePredicates = true,
4220
- resourcesOwner,
4221
- signatureCallback
4222
- } = {}) {
4511
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4223
4512
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4224
- const { minGasPrice } = this.getGasConfig();
4225
- const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4226
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4513
+ const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4514
+ const baseAssetId = this.getBaseAssetId();
4227
4515
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4228
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4229
- txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4516
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4517
+ txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4518
+ txRequestClone.maxFee = (0, import_math17.bn)(0);
4230
4519
  if (isScriptTransaction) {
4231
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4520
+ txRequestClone.gasLimit = (0, import_math17.bn)(0);
4232
4521
  }
4233
- if (estimatePredicates) {
4234
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4235
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4236
- }
4237
- await this.estimatePredicates(txRequestClone);
4522
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4523
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4238
4524
  }
4525
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4526
+ let addedSignatures = 0;
4239
4527
  if (signatureCallback && isScriptTransaction) {
4240
- await signatureCallback(txRequestClone);
4528
+ const lengthBefore = signedRequest.witnesses.length;
4529
+ await signatureCallback(signedRequest);
4530
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4241
4531
  }
4242
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4243
- transactionRequest: txRequestClone
4532
+ await this.estimatePredicates(signedRequest);
4533
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4534
+ transactionRequest: signedRequest
4244
4535
  });
4245
4536
  let receipts = [];
4537
+ let dryRunStatus;
4246
4538
  let missingContractIds = [];
4247
4539
  let outputVariables = 0;
4248
- let gasUsed = (0, import_math15.bn)(0);
4249
- if (isScriptTransaction && estimateTxDependencies) {
4250
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4251
- const result = await this.estimateTxDependencies(txRequestClone);
4252
- receipts = result.receipts;
4253
- outputVariables = result.outputVariables;
4254
- missingContractIds = result.missingContractIds;
4540
+ let gasUsed = (0, import_math17.bn)(0);
4541
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4542
+ txRequestClone.maxFee = maxFee;
4543
+ if (isScriptTransaction) {
4544
+ txRequestClone.gasLimit = gasLimit;
4545
+ if (signatureCallback) {
4546
+ await signatureCallback(txRequestClone);
4547
+ }
4548
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4255
4549
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4256
4550
  txRequestClone.gasLimit = gasUsed;
4257
- txRequestClone.gasPrice = setGasPrice;
4258
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4259
- transactionRequest: txRequestClone
4551
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4552
+ transactionRequest: txRequestClone,
4553
+ gasPrice
4260
4554
  }));
4261
4555
  }
4262
4556
  return {
4263
4557
  requiredQuantities: allQuantities,
4264
4558
  receipts,
4265
4559
  gasUsed,
4266
- minGasPrice,
4267
- gasPrice: setGasPrice,
4560
+ gasPrice,
4268
4561
  minGas,
4269
4562
  maxGas,
4270
4563
  minFee,
4271
4564
  maxFee,
4272
- estimatedInputs: txRequestClone.inputs,
4273
4565
  outputVariables,
4274
- missingContractIds
4566
+ missingContractIds,
4567
+ addedSignatures,
4568
+ estimatedPredicates: txRequestClone.inputs,
4569
+ dryRunStatus
4275
4570
  };
4276
4571
  }
4277
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4572
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4278
4573
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4279
4574
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4280
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4575
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4576
+ quantitiesToContract
4577
+ });
4281
4578
  transactionRequest.addResources(
4282
4579
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4283
4580
  );
4284
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4285
- transactionRequest,
4286
- forwardingQuantities
4287
- );
4581
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4582
+ quantitiesToContract
4583
+ });
4288
4584
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4289
4585
  return {
4290
4586
  resources,
@@ -4300,17 +4596,16 @@ var _Provider = class {
4300
4596
  const result = await this.operations.getCoins({
4301
4597
  first: 10,
4302
4598
  ...paginationArgs,
4303
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4599
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4304
4600
  });
4305
4601
  const coins = result.coins.edges.map((edge) => edge.node);
4306
4602
  return coins.map((coin) => ({
4307
4603
  id: coin.utxoId,
4308
4604
  assetId: coin.assetId,
4309
- amount: (0, import_math15.bn)(coin.amount),
4605
+ amount: (0, import_math17.bn)(coin.amount),
4310
4606
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4311
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4312
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4313
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4607
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4608
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4314
4609
  }));
4315
4610
  }
4316
4611
  /**
@@ -4324,19 +4619,19 @@ var _Provider = class {
4324
4619
  async getResourcesToSpend(owner, quantities, excludedIds) {
4325
4620
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4326
4621
  const excludeInput = {
4327
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4328
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4622
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4623
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4329
4624
  };
4330
4625
  if (this.cache) {
4331
4626
  const uniqueUtxos = new Set(
4332
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4627
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4333
4628
  );
4334
4629
  excludeInput.utxos = Array.from(uniqueUtxos);
4335
4630
  }
4336
4631
  const coinsQuery = {
4337
4632
  owner: ownerAddress.toB256(),
4338
4633
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4339
- assetId: (0, import_utils23.hexlify)(assetId),
4634
+ assetId: (0, import_utils22.hexlify)(assetId),
4340
4635
  amount: amount.toString(10),
4341
4636
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4342
4637
  })),
@@ -4347,9 +4642,9 @@ var _Provider = class {
4347
4642
  switch (coin.__typename) {
4348
4643
  case "MessageCoin":
4349
4644
  return {
4350
- amount: (0, import_math15.bn)(coin.amount),
4645
+ amount: (0, import_math17.bn)(coin.amount),
4351
4646
  assetId: coin.assetId,
4352
- daHeight: (0, import_math15.bn)(coin.daHeight),
4647
+ daHeight: (0, import_math17.bn)(coin.daHeight),
4353
4648
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4354
4649
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4355
4650
  nonce: coin.nonce
@@ -4357,12 +4652,11 @@ var _Provider = class {
4357
4652
  case "Coin":
4358
4653
  return {
4359
4654
  id: coin.utxoId,
4360
- amount: (0, import_math15.bn)(coin.amount),
4655
+ amount: (0, import_math17.bn)(coin.amount),
4361
4656
  assetId: coin.assetId,
4362
4657
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4363
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4364
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4365
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4658
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4659
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4366
4660
  };
4367
4661
  default:
4368
4662
  return null;
@@ -4379,13 +4673,13 @@ var _Provider = class {
4379
4673
  async getBlock(idOrHeight) {
4380
4674
  let variables;
4381
4675
  if (typeof idOrHeight === "number") {
4382
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4676
+ variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4383
4677
  } else if (idOrHeight === "latest") {
4384
4678
  variables = { height: (await this.getBlockNumber()).toString(10) };
4385
4679
  } else if (idOrHeight.length === 66) {
4386
4680
  variables = { blockId: idOrHeight };
4387
4681
  } else {
4388
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4682
+ variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4389
4683
  }
4390
4684
  const { block } = await this.operations.getBlock(variables);
4391
4685
  if (!block) {
@@ -4393,7 +4687,7 @@ var _Provider = class {
4393
4687
  }
4394
4688
  return {
4395
4689
  id: block.id,
4396
- height: (0, import_math15.bn)(block.header.height),
4690
+ height: (0, import_math17.bn)(block.height),
4397
4691
  time: block.header.time,
4398
4692
  transactionIds: block.transactions.map((tx) => tx.id)
4399
4693
  };
@@ -4408,7 +4702,7 @@ var _Provider = class {
4408
4702
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4409
4703
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4410
4704
  id: block.id,
4411
- height: (0, import_math15.bn)(block.header.height),
4705
+ height: (0, import_math17.bn)(block.height),
4412
4706
  time: block.header.time,
4413
4707
  transactionIds: block.transactions.map((tx) => tx.id)
4414
4708
  }));
@@ -4423,7 +4717,7 @@ var _Provider = class {
4423
4717
  async getBlockWithTransactions(idOrHeight) {
4424
4718
  let variables;
4425
4719
  if (typeof idOrHeight === "number") {
4426
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4720
+ variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4427
4721
  } else if (idOrHeight === "latest") {
4428
4722
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4429
4723
  } else {
@@ -4435,11 +4729,11 @@ var _Provider = class {
4435
4729
  }
4436
4730
  return {
4437
4731
  id: block.id,
4438
- height: (0, import_math15.bn)(block.header.height, 10),
4732
+ height: (0, import_math17.bn)(block.height, 10),
4439
4733
  time: block.header.time,
4440
4734
  transactionIds: block.transactions.map((tx) => tx.id),
4441
4735
  transactions: block.transactions.map(
4442
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4736
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4443
4737
  )
4444
4738
  };
4445
4739
  }
@@ -4454,8 +4748,8 @@ var _Provider = class {
4454
4748
  if (!transaction) {
4455
4749
  return null;
4456
4750
  }
4457
- return new import_transactions18.TransactionCoder().decode(
4458
- (0, import_utils23.arrayify)(transaction.rawPayload),
4751
+ return new import_transactions19.TransactionCoder().decode(
4752
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4459
4753
  0
4460
4754
  )?.[0];
4461
4755
  }
@@ -4482,9 +4776,9 @@ var _Provider = class {
4482
4776
  async getContractBalance(contractId, assetId) {
4483
4777
  const { contractBalance } = await this.operations.getContractBalance({
4484
4778
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4485
- asset: (0, import_utils23.hexlify)(assetId)
4779
+ asset: (0, import_utils22.hexlify)(assetId)
4486
4780
  });
4487
- return (0, import_math15.bn)(contractBalance.amount, 10);
4781
+ return (0, import_math17.bn)(contractBalance.amount, 10);
4488
4782
  }
4489
4783
  /**
4490
4784
  * Returns the balance for the given owner for the given asset ID.
@@ -4496,9 +4790,9 @@ var _Provider = class {
4496
4790
  async getBalance(owner, assetId) {
4497
4791
  const { balance } = await this.operations.getBalance({
4498
4792
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4499
- assetId: (0, import_utils23.hexlify)(assetId)
4793
+ assetId: (0, import_utils22.hexlify)(assetId)
4500
4794
  });
4501
- return (0, import_math15.bn)(balance.amount, 10);
4795
+ return (0, import_math17.bn)(balance.amount, 10);
4502
4796
  }
4503
4797
  /**
4504
4798
  * Returns balances for the given owner.
@@ -4516,7 +4810,7 @@ var _Provider = class {
4516
4810
  const balances = result.balances.edges.map((edge) => edge.node);
4517
4811
  return balances.map((balance) => ({
4518
4812
  assetId: balance.assetId,
4519
- amount: (0, import_math15.bn)(balance.amount)
4813
+ amount: (0, import_math17.bn)(balance.amount)
4520
4814
  }));
4521
4815
  }
4522
4816
  /**
@@ -4534,19 +4828,19 @@ var _Provider = class {
4534
4828
  });
4535
4829
  const messages = result.messages.edges.map((edge) => edge.node);
4536
4830
  return messages.map((message) => ({
4537
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4831
+ messageId: import_transactions19.InputMessageCoder.getMessageId({
4538
4832
  sender: message.sender,
4539
4833
  recipient: message.recipient,
4540
4834
  nonce: message.nonce,
4541
- amount: (0, import_math15.bn)(message.amount),
4835
+ amount: (0, import_math17.bn)(message.amount),
4542
4836
  data: message.data
4543
4837
  }),
4544
4838
  sender: import_address3.Address.fromAddressOrString(message.sender),
4545
4839
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4546
4840
  nonce: message.nonce,
4547
- amount: (0, import_math15.bn)(message.amount),
4548
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4549
- daHeight: (0, import_math15.bn)(message.daHeight)
4841
+ amount: (0, import_math17.bn)(message.amount),
4842
+ data: import_transactions19.InputMessageCoder.decodeData(message.data),
4843
+ daHeight: (0, import_math17.bn)(message.daHeight)
4550
4844
  }));
4551
4845
  }
4552
4846
  /**
@@ -4599,44 +4893,60 @@ var _Provider = class {
4599
4893
  } = result.messageProof;
4600
4894
  return {
4601
4895
  messageProof: {
4602
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4896
+ proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4603
4897
  proofSet: messageProof.proofSet
4604
4898
  },
4605
4899
  blockProof: {
4606
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4900
+ proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4607
4901
  proofSet: blockProof.proofSet
4608
4902
  },
4609
4903
  messageBlockHeader: {
4610
4904
  id: messageBlockHeader.id,
4611
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4612
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4905
+ daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4906
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4613
4907
  transactionsRoot: messageBlockHeader.transactionsRoot,
4614
- height: (0, import_math15.bn)(messageBlockHeader.height),
4908
+ height: (0, import_math17.bn)(messageBlockHeader.height),
4615
4909
  prevRoot: messageBlockHeader.prevRoot,
4616
4910
  time: messageBlockHeader.time,
4617
4911
  applicationHash: messageBlockHeader.applicationHash,
4618
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4619
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4912
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4913
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4914
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4915
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4916
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4620
4917
  },
4621
4918
  commitBlockHeader: {
4622
4919
  id: commitBlockHeader.id,
4623
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4624
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4920
+ daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4921
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4625
4922
  transactionsRoot: commitBlockHeader.transactionsRoot,
4626
- height: (0, import_math15.bn)(commitBlockHeader.height),
4923
+ height: (0, import_math17.bn)(commitBlockHeader.height),
4627
4924
  prevRoot: commitBlockHeader.prevRoot,
4628
4925
  time: commitBlockHeader.time,
4629
4926
  applicationHash: commitBlockHeader.applicationHash,
4630
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4631
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4927
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4928
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4929
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4930
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4931
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4632
4932
  },
4633
4933
  sender: import_address3.Address.fromAddressOrString(sender),
4634
4934
  recipient: import_address3.Address.fromAddressOrString(recipient),
4635
4935
  nonce,
4636
- amount: (0, import_math15.bn)(amount),
4936
+ amount: (0, import_math17.bn)(amount),
4637
4937
  data
4638
4938
  };
4639
4939
  }
4940
+ async getLatestGasPrice() {
4941
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4942
+ return (0, import_math17.bn)(latestGasPrice.gasPrice);
4943
+ }
4944
+ async estimateGasPrice(blockHorizon) {
4945
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4946
+ blockHorizon: String(blockHorizon)
4947
+ });
4948
+ return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4949
+ }
4640
4950
  /**
4641
4951
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4642
4952
  *
@@ -4656,15 +4966,37 @@ var _Provider = class {
4656
4966
  */
4657
4967
  async produceBlocks(amount, startTime) {
4658
4968
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4659
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4660
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4969
+ blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4970
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4661
4971
  });
4662
- return (0, import_math15.bn)(latestBlockHeight);
4972
+ return (0, import_math17.bn)(latestBlockHeight);
4663
4973
  }
4664
4974
  // eslint-disable-next-line @typescript-eslint/require-await
4665
4975
  async getTransactionResponse(transactionId) {
4666
4976
  return new TransactionResponse(transactionId, this);
4667
4977
  }
4978
+ /**
4979
+ * Returns Message for given nonce.
4980
+ *
4981
+ * @param nonce - The nonce of the message to retrieve.
4982
+ * @returns A promise that resolves to the Message object.
4983
+ */
4984
+ async getMessageByNonce(nonce) {
4985
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4986
+ if (!message) {
4987
+ return null;
4988
+ }
4989
+ return message;
4990
+ }
4991
+ async getRelayedTransactionStatus(relayedTransactionId) {
4992
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4993
+ relayedTransactionId
4994
+ });
4995
+ if (!relayedTransactionStatus) {
4996
+ return null;
4997
+ }
4998
+ return relayedTransactionStatus;
4999
+ }
4668
5000
  };
4669
5001
  var Provider = _Provider;
4670
5002
  _cacheInputs = new WeakSet();
@@ -4673,7 +5005,7 @@ cacheInputs_fn = function(inputs) {
4673
5005
  return;
4674
5006
  }
4675
5007
  inputs.forEach((input) => {
4676
- if (input.type === import_transactions18.InputType.Coin) {
5008
+ if (input.type === import_transactions19.InputType.Coin) {
4677
5009
  this.cache?.set(input.id);
4678
5010
  }
4679
5011
  });
@@ -4683,9 +5015,9 @@ __publicField(Provider, "nodeInfoCache", {});
4683
5015
 
4684
5016
  // src/providers/transaction-summary/get-transaction-summary.ts
4685
5017
  var import_errors15 = require("@fuel-ts/errors");
4686
- var import_math16 = require("@fuel-ts/math");
4687
- var import_transactions19 = require("@fuel-ts/transactions");
4688
- var import_utils26 = require("@fuel-ts/utils");
5018
+ var import_math18 = require("@fuel-ts/math");
5019
+ var import_transactions20 = require("@fuel-ts/transactions");
5020
+ var import_utils25 = require("@fuel-ts/utils");
4689
5021
  async function getTransactionSummary(params) {
4690
5022
  const { id, provider, abiMap } = params;
4691
5023
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4697,25 +5029,36 @@ async function getTransactionSummary(params) {
4697
5029
  `Transaction not found for given id: ${id}.`
4698
5030
  );
4699
5031
  }
4700
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4701
- (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
5032
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
5033
+ (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4702
5034
  0
4703
5035
  );
4704
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
5036
+ let txReceipts = [];
5037
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5038
+ txReceipts = gqlTransaction.status.receipts;
5039
+ }
5040
+ const receipts = txReceipts.map(processGqlReceipt);
4705
5041
  const {
4706
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
5042
+ consensusParameters: {
5043
+ feeParameters: { gasPerByte, gasPriceFactor },
5044
+ txParameters: { maxInputs, maxGasPerTx },
5045
+ gasCosts
5046
+ }
4707
5047
  } = provider.getChain();
5048
+ const gasPrice = await provider.getLatestGasPrice();
4708
5049
  const transactionInfo = assembleTransactionSummary({
4709
5050
  id: gqlTransaction.id,
4710
5051
  receipts,
4711
5052
  transaction: decodedTransaction,
4712
- transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
5053
+ transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4713
5054
  gqlTransactionStatus: gqlTransaction.status,
4714
- gasPerByte: (0, import_math16.bn)(gasPerByte),
4715
- gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
5055
+ gasPerByte: (0, import_math18.bn)(gasPerByte),
5056
+ gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
4716
5057
  abiMap,
4717
5058
  maxInputs,
4718
- gasCosts
5059
+ gasCosts,
5060
+ maxGasPerTx,
5061
+ gasPrice
4719
5062
  });
4720
5063
  return {
4721
5064
  gqlTransaction,
@@ -4725,10 +5068,11 @@ async function getTransactionSummary(params) {
4725
5068
  async function getTransactionSummaryFromRequest(params) {
4726
5069
  const { provider, transactionRequest, abiMap } = params;
4727
5070
  const { receipts } = await provider.call(transactionRequest);
4728
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4729
- const maxInputs = provider.getChain().consensusParameters.maxInputs;
5071
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
5072
+ const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
4730
5073
  const transaction = transactionRequest.toTransaction();
4731
5074
  const transactionBytes = transactionRequest.toTransactionBytes();
5075
+ const gasPrice = await provider.getLatestGasPrice();
4732
5076
  const transactionSummary = assembleTransactionSummary({
4733
5077
  receipts,
4734
5078
  transaction,
@@ -4737,7 +5081,9 @@ async function getTransactionSummaryFromRequest(params) {
4737
5081
  gasPerByte,
4738
5082
  gasPriceFactor,
4739
5083
  maxInputs,
4740
- gasCosts
5084
+ gasCosts,
5085
+ maxGasPerTx,
5086
+ gasPrice
4741
5087
  });
4742
5088
  return transactionSummary;
4743
5089
  }
@@ -4746,24 +5092,35 @@ async function getTransactionsSummaries(params) {
4746
5092
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4747
5093
  const { edges, pageInfo } = transactionsByOwner;
4748
5094
  const {
4749
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
5095
+ consensusParameters: {
5096
+ feeParameters: { gasPerByte, gasPriceFactor },
5097
+ txParameters: { maxInputs, maxGasPerTx },
5098
+ gasCosts
5099
+ }
4750
5100
  } = provider.getChain();
5101
+ const gasPrice = await provider.getLatestGasPrice();
4751
5102
  const transactions = edges.map((edge) => {
4752
5103
  const { node: gqlTransaction } = edge;
4753
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4754
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4755
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
5104
+ const { id, rawPayload, status } = gqlTransaction;
5105
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5106
+ let txReceipts = [];
5107
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5108
+ txReceipts = gqlTransaction.status.receipts;
5109
+ }
5110
+ const receipts = txReceipts.map(processGqlReceipt);
4756
5111
  const transactionSummary = assembleTransactionSummary({
4757
5112
  id,
4758
5113
  receipts,
4759
5114
  transaction: decodedTransaction,
4760
- transactionBytes: (0, import_utils26.arrayify)(rawPayload),
5115
+ transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4761
5116
  gqlTransactionStatus: status,
4762
5117
  abiMap,
4763
5118
  gasPerByte,
4764
5119
  gasPriceFactor,
4765
5120
  maxInputs,
4766
- gasCosts
5121
+ gasCosts,
5122
+ maxGasPerTx,
5123
+ gasPrice
4767
5124
  });
4768
5125
  const output = {
4769
5126
  gqlTransaction,
@@ -4898,19 +5255,35 @@ var assets = [
4898
5255
  }
4899
5256
  ];
4900
5257
 
5258
+ // src/providers/transaction-request/helpers.ts
5259
+ var import_math19 = require("@fuel-ts/math");
5260
+ var import_transactions21 = require("@fuel-ts/transactions");
5261
+ var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
5262
+ var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
5263
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
5264
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
5265
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
5266
+ return acc.add(input.amount);
5267
+ }
5268
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
5269
+ return acc.add(input.amount);
5270
+ }
5271
+ return acc;
5272
+ }, (0, import_math19.bn)(0));
5273
+
4901
5274
  // src/utils/formatTransferToContractScriptData.ts
4902
5275
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4903
- var import_math17 = require("@fuel-ts/math");
4904
- var import_utils27 = require("@fuel-ts/utils");
5276
+ var import_math20 = require("@fuel-ts/math");
5277
+ var import_utils26 = require("@fuel-ts/utils");
4905
5278
  var asm = __toESM(require("@fuels/vm-asm"));
4906
5279
  var formatTransferToContractScriptData = (params) => {
4907
5280
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4908
5281
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4909
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5282
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
4910
5283
  const scriptData = Uint8Array.from([
4911
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
5284
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4912
5285
  ...encoded,
4913
- ...(0, import_utils27.arrayify)(assetId)
5286
+ ...(0, import_utils26.arrayify)(assetId)
4914
5287
  ]);
4915
5288
  return scriptData;
4916
5289
  };
@@ -4935,6 +5308,7 @@ var assembleTransferToContractScript = async (params) => {
4935
5308
  };
4936
5309
 
4937
5310
  // src/account.ts
5311
+ var MAX_FUNDING_ATTEMPTS = 2;
4938
5312
  var Account = class extends import_interfaces.AbstractAccount {
4939
5313
  /**
4940
5314
  * The address associated with the account.
@@ -5057,8 +5431,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5057
5431
  * @param assetId - The asset ID to check the balance for.
5058
5432
  * @returns A promise that resolves to the balance amount.
5059
5433
  */
5060
- async getBalance(assetId = import_configs12.BaseAssetId) {
5061
- const amount = await this.provider.getBalance(this.address, assetId);
5434
+ async getBalance(assetId) {
5435
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
5436
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
5062
5437
  return amount;
5063
5438
  }
5064
5439
  /**
@@ -5091,44 +5466,35 @@ var Account = class extends import_interfaces.AbstractAccount {
5091
5466
  * Adds resources to the transaction enough to fund it.
5092
5467
  *
5093
5468
  * @param request - The transaction request.
5094
- * @param coinQuantities - The coin quantities required to execute the transaction.
5469
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
5095
5470
  * @param fee - The estimated transaction fee.
5096
5471
  * @returns A promise that resolves when the resources are added to the transaction.
5097
5472
  */
5098
- async fund(request, coinQuantities, fee) {
5099
- const updatedQuantities = addAmountToAsset({
5100
- amount: (0, import_math18.bn)(fee),
5101
- assetId: import_configs12.BaseAssetId,
5102
- coinQuantities
5473
+ async fund(request, params) {
5474
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5475
+ const baseAssetId = this.provider.getBaseAssetId();
5476
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5477
+ const txRequest = request;
5478
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5479
+ amount: (0, import_math21.bn)(fee),
5480
+ assetId: baseAssetId,
5481
+ coinQuantities: requiredQuantities
5103
5482
  });
5104
5483
  const quantitiesDict = {};
5105
- updatedQuantities.forEach(({ amount, assetId }) => {
5484
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5106
5485
  quantitiesDict[assetId] = {
5107
5486
  required: amount,
5108
- owned: (0, import_math18.bn)(0)
5487
+ owned: (0, import_math21.bn)(0)
5109
5488
  };
5110
5489
  });
5111
- const cachedUtxos = [];
5112
- const cachedMessages = [];
5113
- const owner = this.address.toB256();
5114
- request.inputs.forEach((input) => {
5115
- const isResource = "amount" in input;
5116
- if (isResource) {
5117
- const isCoin2 = "owner" in input;
5118
- if (isCoin2) {
5119
- const assetId = String(input.assetId);
5120
- if (input.owner === owner && quantitiesDict[assetId]) {
5121
- const amount = (0, import_math18.bn)(input.amount);
5122
- quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5123
- cachedUtxos.push(input.id);
5124
- }
5125
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5126
- quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5127
- cachedMessages.push(input.nonce);
5128
- }
5490
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5491
+ const isCoin2 = isRequestInputCoin(input);
5492
+ const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
5493
+ if (quantitiesDict[assetId]) {
5494
+ quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
5129
5495
  }
5130
5496
  });
5131
- const missingQuantities = [];
5497
+ let missingQuantities = [];
5132
5498
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
5133
5499
  if (owned.lt(required)) {
5134
5500
  missingQuantities.push({
@@ -5137,14 +5503,54 @@ var Account = class extends import_interfaces.AbstractAccount {
5137
5503
  });
5138
5504
  }
5139
5505
  });
5140
- const needsToBeFunded = missingQuantities.length;
5141
- if (needsToBeFunded) {
5142
- const resources = await this.getResourcesToSpend(missingQuantities, {
5143
- messages: cachedMessages,
5144
- utxos: cachedUtxos
5145
- });
5506
+ let needsToBeFunded = missingQuantities.length > 0;
5507
+ let fundingAttempts = 0;
5508
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5509
+ const resources = await this.getResourcesToSpend(
5510
+ missingQuantities,
5511
+ cacheTxInputsFromOwner(request.inputs, this.address)
5512
+ );
5146
5513
  request.addResources(resources);
5514
+ txRequest.shiftPredicateData();
5515
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5516
+ const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5517
+ if (addedSignatures) {
5518
+ Array.from({ length: addedSignatures }).forEach(
5519
+ () => requestToReestimate2.addEmptyWitness()
5520
+ );
5521
+ }
5522
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5523
+ transactionRequest: requestToReestimate2
5524
+ });
5525
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5526
+ request.inputs,
5527
+ baseAssetId,
5528
+ baseAssetId
5529
+ );
5530
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5531
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5532
+ needsToBeFunded = false;
5533
+ } else {
5534
+ missingQuantities = [
5535
+ {
5536
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5537
+ assetId: baseAssetId
5538
+ }
5539
+ ];
5540
+ }
5541
+ fundingAttempts += 1;
5147
5542
  }
5543
+ txRequest.shiftPredicateData();
5544
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5545
+ const requestToReestimate = (0, import_ramda4.clone)(txRequest);
5546
+ if (addedSignatures) {
5547
+ Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5548
+ }
5549
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
5550
+ transactionRequest: requestToReestimate
5551
+ });
5552
+ txRequest.maxFee = maxFee;
5553
+ return txRequest;
5148
5554
  }
5149
5555
  /**
5150
5556
  * A helper that creates a transfer transaction request and returns it.
@@ -5152,28 +5558,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5152
5558
  * @param destination - The address of the destination.
5153
5559
  * @param amount - The amount of coins to transfer.
5154
5560
  * @param assetId - The asset ID of the coins to transfer.
5155
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5561
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5156
5562
  * @returns A promise that resolves to the prepared transaction request.
5157
5563
  */
5158
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5159
- const { minGasPrice } = this.provider.getGasConfig();
5160
- const params = { gasPrice: minGasPrice, ...txParams };
5161
- const request = new ScriptTransactionRequest(params);
5162
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5163
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5564
+ async createTransfer(destination, amount, assetId, txParams = {}) {
5565
+ const request = new ScriptTransactionRequest(txParams);
5566
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5567
+ request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5568
+ const txCost = await this.provider.getTransactionCost(request, {
5164
5569
  estimateTxDependencies: true,
5165
5570
  resourcesOwner: this
5166
5571
  });
5167
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5168
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5169
- this.validateGas({
5170
- gasUsed,
5171
- gasPrice: request.gasPrice,
5172
- gasLimit: request.gasLimit,
5173
- minGasPrice
5572
+ this.validateGasLimitAndMaxFee({
5573
+ gasUsed: txCost.gasUsed,
5574
+ maxFee: txCost.maxFee,
5575
+ txParams
5174
5576
  });
5175
- await this.fund(request, requiredQuantities, maxFee);
5176
- request.updatePredicateInputs(estimatedInputs);
5577
+ request.gasLimit = txCost.gasUsed;
5578
+ request.maxFee = txCost.maxFee;
5579
+ await this.fund(request, txCost);
5177
5580
  return request;
5178
5581
  }
5179
5582
  /**
@@ -5182,17 +5585,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5182
5585
  * @param destination - The address of the destination.
5183
5586
  * @param amount - The amount of coins to transfer.
5184
5587
  * @param assetId - The asset ID of the coins to transfer.
5185
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5588
+ * @param txParams - The transaction parameters (gasLimit, maturity).
5186
5589
  * @returns A promise that resolves to the transaction response.
5187
5590
  */
5188
- async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5189
- if ((0, import_math18.bn)(amount).lte(0)) {
5591
+ async transfer(destination, amount, assetId, txParams = {}) {
5592
+ if ((0, import_math21.bn)(amount).lte(0)) {
5190
5593
  throw new import_errors16.FuelError(
5191
5594
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5192
5595
  "Transfer amount must be a positive number."
5193
5596
  );
5194
5597
  }
5195
- const request = await this.createTransfer(destination, amount, assetId, txParams);
5598
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5599
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5196
5600
  return this.sendTransaction(request, { estimateTxDependencies: false });
5197
5601
  }
5198
5602
  /**
@@ -5204,39 +5608,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5204
5608
  * @param txParams - The optional transaction parameters.
5205
5609
  * @returns A promise that resolves to the transaction response.
5206
5610
  */
5207
- async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5208
- if ((0, import_math18.bn)(amount).lte(0)) {
5611
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
5612
+ if ((0, import_math21.bn)(amount).lte(0)) {
5209
5613
  throw new import_errors16.FuelError(
5210
5614
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5211
5615
  "Transfer amount must be a positive number."
5212
5616
  );
5213
5617
  }
5214
5618
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5215
- const { minGasPrice } = this.provider.getGasConfig();
5216
- const params = { gasPrice: minGasPrice, ...txParams };
5619
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5217
5620
  const { script, scriptData } = await assembleTransferToContractScript({
5218
5621
  hexlifiedContractId: contractAddress.toB256(),
5219
- amountToTransfer: (0, import_math18.bn)(amount),
5220
- assetId
5622
+ amountToTransfer: (0, import_math21.bn)(amount),
5623
+ assetId: assetIdToTransfer
5221
5624
  });
5222
5625
  const request = new ScriptTransactionRequest({
5223
- ...params,
5626
+ ...txParams,
5224
5627
  script,
5225
5628
  scriptData
5226
5629
  });
5227
5630
  request.addContractInputAndOutput(contractAddress);
5228
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5229
- request,
5230
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5231
- );
5232
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5233
- this.validateGas({
5234
- gasUsed,
5235
- gasPrice: request.gasPrice,
5236
- gasLimit: request.gasLimit,
5237
- minGasPrice
5631
+ const txCost = await this.provider.getTransactionCost(request, {
5632
+ resourcesOwner: this,
5633
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5634
+ });
5635
+ this.validateGasLimitAndMaxFee({
5636
+ gasUsed: txCost.gasUsed,
5637
+ maxFee: txCost.maxFee,
5638
+ txParams
5238
5639
  });
5239
- await this.fund(request, requiredQuantities, maxFee);
5640
+ request.gasLimit = txCost.gasUsed;
5641
+ request.maxFee = txCost.maxFee;
5642
+ await this.fund(request, txCost);
5240
5643
  return this.sendTransaction(request);
5241
5644
  }
5242
5645
  /**
@@ -5248,34 +5651,31 @@ var Account = class extends import_interfaces.AbstractAccount {
5248
5651
  * @returns A promise that resolves to the transaction response.
5249
5652
  */
5250
5653
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5251
- const { minGasPrice } = this.provider.getGasConfig();
5252
5654
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5253
- const recipientDataArray = (0, import_utils28.arrayify)(
5655
+ const recipientDataArray = (0, import_utils27.arrayify)(
5254
5656
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5255
5657
  );
5256
- const amountDataArray = (0, import_utils28.arrayify)(
5257
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5658
+ const amountDataArray = (0, import_utils27.arrayify)(
5659
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5258
5660
  );
5259
5661
  const script = new Uint8Array([
5260
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5662
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5261
5663
  ...recipientDataArray,
5262
5664
  ...amountDataArray
5263
5665
  ]);
5264
- const params = { script, gasPrice: minGasPrice, ...txParams };
5666
+ const params = { script, ...txParams };
5667
+ const baseAssetId = this.provider.getBaseAssetId();
5265
5668
  const request = new ScriptTransactionRequest(params);
5266
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5267
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5268
- request,
5269
- forwardingQuantities
5270
- );
5271
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5272
- this.validateGas({
5273
- gasUsed,
5274
- gasPrice: request.gasPrice,
5275
- gasLimit: request.gasLimit,
5276
- minGasPrice
5669
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5670
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5671
+ this.validateGasLimitAndMaxFee({
5672
+ gasUsed: txCost.gasUsed,
5673
+ maxFee: txCost.maxFee,
5674
+ txParams
5277
5675
  });
5278
- await this.fund(request, requiredQuantities, maxFee);
5676
+ request.maxFee = txCost.maxFee;
5677
+ request.gasLimit = txCost.gasUsed;
5678
+ await this.fund(request, txCost);
5279
5679
  return this.sendTransaction(request);
5280
5680
  }
5281
5681
  async signMessage(message) {
@@ -5333,22 +5733,21 @@ var Account = class extends import_interfaces.AbstractAccount {
5333
5733
  }
5334
5734
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5335
5735
  }
5336
- validateGas({
5736
+ validateGasLimitAndMaxFee({
5737
+ txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
5337
5738
  gasUsed,
5338
- gasPrice,
5339
- gasLimit,
5340
- minGasPrice
5739
+ maxFee
5341
5740
  }) {
5342
- if (minGasPrice.gt(gasPrice)) {
5741
+ if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
5343
5742
  throw new import_errors16.FuelError(
5344
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5345
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5743
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5744
+ `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5346
5745
  );
5347
5746
  }
5348
- if (gasUsed.gt(gasLimit)) {
5747
+ if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
5349
5748
  throw new import_errors16.FuelError(
5350
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5351
- `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5749
+ import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5750
+ `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5352
5751
  );
5353
5752
  }
5354
5753
  }
@@ -5356,14 +5755,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5356
5755
 
5357
5756
  // src/wallet/base-wallet-unlocked.ts
5358
5757
  var import_hasher3 = require("@fuel-ts/hasher");
5359
- var import_utils31 = require("@fuel-ts/utils");
5758
+ var import_utils30 = require("@fuel-ts/utils");
5360
5759
 
5361
5760
  // src/signer/signer.ts
5362
5761
  var import_address5 = require("@fuel-ts/address");
5363
5762
  var import_crypto2 = require("@fuel-ts/crypto");
5364
5763
  var import_hasher2 = require("@fuel-ts/hasher");
5365
- var import_math19 = require("@fuel-ts/math");
5366
- var import_utils29 = require("@fuel-ts/utils");
5764
+ var import_math22 = require("@fuel-ts/math");
5765
+ var import_utils28 = require("@fuel-ts/utils");
5367
5766
  var import_secp256k1 = require("@noble/curves/secp256k1");
5368
5767
  var Signer = class {
5369
5768
  address;
@@ -5382,10 +5781,10 @@ var Signer = class {
5382
5781
  privateKey = `0x${privateKey}`;
5383
5782
  }
5384
5783
  }
5385
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5386
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5387
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5388
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5784
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5785
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5786
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5787
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5389
5788
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5390
5789
  }
5391
5790
  /**
@@ -5399,11 +5798,11 @@ var Signer = class {
5399
5798
  * @returns hashed signature
5400
5799
  */
5401
5800
  sign(data) {
5402
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5403
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5404
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5801
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5802
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5803
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5405
5804
  s[0] |= (signature.recovery || 0) << 7;
5406
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5805
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5407
5806
  }
5408
5807
  /**
5409
5808
  * Add point on the current elliptic curve
@@ -5412,8 +5811,8 @@ var Signer = class {
5412
5811
  * @returns compressed point on the curve
5413
5812
  */
5414
5813
  addPoint(point) {
5415
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5416
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5814
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5815
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5417
5816
  const result = p0.add(p1);
5418
5817
  return `0x${result.toHex(true)}`;
5419
5818
  }
@@ -5425,16 +5824,16 @@ var Signer = class {
5425
5824
  * @returns public key from signature from the
5426
5825
  */
5427
5826
  static recoverPublicKey(data, signature) {
5428
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5827
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5429
5828
  const r = signedMessageBytes.slice(0, 32);
5430
5829
  const s = signedMessageBytes.slice(32, 64);
5431
5830
  const recoveryParam = (s[0] & 128) >> 7;
5432
5831
  s[0] &= 127;
5433
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5832
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5434
5833
  recoveryParam
5435
5834
  );
5436
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5437
- return (0, import_utils29.hexlify)(publicKey);
5835
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5836
+ return (0, import_utils28.hexlify)(publicKey);
5438
5837
  }
5439
5838
  /**
5440
5839
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5453,7 +5852,7 @@ var Signer = class {
5453
5852
  * @returns random 32-byte hashed
5454
5853
  */
5455
5854
  static generatePrivateKey(entropy) {
5456
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5855
+ 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);
5457
5856
  }
5458
5857
  /**
5459
5858
  * Extended publicKey from a compact publicKey
@@ -5462,8 +5861,8 @@ var Signer = class {
5462
5861
  * @returns extended publicKey
5463
5862
  */
5464
5863
  static extendPublicKey(publicKey) {
5465
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5466
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5864
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5865
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5467
5866
  }
5468
5867
  };
5469
5868
 
@@ -5471,7 +5870,7 @@ var Signer = class {
5471
5870
  var import_address6 = require("@fuel-ts/address");
5472
5871
  var import_crypto3 = require("@fuel-ts/crypto");
5473
5872
  var import_errors17 = require("@fuel-ts/errors");
5474
- var import_utils30 = require("@fuel-ts/utils");
5873
+ var import_utils29 = require("@fuel-ts/utils");
5475
5874
  var import_uuid = require("uuid");
5476
5875
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5477
5876
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5554,7 +5953,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5554
5953
  );
5555
5954
  }
5556
5955
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5557
- const privateKey = (0, import_utils30.hexlify)(buffer);
5956
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5558
5957
  return privateKey;
5559
5958
  }
5560
5959
 
@@ -5599,7 +5998,7 @@ var BaseWalletUnlocked = class extends Account {
5599
5998
  */
5600
5999
  async signMessage(message) {
5601
6000
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5602
- return (0, import_utils31.hexlify)(signedMessage);
6001
+ return (0, import_utils30.hexlify)(signedMessage);
5603
6002
  }
5604
6003
  /**
5605
6004
  * Signs a transaction with the wallet's private key.
@@ -5612,7 +6011,7 @@ var BaseWalletUnlocked = class extends Account {
5612
6011
  const chainId = this.provider.getChainId();
5613
6012
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5614
6013
  const signature = await this.signer().sign(hashedTransaction);
5615
- return (0, import_utils31.hexlify)(signature);
6014
+ return (0, import_utils30.hexlify)(signature);
5616
6015
  }
5617
6016
  /**
5618
6017
  * Populates a transaction with the witnesses signature.
@@ -5632,7 +6031,7 @@ var BaseWalletUnlocked = class extends Account {
5632
6031
  * @param transactionRequestLike - The transaction request to send.
5633
6032
  * @returns A promise that resolves to the TransactionResponse object.
5634
6033
  */
5635
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
6034
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5636
6035
  const transactionRequest = transactionRequestify(transactionRequestLike);
5637
6036
  if (estimateTxDependencies) {
5638
6037
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5673,16 +6072,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5673
6072
  // src/hdwallet/hdwallet.ts
5674
6073
  var import_errors20 = require("@fuel-ts/errors");
5675
6074
  var import_hasher6 = require("@fuel-ts/hasher");
5676
- var import_math20 = require("@fuel-ts/math");
5677
- var import_utils35 = require("@fuel-ts/utils");
5678
- var import_ethers3 = require("ethers");
6075
+ var import_math23 = require("@fuel-ts/math");
6076
+ var import_utils34 = require("@fuel-ts/utils");
6077
+ var import_ethers2 = require("ethers");
5679
6078
 
5680
6079
  // src/mnemonic/mnemonic.ts
5681
6080
  var import_crypto4 = require("@fuel-ts/crypto");
5682
6081
  var import_errors19 = require("@fuel-ts/errors");
5683
6082
  var import_hasher5 = require("@fuel-ts/hasher");
5684
- var import_utils33 = require("@fuel-ts/utils");
5685
- var import_ethers2 = require("ethers");
6083
+ var import_utils32 = require("@fuel-ts/utils");
6084
+ var import_ethers = require("ethers");
5686
6085
 
5687
6086
  // src/wordlists/words/english.ts
5688
6087
  var english = [
@@ -7745,7 +8144,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7745
8144
  // src/mnemonic/utils.ts
7746
8145
  var import_errors18 = require("@fuel-ts/errors");
7747
8146
  var import_hasher4 = require("@fuel-ts/hasher");
7748
- var import_utils32 = require("@fuel-ts/utils");
8147
+ var import_utils31 = require("@fuel-ts/utils");
7749
8148
  function toUtf8Bytes(stri) {
7750
8149
  const str = stri.normalize("NFKD");
7751
8150
  const result = [];
@@ -7812,14 +8211,14 @@ function entropyToMnemonicIndices(entropy) {
7812
8211
  }
7813
8212
  }
7814
8213
  const checksumBits = entropy.length / 4;
7815
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8214
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7816
8215
  indices[indices.length - 1] <<= checksumBits;
7817
8216
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7818
8217
  return indices;
7819
8218
  }
7820
8219
  function mnemonicWordsToEntropy(words, wordlist) {
7821
8220
  const size = Math.ceil(11 * words.length / 8);
7822
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8221
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7823
8222
  let offset = 0;
7824
8223
  for (let i = 0; i < words.length; i += 1) {
7825
8224
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7839,7 +8238,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7839
8238
  const entropyBits = 32 * words.length / 3;
7840
8239
  const checksumBits = words.length / 3;
7841
8240
  const checksumMask = getUpperMask(checksumBits);
7842
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8241
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7843
8242
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7844
8243
  throw new import_errors18.FuelError(
7845
8244
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7914,7 +8313,7 @@ var Mnemonic = class {
7914
8313
  static mnemonicToEntropy(phrase, wordlist = english) {
7915
8314
  const words = getWords(phrase);
7916
8315
  assertMnemonic(words);
7917
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8316
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7918
8317
  }
7919
8318
  /**
7920
8319
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7922,7 +8321,7 @@ var Mnemonic = class {
7922
8321
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7923
8322
  */
7924
8323
  static entropyToMnemonic(entropy, wordlist = english) {
7925
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
8324
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7926
8325
  assertWordList(wordlist);
7927
8326
  assertEntropy(entropyBytes);
7928
8327
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7936,7 +8335,7 @@ var Mnemonic = class {
7936
8335
  assertMnemonic(getWords(phrase));
7937
8336
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7938
8337
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7939
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8338
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7940
8339
  }
7941
8340
  /**
7942
8341
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7991,14 +8390,14 @@ var Mnemonic = class {
7991
8390
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7992
8391
  */
7993
8392
  static masterKeysFromSeed(seed) {
7994
- const seedArray = (0, import_utils33.arrayify)(seed);
8393
+ const seedArray = (0, import_utils32.arrayify)(seed);
7995
8394
  if (seedArray.length < 16 || seedArray.length > 64) {
7996
8395
  throw new import_errors19.FuelError(
7997
8396
  import_errors19.ErrorCode.INVALID_SEED,
7998
8397
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7999
8398
  );
8000
8399
  }
8001
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8400
+ return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8002
8401
  }
8003
8402
  /**
8004
8403
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8009,22 +8408,22 @@ var Mnemonic = class {
8009
8408
  */
8010
8409
  static seedToExtendedKey(seed, testnet = false) {
8011
8410
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8012
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8411
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8013
8412
  const depth = "0x00";
8014
8413
  const fingerprint = "0x00000000";
8015
8414
  const index = "0x00000000";
8016
8415
  const chainCode = masterKey.slice(32);
8017
8416
  const privateKey = masterKey.slice(0, 32);
8018
- const extendedKey = (0, import_utils33.concat)([
8417
+ const extendedKey = (0, import_utils32.concat)([
8019
8418
  prefix,
8020
8419
  depth,
8021
8420
  fingerprint,
8022
8421
  index,
8023
8422
  chainCode,
8024
- (0, import_utils33.concat)(["0x00", privateKey])
8423
+ (0, import_utils32.concat)(["0x00", privateKey])
8025
8424
  ]);
8026
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8027
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8425
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8426
+ return (0, import_ethers.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8028
8427
  }
8029
8428
  /**
8030
8429
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8039,7 +8438,7 @@ var Mnemonic = class {
8039
8438
  * @returns A randomly generated mnemonic
8040
8439
  */
8041
8440
  static generate(size = 32, extraEntropy = "") {
8042
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8441
+ 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);
8043
8442
  return Mnemonic.entropyToMnemonic(entropy);
8044
8443
  }
8045
8444
  };
@@ -8047,12 +8446,12 @@ var mnemonic_default = Mnemonic;
8047
8446
 
8048
8447
  // src/hdwallet/hdwallet.ts
8049
8448
  var HARDENED_INDEX = 2147483648;
8050
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8051
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8052
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8053
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8449
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8450
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8451
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8452
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8054
8453
  function base58check(data) {
8055
- return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8454
+ return (0, import_ethers2.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8056
8455
  }
8057
8456
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8058
8457
  if (isPublic) {
@@ -8061,11 +8460,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8061
8460
  return testnet ? TestnetPRV2 : MainnetPRV2;
8062
8461
  }
8063
8462
  function isPublicExtendedKey(extendedKey) {
8064
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8463
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8065
8464
  }
8066
8465
  function isValidExtendedKey(extendedKey) {
8067
8466
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8068
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8467
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8069
8468
  );
8070
8469
  }
8071
8470
  function parsePath(path, depth = 0) {
@@ -8083,8 +8482,8 @@ function parsePath(path, depth = 0) {
8083
8482
  var HDWallet = class {
8084
8483
  depth = 0;
8085
8484
  index = 0;
8086
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
8087
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8485
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
8486
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8088
8487
  privateKey;
8089
8488
  publicKey;
8090
8489
  chainCode;
@@ -8096,8 +8495,8 @@ var HDWallet = class {
8096
8495
  constructor(config) {
8097
8496
  if (config.privateKey) {
8098
8497
  const signer = new Signer(config.privateKey);
8099
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8100
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8498
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8499
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8101
8500
  } else {
8102
8501
  if (!config.publicKey) {
8103
8502
  throw new import_errors20.FuelError(
@@ -8105,10 +8504,10 @@ var HDWallet = class {
8105
8504
  "Both public and private Key cannot be missing. At least one should be provided."
8106
8505
  );
8107
8506
  }
8108
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8507
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8109
8508
  }
8110
8509
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8111
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8510
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8112
8511
  this.depth = config.depth || this.depth;
8113
8512
  this.index = config.index || this.index;
8114
8513
  this.chainCode = config.chainCode;
@@ -8124,9 +8523,9 @@ var HDWallet = class {
8124
8523
  * @returns A new instance of HDWallet on the derived index
8125
8524
  */
8126
8525
  deriveIndex(index) {
8127
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8128
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8129
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8526
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8527
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8528
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8130
8529
  const data = new Uint8Array(37);
8131
8530
  if (index & HARDENED_INDEX) {
8132
8531
  if (!privateKey) {
@@ -8137,15 +8536,15 @@ var HDWallet = class {
8137
8536
  }
8138
8537
  data.set(privateKey, 1);
8139
8538
  } else {
8140
- data.set((0, import_utils35.arrayify)(this.publicKey));
8539
+ data.set((0, import_utils34.arrayify)(this.publicKey));
8141
8540
  }
8142
- data.set((0, import_math20.toBytes)(index, 4), 33);
8143
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8541
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8542
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8144
8543
  const IL = bytes.slice(0, 32);
8145
8544
  const IR = bytes.slice(32);
8146
8545
  if (privateKey) {
8147
8546
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8148
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8547
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8149
8548
  return new HDWallet({
8150
8549
  privateKey: ki,
8151
8550
  chainCode: IR,
@@ -8154,7 +8553,7 @@ var HDWallet = class {
8154
8553
  parentFingerprint: this.fingerprint
8155
8554
  });
8156
8555
  }
8157
- const signer = new Signer((0, import_utils35.hexlify)(IL));
8556
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
8158
8557
  const Ki = signer.addPoint(publicKey);
8159
8558
  return new HDWallet({
8160
8559
  publicKey: Ki,
@@ -8189,12 +8588,12 @@ var HDWallet = class {
8189
8588
  );
8190
8589
  }
8191
8590
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8192
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8591
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8193
8592
  const parentFingerprint = this.parentFingerprint;
8194
- const index = (0, import_math20.toHex)(this.index, 4);
8593
+ const index = (0, import_math23.toHex)(this.index, 4);
8195
8594
  const chainCode = this.chainCode;
8196
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8197
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8595
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8596
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8198
8597
  return base58check(extendedKey);
8199
8598
  }
8200
8599
  /**
@@ -8206,13 +8605,13 @@ var HDWallet = class {
8206
8605
  static fromSeed(seed) {
8207
8606
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8208
8607
  return new HDWallet({
8209
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8210
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8608
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8609
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8211
8610
  });
8212
8611
  }
8213
8612
  static fromExtendedKey(extendedKey) {
8214
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8215
- const bytes = (0, import_utils35.arrayify)(decoded);
8613
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8614
+ const bytes = (0, import_utils34.arrayify)(decoded);
8216
8615
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8217
8616
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8218
8617
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8221,9 +8620,9 @@ var HDWallet = class {
8221
8620
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8222
8621
  }
8223
8622
  const depth = bytes[4];
8224
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8225
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8226
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8623
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8624
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8625
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8227
8626
  const key = bytes.slice(45, 78);
8228
8627
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8229
8628
  throw new import_errors20.FuelError(
@@ -8826,21 +9225,20 @@ var StorageAbstract = class {
8826
9225
  // src/predicate/predicate.ts
8827
9226
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8828
9227
  var import_address10 = require("@fuel-ts/address");
8829
- var import_configs13 = require("@fuel-ts/address/configs");
8830
9228
  var import_errors25 = require("@fuel-ts/errors");
8831
- var import_transactions20 = require("@fuel-ts/transactions");
8832
- var import_utils37 = require("@fuel-ts/utils");
9229
+ var import_transactions22 = require("@fuel-ts/transactions");
9230
+ var import_utils36 = require("@fuel-ts/utils");
8833
9231
 
8834
9232
  // src/predicate/utils/getPredicateRoot.ts
8835
9233
  var import_hasher7 = require("@fuel-ts/hasher");
8836
9234
  var import_merkle = require("@fuel-ts/merkle");
8837
- var import_utils36 = require("@fuel-ts/utils");
9235
+ var import_utils35 = require("@fuel-ts/utils");
8838
9236
  var getPredicateRoot = (bytecode) => {
8839
9237
  const chunkSize = 16 * 1024;
8840
- const bytes = (0, import_utils36.arrayify)(bytecode);
8841
- const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8842
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8843
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9238
+ const bytes = (0, import_utils35.arrayify)(bytecode);
9239
+ const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9240
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9241
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8844
9242
  return predicateRoot;
8845
9243
  };
8846
9244
 
@@ -8888,35 +9286,22 @@ var Predicate = class extends Account {
8888
9286
  const request = transactionRequestify(transactionRequestLike);
8889
9287
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8890
9288
  request.inputs?.forEach((input) => {
8891
- if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8892
- input.predicate = this.bytes;
8893
- input.predicateData = this.getPredicateData(policies.length);
9289
+ if (input.type === import_transactions22.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9290
+ input.predicate = (0, import_utils36.hexlify)(this.bytes);
9291
+ input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8894
9292
  }
8895
9293
  });
8896
9294
  return request;
8897
9295
  }
8898
- /**
8899
- * A helper that creates a transfer transaction request and returns it.
8900
- *
8901
- * @param destination - The address of the destination.
8902
- * @param amount - The amount of coins to transfer.
8903
- * @param assetId - The asset ID of the coins to transfer.
8904
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8905
- * @returns A promise that resolves to the prepared transaction request.
8906
- */
8907
- async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8908
- const request = await super.createTransfer(destination, amount, assetId, txParams);
8909
- return this.populateTransactionPredicateData(request);
8910
- }
8911
9296
  /**
8912
9297
  * Sends a transaction with the populated predicate data.
8913
9298
  *
8914
9299
  * @param transactionRequestLike - The transaction request-like object.
8915
9300
  * @returns A promise that resolves to the transaction response.
8916
9301
  */
8917
- sendTransaction(transactionRequestLike, options) {
8918
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8919
- return super.sendTransaction(transactionRequest, options);
9302
+ sendTransaction(transactionRequestLike) {
9303
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9304
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8920
9305
  }
8921
9306
  /**
8922
9307
  * Simulates a transaction with the populated predicate data.
@@ -8925,17 +9310,17 @@ var Predicate = class extends Account {
8925
9310
  * @returns A promise that resolves to the call result.
8926
9311
  */
8927
9312
  simulateTransaction(transactionRequestLike) {
8928
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8929
- return super.simulateTransaction(transactionRequest);
9313
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9314
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8930
9315
  }
8931
9316
  getPredicateData(policiesLength) {
8932
9317
  if (!this.predicateData.length) {
8933
9318
  return new Uint8Array();
8934
9319
  }
8935
9320
  const mainFn = this.interface?.functions.main;
8936
- const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9321
+ const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8937
9322
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
8938
- maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9323
+ maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
8939
9324
  });
8940
9325
  const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
8941
9326
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
@@ -8949,7 +9334,7 @@ var Predicate = class extends Account {
8949
9334
  * @returns An object containing the new predicate bytes and interface.
8950
9335
  */
8951
9336
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8952
- let predicateBytes = (0, import_utils37.arrayify)(bytes);
9337
+ let predicateBytes = (0, import_utils36.arrayify)(bytes);
8953
9338
  let abiInterface;
8954
9339
  if (jsonAbi) {
8955
9340
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -8972,6 +9357,25 @@ var Predicate = class extends Account {
8972
9357
  predicateInterface: abiInterface
8973
9358
  };
8974
9359
  }
9360
+ /**
9361
+ * Retrieves resources satisfying the spend query for the account.
9362
+ *
9363
+ * @param quantities - IDs of coins to exclude.
9364
+ * @param excludedIds - IDs of resources to be excluded from the query.
9365
+ * @returns A promise that resolves to an array of Resources.
9366
+ */
9367
+ async getResourcesToSpend(quantities, excludedIds) {
9368
+ const resources = await this.provider.getResourcesToSpend(
9369
+ this.address,
9370
+ quantities,
9371
+ excludedIds
9372
+ );
9373
+ return resources.map((resource) => ({
9374
+ ...resource,
9375
+ predicate: (0, import_utils36.hexlify)(this.bytes),
9376
+ padPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9377
+ }));
9378
+ }
8975
9379
  /**
8976
9380
  * Sets the configurable constants for the predicate.
8977
9381
  *
@@ -9721,7 +10125,7 @@ __publicField(Fuel, "defaultConfig", {});
9721
10125
  WalletLocked,
9722
10126
  WalletManager,
9723
10127
  WalletUnlocked,
9724
- addAmountToAsset,
10128
+ addAmountToCoinQuantities,
9725
10129
  addOperation,
9726
10130
  assemblePanicError,
9727
10131
  assembleReceiptByType,
@@ -9730,10 +10134,11 @@ __publicField(Fuel, "defaultConfig", {});
9730
10134
  assets,
9731
10135
  buildBlockExplorerUrl,
9732
10136
  cacheFor,
10137
+ cacheTxInputsFromOwner,
10138
+ calculateGasFee,
9733
10139
  calculateMetadataGasForTxCreate,
9734
10140
  calculateMetadataGasForTxScript,
9735
- calculatePriceWithFactor,
9736
- calculateTransactionFee,
10141
+ calculateTXFeeForSummary,
9737
10142
  coinQuantityfy,
9738
10143
  deferPromise,
9739
10144
  dispatchFuelConnectorEvent,
@@ -9793,6 +10198,8 @@ __publicField(Fuel, "defaultConfig", {});
9793
10198
  isTypeCreate,
9794
10199
  isTypeMint,
9795
10200
  isTypeScript,
10201
+ isTypeUpgrade,
10202
+ isTypeUpload,
9796
10203
  normalizeJSON,
9797
10204
  outputify,
9798
10205
  processGqlReceipt,