@fuel-ts/account 0.0.0-rc-2021-20240415193305 → 0.0.0-rc-2045-20240416150348

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +545 -796
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +507 -762
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +388 -642
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  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/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -7
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +27 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +25 -8
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1057 -1546
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +503 -740
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +397 -634
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  WalletLocked: () => WalletLocked,
96
96
  WalletManager: () => WalletManager,
97
97
  WalletUnlocked: () => WalletUnlocked,
98
- addAmountToCoinQuantities: () => addAmountToCoinQuantities,
98
+ addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,10 +104,9 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
- cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
- calculateGasFee: () => calculateGasFee,
109
107
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
108
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
+ calculatePriceWithFactor: () => calculatePriceWithFactor,
111
110
  calculateTransactionFee: () => calculateTransactionFee,
112
111
  coinQuantityfy: () => coinQuantityfy,
113
112
  deferPromise: () => deferPromise,
@@ -188,9 +187,8 @@ var import_address4 = require("@fuel-ts/address");
188
187
  var import_configs12 = require("@fuel-ts/address/configs");
189
188
  var import_errors16 = require("@fuel-ts/errors");
190
189
  var import_interfaces = require("@fuel-ts/interfaces");
191
- var import_math19 = require("@fuel-ts/math");
192
- var import_utils27 = require("@fuel-ts/utils");
193
- var import_ramda4 = require("ramda");
190
+ var import_math18 = require("@fuel-ts/math");
191
+ var import_utils28 = require("@fuel-ts/utils");
194
192
 
195
193
  // src/providers/coin-quantity.ts
196
194
  var import_configs = require("@fuel-ts/address/configs");
@@ -216,7 +214,7 @@ var coinQuantityfy = (coinQuantityLike) => {
216
214
  max: max2 ? (0, import_math.bn)(max2) : void 0
217
215
  };
218
216
  };
219
- var addAmountToCoinQuantities = (params) => {
217
+ var addAmountToAsset = (params) => {
220
218
  const { amount, assetId } = params;
221
219
  const coinQuantities = [...params.coinQuantities];
222
220
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -231,11 +229,11 @@ var addAmountToCoinQuantities = (params) => {
231
229
  // src/providers/provider.ts
232
230
  var import_address3 = require("@fuel-ts/address");
233
231
  var import_errors14 = require("@fuel-ts/errors");
234
- var import_math16 = require("@fuel-ts/math");
235
- var import_transactions19 = require("@fuel-ts/transactions");
236
- var import_utils22 = require("@fuel-ts/utils");
232
+ var import_math15 = require("@fuel-ts/math");
233
+ var import_transactions18 = require("@fuel-ts/transactions");
234
+ var import_utils23 = require("@fuel-ts/utils");
237
235
  var import_versions = require("@fuel-ts/versions");
238
- var import_utils23 = require("@noble/curves/abstract/utils");
236
+ var import_utils24 = require("@noble/curves/abstract/utils");
239
237
  var import_ethers = require("ethers");
240
238
  var import_graphql_request = require("graphql-request");
241
239
  var import_ramda3 = require("ramda");
@@ -244,10 +242,14 @@ var import_ramda3 = require("ramda");
244
242
  var import_graphql_tag = __toESM(require("graphql-tag"));
245
243
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
246
244
  fragment receiptFragment on Receipt {
247
- id
245
+ contract {
246
+ id
247
+ }
248
248
  pc
249
249
  is
250
- to
250
+ to {
251
+ id
252
+ }
251
253
  toAddress
252
254
  amount
253
255
  assetId
@@ -285,16 +287,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
285
287
  id
286
288
  }
287
289
  time
288
- receipts {
289
- ...receiptFragment
290
- }
291
290
  programState {
292
291
  returnType
293
292
  data
294
293
  }
295
- receipts {
296
- ...receiptFragment
297
- }
298
294
  }
299
295
  ... on FailureStatus {
300
296
  block {
@@ -302,24 +298,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
302
298
  }
303
299
  time
304
300
  reason
305
- receipts {
306
- ...receiptFragment
307
- }
308
301
  }
309
302
  ... on SqueezedOutStatus {
310
303
  reason
311
304
  }
312
305
  }
313
- ${ReceiptFragmentFragmentDoc}`;
306
+ `;
314
307
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
315
308
  fragment transactionFragment on Transaction {
316
309
  id
317
310
  rawPayload
311
+ gasPrice
312
+ receipts {
313
+ ...receiptFragment
314
+ }
318
315
  status {
319
316
  ...transactionStatusFragment
320
317
  }
321
318
  }
322
- ${TransactionStatusFragmentFragmentDoc}`;
319
+ ${ReceiptFragmentFragmentDoc}
320
+ ${TransactionStatusFragmentFragmentDoc}`;
323
321
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
324
322
  fragment inputEstimatePredicatesFragment on Input {
325
323
  ... on InputCoin {
@@ -337,46 +335,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
337
335
  }
338
336
  }
339
337
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
340
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
341
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
342
- reason
343
- programState {
344
- returnType
345
- data
346
- }
347
- }
348
- `;
349
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
350
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
351
- programState {
352
- returnType
353
- data
354
- }
355
- }
356
- `;
357
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
358
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
359
- ... on DryRunFailureStatus {
360
- ...dryRunFailureStatusFragment
361
- }
362
- ... on DryRunSuccessStatus {
363
- ...dryRunSuccessStatusFragment
364
- }
365
- }
366
- ${DryRunFailureStatusFragmentFragmentDoc}
367
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
368
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
369
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
370
- id
371
- status {
372
- ...dryRunTransactionStatusFragment
373
- }
374
- receipts {
375
- ...receiptFragment
376
- }
377
- }
378
- ${DryRunTransactionStatusFragmentFragmentDoc}
379
- ${ReceiptFragmentFragmentDoc}`;
380
338
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
381
339
  fragment coinFragment on Coin {
382
340
  __typename
@@ -384,6 +342,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
384
342
  owner
385
343
  amount
386
344
  assetId
345
+ maturity
387
346
  blockCreated
388
347
  txCreatedIdx
389
348
  }
@@ -422,32 +381,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
422
381
  messageBlockHeader {
423
382
  id
424
383
  daHeight
425
- consensusParametersVersion
426
- stateTransitionBytecodeVersion
427
384
  transactionsCount
428
- messageReceiptCount
429
385
  transactionsRoot
430
- messageOutboxRoot
431
- eventInboxRoot
432
386
  height
433
387
  prevRoot
434
388
  time
435
389
  applicationHash
390
+ messageReceiptRoot
391
+ messageReceiptCount
436
392
  }
437
393
  commitBlockHeader {
438
394
  id
439
395
  daHeight
440
- consensusParametersVersion
441
- stateTransitionBytecodeVersion
442
396
  transactionsCount
443
- messageReceiptCount
444
397
  transactionsRoot
445
- messageOutboxRoot
446
- eventInboxRoot
447
398
  height
448
399
  prevRoot
449
400
  time
450
401
  applicationHash
402
+ messageReceiptRoot
403
+ messageReceiptCount
451
404
  }
452
405
  sender
453
406
  recipient
@@ -466,8 +419,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
466
419
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
467
420
  fragment blockFragment on Block {
468
421
  id
469
- height
470
422
  header {
423
+ height
471
424
  time
472
425
  }
473
426
  transactions {
@@ -525,11 +478,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
525
478
  `;
