@fuel-ts/account 0.84.0 → 0.86.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 (63) hide show
  1. package/dist/account.d.ts +6 -6
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  4. package/dist/index.global.js +1878 -2996
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +565 -512
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +380 -342
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  11. package/dist/mnemonic/utils.d.ts +0 -1
  12. package/dist/mnemonic/utils.d.ts.map +1 -1
  13. package/dist/predicate/predicate.d.ts +9 -2
  14. package/dist/predicate/predicate.d.ts.map +1 -1
  15. package/dist/providers/__generated__/operations.d.ts +346 -552
  16. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  17. package/dist/providers/assets/assets.d.ts +9 -0
  18. package/dist/providers/assets/assets.d.ts.map +1 -0
  19. package/dist/providers/assets/index.d.ts +1 -2
  20. package/dist/providers/assets/index.d.ts.map +1 -1
  21. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
  22. package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
  23. package/dist/providers/assets/utils/index.d.ts +1 -0
  24. package/dist/providers/assets/utils/index.d.ts.map +1 -1
  25. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -1
  26. package/dist/providers/coin.d.ts +0 -1
  27. package/dist/providers/coin.d.ts.map +1 -1
  28. package/dist/providers/message.d.ts +0 -1
  29. package/dist/providers/message.d.ts.map +1 -1
  30. package/dist/providers/provider.d.ts +6 -10
  31. package/dist/providers/provider.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/helpers.d.ts +4 -0
  33. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/index.d.ts +1 -0
  35. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/input.d.ts +0 -2
  37. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  38. package/dist/providers/transaction-request/transaction-request.d.ts +2 -1
  39. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  40. package/dist/providers/transaction-request/utils.d.ts +0 -4
  41. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/call.d.ts +1 -1
  43. package/dist/providers/transaction-summary/call.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/receipt.d.ts +2 -2
  45. package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
  46. package/dist/providers/transaction-summary/types.d.ts +5 -13
  47. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  48. package/dist/providers/utils/extract-tx-error.d.ts +2 -2
  49. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
  50. package/dist/providers/utils/gas.d.ts.map +1 -1
  51. package/dist/providers/utils/receipts.d.ts +2 -2
  52. package/dist/providers/utils/receipts.d.ts.map +1 -1
  53. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  54. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  55. package/dist/test-utils.global.js +1628 -2758
  56. package/dist/test-utils.global.js.map +1 -1
  57. package/dist/test-utils.js +523 -499
  58. package/dist/test-utils.js.map +1 -1
  59. package/dist/test-utils.mjs +353 -329
  60. package/dist/test-utils.mjs.map +1 -1
  61. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  62. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  63. package/package.json +15 -16
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
88
88
  StorageAbstract: () => StorageAbstract,
89
89
  TransactionResponse: () => TransactionResponse,
90
90
  TransactionStatus: () => TransactionStatus,
91
- TransactionType: () => import_transactions6.TransactionType,
91
+ TransactionType: () => import_transactions7.TransactionType,
92
92
  TransactionTypeName: () => TransactionTypeName,
93
93
  Vault: () => Vault,
94
94
  Wallet: () => Wallet,
@@ -104,7 +104,8 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
107
+ cacheRequestInputsResources: () => cacheRequestInputsResources,
108
+ cacheRequestInputsResourcesFromOwner: () => cacheRequestInputsResourcesFromOwner,
108
109
  calculateGasFee: () => calculateGasFee,
109
110
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
111
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
@@ -116,7 +117,9 @@ __export(src_exports, {
116
117
  extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
117
118
  extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
118
119
  extractTxError: () => extractTxError,
120
+ fuelAssetsBaseUrl: () => fuelAssetsBaseUrl,
119
121
  gasUsedByInputs: () => gasUsedByInputs,
122
+ getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
120
123
  getAssetEth: () => getAssetEth,
121
124
  getAssetFuel: () => getAssetFuel,
122
125
  getAssetNetwork: () => getAssetNetwork,
@@ -151,6 +154,7 @@ __export(src_exports, {
151
154
  getReceiptsMessageOut: () => getReceiptsMessageOut,
152
155
  getReceiptsTransferOut: () => getReceiptsTransferOut,
153
156
  getReceiptsWithMissingData: () => getReceiptsWithMissingData,
157
+ getRequestInputResourceOwner: () => getRequestInputResourceOwner,
154
158
  getTransactionStatusName: () => getTransactionStatusName,
155
159
  getTransactionSummary: () => getTransactionSummary,
156
160
  getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
@@ -164,6 +168,10 @@ __export(src_exports, {
164
168
  isMessage: () => isMessage,
165
169
  isRawCoin: () => isRawCoin,
166
170
  isRawMessage: () => isRawMessage,
171
+ isRequestInputCoin: () => isRequestInputCoin,
172
+ isRequestInputMessage: () => isRequestInputMessage,
173
+ isRequestInputResource: () => isRequestInputResource,
174
+ isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
167
175
  isType: () => isType,
168
176
  isTypeCreate: () => isTypeCreate,
169
177
  isTypeMint: () => isTypeMint,
@@ -174,6 +182,7 @@ __export(src_exports, {
174
182
  outputify: () => outputify,
175
183
  processGqlReceipt: () => processGqlReceipt,
176
184
  processGraphqlStatus: () => processGraphqlStatus,
185
+ rawAssets: () => rawAssets,
177
186
  resolveGasDependentCosts: () => resolveGasDependentCosts,
178
187
  resolveIconPaths: () => resolveIconPaths,
179
188
  returnZeroScript: () => returnZeroScript,
@@ -189,8 +198,8 @@ module.exports = __toCommonJS(src_exports);
189
198
  var import_address4 = require("@fuel-ts/address");
190
199
  var import_errors16 = require("@fuel-ts/errors");
191
200
  var import_interfaces = require("@fuel-ts/interfaces");
192
- var import_math21 = require("@fuel-ts/math");
193
- var import_utils27 = require("@fuel-ts/utils");
201
+ var import_math20 = require("@fuel-ts/math");
202
+ var import_utils28 = require("@fuel-ts/utils");
194
203
  var import_ramda4 = require("ramda");
195
204
 
196
205
  // src/providers/coin-quantity.ts
@@ -232,7 +241,7 @@ var addAmountToCoinQuantities = (params) => {
232
241
  var import_address3 = require("@fuel-ts/address");
233
242
  var import_errors14 = require("@fuel-ts/errors");
234
243
  var import_math17 = require("@fuel-ts/math");
235
- var import_transactions19 = require("@fuel-ts/transactions");
244
+ var import_transactions20 = require("@fuel-ts/transactions");
236
245
  var import_utils22 = require("@fuel-ts/utils");
237
246
  var import_versions = require("@fuel-ts/versions");
238
247
  var import_utils23 = require("@noble/curves/abstract/utils");
@@ -241,7 +250,7 @@ var import_ramda3 = require("ramda");
241
250
 
242
251
  // src/providers/__generated__/operations.ts
243
252
  var import_graphql_tag = __toESM(require("graphql-tag"));
244
- var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
253
+ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
245
254
  fragment transactionStatusSubscriptionFragment on TransactionStatus {
246
255
  type: __typename
247
256
  ... on SqueezedOutStatus {
@@ -249,7 +258,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.defaul
249
258
  }
250
259
  }
251
260
  `;
252
- var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
261
+ var SubmittedStatusFragmentDoc = import_graphql_tag.default`
262
+ fragment SubmittedStatusFragment on SubmittedStatus {
263
+ type: __typename
264
+ time
265
+ }
266
+ `;
267
+ var ReceiptFragmentDoc = import_graphql_tag.default`
253
268
  fragment receiptFragment on Receipt {
254
269
  id
255
270
  pc
@@ -281,45 +296,65 @@ var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
281
296
  subId
282
297
  }
283
298
  `;
284
- var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
- fragment transactionStatusFragment on TransactionStatus {
299
+ var SuccessStatusFragmentDoc = import_graphql_tag.default`
300
+ fragment SuccessStatusFragment on SuccessStatus {
301
+ type: __typename
302
+ block {
303
+ id
304
+ }
305
+ time
306
+ programState {
307
+ returnType
308
+ data
309
+ }
310
+ receipts {
311
+ ...receiptFragment
312
+ }
313
+ totalGas
314
+ totalFee
315
+ }
316
+ ${ReceiptFragmentDoc}`;
317
+ var FailureStatusFragmentDoc = import_graphql_tag.default`
318
+ fragment FailureStatusFragment on FailureStatus {
319
+ type: __typename
320
+ block {
321
+ id
322
+ }
323
+ totalGas
324
+ totalFee
325
+ time
326
+ reason
327
+ receipts {
328
+ ...receiptFragment
329
+ }
330
+ }
331
+ ${ReceiptFragmentDoc}`;
332
+ var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
333
+ fragment SqueezedOutStatusFragment on SqueezedOutStatus {
286
334
  type: __typename
335
+ reason
336
+ }
337
+ `;
338
+ var TransactionStatusFragmentDoc = import_graphql_tag.default`
339
+ fragment transactionStatusFragment on TransactionStatus {
287
340
  ... on SubmittedStatus {
288
- time
341
+ ...SubmittedStatusFragment
289
342
  }
290
343
  ... on SuccessStatus {
291
- block {
292
- id
293
- }
294
- time
295
- programState {
296
- returnType
297
- data
298
- }
299
- receipts {
300
- ...receiptFragment
301
- }
302
- totalGas
303
- totalFee
344
+ ...SuccessStatusFragment
304
345
  }
305
346
  ... on FailureStatus {
306
- block {
307
- id
308
- }
309
- totalGas
310
- totalFee
311
- time
312
- reason
313
- receipts {
314
- ...receiptFragment
315
- }
347
+ ...FailureStatusFragment
316
348
  }
317
349
  ... on SqueezedOutStatus {
318
- reason
350
+ ...SqueezedOutStatusFragment
319
351
  }
320
352
  }
321
- ${ReceiptFragmentFragmentDoc}`;
322
- var TransactionFragmentFragmentDoc = import_graphql_tag.default`
353
+ ${SubmittedStatusFragmentDoc}
354
+ ${SuccessStatusFragmentDoc}
355
+ ${FailureStatusFragmentDoc}
356
+ ${SqueezedOutStatusFragmentDoc}`;
357
+ var TransactionFragmentDoc = import_graphql_tag.default`
323
358
  fragment transactionFragment on Transaction {
324
359
  id
325
360
  rawPayload
@@ -327,8 +362,8 @@ var TransactionFragmentFragmentDoc = import_graphql_tag.default`
327
362
  ...transactionStatusFragment
328
363
  }
329
364
  }
330
- ${TransactionStatusFragmentFragmentDoc}`;
331
- var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
365
+ ${TransactionStatusFragmentDoc}`;
366
+ var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
332
367
  fragment inputEstimatePredicatesFragment on Input {
333
368
  ... on InputCoin {
334
369
  predicateGasUsed
@@ -338,14 +373,14 @@ var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
338
373
  }
339
374
  }
340
375
  `;
341
- var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
376
+ var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
342
377
  fragment transactionEstimatePredicatesFragment on Transaction {
343
378
  inputs {
344
379
  ...inputEstimatePredicatesFragment
345
380
  }
346
381
  }
347
- ${InputEstimatePredicatesFragmentFragmentDoc}`;
348
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
382
+ ${InputEstimatePredicatesFragmentDoc}`;
383
+ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
349
384
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
350
385
  totalGas
351
386
  totalFee
@@ -356,7 +391,7 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
356
391
  }
357
392
  }
358
393
  `;
359
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
394
+ var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
360
395
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
361
396
  totalGas
362
397
  totalFee
@@ -366,7 +401,7 @@ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
366
401
  }
367
402
  }
368
403
  `;
369
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
404
+ var DryRunTransactionStatusFragmentDoc = import_graphql_tag.default`
370
405
  fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
371
406
  ... on DryRunFailureStatus {
372
407
  ...dryRunFailureStatusFragment
@@ -375,9 +410,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
375
410
  ...dryRunSuccessStatusFragment
376
411
  }
377
412
  }
378
- ${DryRunFailureStatusFragmentFragmentDoc}
379
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
380
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
413
+ ${DryRunFailureStatusFragmentDoc}
414
+ ${DryRunSuccessStatusFragmentDoc}`;
415
+ var DryRunTransactionExecutionStatusFragmentDoc = import_graphql_tag.default`
381
416
  fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
382
417
  id
383
418
  status {
@@ -387,11 +422,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.def
387
422
  ...receiptFragment
388
423
  }
389
424
  }
390
- ${DryRunTransactionStatusFragmentFragmentDoc}
391
- ${ReceiptFragmentFragmentDoc}`;
392
- var CoinFragmentFragmentDoc = import_graphql_tag.default`
425
+ ${DryRunTransactionStatusFragmentDoc}
426
+ ${ReceiptFragmentDoc}`;
427
+ var CoinFragmentDoc = import_graphql_tag.default`
393
428
  fragment coinFragment on Coin {
394
- __typename
429
+ type: __typename
395
430
  utxoId
396
431
  owner
397
432
  amount
@@ -400,9 +435,9 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
400
435
  txCreatedIdx
401
436
  }
402
437
  `;
403
- var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
438
+ var MessageCoinFragmentDoc = import_graphql_tag.default`
404
439
  fragment messageCoinFragment on MessageCoin {
405
- __typename
440
+ type: __typename
406
441
  sender
407
442
  recipient
408
443
  nonce
@@ -411,7 +446,7 @@ var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
411
446
  daHeight
412
447
  }
413
448
  `;
414
- var MessageFragmentFragmentDoc = import_graphql_tag.default`
449
+ var MessageFragmentDoc = import_graphql_tag.default`
415
450
  fragment messageFragment on Message {
416
451
  amount
417
452
  sender
@@ -421,7 +456,7 @@ var MessageFragmentFragmentDoc = import_graphql_tag.default`
421
456
  daHeight
422
457
  }
423
458
  `;
424
- var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
459
+ var MessageProofFragmentDoc = import_graphql_tag.default`
425
460
  fragment messageProofFragment on MessageProof {
426
461
  messageProof {
427
462
  proofSet
@@ -468,14 +503,14 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
468
503
  data
469
504
  }
470
505
  `;
471
- var BalanceFragmentFragmentDoc = import_graphql_tag.default`
506
+ var BalanceFragmentDoc = import_graphql_tag.default`
472
507
  fragment balanceFragment on Balance {
473
508
  owner
474
509
  amount
475
510
  assetId
476
511
  }
477
512
  `;
478
- var BlockFragmentFragmentDoc = import_graphql_tag.default`
513
+ var BlockFragmentDoc = import_graphql_tag.default`
479
514
  fragment blockFragment on Block {
480
515
  id
481
516
  height
@@ -487,7 +522,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
487
522
  }
488
523
  }
489
524
  `;
490
- var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
525
+ var TxParametersFragmentDoc = import_graphql_tag.default`
491
526
  fragment TxParametersFragment on TxParameters {
492
527
  version
493
528
  maxInputs
@@ -498,7 +533,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
498
533
  maxBytecodeSubsections
499
534
  }
500
535
  `;
501
- var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
536
+ var PredicateParametersFragmentDoc = import_graphql_tag.default`
502
537
  fragment PredicateParametersFragment on PredicateParameters {
503
538
  version
504
539
  maxPredicateLength
@@ -507,41 +542,42 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
507
542
  maxMessageDataLength
508
543
  }
509
544
  `;
510
- var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
545
+ var ScriptParametersFragmentDoc = import_graphql_tag.default`
511
546
  fragment ScriptParametersFragment on ScriptParameters {
512
547
  version
513
548
  maxScriptLength
514
549
  maxScriptDataLength
515
550
  }
516
551
  `;
517
- var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
552
+ var ContractParametersFragmentDoc = import_graphql_tag.default`
518
553
  fragment ContractParametersFragment on ContractParameters {
519
554
  version
520
555
  contractMaxSize
521
556
  maxStorageSlots
522
557
  }
523
558
  `;
524
- var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
559
+ var FeeParametersFragmentDoc = import_graphql_tag.default`
525
560
  fragment FeeParametersFragment on FeeParameters {
526
561
  version
527
562
  gasPriceFactor
528
563
  gasPerByte
529
564
  }
530
565
  `;
531
- var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
566
+ var DependentCostFragmentDoc = import_graphql_tag.default`
532
567
  fragment DependentCostFragment on DependentCost {
533
- __typename
534
568
  ... on LightOperation {
569
+ type: __typename
535
570
  base
536
571
  unitsPerGas
537
572
  }
538
573
  ... on HeavyOperation {
574
+ type: __typename
539
575
  base
540
576
  gasPerUnit
541
577
  }
542
578
  }
543
579
  `;
544
- var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
580
+ var GasCostsFragmentDoc = import_graphql_tag.default`
545
581
  fragment GasCostsFragment on GasCosts {
546
582
  version
547
583
  add
@@ -697,8 +733,8 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
697
733
  }
698
734
  newStoragePerByte
699
735
  }
700
- ${DependentCostFragmentFragmentDoc}`;
701
- var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
736
+ ${DependentCostFragmentDoc}`;
737
+ var ConsensusParametersFragmentDoc = import_graphql_tag.default`
702
738
  fragment consensusParametersFragment on ConsensusParameters {
703
739
  version
704
740
  txParams {
@@ -722,13 +758,13 @@ var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
722
758
  baseAssetId
723
759
  chainId
724
760
  }
725
- ${TxParametersFragmentFragmentDoc}
726
- ${PredicateParametersFragmentFragmentDoc}
727
- ${ScriptParametersFragmentFragmentDoc}
728
- ${ContractParametersFragmentFragmentDoc}
729
- ${FeeParametersFragmentFragmentDoc}
730
- ${GasCostsFragmentFragmentDoc}`;
731
- var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
761
+ ${TxParametersFragmentDoc}
762
+ ${PredicateParametersFragmentDoc}
763
+ ${ScriptParametersFragmentDoc}
764
+ ${ContractParametersFragmentDoc}
765
+ ${FeeParametersFragmentDoc}
766
+ ${GasCostsFragmentDoc}`;
767
+ var ChainInfoFragmentDoc = import_graphql_tag.default`
732
768
  fragment chainInfoFragment on ChainInfo {
733
769
  name
734
770
  latestBlock {
@@ -739,16 +775,16 @@ var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
739
775
  ...consensusParametersFragment
740
776
  }
741
777
  }
742
- ${BlockFragmentFragmentDoc}
743
- ${ConsensusParametersFragmentFragmentDoc}`;
744
- var ContractBalanceFragmentFragmentDoc = import_graphql_tag.default`
778
+ ${BlockFragmentDoc}
779
+ ${ConsensusParametersFragmentDoc}`;
780
+ var ContractBalanceFragmentDoc = import_graphql_tag.default`
745
781
  fragment contractBalanceFragment on ContractBalance {
746
782
  contract
747
783
  amount
748
784
  assetId
749
785
  }
750
786
  `;
751
- var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
787
+ var PageInfoFragmentDoc = import_graphql_tag.default`
752
788
  fragment pageInfoFragment on PageInfo {
753
789
  hasPreviousPage
754
790
  hasNextPage
@@ -756,7 +792,7 @@ var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
756
792
  endCursor
757
793
  }
758
794
  `;
759
- var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
795
+ var NodeInfoFragmentDoc = import_graphql_tag.default`
760
796
  fragment nodeInfoFragment on NodeInfo {
761
797
  utxoValidation
762
798
  vmBacktrace
@@ -765,7 +801,7 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
765
801
  nodeVersion
766
802
  }
767
803
  `;
768
- var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
804
+ var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
769
805
  fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
770
806
  ... on RelayedTransactionFailed {
771
807
  blockHeight
@@ -786,28 +822,28 @@ var GetNodeInfoDocument = import_graphql_tag.default`
786
822
  ...nodeInfoFragment
787
823
  }
