@fuel-ts/account 0.0.0-rc-2021-20240425184301 → 0.0.0-rc-2152-20240425194419

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

Potentially problematic release.


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

Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +6 -7
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +696 -1818
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +545 -796
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +421 -671
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +24 -12
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +359 -810
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -46
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +28 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1189 -2540
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +532 -778
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +419 -665
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToCoinQuantities: () => addAmountToCoinQuantities,
98
+ addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,9 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
109
107
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
108
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
110
  calculateTransactionFee: () => calculateTransactionFee,
112
111
  coinQuantityfy: () => coinQuantityfy,
113
112
  deferPromise: () => deferPromise,
@@ -187,9 +186,8 @@ module.exports = __toCommonJS(src_exports);
187
186
  var import_address4 = require("@fuel-ts/address");
188
187
  var import_errors16 = require("@fuel-ts/errors");
189
188
  var import_interfaces = require("@fuel-ts/interfaces");
190
- var import_math19 = require("@fuel-ts/math");
191
- var import_utils27 = require("@fuel-ts/utils");
192
- var import_ramda4 = require("ramda");
189
+ var import_math18 = require("@fuel-ts/math");
190
+ var import_utils28 = require("@fuel-ts/utils");
193
191
 
194
192
  // src/providers/coin-quantity.ts
195
193
  var import_math = require("@fuel-ts/math");
@@ -197,24 +195,24 @@ var import_utils = require("@fuel-ts/utils");
197
195
  var coinQuantityfy = (coinQuantityLike) => {
198
196
  let assetId;
199
197
  let amount;
200
- let max;
198
+ let max2;
201
199
  if (Array.isArray(coinQuantityLike)) {
202
200
  amount = coinQuantityLike[0];
203
201
  assetId = coinQuantityLike[1];
204
- max = coinQuantityLike[2] ?? void 0;
202
+ max2 = coinQuantityLike[2] ?? void 0;
205
203
  } else {
206
204
  amount = coinQuantityLike.amount;
207
205
  assetId = coinQuantityLike.assetId;
208
- max = coinQuantityLike.max ?? void 0;
206
+ max2 = coinQuantityLike.max ?? void 0;
209
207
  }
210
208
  const bnAmount = (0, import_math.bn)(amount);
211
209
  return {
212
210
  assetId: (0, import_utils.hexlify)(assetId),
213
211
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
214
- max: max ? (0, import_math.bn)(max) : void 0
212
+ max: max2 ? (0, import_math.bn)(max2) : void 0
215
213
  };
216
214
  };
