@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-2021-20240411141803

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 +5 -4
  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 +844 -560
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +786 -518
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +666 -399
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +888 -322
  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 -1
  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 +2 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +45 -27
  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 +6 -5
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +3 -0
  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 +2 -0
  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 +3 -2
  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 +8 -2
  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 +1562 -1046
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +764 -499
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +660 -395
  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
- addAmountToAsset: () => addAmountToAsset,
98
+ addAmountToCoinQuantities: () => addAmountToCoinQuantities,
99
99
  addOperation: () => addOperation,
100
100
  assemblePanicError: () => assemblePanicError,
101
101
  assembleReceiptByType: () => assembleReceiptByType,
@@ -104,9 +104,10 @@ __export(src_exports, {
104
104
  assets: () => assets,
105
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
106
106
  cacheFor: () => cacheFor,
107
+ cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
108
+ calculateGasFee: () => calculateGasFee,
107
109
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
108
110
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
109
- calculatePriceWithFactor: () => calculatePriceWithFactor,
110
111
  calculateTransactionFee: () => calculateTransactionFee,
111
112
  coinQuantityfy: () => coinQuantityfy,
112
113
  deferPromise: () => deferPromise,
@@ -187,8 +188,9 @@ var import_address4 = require("@fuel-ts/address");
187
188
  var import_configs12 = require("@fuel-ts/address/configs");
188
189
  var import_errors16 = require("@fuel-ts/errors");
189
190
  var import_interfaces = require("@fuel-ts/interfaces");
190
- var import_math18 = require("@fuel-ts/math");
191
- var import_utils28 = require("@fuel-ts/utils");
191
+ var import_math19 = require("@fuel-ts/math");
192
+ var import_utils27 = require("@fuel-ts/utils");
193
+ var import_ramda4 = require("ramda");
192
194
 
193
195
  // src/providers/coin-quantity.ts
194
196
  var import_configs = require("@fuel-ts/address/configs");
@@ -197,24 +199,24 @@ var import_utils = require("@fuel-ts/utils");
197
199
  var coinQuantityfy = (coinQuantityLike) => {
198
200
  let assetId;
199
201
  let amount;
200
- let max2;
202
+ let max;
201
203
  if (Array.isArray(coinQuantityLike)) {
202
204
  amount = coinQuantityLike[0];
203
205
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
204
- max2 = coinQuantityLike[2] ?? void 0;
206
+ max = coinQuantityLike[2] ?? void 0;
205
207
  } else {
206
208
  amount = coinQuantityLike.amount;
207
209
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
208
- max2 = coinQuantityLike.max ?? void 0;
210
+ max = coinQuantityLike.max ?? void 0;
209
211
  }
210
212
  const bnAmount = (0, import_math.bn)(amount);
211
213
  return {
212
214
  assetId: (0, import_utils.hexlify)(assetId),
213
215
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
214
- max: max2 ? (0, import_math.bn)(max2) : void 0
216
+ max: max ? (0, import_math.bn)(max) : void 0
215
217
  };
216
218
  };
217
- var addAmountToAsset = (params) => {
219
+ var addAmountToCoinQuantities = (params) => {
218
220
  const { amount, assetId } = params;
219
221
  const coinQuantities = [...params.coinQuantities];
220
222
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -229,12 +231,12 @@ var addAmountToAsset = (params) => {
229
231
  // src/providers/provider.ts
230
232
  var import_address3 = require("@fuel-ts/address");
231
233
  var import_errors14 = require("@fuel-ts/errors");
232
- var import_math15 = require("@fuel-ts/math");
233
- var import_transactions18 = require("@fuel-ts/transactions");
234
- var import_utils23 = require("@fuel-ts/utils");
234
+ var import_math16 = require("@fuel-ts/math");
235
+ var import_transactions19 = require("@fuel-ts/transactions");
236
+ var import_utils22 = require("@fuel-ts/utils");
235
237
  var import_versions = require("@fuel-ts/versions");
236
- var import_utils24 = require("@noble/curves/abstract/utils");
237
- var import_ethers = require("ethers");
238
+ var import_utils23 = require("@noble/curves/abstract/utils");
239
+ var import_ethers2 = require("ethers");
238
240
  var import_graphql_request = require("graphql-request");
239
241
  var import_ramda3 = require("ramda");
240
242
 
@@ -242,14 +244,10 @@ var import_ramda3 = require("ramda");
242
244
  var import_graphql_tag = __toESM(require("graphql-tag"));
243
245
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
244
246
  fragment receiptFragment on Receipt {
245
- contract {
246
- id
247
- }
247
+ id
248
248
  pc
249
249
  is
250
- to {
251
- id
252
- }
250
+ to
253
251
  toAddress
254
252
  amount
255
253
  assetId
@@ -287,10 +285,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
287
285
  id
288
286
  }
289
287
  time
288
+ receipts {
289
+ ...receiptFragment
290
+ }
290
291
  programState {
291
292
  returnType
292
293
  data
293
294
  }
295
+ receipts {
296
+ ...receiptFragment
297
+ }
294
298
  }
295
299
  ... on FailureStatus {
296
300
  block {
@@ -298,26 +302,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
298
302
  }
299
303
  time
300
304
  reason
305
+ receipts {
306
+ ...receiptFragment
307
+ }
301
308
  }
302
309
  ... on SqueezedOutStatus {
303
310
  reason
304
311
  }
305
312
  }
306
- `;
313
+ ${ReceiptFragmentFragmentDoc}`;
307
314
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
308
315
  fragment transactionFragment on Transaction {
309
316
  id
310
317
  rawPayload
311
- gasPrice
312
- receipts {
313
- ...receiptFragment
314
- }
315
318
  status {
316
319
  ...transactionStatusFragment
317
320
  }
318
321
  }
319
- ${ReceiptFragmentFragmentDoc}
320
- ${TransactionStatusFragmentFragmentDoc}`;
322
+ ${TransactionStatusFragmentFragmentDoc}`;
321
323
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
322
324
  fragment inputEstimatePredicatesFragment on Input {
323
325
  ... on InputCoin {
@@ -335,6 +337,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
335
337
  }
336
338
  }
337
339
  ${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}`;
338
380
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
339
381
  fragment coinFragment on Coin {
340
382
  __typename
@@ -342,7 +384,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
342
384
  owner
343
385
  amount
344
386
  assetId
345
- maturity
346
387
  blockCreated
347
388
  txCreatedIdx
348
389
  }
@@ -387,7 +428,6 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
387
428
  prevRoot
388
429
  time
389
430
  applicationHash
390
- messageReceiptRoot
391
431
  messageReceiptCount
392
432
  }
393
433
  commitBlockHeader {
@@ -399,7 +439,6 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
399
439
  prevRoot
400
440
  time
401
441
  applicationHash
402
- messageReceiptRoot
403
442
  messageReceiptCount
404
443
  }
405
444
  sender
@@ -419,8 +458,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
419
458
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
420
459
  fragment blockFragment on Block {
421
460
  id
461
+ height
422
462
  header {
423
- height
424
463
  time
425
464
  }
426
465
  transactions {
@@ -478,6 +517,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
478
517
  `;
479
518
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
480
519
  fragment GasCostsFragment on GasCosts {
520
+ version {
521
+ ... on Version {
522
+ value
523
+ }
524
+ }
481
525
  add
482
526
  addi
483
527
  aloc
@@ -490,7 +534,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
490
534
  cb
491
535
  cfei
492
536
  cfsi
493
- croo
494
537
  div
495
538
  divi
496
539
  ecr1
@@ -573,6 +616,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
573
616
  ccp {
574
617
  ...DependentCostFragment
575
618
  }
619
+ croo {
620
+ ...DependentCostFragment
621
+ }
576
622
  csiz {
577
623
  ...DependentCostFragment
578
624
  }
@@ -632,6 +678,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
632
678
  ${DependentCostFragmentFragmentDoc}`;
633
679
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
634
680
  fragment consensusParametersFragment on ConsensusParameters {
681
+ version {
682
+ ... on Version {
683
+ value
684
+ }
685
+ }
635
686
  txParams {
636
687
  ...TxParametersFragment
637
688
  }
@@ -691,18 +742,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
691
742
  fragment nodeInfoFragment on NodeInfo {
692
743
  utxoValidation
693
744
  vmBacktrace
694
- minGasPrice
695
745
  maxTx
696
746
  maxDepth
697
747
  nodeVersion
698
- peers {
699
- id
700
- addresses
701
- clientVersion
702
- blockHeight
703
- lastHeartbeatMs
704
- appScore
705
- }
706
748
  }
707
749
  `;
708
750
  var GetVersionDocument = import_graphql_tag.default`
@@ -737,13 +779,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
737
779
  query getTransactionWithReceipts($transactionId: TransactionId!) {
738
780
  transaction(id: $transactionId) {
739
781
  ...transactionFragment
740
- receipts {
741
- ...receiptFragment
742
- }
743
782
  }
744
783
  }
745
- ${TransactionFragmentFragmentDoc}
746
- ${ReceiptFragmentFragmentDoc}`;
784
+ ${TransactionFragmentFragmentDoc}`;
747
785
  var GetTransactionsDocument = import_graphql_tag.default`
748
786
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
749
787
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -871,6 +909,20 @@ var GetBalanceDocument = import_graphql_tag.default`
871
909
  }
872
910
  }
873
911
  ${BalanceFragmentFragmentDoc}`;
912
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
913
+ query getLatestGasPrice {
914
+ latestGasPrice {
915
+ gasPrice
916
+ }
917
+ }
918
+ `;
919
+ var EstimateGasPriceDocument = import_graphql_tag.default`
920
+ query estimateGasPrice($blockHorizon: U32!) {
921
+ estimateGasPrice(blockHorizon: $blockHorizon) {
922
+ gasPrice
923
+ }
924
+ }
925
+ `;
874
926
  var GetBalancesDocument = import_graphql_tag.default`
875
927
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
876
928
  balances(
@@ -925,12 +977,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
925
977
  }
926
978
  `;
927
979
  var DryRunDocument = import_graphql_tag.default`
928
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
929
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
930
- ...receiptFragment
980
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
981
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
982
+ ...dryRunTransactionExecutionStatusFragment
931
983
  }
932
984
  }
933
- ${ReceiptFragmentFragmentDoc}`;
985
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
934
986
  var SubmitDocument = import_graphql_tag.default`
935
987
  mutation submit($encodedTransaction: HexString!) {
936
988
  submit(tx: $encodedTransaction) {
@@ -1013,6 +1065,12 @@ function getSdk(requester) {
1013
1065
  getBalance(variables, options) {
1014
1066
  return requester(GetBalanceDocument, variables, options);
1015
1067
  },
1068
+ getLatestGasPrice(variables, options) {
1069
+ return requester(GetLatestGasPriceDocument, variables, options);
1070
+ },
1071
+ estimateGasPrice(variables, options) {
1072
+ return requester(EstimateGasPriceDocument, variables, options);
1073
+ },
1016
1074
  getBalances(variables, options) {
1017
1075
  return requester(GetBalancesDocument, variables, options);
1018
1076
  },
@@ -1082,11 +1140,14 @@ var _FuelGraphqlSubscriber = class {
1082
1140
  let data;
1083
1141
  let errors;
1084
1142
  try {
1085
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1143
+ const sanitizedText = text.replace(/\s/g, "");
1144
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
1086
1145
  } catch (e) {
1087
1146
  throw new import_errors.FuelError(
1088
1147
  import_errors.ErrorCode.STREAM_PARSING_ERROR,
1089
- `Error while parsing stream data response: ${text}`
1148
+ `Error while parsing stream data response: ${text}
1149
+
1150
+ Thrown error: ${e}`
1090
1151
  );
1091
1152
  }
1092
1153
  if (Array.isArray(errors)) {
@@ -1187,7 +1248,7 @@ var inputify = (value) => {
1187
1248
  return {
1188
1249
  type: import_transactions.InputType.Coin,
1189
1250
  txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1190
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1251
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
1191
1252
  owner: (0, import_utils3.hexlify)(value.owner),
1192
1253
  amount: (0, import_math2.bn)(value.amount),
1193
1254
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1196,10 +1257,9 @@ var inputify = (value) => {
1196
1257
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1197
1258
  },
1198
1259
  witnessIndex: value.witnessIndex,
1199
- maturity: value.maturity ?? 0,
1200
1260
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1201
- predicateLength: predicate.length,
1202
- predicateDataLength: predicateData.length,
1261
+ predicateLength: (0, import_math2.bn)(predicate.length),
1262
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1203
1263
  predicate: (0, import_utils3.hexlify)(predicate),
1204
1264
  predicateData: (0, import_utils3.hexlify)(predicateData)
1205
1265
  };
@@ -1230,8 +1290,8 @@ var inputify = (value) => {
1230
1290
  nonce: (0, import_utils3.hexlify)(value.nonce),
1231
1291
  witnessIndex: value.witnessIndex,
1232
1292
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1233
- predicateLength: predicate.length,
1234
- predicateDataLength: predicateData.length,
1293
+ predicateLength: (0, import_math2.bn)(predicate.length),
1294
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1235
1295
  predicate: (0, import_utils3.hexlify)(predicate),
1236
1296
  predicateData: (0, import_utils3.hexlify)(predicateData),
1237
1297
  data: (0, import_utils3.hexlify)(data),
@@ -1310,6 +1370,7 @@ var import_configs7 = require("@fuel-ts/address/configs");
1310
1370
  var import_math7 = require("@fuel-ts/math");
1311
1371
  var import_transactions6 = require("@fuel-ts/transactions");
1312
1372
  var import_utils9 = require("@fuel-ts/utils");
1373
+ var import_ethers = require("ethers");
1313
1374
 
1314
1375
  // src/providers/resource.ts
1315
1376
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -1348,8 +1409,8 @@ function assembleReceiptByType(receipt) {
1348
1409
  case "CALL" /* Call */: {
1349
1410
  const callReceipt = {
1350
1411
  type: import_transactions3.ReceiptType.Call,
1351
- from: hexOrZero(receipt.contract?.id),
1352
- to: hexOrZero(receipt?.to?.id),
1412
+ from: hexOrZero(receipt.id || receipt.contractId),
1413
+ to: hexOrZero(receipt?.to),
1353
1414
  amount: (0, import_math4.bn)(receipt.amount),
1354
1415
  assetId: hexOrZero(receipt.assetId),
1355
1416
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1363,7 +1424,7 @@ function assembleReceiptByType(receipt) {
1363
1424
  case "RETURN" /* Return */: {
1364
1425
  const returnReceipt = {
1365
1426
  type: import_transactions3.ReceiptType.Return,
1366
- id: hexOrZero(receipt.contract?.id),
1427
+ id: hexOrZero(receipt.id || receipt.contractId),
1367
1428
  val: (0, import_math4.bn)(receipt.val),
1368
1429
  pc: (0, import_math4.bn)(receipt.pc),
1369
1430
  is: (0, import_math4.bn)(receipt.is)
@@ -1373,7 +1434,7 @@ function assembleReceiptByType(receipt) {
1373
1434
  case "RETURN_DATA" /* ReturnData */: {
1374
1435
  const returnDataReceipt = {
1375
1436
  type: import_transactions3.ReceiptType.ReturnData,
1376
- id: hexOrZero(receipt.contract?.id),
1437
+ id: hexOrZero(receipt.id || receipt.contractId),
1377
1438
  ptr: (0, import_math4.bn)(receipt.ptr),
1378
1439
  len: (0, import_math4.bn)(receipt.len),
1379
1440
  digest: hexOrZero(receipt.digest),
@@ -1385,7 +1446,7 @@ function assembleReceiptByType(receipt) {
1385
1446
  case "PANIC" /* Panic */: {
1386
1447
  const panicReceipt = {
1387
1448
  type: import_transactions3.ReceiptType.Panic,
1388
- id: hexOrZero(receipt.contract?.id),
1449
+ id: hexOrZero(receipt.id),
1389
1450
  reason: (0, import_math4.bn)(receipt.reason),
1390
1451
  pc: (0, import_math4.bn)(receipt.pc),
1391
1452
  is: (0, import_math4.bn)(receipt.is),
@@ -1396,7 +1457,7 @@ function assembleReceiptByType(receipt) {
1396
1457
  case "REVERT" /* Revert */: {
1397
1458
  const revertReceipt = {
1398
1459
  type: import_transactions3.ReceiptType.Revert,
1399
- id: hexOrZero(receipt.contract?.id),
1460
+ id: hexOrZero(receipt.id || receipt.contractId),
1400
1461
  val: (0, import_math4.bn)(receipt.ra),
1401
1462
  pc: (0, import_math4.bn)(receipt.pc),
1402
1463
  is: (0, import_math4.bn)(receipt.is)
@@ -1406,7 +1467,7 @@ function assembleReceiptByType(receipt) {
1406
1467
  case "LOG" /* Log */: {
1407
1468
  const logReceipt = {
1408
1469
  type: import_transactions3.ReceiptType.Log,
1409
- id: hexOrZero(receipt.contract?.id),
1470
+ id: hexOrZero(receipt.id || receipt.contractId),
1410
1471
  val0: (0, import_math4.bn)(receipt.ra),
1411
1472
  val1: (0, import_math4.bn)(receipt.rb),
1412
1473
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1419,7 +1480,7 @@ function assembleReceiptByType(receipt) {
1419
1480
  case "LOG_DATA" /* LogData */: {
1420
1481
  const logDataReceipt = {
1421
1482
  type: import_transactions3.ReceiptType.LogData,
1422
- id: hexOrZero(receipt.contract?.id),
1483
+ id: hexOrZero(receipt.id || receipt.contractId),
1423
1484
  val0: (0, import_math4.bn)(receipt.ra),
1424
1485
  val1: (0, import_math4.bn)(receipt.rb),
1425
1486
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1433,8 +1494,8 @@ function assembleReceiptByType(receipt) {
1433
1494
  case "TRANSFER" /* Transfer */: {
1434
1495
  const transferReceipt = {
1435
1496
  type: import_transactions3.ReceiptType.Transfer,
1436
- from: hexOrZero(receipt.contract?.id),
1437
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1497
+ from: hexOrZero(receipt.id || receipt.contractId),
1498
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1438
1499
  amount: (0, import_math4.bn)(receipt.amount),
1439
1500
  assetId: hexOrZero(receipt.assetId),
1440
1501
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1445,8 +1506,8 @@ function assembleReceiptByType(receipt) {
1445
1506
  case "TRANSFER_OUT" /* TransferOut */: {
1446
1507
  const transferOutReceipt = {
1447
1508
  type: import_transactions3.ReceiptType.TransferOut,
1448
- from: hexOrZero(receipt.contract?.id),
1449
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1509
+ from: hexOrZero(receipt.id || receipt.contractId),
1510
+ to: hexOrZero(receipt.toAddress || receipt.to),
1450
1511
  amount: (0, import_math4.bn)(receipt.amount),
1451
1512
  assetId: hexOrZero(receipt.assetId),
1452
1513
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1489,7 +1550,7 @@ function assembleReceiptByType(receipt) {
1489
1550
  return receiptMessageOut;
1490
1551
  }
1491
1552
  case "MINT" /* Mint */: {
1492
- const contractId = hexOrZero(receipt.contract?.id);
1553
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1493
1554
  const subId = hexOrZero(receipt.subId);
1494
1555
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1495
1556
  const mintReceipt = {
@@ -1504,7 +1565,7 @@ function assembleReceiptByType(receipt) {
1504
1565
  return mintReceipt;
1505
1566
  }
1506
1567
  case "BURN" /* Burn */: {
1507
- const contractId = hexOrZero(receipt.contract?.id);
1568
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1508
1569
  const subId = hexOrZero(receipt.subId);
1509
1570
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1510
1571
  const burnReceipt = {
@@ -1589,7 +1650,6 @@ var buildBlockExplorerUrl = (options = {}) => {
1589
1650
  var import_math5 = require("@fuel-ts/math");
1590
1651
  var import_transactions4 = require("@fuel-ts/transactions");
1591
1652
  var import_utils6 = require("@fuel-ts/utils");
1592
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1593
1653
  var getGasUsedFromReceipts = (receipts) => {
1594
1654
  const scriptResult = receipts.filter(
1595
1655
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1610,18 +1670,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1610
1670
  }
1611
1671
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1612
1672
  const witnessCache = [];
1613
- const totalGas = inputs.reduce((total, input) => {
1673
+ const chargeableInputs = inputs.filter((input) => {
1674
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1675
+ if (isCoinOrMessage) {
1676
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1677
+ return true;
1678
+ }
1679
+ if (!witnessCache.includes(input.witnessIndex)) {
1680
+ witnessCache.push(input.witnessIndex);
1681
+ return true;
1682
+ }
1683
+ }
1684
+ return false;
1685
+ });
1686
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1687
+ const totalGas = chargeableInputs.reduce((total, input) => {
1614
1688
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1615
1689
  return total.add(
1616
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1690
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1617
1691
  );
1618
1692
  }
1619
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1620
- witnessCache.push(input.witnessIndex);
1621
- return total.add(gasCosts.ecr1);
1622
- }
1623
- return total;
1624
- }, (0, import_math5.bn)());
1693
+ return total.add(gasCosts.ecr1);
1694
+ }, (0, import_math5.bn)(0));
1625
1695
  return totalGas;
1626
1696
  }
1627
1697
  function getMinGas(params) {
@@ -1633,12 +1703,20 @@ function getMinGas(params) {
1633
1703
  return minGas;
1634
1704
  }
1635
1705
  function getMaxGas(params) {
1636
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1706
+ const {
1707
+ gasPerByte,
1708
+ witnessesLength,
1709
+ witnessLimit,
1710
+ minGas,
1711
+ gasLimit = (0, import_math5.bn)(0),
1712
+ maxGasPerTx
1713
+ } = params;
1637
1714
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1638
1715
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1639
1716
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1640
1717
  }
1641
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1718
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1719
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1642
1720
  }
1643
1721
  function calculateMetadataGasForTxCreate({
1644
1722
  gasCosts,
@@ -1660,6 +1738,10 @@ function calculateMetadataGasForTxScript({
1660
1738
  }) {
1661
1739
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1662
1740
  }
1741
+ var calculateGasFee = (params) => {
1742
+ const { gas, gasPrice, priceFactor, tip } = params;
1743
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1744
+ };
1663
1745
 
1664
1746
  // src/providers/utils/json.ts
1665
1747
  var import_utils7 = require("@fuel-ts/utils");
@@ -1808,7 +1890,7 @@ var witnessify = (value) => {
1808
1890
  // src/providers/transaction-request/transaction-request.ts
1809
1891
  var BaseTransactionRequest = class {
1810
1892
  /** Gas price for transaction */
1811
- gasPrice;
1893
+ tip;
1812
1894
  /** Block until which tx cannot be included */
1813
1895
  maturity;
1814
1896
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1827,7 +1909,7 @@ var BaseTransactionRequest = class {
1827
1909
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1828
1910
  */
1829
1911
  constructor({
1830
- gasPrice,
1912
+ tip,
1831
1913
  maturity,
1832
1914
  maxFee,
1833
1915
  witnessLimit,
@@ -1835,7 +1917,7 @@ var BaseTransactionRequest = class {
1835
1917
  outputs,
1836
1918
  witnesses
1837
1919
  } = {}) {
1838
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1920
+ this.tip = (0, import_math7.bn)(tip);
1839
1921
  this.maturity = maturity ?? 0;
1840
1922
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1841
1923
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1846,9 +1928,9 @@ var BaseTransactionRequest = class {
1846
1928
  static getPolicyMeta(req) {
1847
1929
  let policyTypes = 0;
1848
1930
  const policies = [];
1849
- if (req.gasPrice) {
1850
- policyTypes += import_transactions6.PolicyType.GasPrice;
1851
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1931
+ if (req.tip) {
1932
+ policyTypes += import_transactions6.PolicyType.Tip;
1933
+ policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1852
1934
  }
1853
1935
  if (req.witnessLimit) {
1854
1936
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -2036,9 +2118,9 @@ var BaseTransactionRequest = class {
2036
2118
  * @param predicateData - Predicate data bytes.
2037
2119
  */
2038
2120
  addCoinInput(coin) {
2039
- const { assetId, owner, amount, id, predicate } = coin;
2121
+ const { assetId, owner, amount } = coin;
2040
2122
  let witnessIndex;
2041
- if (predicate) {
2123
+ if (coin.predicate) {
2042
2124
  witnessIndex = 0;
2043
2125
  } else {
2044
2126
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -2047,14 +2129,13 @@ var BaseTransactionRequest = class {
2047
2129
  }
2048
2130
  }
2049
2131
  const input = {
2050
- id,
2132
+ ...coin,
2051
2133
  type: import_transactions6.InputType.Coin,
2052
2134
  owner: owner.toB256(),
2053
2135
  amount,
2054
2136
  assetId,
2055
2137
  txPointer: "0x00000000000000000000000000000000",
2056
- witnessIndex,
2057
- predicate
2138
+ witnessIndex
2058
2139
  };
2059
2140
  this.pushInput(input);
2060
2141
  this.addChangeOutput(owner, assetId);
@@ -2068,10 +2149,10 @@ var BaseTransactionRequest = class {
2068
2149
  * @param predicateData - Predicate data bytes.
2069
2150
  */
2070
2151
  addMessageInput(message) {
2071
- const { recipient, sender, amount, predicate, nonce } = message;
2152
+ const { recipient, sender, amount } = message;
2072
2153
  const assetId = import_configs7.BaseAssetId;
2073
2154
  let witnessIndex;
2074
- if (predicate) {
2155
+ if (message.predicate) {
2075
2156
  witnessIndex = 0;
2076
2157
  } else {
2077
2158
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2080,13 +2161,12 @@ var BaseTransactionRequest = class {
2080
2161
  }
2081
2162
  }
2082
2163
  const input = {
2083
- nonce,
2164
+ ...message,
2084
2165
  type: import_transactions6.InputType.Message,
2085
2166
  sender: sender.toB256(),
2086
2167
  recipient: recipient.toB256(),
2087
2168
  amount,
2088
- witnessIndex,
2089
- predicate
2169
+ witnessIndex
2090
2170
  };
2091
2171
  this.pushInput(input);
2092
2172
  this.addChangeOutput(recipient, assetId);
@@ -2196,7 +2276,7 @@ var BaseTransactionRequest = class {
2196
2276
  }
2197
2277
  calculateMaxGas(chainInfo, minGas) {
2198
2278
  const { consensusParameters } = chainInfo;
2199
- const { gasPerByte } = consensusParameters;
2279
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2200
2280
  const witnessesLength = this.toTransaction().witnesses.reduce(
2201
2281
  (acc, wit) => acc + wit.dataLength,
2202
2282
  0
@@ -2205,7 +2285,8 @@ var BaseTransactionRequest = class {
2205
2285
  gasPerByte,
2206
2286
  minGas,
2207
2287
  witnessesLength,
2208
- witnessLimit: this.witnessLimit
2288
+ witnessLimit: this.witnessLimit,
2289
+ maxGasPerTx
2209
2290
  });
2210
2291
  }
2211
2292
  /**
@@ -2215,12 +2296,6 @@ var BaseTransactionRequest = class {
2215
2296
  * @param quantities - CoinQuantity Array.
2216
2297
  */
2217
2298
  fundWithFakeUtxos(quantities, resourcesOwner) {
2218
- let idCounter = 0;
2219
- const generateId = () => {
2220
- const counterString = String(idCounter++);
2221
- const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2222
- return id;
2223
- };
2224
2299
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2225
2300
  if ("assetId" in input) {
2226
2301
  return input.assetId === assetId;
@@ -2229,17 +2304,20 @@ var BaseTransactionRequest = class {
2229
2304
  });
2230
2305
  const updateAssetInput = (assetId, quantity) => {
2231
2306
  const assetInput = findAssetInput(assetId);
2307
+ let usedQuantity = quantity;
2308
+ if (assetId === import_configs7.BaseAssetId) {
2309
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2310
+ }
2232
2311
  if (assetInput && "assetId" in assetInput) {
2233
- assetInput.id = generateId();
2234
- assetInput.amount = quantity;
2312
+ assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
2313
+ assetInput.amount = usedQuantity;
2235
2314
  } else {
2236
2315
  this.addResources([
2237
2316
  {
2238
- id: generateId(),
2239
- amount: quantity,
2317
+ id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
2318
+ amount: usedQuantity,
2240
2319
  assetId,
2241
2320
  owner: resourcesOwner || import_address.Address.fromRandom(),
2242
- maturity: 0,
2243
2321
  blockCreated: (0, import_math7.bn)(1),
2244
2322
  txCreatedIdx: (0, import_math7.bn)(1)
2245
2323
  }
@@ -2271,7 +2349,7 @@ var BaseTransactionRequest = class {
2271
2349
  toJSON() {
2272
2350
  return normalizeJSON(this);
2273
2351
  }
2274
- updatePredicateInputs(inputs) {
2352
+ updatePredicateGasUsed(inputs) {
2275
2353
  this.inputs.forEach((i) => {
2276
2354
  let correspondingInput;
2277
2355
  switch (i.type) {
@@ -2293,6 +2371,15 @@ var BaseTransactionRequest = class {
2293
2371
  }
2294
2372
  });
2295
2373
  }
2374
+ shiftPredicateData() {
2375
+ this.inputs.forEach((input) => {
2376
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2377
+ input.predicateData = input.paddPredicateData(
2378
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2379
+ );
2380
+ }
2381
+ });
2382
+ }
2296
2383
  };
2297
2384
 
2298
2385
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2439,9 +2526,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2439
2526
  return {
2440
2527
  type: import_transactions8.TransactionType.Create,
2441
2528
  ...baseTransaction,
2442
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2443
2529
  bytecodeWitnessIndex,
2444
- storageSlotsCount: storageSlots.length,
2530
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2445
2531
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2446
2532
  storageSlots
2447
2533
  };
@@ -2564,8 +2650,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2564
2650
  type: import_transactions9.TransactionType.Script,
2565
2651
  scriptGasLimit: this.gasLimit,
2566
2652
  ...super.getBaseTransaction(),
2567
- scriptLength: script.length,
2568
- scriptDataLength: scriptData.length,
2653
+ scriptLength: (0, import_math10.bn)(script.length),
2654
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2569
2655
  receiptsRoot: import_configs10.ZeroBytes32,
2570
2656
  script: (0, import_utils15.hexlify)(script),
2571
2657
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2629,7 +2715,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2629
2715
  }
2630
2716
  calculateMaxGas(chainInfo, minGas) {
2631
2717
  const { consensusParameters } = chainInfo;
2632
- const { gasPerByte } = consensusParameters;
2718
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2633
2719
  const witnessesLength = this.toTransaction().witnesses.reduce(
2634
2720
  (acc, wit) => acc + wit.dataLength,
2635
2721
  0
@@ -2639,7 +2725,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2639
2725
  minGas,
2640
2726
  witnessesLength,
2641
2727
  witnessLimit: this.witnessLimit,
2642
- gasLimit: this.gasLimit
2728
+ gasLimit: this.gasLimit,
2729
+ maxGasPerTx
2643
2730
  });
2644
2731
  }
2645
2732
  /**
@@ -2714,15 +2801,32 @@ var transactionRequestify = (obj) => {
2714
2801
  }
2715
2802
  }
2716
2803
  };
2804
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2805
+ (acc, input) => {
2806
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2807
+ acc.utxos.push(input.id);
2808
+ }
2809
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2810
+ acc.messages.push(input.nonce);
2811
+ }
2812
+ return acc;
2813
+ },
2814
+ {
2815
+ utxos: [],
2816
+ messages: []
2817
+ }
2818
+ );
2717
2819
 
2718
2820
  // src/providers/transaction-response/transaction-response.ts
2719
2821
  var import_errors13 = require("@fuel-ts/errors");
2720
- var import_math14 = require("@fuel-ts/math");
2721
- var import_transactions17 = require("@fuel-ts/transactions");
2722
- var import_utils21 = require("@fuel-ts/utils");
2822
+ var import_math15 = require("@fuel-ts/math");
2823
+ var import_transactions18 = require("@fuel-ts/transactions");
2824
+ var import_utils20 = require("@fuel-ts/utils");
2723
2825
 
2724
2826
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2725
- var import_utils19 = require("@fuel-ts/utils");
2827
+ var import_math14 = require("@fuel-ts/math");
2828
+ var import_transactions16 = require("@fuel-ts/transactions");
2829
+ var import_utils18 = require("@fuel-ts/utils");
2726
2830
 
2727
2831
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2728
2832
  var import_math11 = require("@fuel-ts/math");
@@ -2730,9 +2834,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
2730
2834
  var import_utils16 = require("@fuel-ts/utils");
2731
2835
  var calculateTransactionFee = (params) => {
2732
2836
  const {
2733
- gasUsed,
2837
+ gasPrice,
2734
2838
  rawPayload,
2735
- consensusParameters: { gasCosts, feeParams }
2839
+ tip,
2840
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2736
2841
  } = params;
2737
2842
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2738
2843
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2742,8 +2847,7 @@ var calculateTransactionFee = (params) => {
2742
2847
  return {
2743
2848
  fee: (0, import_math11.bn)(0),
2744
2849
  minFee: (0, import_math11.bn)(0),
2745
- maxFee: (0, import_math11.bn)(0),
2746
- feeFromGasUsed: (0, import_math11.bn)(0)
2850
+ maxFee: (0, import_math11.bn)(0)
2747
2851
  };
2748
2852
  }
2749
2853
  const { type, witnesses, inputs, policies } = transaction;
@@ -2775,7 +2879,6 @@ var calculateTransactionFee = (params) => {
2775
2879
  metadataGas,
2776
2880
  txBytesSize: transactionBytes.length
2777
2881
  });
2778
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2779
2882
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2780
2883
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2781
2884
  const maxGas = getMaxGas({
@@ -2783,17 +2886,25 @@ var calculateTransactionFee = (params) => {
2783
2886
  minGas,
2784
2887
  witnessesLength,
2785
2888
  gasLimit,
2786
- witnessLimit
2889
+ witnessLimit,
2890
+ maxGasPerTx
2891
+ });
2892
+ const minFee = calculateGasFee({
2893
+ gasPrice,
2894
+ gas: minGas,
2895
+ priceFactor: gasPriceFactor,
2896
+ tip
2897
+ });
2898
+ const maxFee = calculateGasFee({
2899
+ gasPrice,
2900
+ gas: maxGas,
2901
+ priceFactor: gasPriceFactor,
2902
+ tip
2787
2903
  });
2788
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2789
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2790
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2791
- const fee = minFee.add(feeFromGasUsed);
2792
2904
  return {
2793
- fee,
2794
2905
  minFee,
2795
2906
  maxFee,
2796
- feeFromGasUsed
2907
+ fee: maxFee
2797
2908
  };
2798
2909
  };
2799
2910
 
@@ -3407,10 +3518,12 @@ function assembleTransactionSummary(params) {
3407
3518
  gqlTransactionStatus,
3408
3519
  abiMap = {},
3409
3520
  maxInputs,
3410
- gasCosts
3521
+ gasCosts,
3522
+ maxGasPerTx,
3523
+ gasPrice
3411
3524
  } = params;
3412
3525
  const gasUsed = getGasUsedFromReceipts(receipts);
3413
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3526
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3414
3527
  const operations = getOperations({
3415
3528
  transactionType: transaction.type,
3416
3529
  inputs: transaction.inputs || [],
@@ -3421,11 +3534,14 @@ function assembleTransactionSummary(params) {
3421
3534
  maxInputs
3422
3535
  });
3423
3536
  const typeName = getTransactionTypeName(transaction.type);
3537
+ const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3424
3538
  const { fee } = calculateTransactionFee({
3425
- gasUsed,
3539
+ gasPrice,
3426
3540
  rawPayload,
3541
+ tip,
3427
3542
  consensusParameters: {
3428
3543
  gasCosts,
3544
+ maxGasPerTx,
3429
3545
  feeParams: {
3430
3546
  gasPerByte,
3431
3547
  gasPriceFactor
@@ -3437,7 +3553,7 @@ function assembleTransactionSummary(params) {
3437
3553
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3438
3554
  let date;
3439
3555
  if (time) {
3440
- date = import_utils19.DateTime.fromTai64(time);
3556
+ date = import_utils18.DateTime.fromTai64(time);
3441
3557
  }
3442
3558
  const transactionSummary = {
3443
3559
  id,
@@ -3465,12 +3581,12 @@ function assembleTransactionSummary(params) {
3465
3581
 
3466
3582
  // src/providers/transaction-response/getDecodedLogs.ts
3467
3583
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
3468
- var import_transactions16 = require("@fuel-ts/transactions");
3584
+ var import_transactions17 = require("@fuel-ts/transactions");
3469
3585
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3470
3586
  return receipts.reduce((logs, receipt) => {
3471
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3587
+ if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3472
3588
  const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3473
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3589
+ const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3474
3590
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3475
3591
  logs.push(decodedLog);
3476
3592
  }
@@ -3485,7 +3601,7 @@ var TransactionResponse = class {
3485
3601
  /** Current provider */
3486
3602
  provider;
3487
3603
  /** Gas used on the transaction */
3488
- gasUsed = (0, import_math14.bn)(0);
3604
+ gasUsed = (0, import_math15.bn)(0);
3489
3605
  /** The graphql Transaction with receipts object. */
3490
3606
  gqlTransaction;
3491
3607
  abis;
@@ -3543,8 +3659,8 @@ var TransactionResponse = class {
3543
3659
  * @returns The decoded transaction.
3544
3660
  */
3545
3661
  decodeTransaction(transactionWithReceipts) {
3546
- return new import_transactions17.TransactionCoder().decode(
3547
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3662
+ return new import_transactions18.TransactionCoder().decode(
3663
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3548
3664
  0
3549
3665
  )?.[0];
3550
3666
  }
@@ -3563,20 +3679,27 @@ var TransactionResponse = class {
3563
3679
  const decodedTransaction = this.decodeTransaction(
3564
3680
  transaction
3565
3681
  );
3566
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3567
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3682
+ let txReceipts = [];
3683
+ if (transaction?.status && "receipts" in transaction.status) {
3684
+ txReceipts = transaction.status.receipts;
3685
+ }
3686
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3687
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3688
+ const gasPrice = await this.provider.getLatestGasPrice();
3568
3689
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3569
3690
  const transactionSummary = assembleTransactionSummary({
3570
3691
  id: this.id,
3571
3692
  receipts,
3572
3693
  transaction: decodedTransaction,
3573
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3694
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3574
3695
  gqlTransactionStatus: transaction.status,
3575
3696
  gasPerByte,
3576
3697
  gasPriceFactor,
3577
3698
  abiMap: contractsAbiMap,
3578
3699
  maxInputs,
3579
- gasCosts
3700
+ gasCosts,
3701
+ maxGasPerTx,
3702
+ gasPrice
3580
3703
  });
3581
3704
  return transactionSummary;
3582
3705
  }
@@ -3703,29 +3826,29 @@ var processGqlChain = (chain) => {
3703
3826
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3704
3827
  return {
3705
3828
  name,
3706
- baseChainHeight: (0, import_math15.bn)(daHeight),
3829
+ baseChainHeight: (0, import_math16.bn)(daHeight),
3707
3830
  consensusParameters: {
3708
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3709
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3710
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3711
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3712
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3713
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3714
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3715
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3716
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3717
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3718
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3719
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3720
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3721
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3722
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3831
+ contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3832
+ maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3833
+ maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3834
+ maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3835
+ maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3836
+ maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3837
+ maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3838
+ maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3839
+ maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3840
+ maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3841
+ maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3842
+ gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3843
+ gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3844
+ maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3845
+ chainId: (0, import_math16.bn)(consensusParameters.chainId),
3723
3846
  gasCosts
3724
3847
  },
3725
3848
  gasCosts,
3726
3849
  latestBlock: {
3727
3850
  id: latestBlock.id,
3728
- height: (0, import_math15.bn)(latestBlock.header.height),
3851
+ height: (0, import_math16.bn)(latestBlock.height),
3729
3852
  time: latestBlock.header.time,
3730
3853
  transactions: latestBlock.transactions.map((i) => ({
3731
3854
  id: i.id
@@ -3819,10 +3942,8 @@ var _Provider = class {
3819
3942
  * Returns some helpful parameters related to gas fees.
3820
3943
  */
3821
3944
  getGasConfig() {
3822
- const { minGasPrice } = this.getNode();
3823
3945
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3824
3946
  return {
3825
- minGasPrice,
3826
3947
  maxGasPerTx,
3827
3948
  maxGasPerPredicate,
3828
3949
  gasPriceFactor,
@@ -3910,7 +4031,7 @@ var _Provider = class {
3910
4031
  name,
3911
4032
  consensusParameters: { chainId }
3912
4033
  } = await this.getChain();
3913
- const network = new import_ethers.Network(name, chainId.toNumber());
4034
+ const network = new import_ethers2.Network(name, chainId.toNumber());
3914
4035
  return Promise.resolve(network);
3915
4036
  }
3916
4037
  /**
@@ -3920,7 +4041,7 @@ var _Provider = class {
3920
4041
  */
3921
4042
  async getBlockNumber() {
3922
4043
  const { chain } = await this.operations.getChain();
3923
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
4044
+ return (0, import_math16.bn)(chain.latestBlock.height, 10);
3924
4045
  }
3925
4046
  /**
3926
4047
  * Returns the chain information.
@@ -3930,13 +4051,11 @@ var _Provider = class {
3930
4051
  async fetchNode() {
3931
4052
  const { nodeInfo } = await this.operations.getNodeInfo();
3932
4053
  const processedNodeInfo = {
3933
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3934
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3935
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
4054
+ maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4055
+ maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3936
4056
  nodeVersion: nodeInfo.nodeVersion,
3937
4057
  utxoValidation: nodeInfo.utxoValidation,
3938
- vmBacktrace: nodeInfo.vmBacktrace,
3939
- peers: nodeInfo.peers
4058
+ vmBacktrace: nodeInfo.vmBacktrace
3940
4059
  };
3941
4060
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3942
4061
  return processedNodeInfo;
@@ -3978,9 +4097,9 @@ var _Provider = class {
3978
4097
  if (estimateTxDependencies) {
3979
4098
  await this.estimateTxDependencies(transactionRequest);
3980
4099
  }
3981
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4100
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3982
4101
  let abis;
3983
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4102
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3984
4103
  abis = transactionRequest.abis;
3985
4104
  }
3986
4105
  if (awaitExecution) {
@@ -4021,15 +4140,14 @@ var _Provider = class {
4021
4140
  if (estimateTxDependencies) {
4022
4141
  return this.estimateTxDependencies(transactionRequest);
4023
4142
  }
4024
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4025
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4026
- encodedTransaction,
4143
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4144
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4145
+ encodedTransactions: encodedTransaction,
4027
4146
  utxoValidation: utxoValidation || false
4028
4147
  });
4029
- const receipts = gqlReceipts.map(processGqlReceipt);
4030
- return {
4031
- receipts
4032
- };
4148
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4149
+ const receipts = rawReceipts.map(processGqlReceipt);
4150
+ return { receipts, dryrunStatus: status };
4033
4151
  }
4034
4152
  /**
4035
4153
  * Verifies whether enough gas is available to complete transaction.
@@ -4040,13 +4158,13 @@ var _Provider = class {
4040
4158
  async estimatePredicates(transactionRequest) {
4041
4159
  const shouldEstimatePredicates = Boolean(
4042
4160
  transactionRequest.inputs.find(
4043
- (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()
4161
+ (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()
4044
4162
  )
4045
4163
  );
4046
4164
  if (!shouldEstimatePredicates) {
4047
4165
  return transactionRequest;
4048
4166
  }
4049
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4167
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4050
4168
  const response = await this.operations.estimatePredicates({
4051
4169
  encodedTransaction
4052
4170
  });
@@ -4055,7 +4173,7 @@ var _Provider = class {
4055
4173
  } = response;
4056
4174
  if (inputs) {
4057
4175
  inputs.forEach((input, index) => {
4058
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4176
+ if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4059
4177
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4060
4178
  }
4061
4179
  });
@@ -4068,31 +4186,31 @@ var _Provider = class {
4068
4186
  * If there are missing variable outputs,
4069
4187
  * `addVariableOutputs` is called on the transaction.
4070
4188
  *
4071
- * @privateRemarks
4072
- * TODO: Investigate support for missing contract IDs
4073
- * TODO: Add support for missing output messages
4074
4189
  *
4075
4190
  * @param transactionRequest - The transaction request object.
4076
4191
  * @returns A promise.
4077
4192
  */
4078
4193
  async estimateTxDependencies(transactionRequest) {
4079
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4194
+ if (transactionRequest.type === import_transactions19.TransactionType.Create) {
4080
4195
  return {
4081
4196
  receipts: [],
4082
4197
  outputVariables: 0,
4083
4198
  missingContractIds: []
4084
4199
  };
4085
4200
  }
4086
- await this.estimatePredicates(transactionRequest);
4087
4201
  let receipts = [];
4088
4202
  const missingContractIds = [];
4089
4203
  let outputVariables = 0;
4204
+ let dryrunStatus;
4090
4205
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4091
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4092
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4206
+ const {
4207
+ dryRun: [{ receipts: rawReceipts, status }]
4208
+ } = await this.operations.dryRun({
4209
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4093
4210
  utxoValidation: false
4094
4211
  });
4095
- receipts = gqlReceipts.map(processGqlReceipt);
4212
+ receipts = rawReceipts.map(processGqlReceipt);
4213
+ dryrunStatus = status;
4096
4214
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4097
4215
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4098
4216
  if (hasMissingOutputs) {
@@ -4102,6 +4220,11 @@ var _Provider = class {
4102
4220
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4103
4221
  missingContractIds.push(contractId);
4104
4222
  });
4223
+ const { maxFee } = await this.estimateTxGasAndFee({
4224
+ transactionRequest,
4225
+ optimizeGas: false
4226
+ });
4227
+ transactionRequest.maxFee = maxFee;
4105
4228
  } else {
4106
4229
  break;
4107
4230
  }
@@ -4109,7 +4232,133 @@ var _Provider = class {
4109
4232
  return {
4110
4233
  receipts,
4111
4234
  outputVariables,
4112
- missingContractIds
4235
+ missingContractIds,
4236
+ dryrunStatus
4237
+ };
4238
+ }
4239
+ /**
4240
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4241
+ *
4242
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4243
+ * further modifications are identified. The method iteratively updates these transactions
4244
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4245
+ *
4246
+ * @param transactionRequests - Array of transaction request objects.
4247
+ * @returns A promise that resolves to an array of results for each transaction.
4248
+ */
4249
+ async estimateMultipleTxDependencies(transactionRequests) {
4250
+ const results = transactionRequests.map(() => ({
4251
+ receipts: [],
4252
+ outputVariables: 0,
4253
+ missingContractIds: [],
4254
+ dryrunStatus: void 0
4255
+ }));
4256
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4257
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4258
+ allRequests.forEach((req, index) => {
4259
+ if (req.type === import_transactions19.TransactionType.Script) {
4260
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4261
+ }
4262
+ });
4263
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4264
+ let attempt = 0;
4265
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4266
+ const encodedTransactions = transactionsToProcess.map(
4267
+ (index) => serializedTransactionsMap.get(index)
4268
+ );
4269
+ const dryRunResults = await this.operations.dryRun({
4270
+ encodedTransactions,
4271
+ utxoValidation: false
4272
+ });
4273
+ const nextRoundTransactions = [];
4274
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4275
+ const currentResultIndex = transactionsToProcess[i];
4276
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4277
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4278
+ results[currentResultIndex].dryrunStatus = status;
4279
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4280
+ results[currentResultIndex].receipts
4281
+ );
4282
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4283
+ const requestToProcess = allRequests[currentResultIndex];
4284
+ if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4285
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
4286
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
4287
+ missingOutputContractIds.forEach(({ contractId }) => {
4288
+ requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4289
+ results[currentResultIndex].missingContractIds.push(contractId);
4290
+ });
4291
+ const { maxFee } = await this.estimateTxGasAndFee({
4292
+ transactionRequest: requestToProcess,
4293
+ optimizeGas: false
4294
+ });
4295
+ requestToProcess.maxFee = maxFee;
4296
+ serializedTransactionsMap.set(
4297
+ currentResultIndex,
4298
+ (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4299
+ );
4300
+ nextRoundTransactions.push(currentResultIndex);
4301
+ allRequests[currentResultIndex] = requestToProcess;
4302
+ }
4303
+ }
4304
+ transactionsToProcess = nextRoundTransactions;
4305
+ attempt += 1;
4306
+ }
4307
+ return results;
4308
+ }
4309
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4310
+ if (estimateTxDependencies) {
4311
+ return this.estimateMultipleTxDependencies(transactionRequests);
4312
+ }
4313
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4314
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4315
+ encodedTransactions,
4316
+ utxoValidation: utxoValidation || false
4317
+ });
4318
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4319
+ const receipts = rawReceipts.map(processGqlReceipt);
4320
+ return { receipts, dryrunStatus: status };
4321
+ });
4322
+ return results;
4323
+ }
4324
+ async estimateTxGasAndFee(params) {
4325
+ const { transactionRequest, optimizeGas = true } = params;
4326
+ let { gasPrice } = params;
4327
+ const chainInfo = this.getChain();
4328
+ const { gasPriceFactor } = this.getGasConfig();
4329
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4330
+ if (!gasPrice) {
4331
+ gasPrice = await this.estimateGasPrice(10);
4332
+ }
4333
+ const minFee = calculateGasFee({
4334
+ gasPrice: (0, import_math16.bn)(gasPrice),
4335
+ gas: minGas,
4336
+ priceFactor: gasPriceFactor,
4337
+ tip: transactionRequest.tip
4338
+ }).add(1);
4339
+ let gasLimit = (0, import_math16.bn)(0);
4340
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4341
+ gasLimit = transactionRequest.gasLimit;
4342
+ if (!optimizeGas) {
4343
+ transactionRequest.gasLimit = minGas;
4344
+ gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
4345
+ transactionRequest.gasLimit = gasLimit;
4346
+ }
4347
+ }
4348
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4349
+ const maxFee = calculateGasFee({
4350
+ gasPrice: (0, import_math16.bn)(gasPrice),
4351
+ gas: maxGas,
4352
+ priceFactor: gasPriceFactor,
4353
+ tip: transactionRequest.tip
4354
+ }).add(1);
4355
+ return {
4356
+ minGas,
4357
+ minFee,
4358
+ maxGas,
4359
+ maxFee,
4360
+ gasPrice,
4361
+ gasLimit
4113
4362
  };
4114
4363
  }
4115
4364
  /**
@@ -4127,15 +4376,17 @@ var _Provider = class {
4127
4376
  if (estimateTxDependencies) {
4128
4377
  return this.estimateTxDependencies(transactionRequest);
4129
4378
  }
4130
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4131
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
4132
- encodedTransaction,
4379
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4380
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4381
+ encodedTransactions,
4133
4382
  utxoValidation: true
4134
4383
  });
4135
- const receipts = gqlReceipts.map(processGqlReceipt);
4136
- return {
4137
- receipts
4138
- };
4384
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4385
+ const { id, receipts, status } = dryRunStatus;
4386
+ const processedReceipts = receipts.map(processGqlReceipt);
4387
+ return { id, receipts: processedReceipts, status };
4388
+ });
4389
+ return { receipts: callResult[0].receipts };
4139
4390
  }
4140
4391
  /**
4141
4392
  * Returns a transaction cost to enable user
@@ -4152,80 +4403,80 @@ var _Provider = class {
4152
4403
  * @param tolerance - The tolerance to add on top of the gasUsed.
4153
4404
  * @returns A promise that resolves to the transaction cost object.
4154
4405
  */
4155
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4156
- estimateTxDependencies = true,
4157
- estimatePredicates = true,
4158
- resourcesOwner,
4159
- signatureCallback
4160
- } = {}) {
4406
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4161
4407
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4162
- const chainInfo = this.getChain();
4163
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4164
- const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4165
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4408
+ const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
4166
4409
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4167
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4410
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4168
4411
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4169
- if (estimatePredicates) {
4170
- if (isScriptTransaction) {
4171
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4172
- }
4173
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4174
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4175
- }
4176
- await this.estimatePredicates(txRequestClone);
4412
+ txRequestClone.maxFee = (0, import_math16.bn)(0);
4413
+ if (isScriptTransaction) {
4414
+ txRequestClone.gasLimit = (0, import_math16.bn)(0);
4177
4415
  }
4178
- if (signatureCallback && isScriptTransaction) {
4179
- await signatureCallback(txRequestClone);
4416
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4417
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
4180
4418
  }
4181
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4182
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4419
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4420
+ let addedSignatures = 0;
4421
+ if (signatureCallback && isScriptTransaction) {
4422
+ const lengthBefore = signedRequest.witnesses.length;
4423
+ await signatureCallback(signedRequest);
4424
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
4425
+ }
4426
+ await this.estimatePredicates(signedRequest);
4427
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4428
+ transactionRequest: signedRequest,
4429
+ optimizeGas: false
4430
+ });
4431
+ txRequestClone.maxFee = maxFee;
4183
4432
  let receipts = [];
4184
4433
  let missingContractIds = [];
4185
4434
  let outputVariables = 0;
4186
- if (isScriptTransaction && estimateTxDependencies) {
4187
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4188
- txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4435
+ let gasUsed = (0, import_math16.bn)(0);
4436
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4437
+ if (isScriptTransaction) {
4438
+ if (signatureCallback) {
4439
+ await signatureCallback(txRequestClone);
4440
+ }
4441
+ txRequestClone.gasLimit = gasLimit;
4189
4442
  const result = await this.estimateTxDependencies(txRequestClone);
4190
4443
  receipts = result.receipts;
4191
4444
  outputVariables = result.outputVariables;
4192
4445
  missingContractIds = result.missingContractIds;
4446
+ gasUsed = getGasUsedFromReceipts(receipts);
4447
+ txRequestClone.gasLimit = gasUsed;
4448
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4449
+ transactionRequest: txRequestClone,
4450
+ gasPrice
4451
+ }));
4193
4452
  }
4194
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4195
- const usedFee = calculatePriceWithFactor(
4196
- gasUsed,
4197
- gasPrice,
4198
- gasPriceFactor
4199
- ).normalizeZeroToOne();
4200
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4201
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4202
4453
  return {
4203
4454
  requiredQuantities: allQuantities,
4204
4455
  receipts,
4205
4456
  gasUsed,
4206
- minGasPrice,
4207
4457
  gasPrice,
4208
4458
  minGas,
4209
4459
  maxGas,
4210
- usedFee,
4211
4460
  minFee,
4212
4461
  maxFee,
4213
- estimatedInputs: txRequestClone.inputs,
4214
4462
  outputVariables,
4215
- missingContractIds
4463
+ missingContractIds,
4464
+ addedSignatures,
4465
+ estimatedPredicates: txRequestClone.inputs
4216
4466
  };
4217
4467
  }
4218
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4468
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4219
4469
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4220
4470
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4221
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4471
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4472
+ quantitiesToContract
4473
+ });
4222
4474
  transactionRequest.addResources(
4223
4475
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4224
4476
  );
4225
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4226
- transactionRequest,
4227
- forwardingQuantities
4228
- );
4477
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4478
+ quantitiesToContract
4479
+ });
4229
4480
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4230
4481
  return {
4231
4482
  resources,
@@ -4241,17 +4492,16 @@ var _Provider = class {
4241
4492
  const result = await this.operations.getCoins({
4242
4493
  first: 10,
4243
4494
  ...paginationArgs,
4244
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4495
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4245
4496
  });
4246
4497
  const coins = result.coins.edges.map((edge) => edge.node);
4247
4498
  return coins.map((coin) => ({
4248
4499
  id: coin.utxoId,
4249
4500
  assetId: coin.assetId,
4250
- amount: (0, import_math15.bn)(coin.amount),
4501
+ amount: (0, import_math16.bn)(coin.amount),
4251
4502
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4252
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4253
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4254
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4503
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4504
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4255
4505
  }));
4256
4506
  }
4257
4507
  /**
@@ -4265,19 +4515,19 @@ var _Provider = class {
4265
4515
  async getResourcesToSpend(owner, quantities, excludedIds) {
4266
4516
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4267
4517
  const excludeInput = {
4268
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4269
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4518
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4519
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4270
4520
  };
4271
4521
  if (this.cache) {
4272
4522
  const uniqueUtxos = new Set(
4273
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4523
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4274
4524
  );
4275
4525
  excludeInput.utxos = Array.from(uniqueUtxos);
4276
4526
  }
4277
4527
  const coinsQuery = {
4278
4528
  owner: ownerAddress.toB256(),
4279
4529
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4280
- assetId: (0, import_utils23.hexlify)(assetId),
4530
+ assetId: (0, import_utils22.hexlify)(assetId),
4281
4531
  amount: amount.toString(10),
4282
4532
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4283
4533
  })),
@@ -4288,9 +4538,9 @@ var _Provider = class {
4288
4538
  switch (coin.__typename) {
4289
4539
  case "MessageCoin":
4290
4540
  return {
4291
- amount: (0, import_math15.bn)(coin.amount),
4541
+ amount: (0, import_math16.bn)(coin.amount),
4292
4542
  assetId: coin.assetId,
4293
- daHeight: (0, import_math15.bn)(coin.daHeight),
4543
+ daHeight: (0, import_math16.bn)(coin.daHeight),
4294
4544
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4295
4545
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4296
4546
  nonce: coin.nonce
@@ -4298,12 +4548,11 @@ var _Provider = class {
4298
4548
  case "Coin":
4299
4549
  return {
4300
4550
  id: coin.utxoId,
4301
- amount: (0, import_math15.bn)(coin.amount),
4551
+ amount: (0, import_math16.bn)(coin.amount),
4302
4552
  assetId: coin.assetId,
4303
4553
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4304
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4305
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4306
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4554
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4555
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4307
4556
  };
4308
4557
  default:
4309
4558
  return null;
@@ -4320,13 +4569,13 @@ var _Provider = class {
4320
4569
  async getBlock(idOrHeight) {
4321
4570
  let variables;
4322
4571
  if (typeof idOrHeight === "number") {
4323
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4572
+ variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4324
4573
  } else if (idOrHeight === "latest") {
4325
4574
  variables = { height: (await this.getBlockNumber()).toString(10) };
4326
4575
  } else if (idOrHeight.length === 66) {
4327
4576
  variables = { blockId: idOrHeight };
4328
4577
  } else {
4329
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4578
+ variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4330
4579
  }
4331
4580
  const { block } = await this.operations.getBlock(variables);
4332
4581
  if (!block) {
@@ -4334,7 +4583,7 @@ var _Provider = class {
4334
4583
  }
4335
4584
  return {
4336
4585
  id: block.id,
4337
- height: (0, import_math15.bn)(block.header.height),
4586
+ height: (0, import_math16.bn)(block.height),
4338
4587
  time: block.header.time,
4339
4588
  transactionIds: block.transactions.map((tx) => tx.id)
4340
4589
  };
@@ -4349,7 +4598,7 @@ var _Provider = class {
4349
4598
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4350
4599
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4351
4600
  id: block.id,
4352
- height: (0, import_math15.bn)(block.header.height),
4601
+ height: (0, import_math16.bn)(block.height),
4353
4602
  time: block.header.time,
4354
4603
  transactionIds: block.transactions.map((tx) => tx.id)
4355
4604
  }));
@@ -4364,7 +4613,7 @@ var _Provider = class {
4364
4613
  async getBlockWithTransactions(idOrHeight) {
4365
4614
  let variables;
4366
4615
  if (typeof idOrHeight === "number") {
4367
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4616
+ variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4368
4617
  } else if (idOrHeight === "latest") {
4369
4618
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4370
4619
  } else {
@@ -4376,11 +4625,11 @@ var _Provider = class {
4376
4625
  }
4377
4626
  return {
4378
4627
  id: block.id,
4379
- height: (0, import_math15.bn)(block.header.height, 10),
4628
+ height: (0, import_math16.bn)(block.height, 10),
4380
4629
  time: block.header.time,
4381
4630
  transactionIds: block.transactions.map((tx) => tx.id),
4382
4631
  transactions: block.transactions.map(
4383
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4632
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4384
4633
  )
4385
4634
  };
4386
4635
  }
@@ -4395,8 +4644,8 @@ var _Provider = class {
4395
4644
  if (!transaction) {
4396
4645
  return null;
4397
4646
  }
4398
- return new import_transactions18.TransactionCoder().decode(
4399
- (0, import_utils23.arrayify)(transaction.rawPayload),
4647
+ return new import_transactions19.TransactionCoder().decode(
4648
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4400
4649
  0
4401
4650
  )?.[0];
4402
4651
  }
@@ -4423,9 +4672,9 @@ var _Provider = class {
4423
4672
  async getContractBalance(contractId, assetId) {
4424
4673
  const { contractBalance } = await this.operations.getContractBalance({
4425
4674
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4426
- asset: (0, import_utils23.hexlify)(assetId)
4675
+ asset: (0, import_utils22.hexlify)(assetId)
4427
4676
  });
4428
- return (0, import_math15.bn)(contractBalance.amount, 10);
4677
+ return (0, import_math16.bn)(contractBalance.amount, 10);
4429
4678
  }
4430
4679
  /**
4431
4680
  * Returns the balance for the given owner for the given asset ID.
@@ -4437,9 +4686,9 @@ var _Provider = class {
4437
4686
  async getBalance(owner, assetId) {
4438
4687
  const { balance } = await this.operations.getBalance({
4439
4688
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4440
- assetId: (0, import_utils23.hexlify)(assetId)
4689
+ assetId: (0, import_utils22.hexlify)(assetId)
4441
4690
  });
4442
- return (0, import_math15.bn)(balance.amount, 10);
4691
+ return (0, import_math16.bn)(balance.amount, 10);
4443
4692
  }
4444
4693
  /**
4445
4694
  * Returns balances for the given owner.
@@ -4457,7 +4706,7 @@ var _Provider = class {
4457
4706
  const balances = result.balances.edges.map((edge) => edge.node);
4458
4707
  return balances.map((balance) => ({
4459
4708
  assetId: balance.assetId,
4460
- amount: (0, import_math15.bn)(balance.amount)
4709
+ amount: (0, import_math16.bn)(balance.amount)
4461
4710
  }));
4462
4711
  }
4463
4712
  /**
@@ -4475,19 +4724,19 @@ var _Provider = class {
4475
4724
  });
4476
4725
  const messages = result.messages.edges.map((edge) => edge.node);
4477
4726
  return messages.map((message) => ({
4478
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4727
+ messageId: import_transactions19.InputMessageCoder.getMessageId({
4479
4728
  sender: message.sender,
4480
4729
  recipient: message.recipient,
4481
4730
  nonce: message.nonce,
4482
- amount: (0, import_math15.bn)(message.amount),
4731
+ amount: (0, import_math16.bn)(message.amount),
4483
4732
  data: message.data
4484
4733
  }),
4485
4734
  sender: import_address3.Address.fromAddressOrString(message.sender),
4486
4735
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4487
4736
  nonce: message.nonce,
4488
- amount: (0, import_math15.bn)(message.amount),
4489
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4490
- daHeight: (0, import_math15.bn)(message.daHeight)
4737
+ amount: (0, import_math16.bn)(message.amount),
4738
+ data: import_transactions19.InputMessageCoder.decodeData(message.data),
4739
+ daHeight: (0, import_math16.bn)(message.daHeight)
4491
4740
  }));
4492
4741
  }
4493
4742
  /**
@@ -4540,44 +4789,52 @@ var _Provider = class {
4540
4789
  } = result.messageProof;
4541
4790
  return {
4542
4791
  messageProof: {
4543
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4792
+ proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4544
4793
  proofSet: messageProof.proofSet
4545
4794
  },
4546
4795
  blockProof: {
4547
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4796
+ proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4548
4797
  proofSet: blockProof.proofSet
4549
4798
  },
4550
4799
  messageBlockHeader: {
4551
4800
  id: messageBlockHeader.id,
4552
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4553
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4801
+ daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4802
+ transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4554
4803
  transactionsRoot: messageBlockHeader.transactionsRoot,
4555
- height: (0, import_math15.bn)(messageBlockHeader.height),
4804
+ height: (0, import_math16.bn)(messageBlockHeader.height),
4556
4805
  prevRoot: messageBlockHeader.prevRoot,
4557
4806
  time: messageBlockHeader.time,
4558
4807
  applicationHash: messageBlockHeader.applicationHash,
4559
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4560
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4808
+ messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount)
4561
4809
  },
4562
4810
  commitBlockHeader: {
4563
4811
  id: commitBlockHeader.id,
4564
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4565
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4812
+ daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4813
+ transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4566
4814
  transactionsRoot: commitBlockHeader.transactionsRoot,
4567
- height: (0, import_math15.bn)(commitBlockHeader.height),
4815
+ height: (0, import_math16.bn)(commitBlockHeader.height),
4568
4816
  prevRoot: commitBlockHeader.prevRoot,
4569
4817
  time: commitBlockHeader.time,
4570
4818
  applicationHash: commitBlockHeader.applicationHash,
4571
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4572
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4819
+ messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount)
4573
4820
  },
4574
4821
  sender: import_address3.Address.fromAddressOrString(sender),
4575
4822
  recipient: import_address3.Address.fromAddressOrString(recipient),
4576
4823
  nonce,
4577
- amount: (0, import_math15.bn)(amount),
4824
+ amount: (0, import_math16.bn)(amount),
4578
4825
  data
4579
4826
  };
4580
4827
  }
4828
+ async getLatestGasPrice() {
4829
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4830
+ return (0, import_math16.bn)(latestGasPrice.gasPrice);
4831
+ }
4832
+ async estimateGasPrice(blockHorizon) {
4833
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4834
+ blockHorizon: String(blockHorizon)
4835
+ });
4836
+ return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4837
+ }
4581
4838
  /**
4582
4839
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4583
4840
  *
@@ -4597,10 +4854,10 @@ var _Provider = class {
4597
4854
  */
4598
4855
  async produceBlocks(amount, startTime) {
4599
4856
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4600
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4601
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4857
+ blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4858
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4602
4859
  });
4603
- return (0, import_math15.bn)(latestBlockHeight);
4860
+ return (0, import_math16.bn)(latestBlockHeight);
4604
4861
  }
4605
4862
  // eslint-disable-next-line @typescript-eslint/require-await
4606
4863
  async getTransactionResponse(transactionId) {
@@ -4614,7 +4871,7 @@ cacheInputs_fn = function(inputs) {
4614
4871
  return;
4615
4872
  }
4616
4873
  inputs.forEach((input) => {
4617
- if (input.type === import_transactions18.InputType.Coin) {
4874
+ if (input.type === import_transactions19.InputType.Coin) {
4618
4875
  this.cache?.set(input.id);
4619
4876
  }
4620
4877
  });
@@ -4624,9 +4881,9 @@ __publicField(Provider, "nodeInfoCache", {});
4624
4881
 
4625
4882
  // src/providers/transaction-summary/get-transaction-summary.ts
4626
4883
  var import_errors15 = require("@fuel-ts/errors");
4627
- var import_math16 = require("@fuel-ts/math");
4628
- var import_transactions19 = require("@fuel-ts/transactions");
4629
- var import_utils26 = require("@fuel-ts/utils");
4884
+ var import_math17 = require("@fuel-ts/math");
4885
+ var import_transactions20 = require("@fuel-ts/transactions");
4886
+ var import_utils25 = require("@fuel-ts/utils");
4630
4887
  async function getTransactionSummary(params) {
4631
4888
  const { id, provider, abiMap } = params;
4632
4889
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -4638,25 +4895,32 @@ async function getTransactionSummary(params) {
4638
4895
  `Transaction not found for given id: ${id}.`
4639
4896
  );
4640
4897
  }
4641
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4642
- (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4898
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
4899
+ (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4643
4900
  0
4644
4901
  );
4645
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
4902
+ let txReceipts = [];
4903
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4904
+ txReceipts = gqlTransaction.status.receipts;
4905
+ }
4906
+ const receipts = txReceipts.map(processGqlReceipt);
4646
4907
  const {
4647
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4908
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4648
4909
  } = provider.getChain();
4910
+ const gasPrice = await provider.getLatestGasPrice();
4649
4911
  const transactionInfo = assembleTransactionSummary({
4650
4912
  id: gqlTransaction.id,
4651
4913
  receipts,
4652
4914
  transaction: decodedTransaction,
4653
- transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4915
+ transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4654
4916
  gqlTransactionStatus: gqlTransaction.status,
4655
- gasPerByte: (0, import_math16.bn)(gasPerByte),
4656
- gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4917
+ gasPerByte: (0, import_math17.bn)(gasPerByte),
4918
+ gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
4657
4919
  abiMap,
4658
4920
  maxInputs,
4659
- gasCosts
4921
+ gasCosts,
4922
+ maxGasPerTx,
4923
+ gasPrice
4660
4924
  });
4661
4925
  return {
4662
4926
  gqlTransaction,
@@ -4666,10 +4930,11 @@ async function getTransactionSummary(params) {
4666
4930
  async function getTransactionSummaryFromRequest(params) {
4667
4931
  const { provider, transactionRequest, abiMap } = params;
4668
4932
  const { receipts } = await provider.call(transactionRequest);
4669
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
4933
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4670
4934
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
4671
4935
  const transaction = transactionRequest.toTransaction();
4672
4936
  const transactionBytes = transactionRequest.toTransactionBytes();
4937
+ const gasPrice = await provider.getLatestGasPrice();
4673
4938
  const transactionSummary = assembleTransactionSummary({
4674
4939
  receipts,
4675
4940
  transaction,
@@ -4678,7 +4943,9 @@ async function getTransactionSummaryFromRequest(params) {
4678
4943
  gasPerByte,
4679
4944
  gasPriceFactor,
4680
4945
  maxInputs,
4681
- gasCosts
4946
+ gasCosts,
4947
+ maxGasPerTx,
4948
+ gasPrice
4682
4949
  });
4683
4950
  return transactionSummary;
4684
4951
  }
@@ -4687,24 +4954,31 @@ async function getTransactionsSummaries(params) {
4687
4954
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4688
4955
  const { edges, pageInfo } = transactionsByOwner;
4689
4956
  const {
4690
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
4957
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
4691
4958
  } = provider.getChain();
4959
+ const gasPrice = await provider.getLatestGasPrice();
4692
4960
  const transactions = edges.map((edge) => {
4693
4961
  const { node: gqlTransaction } = edge;
4694
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4695
- const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4696
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4962
+ const { id, rawPayload, status } = gqlTransaction;
4963
+ const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4964
+ let txReceipts = [];
4965
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
4966
+ txReceipts = gqlTransaction.status.receipts;
4967
+ }
4968
+ const receipts = txReceipts.map(processGqlReceipt);
4697
4969
  const transactionSummary = assembleTransactionSummary({
4698
4970
  id,
4699
4971
  receipts,
4700
4972
  transaction: decodedTransaction,
4701
- transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4973
+ transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4702
4974
  gqlTransactionStatus: status,
4703
4975
  abiMap,
4704
4976
  gasPerByte,
4705
4977
  gasPriceFactor,
4706
4978
  maxInputs,
4707
- gasCosts
4979
+ gasCosts,
4980
+ maxGasPerTx,
4981
+ gasPrice
4708
4982
  });
4709
4983
  const output = {
4710
4984
  gqlTransaction,
@@ -4841,17 +5115,17 @@ var assets = [
4841
5115
 
4842
5116
  // src/utils/formatTransferToContractScriptData.ts
4843
5117
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4844
- var import_math17 = require("@fuel-ts/math");
4845
- var import_utils27 = require("@fuel-ts/utils");
5118
+ var import_math18 = require("@fuel-ts/math");
5119
+ var import_utils26 = require("@fuel-ts/utils");
4846
5120
  var asm = __toESM(require("@fuels/vm-asm"));
4847
5121
  var formatTransferToContractScriptData = (params) => {
4848
5122
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4849
5123
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4850
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
5124
+ const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4851
5125
  const scriptData = Uint8Array.from([
4852
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
5126
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4853
5127
  ...encoded,
4854
- ...(0, import_utils27.arrayify)(assetId)
5128
+ ...(0, import_utils26.arrayify)(assetId)
4855
5129
  ]);
4856
5130
  return scriptData;
4857
5131
  };
@@ -5036,36 +5310,33 @@ var Account = class extends import_interfaces.AbstractAccount {
5036
5310
  * @param fee - The estimated transaction fee.
5037
5311
  * @returns A promise that resolves when the resources are added to the transaction.
5038
5312
  */
5039
- async fund(request, coinQuantities, fee) {
5040
- const updatedQuantities = addAmountToAsset({
5041
- amount: (0, import_math18.bn)(fee),
5313
+ async fund(request, params) {
5314
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5315
+ const txRequest = request;
5316
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5317
+ amount: (0, import_math19.bn)(fee),
5042
5318
  assetId: import_configs12.BaseAssetId,
5043
- coinQuantities
5319
+ coinQuantities: requiredQuantities
5044
5320
  });
5045
5321
  const quantitiesDict = {};
5046
- updatedQuantities.forEach(({ amount, assetId }) => {
5322
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5047
5323
  quantitiesDict[assetId] = {
5048
5324
  required: amount,
5049
- owned: (0, import_math18.bn)(0)
5325
+ owned: (0, import_math19.bn)(0)
5050
5326
  };
5051
5327
  });
5052
- const cachedUtxos = [];
5053
- const cachedMessages = [];
5054
- const owner = this.address.toB256();
5055
- request.inputs.forEach((input) => {
5328
+ txRequest.inputs.forEach((input) => {
5056
5329
  const isResource = "amount" in input;
5057
5330
  if (isResource) {
5058
5331
  const isCoin2 = "owner" in input;
5059
5332
  if (isCoin2) {
5060
5333
  const assetId = String(input.assetId);
5061
- if (input.owner === owner && quantitiesDict[assetId]) {
5062
- const amount = (0, import_math18.bn)(input.amount);
5334
+ if (quantitiesDict[assetId]) {
5335
+ const amount = (0, import_math19.bn)(input.amount);
5063
5336
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5064
- cachedUtxos.push(input.id);
5065
5337
  }
5066
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5338
+ } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5067
5339
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5068
- cachedMessages.push(input.nonce);
5069
5340
  }
5070
5341
  }
5071
5342
  });
@@ -5080,12 +5351,23 @@ var Account = class extends import_interfaces.AbstractAccount {
5080
5351
  });
5081
5352
  const needsToBeFunded = missingQuantities.length;
5082
5353
  if (needsToBeFunded) {
5083
- const resources = await this.getResourcesToSpend(missingQuantities, {
5084
- messages: cachedMessages,
5085
- utxos: cachedUtxos
5086
- });
5087
- request.addResources(resources);
5354
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5355
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5356
+ txRequest.addResources(resources);
5357
+ }
5358
+ txRequest.shiftPredicateData();
5359
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5360
+ const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
5361
+ if (addedSignatures) {
5362
+ Array.from({ length: addedSignatures }).forEach(
5363
+ () => requestToBeReEstimate.addEmptyWitness()
5364
+ );
5088
5365
  }
5366
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
5367
+ transactionRequest: requestToBeReEstimate
5368
+ });
5369
+ txRequest.maxFee = maxFee;
5370
+ return txRequest;
5089
5371
  }
5090
5372
  /**
5091
5373
  * A helper that creates a transfer transaction request and returns it.
@@ -5093,28 +5375,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5093
5375
  * @param destination - The address of the destination.
5094
5376
  * @param amount - The amount of coins to transfer.
5095
5377
  * @param assetId - The asset ID of the coins to transfer.
5096
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5378
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
5097
5379
  * @returns A promise that resolves to the prepared transaction request.
5098
5380
  */
5099
5381
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5100
- const { minGasPrice } = this.provider.getGasConfig();
5101
- const params = { gasPrice: minGasPrice, ...txParams };
5102
- const request = new ScriptTransactionRequest(params);
5382
+ const request = new ScriptTransactionRequest(txParams);
5103
5383
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5104
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5384
+ const txCost = await this.provider.getTransactionCost(request, {
5105
5385
  estimateTxDependencies: true,
5106
5386
  resourcesOwner: this
5107
5387
  });
5108
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5109
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5110
- this.validateGas({
5111
- gasUsed,
5112
- gasPrice: request.gasPrice,
5113
- gasLimit: request.gasLimit,
5114
- minGasPrice
5115
- });
5116
- await this.fund(request, requiredQuantities, maxFee);
5117
- request.updatePredicateInputs(estimatedInputs);
5388
+ if ("gasLimit" in txParams) {
5389
+ this.validateGas({
5390
+ gasUsed: txCost.gasUsed,
5391
+ gasLimit: request.gasLimit
5392
+ });
5393
+ }
5394
+ request.gasLimit = txCost.gasUsed;
5395
+ request.maxFee = txCost.maxFee;
5396
+ await this.fund(request, txCost);
5118
5397
  return request;
5119
5398
  }
5120
5399
  /**
@@ -5127,7 +5406,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5127
5406
  * @returns A promise that resolves to the transaction response.
5128
5407
  */
5129
5408
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5130
- if ((0, import_math18.bn)(amount).lte(0)) {
5409
+ if ((0, import_math19.bn)(amount).lte(0)) {
5131
5410
  throw new import_errors16.FuelError(
5132
5411
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5133
5412
  "Transfer amount must be a positive number."
@@ -5146,38 +5425,37 @@ var Account = class extends import_interfaces.AbstractAccount {
5146
5425
  * @returns A promise that resolves to the transaction response.
5147
5426
  */
5148
5427
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5149
- if ((0, import_math18.bn)(amount).lte(0)) {
5428
+ if ((0, import_math19.bn)(amount).lte(0)) {
5150
5429
  throw new import_errors16.FuelError(
5151
5430
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5152
5431
  "Transfer amount must be a positive number."
5153
5432
  );
5154
5433
  }
5155
5434
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5156
- const { minGasPrice } = this.provider.getGasConfig();
5157
- const params = { gasPrice: minGasPrice, ...txParams };
5158
5435
  const { script, scriptData } = await assembleTransferToContractScript({
5159
5436
  hexlifiedContractId: contractAddress.toB256(),
5160
- amountToTransfer: (0, import_math18.bn)(amount),
5437
+ amountToTransfer: (0, import_math19.bn)(amount),
5161
5438
  assetId
5162
5439
  });
5163
5440
  const request = new ScriptTransactionRequest({
5164
- ...params,
5441
+ ...txParams,
5165
5442
  script,
5166
5443
  scriptData
5167
5444
  });
5168
5445
  request.addContractInputAndOutput(contractAddress);
5169
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5170
- request,
5171
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5172
- );
5173
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5174
- this.validateGas({
5175
- gasUsed,
5176
- gasPrice: request.gasPrice,
5177
- gasLimit: request.gasLimit,
5178
- minGasPrice
5446
+ const txCost = await this.provider.getTransactionCost(request, {
5447
+ resourcesOwner: this,
5448
+ quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5179
5449
  });
5180
- await this.fund(request, requiredQuantities, maxFee);
5450
+ if (txParams.gasLimit) {
5451
+ this.validateGas({
5452
+ gasUsed: txCost.gasUsed,
5453
+ gasLimit: request.gasLimit
5454
+ });
5455
+ }
5456
+ request.gasLimit = txCost.gasUsed;
5457
+ request.maxFee = txCost.maxFee;
5458
+ await this.fund(request, txCost);
5181
5459
  return this.sendTransaction(request);
5182
5460
  }
5183
5461
  /**
@@ -5189,34 +5467,31 @@ var Account = class extends import_interfaces.AbstractAccount {
5189
5467
  * @returns A promise that resolves to the transaction response.
5190
5468
  */
5191
5469
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5192
- const { minGasPrice } = this.provider.getGasConfig();
5193
5470
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5194
- const recipientDataArray = (0, import_utils28.arrayify)(
5471
+ const recipientDataArray = (0, import_utils27.arrayify)(
5195
5472
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5196
5473
  );
5197
- const amountDataArray = (0, import_utils28.arrayify)(
5198
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5474
+ const amountDataArray = (0, import_utils27.arrayify)(
5475
+ "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5199
5476
  );
5200
5477
  const script = new Uint8Array([
5201
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5478
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5202
5479
  ...recipientDataArray,
5203
5480
  ...amountDataArray
5204
5481
  ]);
5205
- const params = { script, gasPrice: minGasPrice, ...txParams };
5482
+ const params = { script, ...txParams };
5206
5483
  const request = new ScriptTransactionRequest(params);
5207
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5208
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5209
- request,
5210
- forwardingQuantities
5211
- );
5212
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5213
- this.validateGas({
5214
- gasUsed,
5215
- gasPrice: request.gasPrice,
5216
- gasLimit: request.gasLimit,
5217
- minGasPrice
5218
- });
5219
- await this.fund(request, requiredQuantities, maxFee);
5484
+ const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5485
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5486
+ if (txParams.gasLimit) {
5487
+ this.validateGas({
5488
+ gasUsed: txCost.gasUsed,
5489
+ gasLimit: request.gasLimit
5490
+ });
5491
+ }
5492
+ request.maxFee = txCost.maxFee;
5493
+ request.gasLimit = txCost.gasUsed;
5494
+ await this.fund(request, txCost);
5220
5495
  return this.sendTransaction(request);
5221
5496
  }
5222
5497
  async signMessage(message) {
@@ -5274,18 +5549,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5274
5549
  }
5275
5550
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5276
5551
  }
5277
- validateGas({
5278
- gasUsed,
5279
- gasPrice,
5280
- gasLimit,
5281
- minGasPrice
5282
- }) {
5283
- if (minGasPrice.gt(gasPrice)) {
5284
- throw new import_errors16.FuelError(
5285
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5286
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5287
- );
5288
- }
5552
+ validateGas({ gasUsed, gasLimit }) {
5289
5553
  if (gasUsed.gt(gasLimit)) {
5290
5554
  throw new import_errors16.FuelError(
5291
5555
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5297,14 +5561,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5297
5561
 
5298
5562
  // src/wallet/base-wallet-unlocked.ts
5299
5563
  var import_hasher3 = require("@fuel-ts/hasher");
5300
- var import_utils31 = require("@fuel-ts/utils");
5564
+ var import_utils30 = require("@fuel-ts/utils");
5301
5565
 
5302
5566
  // src/signer/signer.ts
5303
5567
  var import_address5 = require("@fuel-ts/address");
5304
5568
  var import_crypto = require("@fuel-ts/crypto");
5305
5569
  var import_hasher2 = require("@fuel-ts/hasher");
5306
- var import_math19 = require("@fuel-ts/math");
5307
- var import_utils29 = require("@fuel-ts/utils");
5570
+ var import_math20 = require("@fuel-ts/math");
5571
+ var import_utils28 = require("@fuel-ts/utils");
5308
5572
  var import_secp256k1 = require("@noble/curves/secp256k1");
5309
5573
  var Signer = class {
5310
5574
  address;
@@ -5323,10 +5587,10 @@ var Signer = class {
5323
5587
  privateKey = `0x${privateKey}`;
5324
5588
  }
5325
5589
  }
5326
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5327
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5328
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5329
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5590
+ const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5591
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5592
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5593
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5330
5594
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5331
5595
  }
5332
5596
  /**
@@ -5340,11 +5604,11 @@ var Signer = class {
5340
5604
  * @returns hashed signature
5341
5605
  */
5342
5606
  sign(data) {
5343
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5344
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5345
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5607
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5608
+ const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5609
+ const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5346
5610
  s[0] |= (signature.recovery || 0) << 7;
5347
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5611
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5348
5612
  }
5349
5613
  /**
5350
5614
  * Add point on the current elliptic curve
@@ -5353,8 +5617,8 @@ var Signer = class {
5353
5617
  * @returns compressed point on the curve
5354
5618
  */
5355
5619
  addPoint(point) {
5356
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5357
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5620
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5621
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5358
5622
  const result = p0.add(p1);
5359
5623
  return `0x${result.toHex(true)}`;
5360
5624
  }
@@ -5366,16 +5630,16 @@ var Signer = class {
5366
5630
  * @returns public key from signature from the
5367
5631
  */
5368
5632
  static recoverPublicKey(data, signature) {
5369
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5633
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5370
5634
  const r = signedMessageBytes.slice(0, 32);
5371
5635
  const s = signedMessageBytes.slice(32, 64);
5372
5636
  const recoveryParam = (s[0] & 128) >> 7;
5373
5637
  s[0] &= 127;
5374
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5638
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5375
5639
  recoveryParam
5376
5640
  );
5377
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5378
- return (0, import_utils29.hexlify)(publicKey);
5641
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5642
+ return (0, import_utils28.hexlify)(publicKey);
5379
5643
  }
5380
5644
  /**
5381
5645
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5394,7 +5658,7 @@ var Signer = class {
5394
5658
  * @returns random 32-byte hashed
5395
5659
  */
5396
5660
  static generatePrivateKey(entropy) {
5397
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5661
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5398
5662
  }
5399
5663
  /**
5400
5664
  * Extended publicKey from a compact publicKey
@@ -5403,8 +5667,8 @@ var Signer = class {
5403
5667
  * @returns extended publicKey
5404
5668
  */
5405
5669
  static extendPublicKey(publicKey) {
5406
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5407
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5670
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5671
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5408
5672
  }
5409
5673
  };
5410
5674
 
@@ -5412,7 +5676,7 @@ var Signer = class {
5412
5676
  var import_address6 = require("@fuel-ts/address");
5413
5677
  var import_crypto2 = require("@fuel-ts/crypto");
5414
5678
  var import_errors17 = require("@fuel-ts/errors");
5415
- var import_utils30 = require("@fuel-ts/utils");
5679
+ var import_utils29 = require("@fuel-ts/utils");
5416
5680
  var import_uuid = require("uuid");
5417
5681
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5418
5682
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5495,7 +5759,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5495
5759
  );
5496
5760
  }
5497
5761
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5498
- const privateKey = (0, import_utils30.hexlify)(buffer);
5762
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5499
5763
  return privateKey;
5500
5764
  }
5501
5765
 
@@ -5540,7 +5804,7 @@ var BaseWalletUnlocked = class extends Account {
5540
5804
  */
5541
5805
  async signMessage(message) {
5542
5806
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5543
- return (0, import_utils31.hexlify)(signedMessage);
5807
+ return (0, import_utils30.hexlify)(signedMessage);
5544
5808
  }
5545
5809
  /**
5546
5810
  * Signs a transaction with the wallet's private key.
@@ -5553,7 +5817,7 @@ var BaseWalletUnlocked = class extends Account {
5553
5817
  const chainId = this.provider.getChainId();
5554
5818
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5555
5819
  const signature = await this.signer().sign(hashedTransaction);
5556
- return (0, import_utils31.hexlify)(signature);
5820
+ return (0, import_utils30.hexlify)(signature);
5557
5821
  }
5558
5822
  /**
5559
5823
  * Populates a transaction with the witnesses signature.
@@ -5573,7 +5837,7 @@ var BaseWalletUnlocked = class extends Account {
5573
5837
  * @param transactionRequestLike - The transaction request to send.
5574
5838
  * @returns A promise that resolves to the TransactionResponse object.
5575
5839
  */
5576
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5840
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5577
5841
  const transactionRequest = transactionRequestify(transactionRequestLike);
5578
5842
  if (estimateTxDependencies) {
5579
5843
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5614,16 +5878,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5614
5878
  // src/hdwallet/hdwallet.ts
5615
5879
  var import_errors20 = require("@fuel-ts/errors");
5616
5880
  var import_hasher6 = require("@fuel-ts/hasher");
5617
- var import_math20 = require("@fuel-ts/math");
5618
- var import_utils35 = require("@fuel-ts/utils");
5619
- var import_ethers3 = require("ethers");
5881
+ var import_math21 = require("@fuel-ts/math");
5882
+ var import_utils34 = require("@fuel-ts/utils");
5883
+ var import_ethers4 = require("ethers");
5620
5884
 
5621
5885
  // src/mnemonic/mnemonic.ts
5622
5886
  var import_crypto3 = require("@fuel-ts/crypto");
5623
5887
  var import_errors19 = require("@fuel-ts/errors");
5624
5888
  var import_hasher5 = require("@fuel-ts/hasher");
5625
- var import_utils33 = require("@fuel-ts/utils");
5626
- var import_ethers2 = require("ethers");
5889
+ var import_utils32 = require("@fuel-ts/utils");
5890
+ var import_ethers3 = require("ethers");
5627
5891
 
5628
5892
  // src/wordlists/words/english.ts
5629
5893
  var english = [
@@ -7686,7 +7950,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7686
7950
  // src/mnemonic/utils.ts
7687
7951
  var import_errors18 = require("@fuel-ts/errors");
7688
7952
  var import_hasher4 = require("@fuel-ts/hasher");
7689
- var import_utils32 = require("@fuel-ts/utils");
7953
+ var import_utils31 = require("@fuel-ts/utils");
7690
7954
  function toUtf8Bytes(stri) {
7691
7955
  const str = stri.normalize("NFKD");
7692
7956
  const result = [];
@@ -7753,14 +8017,14 @@ function entropyToMnemonicIndices(entropy) {
7753
8017
  }
7754
8018
  }
7755
8019
  const checksumBits = entropy.length / 4;
7756
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8020
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7757
8021
  indices[indices.length - 1] <<= checksumBits;
7758
8022
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7759
8023
  return indices;
7760
8024
  }
7761
8025
  function mnemonicWordsToEntropy(words, wordlist) {
7762
8026
  const size = Math.ceil(11 * words.length / 8);
7763
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8027
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7764
8028
  let offset = 0;
7765
8029
  for (let i = 0; i < words.length; i += 1) {
7766
8030
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7780,7 +8044,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7780
8044
  const entropyBits = 32 * words.length / 3;
7781
8045
  const checksumBits = words.length / 3;
7782
8046
  const checksumMask = getUpperMask(checksumBits);
7783
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8047
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7784
8048
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7785
8049
  throw new import_errors18.FuelError(
7786
8050
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7855,7 +8119,7 @@ var Mnemonic = class {
7855
8119
  static mnemonicToEntropy(phrase, wordlist = english) {
7856
8120
  const words = getWords(phrase);
7857
8121
  assertMnemonic(words);
7858
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8122
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7859
8123
  }
7860
8124
  /**
7861
8125
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7863,7 +8127,7 @@ var Mnemonic = class {
7863
8127
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7864
8128
  */
7865
8129
  static entropyToMnemonic(entropy, wordlist = english) {
7866
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
8130
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7867
8131
  assertWordList(wordlist);
7868
8132
  assertEntropy(entropyBytes);
7869
8133
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7877,7 +8141,7 @@ var Mnemonic = class {
7877
8141
  assertMnemonic(getWords(phrase));
7878
8142
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7879
8143
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7880
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8144
+ return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7881
8145
  }
7882
8146
  /**
7883
8147
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7932,14 +8196,14 @@ var Mnemonic = class {
7932
8196
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7933
8197
  */
7934
8198
  static masterKeysFromSeed(seed) {
7935
- const seedArray = (0, import_utils33.arrayify)(seed);
8199
+ const seedArray = (0, import_utils32.arrayify)(seed);
7936
8200
  if (seedArray.length < 16 || seedArray.length > 64) {
7937
8201
  throw new import_errors19.FuelError(
7938
8202
  import_errors19.ErrorCode.INVALID_SEED,
7939
8203
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7940
8204
  );
7941
8205
  }
7942
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8206
+ return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
7943
8207
  }
7944
8208
  /**
7945
8209
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7950,22 +8214,22 @@ var Mnemonic = class {
7950
8214
  */
7951
8215
  static seedToExtendedKey(seed, testnet = false) {
7952
8216
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7953
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8217
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7954
8218
  const depth = "0x00";
7955
8219
  const fingerprint = "0x00000000";
7956
8220
  const index = "0x00000000";
7957
8221
  const chainCode = masterKey.slice(32);
7958
8222
  const privateKey = masterKey.slice(0, 32);
7959
- const extendedKey = (0, import_utils33.concat)([
8223
+ const extendedKey = (0, import_utils32.concat)([
7960
8224
  prefix,
7961
8225
  depth,
7962
8226
  fingerprint,
7963
8227
  index,
7964
8228
  chainCode,
7965
- (0, import_utils33.concat)(["0x00", privateKey])
8229
+ (0, import_utils32.concat)(["0x00", privateKey])
7966
8230
  ]);
7967
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7968
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8231
+ const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8232
+ return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7969
8233
  }
7970
8234
  /**
7971
8235
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7980,7 +8244,7 @@ var Mnemonic = class {
7980
8244
  * @returns A randomly generated mnemonic
7981
8245
  */
7982
8246
  static generate(size = 32, extraEntropy = "") {
7983
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8247
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7984
8248
  return Mnemonic.entropyToMnemonic(entropy);
7985
8249
  }
7986
8250
  };
@@ -7988,12 +8252,12 @@ var mnemonic_default = Mnemonic;
7988
8252
 
7989
8253
  // src/hdwallet/hdwallet.ts
7990
8254
  var HARDENED_INDEX = 2147483648;
7991
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7992
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7993
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7994
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8255
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
8256
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8257
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8258
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7995
8259
  function base58check(data) {
7996
- 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)]));
8260
+ return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7997
8261
  }
7998
8262
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7999
8263
  if (isPublic) {
@@ -8002,11 +8266,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8002
8266
  return testnet ? TestnetPRV2 : MainnetPRV2;
8003
8267
  }
8004
8268
  function isPublicExtendedKey(extendedKey) {
8005
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8269
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8006
8270
  }
8007
8271
  function isValidExtendedKey(extendedKey) {
8008
8272
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8009
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8273
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8010
8274
  );
8011
8275
  }
8012
8276
  function parsePath(path, depth = 0) {
@@ -8024,8 +8288,8 @@ function parsePath(path, depth = 0) {
8024
8288
  var HDWallet = class {
8025
8289
  depth = 0;
8026
8290
  index = 0;
8027
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
8028
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8291
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
8292
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8029
8293
  privateKey;
8030
8294
  publicKey;
8031
8295
  chainCode;
@@ -8037,8 +8301,8 @@ var HDWallet = class {
8037
8301
  constructor(config) {
8038
8302
  if (config.privateKey) {
8039
8303
  const signer = new Signer(config.privateKey);
8040
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8041
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8304
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
8305
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8042
8306
  } else {
8043
8307
  if (!config.publicKey) {
8044
8308
  throw new import_errors20.FuelError(
@@ -8046,10 +8310,10 @@ var HDWallet = class {
8046
8310
  "Both public and private Key cannot be missing. At least one should be provided."
8047
8311
  );
8048
8312
  }
8049
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8313
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8050
8314
  }
8051
8315
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8052
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8316
+ this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8053
8317
  this.depth = config.depth || this.depth;
8054
8318
  this.index = config.index || this.index;
8055
8319
  this.chainCode = config.chainCode;
@@ -8065,9 +8329,9 @@ var HDWallet = class {
8065
8329
  * @returns A new instance of HDWallet on the derived index
8066
8330
  */
8067
8331
  deriveIndex(index) {
8068
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8069
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8070
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8332
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8333
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8334
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8071
8335
  const data = new Uint8Array(37);
8072
8336
  if (index & HARDENED_INDEX) {
8073
8337
  if (!privateKey) {
@@ -8078,15 +8342,15 @@ var HDWallet = class {
8078
8342
  }
8079
8343
  data.set(privateKey, 1);
8080
8344
  } else {
8081
- data.set((0, import_utils35.arrayify)(this.publicKey));
8345
+ data.set((0, import_utils34.arrayify)(this.publicKey));
8082
8346
  }
8083
- data.set((0, import_math20.toBytes)(index, 4), 33);
8084
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8347
+ data.set((0, import_math21.toBytes)(index, 4), 33);
8348
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
8085
8349
  const IL = bytes.slice(0, 32);
8086
8350
  const IR = bytes.slice(32);
8087
8351
  if (privateKey) {
8088
8352
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8089
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8353
+ const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8090
8354
  return new HDWallet({
8091
8355
  privateKey: ki,
8092
8356
  chainCode: IR,
@@ -8095,7 +8359,7 @@ var HDWallet = class {
8095
8359
  parentFingerprint: this.fingerprint
8096
8360
  });
8097
8361
  }
8098
- const signer = new Signer((0, import_utils35.hexlify)(IL));
8362
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
8099
8363
  const Ki = signer.addPoint(publicKey);
8100
8364
  return new HDWallet({
8101
8365
  publicKey: Ki,
@@ -8130,12 +8394,12 @@ var HDWallet = class {
8130
8394
  );
8131
8395
  }
8132
8396
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8133
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8397
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8134
8398
  const parentFingerprint = this.parentFingerprint;
8135
- const index = (0, import_math20.toHex)(this.index, 4);
8399
+ const index = (0, import_math21.toHex)(this.index, 4);
8136
8400
  const chainCode = this.chainCode;
8137
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8138
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8401
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8402
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8139
8403
  return base58check(extendedKey);
8140
8404
  }
8141
8405
  /**
@@ -8147,13 +8411,13 @@ var HDWallet = class {
8147
8411
  static fromSeed(seed) {
8148
8412
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8149
8413
  return new HDWallet({
8150
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8151
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8414
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8415
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8152
8416
  });
8153
8417
  }
8154
8418
  static fromExtendedKey(extendedKey) {
8155
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8156
- const bytes = (0, import_utils35.arrayify)(decoded);
8419
+ const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
8420
+ const bytes = (0, import_utils34.arrayify)(decoded);
8157
8421
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8158
8422
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8159
8423
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8162,9 +8426,9 @@ var HDWallet = class {
8162
8426
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8163
8427
  }
8164
8428
  const depth = bytes[4];
8165
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8166
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8167
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8429
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8430
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8431
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8168
8432
  const key = bytes.slice(45, 78);
8169
8433
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8170
8434
  throw new import_errors20.FuelError(
@@ -8769,19 +9033,19 @@ var import_abi_coder5 = require("@fuel-ts/abi-coder");
8769
9033
  var import_address10 = require("@fuel-ts/address");
8770
9034
  var import_configs13 = require("@fuel-ts/address/configs");
8771
9035
  var import_errors25 = require("@fuel-ts/errors");
8772
- var import_transactions20 = require("@fuel-ts/transactions");
8773
- var import_utils37 = require("@fuel-ts/utils");
9036
+ var import_transactions21 = require("@fuel-ts/transactions");
9037
+ var import_utils36 = require("@fuel-ts/utils");
8774
9038
 
8775
9039
  // src/predicate/utils/getPredicateRoot.ts
8776
9040
  var import_hasher7 = require("@fuel-ts/hasher");
8777
9041
  var import_merkle = require("@fuel-ts/merkle");
8778
- var import_utils36 = require("@fuel-ts/utils");
9042
+ var import_utils35 = require("@fuel-ts/utils");
8779
9043
  var getPredicateRoot = (bytecode) => {
8780
9044
  const chunkSize = 16 * 1024;
8781
- const bytes = (0, import_utils36.arrayify)(bytecode);
8782
- const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8783
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8784
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9045
+ const bytes = (0, import_utils35.arrayify)(bytecode);
9046
+ const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
9047
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
9048
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8785
9049
  return predicateRoot;
8786
9050
  };
8787
9051
 
@@ -8829,10 +9093,9 @@ var Predicate = class extends Account {
8829
9093
  const request = transactionRequestify(transactionRequestLike);
8830
9094
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8831
9095
  request.inputs?.forEach((input) => {
8832
- if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8833
- input.predicate = this.bytes;
8834
- input.predicateData = this.getPredicateData(policies.length);
8835
- input.witnessIndex = 0;
9096
+ if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9097
+ input.predicate = (0, import_utils36.hexlify)(this.bytes);
9098
+ input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
8836
9099
  }
8837
9100
  });
8838
9101
  return request;
@@ -8847,8 +9110,7 @@ var Predicate = class extends Account {
8847
9110
  * @returns A promise that resolves to the prepared transaction request.
8848
9111
  */
8849
9112
  async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8850
- const request = await super.createTransfer(destination, amount, assetId, txParams);
8851
- return this.populateTransactionPredicateData(request);
9113
+ return super.createTransfer(destination, amount, assetId, txParams);
8852
9114
  }
8853
9115
  /**
8854
9116
  * Sends a transaction with the populated predicate data.
@@ -8856,9 +9118,9 @@ var Predicate = class extends Account {
8856
9118
  * @param transactionRequestLike - The transaction request-like object.
8857
9119
  * @returns A promise that resolves to the transaction response.
8858
9120
  */
8859
- sendTransaction(transactionRequestLike, options) {
8860
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8861
- return super.sendTransaction(transactionRequest, options);
9121
+ sendTransaction(transactionRequestLike) {
9122
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9123
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
8862
9124
  }
8863
9125
  /**
8864
9126
  * Simulates a transaction with the populated predicate data.
@@ -8867,29 +9129,15 @@ var Predicate = class extends Account {
8867
9129
  * @returns A promise that resolves to the call result.
8868
9130
  */
8869
9131
  simulateTransaction(transactionRequestLike) {
8870
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8871
- return super.simulateTransaction(transactionRequest);
8872
- }
8873
- /**
8874
- * Retrieves resources satisfying the spend query for the account.
8875
- *
8876
- * @param quantities - IDs of coins to exclude.
8877
- * @param excludedIds - IDs of resources to be excluded from the query.
8878
- * @returns A promise that resolves to an array of Resources.
8879
- */
8880
- async getResourcesToSpend(quantities, excludedIds) {
8881
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8882
- return resources.map((resource) => ({
8883
- ...resource,
8884
- predicate: (0, import_utils37.hexlify)(this.bytes)
8885
- }));
9132
+ const transactionRequest = transactionRequestify(transactionRequestLike);
9133
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
8886
9134
  }
8887
9135
  getPredicateData(policiesLength) {
8888
9136
  if (!this.predicateData.length) {
8889
9137
  return new Uint8Array();
8890
9138
  }
8891
9139
  const mainFn = this.interface?.functions.main;
8892
- const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9140
+ const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8893
9141
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8894
9142
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8895
9143
  });
@@ -8905,7 +9153,7 @@ var Predicate = class extends Account {
8905
9153
  * @returns An object containing the new predicate bytes and interface.
8906
9154
  */
8907
9155
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8908
- let predicateBytes = (0, import_utils37.arrayify)(bytes);
9156
+ let predicateBytes = (0, import_utils36.arrayify)(bytes);
8909
9157
  let abiInterface;
8910
9158
  if (jsonAbi) {
8911
9159
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
@@ -8928,6 +9176,25 @@ var Predicate = class extends Account {
8928
9176
  predicateInterface: abiInterface
8929
9177
  };
8930
9178
  }
9179
+ /**
9180
+ * Retrieves resources satisfying the spend query for the account.
9181
+ *
9182
+ * @param quantities - IDs of coins to exclude.
9183
+ * @param excludedIds - IDs of resources to be excluded from the query.
9184
+ * @returns A promise that resolves to an array of Resources.
9185
+ */
9186
+ async getResourcesToSpend(quantities, excludedIds) {
9187
+ const resources = await this.provider.getResourcesToSpend(
9188
+ this.address,
9189
+ quantities,
9190
+ excludedIds
9191
+ );
9192
+ return resources.map((resource) => ({
9193
+ ...resource,
9194
+ predicate: (0, import_utils36.hexlify)(this.bytes),
9195
+ paddPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
9196
+ }));
9197
+ }
8931
9198
  /**
8932
9199
  * Sets the configurable constants for the predicate.
8933
9200
  *
@@ -9677,7 +9944,7 @@ __publicField(Fuel, "defaultConfig", {});
9677
9944
  WalletLocked,
9678
9945
  WalletManager,
9679
9946
  WalletUnlocked,
9680
- addAmountToAsset,
9947
+ addAmountToCoinQuantities,
9681
9948
  addOperation,
9682
9949
  assemblePanicError,
9683
9950
  assembleReceiptByType,
@@ -9686,9 +9953,10 @@ __publicField(Fuel, "defaultConfig", {});
9686
9953
  assets,
9687
9954
  buildBlockExplorerUrl,
9688
9955
  cacheFor,
9956
+ cacheTxInputsFromOwner,
9957
+ calculateGasFee,
9689
9958
  calculateMetadataGasForTxCreate,
9690
9959
  calculateMetadataGasForTxScript,
9691
- calculatePriceWithFactor,
9692
9960
  calculateTransactionFee,
9693
9961
  coinQuantityfy,
9694
9962
  deferPromise,