788
824
  }
789
- ${NodeInfoFragmentFragmentDoc}`;
825
+ ${NodeInfoFragmentDoc}`;
790
826
  var GetChainDocument = import_graphql_tag.default`
791
827
  query getChain {
792
828
  chain {
793
829
  ...chainInfoFragment
794
830
  }
795
831
  }
796
- ${ChainInfoFragmentFragmentDoc}`;
832
+ ${ChainInfoFragmentDoc}`;
797
833
  var GetTransactionDocument = import_graphql_tag.default`
798
834
  query getTransaction($transactionId: TransactionId!) {
799
835
  transaction(id: $transactionId) {
800
836
  ...transactionFragment
801
837
  }
802
838
  }
803
- ${TransactionFragmentFragmentDoc}`;
839
+ ${TransactionFragmentDoc}`;
804
840
  var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
805
841
  query getTransactionWithReceipts($transactionId: TransactionId!) {
806
842
  transaction(id: $transactionId) {
807
843
  ...transactionFragment
808
844
  }
809
845
  }
810
- ${TransactionFragmentFragmentDoc}`;
846
+ ${TransactionFragmentDoc}`;
811
847
  var GetTransactionsDocument = import_graphql_tag.default`
812
848
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
813
849
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -818,7 +854,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
818
854
  }
819
855
  }
820
856
  }
821
- ${TransactionFragmentFragmentDoc}`;
857
+ ${TransactionFragmentDoc}`;
822
858
  var GetTransactionsByOwnerDocument = import_graphql_tag.default`
823
859
  query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
824
860
  transactionsByOwner(
@@ -838,22 +874,22 @@ var GetTransactionsByOwnerDocument = import_graphql_tag.default`
838
874
  }
839
875
  }
840
876
  }
841
- ${PageInfoFragmentFragmentDoc}
842
- ${TransactionFragmentFragmentDoc}`;
877
+ ${PageInfoFragmentDoc}
878
+ ${TransactionFragmentDoc}`;
843
879
  var EstimatePredicatesDocument = import_graphql_tag.default`
844
880
  query estimatePredicates($encodedTransaction: HexString!) {
845
881
  estimatePredicates(tx: $encodedTransaction) {
846
882
  ...transactionEstimatePredicatesFragment
847
883
  }
848
884
  }
849
- ${TransactionEstimatePredicatesFragmentFragmentDoc}`;
885
+ ${TransactionEstimatePredicatesFragmentDoc}`;
850
886
  var GetBlockDocument = import_graphql_tag.default`
851
887
  query getBlock($blockId: BlockId, $height: U32) {
852
888
  block(id: $blockId, height: $height) {
853
889
  ...blockFragment
854
890
  }
855
891
  }
856
- ${BlockFragmentFragmentDoc}`;
892
+ ${BlockFragmentDoc}`;
857
893
  var GetBlockWithTransactionsDocument = import_graphql_tag.default`
858
894
  query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
859
895
  block(id: $blockId, height: $blockHeight) {
@@ -863,8 +899,8 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
863
899
  }
864
900
  }
865
901
  }
866
- ${BlockFragmentFragmentDoc}
867
- ${TransactionFragmentFragmentDoc}`;
902
+ ${BlockFragmentDoc}
903
+ ${TransactionFragmentDoc}`;
868
904
  var GetBlocksDocument = import_graphql_tag.default`
869
905
  query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
870
906
  blocks(after: $after, before: $before, first: $first, last: $last) {
@@ -875,14 +911,14 @@ var GetBlocksDocument = import_graphql_tag.default`
875
911
  }
876
912
  }
877
913
  }
878
- ${BlockFragmentFragmentDoc}`;
914
+ ${BlockFragmentDoc}`;
879
915
  var GetCoinDocument = import_graphql_tag.default`
880
916
  query getCoin($coinId: UtxoId!) {
881
917
  coin(utxoId: $coinId) {
882
918
  ...coinFragment
883
919
  }
884
920
  }
885
- ${CoinFragmentFragmentDoc}`;
921
+ ${CoinFragmentDoc}`;
886
922
  var GetCoinsDocument = import_graphql_tag.default`
887
923
  query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
888
924
  coins(
@@ -899,7 +935,7 @@ var GetCoinsDocument = import_graphql_tag.default`
899
935
  }
900
936
  }
901
937
  }
902
- ${CoinFragmentFragmentDoc}`;
938
+ ${CoinFragmentDoc}`;
903
939
  var GetCoinsToSpendDocument = import_graphql_tag.default`
904
940
  query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
905
941
  coinsToSpend(
@@ -911,8 +947,8 @@ var GetCoinsToSpendDocument = import_graphql_tag.default`
911
947
  ...messageCoinFragment
912
948
  }
913
949
  }
914
- ${CoinFragmentFragmentDoc}
915
- ${MessageCoinFragmentFragmentDoc}`;
950
+ ${CoinFragmentDoc}
951
+ ${MessageCoinFragmentDoc}`;
916
952
  var GetContractDocument = import_graphql_tag.default`
917
953
  query getContract($contractId: ContractId!) {
918
954
  contract(id: $contractId) {
@@ -927,14 +963,14 @@ var GetContractBalanceDocument = import_graphql_tag.default`
927
963
  ...contractBalanceFragment
928
964
  }
929
965
  }
930
- ${ContractBalanceFragmentFragmentDoc}`;
966
+ ${ContractBalanceFragmentDoc}`;
931
967
  var GetBalanceDocument = import_graphql_tag.default`
932
968
  query getBalance($owner: Address!, $assetId: AssetId!) {
933
969
  balance(owner: $owner, assetId: $assetId) {
934
970
  ...balanceFragment
935
971
  }
936
972
  }
937
- ${BalanceFragmentFragmentDoc}`;
973
+ ${BalanceFragmentDoc}`;
938
974
  var GetLatestGasPriceDocument = import_graphql_tag.default`
939
975
  query getLatestGasPrice {
940
976
  latestGasPrice {
@@ -965,7 +1001,7 @@ var GetBalancesDocument = import_graphql_tag.default`
965
1001
  }
966
1002
  }
967
1003
  }
968
- ${BalanceFragmentFragmentDoc}`;
1004
+ ${BalanceFragmentDoc}`;
969
1005
  var GetMessagesDocument = import_graphql_tag.default`
970
1006
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
971
1007
  messages(
@@ -982,7 +1018,7 @@ var GetMessagesDocument = import_graphql_tag.default`
982
1018
  }
983
1019
  }
984
1020
  }
985
- ${MessageFragmentFragmentDoc}`;
1021
+ ${MessageFragmentDoc}`;
986
1022
  var GetMessageProofDocument = import_graphql_tag.default`
987
1023
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
988
1024
  messageProof(
@@ -994,7 +1030,7 @@ var GetMessageProofDocument = import_graphql_tag.default`
994
1030
  ...messageProofFragment
995
1031
  }
996
1032
  }
997
- ${MessageProofFragmentFragmentDoc}`;
1033
+ ${MessageProofFragmentDoc}`;
998
1034
  var GetMessageStatusDocument = import_graphql_tag.default`
999
1035
  query getMessageStatus($nonce: Nonce!) {
1000
1036
  messageStatus(nonce: $nonce) {
@@ -1008,14 +1044,14 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1008
1044
  ...relayedTransactionStatusFragment
1009
1045
  }
1010
1046
  }
1011
- ${RelayedTransactionStatusFragmentFragmentDoc}`;
1047
+ ${RelayedTransactionStatusFragmentDoc}`;
1012
1048
  var DryRunDocument = import_graphql_tag.default`
1013
1049
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
1014
1050
  dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
1015
1051
  ...dryRunTransactionExecutionStatusFragment
1016
1052
  }
1017
1053
  }
1018
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
1054
+ ${DryRunTransactionExecutionStatusFragmentDoc}`;
1019
1055
  var SubmitDocument = import_graphql_tag.default`