217
- var addAmountToCoinQuantities = (params) => {
215
+ var addAmountToAsset = (params) => {
218
216
  const { amount, assetId } = params;
219
217
  const coinQuantities = [...params.coinQuantities];
220
218
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -229,31 +227,26 @@ var addAmountToCoinQuantities = (params) => {
229
227
  // src/providers/provider.ts
230
228
  var import_address3 = require("@fuel-ts/address");
231
229
  var import_errors14 = require("@fuel-ts/errors");
232
- var import_math16 = require("@fuel-ts/math");
233
- var import_transactions19 = require("@fuel-ts/transactions");
234
- var import_utils22 = require("@fuel-ts/utils");
230
+ var import_math15 = require("@fuel-ts/math");
231
+ var import_transactions18 = require("@fuel-ts/transactions");
232
+ var import_utils23 = require("@fuel-ts/utils");
235
233
  var import_versions = require("@fuel-ts/versions");
236
- var import_utils23 = require("@noble/curves/abstract/utils");
237
- var import_ethers = require("ethers");
234
+ var import_utils24 = require("@noble/curves/abstract/utils");
238
235
  var import_graphql_request = require("graphql-request");
239
236
  var import_ramda3 = require("ramda");
240
237
 
241
238
  // src/providers/__generated__/operations.ts
242
239
  var import_graphql_tag = __toESM(require("graphql-tag"));
243
- var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
244
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
245
- type: __typename
246
- ... on SqueezedOutStatus {
247
- reason
248
- }
249
- }
250
- `;
251
240
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
252
241
  fragment receiptFragment on Receipt {
253
- id
242
+ contract {
243
+ id
244
+ }
254
245
  pc
255
246
  is
256
- to
247
+ to {
248
+ id
249
+ }
257
250
  toAddress
258
251
  amount
259
252
  assetId
@@ -291,16 +284,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
291
284
  id
292
285
  }
293
286
  time
294
- receipts {
295
- ...receiptFragment
296
- }
297
287
  programState {
298
288
  returnType
299
289
  data
300
290
  }
301
- receipts {
302
- ...receiptFragment
303
- }
304
291
  }
305
292
  ... on FailureStatus {
306
293
  block {
@@ -308,24 +295,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
308
295
  }
309
296
  time
310
297
  reason
311
- receipts {
312
- ...receiptFragment
313
- }
314
298
  }
315
299
  ... on SqueezedOutStatus {
316
300
  reason
317
301
  }
318
302
  }
319
- ${ReceiptFragmentFragmentDoc}`;
303
+ `;
320
304
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
321
305
  fragment transactionFragment on Transaction {
322
306
  id
323
307
  rawPayload
308
+ gasPrice
309
+ receipts {
310
+ ...receiptFragment
311
+ }
324
312
  status {
325
313
  ...transactionStatusFragment
326
314
  }
327
315
  }
328
- ${TransactionStatusFragmentFragmentDoc}`;
316
+ ${ReceiptFragmentFragmentDoc}
317
+ ${TransactionStatusFragmentFragmentDoc}`;
329
318
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
330
319
  fragment inputEstimatePredicatesFragment on Input {
331
320
  ... on InputCoin {
@@ -343,46 +332,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
343
332
  }
344
333
  }
345
334
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
346
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
347
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
348
- reason
349
- programState {
350
- returnType
351
- data
352
- }
353
- }
354
- `;
355
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
356
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
357
- programState {
358
- returnType
359
- data
360
- }
361
- }
362
- `;
363
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
364
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
365
- ... on DryRunFailureStatus {
366
- ...dryRunFailureStatusFragment
367
- }
368
- ... on DryRunSuccessStatus {
369
- ...dryRunSuccessStatusFragment
370
- }
371
- }
372
- ${DryRunFailureStatusFragmentFragmentDoc}
373
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
374
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
375
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
376
- id
377
- status {
378
- ...dryRunTransactionStatusFragment
379
- }
380
- receipts {
381
- ...receiptFragment
382
- }
383
- }
384
- ${DryRunTransactionStatusFragmentFragmentDoc}
385
- ${ReceiptFragmentFragmentDoc}`;
386
335
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
387
336
  fragment coinFragment on Coin {
388
337
  __typename
@@ -390,6 +339,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
390
339
  owner
391
340
  amount
392
341
  assetId
342
+ maturity
393
343
  blockCreated
394
344
  txCreatedIdx
395
345
  }
@@ -428,32 +378,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
428
378
  messageBlockHeader {
429
379
  id
430
380
  daHeight
431
- consensusParametersVersion
432
- stateTransitionBytecodeVersion
433
381
  transactionsCount
434
- messageReceiptCount
435
382
  transactionsRoot
436
- messageOutboxRoot
437
- eventInboxRoot
438
383
  height
439
384
  prevRoot
440
385
  time
441
386
  applicationHash
387
+ messageReceiptRoot
388
+ messageReceiptCount
442
389
  }
443
390
  commitBlockHeader {
444
391
  id
445
392
  daHeight
446
- consensusParametersVersion
447
- stateTransitionBytecodeVersion
448
393
  transactionsCount
449
- messageReceiptCount
450
394
  transactionsRoot
451
- messageOutboxRoot
452
- eventInboxRoot
453
395
  height
454
396
  prevRoot
455
397
  time
456
398
  applicationHash
399
+ messageReceiptRoot
400
+ messageReceiptCount
457
401
  }
458
402
  sender
459
403
  recipient
@@ -472,8 +416,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
472
416
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
473
417
  fragment blockFragment on Block {
474
418
  id
475
- height
476
419
  header {
420
+ height
477
421
  time
478
422
  }
479
423
  transactions {
@@ -483,7 +427,6 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
483
427
  `;
484
428
  var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
485
429
  fragment TxParametersFragment on TxParameters {
486
- version
487
430
  maxInputs
488
431
  maxOutputs
489
432
  maxWitnesses
@@ -493,7 +436,6 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
493
436
  `;
494
437
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
495
438
  fragment PredicateParametersFragment on PredicateParameters {
496
- version
497
439
  maxPredicateLength
498
440
  maxPredicateDataLength
499
441
  maxGasPerPredicate
@@ -502,21 +444,18 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
502
444
  `;
503
445
  var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
504
446
  fragment ScriptParametersFragment on ScriptParameters {
505
- version
506
447
  maxScriptLength
507
448
  maxScriptDataLength
508
449
  }
509
450
  `;
510
451
  var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
511
452
  fragment ContractParametersFragment on ContractParameters {
512
- version
513
453
  contractMaxSize
514
454
  maxStorageSlots
515
455
  }
516
456
  `;
517
457
  var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
518
458
  fragment FeeParametersFragment on FeeParameters {
519
- version
520
459
  gasPriceFactor
521
460
  gasPerByte
522
461
  }
@@ -536,7 +475,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
536
475
  `;
537
476
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
538
477
  fragment GasCostsFragment on GasCosts {
539
- version
540
478
  add
541
479
  addi
542
480
  aloc
@@ -549,6 +487,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
549
487
  cb
550
488
  cfei
551
489
  cfsi
490
+ croo
552
491
  div
553
492
  divi
554
493
  ecr1
@@ -631,9 +570,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
631
570
  ccp {
632
571
  ...DependentCostFragment
633
572
  }
634
- croo {
635
- ...DependentCostFragment
636
- }
637
573
  csiz {
638
574
  ...DependentCostFragment
639
575
  }
@@ -693,7 +629,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
693
629
  ${DependentCostFragmentFragmentDoc}`;
694
630
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
695
631
  fragment consensusParametersFragment on ConsensusParameters {
696
- version
697
632
  txParams {
698
633
  ...TxParametersFragment
699
634
  }
@@ -753,9 +688,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
753
688
  fragment nodeInfoFragment on NodeInfo {
754
689
  utxoValidation
755
690
  vmBacktrace
691
+ minGasPrice
756
692
  maxTx
757
693
  maxDepth
758
694
  nodeVersion
695
+ peers {
696
+ id
697
+ addresses
698
+ clientVersion
699
+ blockHeight
700
+ lastHeartbeatMs
701
+ appScore
702
+ }
759
703
  }
760
704
  `;
761
705
  var GetVersionDocument = import_graphql_tag.default`
@@ -790,9 +734,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
790
734
  query getTransactionWithReceipts($transactionId: TransactionId!) {
791
735
  transaction(id: $transactionId) {
792
736
  ...transactionFragment
737
+ receipts {
738
+ ...receiptFragment
739
+ }
793
740
  }
794
741
  }
795
- ${TransactionFragmentFragmentDoc}`;
742
+ ${TransactionFragmentFragmentDoc}
743
+ ${ReceiptFragmentFragmentDoc}`;
796
744
  var GetTransactionsDocument = import_graphql_tag.default`
797
745
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
798
746
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -920,20 +868,6 @@ var GetBalanceDocument = import_graphql_tag.default`
920
868
  }
921
869
  }
922
870
  ${BalanceFragmentFragmentDoc}`;
923
- var GetLatestGasPriceDocument = import_graphql_tag.default`
924
- query getLatestGasPrice {
925
- latestGasPrice {
926
- gasPrice
927
- }
928
- }
929
- `;
930
- var EstimateGasPriceDocument = import_graphql_tag.default`
931
- query estimateGasPrice($blockHorizon: U32!) {
932
- estimateGasPrice(blockHorizon: $blockHorizon) {
933
- gasPrice
934
- }
935
- }
936
- `;
937
871
  var GetBalancesDocument = import_graphql_tag.default`
938
872
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
939
873
  balances(
@@ -988,12 +922,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
988
922
  }
989
923
  `;
990
924
  var DryRunDocument = import_graphql_tag.default`
991
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
992
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
993
- ...dryRunTransactionExecutionStatusFragment
925
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
926
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
927
+ ...receiptFragment
994
928
  }
995
929
  }
996
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
930
+ ${ReceiptFragmentFragmentDoc}`;
997
931
  var SubmitDocument = import_graphql_tag.default`
998
932
  mutation submit($encodedTransaction: HexString!) {
999
933
  submit(tx: $encodedTransaction) {
@@ -1012,17 +946,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
1012
946
  var SubmitAndAwaitDocument = import_graphql_tag.default`
1013
947
  subscription submitAndAwait($encodedTransaction: HexString!) {
1014
948
  submitAndAwait(tx: $encodedTransaction) {
1015
- ...transactionStatusSubscriptionFragment
949
+ ...transactionStatusFragment
1016
950
  }
1017
951
  }
1018
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
952
+ ${TransactionStatusFragmentFragmentDoc}`;
1019
953
  var StatusChangeDocument = import_graphql_tag.default`
1020
954
  subscription statusChange($transactionId: TransactionId!) {
1021
955
  statusChange(id: $transactionId) {
1022
- ...transactionStatusSubscriptionFragment
956
+ ...transactionStatusFragment
1023
957
  }
1024
958
  }
1025
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
959
+ ${TransactionStatusFragmentFragmentDoc}`;
1026
960
  function getSdk(requester) {
1027
961
  return {
1028
962
  getVersion(variables, options) {
@@ -1076,12 +1010,6 @@ function getSdk(requester) {
1076
1010
  getBalance(variables, options) {
1077
1011
  return requester(GetBalanceDocument, variables, options);
1078
1012
  },
1079
- getLatestGasPrice(variables, options) {
1080
- return requester(GetLatestGasPriceDocument, variables, options);
1081
- },
1082
- estimateGasPrice(variables, options) {
1083
- return requester(EstimateGasPriceDocument, variables, options);
1084
- },
1085
1013
  getBalances(variables, options) {
1086
1014
  return requester(GetBalancesDocument, variables, options);
1087
1015
  },
@@ -1275,9 +1203,10 @@ var inputify = (value) => {
1275
1203
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1276
1204
  },
1277
1205
  witnessIndex: value.witnessIndex,
1206
+ maturity: value.maturity ?? 0,
1278
1207
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1279
- predicateLength: (0, import_math2.bn)(predicate.length),
1280
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1208
+ predicateLength: predicate.length,
1209
+ predicateDataLength: predicateData.length,
1281
1210
  predicate: (0, import_utils3.hexlify)(predicate),
1282
1211
  predicateData: (0, import_utils3.hexlify)(predicateData)
1283
1212
  };
@@ -1308,8 +1237,8 @@ var inputify = (value) => {
1308
1237
  nonce: (0, import_utils3.hexlify)(value.nonce),
1309
1238
  witnessIndex: value.witnessIndex,
1310
1239
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1311
- predicateLength: (0, import_math2.bn)(predicate.length),
1312
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1240
+ predicateLength: predicate.length,
1241
+ predicateDataLength: predicateData.length,
1313
1242
  predicate: (0, import_utils3.hexlify)(predicate),
1314
1243
  predicateData: (0, import_utils3.hexlify)(predicateData),
1315
1244
  data: (0, import_utils3.hexlify)(data),
@@ -1428,8 +1357,8 @@ function assembleReceiptByType(receipt) {
1428
1357
  case "CALL" /* Call */: {
1429
1358
  const callReceipt = {
1430
1359
  type: import_transactions3.ReceiptType.Call,
1431
- from: hexOrZero(receipt.id || receipt.contractId),
1432
- to: hexOrZero(receipt?.to),
1360
+ from: hexOrZero(receipt.contract?.id),
1361
+ to: hexOrZero(receipt?.to?.id),
1433
1362
  amount: (0, import_math4.bn)(receipt.amount),
1434
1363
  assetId: hexOrZero(receipt.assetId),
1435
1364
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1443,7 +1372,7 @@ function assembleReceiptByType(receipt) {
1443
1372
  case "RETURN" /* Return */: {
1444
1373
  const returnReceipt = {
1445
1374
  type: import_transactions3.ReceiptType.Return,
1446
- id: hexOrZero(receipt.id || receipt.contractId),
1375
+ id: hexOrZero(receipt.contract?.id),
1447
1376
  val: (0, import_math4.bn)(receipt.val),
1448
1377
  pc: (0, import_math4.bn)(receipt.pc),
1449
1378
  is: (0, import_math4.bn)(receipt.is)
@@ -1453,7 +1382,7 @@ function assembleReceiptByType(receipt) {
1453
1382
  case "RETURN_DATA" /* ReturnData */: {
1454
1383
  const returnDataReceipt = {
1455
1384
  type: import_transactions3.ReceiptType.ReturnData,
1456
- id: hexOrZero(receipt.id || receipt.contractId),
1385
+ id: hexOrZero(receipt.contract?.id),
1457
1386
  ptr: (0, import_math4.bn)(receipt.ptr),
1458
1387
  len: (0, import_math4.bn)(receipt.len),
1459
1388
  digest: hexOrZero(receipt.digest),
@@ -1465,7 +1394,7 @@ function assembleReceiptByType(receipt) {
1465
1394
  case "PANIC" /* Panic */: {
1466
1395
  const panicReceipt = {
1467
1396
  type: import_transactions3.ReceiptType.Panic,
1468
- id: hexOrZero(receipt.id),
1397
+ id: hexOrZero(receipt.contract?.id),
1469
1398
  reason: (0, import_math4.bn)(receipt.reason),
1470
1399
  pc: (0, import_math4.bn)(receipt.pc),
1471
1400
  is: (0, import_math4.bn)(receipt.is),
@@ -1476,7 +1405,7 @@ function assembleReceiptByType(receipt) {
1476
1405
  case "REVERT" /* Revert */: {
1477
1406
  const revertReceipt = {
1478
1407
  type: import_transactions3.ReceiptType.Revert,
1479
- id: hexOrZero(receipt.id || receipt.contractId),
1408
+ id: hexOrZero(receipt.contract?.id),
1480
1409
  val: (0, import_math4.bn)(receipt.ra),
1481
1410
  pc: (0, import_math4.bn)(receipt.pc),
1482
1411
  is: (0, import_math4.bn)(receipt.is)
@@ -1486,7 +1415,7 @@ function assembleReceiptByType(receipt) {
1486
1415
  case "LOG" /* Log */: {
1487
1416
  const logReceipt = {
1488
1417
  type: import_transactions3.ReceiptType.Log,
1489
- id: hexOrZero(receipt.id || receipt.contractId),
1418
+ id: hexOrZero(receipt.contract?.id),
1490
1419
  val0: (0, import_math4.bn)(receipt.ra),
1491
1420
  val1: (0, import_math4.bn)(receipt.rb),
1492
1421
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1499,7 +1428,7 @@ function assembleReceiptByType(receipt) {
1499
1428
  case "LOG_DATA" /* LogData */: {
1500
1429
  const logDataReceipt = {
1501
1430
  type: import_transactions3.ReceiptType.LogData,
1502
- id: hexOrZero(receipt.id || receipt.contractId),
1431
+ id: hexOrZero(receipt.contract?.id),
1503
1432
  val0: (0, import_math4.bn)(receipt.ra),
1504
1433
  val1: (0, import_math4.bn)(receipt.rb),
1505
1434
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1513,8 +1442,8 @@ function assembleReceiptByType(receipt) {
1513
1442
  case "TRANSFER" /* Transfer */: {
1514
1443
  const transferReceipt = {
1515
1444
  type: import_transactions3.ReceiptType.Transfer,
1516
- from: hexOrZero(receipt.id || receipt.contractId),
1517
- to: hexOrZero(receipt.toAddress || receipt?.to),
1445
+ from: hexOrZero(receipt.contract?.id),
1446
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1518
1447
  amount: (0, import_math4.bn)(receipt.amount),
1519
1448
  assetId: hexOrZero(receipt.assetId),
1520
1449
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1525,8 +1454,8 @@ function assembleReceiptByType(receipt) {
1525
1454
  case "TRANSFER_OUT" /* TransferOut */: {
1526
1455
  const transferOutReceipt = {
1527
1456
  type: import_transactions3.ReceiptType.TransferOut,
1528
- from: hexOrZero(receipt.id || receipt.contractId),
1529
- to: hexOrZero(receipt.toAddress || receipt.to),
1457
+ from: hexOrZero(receipt.contract?.id),
1458
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1530
1459
  amount: (0, import_math4.bn)(receipt.amount),
1531
1460
  assetId: hexOrZero(receipt.assetId),
1532
1461
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1569,7 +1498,7 @@ function assembleReceiptByType(receipt) {
1569
1498
  return receiptMessageOut;
1570
1499
  }
1571
1500
  case "MINT" /* Mint */: {
1572
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1501
+ const contractId = hexOrZero(receipt.contract?.id);
1573
1502
  const subId = hexOrZero(receipt.subId);
1574
1503
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1575
1504
  const mintReceipt = {
@@ -1584,7 +1513,7 @@ function assembleReceiptByType(receipt) {
1584
1513
  return mintReceipt;
1585
1514
  }
1586
1515
  case "BURN" /* Burn */: {
1587
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1516
+ const contractId = hexOrZero(receipt.contract?.id);
1588
1517
  const subId = hexOrZero(receipt.subId);
1589
1518
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1590
1519
  const burnReceipt = {
@@ -1669,6 +1598,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1669
1598
  var import_math5 = require("@fuel-ts/math");
1670
1599
  var import_transactions4 = require("@fuel-ts/transactions");
1671
1600
  var import_utils6 = require("@fuel-ts/utils");
1601
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1672
1602
  var getGasUsedFromReceipts = (receipts) => {
1673
1603
  const scriptResult = receipts.filter(
1674
1604
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1689,28 +1619,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1689
1619
  }
1690
1620
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1691
1621
  const witnessCache = [];
1692
- const chargeableInputs = inputs.filter((input) => {
1693
- const isCoinOrMessage = "owner" in input || "sender" in input;
1694
- if (isCoinOrMessage) {
1695
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1696
- return true;
1697
- }
1698
- if (!witnessCache.includes(input.witnessIndex)) {
1699
- witnessCache.push(input.witnessIndex);
1700
- return true;
1701
- }
1702
- }
1703
- return false;
1704
- });
1705
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1706
- const totalGas = chargeableInputs.reduce((total, input) => {
1622
+ const totalGas = inputs.reduce((total, input) => {
1707
1623
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1708
1624
  return total.add(
1709
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1625
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1710
1626
  );
1711
1627
  }
1712
- return total.add(gasCosts.ecr1);
1713
- }, (0, import_math5.bn)(0));
1628
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1629
+ witnessCache.push(input.witnessIndex);
1630
+ return total.add(gasCosts.ecr1);
1631
+ }
1632
+ return total;
1633
+ }, (0, import_math5.bn)());
1714
1634
  return totalGas;
1715
1635
  }
1716
1636
  function getMinGas(params) {
@@ -1722,20 +1642,12 @@ function getMinGas(params) {
1722
1642
  return minGas;
1723
1643
  }
1724
1644
  function getMaxGas(params) {
1725
- const {
1726
- gasPerByte,
1727
- witnessesLength,
1728
- witnessLimit,
1729
- minGas,
1730
- gasLimit = (0, import_math5.bn)(0),
1731
- maxGasPerTx
1732
- } = params;
1645
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1733
1646
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1734
1647
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1735
1648
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1736
1649
  }
1737
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1738
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1650
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1739
1651
  }
1740
1652
  function calculateMetadataGasForTxCreate({
1741
1653
  gasCosts,
@@ -1757,10 +1669,6 @@ function calculateMetadataGasForTxScript({
1757
1669
  }) {
1758
1670
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1759
1671
  }
1760
- var calculateGasFee = (params) => {
1761
- const { gas, gasPrice, priceFactor, tip } = params;
1762
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1763
- };
1764
1672
 
1765
1673
  // src/providers/utils/json.ts
1766
1674
  var import_utils7 = require("@fuel-ts/utils");
@@ -1909,7 +1817,7 @@ var witnessify = (value) => {
1909
1817
  // src/providers/transaction-request/transaction-request.ts
1910
1818
  var BaseTransactionRequest = class {
1911
1819
  /** Gas price for transaction */
1912
- tip;
1820
+ gasPrice;
1913
1821
  /** Block until which tx cannot be included */
1914
1822
  maturity;
1915
1823
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1928,7 +1836,7 @@ var BaseTransactionRequest = class {
1928
1836
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1929
1837
  */
1930
1838
  constructor({
1931
- tip,
1839
+ gasPrice,
1932
1840
  maturity,
1933
1841
  maxFee,
1934
1842
  witnessLimit,
@@ -1936,7 +1844,7 @@ var BaseTransactionRequest = class {
1936
1844
  outputs,
1937
1845
  witnesses
1938
1846
  } = {}) {
1939
- this.tip = (0, import_math7.bn)(tip);
1847
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1940
1848
  this.maturity = maturity ?? 0;
1941
1849
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1942
1850
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1947,9 +1855,9 @@ var BaseTransactionRequest = class {
1947
1855
  static getPolicyMeta(req) {
1948
1856
  let policyTypes = 0;
1949
1857
  const policies = [];
1950
- if (req.tip) {
1951
- policyTypes += import_transactions6.PolicyType.Tip;
1952
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1858
+ if (req.gasPrice) {
1859
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1860
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1953
1861
  }
1954
1862
  if (req.witnessLimit) {
1955
1863
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2133,11 +2041,13 @@ var BaseTransactionRequest = class {
2133
2041
  * assetId, if one it was not added yet.
2134
2042
  *
2135
2043
  * @param coin - Coin resource.
2044
+ * @param predicate - Predicate bytes.
2045
+ * @param predicateData - Predicate data bytes.
2136
2046
  */
2137
- addCoinInput(coin) {
2047
+ addCoinInput(coin, predicate) {
2138
2048
  const { assetId, owner, amount } = coin;
2139
2049
  let witnessIndex;
2140
- if (coin.predicate) {
2050
+ if (predicate) {
2141
2051
  witnessIndex = 0;
2142
2052
  } else {
2143
2053
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2152,7 +2062,8 @@ var BaseTransactionRequest = class {
2152
2062
  amount,
2153
2063
  assetId,
2154
2064
  txPointer: "0x00000000000000000000000000000000",
2155
- witnessIndex
2065
+ witnessIndex,
2066
+ predicate: predicate?.bytes
2156
2067
  };
2157
2068
  this.pushInput(input);
2158
2069
  this.addChangeOutput(owner, assetId);
@@ -2162,11 +2073,12 @@ var BaseTransactionRequest = class {
2162
2073
  * asset against the message
2163
2074
  *
2164
2075
  * @param message - Message resource.
2076
+ * @param predicate - Predicate bytes.
2165
2077
  */
2166
- addMessageInput(message) {
2078
+ addMessageInput(message, predicate) {
2167
2079
  const { recipient, sender, amount, assetId } = message;
2168
2080
  let witnessIndex;
2169
- if (message.predicate) {
2081
+ if (predicate) {
2170
2082
  witnessIndex = 0;
2171
2083
  } else {
2172
2084
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2180,7 +2092,8 @@ var BaseTransactionRequest = class {
2180
2092
  sender: sender.toB256(),
2181
2093
  recipient: recipient.toB256(),
2182
2094
  amount,
2183
- witnessIndex
2095
+ witnessIndex,
2096
+ predicate: predicate?.bytes
2184
2097
  };
2185
2098
  this.pushInput(input);
2186
2099
  this.addChangeOutput(recipient, assetId);
@@ -2211,6 +2124,32 @@ var BaseTransactionRequest = class {
2211
2124
  resources.forEach((resource) => this.addResource(resource));
2212
2125
  return this;
2213
2126
  }
2127
+ /**
2128
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2129
+ * outputs from the related assetIds.
2130
+ *
2131
+ * @param resources - The resources to add.
2132
+ * @returns This transaction.
2133
+ */
2134
+ addPredicateResource(resource, predicate) {
2135
+ if (isCoin(resource)) {
2136
+ this.addCoinInput(resource, predicate);
2137
+ } else {
2138
+ this.addMessageInput(resource, predicate);
2139
+ }
2140
+ return this;
2141
+ }
2142
+ /**
2143
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2144
+ * from the related assetIds.
2145
+ *
2146
+ * @param resources - The resources to add.
2147
+ * @returns This transaction.
2148
+ */
2149
+ addPredicateResources(resources, predicate) {
2150
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2151
+ return this;
2152
+ }
2214
2153
  /**
2215
2154
  * Adds a coin output to the transaction.
2216
2155
  *
@@ -2290,7 +2229,7 @@ var BaseTransactionRequest = class {
2290
2229
  }
2291
2230
  calculateMaxGas(chainInfo, minGas) {
2292
2231
  const { consensusParameters } = chainInfo;
2293
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2232
+ const { gasPerByte } = consensusParameters;
2294
2233
  const witnessesLength = this.toTransaction().witnesses.reduce(
2295
2234
  (acc, wit) => acc + wit.dataLength,
2296
2235
  0
@@ -2299,8 +2238,7 @@ var BaseTransactionRequest = class {
2299
2238
  gasPerByte,
2300
2239
  minGas,
2301
2240
  witnessesLength,
2302
- witnessLimit: this.witnessLimit,
2303
- maxGasPerTx
2241
+ witnessLimit: this.witnessLimit
2304
2242
  });
2305
2243
  }
2306
2244
  /**
@@ -2319,20 +2257,17 @@ var BaseTransactionRequest = class {
2319
2257
  });
2320
2258
  const updateAssetInput = (assetId, quantity) => {
2321
2259
  const assetInput = findAssetInput(assetId);
2322
- let usedQuantity = quantity;
2323
- if (assetId === baseAssetId) {
2324
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2325
- }
2326
2260
  if (assetInput && "assetId" in assetInput) {
2327
2261
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2328
- assetInput.amount = usedQuantity;
2262
+ assetInput.amount = quantity;
2329
2263
  } else {
2330
2264
  this.addResources([
2331
2265
  {
2332
2266
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2333
- amount: usedQuantity,
2267
+ amount: quantity,
2334
2268
  assetId,
2335
2269
  owner: resourcesOwner || import_address.Address.fromRandom(),
2270
+ maturity: 0,
2336
2271
  blockCreated: (0, import_math7.bn)(1),
2337
2272
  txCreatedIdx: (0, import_math7.bn)(1)
2338
2273
  }
@@ -2364,7 +2299,7 @@ var BaseTransactionRequest = class {
2364
2299
  toJSON() {
2365
2300
  return normalizeJSON(this);
2366
2301
  }
2367
- updatePredicateGasUsed(inputs) {
2302
+ updatePredicateInputs(inputs) {
2368
2303
  this.inputs.forEach((i) => {
2369
2304
  let correspondingInput;
2370
2305
  switch (i.type) {
@@ -2386,15 +2321,6 @@ var BaseTransactionRequest = class {
2386
2321
  }
2387
2322
  });
2388
2323
  }
2389
- shiftPredicateData() {
2390
- this.inputs.forEach((input) => {
2391
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2392
- input.predicateData = input.padPredicateData(
2393
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2394
- );
2395
- }
2396
- });
2397
- }
2398
2324
  };
2399
2325
 
2400
2326
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2536,8 +2462,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2536
2462
  return {
2537
2463
  type: import_transactions8.TransactionType.Create,
2538
2464
  ...baseTransaction,
2465
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2539
2466
  bytecodeWitnessIndex,
2540
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2467
+ storageSlotsCount: storageSlots.length,
2541
2468
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2542
2469
  storageSlots
2543
2470
  };
@@ -2660,8 +2587,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2660
2587
  type: import_transactions9.TransactionType.Script,
2661
2588
  scriptGasLimit: this.gasLimit,
2662
2589
  ...super.getBaseTransaction(),
2663
- scriptLength: (0, import_math10.bn)(script.length),
2664
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2590
+ scriptLength: script.length,
2591
+ scriptDataLength: scriptData.length,
2665
2592
  receiptsRoot: import_configs9.ZeroBytes32,
2666
2593
  script: (0, import_utils15.hexlify)(script),
2667
2594
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2725,7 +2652,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2725
2652
  }
2726
2653
  calculateMaxGas(chainInfo, minGas) {
2727
2654
  const { consensusParameters } = chainInfo;
2728
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2655
+ const { gasPerByte } = consensusParameters;
2729
2656
  const witnessesLength = this.toTransaction().witnesses.reduce(
2730
2657
  (acc, wit) => acc + wit.dataLength,
2731
2658
  0
@@ -2735,8 +2662,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2735
2662
  minGas,
2736
2663
  witnessesLength,
2737
2664
  witnessLimit: this.witnessLimit,
2738
- gasLimit: this.gasLimit,
2739
- maxGasPerTx
2665
+ gasLimit: this.gasLimit
2740
2666
  });
2741
2667
  }
2742
2668
  /**
@@ -2811,32 +2737,15 @@ var transactionRequestify = (obj) => {
2811
2737
  }
2812
2738
  }
2813
2739
  };
2814
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2815
- (acc, input) => {
2816
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2817
- acc.utxos.push(input.id);
2818
- }
2819
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2820
- acc.messages.push(input.nonce);
2821
- }
2822
- return acc;
2823
- },
2824
- {
2825
- utxos: [],
2826
- messages: []
2827
- }
2828
- );
2829
2740
 
2830
2741
  // src/providers/transaction-response/transaction-response.ts
2831
2742
  var import_errors13 = require("@fuel-ts/errors");
2832
- var import_math15 = require("@fuel-ts/math");
2833
- var import_transactions18 = require("@fuel-ts/transactions");
2834
- var import_utils20 = require("@fuel-ts/utils");
2743
+ var import_math14 = require("@fuel-ts/math");
2744
+ var import_transactions17 = require("@fuel-ts/transactions");
2745
+ var import_utils21 = require("@fuel-ts/utils");
2835
2746
 
2836
2747
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2837
- var import_math14 = require("@fuel-ts/math");
2838
- var import_transactions16 = require("@fuel-ts/transactions");
2839
- var import_utils18 = require("@fuel-ts/utils");
2748
+ var import_utils19 = require("@fuel-ts/utils");
2840
2749
 
2841
2750
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2842
2751
  var import_math11 = require("@fuel-ts/math");
@@ -2844,10 +2753,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2844
2753
  var import_utils16 = require("@fuel-ts/utils");
2845
2754
  var calculateTransactionFee = (params) => {
2846
2755
  const {
2847
- gasPrice,
2756
+ gasUsed,
2848
2757
  rawPayload,
2849
- tip,
2850
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2758
+ consensusParameters: { gasCosts, feeParams }
2851
2759
  } = params;
2852
2760
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2853
2761
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2857,7 +2765,8 @@ var calculateTransactionFee = (params) => {
2857
2765
  return {
2858
2766
  fee: (0, import_math11.bn)(0),
2859
2767
  minFee: (0, import_math11.bn)(0),
2860
- maxFee: (0, import_math11.bn)(0)
2768
+ maxFee: (0, import_math11.bn)(0),
2769
+ feeFromGasUsed: (0, import_math11.bn)(0)
2861
2770
  };
2862
2771
  }
2863
2772
  const { type, witnesses, inputs, policies } = transaction;
@@ -2889,6 +2798,7 @@ var calculateTransactionFee = (params) => {
2889
2798
  metadataGas,
2890
2799
  txBytesSize: transactionBytes.length
2891
2800
  });
2801
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2892
2802
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2893
2803
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2894
2804
  const maxGas = getMaxGas({
@@ -2896,25 +2806,17 @@ var calculateTransactionFee = (params) => {
2896
2806
  minGas,
2897
2807
  witnessesLength,
2898
2808
  gasLimit,
2899
- witnessLimit,
2900
- maxGasPerTx
2901
- });
2902
- const minFee = calculateGasFee({
2903
- gasPrice,
2904
- gas: minGas,
2905
- priceFactor: gasPriceFactor,
2906
- tip
2907
- });
2908
- const maxFee = calculateGasFee({
2909
- gasPrice,
2910
- gas: maxGas,
2911
- priceFactor: gasPriceFactor,
2912
- tip
2809
+ witnessLimit
2913
2810
  });
2811
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2812
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2813
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2814
+ const fee = minFee.add(feeFromGasUsed);
2914
2815
  return {
2816
+ fee,
2915
2817
  minFee,
2916
2818
  maxFee,
2917
- fee: maxFee
2819
+ feeFromGasUsed
2918
2820
  };
2919
2821
  };
2920
2822
 
@@ -3528,12 +3430,10 @@ function assembleTransactionSummary(params) {
3528
3430
  gqlTransactionStatus,
3529
3431
  abiMap = {},
3530
3432
  maxInputs,
3531
- gasCosts,
3532
- maxGasPerTx,
3533
- gasPrice
3433
+ gasCosts
3534
3434
  } = params;
3535
3435
  const gasUsed = getGasUsedFromReceipts(receipts);
3536
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3436
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3537
3437
  const operations = getOperations({
3538
3438
  transactionType: transaction.type,
3539
3439
  inputs: transaction.inputs || [],
@@ -3544,14 +3444,11 @@ function assembleTransactionSummary(params) {
3544
3444
  maxInputs
3545
3445
  });
3546
3446
  const typeName = getTransactionTypeName(transaction.type);
3547
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3548
3447
  const { fee } = calculateTransactionFee({
3549
- gasPrice,
3448
+ gasUsed,
3550
3449
  rawPayload,
3551
- tip,
3552
3450
  consensusParameters: {
3553
3451
  gasCosts,
3554
- maxGasPerTx,
3555
3452
  feeParams: {
3556
3453
  gasPerByte,
3557
3454
  gasPriceFactor
@@ -3563,7 +3460,7 @@ function assembleTransactionSummary(params) {
3563
3460
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3564
3461
  let date;
3565
3462
  if (time) {
3566
- date = import_utils18.DateTime.fromTai64(time);
3463
+ date = import_utils19.DateTime.fromTai64(time);
3567
3464
  }
3568
3465
  const transactionSummary = {
3569
3466
  id,
@@ -3591,12 +3488,12 @@ function assembleTransactionSummary(params) {
3591
3488
 
3592
3489
  // src/providers/transaction-response/getDecodedLogs.ts
3593
3490
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3594
- var import_transactions17 = require("@fuel-ts/transactions");
3491
+ var import_transactions16 = require("@fuel-ts/transactions");
3595
3492
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3596
3493
  return receipts.reduce((logs, receipt) => {
3597
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3494
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3598
3495
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3599
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3496
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3600
3497
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3601
3498
  logs.push(decodedLog);
3602
3499
  }
@@ -3611,7 +3508,7 @@ var TransactionResponse = class {
3611
3508
  /** Current provider */
3612
3509
  provider;
3613
3510
  /** Gas used on the transaction */
3614
- gasUsed = (0, import_math15.bn)(0);
3511
+ gasUsed = (0, import_math14.bn)(0);
3615
3512
  /** The graphql Transaction with receipts object. */
3616
3513
  gqlTransaction;
3617
3514
  abis;
@@ -3669,8 +3566,8 @@ var TransactionResponse = class {
3669
3566
  * @returns The decoded transaction.
3670
3567
  */
3671
3568
  decodeTransaction(transactionWithReceipts) {
3672
- return new import_transactions18.TransactionCoder().decode(
3673
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3569
+ return new import_transactions17.TransactionCoder().decode(
3570
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3674
3571
  0
3675
3572
  )?.[0];
3676
3573
  }
@@ -3689,27 +3586,20 @@ var TransactionResponse = class {
3689
3586
  const decodedTransaction = this.decodeTransaction(
3690
3587
  transaction
3691
3588
  );
3692
- let txReceipts = [];
3693
- if (transaction?.status && "receipts" in transaction.status) {
3694
- txReceipts = transaction.status.receipts;
3695
- }
3696
- const receipts = txReceipts.map(processGqlReceipt) || [];
3697
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3698
- const gasPrice = await this.provider.getLatestGasPrice();
3589
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3590
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3699
3591
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3700
3592
  const transactionSummary = assembleTransactionSummary({
3701
3593
  id: this.id,
3702
3594
  receipts,
3703
3595
  transaction: decodedTransaction,
3704
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3596
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3705
3597
  gqlTransactionStatus: transaction.status,
3706
3598
  gasPerByte,
3707
3599
  gasPriceFactor,
3708
3600
  abiMap: contractsAbiMap,
3709
3601
  maxInputs,
3710
- gasCosts,
3711
- maxGasPerTx,
3712
- gasPrice
3602
+ gasCosts
3713
3603
  });
3714
3604
  return transactionSummary;
3715
3605
  }
@@ -3835,30 +3725,30 @@ var processGqlChain = (chain) => {
3835
3725
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3836
3726
  return {
3837
3727
  name,
3838
- baseChainHeight: (0, import_math16.bn)(daHeight),
3728
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3839
3729
  consensusParameters: {
3840
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3841
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3842
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3843
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3844
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3845
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3846
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3847
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3848
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3849
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3850
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3851
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3852
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3853
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3854
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3730
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3731
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3732
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3733
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3734
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3735
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3736
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3737
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3738
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3739
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3740
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3741
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3742
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3743
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3744
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3855
3745
  baseAssetId: consensusParameters.baseAssetId,
3856
3746
  gasCosts
3857
3747
  },
3858
3748
  gasCosts,
3859
3749
  latestBlock: {
3860
3750
  id: latestBlock.id,
3861
- height: (0, import_math16.bn)(latestBlock.height),
3751
+ height: (0, import_math15.bn)(latestBlock.header.height),
3862
3752
  time: latestBlock.header.time,
3863
3753
  transactions: latestBlock.transactions.map((i) => ({
3864
3754
  id: i.id
@@ -3952,8 +3842,10 @@ var _Provider = class {
3952
3842
  * Returns some helpful parameters related to gas fees.
3953
3843
  */
3954
3844
  getGasConfig() {
3845
+ const { minGasPrice } = this.getNode();
3955
3846
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3956
3847
  return {
3848
+ minGasPrice,
3957
3849
  maxGasPerTx,
3958
3850
  maxGasPerPredicate,
3959
3851
  gasPriceFactor,
@@ -4029,21 +3921,6 @@ var _Provider = class {
4029
3921
  } = await this.operations.getVersion();
4030
3922
  return nodeVersion;
4031
3923
  }
4032
- /**
4033
- * @hidden
4034
- *
4035
- * Returns the network configuration of the connected Fuel node.
4036
- *
4037
- * @returns A promise that resolves to the network configuration object
4038
- */
4039
- async getNetwork() {
4040
- const {
4041
- name,
4042
- consensusParameters: { chainId }
4043
- } = await this.getChain();
4044
- const network = new import_ethers.Network(name, chainId.toNumber());
4045
- return Promise.resolve(network);
4046
- }
4047
3924
  /**
4048
3925
  * Returns the block number.
4049
3926
  *
@@ -4051,7 +3928,7 @@ var _Provider = class {
4051
3928
  */
4052
3929
  async getBlockNumber() {
4053
3930
  const { chain } = await this.operations.getChain();
4054
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3931
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4055
3932
  }
4056
3933
  /**
4057
3934
  * Returns the chain information.
@@ -4061,11 +3938,13 @@ var _Provider = class {
4061
3938
  async fetchNode() {
4062
3939
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
3940
  const processedNodeInfo = {
4064
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4065
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3941
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3942
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3943
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4066
3944
  nodeVersion: nodeInfo.nodeVersion,
4067
3945
  utxoValidation: nodeInfo.utxoValidation,
4068
- vmBacktrace: nodeInfo.vmBacktrace
3946
+ vmBacktrace: nodeInfo.vmBacktrace,
3947
+ peers: nodeInfo.peers
4069
3948
  };
4070
3949
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4071
3950
  return processedNodeInfo;
@@ -4118,9 +3997,9 @@ var _Provider = class {
4118
3997
  if (estimateTxDependencies) {
4119
3998
  await this.estimateTxDependencies(transactionRequest);
4120
3999
  }
4121
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4000
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4122
4001
  let abis;
4123
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4002
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4124
4003
  abis = transactionRequest.abis;
4125
4004
  }
4126
4005
  if (awaitExecution) {
@@ -4161,14 +4040,15 @@ var _Provider = class {
4161
4040
  if (estimateTxDependencies) {
4162
4041
  return this.estimateTxDependencies(transactionRequest);
4163
4042
  }
4164
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4165
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4166
- encodedTransactions: encodedTransaction,
4043
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4044
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4045
+ encodedTransaction,
4167
4046
  utxoValidation: utxoValidation || false
4168
4047
  });
4169
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4170
- const receipts = rawReceipts.map(processGqlReceipt);
4171
- return { receipts, dryrunStatus: status };
4048
+ const receipts = gqlReceipts.map(processGqlReceipt);
4049
+ return {
4050
+ receipts
4051
+ };
4172
4052
  }
4173
4053
  /**
4174
4054
  * Verifies whether enough gas is available to complete transaction.
@@ -4179,13 +4059,13 @@ var _Provider = class {
4179
4059
  async estimatePredicates(transactionRequest) {
4180
4060
  const shouldEstimatePredicates = Boolean(
4181
4061
  transactionRequest.inputs.find(
4182
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
4062
+ (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
4183
4063
  )
4184
4064
  );
4185
4065
  if (!shouldEstimatePredicates) {
4186
4066
  return transactionRequest;
4187
4067
  }
4188
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4068
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4189
4069
  const response = await this.operations.estimatePredicates({
4190
4070
  encodedTransaction
4191
4071
  });
@@ -4194,7 +4074,7 @@ var _Provider = class {
4194
4074
  } = response;
4195
4075
  if (inputs) {
4196
4076
  inputs.forEach((input, index) => {
4197
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4077
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4198
4078
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4199
4079
  }
4200
4080
  });
@@ -4207,31 +4087,31 @@ var _Provider = class {
4207
4087
  * If there are missing variable outputs,
4208
4088
  * `addVariableOutputs` is called on the transaction.
4209
4089
  *
4090
+ * @privateRemarks
4091
+ * TODO: Investigate support for missing contract IDs
4092
+ * TODO: Add support for missing output messages
4210
4093
  *
4211
4094
  * @param transactionRequest - The transaction request object.
4212
4095
  * @returns A promise.
4213
4096
  */
4214
4097
  async estimateTxDependencies(transactionRequest) {
4215
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4098
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4216
4099
  return {
4217
4100
  receipts: [],
4218
4101
  outputVariables: 0,
4219
4102
  missingContractIds: []
4220
4103
  };
4221
4104
  }
4105
+ await this.estimatePredicates(transactionRequest);
4222
4106
  let receipts = [];
4223
4107
  const missingContractIds = [];
4224
4108
  let outputVariables = 0;
4225
- let dryrunStatus;
4226
4109
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4227
- const {
4228
- dryRun: [{ receipts: rawReceipts, status }]
4229
- } = await this.operations.dryRun({
4230
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4110
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4111
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4231
4112
  utxoValidation: false
4232
4113
  });
4233
- receipts = rawReceipts.map(processGqlReceipt);
4234
- dryrunStatus = status;
4114
+ receipts = gqlReceipts.map(processGqlReceipt);
4235
4115
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4236
4116
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4237
4117
  if (hasMissingOutputs) {
@@ -4241,10 +4121,6 @@ var _Provider = class {
4241
4121
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4242
4122
  missingContractIds.push(contractId);
4243
4123
  });
4244
- const { maxFee } = await this.estimateTxGasAndFee({
4245
- transactionRequest
4246
- });
4247
- transactionRequest.maxFee = maxFee;
4248
4124
  } else {
4249
4125
  break;
4250
4126
  }
@@ -4252,136 +4128,37 @@ var _Provider = class {
4252
4128
  return {
4253
4129
  receipts,
4254
4130
  outputVariables,
4255
- missingContractIds,
4256
- dryrunStatus
4131
+ missingContractIds
4257
4132
  };
4258
4133
  }
4259
- /**
4260
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4261
- *
4262
- * Transactions are dry run in batches. After each dry run, transactions requiring
4263
- * further modifications are identified. The method iteratively updates these transactions
4264
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4265
- *
4266
- * @param transactionRequests - Array of transaction request objects.
4267
- * @returns A promise that resolves to an array of results for each transaction.
4268
- */
4269
- async estimateMultipleTxDependencies(transactionRequests) {
4270
- const results = transactionRequests.map(() => ({
4271
- receipts: [],
4272
- outputVariables: 0,
4273
- missingContractIds: [],
4274
- dryrunStatus: void 0
4275
- }));
4276
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4277
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4278
- allRequests.forEach((req, index) => {
4279
- if (req.type === import_transactions19.TransactionType.Script) {
4280
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4281
- }
4282
- });
4283
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4284
- let attempt = 0;
4285
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4286
- const encodedTransactions = transactionsToProcess.map(
4287
- (index) => serializedTransactionsMap.get(index)
4288
- );
4289
- const dryRunResults = await this.operations.dryRun({
4290
- encodedTransactions,
4291
- utxoValidation: false
4292
- });
4293
- const nextRoundTransactions = [];
4294
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4295
- const requestIdx = transactionsToProcess[i];
4296
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4297
- const result = results[requestIdx];
4298
- result.receipts = rawReceipts.map(processGqlReceipt);
4299
- result.dryrunStatus = status;
4300
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4301
- result.receipts
4302
- );
4303
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4304
- const request = allRequests[requestIdx];
4305
- if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4306
- result.outputVariables += missingOutputVariables.length;
4307
- request.addVariableOutputs(missingOutputVariables.length);
4308
- missingOutputContractIds.forEach(({ contractId }) => {
4309
- request.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4310
- result.missingContractIds.push(contractId);
4311
- });
4312
- const { maxFee } = await this.estimateTxGasAndFee({
4313
- transactionRequest: request
4314
- });
4315
- request.maxFee = maxFee;
4316
- serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4317
- nextRoundTransactions.push(requestIdx);
4318
- }
4319
- }
4320
- transactionsToProcess = nextRoundTransactions;
4321
- attempt += 1;
4322
- }
4323
- return results;
4324
- }
4325
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4326
- if (estimateTxDependencies) {
4327
- return this.estimateMultipleTxDependencies(transactionRequests);
4328
- }
4329
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4330
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4331
- encodedTransactions,
4332
- utxoValidation: utxoValidation || false
4333
- });
4334
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4335
- const receipts = rawReceipts.map(processGqlReceipt);
4336
- return { receipts, dryrunStatus: status };
4337
- });
4338
- return results;
4339
- }
4340
4134
  /**
4341
4135
  * Estimates the transaction gas and fee based on the provided transaction request.
4342
4136
  * @param transactionRequest - The transaction request object.
4343
4137
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4344
4138
  */
4345
- async estimateTxGasAndFee(params) {
4139
+ estimateTxGasAndFee(params) {
4346
4140
  const { transactionRequest } = params;
4347
- let { gasPrice } = params;
4141
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4348
4142
  const chainInfo = this.getChain();
4349
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4143
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4144
+ transactionRequest.gasPrice = gasPrice;
4350
4145
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4351
- if (!gasPrice) {
4352
- gasPrice = await this.estimateGasPrice(10);
4353
- }
4354
- const minFee = calculateGasFee({
4355
- gasPrice: (0, import_math16.bn)(gasPrice),
4356
- gas: minGas,
4357
- priceFactor: gasPriceFactor,
4358
- tip: transactionRequest.tip
4359
- }).add(1);
4360
- let gasLimit = (0, import_math16.bn)(0);
4361
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4362
- gasLimit = transactionRequest.gasLimit;
4146
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4147
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4363
4148
  if (transactionRequest.gasLimit.eq(0)) {
4364
4149
  transactionRequest.gasLimit = minGas;
4365
4150
  transactionRequest.gasLimit = maxGasPerTx.sub(
4366
4151
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4367
4152
  );
4368
- gasLimit = transactionRequest.gasLimit;
4369
4153
  }
4370
4154
  }
4371
4155
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4372
- const maxFee = calculateGasFee({
4373
- gasPrice: (0, import_math16.bn)(gasPrice),
4374
- gas: maxGas,
4375
- priceFactor: gasPriceFactor,
4376
- tip: transactionRequest.tip
4377
- }).add(1);
4156
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4378
4157
  return {
4379
4158
  minGas,
4380
4159
  minFee,
4381
4160
  maxGas,
4382
- maxFee,
4383
- gasPrice,
4384
- gasLimit
4161
+ maxFee
4385
4162
  };
4386
4163
  }
4387
4164
  /**
@@ -4399,17 +4176,15 @@ var _Provider = class {
4399
4176
  if (estimateTxDependencies) {
4400
4177
  return this.estimateTxDependencies(transactionRequest);
4401
4178
  }
4402
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4403
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4404
- encodedTransactions,
4179
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4180
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4181
+ encodedTransaction,
4405
4182
  utxoValidation: true
4406
4183
  });
4407
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4408
- const { id, receipts, status } = dryRunStatus;
4409
- const processedReceipts = receipts.map(processGqlReceipt);
4410
- return { id, receipts: processedReceipts, status };
4411
- });
4412
- return { receipts: callResult[0].receipts };
4184
+ const receipts = gqlReceipts.map(processGqlReceipt);
4185
+ return {
4186
+ receipts
4187
+ };
4413
4188
  }
4414
4189
  /**
4415
4190
  * Returns a transaction cost to enable user
@@ -4426,80 +4201,78 @@ var _Provider = class {
4426
4201
  * @param tolerance - The tolerance to add on top of the gasUsed.
4427
4202
  * @returns A promise that resolves to the transaction cost object.
4428
4203
  */
4429
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4204
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4205
+ estimateTxDependencies = true,
4206
+ estimatePredicates = true,
4207
+ resourcesOwner,
4208
+ signatureCallback
4209
+ } = {}) {
4430
4210
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4431
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4211
+ const { minGasPrice } = this.getGasConfig();
4212
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4213
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4432
4214
  const baseAssetId = this.getBaseAssetId();
4433
4215
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4434
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4216
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4435
4217
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4436
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4437
4218
  if (isScriptTransaction) {
4438
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4219
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4439
4220
  }
4440
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4441
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4221
+ if (estimatePredicates) {
4222
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4223
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4224
+ }
4225
+ await this.estimatePredicates(txRequestClone);
4442
4226
  }
4443
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4444
- let addedSignatures = 0;
4445
4227
  if (signatureCallback && isScriptTransaction) {
4446
- const lengthBefore = signedRequest.witnesses.length;
4447
- await signatureCallback(signedRequest);
4448
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4228
+ await signatureCallback(txRequestClone);
4449
4229
  }
4450
- await this.estimatePredicates(signedRequest);
4451
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4452
- transactionRequest: signedRequest
4230
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4231
+ transactionRequest: txRequestClone
4453
4232
  });
4454
4233
  let receipts = [];
4455
4234
  let missingContractIds = [];
4456
4235
  let outputVariables = 0;
4457
- let gasUsed = (0, import_math16.bn)(0);
4458
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4459
- txRequestClone.maxFee = maxFee;
4460
- if (isScriptTransaction) {
4461
- txRequestClone.gasLimit = gasLimit;
4462
- if (signatureCallback) {
4463
- await signatureCallback(txRequestClone);
4464
- }
4236
+ let gasUsed = (0, import_math15.bn)(0);
4237
+ if (isScriptTransaction && estimateTxDependencies) {
4238
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4465
4239
  const result = await this.estimateTxDependencies(txRequestClone);
4466
4240
  receipts = result.receipts;
4467
4241
  outputVariables = result.outputVariables;
4468
4242
  missingContractIds = result.missingContractIds;
4469
4243
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4470
4244
  txRequestClone.gasLimit = gasUsed;
4471
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4472
- transactionRequest: txRequestClone,
4473
- gasPrice
4245
+ txRequestClone.gasPrice = setGasPrice;
4246
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4247
+ transactionRequest: txRequestClone
4474
4248
  }));
4475
4249
  }
4476
4250
  return {
4477
4251
  requiredQuantities: allQuantities,
4478
4252
  receipts,
4479
4253
  gasUsed,
4480
- gasPrice,
4254
+ minGasPrice,
4255
+ gasPrice: setGasPrice,
4481
4256
  minGas,
4482
4257
  maxGas,
4483
4258
  minFee,
4484
4259
  maxFee,
4260
+ estimatedInputs: txRequestClone.inputs,
4485
4261
  outputVariables,
4486
- missingContractIds,
4487
- addedSignatures,
4488
- estimatedPredicates: txRequestClone.inputs
4262
+ missingContractIds
4489
4263
  };
4490
4264
  }
4491
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4265
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4492
4266
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4493
4267
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4494
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4495
- quantitiesToContract
4496
- });
4268
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4497
4269
  transactionRequest.addResources(
4498
4270
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4499
4271
  );
4500
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4501
- quantitiesToContract
4502
- });
4272
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4273
+ transactionRequest,
4274
+ forwardingQuantities
4275
+ );
4503
4276
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4504
4277
  return {
4505
4278
  resources,
@@ -4515,16 +4288,17 @@ var _Provider = class {
4515
4288
  const result = await this.operations.getCoins({
4516
4289
  first: 10,
4517
4290
  ...paginationArgs,
4518
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4291
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4519
4292
  });
4520
4293
  const coins = result.coins.edges.map((edge) => edge.node);
4521
4294
  return coins.map((coin) => ({
4522
4295
  id: coin.utxoId,
4523
4296
  assetId: coin.assetId,
4524
- amount: (0, import_math16.bn)(coin.amount),
4297
+ amount: (0, import_math15.bn)(coin.amount),
4525
4298
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4526
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4527
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4299
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4300
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4301
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4528
4302
  }));
4529
4303
  }
4530
4304
  /**
@@ -4538,19 +4312,19 @@ var _Provider = class {
4538
4312
  async getResourcesToSpend(owner, quantities, excludedIds) {
4539
4313
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4540
4314
  const excludeInput = {
4541
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4542
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4315
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4316
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4543
4317
  };
4544
4318
  if (this.cache) {
4545
4319
  const uniqueUtxos = new Set(
4546
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4320
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4547
4321
  );
4548
4322
  excludeInput.utxos = Array.from(uniqueUtxos);
4549
4323
  }
4550
4324
  const coinsQuery = {
4551
4325
  owner: ownerAddress.toB256(),
4552
4326
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4553
- assetId: (0, import_utils22.hexlify)(assetId),
4327
+ assetId: (0, import_utils23.hexlify)(assetId),
4554
4328
  amount: amount.toString(10),
4555
4329
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4556
4330
  })),
@@ -4561,9 +4335,9 @@ var _Provider = class {
4561
4335
  switch (coin.__typename) {
4562
4336
  case "MessageCoin":
4563
4337
  return {
4564
- amount: (0, import_math16.bn)(coin.amount),
4338
+ amount: (0, import_math15.bn)(coin.amount),
4565
4339
  assetId: coin.assetId,
4566
- daHeight: (0, import_math16.bn)(coin.daHeight),
4340
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4567
4341
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4568
4342
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4569
4343
  nonce: coin.nonce
@@ -4571,11 +4345,12 @@ var _Provider = class {
4571
4345
  case "Coin":
4572
4346
  return {
4573
4347
  id: coin.utxoId,
4574
- amount: (0, import_math16.bn)(coin.amount),
4348
+ amount: (0, import_math15.bn)(coin.amount),
4575
4349
  assetId: coin.assetId,
4576
4350
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4577
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4578
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4351
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4352
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4353
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4579
4354
  };
4580
4355
  default:
4581
4356
  return null;
@@ -4592,13 +4367,13 @@ var _Provider = class {
4592
4367
  async getBlock(idOrHeight) {
4593
4368
  let variables;
4594
4369
  if (typeof idOrHeight === "number") {
4595
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4370
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4596
4371
  } else if (idOrHeight === "latest") {
4597
4372
  variables = { height: (await this.getBlockNumber()).toString(10) };
4598
4373
  } else if (idOrHeight.length === 66) {
4599
4374
  variables = { blockId: idOrHeight };
4600
4375
  } else {
4601
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4376
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4602
4377
  }
4603
4378
  const { block } = await this.operations.getBlock(variables);
4604
4379
  if (!block) {
@@ -4606,7 +4381,7 @@ var _Provider = class {
4606
4381
  }
4607
4382
  return {
4608
4383
  id: block.id,
4609
- height: (0, import_math16.bn)(block.height),
4384
+ height: (0, import_math15.bn)(block.header.height),
4610
4385
  time: block.header.time,
4611
4386
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4387
  };
@@ -4621,7 +4396,7 @@ var _Provider = class {
4621
4396
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4622
4397
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4623
4398
  id: block.id,
4624
- height: (0, import_math16.bn)(block.height),
4399
+ height: (0, import_math15.bn)(block.header.height),
4625
4400
  time: block.header.time,
4626
4401
  transactionIds: block.transactions.map((tx) => tx.id)
4627
4402
  }));
@@ -4636,7 +4411,7 @@ var _Provider = class {
4636
4411
  async getBlockWithTransactions(idOrHeight) {
4637
4412
  let variables;
4638
4413
  if (typeof idOrHeight === "number") {
4639
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4414
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4640
4415
  } else if (idOrHeight === "latest") {
4641
4416
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4642
4417
  } else {
@@ -4648,11 +4423,11 @@ var _Provider = class {
4648
4423
  }
4649
4424
  return {
4650
4425
  id: block.id,
4651
- height: (0, import_math16.bn)(block.height, 10),
4426
+ height: (0, import_math15.bn)(block.header.height, 10),
4652
4427
  time: block.header.time,
4653
4428
  transactionIds: block.transactions.map((tx) => tx.id),
4654
4429
  transactions: block.transactions.map(
4655
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4430
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4656
4431
  )
4657
4432
  };
4658
4433
  }
@@ -4667,8 +4442,8 @@ var _Provider = class {
4667
4442
  if (!transaction) {
4668
4443
  return null;
4669
4444
  }
4670
- return new import_transactions19.TransactionCoder().decode(
4671
- (0, import_utils22.arrayify)(transaction.rawPayload),
4445
+ return new import_transactions18.TransactionCoder().decode(
4446
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4672
4447
  0
4673
4448
  )?.[0];
4674
4449
  }
@@ -4695,9 +4470,9 @@ var _Provider = class {
4695
4470
  async getContractBalance(contractId, assetId) {
4696
4471
  const { contractBalance } = await this.operations.getContractBalance({
4697
4472
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4698
- asset: (0, import_utils22.hexlify)(assetId)
4473
+ asset: (0, import_utils23.hexlify)(assetId)
4699
4474
  });
4700
- return (0, import_math16.bn)(contractBalance.amount, 10);
4475
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4701
4476
  }
4702
4477
  /**
4703
4478
  * Returns the balance for the given owner for the given asset ID.
@@ -4709,9 +4484,9 @@ var _Provider = class {
4709
4484
  async getBalance(owner, assetId) {
4710
4485
  const { balance } = await this.operations.getBalance({
4711
4486
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4712
- assetId: (0, import_utils22.hexlify)(assetId)
4487
+ assetId: (0, import_utils23.hexlify)(assetId)
4713
4488
  });
4714
- return (0, import_math16.bn)(balance.amount, 10);
4489
+ return (0, import_math15.bn)(balance.amount, 10);
4715
4490
  }
4716
4491
  /**
4717
4492
  * Returns balances for the given owner.
@@ -4729,7 +4504,7 @@ var _Provider = class {
4729
4504
  const balances = result.balances.edges.map((edge) => edge.node);
4730
4505
  return balances.map((balance) => ({
4731
4506
  assetId: balance.assetId,
4732
- amount: (0, import_math16.bn)(balance.amount)
4507
+ amount: (0, import_math15.bn)(balance.amount)
4733
4508
  }));
4734
4509
  }
4735
4510
  /**
@@ -4747,19 +4522,19 @@ var _Provider = class {
4747
4522
  });
4748
4523
  const messages = result.messages.edges.map((edge) => edge.node);
4749
4524
  return messages.map((message) => ({
4750
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4525
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4751
4526
  sender: message.sender,
4752
4527
  recipient: message.recipient,
4753
4528
  nonce: message.nonce,
4754
- amount: (0, import_math16.bn)(message.amount),
4529
+ amount: (0, import_math15.bn)(message.amount),
4755
4530
  data: message.data
4756
4531
  }),
4757
4532
  sender: import_address3.Address.fromAddressOrString(message.sender),
4758
4533
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4759
4534
  nonce: message.nonce,
4760
- amount: (0, import_math16.bn)(message.amount),
4761
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4762
- daHeight: (0, import_math16.bn)(message.daHeight)
4535
+ amount: (0, import_math15.bn)(message.amount),
4536
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4537
+ daHeight: (0, import_math15.bn)(message.daHeight)
4763
4538
  }));
4764
4539
  }
4765
4540
  /**
@@ -4812,60 +4587,44 @@ var _Provider = class {
4812
4587
  } = result.messageProof;
4813
4588
  return {
4814
4589
  messageProof: {
4815
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4590
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4816
4591
  proofSet: messageProof.proofSet
4817
4592
  },
4818
4593
  blockProof: {
4819
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4594
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4820
4595
  proofSet: blockProof.proofSet
4821
4596
  },
4822
4597
  messageBlockHeader: {
4823
4598
  id: messageBlockHeader.id,
4824
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4825
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4599
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4600
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4826
4601
  transactionsRoot: messageBlockHeader.transactionsRoot,
4827
- height: (0, import_math16.bn)(messageBlockHeader.height),
4602
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4828
4603
  prevRoot: messageBlockHeader.prevRoot,
4829
4604
  time: messageBlockHeader.time,
4830
4605
  applicationHash: messageBlockHeader.applicationHash,
4831
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4832
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4833
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4834
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4835
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4606
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4607
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4836
4608
  },
4837
4609
  commitBlockHeader: {
4838
4610
  id: commitBlockHeader.id,
4839
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4840
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4611
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4612
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4841
4613
  transactionsRoot: commitBlockHeader.transactionsRoot,
4842
- height: (0, import_math16.bn)(commitBlockHeader.height),
4614
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4843
4615
  prevRoot: commitBlockHeader.prevRoot,
4844
4616
  time: commitBlockHeader.time,
4845
4617
  applicationHash: commitBlockHeader.applicationHash,
4846
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4847
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4848
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4849
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4850
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4618
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4619
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4851
4620
  },
4852
4621
  sender: import_address3.Address.fromAddressOrString(sender),
4853
4622
  recipient: import_address3.Address.fromAddressOrString(recipient),
4854
4623
  nonce,
4855
- amount: (0, import_math16.bn)(amount),
4624
+ amount: (0, import_math15.bn)(amount),
4856
4625
  data
4857
4626
  };
4858
4627
  }
4859
- async getLatestGasPrice() {
4860
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4861
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4862
- }
4863
- async estimateGasPrice(blockHorizon) {
4864
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4865
- blockHorizon: String(blockHorizon)
4866
- });
4867
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4868
- }
4869
4628
  /**
4870
4629
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4871
4630
  *
@@ -4885,10 +4644,10 @@ var _Provider = class {
4885
4644
  */
4886
4645
  async produceBlocks(amount, startTime) {
4887
4646
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4888
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4889
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4647
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4648
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4890
4649
  });
4891
- return (0, import_math16.bn)(latestBlockHeight);
4650
+ return (0, import_math15.bn)(latestBlockHeight);
4892
4651
  }
4893
4652
  // eslint-disable-next-line @typescript-eslint/require-await
4894
4653
  async getTransactionResponse(transactionId) {
@@ -4902,7 +4661,7 @@ cacheInputs_fn = function(inputs) {
4902
4661
  return;
4903
4662
  }
4904
4663
  inputs.forEach((input) => {
4905
- if (input.type === import_transactions19.InputType.Coin) {
4664
+ if (input.type === import_transactions18.InputType.Coin) {
4906
4665
  this.cache?.set(input.id);
4907
4666
  }
4908
4667
  });
@@ -4912,9 +4671,9 @@ __publicField(Provider, "nodeInfoCache", {});
4912
4671
 
4913
4672
  // src/providers/transaction-summary/get-transaction-summary.ts
4914
4673
  var import_errors15 = require("@fuel-ts/errors");
4915
- var import_math17 = require("@fuel-ts/math");
4916
- var import_transactions20 = require("@fuel-ts/transactions");
4917
- var import_utils25 = require("@fuel-ts/utils");
4674
+ var import_math16 = require("@fuel-ts/math");
4675
+ var import_transactions19 = require("@fuel-ts/transactions");
4676
+ var import_utils26 = require("@fuel-ts/utils");
4918
4677
  async function getTransactionSummary(params) {
4919
4678
  const { id, provider, abiMap } = params;
4920
4679
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4926,32 +4685,25 @@ async function getTransactionSummary(params) {
4926
4685
  `Transaction not found for given id: ${id}.`
4927
4686
  );
4928
4687
  }
4929
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4930
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4688
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4689
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4931
4690
  0
4932
4691
  );
4933
- let txReceipts = [];
4934
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4935
- txReceipts = gqlTransaction.status.receipts;
4936
- }
4937
- const receipts = txReceipts.map(processGqlReceipt);
4692
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4938
4693
  const {
4939
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4694
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4940
4695
  } = provider.getChain();
4941
- const gasPrice = await provider.getLatestGasPrice();
4942
4696
  const transactionInfo = assembleTransactionSummary({
4943
4697
  id: gqlTransaction.id,
4944
4698
  receipts,
4945
4699
  transaction: decodedTransaction,
4946
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4700
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4947
4701
  gqlTransactionStatus: gqlTransaction.status,
4948
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4949
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4702
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4703
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4950
4704
  abiMap,
4951
4705
  maxInputs,
4952
- gasCosts,
4953
- maxGasPerTx,
4954
- gasPrice
4706
+ gasCosts
4955
4707
  });
4956
4708
  return {
4957
4709
  gqlTransaction,
@@ -4961,11 +4713,10 @@ async function getTransactionSummary(params) {
4961
4713
  async function getTransactionSummaryFromRequest(params) {
4962
4714
  const { provider, transactionRequest, abiMap } = params;
4963
4715
  const { receipts } = await provider.call(transactionRequest);
4964
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4716
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4965
4717
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4966
4718
  const transaction = transactionRequest.toTransaction();
4967
4719
  const transactionBytes = transactionRequest.toTransactionBytes();
4968
- const gasPrice = await provider.getLatestGasPrice();
4969
4720
  const transactionSummary = assembleTransactionSummary({
4970
4721
  receipts,
4971
4722
  transaction,
@@ -4974,9 +4725,7 @@ async function getTransactionSummaryFromRequest(params) {
4974
4725
  gasPerByte,
4975
4726
  gasPriceFactor,
4976
4727
  maxInputs,
4977
- gasCosts,
4978
- maxGasPerTx,
4979
- gasPrice
4728
+ gasCosts
4980
4729
  });
4981
4730
  return transactionSummary;
4982
4731
  }
@@ -4985,31 +4734,24 @@ async function getTransactionsSummaries(params) {
4985
4734
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4986
4735
  const { edges, pageInfo } = transactionsByOwner;
4987
4736
  const {
4988
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4737
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4989
4738
  } = provider.getChain();
4990
- const gasPrice = await provider.getLatestGasPrice();
4991
4739
  const transactions = edges.map((edge) => {
4992
4740
  const { node: gqlTransaction } = edge;
4993
- const { id, rawPayload, status } = gqlTransaction;
4994
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4995
- let txReceipts = [];
4996
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4997
- txReceipts = gqlTransaction.status.receipts;
4998
- }
4999
- const receipts = txReceipts.map(processGqlReceipt);
4741
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4742
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4743
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
5000
4744
  const transactionSummary = assembleTransactionSummary({
5001
4745
  id,
5002
4746
  receipts,
5003
4747
  transaction: decodedTransaction,
5004
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4748
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
5005
4749
  gqlTransactionStatus: status,
5006
4750
  abiMap,
5007
4751
  gasPerByte,
5008
4752
  gasPriceFactor,
5009
4753
  maxInputs,
5010
- gasCosts,
5011
- maxGasPerTx,
5012
- gasPrice
4754
+ gasCosts
5013
4755
  });
5014
4756
  const output = {
5015
4757
  gqlTransaction,
@@ -5146,17 +4888,17 @@ var assets = [
5146
4888
 
5147
4889
  // src/utils/formatTransferToContractScriptData.ts
5148
4890
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5149
- var import_math18 = require("@fuel-ts/math");
5150
- var import_utils26 = require("@fuel-ts/utils");
4891
+ var import_math17 = require("@fuel-ts/math");
4892
+ var import_utils27 = require("@fuel-ts/utils");
5151
4893
  var asm = __toESM(require("@fuels/vm-asm"));
5152
4894
  var formatTransferToContractScriptData = (params) => {
5153
4895
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5154
4896
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5155
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4897
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5156
4898
  const scriptData = Uint8Array.from([
5157
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4899
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5158
4900
  ...encoded,
5159
- ...(0, import_utils26.arrayify)(assetId)
4901
+ ...(0, import_utils27.arrayify)(assetId)
5160
4902
  ]);
5161
4903
  return scriptData;
5162
4904
  };
@@ -5342,31 +5084,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5342
5084
  * @param fee - The estimated transaction fee.
5343
5085
  * @returns A promise that resolves when the resources are added to the transaction.
5344
5086
  */
5345
- async fund(request, params) {
5346
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5087
+ async fund(request, coinQuantities, fee) {
5347
5088
  const baseAssetId = this.provider.getBaseAssetId();
5348
- const txRequest = request;
5349
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5350
- amount: (0, import_math19.bn)(fee),
5089
+ const updatedQuantities = addAmountToAsset({
5090
+ amount: (0, import_math18.bn)(fee),
5351
5091
  assetId: baseAssetId,
5352
- coinQuantities: requiredQuantities
5092
+ coinQuantities
5353
5093
  });
5354
5094
  const quantitiesDict = {};
5355
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5095
+ updatedQuantities.forEach(({ amount, assetId }) => {
5356
5096
  quantitiesDict[assetId] = {
5357
5097
  required: amount,
5358
- owned: (0, import_math19.bn)(0)
5098
+ owned: (0, import_math18.bn)(0)
5359
5099
  };
5360
5100
  });
5361
- txRequest.inputs.forEach((input) => {
5101
+ const cachedUtxos = [];
5102
+ const cachedMessages = [];
5103
+ const owner = this.address.toB256();
5104
+ request.inputs.forEach((input) => {
5362
5105
  const isResource = "amount" in input;
5363
- if (!isResource) {
5364
- return;
5365
- }
5366
- const isCoin2 = "owner" in input;
5367
- const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
5368
- if (quantitiesDict[assetId]) {
5369
- quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
5106
+ if (isResource) {
5107
+ const isCoin2 = "owner" in input;
5108
+ if (isCoin2) {
5109
+ const assetId = String(input.assetId);
5110
+ if (input.owner === owner && quantitiesDict[assetId]) {
5111
+ const amount = (0, import_math18.bn)(input.amount);
5112
+ quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5113
+ cachedUtxos.push(input.id);
5114
+ }
5115
+ } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
5116
+ quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
5117
+ cachedMessages.push(input.nonce);
5118
+ }
5370
5119
  }
5371
5120
  });
5372
5121
  const missingQuantities = [];
@@ -5380,21 +5129,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5380
5129
  });
5381
5130
  const needsToBeFunded = missingQuantities.length;
5382
5131
  if (needsToBeFunded) {
5383
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5384
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5385
- txRequest.addResources(resources);
5386
- }
5387
- txRequest.shiftPredicateData();
5388
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5389
- const requestToReestimate = (0, import_ramda4.clone)(txRequest);
5390
- if (addedSignatures) {
5391
- Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5392
- }
5393
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5394
- transactionRequest: requestToReestimate
5395
- });
5396
- txRequest.maxFee = maxFee;
5397
- return txRequest;
5132
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5133
+ messages: cachedMessages,
5134
+ utxos: cachedUtxos
5135
+ });
5136
+ request.addResources(resources);
5137
+ }
5398
5138
  }
5399
5139
  /**
5400
5140
  * A helper that creates a transfer transaction request and returns it.
@@ -5402,25 +5142,29 @@ var Account = class extends import_interfaces.AbstractAccount {
5402
5142
  * @param destination - The address of the destination.
5403
5143
  * @param amount - The amount of coins to transfer.
5404
5144
  * @param assetId - The asset ID of the coins to transfer.
5405
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5145
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5406
5146
  * @returns A promise that resolves to the prepared transaction request.
5407
5147
  */
5408
5148
  async createTransfer(destination, amount, assetId, txParams = {}) {
5409
- const request = new ScriptTransactionRequest(txParams);
5149
+ const { minGasPrice } = this.provider.getGasConfig();
5410
5150
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5151
+ const params = { gasPrice: minGasPrice, ...txParams };
5152
+ const request = new ScriptTransactionRequest(params);
5411
5153
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5412
- const txCost = await this.provider.getTransactionCost(request, {
5154
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5413
5155
  estimateTxDependencies: true,
5414
5156
  resourcesOwner: this
5415
5157
  });
5416
- this.validateGasLimitAndMaxFee({
5417
- gasUsed: txCost.gasUsed,
5418
- maxFee: txCost.maxFee,
5419
- txParams
5158
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5159
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5160
+ this.validateGas({
5161
+ gasUsed,
5162
+ gasPrice: request.gasPrice,
5163
+ gasLimit: request.gasLimit,
5164
+ minGasPrice
5420
5165
  });
5421
- request.gasLimit = txCost.gasUsed;
5422
- request.maxFee = txCost.maxFee;
5423
- await this.fund(request, txCost);
5166
+ await this.fund(request, requiredQuantities, maxFee);
5167
+ request.updatePredicateInputs(estimatedInputs);
5424
5168
  return request;
5425
5169
  }
5426
5170
  /**
@@ -5429,11 +5173,11 @@ var Account = class extends import_interfaces.AbstractAccount {
5429
5173
  * @param destination - The address of the destination.
5430
5174
  * @param amount - The amount of coins to transfer.
5431
5175
  * @param assetId - The asset ID of the coins to transfer.
5432
- * @param txParams - The transaction parameters (gasLimit, maturity).
5176
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5433
5177
  * @returns A promise that resolves to the transaction response.
5434
5178
  */
5435
5179
  async transfer(destination, amount, assetId, txParams = {}) {
5436
- if ((0, import_math19.bn)(amount).lte(0)) {
5180
+ if ((0, import_math18.bn)(amount).lte(0)) {
5437
5181
  throw new import_errors16.FuelError(
5438
5182
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5439
5183
  "Transfer amount must be a positive number."
@@ -5453,37 +5197,39 @@ var Account = class extends import_interfaces.AbstractAccount {
5453
5197
  * @returns A promise that resolves to the transaction response.
5454
5198
  */
5455
5199
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5456
- if ((0, import_math19.bn)(amount).lte(0)) {
5200
+ if ((0, import_math18.bn)(amount).lte(0)) {
5457
5201
  throw new import_errors16.FuelError(
5458
5202
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5459
5203
  "Transfer amount must be a positive number."
5460
5204
  );
5461
5205
  }
5462
5206
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5207
+ const { minGasPrice } = this.provider.getGasConfig();
5463
5208
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5209
+ const params = { gasPrice: minGasPrice, ...txParams };
5464
5210
  const { script, scriptData } = await assembleTransferToContractScript({
5465
5211
  hexlifiedContractId: contractAddress.toB256(),
5466
- amountToTransfer: (0, import_math19.bn)(amount),
5212
+ amountToTransfer: (0, import_math18.bn)(amount),
5467
5213
  assetId: assetIdToTransfer
5468
5214
  });
5469
5215
  const request = new ScriptTransactionRequest({
5470
- ...txParams,
5216
+ ...params,
5471
5217
  script,
5472
5218
  scriptData
5473
5219
  });
5474
5220
  request.addContractInputAndOutput(contractAddress);
5475
- const txCost = await this.provider.getTransactionCost(request, {
5476
- resourcesOwner: this,
5477
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
5478
- });
5479
- this.validateGasLimitAndMaxFee({
5480
- gasUsed: txCost.gasUsed,
5481
- maxFee: txCost.maxFee,
5482
- txParams
5221
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5222
+ request,
5223
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetIdToTransfer) }]
5224
+ );
5225
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5226
+ this.validateGas({
5227
+ gasUsed,
5228
+ gasPrice: request.gasPrice,
5229
+ gasLimit: request.gasLimit,
5230
+ minGasPrice
5483
5231
  });
5484
- request.gasLimit = txCost.gasUsed;
5485
- request.maxFee = txCost.maxFee;
5486
- await this.fund(request, txCost);
5232
+ await this.fund(request, requiredQuantities, maxFee);
5487
5233
  return this.sendTransaction(request);
5488
5234
  }
5489
5235
  /**
@@ -5495,31 +5241,39 @@ var Account = class extends import_interfaces.AbstractAccount {
5495
5241
  * @returns A promise that resolves to the transaction response.
5496
5242
  */
5497
5243
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5244
+ const { minGasPrice } = this.provider.getGasConfig();
5245
+ const baseAssetId = this.provider.getBaseAssetId();
5498
5246
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5499
- const recipientDataArray = (0, import_utils27.arrayify)(
5247
+ const recipientDataArray = (0, import_utils28.arrayify)(
5500
5248
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5501
5249
  );
5502
- const amountDataArray = (0, import_utils27.arrayify)(
5503
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5250
+ const amountDataArray = (0, import_utils28.arrayify)(
5251
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5504
5252
  );
5505
5253
  const script = new Uint8Array([
5506
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5254
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5507
5255
  ...recipientDataArray,
5508
5256
  ...amountDataArray
5509
5257
  ]);
5510
- const params = { script, ...txParams };
5511
- const baseAssetId = this.provider.getBaseAssetId();
5258
+ const params = {
5259
+ script,
5260
+ gasPrice: minGasPrice,
5261
+ ...txParams
5262
+ };
5512
5263
  const request = new ScriptTransactionRequest(params);
5513
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
5514
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5515
- this.validateGasLimitAndMaxFee({
5516
- gasUsed: txCost.gasUsed,
5517
- maxFee: txCost.maxFee,
5518
- txParams
5264
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: baseAssetId }];
5265
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5266
+ request,
5267
+ forwardingQuantities
5268
+ );
5269
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5270
+ this.validateGas({
5271
+ gasUsed,
5272
+ gasPrice: request.gasPrice,
5273
+ gasLimit: request.gasLimit,
5274
+ minGasPrice
5519
5275
  });
5520
- request.maxFee = txCost.maxFee;
5521
- request.gasLimit = txCost.gasUsed;
5522
- await this.fund(request, txCost);
5276
+ await this.fund(request, requiredQuantities, maxFee);
5523
5277
  return this.sendTransaction(request);
5524
5278
  }
5525
5279
  async signMessage(message) {
@@ -5577,21 +5331,22 @@ var Account = class extends import_interfaces.AbstractAccount {
5577
5331
  }
5578
5332
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5579
5333
  }
5580
- validateGasLimitAndMaxFee({
5581
- txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
5334
+ validateGas({
5582
5335
  gasUsed,
5583
- maxFee
5336
+ gasPrice,
5337
+ gasLimit,
5338
+ minGasPrice
5584
5339
  }) {
5585
- if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
5340
+ if (minGasPrice.gt(gasPrice)) {
5586
5341
  throw new import_errors16.FuelError(
5587
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5588
- `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5342
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5343
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5589
5344
  );
5590
5345
  }
5591
- if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
5346
+ if (gasUsed.gt(gasLimit)) {
5592
5347
  throw new import_errors16.FuelError(
5593
- import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5594
- `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5348
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5349
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5595
5350
  );
5596
5351
  }
5597
5352
  }
@@ -5599,14 +5354,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5599
5354
 
5600
5355
  // src/wallet/base-wallet-unlocked.ts
5601
5356
  var import_hasher3 = require("@fuel-ts/hasher");
5602
- var import_utils30 = require("@fuel-ts/utils");
5357
+ var import_utils31 = require("@fuel-ts/utils");
5603
5358
 
5604
5359
  // src/signer/signer.ts
5605
5360
  var import_address5 = require("@fuel-ts/address");
5606
5361
  var import_crypto2 = require("@fuel-ts/crypto");
5607
5362
  var import_hasher2 = require("@fuel-ts/hasher");
5608
- var import_math20 = require("@fuel-ts/math");
5609
- var import_utils28 = require("@fuel-ts/utils");
5363
+ var import_math19 = require("@fuel-ts/math");
5364
+ var import_utils29 = require("@fuel-ts/utils");
5610
5365
  var import_secp256k1 = require("@noble/curves/secp256k1");
5611
5366
  var Signer = class {
5612
5367
  address;
@@ -5625,10 +5380,10 @@ var Signer = class {
5625
5380
  privateKey = `0x${privateKey}`;
5626
5381
  }
5627
5382
  }
5628
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5629
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5630
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5631
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5383
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5384
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5385
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5386
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5632
5387
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5633
5388
  }
5634
5389
  /**
@@ -5642,11 +5397,11 @@ var Signer = class {
5642
5397
  * @returns hashed signature
5643
5398
  */
5644
5399
  sign(data) {
5645
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5646
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5647
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5400
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5401
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5402
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5648
5403
  s[0] |= (signature.recovery || 0) << 7;
5649
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5404
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5650
5405
  }
5651
5406
  /**
5652
5407
  * Add point on the current elliptic curve
@@ -5655,8 +5410,8 @@ var Signer = class {
5655
5410
  * @returns compressed point on the curve
5656
5411
  */
5657
5412
  addPoint(point) {
5658
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5659
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5413
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5414
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5660
5415
  const result = p0.add(p1);
5661
5416
  return `0x${result.toHex(true)}`;
5662
5417
  }
@@ -5668,16 +5423,16 @@ var Signer = class {
5668
5423
  * @returns public key from signature from the
5669
5424
  */
5670
5425
  static recoverPublicKey(data, signature) {
5671
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5426
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5672
5427
  const r = signedMessageBytes.slice(0, 32);
5673
5428
  const s = signedMessageBytes.slice(32, 64);
5674
5429
  const recoveryParam = (s[0] & 128) >> 7;
5675
5430
  s[0] &= 127;
5676
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5431
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5677
5432
  recoveryParam
5678
5433
  );
5679
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5680
- return (0, import_utils28.hexlify)(publicKey);
5434
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5435
+ return (0, import_utils29.hexlify)(publicKey);
5681
5436
  }
5682
5437
  /**
5683
5438
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5696,7 +5451,7 @@ var Signer = class {
5696
5451
  * @returns random 32-byte hashed
5697
5452
  */
5698
5453
  static generatePrivateKey(entropy) {
5699
- 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);
5454
+ 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);
5700
5455
  }
5701
5456
  /**
5702
5457
  * Extended publicKey from a compact publicKey
@@ -5705,8 +5460,8 @@ var Signer = class {
5705
5460
  * @returns extended publicKey
5706
5461
  */
5707
5462
  static extendPublicKey(publicKey) {
5708
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5709
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5463
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5464
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5710
5465
  }
5711
5466
  };
5712
5467
 
@@ -5714,7 +5469,7 @@ var Signer = class {
5714
5469
  var import_address6 = require("@fuel-ts/address");
5715
5470
  var import_crypto3 = require("@fuel-ts/crypto");
5716
5471
  var import_errors17 = require("@fuel-ts/errors");
5717
- var import_utils29 = require("@fuel-ts/utils");
5472
+ var import_utils30 = require("@fuel-ts/utils");
5718
5473
  var import_uuid = require("uuid");
5719
5474
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5720
5475
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5797,7 +5552,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5797
5552
  );
5798
5553
  }
5799
5554
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5800
- const privateKey = (0, import_utils29.hexlify)(buffer);
5555
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5801
5556
  return privateKey;
5802
5557
  }
5803
5558
 
@@ -5842,7 +5597,7 @@ var BaseWalletUnlocked = class extends Account {
5842
5597
  */
5843
5598
  async signMessage(message) {
5844
5599
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5845
- return (0, import_utils30.hexlify)(signedMessage);
5600
+ return (0, import_utils31.hexlify)(signedMessage);
5846
5601
  }
5847
5602
  /**
5848
5603
  * Signs a transaction with the wallet's private key.
@@ -5855,7 +5610,7 @@ var BaseWalletUnlocked = class extends Account {
5855
5610
  const chainId = this.provider.getChainId();
5856
5611
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5857
5612
  const signature = await this.signer().sign(hashedTransaction);
5858
- return (0, import_utils30.hexlify)(signature);
5613
+ return (0, import_utils31.hexlify)(signature);
5859
5614
  }
5860
5615
  /**
5861
5616
  * Populates a transaction with the witnesses signature.
@@ -5875,7 +5630,7 @@ var BaseWalletUnlocked = class extends Account {
5875
5630
  * @param transactionRequestLike - The transaction request to send.
5876
5631
  * @returns A promise that resolves to the TransactionResponse object.
5877
5632
  */
5878
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5633
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5879
5634
  const transactionRequest = transactionRequestify(transactionRequestLike);
5880
5635
  if (estimateTxDependencies) {
5881
5636
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5916,16 +5671,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5916
5671
  // src/hdwallet/hdwallet.ts
5917
5672
  var import_errors20 = require("@fuel-ts/errors");
5918
5673
  var import_hasher6 = require("@fuel-ts/hasher");
5919
- var import_math21 = require("@fuel-ts/math");
5920
- var import_utils34 = require("@fuel-ts/utils");
5921
- var import_ethers3 = require("ethers");
5674
+ var import_math20 = require("@fuel-ts/math");
5675
+ var import_utils35 = require("@fuel-ts/utils");
5676
+ var import_ethers2 = require("ethers");
5922
5677
 
5923
5678
  // src/mnemonic/mnemonic.ts
5924
5679
  var import_crypto4 = require("@fuel-ts/crypto");
5925
5680
  var import_errors19 = require("@fuel-ts/errors");
5926
5681
  var import_hasher5 = require("@fuel-ts/hasher");
5927
- var import_utils32 = require("@fuel-ts/utils");
5928
- var import_ethers2 = require("ethers");
5682
+ var import_utils33 = require("@fuel-ts/utils");
5683
+ var import_ethers = require("ethers");
5929
5684
 
5930
5685
  // src/wordlists/words/english.ts
5931
5686
  var english = [
@@ -7988,7 +7743,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7988
7743
  // src/mnemonic/utils.ts
7989
7744
  var import_errors18 = require("@fuel-ts/errors");
7990
7745
  var import_hasher4 = require("@fuel-ts/hasher");
7991
- var import_utils31 = require("@fuel-ts/utils");
7746
+ var import_utils32 = require("@fuel-ts/utils");
7992
7747
  function toUtf8Bytes(stri) {
7993
7748
  const str = stri.normalize("NFKD");
7994
7749
  const result = [];
@@ -8055,14 +7810,14 @@ function entropyToMnemonicIndices(entropy) {
8055
7810
  }
8056
7811
  }
8057
7812
  const checksumBits = entropy.length / 4;
8058
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7813
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8059
7814
  indices[indices.length - 1] <<= checksumBits;
8060
7815
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8061
7816
  return indices;
8062
7817
  }
8063
7818
  function mnemonicWordsToEntropy(words, wordlist) {
8064
7819
  const size = Math.ceil(11 * words.length / 8);
8065
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7820
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8066
7821
  let offset = 0;
8067
7822
  for (let i = 0; i < words.length; i += 1) {
8068
7823
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8082,7 +7837,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8082
7837
  const entropyBits = 32 * words.length / 3;
8083
7838
  const checksumBits = words.length / 3;
8084
7839
  const checksumMask = getUpperMask(checksumBits);
8085
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7840
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8086
7841
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8087
7842
  throw new import_errors18.FuelError(
8088
7843
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8157,7 +7912,7 @@ var Mnemonic = class {
8157
7912
  static mnemonicToEntropy(phrase, wordlist = english) {
8158
7913
  const words = getWords(phrase);
8159
7914
  assertMnemonic(words);
8160
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7915
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8161
7916
  }
8162
7917
  /**
8163
7918
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8165,7 +7920,7 @@ var Mnemonic = class {
8165
7920
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8166
7921
  */
8167
7922
  static entropyToMnemonic(entropy, wordlist = english) {
8168
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7923
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8169
7924
  assertWordList(wordlist);
8170
7925
  assertEntropy(entropyBytes);
8171
7926
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8179,7 +7934,7 @@ var Mnemonic = class {
8179
7934
  assertMnemonic(getWords(phrase));
8180
7935
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8181
7936
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8182
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7937
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8183
7938
  }
8184
7939
  /**
8185
7940
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8234,14 +7989,14 @@ var Mnemonic = class {
8234
7989
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8235
7990
  */
8236
7991
  static masterKeysFromSeed(seed) {
8237
- const seedArray = (0, import_utils32.arrayify)(seed);
7992
+ const seedArray = (0, import_utils33.arrayify)(seed);
8238
7993
  if (seedArray.length < 16 || seedArray.length > 64) {
8239
7994
  throw new import_errors19.FuelError(
8240
7995
  import_errors19.ErrorCode.INVALID_SEED,
8241
7996
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8242
7997
  );
8243
7998
  }
8244
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7999
+ return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8245
8000
  }
8246
8001
  /**
8247
8002
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8252,22 +8007,22 @@ var Mnemonic = class {
8252
8007
  */
8253
8008
  static seedToExtendedKey(seed, testnet = false) {
8254
8009
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8255
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8010
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8256
8011
  const depth = "0x00";
8257
8012
  const fingerprint = "0x00000000";
8258
8013
  const index = "0x00000000";
8259
8014
  const chainCode = masterKey.slice(32);
8260
8015
  const privateKey = masterKey.slice(0, 32);
8261
- const extendedKey = (0, import_utils32.concat)([
8016
+ const extendedKey = (0, import_utils33.concat)([
8262
8017
  prefix,
8263
8018
  depth,
8264
8019
  fingerprint,
8265
8020
  index,
8266
8021
  chainCode,
8267
- (0, import_utils32.concat)(["0x00", privateKey])
8022
+ (0, import_utils33.concat)(["0x00", privateKey])
8268
8023
  ]);
8269
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8270
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8024
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8025
+ return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8271
8026
  }
8272
8027
  /**
8273
8028
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8282,7 +8037,7 @@ var Mnemonic = class {
8282
8037
  * @returns A randomly generated mnemonic
8283
8038
  */
8284
8039
  static generate(size = 32, extraEntropy = "") {
8285
- 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);
8040
+ 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);
8286
8041
  return Mnemonic.entropyToMnemonic(entropy);
8287
8042
  }
8288
8043
  };
@@ -8290,12 +8045,12 @@ var mnemonic_default = Mnemonic;
8290
8045
 
8291
8046
  // src/hdwallet/hdwallet.ts
8292
8047
  var HARDENED_INDEX = 2147483648;
8293
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8294
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8295
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8296
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8048
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8049
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8050
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8051
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8297
8052
  function base58check(data) {
8298
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8053
+ return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8299
8054
  }
8300
8055
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8301
8056
  if (isPublic) {
@@ -8304,11 +8059,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8304
8059
  return testnet ? TestnetPRV2 : MainnetPRV2;
8305
8060
  }
8306
8061
  function isPublicExtendedKey(extendedKey) {
8307
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8062
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8308
8063
  }
8309
8064
  function isValidExtendedKey(extendedKey) {
8310
8065
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8311
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8066
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8312
8067
  );
8313
8068
  }
8314
8069
  function parsePath(path, depth = 0) {
@@ -8326,8 +8081,8 @@ function parsePath(path, depth = 0) {
8326
8081
  var HDWallet = class {
8327
8082
  depth = 0;
8328
8083
  index = 0;
8329
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8330
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8084
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8085
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8331
8086
  privateKey;
8332
8087
  publicKey;
8333
8088
  chainCode;
@@ -8339,8 +8094,8 @@ var HDWallet = class {
8339
8094
  constructor(config) {
8340
8095
  if (config.privateKey) {
8341
8096
  const signer = new Signer(config.privateKey);
8342
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8343
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8097
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8098
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8344
8099
  } else {
8345
8100
  if (!config.publicKey) {
8346
8101
  throw new import_errors20.FuelError(
@@ -8348,10 +8103,10 @@ var HDWallet = class {
8348
8103
  "Both public and private Key cannot be missing. At least one should be provided."
8349
8104
  );
8350
8105
  }
8351
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8106
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8352
8107
  }
8353
8108
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8354
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8109
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8355
8110
  this.depth = config.depth || this.depth;
8356
8111
  this.index = config.index || this.index;
8357
8112
  this.chainCode = config.chainCode;
@@ -8367,9 +8122,9 @@ var HDWallet = class {
8367
8122
  * @returns A new instance of HDWallet on the derived index
8368
8123
  */
8369
8124
  deriveIndex(index) {
8370
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8371
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8372
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8125
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8126
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8127
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8373
8128
  const data = new Uint8Array(37);
8374
8129
  if (index & HARDENED_INDEX) {
8375
8130
  if (!privateKey) {
@@ -8380,15 +8135,15 @@ var HDWallet = class {
8380
8135
  }
8381
8136
  data.set(privateKey, 1);
8382
8137
  } else {
8383
- data.set((0, import_utils34.arrayify)(this.publicKey));
8138
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8384
8139
  }
8385
- data.set((0, import_math21.toBytes)(index, 4), 33);
8386
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8140
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8141
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8387
8142
  const IL = bytes.slice(0, 32);
8388
8143
  const IR = bytes.slice(32);
8389
8144
  if (privateKey) {
8390
8145
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8391
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8146
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8392
8147
  return new HDWallet({
8393
8148
  privateKey: ki,
8394
8149
  chainCode: IR,
@@ -8397,7 +8152,7 @@ var HDWallet = class {
8397
8152
  parentFingerprint: this.fingerprint
8398
8153
  });
8399
8154
  }
8400
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8155
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8401
8156
  const Ki = signer.addPoint(publicKey);
8402
8157
  return new HDWallet({
8403
8158
  publicKey: Ki,
@@ -8432,12 +8187,12 @@ var HDWallet = class {
8432
8187
  );
8433
8188
  }
8434
8189
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8435
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8190
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8436
8191
  const parentFingerprint = this.parentFingerprint;
8437
- const index = (0, import_math21.toHex)(this.index, 4);
8192
+ const index = (0, import_math20.toHex)(this.index, 4);
8438
8193
  const chainCode = this.chainCode;
8439
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8440
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8194
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8195
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8441
8196
  return base58check(extendedKey);
8442
8197
  }
8443
8198
  /**
@@ -8449,13 +8204,13 @@ var HDWallet = class {
8449
8204
  static fromSeed(seed) {
8450
8205
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8451
8206
  return new HDWallet({
8452
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8453
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8207
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8208
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8454
8209
  });
8455
8210
  }
8456
8211
  static fromExtendedKey(extendedKey) {
8457
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8458
- const bytes = (0, import_utils34.arrayify)(decoded);
8212
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8213
+ const bytes = (0, import_utils35.arrayify)(decoded);
8459
8214
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8460
8215
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8461
8216
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8464,9 +8219,9 @@ var HDWallet = class {
8464
8219
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8465
8220
  }
8466
8221
  const depth = bytes[4];
8467
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8468
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8469
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8222
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8223
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8224
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8470
8225
  const key = bytes.slice(45, 78);
8471
8226
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8472
8227
  throw new import_errors20.FuelError(
@@ -9070,19 +8825,19 @@ var StorageAbstract = class {
9070
8825
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9071
8826
  var import_address10 = require("@fuel-ts/address");
9072
8827
  var import_errors25 = require("@fuel-ts/errors");
9073
- var import_transactions21 = require("@fuel-ts/transactions");
9074
- var import_utils36 = require("@fuel-ts/utils");
8828
+ var import_transactions20 = require("@fuel-ts/transactions");
8829
+ var import_utils37 = require("@fuel-ts/utils");
9075
8830
 
9076
8831
  // src/predicate/utils/getPredicateRoot.ts
9077
8832
  var import_hasher7 = require("@fuel-ts/hasher");
9078
8833
  var import_merkle = require("@fuel-ts/merkle");
9079
- var import_utils35 = require("@fuel-ts/utils");
8834
+ var import_utils36 = require("@fuel-ts/utils");
9080
8835
  var getPredicateRoot = (bytecode) => {
9081
8836
  const chunkSize = 16 * 1024;
9082
- const bytes = (0, import_utils35.arrayify)(bytecode);
9083
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9084
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9085
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8837
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8838
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8839
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8840
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9086
8841
  return predicateRoot;
9087
8842
  };
9088
8843
 
@@ -9130,22 +8885,36 @@ var Predicate = class extends Account {
9130
8885
  const request = transactionRequestify(transactionRequestLike);
9131
8886
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9132
8887
  request.inputs?.forEach((input) => {
9133
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9134
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9135
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8888
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8889
+ input.predicate = this.bytes;
8890
+ input.predicateData = this.getPredicateData(policies.length);
9136
8891
  }
9137
8892
  });
9138
8893
  return request;
9139
8894
  }
8895
+ /**
8896
+ * A helper that creates a transfer transaction request and returns it.
8897
+ *
8898
+ * @param destination - The address of the destination.
8899
+ * @param amount - The amount of coins to transfer.
8900
+ * @param assetId - The asset ID of the coins to transfer.
8901
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8902
+ * @returns A promise that resolves to the prepared transaction request.
8903
+ */
8904
+ async createTransfer(destination, amount, assetId, txParams = {}) {
8905
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8906
+ const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8907
+ return this.populateTransactionPredicateData(request);
8908
+ }
9140
8909
  /**
9141
8910
  * Sends a transaction with the populated predicate data.
9142
8911
  *
9143
8912
  * @param transactionRequestLike - The transaction request-like object.
9144
8913
  * @returns A promise that resolves to the transaction response.
9145
8914
  */
9146
- sendTransaction(transactionRequestLike) {
9147
- const transactionRequest = transactionRequestify(transactionRequestLike);
9148
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8915
+ sendTransaction(transactionRequestLike, options) {
8916
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8917
+ return super.sendTransaction(transactionRequest, options);
9149
8918
  }
9150
8919
  /**
9151
8920
  * Simulates a transaction with the populated predicate data.
@@ -9154,15 +8923,15 @@ var Predicate = class extends Account {
9154
8923
  * @returns A promise that resolves to the call result.
9155
8924
  */
9156
8925
  simulateTransaction(transactionRequestLike) {
9157
- const transactionRequest = transactionRequestify(transactionRequestLike);
9158
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8926
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8927
+ return super.simulateTransaction(transactionRequest);
9159
8928
  }
9160
8929
  getPredicateData(policiesLength) {
9161
8930
  if (!this.predicateData.length) {
9162
8931
  return new Uint8Array();
9163
8932
  }
9164
8933
  const mainFn = this.interface?.functions.main;
9165
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8934
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9166
8935
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9167
8936
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9168
8937
  });
@@ -9178,7 +8947,7 @@ var Predicate = class extends Account {
9178
8947
  * @returns An object containing the new predicate bytes and interface.
9179
8948
  */
9180
8949
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9181
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8950
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9182
8951
  let abiInterface;
9183
8952
  if (jsonAbi) {
9184
8953
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9201,25 +8970,6 @@ var Predicate = class extends Account {
9201
8970
  predicateInterface: abiInterface
9202
8971
  };
9203
8972
  }
9204
- /**
9205
- * Retrieves resources satisfying the spend query for the account.
9206
- *
9207
- * @param quantities - IDs of coins to exclude.
9208
- * @param excludedIds - IDs of resources to be excluded from the query.
9209
- * @returns A promise that resolves to an array of Resources.
9210
- */
9211
- async getResourcesToSpend(quantities, excludedIds) {
9212
- const resources = await this.provider.getResourcesToSpend(
9213
- this.address,
9214
- quantities,
9215
- excludedIds
9216
- );
9217
- return resources.map((resource) => ({
9218
- ...resource,
9219
- predicate: (0, import_utils36.hexlify)(this.bytes),
9220
- padPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9221
- }));
9222
- }
9223
8973
  /**
9224
8974
  * Sets the configurable constants for the predicate.
9225
8975
  *
@@ -9969,7 +9719,7 @@ __publicField(Fuel, "defaultConfig", {});
9969
9719
  WalletLocked,
9970
9720
  WalletManager,
9971
9721
  WalletUnlocked,
9972
- addAmountToCoinQuantities,
9722
+ addAmountToAsset,
9973
9723
  addOperation,
9974
9724
  assemblePanicError,
9975
9725
  assembleReceiptByType,
@@ -9978,10 +9728,9 @@ __publicField(Fuel, "defaultConfig", {});
9978
9728
  assets,
9979
9729
  buildBlockExplorerUrl,
9980
9730
  cacheFor,
9981
- cacheTxInputsFromOwner,
9982
- calculateGasFee,
9983
9731
  calculateMetadataGasForTxCreate,
9984
9732
  calculateMetadataGasForTxScript,
9733
+ calculatePriceWithFactor,
9985
9734
  calculateTransactionFee,
9986
9735
  coinQuantityfy,
9987
9736
  deferPromise,