526
479
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
527
480
  fragment GasCostsFragment on GasCosts {
528
- version {
529
- ... on Version {
530
- value
531
- }
532
- }
533
481
  add
534
482
  addi
535
483
  aloc
@@ -542,6 +490,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
542
490
  cb
543
491
  cfei
544
492
  cfsi
493
+ croo
545
494
  div
546
495
  divi
547
496
  ecr1
@@ -624,9 +573,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
624
573
  ccp {
625
574
  ...DependentCostFragment
626
575
  }
627
- croo {
628
- ...DependentCostFragment
629
- }
630
576
  csiz {
631
577
  ...DependentCostFragment
632
578
  }
@@ -686,11 +632,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
686
632
  ${DependentCostFragmentFragmentDoc}`;
687
633
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
688
634
  fragment consensusParametersFragment on ConsensusParameters {
689
- version {
690
- ... on Version {
691
- value
692
- }
693
- }
694
635
  txParams {
695
636
  ...TxParametersFragment
696
637
  }
@@ -750,9 +691,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
750
691
  fragment nodeInfoFragment on NodeInfo {
751
692
  utxoValidation
752
693
  vmBacktrace
694
+ minGasPrice
753
695
  maxTx
754
696
  maxDepth
755
697
  nodeVersion
698
+ peers {
699
+ id
700
+ addresses
701
+ clientVersion
702
+ blockHeight
703
+ lastHeartbeatMs
704
+ appScore
705
+ }
756
706
  }
757
707
  `;
758
708
  var GetVersionDocument = import_graphql_tag.default`
@@ -787,9 +737,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
787
737
  query getTransactionWithReceipts($transactionId: TransactionId!) {
788
738
  transaction(id: $transactionId) {
789
739
  ...transactionFragment
740
+ receipts {
741
+ ...receiptFragment
742
+ }
790
743
  }
791
744
  }
792
- ${TransactionFragmentFragmentDoc}`;
745
+ ${TransactionFragmentFragmentDoc}
746
+ ${ReceiptFragmentFragmentDoc}`;
793
747
  var GetTransactionsDocument = import_graphql_tag.default`
794
748
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
795
749
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -917,20 +871,6 @@ var GetBalanceDocument = import_graphql_tag.default`
917
871
  }
918
872
  }
919
873
  ${BalanceFragmentFragmentDoc}`;
920
- var GetLatestGasPriceDocument = import_graphql_tag.default`
921
- query getLatestGasPrice {
922
- latestGasPrice {
923
- gasPrice
924
- }
925
- }
926
- `;
927
- var EstimateGasPriceDocument = import_graphql_tag.default`
928
- query estimateGasPrice($blockHorizon: U32!) {
929
- estimateGasPrice(blockHorizon: $blockHorizon) {
930
- gasPrice
931
- }
932
- }
933
- `;
934
874
  var GetBalancesDocument = import_graphql_tag.default`
935
875
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
936
876
  balances(
@@ -985,12 +925,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
985
925
  }
986
926
  `;
987
927
  var DryRunDocument = import_graphql_tag.default`
988
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
989
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
990
- ...dryRunTransactionExecutionStatusFragment
928
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
+ ...receiptFragment
991
931
  }
992
932
  }
993
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
933
+ ${ReceiptFragmentFragmentDoc}`;
994
934
  var SubmitDocument = import_graphql_tag.default`
995
935
  mutation submit($encodedTransaction: HexString!) {
996
936
  submit(tx: $encodedTransaction) {
@@ -1073,12 +1013,6 @@ function getSdk(requester) {
1073
1013
  getBalance(variables, options) {
1074
1014
  return requester(GetBalanceDocument, variables, options);
1075
1015
  },
1076
- getLatestGasPrice(variables, options) {
1077
- return requester(GetLatestGasPriceDocument, variables, options);
1078
- },
1079
- estimateGasPrice(variables, options) {
1080
- return requester(EstimateGasPriceDocument, variables, options);
1081
- },
1082
1016
  getBalances(variables, options) {
1083
1017
  return requester(GetBalancesDocument, variables, options);
1084
1018
  },
@@ -1148,14 +1082,11 @@ var _FuelGraphqlSubscriber = class {
1148
1082
  let data;
1149
1083
  let errors;
1150
1084
  try {
1151
- const sanitizedText = text.replace(/\s/g, "");
1152
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1085
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1153
1086
  } catch (e) {
1154
1087
  throw new import_errors.FuelError(
1155
1088
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1156
- `Error while parsing stream data response: ${text}
1157
-
1158
- Thrown error: ${e}`
1089
+ `Error while parsing stream data response: ${text}`
1159
1090
  );
1160
1091
  }
1161
1092
  if (Array.isArray(errors)) {
@@ -1266,9 +1197,10 @@ var inputify = (value) => {
1266
1197
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1267
1198
  },
1268
1199
  witnessIndex: value.witnessIndex,
1200
+ maturity: value.maturity ?? 0,
1269
1201
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1270
- predicateLength: (0, import_math2.bn)(predicate.length),
1271
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1202
+ predicateLength: predicate.length,
1203
+ predicateDataLength: predicateData.length,
1272
1204
  predicate: (0, import_utils3.hexlify)(predicate),
1273
1205
  predicateData: (0, import_utils3.hexlify)(predicateData)
1274
1206
  };
@@ -1299,8 +1231,8 @@ var inputify = (value) => {
1299
1231
  nonce: (0, import_utils3.hexlify)(value.nonce),
1300
1232
  witnessIndex: value.witnessIndex,
1301
1233
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1302
- predicateLength: (0, import_math2.bn)(predicate.length),
1303
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1234
+ predicateLength: predicate.length,
1235
+ predicateDataLength: predicateData.length,
1304
1236
  predicate: (0, import_utils3.hexlify)(predicate),
1305
1237
  predicateData: (0, import_utils3.hexlify)(predicateData),
1306
1238
  data: (0, import_utils3.hexlify)(data),
@@ -1419,8 +1351,8 @@ function assembleReceiptByType(receipt) {
1419
1351
  case "CALL" /* Call */: {
1420
1352
  const callReceipt = {
1421
1353
  type: import_transactions3.ReceiptType.Call,
1422
- from: hexOrZero(receipt.id || receipt.contractId),
1423
- to: hexOrZero(receipt?.to),
1354
+ from: hexOrZero(receipt.contract?.id),
1355
+ to: hexOrZero(receipt?.to?.id),
1424
1356
  amount: (0, import_math4.bn)(receipt.amount),
1425
1357
  assetId: hexOrZero(receipt.assetId),
1426
1358
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1434,7 +1366,7 @@ function assembleReceiptByType(receipt) {
1434
1366
  case "RETURN" /* Return */: {
1435
1367
  const returnReceipt = {
1436
1368
  type: import_transactions3.ReceiptType.Return,
1437
- id: hexOrZero(receipt.id || receipt.contractId),
1369
+ id: hexOrZero(receipt.contract?.id),
1438
1370
  val: (0, import_math4.bn)(receipt.val),
1439
1371
  pc: (0, import_math4.bn)(receipt.pc),
1440
1372
  is: (0, import_math4.bn)(receipt.is)
@@ -1444,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1444
1376
  case "RETURN_DATA" /* ReturnData */: {
1445
1377
  const returnDataReceipt = {
1446
1378
  type: import_transactions3.ReceiptType.ReturnData,
1447
- id: hexOrZero(receipt.id || receipt.contractId),
1379
+ id: hexOrZero(receipt.contract?.id),
1448
1380
  ptr: (0, import_math4.bn)(receipt.ptr),
1449
1381
  len: (0, import_math4.bn)(receipt.len),
1450
1382
  digest: hexOrZero(receipt.digest),
@@ -1456,7 +1388,7 @@ function assembleReceiptByType(receipt) {
1456
1388
  case "PANIC" /* Panic */: {
1457
1389
  const panicReceipt = {
1458
1390
  type: import_transactions3.ReceiptType.Panic,
1459
- id: hexOrZero(receipt.id),
1391
+ id: hexOrZero(receipt.contract?.id),
1460
1392
  reason: (0, import_math4.bn)(receipt.reason),
1461
1393
  pc: (0, import_math4.bn)(receipt.pc),
1462
1394
  is: (0, import_math4.bn)(receipt.is),
@@ -1467,7 +1399,7 @@ function assembleReceiptByType(receipt) {
1467
1399
  case "REVERT" /* Revert */: {
1468
1400
  const revertReceipt = {
1469
1401
  type: import_transactions3.ReceiptType.Revert,
1470
- id: hexOrZero(receipt.id || receipt.contractId),
1402
+ id: hexOrZero(receipt.contract?.id),
1471
1403
  val: (0, import_math4.bn)(receipt.ra),
1472
1404
  pc: (0, import_math4.bn)(receipt.pc),
1473
1405
  is: (0, import_math4.bn)(receipt.is)
@@ -1477,7 +1409,7 @@ function assembleReceiptByType(receipt) {
1477
1409
  case "LOG" /* Log */: {
1478
1410
  const logReceipt = {
1479
1411
  type: import_transactions3.ReceiptType.Log,
1480
- id: hexOrZero(receipt.id || receipt.contractId),
1412
+ id: hexOrZero(receipt.contract?.id),
1481
1413
  val0: (0, import_math4.bn)(receipt.ra),
1482
1414
  val1: (0, import_math4.bn)(receipt.rb),
1483
1415
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1490,7 +1422,7 @@ function assembleReceiptByType(receipt) {
1490
1422
  case "LOG_DATA" /* LogData */: {
1491
1423
  const logDataReceipt = {
1492
1424
  type: import_transactions3.ReceiptType.LogData,
1493
- id: hexOrZero(receipt.id || receipt.contractId),
1425
+ id: hexOrZero(receipt.contract?.id),
1494
1426
  val0: (0, import_math4.bn)(receipt.ra),
1495
1427
  val1: (0, import_math4.bn)(receipt.rb),
1496
1428
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1504,8 +1436,8 @@ function assembleReceiptByType(receipt) {
1504
1436
  case "TRANSFER" /* Transfer */: {
1505
1437
  const transferReceipt = {
1506
1438
  type: import_transactions3.ReceiptType.Transfer,
1507
- from: hexOrZero(receipt.id || receipt.contractId),
1508
- to: hexOrZero(receipt.toAddress || receipt?.to),
1439
+ from: hexOrZero(receipt.contract?.id),
1440
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1509
1441
  amount: (0, import_math4.bn)(receipt.amount),
1510
1442
  assetId: hexOrZero(receipt.assetId),
1511
1443
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1516,8 +1448,8 @@ function assembleReceiptByType(receipt) {
1516
1448
  case "TRANSFER_OUT" /* TransferOut */: {
1517
1449
  const transferOutReceipt = {
1518
1450
  type: import_transactions3.ReceiptType.TransferOut,
1519
- from: hexOrZero(receipt.id || receipt.contractId),
1520
- to: hexOrZero(receipt.toAddress || receipt.to),
1451
+ from: hexOrZero(receipt.contract?.id),
1452
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1521
1453
  amount: (0, import_math4.bn)(receipt.amount),
1522
1454
  assetId: hexOrZero(receipt.assetId),
1523
1455
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1560,7 +1492,7 @@ function assembleReceiptByType(receipt) {
1560
1492
  return receiptMessageOut;
1561
1493
  }
1562
1494
  case "MINT" /* Mint */: {
1563
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1495
+ const contractId = hexOrZero(receipt.contract?.id);
1564
1496
  const subId = hexOrZero(receipt.subId);
1565
1497
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1566
1498
  const mintReceipt = {
@@ -1575,7 +1507,7 @@ function assembleReceiptByType(receipt) {
1575
1507
  return mintReceipt;
1576
1508
  }
1577
1509
  case "BURN" /* Burn */: {
1578
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1510
+ const contractId = hexOrZero(receipt.contract?.id);
1579
1511
  const subId = hexOrZero(receipt.subId);
1580
1512
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1581
1513
  const burnReceipt = {
@@ -1660,6 +1592,7 @@ var buildBlockExplorerUrl = (options = {}) => {
1660
1592
  var import_math5 = require("@fuel-ts/math");
1661
1593
  var import_transactions4 = require("@fuel-ts/transactions");
1662
1594
  var import_utils6 = require("@fuel-ts/utils");
1595
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1663
1596
  var getGasUsedFromReceipts = (receipts) => {
1664
1597
  const scriptResult = receipts.filter(
1665
1598
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1680,28 +1613,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1680
1613
  }
1681
1614
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1682
1615
  const witnessCache = [];
1683
- const chargeableInputs = inputs.filter((input) => {
1684
- const isCoinOrMessage = "owner" in input || "sender" in input;
1685
- if (isCoinOrMessage) {
1686
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1687
- return true;
1688
- }
1689
- if (!witnessCache.includes(input.witnessIndex)) {
1690
- witnessCache.push(input.witnessIndex);
1691
- return true;
1692
- }
1693
- }
1694
- return false;
1695
- });
1696
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1697
- const totalGas = chargeableInputs.reduce((total, input) => {
1616
+ const totalGas = inputs.reduce((total, input) => {
1698
1617
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1699
1618
  return total.add(
1700
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1619
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1701
1620
  );
1702
1621
  }
1703
- return total.add(gasCosts.ecr1);
1704
- }, (0, import_math5.bn)(0));
1622
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1623
+ witnessCache.push(input.witnessIndex);
1624
+ return total.add(gasCosts.ecr1);
1625
+ }
1626
+ return total;
1627
+ }, (0, import_math5.bn)());
1705
1628
  return totalGas;
1706
1629
  }
1707
1630
  function getMinGas(params) {
@@ -1713,20 +1636,12 @@ function getMinGas(params) {
1713
1636
  return minGas;
1714
1637
  }
1715
1638
  function getMaxGas(params) {
1716
- const {
1717
- gasPerByte,
1718
- witnessesLength,
1719
- witnessLimit,
1720
- minGas,
1721
- gasLimit = (0, import_math5.bn)(0),
1722
- maxGasPerTx
1723
- } = params;
1639
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1724
1640
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1725
1641
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1726
1642
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1727
1643
  }
1728
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1729
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1644
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1730
1645
  }
1731
1646
  function calculateMetadataGasForTxCreate({
1732
1647
  gasCosts,
@@ -1748,10 +1663,6 @@ function calculateMetadataGasForTxScript({
1748
1663
  }) {
1749
1664
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1750
1665
  }
1751
- var calculateGasFee = (params) => {
1752
- const { gas, gasPrice, priceFactor, tip } = params;
1753
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1754
- };
1755
1666
 
1756
1667
  // src/providers/utils/json.ts
1757
1668
  var import_utils7 = require("@fuel-ts/utils");
@@ -1900,7 +1811,7 @@ var witnessify = (value) => {
1900
1811
  // src/providers/transaction-request/transaction-request.ts
1901
1812
  var BaseTransactionRequest = class {
1902
1813
  /** Gas price for transaction */
1903
- tip;
1814
+ gasPrice;
1904
1815
  /** Block until which tx cannot be included */
1905
1816
  maturity;
1906
1817
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1919,7 +1830,7 @@ var BaseTransactionRequest = class {
1919
1830
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1920
1831
  */
1921
1832
  constructor({
1922
- tip,
1833
+ gasPrice,
1923
1834
  maturity,
1924
1835
  maxFee,
1925
1836
  witnessLimit,
@@ -1927,7 +1838,7 @@ var BaseTransactionRequest = class {
1927
1838
  outputs,
1928
1839
  witnesses
1929
1840
  } = {}) {
1930
- this.tip = (0, import_math7.bn)(tip);
1841
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1931
1842
  this.maturity = maturity ?? 0;
1932
1843
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1933
1844
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1938,9 +1849,9 @@ var BaseTransactionRequest = class {
1938
1849
  static getPolicyMeta(req) {
1939
1850
  let policyTypes = 0;
1940
1851
  const policies = [];
1941
- if (req.tip) {
1942
- policyTypes += import_transactions6.PolicyType.Tip;
1943
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1852
+ if (req.gasPrice) {
1853
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1854
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1944
1855
  }
1945
1856
  if (req.witnessLimit) {
1946
1857
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2127,10 +2038,10 @@ var BaseTransactionRequest = class {
2127
2038
  * @param predicate - Predicate bytes.
2128
2039
  * @param predicateData - Predicate data bytes.
2129
2040
  */
2130
- addCoinInput(coin) {
2041
+ addCoinInput(coin, predicate) {
2131
2042
  const { assetId, owner, amount } = coin;
2132
2043
  let witnessIndex;
2133
- if (coin.predicate) {
2044
+ if (predicate) {
2134
2045
  witnessIndex = 0;
2135
2046
  } else {
2136
2047
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2145,7 +2056,8 @@ var BaseTransactionRequest = class {
2145
2056
  amount,
2146
2057
  assetId,
2147
2058
  txPointer: "0x00000000000000000000000000000000",
2148
- witnessIndex
2059
+ witnessIndex,
2060
+ predicate: predicate?.bytes
2149
2061
  };
2150
2062
  this.pushInput(input);
2151
2063
  this.addChangeOutput(owner, assetId);
@@ -2158,11 +2070,11 @@ var BaseTransactionRequest = class {
2158
2070
  * @param predicate - Predicate bytes.
2159
2071
  * @param predicateData - Predicate data bytes.
2160
2072
  */
2161
- addMessageInput(message) {
2073
+ addMessageInput(message, predicate) {
2162
2074
  const { recipient, sender, amount } = message;
2163
2075
  const assetId = import_configs7.BaseAssetId;
2164
2076
  let witnessIndex;
2165
- if (message.predicate) {
2077
+ if (predicate) {
2166
2078
  witnessIndex = 0;
2167
2079
  } else {
2168
2080
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2176,7 +2088,8 @@ var BaseTransactionRequest = class {
2176
2088
  sender: sender.toB256(),
2177
2089
  recipient: recipient.toB256(),
2178
2090
  amount,
2179
- witnessIndex
2091
+ witnessIndex,
2092
+ predicate: predicate?.bytes
2180
2093
  };
2181
2094
  this.pushInput(input);
2182
2095
  this.addChangeOutput(recipient, assetId);
@@ -2207,6 +2120,32 @@ var BaseTransactionRequest = class {
2207
2120
  resources.forEach((resource) => this.addResource(resource));
2208
2121
  return this;
2209
2122
  }
2123
+ /**
2124
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2125
+ * outputs from the related assetIds.
2126
+ *
2127
+ * @param resources - The resources to add.
2128
+ * @returns This transaction.
2129
+ */
2130
+ addPredicateResource(resource, predicate) {
2131
+ if (isCoin(resource)) {
2132
+ this.addCoinInput(resource, predicate);
2133
+ } else {
2134
+ this.addMessageInput(resource, predicate);
2135
+ }
2136
+ return this;
2137
+ }
2138
+ /**
2139
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2140
+ * from the related assetIds.
2141
+ *
2142
+ * @param resources - The resources to add.
2143
+ * @returns This transaction.
2144
+ */
2145
+ addPredicateResources(resources, predicate) {
2146
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2147
+ return this;
2148
+ }
2210
2149
  /**
2211
2150
  * Adds a coin output to the transaction.
2212
2151
  *
@@ -2286,7 +2225,7 @@ var BaseTransactionRequest = class {
2286
2225
  }
2287
2226
  calculateMaxGas(chainInfo, minGas) {
2288
2227
  const { consensusParameters } = chainInfo;
2289
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2228
+ const { gasPerByte } = consensusParameters;
2290
2229
  const witnessesLength = this.toTransaction().witnesses.reduce(
2291
2230
  (acc, wit) => acc + wit.dataLength,
2292
2231
  0
@@ -2295,8 +2234,7 @@ var BaseTransactionRequest = class {
2295
2234
  gasPerByte,
2296
2235
  minGas,
2297
2236
  witnessesLength,
2298
- witnessLimit: this.witnessLimit,
2299
- maxGasPerTx
2237
+ witnessLimit: this.witnessLimit
2300
2238
  });
2301
2239
  }
2302
2240
  /**
@@ -2314,20 +2252,17 @@ var BaseTransactionRequest = class {
2314
2252
  });
2315
2253
  const updateAssetInput = (assetId, quantity) => {
2316
2254
  const assetInput = findAssetInput(assetId);
2317
- let usedQuantity = quantity;
2318
- if (assetId === import_configs7.BaseAssetId) {
2319
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2320
- }
2321
2255
  if (assetInput && "assetId" in assetInput) {
2322
2256
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2323
- assetInput.amount = usedQuantity;
2257
+ assetInput.amount = quantity;
2324
2258
  } else {
2325
2259
  this.addResources([
2326
2260
  {
2327
2261
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2328
- amount: usedQuantity,
2262
+ amount: quantity,
2329
2263
  assetId,
2330
2264
  owner: resourcesOwner || import_address.Address.fromRandom(),
2265
+ maturity: 0,
2331
2266
  blockCreated: (0, import_math7.bn)(1),
2332
2267
  txCreatedIdx: (0, import_math7.bn)(1)
2333
2268
  }
@@ -2359,7 +2294,7 @@ var BaseTransactionRequest = class {
2359
2294
  toJSON() {
2360
2295
  return normalizeJSON(this);
2361
2296
  }
2362
- updatePredicateGasUsed(inputs) {
2297
+ updatePredicateInputs(inputs) {
2363
2298
  this.inputs.forEach((i) => {
2364
2299
  let correspondingInput;
2365
2300
  switch (i.type) {
@@ -2381,15 +2316,6 @@ var BaseTransactionRequest = class {
2381
2316
  }
2382
2317
  });
2383
2318
  }
2384
- shiftPredicateData() {
2385
- this.inputs.forEach((input) => {
2386
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2387
- input.predicateData = input.paddPredicateData(
2388
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2389
- );
2390
- }
2391
- });
2392
- }
2393
2319
  };
2394
2320
 
2395
2321
  // 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_configs9.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_configs10.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
  }
@@ -3836,29 +3726,29 @@ var processGqlChain = (chain) => {
3836
3726
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3837
3727
  return {
3838
3728
  name,
3839
- baseChainHeight: (0, import_math16.bn)(daHeight),
3729
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3840
3730
  consensusParameters: {
3841
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3842
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3843
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3844
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3845
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3846
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3847
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3848
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3849
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3850
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3851
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3852
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3853
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3854
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3855
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3731
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3732
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3733
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3734
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3735
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3736
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3737
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3738
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3739
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3740
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3741
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3742
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3743
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3744
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3745
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
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,
@@ -4051,7 +3943,7 @@ var _Provider = class {
4051
3943
  */
4052
3944
  async getBlockNumber() {
4053
3945
  const { chain } = await this.operations.getChain();
4054
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3946
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4055
3947
  }
4056
3948
  /**
4057
3949
  * Returns the chain information.
@@ -4061,11 +3953,13 @@ var _Provider = class {
4061
3953
  async fetchNode() {
4062
3954
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
3955
  const processedNodeInfo = {
4064
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4065
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3956
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3957
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3958
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4066
3959
  nodeVersion: nodeInfo.nodeVersion,
4067
3960
  utxoValidation: nodeInfo.utxoValidation,
4068
- vmBacktrace: nodeInfo.vmBacktrace
3961
+ vmBacktrace: nodeInfo.vmBacktrace,
3962
+ peers: nodeInfo.peers
4069
3963
  };
4070
3964
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
4071
3965
  return processedNodeInfo;
@@ -4107,9 +4001,9 @@ var _Provider = class {
4107
4001
  if (estimateTxDependencies) {
4108
4002
  await this.estimateTxDependencies(transactionRequest);
4109
4003
  }
4110
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4004
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4111
4005
  let abis;
4112
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4006
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4113
4007
  abis = transactionRequest.abis;
4114
4008
  }
4115
4009
  if (awaitExecution) {
@@ -4150,14 +4044,15 @@ var _Provider = class {
4150
4044
  if (estimateTxDependencies) {
4151
4045
  return this.estimateTxDependencies(transactionRequest);
4152
4046
  }
4153
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4154
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4155
- encodedTransactions: encodedTransaction,
4047
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4048
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4049
+ encodedTransaction,
4156
4050
  utxoValidation: utxoValidation || false
4157
4051
  });
4158
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4159
- const receipts = rawReceipts.map(processGqlReceipt);
4160
- return { receipts, dryrunStatus: status };
4052
+ const receipts = gqlReceipts.map(processGqlReceipt);
4053
+ return {
4054
+ receipts
4055
+ };
4161
4056
  }
4162
4057
  /**
4163
4058
  * Verifies whether enough gas is available to complete transaction.
@@ -4168,13 +4063,13 @@ var _Provider = class {
4168
4063
  async estimatePredicates(transactionRequest) {
4169
4064
  const shouldEstimatePredicates = Boolean(
4170
4065
  transactionRequest.inputs.find(
4171
- (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()
4066
+ (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()
4172
4067
  )
4173
4068
  );
4174
4069
  if (!shouldEstimatePredicates) {
4175
4070
  return transactionRequest;
4176
4071
  }
4177
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4072
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4178
4073
  const response = await this.operations.estimatePredicates({
4179
4074
  encodedTransaction
4180
4075
  });
@@ -4183,7 +4078,7 @@ var _Provider = class {
4183
4078
  } = response;
4184
4079
  if (inputs) {
4185
4080
  inputs.forEach((input, index) => {
4186
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4081
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4187
4082
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4188
4083
  }
4189
4084
  });
@@ -4196,31 +4091,31 @@ var _Provider = class {
4196
4091
  * If there are missing variable outputs,
4197
4092
  * `addVariableOutputs` is called on the transaction.
4198
4093
  *
4094
+ * @privateRemarks
4095
+ * TODO: Investigate support for missing contract IDs
4096
+ * TODO: Add support for missing output messages
4199
4097
  *
4200
4098
  * @param transactionRequest - The transaction request object.
4201
4099
  * @returns A promise.
4202
4100
  */
4203
4101
  async estimateTxDependencies(transactionRequest) {
4204
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4102
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4205
4103
  return {
4206
4104
  receipts: [],
4207
4105
  outputVariables: 0,
4208
4106
  missingContractIds: []
4209
4107
  };
4210
4108
  }
4109
+ await this.estimatePredicates(transactionRequest);
4211
4110
  let receipts = [];
4212
4111
  const missingContractIds = [];
4213
4112
  let outputVariables = 0;
4214
- let dryrunStatus;
4215
4113
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4216
- const {
4217
- dryRun: [{ receipts: rawReceipts, status }]
4218
- } = await this.operations.dryRun({
4219
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4114
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4115
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4220
4116
  utxoValidation: false
4221
4117
  });
4222
- receipts = rawReceipts.map(processGqlReceipt);
4223
- dryrunStatus = status;
4118
+ receipts = gqlReceipts.map(processGqlReceipt);
4224
4119
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4225
4120
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4226
4121
  if (hasMissingOutputs) {
@@ -4230,10 +4125,6 @@ var _Provider = class {
4230
4125
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4231
4126
  missingContractIds.push(contractId);
4232
4127
  });
4233
- const { maxFee } = await this.estimateTxGasAndFee({
4234
- transactionRequest
4235
- });
4236
- transactionRequest.maxFee = maxFee;
4237
4128
  } else {
4238
4129
  break;
4239
4130
  }
@@ -4241,139 +4132,37 @@ var _Provider = class {
4241
4132
  return {
4242
4133
  receipts,
4243
4134
  outputVariables,
4244
- missingContractIds,
4245
- dryrunStatus
4135
+ missingContractIds
4246
4136
  };
4247
4137
  }
4248
- /**
4249
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4250
- *
4251
- * Transactions are dry run in batches. After each dry run, transactions requiring
4252
- * further modifications are identified. The method iteratively updates these transactions
4253
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4254
- *
4255
- * @param transactionRequests - Array of transaction request objects.
4256
- * @returns A promise that resolves to an array of results for each transaction.
4257
- */
4258
- async estimateMultipleTxDependencies(transactionRequests) {
4259
- const results = transactionRequests.map(() => ({
4260
- receipts: [],
4261
- outputVariables: 0,
4262
- missingContractIds: [],
4263
- dryrunStatus: void 0
4264
- }));
4265
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4266
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4267
- allRequests.forEach((req, index) => {
4268
- if (req.type === import_transactions19.TransactionType.Script) {
4269
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4270
- }
4271
- });
4272
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4273
- let attempt = 0;
4274
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4275
- const encodedTransactions = transactionsToProcess.map(
4276
- (index) => serializedTransactionsMap.get(index)
4277
- );
4278
- const dryRunResults = await this.operations.dryRun({
4279
- encodedTransactions,
4280
- utxoValidation: false
4281
- });
4282
- const nextRoundTransactions = [];
4283
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4284
- const currentResultIndex = transactionsToProcess[i];
4285
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4286
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4287
- results[currentResultIndex].dryrunStatus = status;
4288
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4289
- results[currentResultIndex].receipts
4290
- );
4291
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4292
- const requestToProcess = allRequests[currentResultIndex];
4293
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4294
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4295
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4296
- missingOutputContractIds.forEach(({ contractId }) => {
4297
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4298
- results[currentResultIndex].missingContractIds.push(contractId);
4299
- });
4300
- const { maxFee } = await this.estimateTxGasAndFee({
4301
- transactionRequest: requestToProcess
4302
- });
4303
- requestToProcess.maxFee = maxFee;
4304
- serializedTransactionsMap.set(
4305
- currentResultIndex,
4306
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4307
- );
4308
- nextRoundTransactions.push(currentResultIndex);
4309
- allRequests[currentResultIndex] = requestToProcess;
4310
- }
4311
- }
4312
- transactionsToProcess = nextRoundTransactions;
4313
- attempt += 1;
4314
- }
4315
- return results;
4316
- }
4317
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4318
- if (estimateTxDependencies) {
4319
- return this.estimateMultipleTxDependencies(transactionRequests);
4320
- }
4321
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4322
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4323
- encodedTransactions,
4324
- utxoValidation: utxoValidation || false
4325
- });
4326
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4327
- const receipts = rawReceipts.map(processGqlReceipt);
4328
- return { receipts, dryrunStatus: status };
4329
- });
4330
- return results;
4331
- }
4332
4138
  /**
4333
4139
  * Estimates the transaction gas and fee based on the provided transaction request.
4334
4140
  * @param transactionRequest - The transaction request object.
4335
4141
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4336
4142
  */
4337
- async estimateTxGasAndFee(params) {
4143
+ estimateTxGasAndFee(params) {
4338
4144
  const { transactionRequest } = params;
4339
- let { gasPrice } = params;
4145
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4340
4146
  const chainInfo = this.getChain();
4341
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
4147
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4148
+ transactionRequest.gasPrice = gasPrice;
4342
4149
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4343
- if (!gasPrice) {
4344
- gasPrice = await this.estimateGasPrice(10);
4345
- }
4346
- const minFee = calculateGasFee({
4347
- gasPrice: (0, import_math16.bn)(gasPrice),
4348
- gas: minGas,
4349
- priceFactor: gasPriceFactor,
4350
- tip: transactionRequest.tip
4351
- }).add(1);
4352
- let gasLimit = (0, import_math16.bn)(0);
4353
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4354
- gasLimit = transactionRequest.gasLimit;
4150
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4151
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4355
4152
  if (transactionRequest.gasLimit.eq(0)) {
4356
4153
  transactionRequest.gasLimit = minGas;
4357
4154
  transactionRequest.gasLimit = maxGasPerTx.sub(
4358
4155
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4359
4156
  );
4360
- gasLimit = transactionRequest.gasLimit;
4361
4157
  }
4362
4158
  }
4363
4159
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4364
- const maxFee = calculateGasFee({
4365
- gasPrice: (0, import_math16.bn)(gasPrice),
4366
- gas: maxGas,
4367
- priceFactor: gasPriceFactor,
4368
- tip: transactionRequest.tip
4369
- }).add(1);
4160
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4370
4161
  return {
4371
4162
  minGas,
4372
4163
  minFee,
4373
4164
  maxGas,
4374
- maxFee,
4375
- gasPrice,
4376
- gasLimit
4165
+ maxFee
4377
4166
  };
4378
4167
  }
4379
4168
  /**
@@ -4391,17 +4180,15 @@ var _Provider = class {
4391
4180
  if (estimateTxDependencies) {
4392
4181
  return this.estimateTxDependencies(transactionRequest);
4393
4182
  }
4394
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4395
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4396
- encodedTransactions,
4183
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4184
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
4185
+ encodedTransaction,
4397
4186
  utxoValidation: true
4398
4187
  });
4399
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4400
- const { id, receipts, status } = dryRunStatus;
4401
- const processedReceipts = receipts.map(processGqlReceipt);
4402
- return { id, receipts: processedReceipts, status };
4403
- });
4404
- return { receipts: callResult[0].receipts };
4188
+ const receipts = gqlReceipts.map(processGqlReceipt);
4189
+ return {
4190
+ receipts
4191
+ };
4405
4192
  }
4406
4193
  /**
4407
4194
  * Returns a transaction cost to enable user
@@ -4418,79 +4205,77 @@ var _Provider = class {
4418
4205
  * @param tolerance - The tolerance to add on top of the gasUsed.
4419
4206
  * @returns A promise that resolves to the transaction cost object.
4420
4207
  */
4421
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4208
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4209
+ estimateTxDependencies = true,
4210
+ estimatePredicates = true,
4211
+ resourcesOwner,
4212
+ signatureCallback
4213
+ } = {}) {
4422
4214
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4423
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4215
+ const { minGasPrice } = this.getGasConfig();
4216
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4217
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4424
4218
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4425
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4219
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4426
4220
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4427
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4428
4221
  if (isScriptTransaction) {
4429
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4222
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4430
4223
  }
4431
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4432
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4224
+ if (estimatePredicates) {
4225
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4226
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4227
+ }
4228
+ await this.estimatePredicates(txRequestClone);
4433
4229
  }
4434
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4435
- let addedSignatures = 0;
4436
4230
  if (signatureCallback && isScriptTransaction) {
4437
- const lengthBefore = signedRequest.witnesses.length;
4438
- await signatureCallback(signedRequest);
4439
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
4231
+ await signatureCallback(txRequestClone);
4440
4232
  }
4441
- await this.estimatePredicates(signedRequest);
4442
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4443
- transactionRequest: signedRequest
4233
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4234
+ transactionRequest: txRequestClone
4444
4235
  });
4445
4236
  let receipts = [];
4446
4237
  let missingContractIds = [];
4447
4238
  let outputVariables = 0;
4448
- let gasUsed = (0, import_math16.bn)(0);
4449
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4450
- txRequestClone.maxFee = maxFee;
4451
- if (isScriptTransaction) {
4452
- txRequestClone.gasLimit = gasLimit;
4453
- if (signatureCallback) {
4454
- await signatureCallback(txRequestClone);
4455
- }
4239
+ let gasUsed = (0, import_math15.bn)(0);
4240
+ if (isScriptTransaction && estimateTxDependencies) {
4241
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4456
4242
  const result = await this.estimateTxDependencies(txRequestClone);
4457
4243
  receipts = result.receipts;
4458
4244
  outputVariables = result.outputVariables;
4459
4245
  missingContractIds = result.missingContractIds;
4460
4246
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4461
4247
  txRequestClone.gasLimit = gasUsed;
4462
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4463
- transactionRequest: txRequestClone,
4464
- gasPrice
4248
+ txRequestClone.gasPrice = setGasPrice;
4249
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4250
+ transactionRequest: txRequestClone
4465
4251
  }));
4466
4252
  }
4467
4253
  return {
4468
4254
  requiredQuantities: allQuantities,
4469
4255
  receipts,
4470
4256
  gasUsed,
4471
- gasPrice,
4257
+ minGasPrice,
4258
+ gasPrice: setGasPrice,
4472
4259
  minGas,
4473
4260
  maxGas,
4474
4261
  minFee,
4475
4262
  maxFee,
4263
+ estimatedInputs: txRequestClone.inputs,
4476
4264
  outputVariables,
4477
- missingContractIds,
4478
- addedSignatures,
4479
- estimatedPredicates: txRequestClone.inputs
4265
+ missingContractIds
4480
4266
  };
4481
4267
  }
4482
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4268
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4483
4269
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4484
4270
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4485
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4486
- quantitiesToContract
4487
- });
4271
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4488
4272
  transactionRequest.addResources(
4489
4273
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4490
4274
  );
4491
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4492
- quantitiesToContract
4493
- });
4275
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4276
+ transactionRequest,
4277
+ forwardingQuantities
4278
+ );
4494
4279
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4495
4280
  return {
4496
4281
  resources,
@@ -4506,16 +4291,17 @@ var _Provider = class {
4506
4291
  const result = await this.operations.getCoins({
4507
4292
  first: 10,
4508
4293
  ...paginationArgs,
4509
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4294
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4510
4295
  });
4511
4296
  const coins = result.coins.edges.map((edge) => edge.node);
4512
4297
  return coins.map((coin) => ({
4513
4298
  id: coin.utxoId,
4514
4299
  assetId: coin.assetId,
4515
- amount: (0, import_math16.bn)(coin.amount),
4300
+ amount: (0, import_math15.bn)(coin.amount),
4516
4301
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4517
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4518
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4302
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4303
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4304
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4519
4305
  }));
4520
4306
  }
4521
4307
  /**
@@ -4529,19 +4315,19 @@ var _Provider = class {
4529
4315
  async getResourcesToSpend(owner, quantities, excludedIds) {
4530
4316
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4531
4317
  const excludeInput = {
4532
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4533
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4318
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4319
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4534
4320
  };
4535
4321
  if (this.cache) {
4536
4322
  const uniqueUtxos = new Set(
4537
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4323
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4538
4324
  );
4539
4325
  excludeInput.utxos = Array.from(uniqueUtxos);
4540
4326
  }
4541
4327
  const coinsQuery = {
4542
4328
  owner: ownerAddress.toB256(),
4543
4329
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4544
- assetId: (0, import_utils22.hexlify)(assetId),
4330
+ assetId: (0, import_utils23.hexlify)(assetId),
4545
4331
  amount: amount.toString(10),
4546
4332
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4547
4333
  })),
@@ -4552,9 +4338,9 @@ var _Provider = class {
4552
4338
  switch (coin.__typename) {
4553
4339
  case "MessageCoin":
4554
4340
  return {
4555
- amount: (0, import_math16.bn)(coin.amount),
4341
+ amount: (0, import_math15.bn)(coin.amount),
4556
4342
  assetId: coin.assetId,
4557
- daHeight: (0, import_math16.bn)(coin.daHeight),
4343
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4558
4344
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4559
4345
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4560
4346
  nonce: coin.nonce
@@ -4562,11 +4348,12 @@ var _Provider = class {
4562
4348
  case "Coin":
4563
4349
  return {
4564
4350
  id: coin.utxoId,
4565
- amount: (0, import_math16.bn)(coin.amount),
4351
+ amount: (0, import_math15.bn)(coin.amount),
4566
4352
  assetId: coin.assetId,
4567
4353
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4568
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4569
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4354
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4355
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4356
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4570
4357
  };
4571
4358
  default:
4572
4359
  return null;
@@ -4583,13 +4370,13 @@ var _Provider = class {
4583
4370
  async getBlock(idOrHeight) {
4584
4371
  let variables;
4585
4372
  if (typeof idOrHeight === "number") {
4586
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4373
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4587
4374
  } else if (idOrHeight === "latest") {
4588
4375
  variables = { height: (await this.getBlockNumber()).toString(10) };
4589
4376
  } else if (idOrHeight.length === 66) {
4590
4377
  variables = { blockId: idOrHeight };
4591
4378
  } else {
4592
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4379
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4593
4380
  }
4594
4381
  const { block } = await this.operations.getBlock(variables);
4595
4382
  if (!block) {
@@ -4597,7 +4384,7 @@ var _Provider = class {
4597
4384
  }
4598
4385
  return {
4599
4386
  id: block.id,
4600
- height: (0, import_math16.bn)(block.height),
4387
+ height: (0, import_math15.bn)(block.header.height),
4601
4388
  time: block.header.time,
4602
4389
  transactionIds: block.transactions.map((tx) => tx.id)
4603
4390
  };
@@ -4612,7 +4399,7 @@ var _Provider = class {
4612
4399
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4613
4400
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4614
4401
  id: block.id,
4615
- height: (0, import_math16.bn)(block.height),
4402
+ height: (0, import_math15.bn)(block.header.height),
4616
4403
  time: block.header.time,
4617
4404
  transactionIds: block.transactions.map((tx) => tx.id)
4618
4405
  }));
@@ -4627,7 +4414,7 @@ var _Provider = class {
4627
4414
  async getBlockWithTransactions(idOrHeight) {
4628
4415
  let variables;
4629
4416
  if (typeof idOrHeight === "number") {
4630
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4417
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4631
4418
  } else if (idOrHeight === "latest") {
4632
4419
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4633
4420
  } else {
@@ -4639,11 +4426,11 @@ var _Provider = class {
4639
4426
  }
4640
4427
  return {
4641
4428
  id: block.id,
4642
- height: (0, import_math16.bn)(block.height, 10),
4429
+ height: (0, import_math15.bn)(block.header.height, 10),
4643
4430
  time: block.header.time,
4644
4431
  transactionIds: block.transactions.map((tx) => tx.id),
4645
4432
  transactions: block.transactions.map(
4646
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4433
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4647
4434
  )
4648
4435
  };
4649
4436
  }
@@ -4658,8 +4445,8 @@ var _Provider = class {
4658
4445
  if (!transaction) {
4659
4446
  return null;
4660
4447
  }
4661
- return new import_transactions19.TransactionCoder().decode(
4662
- (0, import_utils22.arrayify)(transaction.rawPayload),
4448
+ return new import_transactions18.TransactionCoder().decode(
4449
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4663
4450
  0
4664
4451
  )?.[0];
4665
4452
  }
@@ -4686,9 +4473,9 @@ var _Provider = class {
4686
4473
  async getContractBalance(contractId, assetId) {
4687
4474
  const { contractBalance } = await this.operations.getContractBalance({
4688
4475
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4689
- asset: (0, import_utils22.hexlify)(assetId)
4476
+ asset: (0, import_utils23.hexlify)(assetId)
4690
4477
  });
4691
- return (0, import_math16.bn)(contractBalance.amount, 10);
4478
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4692
4479
  }
4693
4480
  /**
4694
4481
  * Returns the balance for the given owner for the given asset ID.
@@ -4700,9 +4487,9 @@ var _Provider = class {
4700
4487
  async getBalance(owner, assetId) {
4701
4488
  const { balance } = await this.operations.getBalance({
4702
4489
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4703
- assetId: (0, import_utils22.hexlify)(assetId)
4490
+ assetId: (0, import_utils23.hexlify)(assetId)
4704
4491
  });
4705
- return (0, import_math16.bn)(balance.amount, 10);
4492
+ return (0, import_math15.bn)(balance.amount, 10);
4706
4493
  }
4707
4494
  /**
4708
4495
  * Returns balances for the given owner.
@@ -4720,7 +4507,7 @@ var _Provider = class {
4720
4507
  const balances = result.balances.edges.map((edge) => edge.node);
4721
4508
  return balances.map((balance) => ({
4722
4509
  assetId: balance.assetId,
4723
- amount: (0, import_math16.bn)(balance.amount)
4510
+ amount: (0, import_math15.bn)(balance.amount)
4724
4511
  }));
4725
4512
  }
4726
4513
  /**
@@ -4738,19 +4525,19 @@ var _Provider = class {
4738
4525
  });
4739
4526
  const messages = result.messages.edges.map((edge) => edge.node);
4740
4527
  return messages.map((message) => ({
4741
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4528
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4742
4529
  sender: message.sender,
4743
4530
  recipient: message.recipient,
4744
4531
  nonce: message.nonce,
4745
- amount: (0, import_math16.bn)(message.amount),
4532
+ amount: (0, import_math15.bn)(message.amount),
4746
4533
  data: message.data
4747
4534
  }),
4748
4535
  sender: import_address3.Address.fromAddressOrString(message.sender),
4749
4536
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4750
4537
  nonce: message.nonce,
4751
- amount: (0, import_math16.bn)(message.amount),
4752
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4753
- daHeight: (0, import_math16.bn)(message.daHeight)
4538
+ amount: (0, import_math15.bn)(message.amount),
4539
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4540
+ daHeight: (0, import_math15.bn)(message.daHeight)
4754
4541
  }));
4755
4542
  }
4756
4543
  /**
@@ -4803,60 +4590,44 @@ var _Provider = class {
4803
4590
  } = result.messageProof;
4804
4591
  return {
4805
4592
  messageProof: {
4806
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4593
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4807
4594
  proofSet: messageProof.proofSet
4808
4595
  },
4809
4596
  blockProof: {
4810
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4597
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4811
4598
  proofSet: blockProof.proofSet
4812
4599
  },
4813
4600
  messageBlockHeader: {
4814
4601
  id: messageBlockHeader.id,
4815
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4816
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4602
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4603
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4817
4604
  transactionsRoot: messageBlockHeader.transactionsRoot,
4818
- height: (0, import_math16.bn)(messageBlockHeader.height),
4605
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4819
4606
  prevRoot: messageBlockHeader.prevRoot,
4820
4607
  time: messageBlockHeader.time,
4821
4608
  applicationHash: messageBlockHeader.applicationHash,
4822
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4823
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4824
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4825
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4826
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4609
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4610
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4827
4611
  },
4828
4612
  commitBlockHeader: {
4829
4613
  id: commitBlockHeader.id,
4830
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4831
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4614
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4615
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4832
4616
  transactionsRoot: commitBlockHeader.transactionsRoot,
4833
- height: (0, import_math16.bn)(commitBlockHeader.height),
4617
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4834
4618
  prevRoot: commitBlockHeader.prevRoot,
4835
4619
  time: commitBlockHeader.time,
4836
4620
  applicationHash: commitBlockHeader.applicationHash,
4837
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4838
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4839
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4840
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4841
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4621
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4622
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4842
4623
  },
4843
4624
  sender: import_address3.Address.fromAddressOrString(sender),
4844
4625
  recipient: import_address3.Address.fromAddressOrString(recipient),
4845
4626
  nonce,
4846
- amount: (0, import_math16.bn)(amount),
4627
+ amount: (0, import_math15.bn)(amount),
4847
4628
  data
4848
4629
  };
4849
4630
  }
4850
- async getLatestGasPrice() {
4851
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4852
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4853
- }
4854
- async estimateGasPrice(blockHorizon) {
4855
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4856
- blockHorizon: String(blockHorizon)
4857
- });
4858
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4859
- }
4860
4631
  /**
4861
4632
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4862
4633
  *
@@ -4876,10 +4647,10 @@ var _Provider = class {
4876
4647
  */
4877
4648
  async produceBlocks(amount, startTime) {
4878
4649
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4879
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4880
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4650
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4651
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4881
4652
  });
4882
- return (0, import_math16.bn)(latestBlockHeight);
4653
+ return (0, import_math15.bn)(latestBlockHeight);
4883
4654
  }
4884
4655
  // eslint-disable-next-line @typescript-eslint/require-await
4885
4656
  async getTransactionResponse(transactionId) {
@@ -4893,7 +4664,7 @@ cacheInputs_fn = function(inputs) {
4893
4664
  return;
4894
4665
  }
4895
4666
  inputs.forEach((input) => {
4896
- if (input.type === import_transactions19.InputType.Coin) {
4667
+ if (input.type === import_transactions18.InputType.Coin) {
4897
4668
  this.cache?.set(input.id);
4898
4669
  }
4899
4670
  });
@@ -4903,9 +4674,9 @@ __publicField(Provider, "nodeInfoCache", {});
4903
4674
 
4904
4675
  // src/providers/transaction-summary/get-transaction-summary.ts
4905
4676
  var import_errors15 = require("@fuel-ts/errors");
4906
- var import_math17 = require("@fuel-ts/math");
4907
- var import_transactions20 = require("@fuel-ts/transactions");
4908
- var import_utils25 = require("@fuel-ts/utils");
4677
+ var import_math16 = require("@fuel-ts/math");
4678
+ var import_transactions19 = require("@fuel-ts/transactions");
4679
+ var import_utils26 = require("@fuel-ts/utils");
4909
4680
  async function getTransactionSummary(params) {
4910
4681
  const { id, provider, abiMap } = params;
4911
4682
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4917,32 +4688,25 @@ async function getTransactionSummary(params) {
4917
4688
  `Transaction not found for given id: ${id}.`
4918
4689
  );
4919
4690
  }
4920
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4921
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4691
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4692
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4922
4693
  0
4923
4694
  );
4924
- let txReceipts = [];
4925
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4926
- txReceipts = gqlTransaction.status.receipts;
4927
- }
4928
- const receipts = txReceipts.map(processGqlReceipt);
4695
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4929
4696
  const {
4930
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4697
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4931
4698
  } = provider.getChain();
4932
- const gasPrice = await provider.getLatestGasPrice();
4933
4699
  const transactionInfo = assembleTransactionSummary({
4934
4700
  id: gqlTransaction.id,
4935
4701
  receipts,
4936
4702
  transaction: decodedTransaction,
4937
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4703
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4938
4704
  gqlTransactionStatus: gqlTransaction.status,
4939
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4940
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4705
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4706
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4941
4707
  abiMap,
4942
4708
  maxInputs,
4943
- gasCosts,
4944
- maxGasPerTx,
4945
- gasPrice
4709
+ gasCosts
4946
4710
  });
4947
4711
  return {
4948
4712
  gqlTransaction,
@@ -4952,11 +4716,10 @@ async function getTransactionSummary(params) {
4952
4716
  async function getTransactionSummaryFromRequest(params) {
4953
4717
  const { provider, transactionRequest, abiMap } = params;
4954
4718
  const { receipts } = await provider.call(transactionRequest);
4955
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4719
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4956
4720
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4957
4721
  const transaction = transactionRequest.toTransaction();
4958
4722
  const transactionBytes = transactionRequest.toTransactionBytes();
4959
- const gasPrice = await provider.getLatestGasPrice();
4960
4723
  const transactionSummary = assembleTransactionSummary({
4961
4724
  receipts,
4962
4725
  transaction,
@@ -4965,9 +4728,7 @@ async function getTransactionSummaryFromRequest(params) {
4965
4728
  gasPerByte,
4966
4729
  gasPriceFactor,
4967
4730
  maxInputs,
4968
- gasCosts,
4969
- maxGasPerTx,
4970
- gasPrice
4731
+ gasCosts
4971
4732
  });
4972
4733
  return transactionSummary;
4973
4734
  }
@@ -4976,31 +4737,24 @@ async function getTransactionsSummaries(params) {
4976
4737
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4977
4738
  const { edges, pageInfo } = transactionsByOwner;
4978
4739
  const {
4979
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4740
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4980
4741
  } = provider.getChain();
4981
- const gasPrice = await provider.getLatestGasPrice();
4982
4742
  const transactions = edges.map((edge) => {
4983
4743
  const { node: gqlTransaction } = edge;
4984
- const { id, rawPayload, status } = gqlTransaction;
4985
- const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4986
- let txReceipts = [];
4987
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4988
- txReceipts = gqlTransaction.status.receipts;
4989
- }
4990
- const receipts = txReceipts.map(processGqlReceipt);
4744
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4745
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4746
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4991
4747
  const transactionSummary = assembleTransactionSummary({
4992
4748
  id,
4993
4749
  receipts,
4994
4750
  transaction: decodedTransaction,
4995
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4751
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4996
4752
  gqlTransactionStatus: status,
4997
4753
  abiMap,
4998
4754
  gasPerByte,
4999
4755
  gasPriceFactor,
5000
4756
  maxInputs,
5001
- gasCosts,
5002
- maxGasPerTx,
5003
- gasPrice
4757
+ gasCosts
5004
4758
  });
5005
4759
  const output = {
5006
4760
  gqlTransaction,
@@ -5137,17 +4891,17 @@ var assets = [
5137
4891
 
5138
4892
  // src/utils/formatTransferToContractScriptData.ts
5139
4893
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5140
- var import_math18 = require("@fuel-ts/math");
5141
- var import_utils26 = require("@fuel-ts/utils");
4894
+ var import_math17 = require("@fuel-ts/math");
4895
+ var import_utils27 = require("@fuel-ts/utils");
5142
4896
  var asm = __toESM(require("@fuels/vm-asm"));
5143
4897
  var formatTransferToContractScriptData = (params) => {
5144
4898
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5145
4899
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5146
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4900
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5147
4901
  const scriptData = Uint8Array.from([
5148
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4902
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5149
4903
  ...encoded,
5150
- ...(0, import_utils26.arrayify)(assetId)
4904
+ ...(0, import_utils27.arrayify)(assetId)
5151
4905
  ]);
5152
4906
  return scriptData;
5153
4907
  };
@@ -5332,33 +5086,36 @@ var Account = class extends import_interfaces.AbstractAccount {
5332
5086
  * @param fee - The estimated transaction fee.
5333
5087
  * @returns A promise that resolves when the resources are added to the transaction.
5334
5088
  */
5335
- async fund(request, params) {
5336
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5337
- const txRequest = request;
5338
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5339
- amount: (0, import_math19.bn)(fee),
5089
+ async fund(request, coinQuantities, fee) {
5090
+ const updatedQuantities = addAmountToAsset({
5091
+ amount: (0, import_math18.bn)(fee),
5340
5092
  assetId: import_configs12.BaseAssetId,
5341
- coinQuantities: requiredQuantities
5093
+ coinQuantities
5342
5094
  });
5343
5095
  const quantitiesDict = {};
5344
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5096
+ updatedQuantities.forEach(({ amount, assetId }) => {
5345
5097
  quantitiesDict[assetId] = {
5346
5098
  required: amount,
5347
- owned: (0, import_math19.bn)(0)
5099
+ owned: (0, import_math18.bn)(0)
5348
5100
  };
5349
5101
  });
5350
- txRequest.inputs.forEach((input) => {
5102
+ const cachedUtxos = [];
5103
+ const cachedMessages = [];
5104
+ const owner = this.address.toB256();
5105
+ request.inputs.forEach((input) => {
5351
5106
  const isResource = "amount" in input;
5352
5107
  if (isResource) {
5353
5108
  const isCoin2 = "owner" in input;
5354
5109
  if (isCoin2) {
5355
5110
  const assetId = String(input.assetId);
5356
- if (quantitiesDict[assetId]) {
5357
- const amount = (0, import_math19.bn)(input.amount);
5111
+ if (input.owner === owner && quantitiesDict[assetId]) {
5112
+ const amount = (0, import_math18.bn)(input.amount);
5358
5113
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5114
+ cachedUtxos.push(input.id);
5359
5115
  }
5360
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5116
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5361
5117
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5118
+ cachedMessages.push(input.nonce);
5362
5119
  }
5363
5120
  }
5364
5121
  });
@@ -5373,23 +5130,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5373
5130
  });
5374
5131
  const needsToBeFunded = missingQuantities.length;
5375
5132
  if (needsToBeFunded) {
5376
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5377
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5378
- txRequest.addResources(resources);
5379
- }
5380
- txRequest.shiftPredicateData();
5381
- txRequest.updatePredicateGasUsed(estimatedPredicates);
5382
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5383
- if (addedSignatures) {
5384
- Array.from({ length: addedSignatures }).forEach(
5385
- () => requestToBeReEstimate.addEmptyWitness()
5386
- );
5133
+ const resources = await this.getResourcesToSpend(missingQuantities, {
5134
+ messages: cachedMessages,
5135
+ utxos: cachedUtxos
5136
+ });
5137
+ request.addResources(resources);
5387
5138
  }
5388
- const { maxFee } = await this.provider.estimateTxGasAndFee({
5389
- transactionRequest: requestToBeReEstimate
5390
- });
5391
- txRequest.maxFee = maxFee;
5392
- return txRequest;
5393
5139
  }
5394
5140
  /**
5395
5141
  * A helper that creates a transfer transaction request and returns it.
@@ -5397,25 +5143,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5397
5143
  * @param destination - The address of the destination.
5398
5144
  * @param amount - The amount of coins to transfer.
5399
5145
  * @param assetId - The asset ID of the coins to transfer.
5400
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5146
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5401
5147
  * @returns A promise that resolves to the prepared transaction request.
5402
5148
  */
5403
5149
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5404
- const request = new ScriptTransactionRequest(txParams);
5150
+ const { minGasPrice } = this.provider.getGasConfig();
5151
+ const params = { gasPrice: minGasPrice, ...txParams };
5152
+ const request = new ScriptTransactionRequest(params);
5405
5153
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5406
- const txCost = await this.provider.getTransactionCost(request, {
5154
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5407
5155
  estimateTxDependencies: true,
5408
5156
  resourcesOwner: this
5409
5157
  });
5410
- if ("gasLimit" in txParams) {
5411
- this.validateGas({
5412
- gasUsed: txCost.gasUsed,
5413
- gasLimit: request.gasLimit
5414
- });
5415
- }
5416
- request.gasLimit = txCost.gasUsed;
5417
- request.maxFee = txCost.maxFee;
5418
- await this.fund(request, txCost);
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
5165
+ });
5166
+ await this.fund(request, requiredQuantities, maxFee);
5167
+ request.updatePredicateInputs(estimatedInputs);
5419
5168
  return request;
5420
5169
  }
5421
5170
  /**
@@ -5428,7 +5177,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5428
5177
  * @returns A promise that resolves to the transaction response.
5429
5178
  */
5430
5179
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5431
- if ((0, import_math19.bn)(amount).lte(0)) {
5180
+ if ((0, import_math18.bn)(amount).lte(0)) {
5432
5181
  throw new import_errors16.FuelError(
5433
5182
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5434
5183
  "Transfer amount must be a positive number."
@@ -5447,37 +5196,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5447
5196
  * @returns A promise that resolves to the transaction response.
5448
5197
  */
5449
5198
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5450
- if ((0, import_math19.bn)(amount).lte(0)) {
5199
+ if ((0, import_math18.bn)(amount).lte(0)) {
5451
5200
  throw new import_errors16.FuelError(
5452
5201
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5453
5202
  "Transfer amount must be a positive number."
5454
5203
  );
5455
5204
  }
5456
5205
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5206
+ const { minGasPrice } = this.provider.getGasConfig();
5207
+ const params = { gasPrice: minGasPrice, ...txParams };
5457
5208
  const { script, scriptData } = await assembleTransferToContractScript({
5458
5209
  hexlifiedContractId: contractAddress.toB256(),
5459
- amountToTransfer: (0, import_math19.bn)(amount),
5210
+ amountToTransfer: (0, import_math18.bn)(amount),
5460
5211
  assetId
5461
5212
  });
5462
5213
  const request = new ScriptTransactionRequest({
5463
- ...txParams,
5214
+ ...params,
5464
5215
  script,
5465
5216
  scriptData
5466
5217
  });
5467
5218
  request.addContractInputAndOutput(contractAddress);
5468
- const txCost = await this.provider.getTransactionCost(request, {
5469
- resourcesOwner: this,
5470
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5219
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5220
+ request,
5221
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5222
+ );
5223
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5224
+ this.validateGas({
5225
+ gasUsed,
5226
+ gasPrice: request.gasPrice,
5227
+ gasLimit: request.gasLimit,
5228
+ minGasPrice
5471
5229
  });
5472
- if (txParams.gasLimit) {
5473
- this.validateGas({
5474
- gasUsed: txCost.gasUsed,
5475
- gasLimit: request.gasLimit
5476
- });
5477
- }
5478
- request.gasLimit = txCost.gasUsed;
5479
- request.maxFee = txCost.maxFee;
5480
- await this.fund(request, txCost);
5230
+ await this.fund(request, requiredQuantities, maxFee);
5481
5231
  return this.sendTransaction(request);
5482
5232
  }
5483
5233
  /**
@@ -5489,31 +5239,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5489
5239
  * @returns A promise that resolves to the transaction response.
5490
5240
  */
5491
5241
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5242
+ const { minGasPrice } = this.provider.getGasConfig();
5492
5243
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5493
- const recipientDataArray = (0, import_utils27.arrayify)(
5244
+ const recipientDataArray = (0, import_utils28.arrayify)(
5494
5245
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5495
5246
  );
5496
- const amountDataArray = (0, import_utils27.arrayify)(
5497
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5247
+ const amountDataArray = (0, import_utils28.arrayify)(
5248
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5498
5249
  );
5499
5250
  const script = new Uint8Array([
5500
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5251
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5501
5252
  ...recipientDataArray,
5502
5253
  ...amountDataArray
5503
5254
  ]);
5504
- const params = { script, ...txParams };
5255
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5505
5256
  const request = new ScriptTransactionRequest(params);
5506
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5507
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5508
- if (txParams.gasLimit) {
5509
- this.validateGas({
5510
- gasUsed: txCost.gasUsed,
5511
- gasLimit: request.gasLimit
5512
- });
5513
- }
5514
- request.maxFee = txCost.maxFee;
5515
- request.gasLimit = txCost.gasUsed;
5516
- await this.fund(request, txCost);
5257
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5258
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5259
+ request,
5260
+ forwardingQuantities
5261
+ );
5262
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5263
+ this.validateGas({
5264
+ gasUsed,
5265
+ gasPrice: request.gasPrice,
5266
+ gasLimit: request.gasLimit,
5267
+ minGasPrice
5268
+ });
5269
+ await this.fund(request, requiredQuantities, maxFee);
5517
5270
  return this.sendTransaction(request);
5518
5271
  }
5519
5272
  async signMessage(message) {
@@ -5571,7 +5324,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5571
5324
  }
5572
5325
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5573
5326
  }
5574
- validateGas({ gasUsed, gasLimit }) {
5327
+ validateGas({
5328
+ gasUsed,
5329
+ gasPrice,
5330
+ gasLimit,
5331
+ minGasPrice
5332
+ }) {
5333
+ if (minGasPrice.gt(gasPrice)) {
5334
+ throw new import_errors16.FuelError(
5335
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5336
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5337
+ );
5338
+ }
5575
5339
  if (gasUsed.gt(gasLimit)) {
5576
5340
  throw new import_errors16.FuelError(
5577
5341
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5583,14 +5347,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5583
5347
 
5584
5348
  // src/wallet/base-wallet-unlocked.ts
5585
5349
  var import_hasher3 = require("@fuel-ts/hasher");
5586
- var import_utils30 = require("@fuel-ts/utils");
5350
+ var import_utils31 = require("@fuel-ts/utils");
5587
5351
 
5588
5352
  // src/signer/signer.ts
5589
5353
  var import_address5 = require("@fuel-ts/address");
5590
5354
  var import_crypto2 = require("@fuel-ts/crypto");
5591
5355
  var import_hasher2 = require("@fuel-ts/hasher");
5592
- var import_math20 = require("@fuel-ts/math");
5593
- var import_utils28 = require("@fuel-ts/utils");
5356
+ var import_math19 = require("@fuel-ts/math");
5357
+ var import_utils29 = require("@fuel-ts/utils");
5594
5358
  var import_secp256k1 = require("@noble/curves/secp256k1");
5595
5359
  var Signer = class {
5596
5360
  address;
@@ -5609,10 +5373,10 @@ var Signer = class {
5609
5373
  privateKey = `0x${privateKey}`;
5610
5374
  }
5611
5375
  }
5612
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5613
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5614
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5615
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5376
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5377
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5378
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5379
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5616
5380
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5617
5381
  }
5618
5382
  /**
@@ -5626,11 +5390,11 @@ var Signer = class {
5626
5390
  * @returns hashed signature
5627
5391
  */
5628
5392
  sign(data) {
5629
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5630
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5631
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5393
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5394
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5395
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5632
5396
  s[0] |= (signature.recovery || 0) << 7;
5633
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5397
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5634
5398
  }
5635
5399
  /**
5636
5400
  * Add point on the current elliptic curve
@@ -5639,8 +5403,8 @@ var Signer = class {
5639
5403
  * @returns compressed point on the curve
5640
5404
  */
5641
5405
  addPoint(point) {
5642
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5643
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5406
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5407
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5644
5408
  const result = p0.add(p1);
5645
5409
  return `0x${result.toHex(true)}`;
5646
5410
  }
@@ -5652,16 +5416,16 @@ var Signer = class {
5652
5416
  * @returns public key from signature from the
5653
5417
  */
5654
5418
  static recoverPublicKey(data, signature) {
5655
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5419
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5656
5420
  const r = signedMessageBytes.slice(0, 32);
5657
5421
  const s = signedMessageBytes.slice(32, 64);
5658
5422
  const recoveryParam = (s[0] & 128) >> 7;
5659
5423
  s[0] &= 127;
5660
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5424
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5661
5425
  recoveryParam
5662
5426
  );
5663
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5664
- return (0, import_utils28.hexlify)(publicKey);
5427
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5428
+ return (0, import_utils29.hexlify)(publicKey);
5665
5429
  }
5666
5430
  /**
5667
5431
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5680,7 +5444,7 @@ var Signer = class {
5680
5444
  * @returns random 32-byte hashed
5681
5445
  */
5682
5446
  static generatePrivateKey(entropy) {
5683
- 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);
5447
+ 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);
5684
5448
  }
5685
5449
  /**
5686
5450
  * Extended publicKey from a compact publicKey
@@ -5689,8 +5453,8 @@ var Signer = class {
5689
5453
  * @returns extended publicKey
5690
5454
  */
5691
5455
  static extendPublicKey(publicKey) {
5692
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5693
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5456
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5457
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5694
5458
  }
5695
5459
  };
5696
5460
 
@@ -5698,7 +5462,7 @@ var Signer = class {
5698
5462
  var import_address6 = require("@fuel-ts/address");
5699
5463
  var import_crypto3 = require("@fuel-ts/crypto");
5700
5464
  var import_errors17 = require("@fuel-ts/errors");
5701
- var import_utils29 = require("@fuel-ts/utils");
5465
+ var import_utils30 = require("@fuel-ts/utils");
5702
5466
  var import_uuid = require("uuid");
5703
5467
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5704
5468
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5781,7 +5545,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5781
5545
  );
5782
5546
  }
5783
5547
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5784
- const privateKey = (0, import_utils29.hexlify)(buffer);
5548
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5785
5549
  return privateKey;
5786
5550
  }
5787
5551
 
@@ -5826,7 +5590,7 @@ var BaseWalletUnlocked = class extends Account {
5826
5590
  */
5827
5591
  async signMessage(message) {
5828
5592
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5829
- return (0, import_utils30.hexlify)(signedMessage);
5593
+ return (0, import_utils31.hexlify)(signedMessage);
5830
5594
  }
5831
5595
  /**
5832
5596
  * Signs a transaction with the wallet's private key.
@@ -5839,7 +5603,7 @@ var BaseWalletUnlocked = class extends Account {
5839
5603
  const chainId = this.provider.getChainId();
5840
5604
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5841
5605
  const signature = await this.signer().sign(hashedTransaction);
5842
- return (0, import_utils30.hexlify)(signature);
5606
+ return (0, import_utils31.hexlify)(signature);
5843
5607
  }
5844
5608
  /**
5845
5609
  * Populates a transaction with the witnesses signature.
@@ -5859,7 +5623,7 @@ var BaseWalletUnlocked = class extends Account {
5859
5623
  * @param transactionRequestLike - The transaction request to send.
5860
5624
  * @returns A promise that resolves to the TransactionResponse object.
5861
5625
  */
5862
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5626
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5863
5627
  const transactionRequest = transactionRequestify(transactionRequestLike);
5864
5628
  if (estimateTxDependencies) {
5865
5629
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5900,15 +5664,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5900
5664
  // src/hdwallet/hdwallet.ts
5901
5665
  var import_errors20 = require("@fuel-ts/errors");
5902
5666
  var import_hasher6 = require("@fuel-ts/hasher");
5903
- var import_math21 = require("@fuel-ts/math");
5904
- var import_utils34 = require("@fuel-ts/utils");
5667
+ var import_math20 = require("@fuel-ts/math");
5668
+ var import_utils35 = require("@fuel-ts/utils");
5905
5669
  var import_ethers3 = require("ethers");
5906
5670
 
5907
5671
  // src/mnemonic/mnemonic.ts
5908
5672
  var import_crypto4 = require("@fuel-ts/crypto");
5909
5673
  var import_errors19 = require("@fuel-ts/errors");
5910
5674
  var import_hasher5 = require("@fuel-ts/hasher");
5911
- var import_utils32 = require("@fuel-ts/utils");
5675
+ var import_utils33 = require("@fuel-ts/utils");
5912
5676
  var import_ethers2 = require("ethers");
5913
5677
 
5914
5678
  // src/wordlists/words/english.ts
@@ -7972,7 +7736,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7972
7736
  // src/mnemonic/utils.ts
7973
7737
  var import_errors18 = require("@fuel-ts/errors");
7974
7738
  var import_hasher4 = require("@fuel-ts/hasher");
7975
- var import_utils31 = require("@fuel-ts/utils");
7739
+ var import_utils32 = require("@fuel-ts/utils");
7976
7740
  function toUtf8Bytes(stri) {
7977
7741
  const str = stri.normalize("NFKD");
7978
7742
  const result = [];
@@ -8039,14 +7803,14 @@ function entropyToMnemonicIndices(entropy) {
8039
7803
  }
8040
7804
  }
8041
7805
  const checksumBits = entropy.length / 4;
8042
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7806
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8043
7807
  indices[indices.length - 1] <<= checksumBits;
8044
7808
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8045
7809
  return indices;
8046
7810
  }
8047
7811
  function mnemonicWordsToEntropy(words, wordlist) {
8048
7812
  const size = Math.ceil(11 * words.length / 8);
8049
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7813
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8050
7814
  let offset = 0;
8051
7815
  for (let i = 0; i < words.length; i += 1) {
8052
7816
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8066,7 +7830,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8066
7830
  const entropyBits = 32 * words.length / 3;
8067
7831
  const checksumBits = words.length / 3;
8068
7832
  const checksumMask = getUpperMask(checksumBits);
8069
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7833
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8070
7834
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8071
7835
  throw new import_errors18.FuelError(
8072
7836
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8141,7 +7905,7 @@ var Mnemonic = class {
8141
7905
  static mnemonicToEntropy(phrase, wordlist = english) {
8142
7906
  const words = getWords(phrase);
8143
7907
  assertMnemonic(words);
8144
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7908
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8145
7909
  }
8146
7910
  /**
8147
7911
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8149,7 +7913,7 @@ var Mnemonic = class {
8149
7913
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8150
7914
  */
8151
7915
  static entropyToMnemonic(entropy, wordlist = english) {
8152
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7916
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8153
7917
  assertWordList(wordlist);
8154
7918
  assertEntropy(entropyBytes);
8155
7919
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8218,14 +7982,14 @@ var Mnemonic = class {
8218
7982
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8219
7983
  */
8220
7984
  static masterKeysFromSeed(seed) {
8221
- const seedArray = (0, import_utils32.arrayify)(seed);
7985
+ const seedArray = (0, import_utils33.arrayify)(seed);
8222
7986
  if (seedArray.length < 16 || seedArray.length > 64) {
8223
7987
  throw new import_errors19.FuelError(
8224
7988
  import_errors19.ErrorCode.INVALID_SEED,
8225
7989
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8226
7990
  );
8227
7991
  }
8228
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7992
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8229
7993
  }
8230
7994
  /**
8231
7995
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8236,22 +8000,22 @@ var Mnemonic = class {
8236
8000
  */
8237
8001
  static seedToExtendedKey(seed, testnet = false) {
8238
8002
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8239
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8003
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8240
8004
  const depth = "0x00";
8241
8005
  const fingerprint = "0x00000000";
8242
8006
  const index = "0x00000000";
8243
8007
  const chainCode = masterKey.slice(32);
8244
8008
  const privateKey = masterKey.slice(0, 32);
8245
- const extendedKey = (0, import_utils32.concat)([
8009
+ const extendedKey = (0, import_utils33.concat)([
8246
8010
  prefix,
8247
8011
  depth,
8248
8012
  fingerprint,
8249
8013
  index,
8250
8014
  chainCode,
8251
- (0, import_utils32.concat)(["0x00", privateKey])
8015
+ (0, import_utils33.concat)(["0x00", privateKey])
8252
8016
  ]);
8253
8017
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8254
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8018
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8255
8019
  }
8256
8020
  /**
8257
8021
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8266,7 +8030,7 @@ var Mnemonic = class {
8266
8030
  * @returns A randomly generated mnemonic
8267
8031
  */
8268
8032
  static generate(size = 32, extraEntropy = "") {
8269
- 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);
8033
+ 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);
8270
8034
  return Mnemonic.entropyToMnemonic(entropy);
8271
8035
  }
8272
8036
  };
@@ -8274,12 +8038,12 @@ var mnemonic_default = Mnemonic;
8274
8038
 
8275
8039
  // src/hdwallet/hdwallet.ts
8276
8040
  var HARDENED_INDEX = 2147483648;
8277
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8278
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8279
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8280
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8041
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8042
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8043
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8044
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8281
8045
  function base58check(data) {
8282
- 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)]));
8046
+ return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8283
8047
  }
8284
8048
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8285
8049
  if (isPublic) {
@@ -8288,11 +8052,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8288
8052
  return testnet ? TestnetPRV2 : MainnetPRV2;
8289
8053
  }
8290
8054
  function isPublicExtendedKey(extendedKey) {
8291
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8055
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8292
8056
  }
8293
8057
  function isValidExtendedKey(extendedKey) {
8294
8058
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8295
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8059
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8296
8060
  );
8297
8061
  }
8298
8062
  function parsePath(path, depth = 0) {
@@ -8310,8 +8074,8 @@ function parsePath(path, depth = 0) {
8310
8074
  var HDWallet = class {
8311
8075
  depth = 0;
8312
8076
  index = 0;
8313
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
8314
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8077
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8078
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8315
8079
  privateKey;
8316
8080
  publicKey;
8317
8081
  chainCode;
@@ -8323,8 +8087,8 @@ var HDWallet = class {
8323
8087
  constructor(config) {
8324
8088
  if (config.privateKey) {
8325
8089
  const signer = new Signer(config.privateKey);
8326
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8327
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8090
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8091
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8328
8092
  } else {
8329
8093
  if (!config.publicKey) {
8330
8094
  throw new import_errors20.FuelError(
@@ -8332,7 +8096,7 @@ var HDWallet = class {
8332
8096
  "Both public and private Key cannot be missing. At least one should be provided."
8333
8097
  );
8334
8098
  }
8335
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8099
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8336
8100
  }
8337
8101
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8338
8102
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8351,9 +8115,9 @@ var HDWallet = class {
8351
8115
  * @returns A new instance of HDWallet on the derived index
8352
8116
  */
8353
8117
  deriveIndex(index) {
8354
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8355
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8356
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8118
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8119
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8120
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8357
8121
  const data = new Uint8Array(37);
8358
8122
  if (index & HARDENED_INDEX) {
8359
8123
  if (!privateKey) {
@@ -8364,15 +8128,15 @@ var HDWallet = class {
8364
8128
  }
8365
8129
  data.set(privateKey, 1);
8366
8130
  } else {
8367
- data.set((0, import_utils34.arrayify)(this.publicKey));
8131
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8368
8132
  }
8369
- data.set((0, import_math21.toBytes)(index, 4), 33);
8370
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8133
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8134
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8371
8135
  const IL = bytes.slice(0, 32);
8372
8136
  const IR = bytes.slice(32);
8373
8137
  if (privateKey) {
8374
8138
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8375
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8139
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8376
8140
  return new HDWallet({
8377
8141
  privateKey: ki,
8378
8142
  chainCode: IR,
@@ -8381,7 +8145,7 @@ var HDWallet = class {
8381
8145
  parentFingerprint: this.fingerprint
8382
8146
  });
8383
8147
  }
8384
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8148
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8385
8149
  const Ki = signer.addPoint(publicKey);
8386
8150
  return new HDWallet({
8387
8151
  publicKey: Ki,
@@ -8416,12 +8180,12 @@ var HDWallet = class {
8416
8180
  );
8417
8181
  }
8418
8182
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8419
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8183
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8420
8184
  const parentFingerprint = this.parentFingerprint;
8421
- const index = (0, import_math21.toHex)(this.index, 4);
8185
+ const index = (0, import_math20.toHex)(this.index, 4);
8422
8186
  const chainCode = this.chainCode;
8423
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8424
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8187
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8188
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8425
8189
  return base58check(extendedKey);
8426
8190
  }
8427
8191
  /**
@@ -8433,13 +8197,13 @@ var HDWallet = class {
8433
8197
  static fromSeed(seed) {
8434
8198
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8435
8199
  return new HDWallet({
8436
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8437
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8200
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8201
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8438
8202
  });
8439
8203
  }
8440
8204
  static fromExtendedKey(extendedKey) {
8441
8205
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8442
- const bytes = (0, import_utils34.arrayify)(decoded);
8206
+ const bytes = (0, import_utils35.arrayify)(decoded);
8443
8207
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8444
8208
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8445
8209
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8448,9 +8212,9 @@ var HDWallet = class {
8448
8212
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8449
8213
  }
8450
8214
  const depth = bytes[4];
8451
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8452
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8453
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8215
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8216
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8217
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8454
8218
  const key = bytes.slice(45, 78);
8455
8219
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8456
8220
  throw new import_errors20.FuelError(
@@ -9055,19 +8819,19 @@ var import_abi_coder7 = require("@fuel-ts/abi-coder");
9055
8819
  var import_address10 = require("@fuel-ts/address");
9056
8820
  var import_configs13 = require("@fuel-ts/address/configs");
9057
8821
  var import_errors25 = require("@fuel-ts/errors");
9058
- var import_transactions21 = require("@fuel-ts/transactions");
9059
- var import_utils36 = require("@fuel-ts/utils");
8822
+ var import_transactions20 = require("@fuel-ts/transactions");
8823
+ var import_utils37 = require("@fuel-ts/utils");
9060
8824
 
9061
8825
  // src/predicate/utils/getPredicateRoot.ts
9062
8826
  var import_hasher7 = require("@fuel-ts/hasher");
9063
8827
  var import_merkle = require("@fuel-ts/merkle");
9064
- var import_utils35 = require("@fuel-ts/utils");
8828
+ var import_utils36 = require("@fuel-ts/utils");
9065
8829
  var getPredicateRoot = (bytecode) => {
9066
8830
  const chunkSize = 16 * 1024;
9067
- const bytes = (0, import_utils35.arrayify)(bytecode);
9068
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9069
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9070
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8831
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8832
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8833
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8834
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9071
8835
  return predicateRoot;
9072
8836
  };
9073
8837
 
@@ -9115,9 +8879,9 @@ var Predicate = class extends Account {
9115
8879
  const request = transactionRequestify(transactionRequestLike);
9116
8880
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9117
8881
  request.inputs?.forEach((input) => {
9118
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9119
- input.predicate = (0, import_utils36.hexlify)(this.bytes);
9120
- input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8882
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8883
+ input.predicate = this.bytes;
8884
+ input.predicateData = this.getPredicateData(policies.length);
9121
8885
  }
9122
8886
  });
9123
8887
  return request;
@@ -9132,7 +8896,8 @@ var Predicate = class extends Account {
9132
8896
  * @returns A promise that resolves to the prepared transaction request.
9133
8897
  */
9134
8898
  async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
9135
- return super.createTransfer(destination, amount, assetId, txParams);
8899
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8900
+ return this.populateTransactionPredicateData(request);
9136
8901
  }
9137
8902
  /**
9138
8903
  * Sends a transaction with the populated predicate data.
@@ -9140,9 +8905,9 @@ var Predicate = class extends Account {
9140
8905
  * @param transactionRequestLike - The transaction request-like object.
9141
8906
  * @returns A promise that resolves to the transaction response.
9142
8907
  */
9143
- sendTransaction(transactionRequestLike) {
9144
- const transactionRequest = transactionRequestify(transactionRequestLike);
9145
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8908
+ sendTransaction(transactionRequestLike, options) {
8909
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8910
+ return super.sendTransaction(transactionRequest, options);
9146
8911
  }
9147
8912
  /**
9148
8913
  * Simulates a transaction with the populated predicate data.
@@ -9151,15 +8916,15 @@ var Predicate = class extends Account {
9151
8916
  * @returns A promise that resolves to the call result.
9152
8917
  */
9153
8918
  simulateTransaction(transactionRequestLike) {
9154
- const transactionRequest = transactionRequestify(transactionRequestLike);
9155
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8919
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8920
+ return super.simulateTransaction(transactionRequest);
9156
8921
  }
9157
8922
  getPredicateData(policiesLength) {
9158
8923
  if (!this.predicateData.length) {
9159
8924
  return new Uint8Array();
9160
8925
  }
9161
8926
  const mainFn = this.interface?.functions.main;
9162
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8927
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9163
8928
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9164
8929
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9165
8930
  });
@@ -9175,7 +8940,7 @@ var Predicate = class extends Account {
9175
8940
  * @returns An object containing the new predicate bytes and interface.
9176
8941
  */
9177
8942
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9178
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8943
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9179
8944
  let abiInterface;
9180
8945
  if (jsonAbi) {
9181
8946
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9198,25 +8963,6 @@ var Predicate = class extends Account {
9198
8963
  predicateInterface: abiInterface
9199
8964
  };
9200
8965
  }
9201
- /**
9202
- * Retrieves resources satisfying the spend query for the account.
9203
- *
9204
- * @param quantities - IDs of coins to exclude.
9205
- * @param excludedIds - IDs of resources to be excluded from the query.
9206
- * @returns A promise that resolves to an array of Resources.
9207
- */
9208
- async getResourcesToSpend(quantities, excludedIds) {
9209
- const resources = await this.provider.getResourcesToSpend(
9210
- this.address,
9211
- quantities,
9212
- excludedIds
9213
- );
9214
- return resources.map((resource) => ({
9215
- ...resource,
9216
- predicate: (0, import_utils36.hexlify)(this.bytes),
9217
- paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9218
- }));
9219
- }
9220
8966
  /**
9221
8967
  * Sets the configurable constants for the predicate.
9222
8968
  *
@@ -9966,7 +9712,7 @@ __publicField(Fuel, "defaultConfig", {});
9966
9712
  WalletLocked,
9967
9713
  WalletManager,
9968
9714
  WalletUnlocked,
9969
- addAmountToCoinQuantities,
9715
+ addAmountToAsset,
9970
9716
  addOperation,
9971
9717
  assemblePanicError,
9972
9718
  assembleReceiptByType,
@@ -9975,10 +9721,9 @@ __publicField(Fuel, "defaultConfig", {});
9975
9721
  assets,
9976
9722
  buildBlockExplorerUrl,
9977
9723
  cacheFor,
9978
- cacheTxInputsFromOwner,
9979
- calculateGasFee,
9980
9724
  calculateMetadataGasForTxCreate,
9981
9725
  calculateMetadataGasForTxScript,
9726
+ calculatePriceWithFactor,
9982
9727
  calculateTransactionFee,
9983
9728
  coinQuantityfy,
9984
9729
  deferPromise,