1020
1056
  mutation submit($encodedTransaction: HexString!) {
1021
1057
  submit(tx: $encodedTransaction) {
@@ -1037,21 +1073,21 @@ var GetMessageByNonceDocument = import_graphql_tag.default`
1037
1073
  ...messageFragment
1038
1074
  }
1039
1075
  }
1040
- ${MessageFragmentFragmentDoc}`;
1076
+ ${MessageFragmentDoc}`;
1041
1077
  var SubmitAndAwaitDocument = import_graphql_tag.default`
1042
1078
  subscription submitAndAwait($encodedTransaction: HexString!) {
1043
1079
  submitAndAwait(tx: $encodedTransaction) {
1044
1080
  ...transactionStatusSubscriptionFragment
1045
1081
  }
1046
1082
  }
1047
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
1083
+ ${TransactionStatusSubscriptionFragmentDoc}`;
1048
1084
  var StatusChangeDocument = import_graphql_tag.default`
1049
1085
  subscription statusChange($transactionId: TransactionId!) {
1050
1086
  statusChange(id: $transactionId) {
1051
1087
  ...transactionStatusSubscriptionFragment
1052
1088
  }
1053
1089
  }
1054
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
1090
+ ${TransactionStatusSubscriptionFragmentDoc}`;
1055
1091
  function getSdk(requester) {
1056
1092
  return {
1057
1093
  getVersion(variables, options) {
@@ -1422,8 +1458,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1422
1458
  var import_address = require("@fuel-ts/address");
1423
1459
  var import_configs6 = require("@fuel-ts/address/configs");
1424
1460
  var import_crypto = require("@fuel-ts/crypto");
1425
- var import_math7 = require("@fuel-ts/math");
1426
- var import_transactions6 = require("@fuel-ts/transactions");
1461
+ var import_math8 = require("@fuel-ts/math");
1462
+ var import_transactions7 = require("@fuel-ts/transactions");
1427
1463
  var import_utils9 = require("@fuel-ts/utils");
1428
1464
 
1429
1465
  // src/providers/resource.ts
@@ -1714,10 +1750,9 @@ var getGasUsedFromReceipts = (receipts) => {
1714
1750
  function resolveGasDependentCosts(byteSize, gasDependentCost) {
1715
1751
  const base = (0, import_math5.bn)(gasDependentCost.base);
1716
1752
  let dependentValue = (0, import_math5.bn)(0);
1717
- if (gasDependentCost.__typename === "LightOperation") {
1753
+ if ("unitsPerGas" in gasDependentCost) {
1718
1754
  dependentValue = (0, import_math5.bn)(byteSize).div((0, import_math5.bn)(gasDependentCost.unitsPerGas));
1719
- }
1720
- if (gasDependentCost.__typename === "HeavyOperation") {
1755
+ } else {
1721
1756
  dependentValue = (0, import_math5.bn)(byteSize).mul((0, import_math5.bn)(gasDependentCost.gasPerUnit));
1722
1757
  }
1723
1758
  return base.add(dependentValue);
@@ -1931,6 +1966,52 @@ var NoWitnessByOwnerError = class extends Error {
1931
1966
  name = "NoWitnessByOwnerError";
1932
1967
  };
1933
1968
 
1969
+ // src/providers/transaction-request/helpers.ts
1970
+ var import_math7 = require("@fuel-ts/math");
1971
+ var import_transactions6 = require("@fuel-ts/transactions");
1972
+ var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
1973
+ var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
1974
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1975
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1976
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1977
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1978
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
1979
+ return acc.add(input.amount);
1980
+ }
1981
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
1982
+ return acc.add(input.amount);
1983
+ }
1984
+ return acc;
1985
+ }, (0, import_math7.bn)(0));
1986
+ var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
1987
+ (cache2, input) => {
1988
+ if (isRequestInputCoin(input)) {
1989
+ cache2.utxos.push(input.id);
1990
+ } else {
1991
+ cache2.messages.push(input.nonce);
1992
+ }
1993
+ return cache2;
1994
+ },
1995
+ {
1996
+ utxos: [],
1997
+ messages: []
1998
+ }
1999
+ );
2000
+ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
2001
+ (acc, input) => {
2002
+ if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
2003
+ acc.utxos.push(input.id);
2004
+ } else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
2005
+ acc.messages.push(input.nonce);
2006
+ }
2007
+ return acc;
2008
+ },
2009
+ {
2010
+ utxos: [],
2011
+ messages: []
2012
+ }
2013
+ );
2014
+
1934
2015
  // src/providers/transaction-request/witness.ts
1935
2016
  var import_utils8 = require("@fuel-ts/utils");
1936
2017
  var witnessify = (value) => {
@@ -1971,10 +2052,10 @@ var BaseTransactionRequest = class {
1971
2052
  outputs,
1972
2053
  witnesses
1973
2054
  } = {}) {
1974
- this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
2055
+ this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
1975
2056
  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);
2057
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
2058
+ this.maxFee = (0, import_math8.bn)(maxFee);
1978
2059
  this.inputs = inputs ?? [];
1979
2060
  this.outputs = outputs ?? [];
1980
2061
  this.witnesses = witnesses ?? [];
@@ -1983,20 +2064,20 @@ var BaseTransactionRequest = class {
1983
2064
  let policyTypes = 0;
1984
2065
  const policies = [];
1985
2066
  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 });
2067
+ if ((0, import_math8.bn)(tip).gt(0)) {
2068
+ policyTypes += import_transactions7.PolicyType.Tip;
2069
+ policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
1989
2070
  }
1990
- if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
1991
- policyTypes += import_transactions6.PolicyType.WitnessLimit;
1992
- policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
2071
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
2072
+ policyTypes += import_transactions7.PolicyType.WitnessLimit;
2073
+ policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
1993
2074
  }
1994
2075
  if (maturity && maturity > 0) {
1995
- policyTypes += import_transactions6.PolicyType.Maturity;
1996
- policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
2076
+ policyTypes += import_transactions7.PolicyType.Maturity;
2077
+ policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
1997
2078
  }
1998
- policyTypes += import_transactions6.PolicyType.MaxFee;
1999
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
2079
+ policyTypes += import_transactions7.PolicyType.MaxFee;
2080
+ policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
2000
2081
  return {
2001
2082
  policyTypes,
2002
2083
  policies
@@ -2029,7 +2110,7 @@ var BaseTransactionRequest = class {
2029
2110
  * @returns The transaction bytes.
2030
2111
  */
2031
2112
  toTransactionBytes() {
2032
- return new import_transactions6.TransactionCoder().encode(this.toTransaction());
2113
+ return new import_transactions7.TransactionCoder().encode(this.toTransaction());
2033
2114
  }
2034
2115
  /**
2035
2116
  * @hidden
@@ -2120,7 +2201,7 @@ var BaseTransactionRequest = class {
2120
2201
  */
2121
2202
  getCoinInputs() {
2122
2203
  return this.inputs.filter(
2123
- (input) => input.type === import_transactions6.InputType.Coin
2204
+ (input) => input.type === import_transactions7.InputType.Coin
2124
2205
  );
2125
2206
  }
2126
2207
  /**
@@ -2130,7 +2211,7 @@ var BaseTransactionRequest = class {
2130
2211
  */
2131
2212
  getCoinOutputs() {
2132
2213
  return this.outputs.filter(
2133
- (output) => output.type === import_transactions6.OutputType.Coin
2214
+ (output) => output.type === import_transactions7.OutputType.Coin
2134
2215
  );
2135
2216
  }
2136
2217
  /**
@@ -2140,7 +2221,7 @@ var BaseTransactionRequest = class {
2140
2221
  */
2141
2222
  getChangeOutputs() {
2142
2223
  return this.outputs.filter(
2143
- (output) => output.type === import_transactions6.OutputType.Change
2224
+ (output) => output.type === import_transactions7.OutputType.Change
2144
2225
  );
2145
2226
  }
2146
2227
  /**
@@ -2152,9 +2233,9 @@ var BaseTransactionRequest = class {
2152
2233
  const ownerAddress = (0, import_address.addressify)(owner);
2153
2234
  const found = this.inputs.find((input) => {
2154
2235
  switch (input.type) {
2155
- case import_transactions6.InputType.Coin:
2236
+ case import_transactions7.InputType.Coin:
2156
2237
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
2157
- case import_transactions6.InputType.Message:
2238
+ case import_transactions7.InputType.Message:
2158
2239
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
2159
2240
  default:
2160
2241
  return false;
@@ -2169,7 +2250,7 @@ var BaseTransactionRequest = class {
2169
2250
  * @param coin - Coin resource.
2170
2251
  */
2171
2252
  addCoinInput(coin) {
2172
- const { assetId, owner, amount } = coin;
2253
+ const { assetId, owner, amount, id, predicate } = coin;
2173
2254
  let witnessIndex;
2174
2255
  if (coin.predicate) {
2175
2256
  witnessIndex = 0;
@@ -2180,13 +2261,14 @@ var BaseTransactionRequest = class {
2180
2261
  }
2181
2262
  }
2182
2263
  const input = {
2183
- ...coin,
2184
- type: import_transactions6.InputType.Coin,
2264
+ id,
2265
+ type: import_transactions7.InputType.Coin,
2185
2266
  owner: owner.toB256(),
2186
2267
  amount,
2187
2268
  assetId,
2188
2269
  txPointer: "0x00000000000000000000000000000000",
2189
- witnessIndex
2270
+ witnessIndex,
2271
+ predicate
2190
2272
  };
2191
2273
  this.pushInput(input);
2192
2274
  this.addChangeOutput(owner, assetId);
@@ -2198,7 +2280,7 @@ var BaseTransactionRequest = class {
2198
2280
  * @param message - Message resource.
2199
2281
  */
2200
2282
  addMessageInput(message) {
2201
- const { recipient, sender, amount, assetId } = message;
2283
+ const { recipient, sender, amount, predicate, nonce, assetId } = message;
2202
2284
  let witnessIndex;
2203
2285
  if (message.predicate) {
2204
2286
  witnessIndex = 0;
@@ -2209,12 +2291,13 @@ var BaseTransactionRequest = class {
2209
2291
  }
2210
2292
  }
2211
2293
  const input = {
2212
- ...message,
2213
- type: import_transactions6.InputType.Message,
2294
+ nonce,
2295
+ type: import_transactions7.InputType.Message,
2214
2296
  sender: sender.toB256(),
2215
2297
  recipient: recipient.toB256(),
2216
2298
  amount,
2217
- witnessIndex
2299
+ witnessIndex,
2300
+ predicate
2218
2301
  };
2219
2302
  this.pushInput(input);
2220
2303
  this.addChangeOutput(recipient, assetId);
@@ -2254,7 +2337,7 @@ var BaseTransactionRequest = class {
2254
2337
  */
2255
2338
  addCoinOutput(to, amount, assetId) {
2256
2339
  this.pushOutput({
2257
- type: import_transactions6.OutputType.Coin,
2340
+ type: import_transactions7.OutputType.Coin,
2258
2341
  to: (0, import_address.addressify)(to).toB256(),
2259
2342
  amount,
2260
2343
  assetId
@@ -2270,7 +2353,7 @@ var BaseTransactionRequest = class {
2270
2353
  addCoinOutputs(to, quantities) {
2271
2354
  quantities.map(coinQuantityfy).forEach((quantity) => {
2272
2355
  this.pushOutput({
2273
- type: import_transactions6.OutputType.Coin,
2356
+ type: import_transactions7.OutputType.Coin,
2274
2357
  to: (0, import_address.addressify)(to).toB256(),
2275
2358
  amount: quantity.amount,
2276
2359
  assetId: quantity.assetId
@@ -2290,7 +2373,7 @@ var BaseTransactionRequest = class {
2290
2373
  );
2291
2374
  if (!changeOutput) {
2292
2375
  this.pushOutput({
2293
- type: import_transactions6.OutputType.Change,
2376
+ type: import_transactions7.OutputType.Change,
2294
2377
  to: (0, import_address.addressify)(to).toB256(),
2295
2378
  assetId
2296
2379
  });
@@ -2361,7 +2444,7 @@ var BaseTransactionRequest = class {
2361
2444
  const assetInput = findAssetInput(assetId);
2362
2445
  let usedQuantity = quantity;
2363
2446
  if (assetId === baseAssetId) {
2364
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2447
+ usedQuantity = (0, import_math8.bn)("1000000000000000000");
2365
2448
  }
2366
2449
  if (assetInput && "assetId" in assetInput) {
2367
2450
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
@@ -2373,13 +2456,13 @@ var BaseTransactionRequest = class {
2373
2456
  amount: usedQuantity,
2374
2457
  assetId,
2375
2458
  owner: resourcesOwner || import_address.Address.fromRandom(),
2376
- blockCreated: (0, import_math7.bn)(1),
2377
- txCreatedIdx: (0, import_math7.bn)(1)
2459
+ blockCreated: (0, import_math8.bn)(1),
2460
+ txCreatedIdx: (0, import_math8.bn)(1)
2378
2461
  }
2379
2462
  ]);
2380
2463
  }
2381
2464
  };
2382
- updateAssetInput(baseAssetId, (0, import_math7.bn)(1e11));
2465
+ updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
2383
2466
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2384
2467
  }
2385
2468
  /**
@@ -2390,7 +2473,7 @@ var BaseTransactionRequest = class {
2390
2473
  */
2391
2474
  getCoinOutputsQuantities() {
2392
2475
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2393
- amount: (0, import_math7.bn)(amount),
2476
+ amount: (0, import_math8.bn)(amount),
2394
2477
  assetId: assetId.toString()
2395
2478
  }));
2396
2479
  return coinsQuantities;
@@ -2404,73 +2487,75 @@ var BaseTransactionRequest = class {
2404
2487
  toJSON() {
2405
2488
  return normalizeJSON(this);
2406
2489
  }
2490
+ removeWitness(index) {
2491
+ this.witnesses.splice(index, 1);
2492
+ this.adjustWitnessIndexes(index);
2493
+ }
2494
+ adjustWitnessIndexes(removedIndex) {
2495
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2496
+ if (input.witnessIndex > removedIndex) {
2497
+ input.witnessIndex -= 1;
2498
+ }
2499
+ });
2500
+ }
2407
2501
  updatePredicateGasUsed(inputs) {
2408
2502
  this.inputs.forEach((i) => {
2409
2503
  let correspondingInput;
2410
2504
  switch (i.type) {
2411
- case import_transactions6.InputType.Coin:
2412
- correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2505
+ case import_transactions7.InputType.Coin:
2506
+ correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
2413
2507
  break;
2414
- case import_transactions6.InputType.Message:
2508
+ case import_transactions7.InputType.Message:
2415
2509
  correspondingInput = inputs.find(
2416
- (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2510
+ (x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
2417
2511
  );
2418
2512
  break;
2419
2513
  default:
2420
2514
  return;
2421
2515
  }
2422
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2516
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2423
2517
  i.predicate = correspondingInput.predicate;
2424
2518
  i.predicateData = correspondingInput.predicateData;
2425
2519
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
2426
2520
  }
2427
2521
  });
2428
2522
  }
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
- }
2438
2523
  };
2439
2524
 
2440
2525
  // src/providers/transaction-request/create-transaction-request.ts
2441
2526
  var import_configs8 = require("@fuel-ts/address/configs");
2442
- var import_math9 = require("@fuel-ts/math");
2443
- var import_transactions8 = require("@fuel-ts/transactions");
2527
+ var import_math10 = require("@fuel-ts/math");
2528
+ var import_transactions9 = require("@fuel-ts/transactions");
2444
2529
  var import_utils13 = require("@fuel-ts/utils");
2445
2530
 
2446
2531
  // src/providers/transaction-request/hash-transaction.ts
2447
2532
  var import_configs7 = require("@fuel-ts/address/configs");
2448
2533
  var import_hasher = require("@fuel-ts/hasher");
2449
- var import_math8 = require("@fuel-ts/math");
2450
- var import_transactions7 = require("@fuel-ts/transactions");
2534
+ var import_math9 = require("@fuel-ts/math");
2535
+ var import_transactions8 = require("@fuel-ts/transactions");
2451
2536
  var import_utils11 = require("@fuel-ts/utils");
2452
2537
  var import_ramda2 = require("ramda");
2453
2538
  function hashTransaction(transactionRequest, chainId) {
2454
2539
  const transaction = transactionRequest.toTransaction();
2455
- if (transaction.type === import_transactions7.TransactionType.Script) {
2540
+ if (transaction.type === import_transactions8.TransactionType.Script) {
2456
2541
  transaction.receiptsRoot = import_configs7.ZeroBytes32;
2457
2542
  }
2458
2543
  transaction.inputs = transaction.inputs.map((input) => {
2459
2544
  const inputClone = (0, import_ramda2.clone)(input);
2460
2545
  switch (inputClone.type) {
2461
- case import_transactions7.InputType.Coin: {
2546
+ case import_transactions8.InputType.Coin: {
2462
2547
  inputClone.txPointer = {
2463
2548
  blockHeight: 0,
2464
2549
  txIndex: 0
2465
2550
  };
2466
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2551
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2467
2552
  return inputClone;
2468
2553
  }
2469
- case import_transactions7.InputType.Message: {
2470
- inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2554
+ case import_transactions8.InputType.Message: {
2555
+ inputClone.predicateGasUsed = (0, import_math9.bn)(0);
2471
2556
  return inputClone;
2472
2557
  }
2473
- case import_transactions7.InputType.Contract: {
2558
+ case import_transactions8.InputType.Contract: {
2474
2559
  inputClone.txPointer = {
2475
2560
  blockHeight: 0,
2476
2561
  txIndex: 0
@@ -2488,18 +2573,18 @@ function hashTransaction(transactionRequest, chainId) {
2488
2573
  transaction.outputs = transaction.outputs.map((output) => {
2489
2574
  const outputClone = (0, import_ramda2.clone)(output);
2490
2575
  switch (outputClone.type) {
2491
- case import_transactions7.OutputType.Contract: {
2576
+ case import_transactions8.OutputType.Contract: {
2492
2577
  outputClone.balanceRoot = import_configs7.ZeroBytes32;
2493
2578
  outputClone.stateRoot = import_configs7.ZeroBytes32;
2494
2579
  return outputClone;
2495
2580
  }
2496
- case import_transactions7.OutputType.Change: {
2497
- outputClone.amount = (0, import_math8.bn)(0);
2581
+ case import_transactions8.OutputType.Change: {
2582
+ outputClone.amount = (0, import_math9.bn)(0);
2498
2583
  return outputClone;
2499
2584
  }
2500
- case import_transactions7.OutputType.Variable: {
2585
+ case import_transactions8.OutputType.Variable: {
2501
2586
  outputClone.to = import_configs7.ZeroBytes32;
2502
- outputClone.amount = (0, import_math8.bn)(0);
2587
+ outputClone.amount = (0, import_math9.bn)(0);
2503
2588
  outputClone.assetId = import_configs7.ZeroBytes32;
2504
2589
  return outputClone;
2505
2590
  }
@@ -2510,7 +2595,7 @@ function hashTransaction(transactionRequest, chainId) {
2510
2595
  transaction.witnessesCount = 0;
2511
2596
  transaction.witnesses = [];
2512
2597
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2513
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2598
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
2514
2599
  return (0, import_hasher.sha256)(concatenatedData);
2515
2600
  }
2516
2601
 
@@ -2546,7 +2631,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2546
2631
  return new this(obj);
2547
2632
  }
2548
2633
  /** Type of the transaction */
2549
- type = import_transactions8.TransactionType.Create;
2634
+ type = import_transactions9.TransactionType.Create;
2550
2635
  /** Witness index of contract bytecode to create */
2551
2636
  bytecodeWitnessIndex;
2552
2637
  /** Salt */
@@ -2574,10 +2659,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2574
2659
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2575
2660
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2576
2661
  return {
2577
- type: import_transactions8.TransactionType.Create,
2662
+ type: import_transactions9.TransactionType.Create,
2578
2663
  ...baseTransaction,
2579
2664
  bytecodeWitnessIndex,
2580
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2665
+ storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
2581
2666
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2582
2667
  storageSlots
2583
2668
  };
@@ -2589,7 +2674,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2589
2674
  */
2590
2675
  getContractCreatedOutputs() {
2591
2676
  return this.outputs.filter(
2592
- (output) => output.type === import_transactions8.OutputType.ContractCreated
2677
+ (output) => output.type === import_transactions9.OutputType.ContractCreated
2593
2678
  );
2594
2679
  }
2595
2680
  /**
@@ -2610,14 +2695,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2610
2695
  */
2611
2696
  addContractCreatedOutput(contractId, stateRoot) {
2612
2697
  this.pushOutput({
2613
- type: import_transactions8.OutputType.ContractCreated,
2698
+ type: import_transactions9.OutputType.ContractCreated,
2614
2699
  contractId,
2615
2700
  stateRoot
2616
2701
  });
2617
2702
  }
2618
2703
  metadataGas(gasCosts) {
2619
2704
  return calculateMetadataGasForTxCreate({
2620
- contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2705
+ contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2621
2706
  gasCosts,
2622
2707
  stateRootSize: this.storageSlots.length,
2623
2708
  txBytesSize: this.byteSize()
@@ -2629,8 +2714,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2629
2714
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
2630
2715
  var import_address2 = require("@fuel-ts/address");
2631
2716
  var import_configs9 = require("@fuel-ts/address/configs");
2632
- var import_math10 = require("@fuel-ts/math");
2633
- var import_transactions9 = require("@fuel-ts/transactions");
2717
+ var import_math11 = require("@fuel-ts/math");
2718
+ var import_transactions10 = require("@fuel-ts/transactions");
2634
2719
  var import_utils15 = require("@fuel-ts/utils");
2635
2720
 
2636
2721
  // src/providers/transaction-request/scripts.ts
@@ -2668,7 +2753,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2668
2753
  return new this(obj);
2669
2754
  }
2670
2755
  /** Type of the transaction */
2671
- type = import_transactions9.TransactionType.Script;
2756
+ type = import_transactions10.TransactionType.Script;
2672
2757
  /** Gas limit for transaction */
2673
2758
  gasLimit;
2674
2759
  /** Script to execute */
@@ -2683,7 +2768,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2683
2768
  */
2684
2769
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2685
2770
  super(rest);
2686
- this.gasLimit = (0, import_math10.bn)(gasLimit);
2771
+ this.gasLimit = (0, import_math11.bn)(gasLimit);
2687
2772
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2688
2773
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2689
2774
  this.abis = rest.abis;
@@ -2697,11 +2782,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2697
2782
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2698
2783
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2699
2784
  return {
2700
- type: import_transactions9.TransactionType.Script,
2785
+ type: import_transactions10.TransactionType.Script,
2701
2786
  scriptGasLimit: this.gasLimit,
2702
2787
  ...super.getBaseTransaction(),
2703
- scriptLength: (0, import_math10.bn)(script.length),
2704
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2788
+ scriptLength: (0, import_math11.bn)(script.length),
2789
+ scriptDataLength: (0, import_math11.bn)(scriptData.length),
2705
2790
  receiptsRoot: import_configs9.ZeroBytes32,
2706
2791
  script: (0, import_utils15.hexlify)(script),
2707
2792
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2714,7 +2799,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2714
2799
  */
2715
2800
  getContractInputs() {
2716
2801
  return this.inputs.filter(
2717
- (input) => input.type === import_transactions9.InputType.Contract
2802
+ (input) => input.type === import_transactions10.InputType.Contract
2718
2803
  );
2719
2804
  }
2720
2805
  /**
@@ -2724,7 +2809,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2724
2809
  */
2725
2810
  getContractOutputs() {
2726
2811
  return this.outputs.filter(
2727
- (output) => output.type === import_transactions9.OutputType.Contract
2812
+ (output) => output.type === import_transactions10.OutputType.Contract
2728
2813
  );
2729
2814
  }
2730
2815
  /**
@@ -2734,7 +2819,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2734
2819
  */
2735
2820
  getVariableOutputs() {
2736
2821
  return this.outputs.filter(
2737
- (output) => output.type === import_transactions9.OutputType.Variable
2822
+ (output) => output.type === import_transactions10.OutputType.Variable
2738
2823
  );
2739
2824
  }
2740
2825
  /**
@@ -2757,7 +2842,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2757
2842
  let outputsNumber = numberOfVariables;
2758
2843
  while (outputsNumber) {
2759
2844
  this.pushOutput({
2760
- type: import_transactions9.OutputType.Variable
2845
+ type: import_transactions10.OutputType.Variable
2761
2846
  });
2762
2847
  outputsNumber -= 1;
2763
2848
  }
@@ -2794,12 +2879,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2794
2879
  return this;
2795
2880
  }
2796
2881
  const inputIndex = super.pushInput({
2797
- type: import_transactions9.InputType.Contract,
2882
+ type: import_transactions10.InputType.Contract,
2798
2883
  contractId: contractAddress.toB256(),
2799
2884
  txPointer: "0x00000000000000000000000000000000"
2800
2885
  });
2801
2886
  this.pushOutput({
2802
- type: import_transactions9.OutputType.Contract,
2887
+ type: import_transactions10.OutputType.Contract,
2803
2888
  inputIndex
2804
2889
  });
2805
2890
  return this;
@@ -2836,17 +2921,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2836
2921
 
2837
2922
  // src/providers/transaction-request/utils.ts
2838
2923
  var import_errors9 = require("@fuel-ts/errors");
2839
- var import_transactions10 = require("@fuel-ts/transactions");
2924
+ var import_transactions11 = require("@fuel-ts/transactions");
2840
2925
  var transactionRequestify = (obj) => {
2841
2926
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2842
2927
  return obj;
2843
2928
  }
2844
2929
  const { type } = obj;
2845
2930
  switch (obj.type) {
2846
- case import_transactions10.TransactionType.Script: {
2931
+ case import_transactions11.TransactionType.Script: {
2847
2932
  return ScriptTransactionRequest.from(obj);
2848
2933
  }
2849
- case import_transactions10.TransactionType.Create: {
2934
+ case import_transactions11.TransactionType.Create: {
2850
2935
  return CreateTransactionRequest.from(obj);
2851
2936
  }
2852
2937
  default: {
@@ -2854,36 +2939,21 @@ var transactionRequestify = (obj) => {
2854
2939
  }
2855
2940
  }
2856
2941
  };
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
- );
2872
2942
 
2873
2943
  // src/providers/transaction-response/transaction-response.ts
2874
2944
  var import_errors13 = require("@fuel-ts/errors");
2875
2945
  var import_math16 = require("@fuel-ts/math");
2876
- var import_transactions18 = require("@fuel-ts/transactions");
2946
+ var import_transactions19 = require("@fuel-ts/transactions");
2877
2947
  var import_utils20 = require("@fuel-ts/utils");
2878
2948
 
2879
2949
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2880
2950
  var import_math15 = require("@fuel-ts/math");
2881
- var import_transactions16 = require("@fuel-ts/transactions");
2951
+ var import_transactions17 = require("@fuel-ts/transactions");
2882
2952
  var import_utils18 = require("@fuel-ts/utils");
2883
2953
 
2884
2954
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2885
- var import_math11 = require("@fuel-ts/math");
2886
- var import_transactions11 = require("@fuel-ts/transactions");
2955
+ var import_math12 = require("@fuel-ts/math");
2956
+ var import_transactions12 = require("@fuel-ts/transactions");
2887
2957
  var import_utils16 = require("@fuel-ts/utils");
2888
2958
  var calculateTXFeeForSummary = (params) => {
2889
2959
  const {
@@ -2896,19 +2966,19 @@ var calculateTXFeeForSummary = (params) => {
2896
2966
  if (totalFee) {
2897
2967
  return totalFee;
2898
2968
  }
2899
- const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2900
- const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2969
+ const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
2970
+ const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
2901
2971
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2902
- const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2972
+ const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
2903
2973
  const { type, witnesses, inputs, policies } = transaction;
2904
- let metadataGas = (0, import_math11.bn)(0);
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);
2974
+ let metadataGas = (0, import_math12.bn)(0);
2975
+ let gasLimit = (0, import_math12.bn)(0);
2976
+ if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
2977
+ return (0, import_math12.bn)(0);
2908
2978
  }
2909
- if (type === import_transactions11.TransactionType.Create) {
2979
+ if (type === import_transactions12.TransactionType.Create) {
2910
2980
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2911
- const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2981
+ const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2912
2982
  metadataGas = calculateMetadataGasForTxCreate({
2913
2983
  contractBytesSize,
2914
2984
  gasCosts,
@@ -2927,12 +2997,12 @@ var calculateTXFeeForSummary = (params) => {
2927
2997
  }
2928
2998
  const minGas = getMinGas({
2929
2999
  gasCosts,
2930
- gasPerByte: (0, import_math11.bn)(gasPerByte),
3000
+ gasPerByte: (0, import_math12.bn)(gasPerByte),
2931
3001
  inputs,
2932
3002
  metadataGas,
2933
3003
  txBytesSize: transactionBytes.length
2934
3004
  });
2935
- const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
3005
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
2936
3006
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2937
3007
  const maxGas = getMaxGas({
2938
3008
  gasPerByte,
@@ -2955,42 +3025,31 @@ var calculateTXFeeForSummary = (params) => {
2955
3025
  var import_configs10 = require("@fuel-ts/address/configs");
2956
3026
  var import_errors11 = require("@fuel-ts/errors");
2957
3027
  var import_math13 = require("@fuel-ts/math");
2958
- var import_transactions14 = require("@fuel-ts/transactions");
3028
+ var import_transactions15 = require("@fuel-ts/transactions");
2959
3029
 
2960
3030
  // src/providers/transaction-summary/call.ts
2961
3031
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
2962
- var import_math12 = require("@fuel-ts/math");
2963
- var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
3032
+ var getFunctionCall = ({ abi, receipt }) => {
2964
3033
  const abiInterface = new import_abi_coder4.Interface(abi);
2965
3034
  const callFunctionSelector = receipt.param1.toHex(8);
2966
3035
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2967
3036
  const inputs = functionFragment.jsonFn.inputs;
2968
- let encodedArgs;
2969
- if (functionFragment.isInputDataPointer) {
2970
- if (rawPayload) {
2971
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2972
- encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2973
- }
2974
- } else {
2975
- encodedArgs = receipt.param2.toHex();
2976
- }
3037
+ const encodedArgs = receipt.param2.toHex();
2977
3038
  let argumentsProvided;
2978
- if (encodedArgs) {
2979
- const data = functionFragment.decodeArguments(encodedArgs);
2980
- if (data) {
2981
- argumentsProvided = inputs.reduce((prev, input, index) => {
2982
- const value = data[index];
2983
- const name = input.name;
2984
- if (name) {
2985
- return {
2986
- ...prev,
2987
- // reparse to remove bn
2988
- [name]: JSON.parse(JSON.stringify(value))
2989
- };
2990
- }
2991
- return prev;
2992
- }, {});
2993
- }
3039
+ const data = functionFragment.decodeArguments(encodedArgs);
3040
+ if (data) {
3041
+ argumentsProvided = inputs.reduce((prev, input, index) => {
3042
+ const value = data[index];
3043
+ const name = input.name;
3044
+ if (name) {
3045
+ return {
3046
+ ...prev,
3047
+ // reparse to remove bn
3048
+ [name]: JSON.parse(JSON.stringify(value))
3049
+ };
3050
+ }
3051
+ return prev;
3052
+ }, {});
2994
3053
  }
2995
3054
  const call = {
2996
3055
  functionSignature: functionFragment.signature,
@@ -3003,7 +3062,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
3003
3062
 
3004
3063
  // src/providers/transaction-summary/input.ts
3005
3064
  var import_errors10 = require("@fuel-ts/errors");
3006
- var import_transactions12 = require("@fuel-ts/transactions");
3065
+ var import_transactions13 = require("@fuel-ts/transactions");
3007
3066
  function getInputsByTypes(inputs, types) {
3008
3067
  return inputs.filter((i) => types.includes(i.type));
3009
3068
  }
@@ -3011,16 +3070,16 @@ function getInputsByType(inputs, type) {
3011
3070
  return inputs.filter((i) => i.type === type);
3012
3071
  }
3013
3072
  function getInputsCoin(inputs) {
3014
- return getInputsByType(inputs, import_transactions12.InputType.Coin);
3073
+ return getInputsByType(inputs, import_transactions13.InputType.Coin);
3015
3074
  }
3016
3075
  function getInputsMessage(inputs) {
3017
- return getInputsByType(inputs, import_transactions12.InputType.Message);
3076
+ return getInputsByType(inputs, import_transactions13.InputType.Message);
3018
3077
  }
3019
3078
  function getInputsCoinAndMessage(inputs) {
3020
- return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
3079
+ return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
3021
3080
  }
3022
3081
  function getInputsContract(inputs) {
3023
- return getInputsByType(inputs, import_transactions12.InputType.Contract);
3082
+ return getInputsByType(inputs, import_transactions13.InputType.Contract);
3024
3083
  }
3025
3084
  function getInputFromAssetId(inputs, assetId) {
3026
3085
  const coinInputs = getInputsCoin(inputs);
@@ -3039,7 +3098,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
3039
3098
  if (!contractInput) {
3040
3099
  return void 0;
3041
3100
  }
3042
- if (contractInput.type !== import_transactions12.InputType.Contract) {
3101
+ if (contractInput.type !== import_transactions13.InputType.Contract) {
3043
3102
  throw new import_errors10.FuelError(
3044
3103
  import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
3045
3104
  `Contract input should be of type 'contract'.`
@@ -3048,34 +3107,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
3048
3107
  return contractInput;
3049
3108
  }
3050
3109
  function getInputAccountAddress(input) {
3051
- if (input.type === import_transactions12.InputType.Coin) {
3110
+ if (input.type === import_transactions13.InputType.Coin) {
3052
3111
  return input.owner.toString();
3053
3112
  }
3054
- if (input.type === import_transactions12.InputType.Message) {
3113
+ if (input.type === import_transactions13.InputType.Message) {
3055
3114
  return input.recipient.toString();
3056
3115
  }
3057
3116
  return "";
3058
3117
  }
3059
3118
 
3060
3119
  // src/providers/transaction-summary/output.ts
3061
- var import_transactions13 = require("@fuel-ts/transactions");
3120
+ var import_transactions14 = require("@fuel-ts/transactions");
3062
3121
  function getOutputsByType(outputs, type) {
3063
3122
  return outputs.filter((o) => o.type === type);
3064
3123
  }
3065
3124
  function getOutputsContractCreated(outputs) {
3066
- return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
3125
+ return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
3067
3126
  }
3068
3127
  function getOutputsCoin(outputs) {
3069
- return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
3128
+ return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
3070
3129
  }
3071
3130
  function getOutputsChange(outputs) {
3072
- return getOutputsByType(outputs, import_transactions13.OutputType.Change);
3131
+ return getOutputsByType(outputs, import_transactions14.OutputType.Change);
3073
3132
  }
3074
3133
  function getOutputsContract(outputs) {
3075
- return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
3134
+ return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
3076
3135
  }
3077
3136
  function getOutputsVariable(outputs) {
3078
- return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
3137
+ return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
3079
3138
  }
3080
3139
 
3081
3140
  // src/providers/transaction-summary/types.ts
@@ -3124,11 +3183,11 @@ function getReceiptsByType(receipts, type) {
3124
3183
  }
3125
3184
  function getTransactionTypeName(transactionType) {
3126
3185
  switch (transactionType) {
3127
- case import_transactions14.TransactionType.Mint:
3186
+ case import_transactions15.TransactionType.Mint:
3128
3187
  return "Mint" /* Mint */;
3129
- case import_transactions14.TransactionType.Create:
3188
+ case import_transactions15.TransactionType.Create:
3130
3189
  return "Create" /* Create */;
3131
- case import_transactions14.TransactionType.Script:
3190
+ case import_transactions15.TransactionType.Script:
3132
3191
  return "Script" /* Script */;
3133
3192
  default:
3134
3193
  throw new import_errors11.FuelError(
@@ -3160,10 +3219,10 @@ function hasSameAssetId(a) {
3160
3219
  return (b) => a.assetId === b.assetId;
3161
3220
  }
3162
3221
  function getReceiptsCall(receipts) {
3163
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
3222
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
3164
3223
  }
3165
3224
  function getReceiptsMessageOut(receipts) {
3166
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
3225
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
3167
3226
  }
3168
3227
  var mergeAssets = (op1, op2) => {
3169
3228
  const assets1 = op1.assetsSent || [];
@@ -3202,7 +3261,7 @@ function addOperation(operations, toAdd) {
3202
3261
  return allOperations;
3203
3262
  }
3204
3263
  function getReceiptsTransferOut(receipts) {
3205
- return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
3264
+ return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
3206
3265
  }
3207
3266
  function getWithdrawFromFuelOperations({
3208
3267
  inputs,
@@ -3362,11 +3421,11 @@ function getTransferOperations({
3362
3421
  });
3363
3422
  const transferReceipts = getReceiptsByType(
3364
3423
  receipts,
3365
- import_transactions14.ReceiptType.Transfer
3424
+ import_transactions15.ReceiptType.Transfer
3366
3425
  );
3367
3426
  const transferOutReceipts = getReceiptsByType(
3368
3427
  receipts,
3369
- import_transactions14.ReceiptType.TransferOut
3428
+ import_transactions15.ReceiptType.TransferOut
3370
3429
  );
3371
3430
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3372
3431
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3451,17 +3510,17 @@ function getOperations({
3451
3510
  }
3452
3511
 
3453
3512
  // src/providers/transaction-summary/receipt.ts
3454
- var import_transactions15 = require("@fuel-ts/transactions");
3513
+ var import_transactions16 = require("@fuel-ts/transactions");
3455
3514
  var processGqlReceipt = (gqlReceipt) => {
3456
3515
  const receipt = assembleReceiptByType(gqlReceipt);
3457
3516
  switch (receipt.type) {
3458
- case import_transactions15.ReceiptType.ReturnData: {
3517
+ case import_transactions16.ReceiptType.ReturnData: {
3459
3518
  return {
3460
3519
  ...receipt,
3461
3520
  data: gqlReceipt.data || "0x"
3462
3521
  };
3463
3522
  }
3464
- case import_transactions15.ReceiptType.LogData: {
3523
+ case import_transactions16.ReceiptType.LogData: {
3465
3524
  return {
3466
3525
  ...receipt,
3467
3526
  data: gqlReceipt.data || "0x"
@@ -3474,7 +3533,7 @@ var processGqlReceipt = (gqlReceipt) => {
3474
3533
  var extractMintedAssetsFromReceipts = (receipts) => {
3475
3534
  const mintedAssets = [];
3476
3535
  receipts.forEach((receipt) => {
3477
- if (receipt.type === import_transactions15.ReceiptType.Mint) {
3536
+ if (receipt.type === import_transactions16.ReceiptType.Mint) {
3478
3537
  mintedAssets.push({
3479
3538
  subId: receipt.subId,
3480
3539
  contractId: receipt.contractId,
@@ -3488,7 +3547,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3488
3547
  var extractBurnedAssetsFromReceipts = (receipts) => {
3489
3548
  const burnedAssets = [];
3490
3549
  receipts.forEach((receipt) => {
3491
- if (receipt.type === import_transactions15.ReceiptType.Burn) {
3550
+ if (receipt.type === import_transactions16.ReceiptType.Burn) {
3492
3551
  burnedAssets.push({
3493
3552
  subId: receipt.subId,
3494
3553
  contractId: receipt.contractId,
@@ -3594,7 +3653,7 @@ function assembleTransactionSummary(params) {
3594
3653
  maxInputs
3595
3654
  });
3596
3655
  const typeName = getTransactionTypeName(transaction.type);
3597
- const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3656
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
3598
3657
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3599
3658
  const fee = calculateTXFeeForSummary({
3600
3659
  totalFee,
@@ -3645,12 +3704,12 @@ function assembleTransactionSummary(params) {
3645
3704
 
3646
3705
  // src/providers/transaction-response/getDecodedLogs.ts
3647
3706
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3648
- var import_transactions17 = require("@fuel-ts/transactions");
3707
+ var import_transactions18 = require("@fuel-ts/transactions");
3649
3708
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3650
3709
  return receipts.reduce((logs, receipt) => {
3651
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3710
+ if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
3652
3711
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3653
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3712
+ const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3654
3713
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3655
3714
  logs.push(decodedLog);
3656
3715
  }
@@ -3723,7 +3782,7 @@ var TransactionResponse = class {
3723
3782
  * @returns The decoded transaction.
3724
3783
  */
3725
3784
  decodeTransaction(transactionWithReceipts) {
3726
- return new import_transactions18.TransactionCoder().decode(
3785
+ return new import_transactions19.TransactionCoder().decode(
3727
3786
  (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3728
3787
  0
3729
3788
  )?.[0];
@@ -4073,9 +4132,11 @@ var _Provider = class {
4073
4132
  static ensureClientVersionIsSupported(nodeInfo) {
4074
4133
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
4075
4134
  if (!isMajorSupported || !isMinorSupported) {
4076
- throw new import_errors14.FuelError(
4077
- import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
4078
- `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
4135
+ console.warn(
4136
+ `The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
4137
+ which is not supported by the version of the TS SDK that you are using.
4138
+ Things may not work as expected.
4139
+ Supported fuel-core version: ${supportedVersion}.`
4079
4140
  );
4080
4141
  }
4081
4142
  }
@@ -4202,7 +4263,7 @@ var _Provider = class {
4202
4263
  }
4203
4264
  const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4204
4265
  let abis;
4205
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4266
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4206
4267
  abis = transactionRequest.abis;
4207
4268
  }
4208
4269
  if (awaitExecution) {
@@ -4294,7 +4355,7 @@ var _Provider = class {
4294
4355
  * @returns A promise.
4295
4356
  */
4296
4357
  async estimateTxDependencies(transactionRequest) {
4297
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4358
+ if (transactionRequest.type === import_transactions20.TransactionType.Create) {
4298
4359
  return {
4299
4360
  receipts: [],
4300
4361
  outputVariables: 0,
@@ -4358,7 +4419,7 @@ var _Provider = class {
4358
4419
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4359
4420
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4360
4421
  allRequests.forEach((req, index) => {
4361
- if (req.type === import_transactions19.TransactionType.Script) {
4422
+ if (req.type === import_transactions20.TransactionType.Script) {
4362
4423
  serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4363
4424
  }
4364
4425
  });
@@ -4384,7 +4445,7 @@ var _Provider = class {
4384
4445
  );
4385
4446
  const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4386
4447
  const request = allRequests[requestIdx];
4387
- if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4448
+ if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
4388
4449
  result.outputVariables += missingOutputVariables.length;
4389
4450
  request.addVariableOutputs(missingOutputVariables.length);
4390
4451
  missingOutputContractIds.forEach(({ contractId }) => {
@@ -4440,7 +4501,7 @@ var _Provider = class {
4440
4501
  tip: transactionRequest.tip
4441
4502
  }).add(1);
4442
4503
  let gasLimit = (0, import_math17.bn)(0);
4443
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4504
+ if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4444
4505
  gasLimit = transactionRequest.gasLimit;
4445
4506
  if (transactionRequest.gasLimit.eq(0)) {
4446
4507
  transactionRequest.gasLimit = minGas;
@@ -4510,12 +4571,12 @@ var _Provider = class {
4510
4571
  */
4511
4572
  async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4512
4573
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4513
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4574
+ const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
4514
4575
  const baseAssetId = this.getBaseAssetId();
4576
+ const updateMaxFee = txRequestClone.maxFee.eq(0);
4515
4577
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4516
4578
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4517
4579
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4518
- txRequestClone.maxFee = (0, import_math17.bn)(0);
4519
4580
  if (isScriptTransaction) {
4520
4581
  txRequestClone.gasLimit = (0, import_math17.bn)(0);
4521
4582
  }
@@ -4530,6 +4591,7 @@ var _Provider = class {
4530
4591
  addedSignatures = signedRequest.witnesses.length - lengthBefore;
4531
4592
  }
4532
4593
  await this.estimatePredicates(signedRequest);
4594
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4533
4595
  let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4534
4596
  transactionRequest: signedRequest
4535
4597
  });
@@ -4538,7 +4600,6 @@ var _Provider = class {
4538
4600
  let missingContractIds = [];
4539
4601
  let outputVariables = 0;
4540
4602
  let gasUsed = (0, import_math17.bn)(0);
4541
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4542
4603
  txRequestClone.maxFee = maxFee;
4543
4604
  if (isScriptTransaction) {
4544
4605
  txRequestClone.gasLimit = gasLimit;
@@ -4566,7 +4627,8 @@ var _Provider = class {
4566
4627
  missingContractIds,
4567
4628
  addedSignatures,
4568
4629
  estimatedPredicates: txRequestClone.inputs,
4569
- dryRunStatus
4630
+ dryRunStatus,
4631
+ updateMaxFee
4570
4632
  };
4571
4633
  }
4572
4634
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4639,7 +4701,7 @@ var _Provider = class {
4639
4701
  };
4640
4702
  const result = await this.operations.getCoinsToSpend(coinsQuery);
4641
4703
  const coins = result.coinsToSpend.flat().map((coin) => {
4642
- switch (coin.__typename) {
4704
+ switch (coin.type) {
4643
4705
  case "MessageCoin":
4644
4706
  return {
4645
4707
  amount: (0, import_math17.bn)(coin.amount),
@@ -4733,7 +4795,7 @@ var _Provider = class {
4733
4795
  time: block.header.time,
4734
4796
  transactionIds: block.transactions.map((tx) => tx.id),
4735
4797
  transactions: block.transactions.map(
4736
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4798
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4737
4799
  )
4738
4800
  };
4739
4801
  }
@@ -4748,7 +4810,7 @@ var _Provider = class {
4748
4810
  if (!transaction) {
4749
4811
  return null;
4750
4812
  }
4751
- return new import_transactions19.TransactionCoder().decode(
4813
+ return new import_transactions20.TransactionCoder().decode(
4752
4814
  (0, import_utils22.arrayify)(transaction.rawPayload),
4753
4815
  0
4754
4816
  )?.[0];
@@ -4828,7 +4890,7 @@ var _Provider = class {
4828
4890
  });
4829
4891
  const messages = result.messages.edges.map((edge) => edge.node);
4830
4892
  return messages.map((message) => ({
4831
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4893
+ messageId: import_transactions20.InputMessageCoder.getMessageId({
4832
4894
  sender: message.sender,
4833
4895
  recipient: message.recipient,
4834
4896
  nonce: message.nonce,
@@ -4839,7 +4901,7 @@ var _Provider = class {
4839
4901
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4840
4902
  nonce: message.nonce,
4841
4903
  amount: (0, import_math17.bn)(message.amount),
4842
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4904
+ data: import_transactions20.InputMessageCoder.decodeData(message.data),
4843
4905
  daHeight: (0, import_math17.bn)(message.daHeight)
4844
4906
  }));
4845
4907
  }
@@ -5005,7 +5067,7 @@ cacheInputs_fn = function(inputs) {
5005
5067
  return;
5006
5068
  }
5007
5069
  inputs.forEach((input) => {
5008
- if (input.type === import_transactions19.InputType.Coin) {
5070
+ if (input.type === import_transactions20.InputType.Coin) {
5009
5071
  this.cache?.set(input.id);
5010
5072
  }
5011
5073
  });
@@ -5016,7 +5078,7 @@ __publicField(Provider, "nodeInfoCache", {});
5016
5078
  // src/providers/transaction-summary/get-transaction-summary.ts
5017
5079
  var import_errors15 = require("@fuel-ts/errors");
5018
5080
  var import_math18 = require("@fuel-ts/math");
5019
- var import_transactions20 = require("@fuel-ts/transactions");
5081
+ var import_transactions21 = require("@fuel-ts/transactions");
5020
5082
  var import_utils25 = require("@fuel-ts/utils");
5021
5083
  async function getTransactionSummary(params) {
5022
5084
  const { id, provider, abiMap } = params;
@@ -5029,7 +5091,7 @@ async function getTransactionSummary(params) {
5029
5091
  `Transaction not found for given id: ${id}.`
5030
5092
  );
5031
5093
  }
5032
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
5094
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
5033
5095
  (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
5034
5096
  0
5035
5097
  );
@@ -5102,7 +5164,7 @@ async function getTransactionsSummaries(params) {
5102
5164
  const transactions = edges.map((edge) => {
5103
5165
  const { node: gqlTransaction } = edge;
5104
5166
  const { id, rawPayload, status } = gqlTransaction;
5105
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5167
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5106
5168
  let txReceipts = [];
5107
5169
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5108
5170
  txReceipts = gqlTransaction.status.receipts;
@@ -5222,8 +5284,11 @@ function resolveIconPaths(assets2, basePath = "./") {
5222
5284
  }));
5223
5285
  }
5224
5286
 
5225
- // src/providers/assets/index.ts
5226
- var assets = [
5287
+ // src/providers/assets/utils/fuelAssetsBaseUrl.ts
5288
+ var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
5289
+
5290
+ // src/providers/assets/assets.ts
5291
+ var rawAssets = [
5227
5292
  {
5228
5293
  name: "Ethereum",
5229
5294
  symbol: "ETH",
@@ -5254,36 +5319,21 @@ var assets = [
5254
5319
  ]
5255
5320
  }
5256
5321
  ];
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));
5322
+ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
5273
5323
 
5274
5324
  // src/utils/formatTransferToContractScriptData.ts
5275
5325
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5276
- var import_math20 = require("@fuel-ts/math");
5277
- var import_utils26 = require("@fuel-ts/utils");
5326
+ var import_math19 = require("@fuel-ts/math");
5327
+ var import_utils27 = require("@fuel-ts/utils");
5278
5328
  var asm = __toESM(require("@fuels/vm-asm"));
5279
5329
  var formatTransferToContractScriptData = (params) => {
5280
5330
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5281
5331
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5282
- const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
5332
+ const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
5283
5333
  const scriptData = Uint8Array.from([
5284
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
5334
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5285
5335
  ...encoded,
5286
- ...(0, import_utils26.arrayify)(assetId)
5336
+ ...(0, import_utils27.arrayify)(assetId)
5287
5337
  ]);
5288
5338
  return scriptData;
5289
5339
  };
@@ -5463,20 +5513,20 @@ var Account = class extends import_interfaces.AbstractAccount {
5463
5513
  return balances;
5464
5514
  }
5465
5515
  /**
5466
- * Adds resources to the transaction enough to fund it.
5516
+ * Funds a transaction request by adding the necessary resources.
5467
5517
  *
5468
- * @param request - The transaction request.
5469
- * @param requiredQuantities - The coin quantities required to execute the transaction.
5470
- * @param fee - The estimated transaction fee.
5471
- * @returns A promise that resolves when the resources are added to the transaction.
5518
+ * @typeParam T - The type of the TransactionRequest.
5519
+ * @param request - The transaction request to fund.
5520
+ * @param params - The estimated transaction parameters.
5521
+ * @returns The funded transaction request.
5472
5522
  */
5473
5523
  async fund(request, params) {
5474
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5524
+ const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
5525
+ const fee = request.maxFee;
5475
5526
  const baseAssetId = this.provider.getBaseAssetId();
5476
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5477
- const txRequest = request;
5527
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
5478
5528
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5479
- amount: (0, import_math21.bn)(fee),
5529
+ amount: (0, import_math20.bn)(fee),
5480
5530
  assetId: baseAssetId,
5481
5531
  coinQuantities: requiredQuantities
5482
5532
  });
@@ -5484,7 +5534,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5484
5534
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5485
5535
  quantitiesDict[assetId] = {
5486
5536
  required: amount,
5487
- owned: (0, import_math21.bn)(0)
5537
+ owned: (0, import_math20.bn)(0)
5488
5538
  };
5489
5539
  });
5490
5540
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -5508,17 +5558,19 @@ var Account = class extends import_interfaces.AbstractAccount {
5508
5558
  while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5509
5559
  const resources = await this.getResourcesToSpend(
5510
5560
  missingQuantities,
5511
- cacheTxInputsFromOwner(request.inputs, this.address)
5561
+ cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5512
5562
  );
5513
5563
  request.addResources(resources);
5514
- txRequest.shiftPredicateData();
5515
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5516
- const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5564
+ request.updatePredicateGasUsed(estimatedPredicates);
5565
+ const requestToReestimate2 = (0, import_ramda4.clone)(request);
5517
5566
  if (addedSignatures) {
5518
5567
  Array.from({ length: addedSignatures }).forEach(
5519
5568
  () => requestToReestimate2.addEmptyWitness()
5520
5569
  );
5521
5570
  }
5571
+ if (!updateMaxFee) {
5572
+ break;
5573
+ }
5522
5574
  const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5523
5575
  transactionRequest: requestToReestimate2
5524
5576
  });
@@ -5540,17 +5592,19 @@ var Account = class extends import_interfaces.AbstractAccount {
5540
5592
  }
5541
5593
  fundingAttempts += 1;
5542
5594
  }
5543
- txRequest.shiftPredicateData();
5544
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5545
- const requestToReestimate = (0, import_ramda4.clone)(txRequest);
5595
+ request.updatePredicateGasUsed(estimatedPredicates);
5596
+ const requestToReestimate = (0, import_ramda4.clone)(request);
5546
5597
  if (addedSignatures) {
5547
5598
  Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5548
5599
  }
5600
+ if (!updateMaxFee) {
5601
+ return request;
5602
+ }
5549
5603
  const { maxFee } = await this.provider.estimateTxGasAndFee({
5550
5604
  transactionRequest: requestToReestimate
5551
5605
  });
5552
- txRequest.maxFee = maxFee;
5553
- return txRequest;
5606
+ request.maxFee = maxFee;
5607
+ return request;
5554
5608
  }
5555
5609
  /**
5556
5610
  * A helper that creates a transfer transaction request and returns it.
@@ -5562,20 +5616,19 @@ var Account = class extends import_interfaces.AbstractAccount {
5562
5616
  * @returns A promise that resolves to the prepared transaction request.
5563
5617
  */
5564
5618
  async createTransfer(destination, amount, assetId, txParams = {}) {
5565
- const request = new ScriptTransactionRequest(txParams);
5619
+ let request = new ScriptTransactionRequest(txParams);
5566
5620
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5567
5621
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5568
5622
  const txCost = await this.provider.getTransactionCost(request, {
5569
5623
  estimateTxDependencies: true,
5570
5624
  resourcesOwner: this
5571
5625
  });
5572
- this.validateGasLimitAndMaxFee({
5626
+ request = this.validateGasLimitAndMaxFee({
5627
+ transactionRequest: request,
5573
5628
  gasUsed: txCost.gasUsed,
5574
5629
  maxFee: txCost.maxFee,
5575
5630
  txParams
5576
5631
  });
5577
- request.gasLimit = txCost.gasUsed;
5578
- request.maxFee = txCost.maxFee;
5579
5632
  await this.fund(request, txCost);
5580
5633
  return request;
5581
5634
  }
@@ -5589,7 +5642,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5589
5642
  * @returns A promise that resolves to the transaction response.
5590
5643
  */
5591
5644
  async transfer(destination, amount, assetId, txParams = {}) {
5592
- if ((0, import_math21.bn)(amount).lte(0)) {
5645
+ if ((0, import_math20.bn)(amount).lte(0)) {
5593
5646
  throw new import_errors16.FuelError(
5594
5647
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5595
5648
  "Transfer amount must be a positive number."
@@ -5609,7 +5662,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5609
5662
  * @returns A promise that resolves to the transaction response.
5610
5663
  */
5611
5664
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5612
- if ((0, import_math21.bn)(amount).lte(0)) {
5665
+ if ((0, import_math20.bn)(amount).lte(0)) {
5613
5666
  throw new import_errors16.FuelError(
5614
5667
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5615
5668
  "Transfer amount must be a positive number."
@@ -5619,10 +5672,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5619
5672
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5620
5673
  const { script, scriptData } = await assembleTransferToContractScript({
5621
5674
  hexlifiedContractId: contractAddress.toB256(),
5622
- amountToTransfer: (0, import_math21.bn)(amount),
5675
+ amountToTransfer: (0, import_math20.bn)(amount),
5623
5676
  assetId: assetIdToTransfer
5624
5677
  });
5625
- const request = new ScriptTransactionRequest({
5678
+ let request = new ScriptTransactionRequest({
5626
5679
  ...txParams,
5627
5680
  script,
5628
5681
  scriptData
@@ -5630,15 +5683,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5630
5683
  request.addContractInputAndOutput(contractAddress);
5631
5684
  const txCost = await this.provider.getTransactionCost(request, {
5632
5685
  resourcesOwner: this,
5633
- quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5686
+ quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
5634
5687
  });
5635
- this.validateGasLimitAndMaxFee({
5688
+ request = this.validateGasLimitAndMaxFee({
5689
+ transactionRequest: request,
5636
5690
  gasUsed: txCost.gasUsed,
5637
5691
  maxFee: txCost.maxFee,
5638
5692
  txParams
5639
5693
  });
5640
- request.gasLimit = txCost.gasUsed;
5641
- request.maxFee = txCost.maxFee;
5642
5694
  await this.fund(request, txCost);
5643
5695
  return this.sendTransaction(request);
5644
5696
  }
@@ -5652,29 +5704,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5652
5704
  */
5653
5705
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5654
5706
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5655
- const recipientDataArray = (0, import_utils27.arrayify)(
5707
+ const recipientDataArray = (0, import_utils28.arrayify)(
5656
5708
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5657
5709
  );
5658
- const amountDataArray = (0, import_utils27.arrayify)(
5659
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5710
+ const amountDataArray = (0, import_utils28.arrayify)(
5711
+ "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5660
5712
  );
5661
5713
  const script = new Uint8Array([
5662
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5714
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5663
5715
  ...recipientDataArray,
5664
5716
  ...amountDataArray
5665
5717
  ]);
5666
5718
  const params = { script, ...txParams };
5667
5719
  const baseAssetId = this.provider.getBaseAssetId();
5668
- const request = new ScriptTransactionRequest(params);
5669
- const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5720
+ let request = new ScriptTransactionRequest(params);
5721
+ const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
5670
5722
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5671
- this.validateGasLimitAndMaxFee({
5723
+ request = this.validateGasLimitAndMaxFee({
5724
+ transactionRequest: request,
5672
5725
  gasUsed: txCost.gasUsed,
5673
5726
  maxFee: txCost.maxFee,
5674
5727
  txParams
5675
5728
  });
5676
- request.maxFee = txCost.maxFee;
5677
- request.gasLimit = txCost.gasUsed;
5678
5729
  await this.fund(request, txCost);
5679
5730
  return this.sendTransaction(request);
5680
5731
  }
@@ -5734,35 +5785,42 @@ var Account = class extends import_interfaces.AbstractAccount {
5734
5785
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5735
5786
  }
5736
5787
  validateGasLimitAndMaxFee({
5737
- txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
5738
5788
  gasUsed,
5739
- maxFee
5789
+ maxFee,
5790
+ transactionRequest,
5791
+ txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5740
5792
  }) {
5741
- if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
5793
+ const request = transactionRequestify(transactionRequest);
5794
+ if (!(0, import_utils28.isDefined)(setGasLimit)) {
5795
+ request.gasLimit = gasUsed;
5796
+ } else if (gasUsed.gt(setGasLimit)) {
5742
5797
  throw new import_errors16.FuelError(
5743
5798
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5744
5799
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5745
5800
  );
5746
5801
  }
5747
- if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
5802
+ if (!(0, import_utils28.isDefined)(setMaxFee)) {
5803
+ request.maxFee = maxFee;
5804
+ } else if (maxFee.gt(setMaxFee)) {
5748
5805
  throw new import_errors16.FuelError(
5749
5806
  import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5750
5807
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5751
5808
  );
5752
5809
  }
5810
+ return request;
5753
5811
  }
5754
5812
  };
5755
5813
 
5756
5814
  // src/wallet/base-wallet-unlocked.ts
5757
5815
  var import_hasher3 = require("@fuel-ts/hasher");
5758
- var import_utils30 = require("@fuel-ts/utils");
5816
+ var import_utils31 = require("@fuel-ts/utils");
5759
5817
 
5760
5818
  // src/signer/signer.ts
5761
5819
  var import_address5 = require("@fuel-ts/address");
5762
5820
  var import_crypto2 = require("@fuel-ts/crypto");
5763
5821
  var import_hasher2 = require("@fuel-ts/hasher");
5764
- var import_math22 = require("@fuel-ts/math");
5765
- var import_utils28 = require("@fuel-ts/utils");
5822
+ var import_math21 = require("@fuel-ts/math");
5823
+ var import_utils29 = require("@fuel-ts/utils");
5766
5824
  var import_secp256k1 = require("@noble/curves/secp256k1");
5767
5825
  var Signer = class {
5768
5826
  address;
@@ -5781,10 +5839,10 @@ var Signer = class {
5781
5839
  privateKey = `0x${privateKey}`;
5782
5840
  }
5783
5841
  }
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));
5842
+ const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5843
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5844
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5845
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5788
5846
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5789
5847
  }
5790
5848
  /**
@@ -5798,11 +5856,11 @@ var Signer = class {
5798
5856
  * @returns hashed signature
5799
5857
  */
5800
5858
  sign(data) {
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);
5859
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5860
+ const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5861
+ const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5804
5862
  s[0] |= (signature.recovery || 0) << 7;
5805
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5863
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5806
5864
  }
5807
5865
  /**
5808
5866
  * Add point on the current elliptic curve
@@ -5811,8 +5869,8 @@ var Signer = class {
5811
5869
  * @returns compressed point on the curve
5812
5870
  */
5813
5871
  addPoint(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));
5872
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5873
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5816
5874
  const result = p0.add(p1);
5817
5875
  return `0x${result.toHex(true)}`;
5818
5876
  }
@@ -5824,16 +5882,16 @@ var Signer = class {
5824
5882
  * @returns public key from signature from the
5825
5883
  */
5826
5884
  static recoverPublicKey(data, signature) {
5827
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5885
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5828
5886
  const r = signedMessageBytes.slice(0, 32);
5829
5887
  const s = signedMessageBytes.slice(32, 64);
5830
5888
  const recoveryParam = (s[0] & 128) >> 7;
5831
5889
  s[0] &= 127;
5832
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5890
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5833
5891
  recoveryParam
5834
5892
  );
5835
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5836
- return (0, import_utils28.hexlify)(publicKey);
5893
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5894
+ return (0, import_utils29.hexlify)(publicKey);
5837
5895
  }
5838
5896
  /**
5839
5897
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5852,7 +5910,7 @@ var Signer = class {
5852
5910
  * @returns random 32-byte hashed
5853
5911
  */
5854
5912
  static generatePrivateKey(entropy) {
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);
5913
+ 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);
5856
5914
  }
5857
5915
  /**
5858
5916
  * Extended publicKey from a compact publicKey
@@ -5861,8 +5919,8 @@ var Signer = class {
5861
5919
  * @returns extended publicKey
5862
5920
  */
5863
5921
  static extendPublicKey(publicKey) {
5864
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5865
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5922
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5923
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5866
5924
  }
5867
5925
  };
5868
5926
 
@@ -5870,7 +5928,7 @@ var Signer = class {
5870
5928
  var import_address6 = require("@fuel-ts/address");
5871
5929
  var import_crypto3 = require("@fuel-ts/crypto");
5872
5930
  var import_errors17 = require("@fuel-ts/errors");
5873
- var import_utils29 = require("@fuel-ts/utils");
5931
+ var import_utils30 = require("@fuel-ts/utils");
5874
5932
  var import_uuid = require("uuid");
5875
5933
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5876
5934
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5953,7 +6011,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5953
6011
  );
5954
6012
  }
5955
6013
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5956
- const privateKey = (0, import_utils29.hexlify)(buffer);
6014
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5957
6015
  return privateKey;
5958
6016
  }
5959
6017
 
@@ -5998,7 +6056,7 @@ var BaseWalletUnlocked = class extends Account {
5998
6056
  */
5999
6057
  async signMessage(message) {
6000
6058
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
6001
- return (0, import_utils30.hexlify)(signedMessage);
6059
+ return (0, import_utils31.hexlify)(signedMessage);
6002
6060
  }
6003
6061
  /**
6004
6062
  * Signs a transaction with the wallet's private key.
@@ -6011,7 +6069,7 @@ var BaseWalletUnlocked = class extends Account {
6011
6069
  const chainId = this.provider.getChainId();
6012
6070
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
6013
6071
  const signature = await this.signer().sign(hashedTransaction);
6014
- return (0, import_utils30.hexlify)(signature);
6072
+ return (0, import_utils31.hexlify)(signature);
6015
6073
  }
6016
6074
  /**
6017
6075
  * Populates a transaction with the witnesses signature.
@@ -6070,18 +6128,17 @@ var BaseWalletUnlocked = class extends Account {
6070
6128
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6071
6129
 
6072
6130
  // src/hdwallet/hdwallet.ts
6131
+ var import_crypto5 = require("@fuel-ts/crypto");
6073
6132
  var import_errors20 = require("@fuel-ts/errors");
6074
6133
  var import_hasher6 = require("@fuel-ts/hasher");
6075
- var import_math23 = require("@fuel-ts/math");
6076
- var import_utils34 = require("@fuel-ts/utils");
6077
- var import_ethers2 = require("ethers");
6134
+ var import_math22 = require("@fuel-ts/math");
6135
+ var import_utils35 = require("@fuel-ts/utils");
6078
6136
 
6079
6137
  // src/mnemonic/mnemonic.ts
6080
6138
  var import_crypto4 = require("@fuel-ts/crypto");
6081
6139
  var import_errors19 = require("@fuel-ts/errors");
6082
6140
  var import_hasher5 = require("@fuel-ts/hasher");
6083
- var import_utils32 = require("@fuel-ts/utils");
6084
- var import_ethers = require("ethers");
6141
+ var import_utils33 = require("@fuel-ts/utils");
6085
6142
 
6086
6143
  // src/wordlists/words/english.ts
6087
6144
  var english = [
@@ -8144,39 +8201,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
8144
8201
  // src/mnemonic/utils.ts
8145
8202
  var import_errors18 = require("@fuel-ts/errors");
8146
8203
  var import_hasher4 = require("@fuel-ts/hasher");
8147
- var import_utils31 = require("@fuel-ts/utils");
8148
- function toUtf8Bytes(stri) {
8149
- const str = stri.normalize("NFKD");
8150
- const result = [];
8151
- for (let i = 0; i < str.length; i += 1) {
8152
- const c = str.charCodeAt(i);
8153
- if (c < 128) {
8154
- result.push(c);
8155
- } else if (c < 2048) {
8156
- result.push(c >> 6 | 192);
8157
- result.push(c & 63 | 128);
8158
- } else if ((c & 64512) === 55296) {
8159
- i += 1;
8160
- const c2 = str.charCodeAt(i);
8161
- if (i >= str.length || (c2 & 64512) !== 56320) {
8162
- throw new import_errors18.FuelError(
8163
- import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
8164
- "Invalid UTF-8 in the input string."
8165
- );
8166
- }
8167
- const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
8168
- result.push(pair >> 18 | 240);
8169
- result.push(pair >> 12 & 63 | 128);
8170
- result.push(pair >> 6 & 63 | 128);
8171
- result.push(pair & 63 | 128);
8172
- } else {
8173
- result.push(c >> 12 | 224);
8174
- result.push(c >> 6 & 63 | 128);
8175
- result.push(c & 63 | 128);
8176
- }
8177
- }
8178
- return Uint8Array.from(result);
8179
- }
8204
+ var import_utils32 = require("@fuel-ts/utils");
8180
8205
  function getLowerMask(bits) {
8181
8206
  return (1 << bits) - 1;
8182
8207
  }
@@ -8211,14 +8236,14 @@ function entropyToMnemonicIndices(entropy) {
8211
8236
  }
8212
8237
  }
8213
8238
  const checksumBits = entropy.length / 4;
8214
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8239
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8215
8240
  indices[indices.length - 1] <<= checksumBits;
8216
8241
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8217
8242
  return indices;
8218
8243
  }
8219
8244
  function mnemonicWordsToEntropy(words, wordlist) {
8220
8245
  const size = Math.ceil(11 * words.length / 8);
8221
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
8246
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8222
8247
  let offset = 0;
8223
8248
  for (let i = 0; i < words.length; i += 1) {
8224
8249
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8238,7 +8263,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8238
8263
  const entropyBits = 32 * words.length / 3;
8239
8264
  const checksumBits = words.length / 3;
8240
8265
  const checksumMask = getUpperMask(checksumBits);
8241
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8266
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8242
8267
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8243
8268
  throw new import_errors18.FuelError(
8244
8269
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8249,7 +8274,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8249
8274
  }
8250
8275
 
8251
8276
  // src/mnemonic/mnemonic.ts
8252
- var MasterSecret = toUtf8Bytes("Bitcoin seed");
8277
+ var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
8253
8278
  var MainnetPRV = "0x0488ade4";
8254
8279
  var TestnetPRV = "0x04358394";
8255
8280
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -8313,7 +8338,7 @@ var Mnemonic = class {
8313
8338
  static mnemonicToEntropy(phrase, wordlist = english) {
8314
8339
  const words = getWords(phrase);
8315
8340
  assertMnemonic(words);
8316
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8341
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8317
8342
  }
8318
8343
  /**
8319
8344
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8321,7 +8346,7 @@ var Mnemonic = class {
8321
8346
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8322
8347
  */
8323
8348
  static entropyToMnemonic(entropy, wordlist = english) {
8324
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
8349
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8325
8350
  assertWordList(wordlist);
8326
8351
  assertEntropy(entropyBytes);
8327
8352
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8333,9 +8358,9 @@ var Mnemonic = class {
8333
8358
  */
8334
8359
  static mnemonicToSeed(phrase, passphrase = "") {
8335
8360
  assertMnemonic(getWords(phrase));
8336
- const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8337
- const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8338
- return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8361
+ const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
8362
+ const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
8363
+ return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8339
8364
  }
8340
8365
  /**
8341
8366
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8390,14 +8415,14 @@ var Mnemonic = class {
8390
8415
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8391
8416
  */
8392
8417
  static masterKeysFromSeed(seed) {
8393
- const seedArray = (0, import_utils32.arrayify)(seed);
8418
+ const seedArray = (0, import_utils33.arrayify)(seed);
8394
8419
  if (seedArray.length < 16 || seedArray.length > 64) {
8395
8420
  throw new import_errors19.FuelError(
8396
8421
  import_errors19.ErrorCode.INVALID_SEED,
8397
8422
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8398
8423
  );
8399
8424
  }
8400
- return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8425
+ return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8401
8426
  }
8402
8427
  /**
8403
8428
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8408,22 +8433,22 @@ var Mnemonic = class {
8408
8433
  */
8409
8434
  static seedToExtendedKey(seed, testnet = false) {
8410
8435
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8411
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8436
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8412
8437
  const depth = "0x00";
8413
8438
  const fingerprint = "0x00000000";
8414
8439
  const index = "0x00000000";
8415
8440
  const chainCode = masterKey.slice(32);
8416
8441
  const privateKey = masterKey.slice(0, 32);
8417
- const extendedKey = (0, import_utils32.concat)([
8442
+ const extendedKey = (0, import_utils33.concat)([
8418
8443
  prefix,
8419
8444
  depth,
8420
8445
  fingerprint,
8421
8446
  index,
8422
8447
  chainCode,
8423
- (0, import_utils32.concat)(["0x00", privateKey])
8448
+ (0, import_utils33.concat)(["0x00", privateKey])
8424
8449
  ]);
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]));
8450
+ const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8451
+ return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8427
8452
  }
8428
8453
  /**
8429
8454
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8438,7 +8463,7 @@ var Mnemonic = class {
8438
8463
  * @returns A randomly generated mnemonic
8439
8464
  */
8440
8465
  static generate(size = 32, extraEntropy = "") {
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);
8466
+ 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);
8442
8467
  return Mnemonic.entropyToMnemonic(entropy);
8443
8468
  }
8444
8469
  };
@@ -8446,12 +8471,12 @@ var mnemonic_default = Mnemonic;
8446
8471
 
8447
8472
  // src/hdwallet/hdwallet.ts
8448
8473
  var HARDENED_INDEX = 2147483648;
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");
8474
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8475
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8476
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8477
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8453
8478
  function base58check(data) {
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)]));
8479
+ return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8455
8480
  }
8456
8481
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8457
8482
  if (isPublic) {
@@ -8460,11 +8485,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8460
8485
  return testnet ? TestnetPRV2 : MainnetPRV2;
8461
8486
  }
8462
8487
  function isPublicExtendedKey(extendedKey) {
8463
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8488
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8464
8489
  }
8465
8490
  function isValidExtendedKey(extendedKey) {
8466
8491
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8467
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8492
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8468
8493
  );
8469
8494
  }
8470
8495
  function parsePath(path, depth = 0) {
@@ -8482,8 +8507,8 @@ function parsePath(path, depth = 0) {
8482
8507
  var HDWallet = class {
8483
8508
  depth = 0;
8484
8509
  index = 0;
8485
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8486
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8510
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8511
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8487
8512
  privateKey;
8488
8513
  publicKey;
8489
8514
  chainCode;
@@ -8495,8 +8520,8 @@ var HDWallet = class {
8495
8520
  constructor(config) {
8496
8521
  if (config.privateKey) {
8497
8522
  const signer = new Signer(config.privateKey);
8498
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8499
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8523
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8524
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8500
8525
  } else {
8501
8526
  if (!config.publicKey) {
8502
8527
  throw new import_errors20.FuelError(
@@ -8504,10 +8529,10 @@ var HDWallet = class {
8504
8529
  "Both public and private Key cannot be missing. At least one should be provided."
8505
8530
  );
8506
8531
  }
8507
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8532
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8508
8533
  }
8509
8534
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8510
- this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8535
+ this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8511
8536
  this.depth = config.depth || this.depth;
8512
8537
  this.index = config.index || this.index;
8513
8538
  this.chainCode = config.chainCode;
@@ -8523,9 +8548,9 @@ var HDWallet = class {
8523
8548
  * @returns A new instance of HDWallet on the derived index
8524
8549
  */
8525
8550
  deriveIndex(index) {
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);
8551
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8552
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8553
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8529
8554
  const data = new Uint8Array(37);
8530
8555
  if (index & HARDENED_INDEX) {
8531
8556
  if (!privateKey) {
@@ -8536,15 +8561,15 @@ var HDWallet = class {
8536
8561
  }
8537
8562
  data.set(privateKey, 1);
8538
8563
  } else {
8539
- data.set((0, import_utils34.arrayify)(this.publicKey));
8564
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8540
8565
  }
8541
- data.set((0, import_math23.toBytes)(index, 4), 33);
8542
- const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8566
+ data.set((0, import_math22.toBytes)(index, 4), 33);
8567
+ const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8543
8568
  const IL = bytes.slice(0, 32);
8544
8569
  const IR = bytes.slice(32);
8545
8570
  if (privateKey) {
8546
8571
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8547
- const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8572
+ const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
8548
8573
  return new HDWallet({
8549
8574
  privateKey: ki,
8550
8575
  chainCode: IR,
@@ -8553,7 +8578,7 @@ var HDWallet = class {
8553
8578
  parentFingerprint: this.fingerprint
8554
8579
  });
8555
8580
  }
8556
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8581
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8557
8582
  const Ki = signer.addPoint(publicKey);
8558
8583
  return new HDWallet({
8559
8584
  publicKey: Ki,
@@ -8588,12 +8613,12 @@ var HDWallet = class {
8588
8613
  );
8589
8614
  }
8590
8615
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8591
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8616
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8592
8617
  const parentFingerprint = this.parentFingerprint;
8593
- const index = (0, import_math23.toHex)(this.index, 4);
8618
+ const index = (0, import_math22.toHex)(this.index, 4);
8594
8619
  const chainCode = this.chainCode;
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]));
8620
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8621
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8597
8622
  return base58check(extendedKey);
8598
8623
  }
8599
8624
  /**
@@ -8605,13 +8630,13 @@ var HDWallet = class {
8605
8630
  static fromSeed(seed) {
8606
8631
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8607
8632
  return new HDWallet({
8608
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8609
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8633
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8634
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8610
8635
  });
8611
8636
  }
8612
8637
  static fromExtendedKey(extendedKey) {
8613
- const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8614
- const bytes = (0, import_utils34.arrayify)(decoded);
8638
+ const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8639
+ const bytes = (0, import_utils35.arrayify)(decoded);
8615
8640
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8616
8641
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8617
8642
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8620,9 +8645,9 @@ var HDWallet = class {
8620
8645
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8621
8646
  }
8622
8647
  const depth = bytes[4];
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));
8648
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8649
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8650
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8626
8651
  const key = bytes.slice(45, 78);
8627
8652
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8628
8653
  throw new import_errors20.FuelError(
@@ -8810,7 +8835,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8810
8835
 
8811
8836
  // src/wallet-manager/wallet-manager.ts
8812
8837
  var import_address9 = require("@fuel-ts/address");
8813
- var import_crypto5 = require("@fuel-ts/crypto");
8838
+ var import_crypto6 = require("@fuel-ts/crypto");
8814
8839
  var import_errors23 = require("@fuel-ts/errors");
8815
8840
  var import_events = require("events");
8816
8841
 
@@ -9138,7 +9163,7 @@ var _WalletManager = class extends import_events.EventEmitter {
9138
9163
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
9139
9164
  const data = await this.storage.getItem(this.STORAGE_KEY);
9140
9165
  if (data) {
9141
- const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
9166
+ const state = await (0, import_crypto6.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
9142
9167
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
9143
9168
  }
9144
9169
  }
@@ -9147,7 +9172,7 @@ var _WalletManager = class extends import_events.EventEmitter {
9147
9172
  */
9148
9173
  async saveState() {
9149
9174
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
9150
- const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
9175
+ const encryptedData = await (0, import_crypto6.encrypt)(__privateGet(this, _passphrase), {
9151
9176
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
9152
9177
  });
9153
9178
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -9226,19 +9251,18 @@ var StorageAbstract = class {
9226
9251
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9227
9252
  var import_address10 = require("@fuel-ts/address");
9228
9253
  var import_errors25 = require("@fuel-ts/errors");
9229
- var import_transactions22 = require("@fuel-ts/transactions");
9230
- var import_utils36 = require("@fuel-ts/utils");
9254
+ var import_utils37 = require("@fuel-ts/utils");
9231
9255
 
9232
9256
  // src/predicate/utils/getPredicateRoot.ts
9233
9257
  var import_hasher7 = require("@fuel-ts/hasher");
9234
9258
  var import_merkle = require("@fuel-ts/merkle");
9235
- var import_utils35 = require("@fuel-ts/utils");
9259
+ var import_utils36 = require("@fuel-ts/utils");
9236
9260
  var getPredicateRoot = (bytecode) => {
9237
9261
  const chunkSize = 16 * 1024;
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]));
9262
+ const bytes = (0, import_utils36.arrayify)(bytecode);
9263
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
9264
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
9265
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9242
9266
  return predicateRoot;
9243
9267
  };
9244
9268
 
@@ -9284,11 +9308,15 @@ var Predicate = class extends Account {
9284
9308
  */
9285
9309
  populateTransactionPredicateData(transactionRequestLike) {
9286
9310
  const request = transactionRequestify(transactionRequestLike);
9287
- const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9288
- request.inputs?.forEach((input) => {
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));
9311
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
9312
+ if (placeholderIndex !== -1) {
9313
+ request.removeWitness(placeholderIndex);
9314
+ }
9315
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
9316
+ if (isRequestInputResourceFromOwner(input, this.address)) {
9317
+ input.predicate = (0, import_utils37.hexlify)(this.bytes);
9318
+ input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
9319
+ input.witnessIndex = 0;
9292
9320
  }
9293
9321
  });
9294
9322
  return request;
@@ -9313,17 +9341,12 @@ var Predicate = class extends Account {
9313
9341
  const transactionRequest = transactionRequestify(transactionRequestLike);
9314
9342
  return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
9315
9343
  }
9316
- getPredicateData(policiesLength) {
9344
+ getPredicateData() {
9317
9345
  if (!this.predicateData.length) {
9318
9346
  return new Uint8Array();
9319
9347
  }
9320
9348
  const mainFn = this.interface?.functions.main;
9321
- const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9322
- const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9323
- maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9324
- });
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;
9326
- return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
9349
+ return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
9327
9350
  }
9328
9351
  /**
9329
9352
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -9334,7 +9357,7 @@ var Predicate = class extends Account {
9334
9357
  * @returns An object containing the new predicate bytes and interface.
9335
9358
  */
9336
9359
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9337
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
9360
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9338
9361
  let abiInterface;
9339
9362
  if (jsonAbi) {
9340
9363
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9372,8 +9395,7 @@ var Predicate = class extends Account {
9372
9395
  );
9373
9396
  return resources.map((resource) => ({
9374
9397
  ...resource,
9375
- predicate: (0, import_utils36.hexlify)(this.bytes),
9376
- padPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9398
+ predicate: (0, import_utils37.hexlify)(this.bytes)
9377
9399
  }));
9378
9400
  }
9379
9401
  /**
@@ -9411,6 +9433,28 @@ var Predicate = class extends Account {
9411
9433
  }
9412
9434
  return mutatedBytes;
9413
9435
  }
9436
+ /**
9437
+ * Returns the index of the witness placeholder that was added to this predicate.
9438
+ * If no witness placeholder was added, it returns -1.
9439
+ * @param request - The transaction request.
9440
+ * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
9441
+ */
9442
+ getIndexFromPlaceholderWitness(request) {
9443
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
9444
+ let index = -1;
9445
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
9446
+ if (hasEmptyPredicateInputs) {
9447
+ index = hasEmptyPredicateInputs.witnessIndex;
9448
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
9449
+ if (!allInputsAreEmpty) {
9450
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
9451
+ if (wasFilledInputAddedFirst) {
9452
+ index = -1;
9453
+ }
9454
+ }
9455
+ }
9456
+ return index;
9457
+ }
9414
9458
  };
9415
9459
 
9416
9460
  // src/connectors/fuel.ts
@@ -10134,7 +10178,8 @@ __publicField(Fuel, "defaultConfig", {});
10134
10178
  assets,
10135
10179
  buildBlockExplorerUrl,
10136
10180
  cacheFor,
10137
- cacheTxInputsFromOwner,
10181
+ cacheRequestInputsResources,
10182
+ cacheRequestInputsResourcesFromOwner,
10138
10183
  calculateGasFee,
10139
10184
  calculateMetadataGasForTxCreate,
10140
10185
  calculateMetadataGasForTxScript,
@@ -10146,7 +10191,9 @@ __publicField(Fuel, "defaultConfig", {});
10146
10191
  extractBurnedAssetsFromReceipts,
10147
10192
  extractMintedAssetsFromReceipts,
10148
10193
  extractTxError,
10194
+ fuelAssetsBaseUrl,
10149
10195
  gasUsedByInputs,
10196
+ getAssetAmountInRequestInputs,
10150
10197
  getAssetEth,
10151
10198
  getAssetFuel,
10152
10199
  getAssetNetwork,
@@ -10181,6 +10228,7 @@ __publicField(Fuel, "defaultConfig", {});
10181
10228
  getReceiptsMessageOut,
10182
10229
  getReceiptsTransferOut,
10183
10230
  getReceiptsWithMissingData,
10231
+ getRequestInputResourceOwner,
10184
10232
  getTransactionStatusName,
10185
10233
  getTransactionSummary,
10186
10234
  getTransactionSummaryFromRequest,
@@ -10194,6 +10242,10 @@ __publicField(Fuel, "defaultConfig", {});
10194
10242
  isMessage,
10195
10243
  isRawCoin,
10196
10244
  isRawMessage,
10245
+ isRequestInputCoin,
10246
+ isRequestInputMessage,
10247
+ isRequestInputResource,
10248
+ isRequestInputResourceFromOwner,
10197
10249
  isType,
10198
10250
  isTypeCreate,
10199
10251
  isTypeMint,
@@ -10204,6 +10256,7 @@ __publicField(Fuel, "defaultConfig", {});
10204
10256
  outputify,
10205
10257
  processGqlReceipt,
10206
10258
  processGraphqlStatus,
10259
+ rawAssets,
10207
10260
  resolveGasDependentCosts,
10208
10261
  resolveIconPaths,
10209
10262
  returnZeroScript,