@fuel-ts/account 0.0.0-rc-2143-20240424161332 → 0.0.0-rc-2021-20240424162616

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 +6 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +808 -553
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +769 -514
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +650 -396
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +810 -359
  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 +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +7 -1
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +37 -27
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +8 -29
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +3 -0
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +8 -2
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts +2 -4
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1527 -1056
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +751 -514
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +644 -407
  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 +16 -16
@@ -58,15 +58,16 @@ module.exports = __toCommonJS(test_utils_exports);
58
58
 
59
59
  // src/wallet/base-wallet-unlocked.ts
60
60
  var import_hasher3 = require("@fuel-ts/hasher");
61
- var import_utils31 = require("@fuel-ts/utils");
61
+ var import_utils30 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
65
  var import_configs12 = require("@fuel-ts/address/configs");
66
66
  var import_errors16 = require("@fuel-ts/errors");
67
67
  var import_interfaces = require("@fuel-ts/interfaces");
68
- var import_math18 = require("@fuel-ts/math");
69
- var import_utils28 = require("@fuel-ts/utils");
68
+ var import_math19 = require("@fuel-ts/math");
69
+ var import_utils27 = require("@fuel-ts/utils");
70
+ var import_ramda4 = require("ramda");
70
71
 
71
72
  // src/providers/coin-quantity.ts
72
73
  var import_configs = require("@fuel-ts/address/configs");
@@ -75,24 +76,24 @@ var import_utils = require("@fuel-ts/utils");
75
76
  var coinQuantityfy = (coinQuantityLike) => {
76
77
  let assetId;
77
78
  let amount;
78
- let max2;
79
+ let max;
79
80
  if (Array.isArray(coinQuantityLike)) {
80
81
  amount = coinQuantityLike[0];
81
82
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
82
- max2 = coinQuantityLike[2] ?? void 0;
83
+ max = coinQuantityLike[2] ?? void 0;
83
84
  } else {
84
85
  amount = coinQuantityLike.amount;
85
86
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
86
- max2 = coinQuantityLike.max ?? void 0;
87
+ max = coinQuantityLike.max ?? void 0;
87
88
  }
88
89
  const bnAmount = (0, import_math.bn)(amount);
89
90
  return {
90
91
  assetId: (0, import_utils.hexlify)(assetId),
91
92
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
92
- max: max2 ? (0, import_math.bn)(max2) : void 0
93
+ max: max ? (0, import_math.bn)(max) : void 0
93
94
  };
94
95
  };
95
- var addAmountToAsset = (params) => {
96
+ var addAmountToCoinQuantities = (params) => {
96
97
  const { amount, assetId } = params;
97
98
  const coinQuantities = [...params.coinQuantities];
98
99
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -107,27 +108,31 @@ var addAmountToAsset = (params) => {
107
108
  // src/providers/provider.ts
108
109
  var import_address3 = require("@fuel-ts/address");
109
110
  var import_errors14 = require("@fuel-ts/errors");
110
- var import_math15 = require("@fuel-ts/math");
111
- var import_transactions18 = require("@fuel-ts/transactions");
112
- var import_utils23 = require("@fuel-ts/utils");
111
+ var import_math16 = require("@fuel-ts/math");
112
+ var import_transactions19 = require("@fuel-ts/transactions");
113
+ var import_utils22 = require("@fuel-ts/utils");
113
114
  var import_versions = require("@fuel-ts/versions");
114
- var import_utils24 = require("@noble/curves/abstract/utils");
115
+ var import_utils23 = require("@noble/curves/abstract/utils");
115
116
  var import_ethers = require("ethers");
116
117
  var import_graphql_request = require("graphql-request");
117
118
  var import_ramda3 = require("ramda");
118
119
 
119
120
  // src/providers/__generated__/operations.ts
120
121
  var import_graphql_tag = __toESM(require("graphql-tag"));
122
+ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
123
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
124
+ type: __typename
125
+ ... on SqueezedOutStatus {
126
+ reason
127
+ }
128
+ }
129
+ `;
121
130
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
122
131
  fragment receiptFragment on Receipt {
123
- contract {
124
- id
125
- }
132
+ id
126
133
  pc
127
134
  is
128
- to {
129
- id
130
- }
135
+ to
131
136
  toAddress
132
137
  amount
133
138
  assetId
@@ -165,10 +170,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
165
170
  id
166
171
  }
167
172
  time
173
+ receipts {
174
+ ...receiptFragment
175
+ }
168
176
  programState {
169
177
  returnType
170
178
  data
171
179
  }
180
+ receipts {
181
+ ...receiptFragment
182
+ }
172
183
  }
173
184
  ... on FailureStatus {
174
185
  block {
@@ -176,26 +187,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
176
187
  }
177
188
  time
178
189
  reason
190
+ receipts {
191
+ ...receiptFragment
192
+ }
179
193
  }
180
194
  ... on SqueezedOutStatus {
181
195
  reason
182
196
  }
183
197
  }
184
- `;
198
+ ${ReceiptFragmentFragmentDoc}`;
185
199
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
186
200
  fragment transactionFragment on Transaction {
187
201
  id
188
202
  rawPayload
189
- gasPrice
190
- receipts {
191
- ...receiptFragment
192
- }
193
203
  status {
194
204
  ...transactionStatusFragment
195
205
  }
196
206
  }
197
- ${ReceiptFragmentFragmentDoc}
198
- ${TransactionStatusFragmentFragmentDoc}`;
207
+ ${TransactionStatusFragmentFragmentDoc}`;
199
208
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
200
209
  fragment inputEstimatePredicatesFragment on Input {
201
210
  ... on InputCoin {
@@ -213,6 +222,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
213
222
  }
214
223
  }
215
224
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
225
+ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
226
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
227
+ reason
228
+ programState {
229
+ returnType
230
+ data
231
+ }
232
+ }
233
+ `;
234
+ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
235
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
236
+ programState {
237
+ returnType
238
+ data
239
+ }
240
+ }
241
+ `;
242
+ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
243
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
244
+ ... on DryRunFailureStatus {
245
+ ...dryRunFailureStatusFragment
246
+ }
247
+ ... on DryRunSuccessStatus {
248
+ ...dryRunSuccessStatusFragment
249
+ }
250
+ }
251
+ ${DryRunFailureStatusFragmentFragmentDoc}
252
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
253
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
254
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
255
+ id
256
+ status {
257
+ ...dryRunTransactionStatusFragment
258
+ }
259
+ receipts {
260
+ ...receiptFragment
261
+ }
262
+ }
263
+ ${DryRunTransactionStatusFragmentFragmentDoc}
264
+ ${ReceiptFragmentFragmentDoc}`;
216
265
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
217
266
  fragment coinFragment on Coin {
218
267
  __typename
@@ -220,7 +269,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
220
269
  owner
221
270
  amount
222
271
  assetId
223
- maturity
224
272
  blockCreated
225
273
  txCreatedIdx
226
274
  }
@@ -259,26 +307,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
259
307
  messageBlockHeader {
260
308
  id
261
309
  daHeight
310
+ consensusParametersVersion
311
+ stateTransitionBytecodeVersion
262
312
  transactionsCount
313
+ messageReceiptCount
263
314
  transactionsRoot
315
+ messageOutboxRoot
316
+ eventInboxRoot
264
317
  height
265
318
  prevRoot
266
319
  time
267
320
  applicationHash
268
- messageReceiptRoot
269
- messageReceiptCount
270
321
  }
271
322
  commitBlockHeader {
272
323
  id
273
324
  daHeight
325
+ consensusParametersVersion
326
+ stateTransitionBytecodeVersion
274
327
  transactionsCount
328
+ messageReceiptCount
275
329
  transactionsRoot
330
+ messageOutboxRoot
331
+ eventInboxRoot
276
332
  height
277
333
  prevRoot
278
334
  time
279
335
  applicationHash
280
- messageReceiptRoot
281
- messageReceiptCount
282
336
  }
283
337
  sender
284
338
  recipient
@@ -297,8 +351,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
297
351
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
298
352
  fragment blockFragment on Block {
299
353
  id
354
+ height
300
355
  header {
301
- height
302
356
  time
303
357
  }
304
358
  transactions {
@@ -308,6 +362,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
308
362
  `;
309
363
  var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
310
364
  fragment TxParametersFragment on TxParameters {
365
+ version
311
366
  maxInputs
312
367
  maxOutputs
313
368
  maxWitnesses
@@ -317,6 +372,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
317
372
  `;
318
373
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
319
374
  fragment PredicateParametersFragment on PredicateParameters {
375
+ version
320
376
  maxPredicateLength
321
377
  maxPredicateDataLength
322
378
  maxGasPerPredicate
@@ -325,18 +381,21 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
325
381
  `;
326
382
  var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
327
383
  fragment ScriptParametersFragment on ScriptParameters {
384
+ version
328
385
  maxScriptLength
329
386
  maxScriptDataLength
330
387
  }
331
388
  `;
332
389
  var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
333
390
  fragment ContractParametersFragment on ContractParameters {
391
+ version
334
392
  contractMaxSize
335
393
  maxStorageSlots
336
394
  }
337
395
  `;
338
396
  var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
339
397
  fragment FeeParametersFragment on FeeParameters {
398
+ version
340
399
  gasPriceFactor
341
400
  gasPerByte
342
401
  }
@@ -356,6 +415,7 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
356
415
  `;
357
416
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
358
417
  fragment GasCostsFragment on GasCosts {
418
+ version
359
419
  add
360
420
  addi
361
421
  aloc
@@ -368,7 +428,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
368
428
  cb
369
429
  cfei
370
430
  cfsi
371
- croo
372
431
  div
373
432
  divi
374
433
  ecr1
@@ -451,6 +510,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
451
510
  ccp {
452
511
  ...DependentCostFragment
453
512
  }
513
+ croo {
514
+ ...DependentCostFragment
515
+ }
454
516
  csiz {
455
517
  ...DependentCostFragment
456
518
  }
@@ -510,6 +572,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
510
572
  ${DependentCostFragmentFragmentDoc}`;
511
573
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
512
574
  fragment consensusParametersFragment on ConsensusParameters {
575
+ version
513
576
  txParams {
514
577
  ...TxParametersFragment
515
578
  }
@@ -569,18 +632,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
569
632
  fragment nodeInfoFragment on NodeInfo {
570
633
  utxoValidation
571
634
  vmBacktrace
572
- minGasPrice
573
635
  maxTx
574
636
  maxDepth
575
637
  nodeVersion
576
- peers {
577
- id
578
- addresses
579
- clientVersion
580
- blockHeight
581
- lastHeartbeatMs
582
- appScore
583
- }
584
638
  }
585
639
  `;
586
640
  var GetVersionDocument = import_graphql_tag.default`
@@ -615,13 +669,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
615
669
  query getTransactionWithReceipts($transactionId: TransactionId!) {
616
670
  transaction(id: $transactionId) {
617
671
  ...transactionFragment
618
- receipts {
619
- ...receiptFragment
620
- }
621
672
  }
622
673
  }
623
- ${TransactionFragmentFragmentDoc}
624
- ${ReceiptFragmentFragmentDoc}`;
674
+ ${TransactionFragmentFragmentDoc}`;
625
675
  var GetTransactionsDocument = import_graphql_tag.default`
626
676
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
627
677
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -749,6 +799,20 @@ var GetBalanceDocument = import_graphql_tag.default`
749
799
  }
750
800
  }
751
801
  ${BalanceFragmentFragmentDoc}`;
802
+ var GetLatestGasPriceDocument = import_graphql_tag.default`
803
+ query getLatestGasPrice {
804
+ latestGasPrice {
805
+ gasPrice
806
+ }
807
+ }
808
+ `;
809
+ var EstimateGasPriceDocument = import_graphql_tag.default`
810
+ query estimateGasPrice($blockHorizon: U32!) {
811
+ estimateGasPrice(blockHorizon: $blockHorizon) {
812
+ gasPrice
813
+ }
814
+ }
815
+ `;
752
816
  var GetBalancesDocument = import_graphql_tag.default`
753
817
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
754
818
  balances(
@@ -803,12 +867,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
803
867
  }
804
868
  `;
805
869
  var DryRunDocument = import_graphql_tag.default`
806
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
807
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
808
- ...receiptFragment
870
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
871
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
872
+ ...dryRunTransactionExecutionStatusFragment
809
873
  }
810
874
  }
811
- ${ReceiptFragmentFragmentDoc}`;
875
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
812
876
  var SubmitDocument = import_graphql_tag.default`
813
877
  mutation submit($encodedTransaction: HexString!) {
814
878
  submit(tx: $encodedTransaction) {
@@ -827,17 +891,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
827
891
  var SubmitAndAwaitDocument = import_graphql_tag.default`
828
892
  subscription submitAndAwait($encodedTransaction: HexString!) {
829
893
  submitAndAwait(tx: $encodedTransaction) {
830
- ...transactionStatusFragment
894
+ ...transactionStatusSubscriptionFragment
831
895
  }
832
896
  }
833
- ${TransactionStatusFragmentFragmentDoc}`;
897
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
834
898
  var StatusChangeDocument = import_graphql_tag.default`
835
899
  subscription statusChange($transactionId: TransactionId!) {
836
900
  statusChange(id: $transactionId) {
837
- ...transactionStatusFragment
901
+ ...transactionStatusSubscriptionFragment
838
902
  }
839
903
  }
840
- ${TransactionStatusFragmentFragmentDoc}`;
904
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
841
905
  function getSdk(requester) {
842
906
  return {
843
907
  getVersion(variables, options) {
@@ -891,6 +955,12 @@ function getSdk(requester) {
891
955
  getBalance(variables, options) {
892
956
  return requester(GetBalanceDocument, variables, options);
893
957
  },
958
+ getLatestGasPrice(variables, options) {
959
+ return requester(GetLatestGasPriceDocument, variables, options);
960
+ },
961
+ estimateGasPrice(variables, options) {
962
+ return requester(EstimateGasPriceDocument, variables, options);
963
+ },
894
964
  getBalances(variables, options) {
895
965
  return requester(GetBalancesDocument, variables, options);
896
966
  },
@@ -1084,10 +1154,9 @@ var inputify = (value) => {
1084
1154
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1085
1155
  },
1086
1156
  witnessIndex: value.witnessIndex,
1087
- maturity: value.maturity ?? 0,
1088
1157
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1089
- predicateLength: predicate.length,
1090
- predicateDataLength: predicateData.length,
1158
+ predicateLength: (0, import_math2.bn)(predicate.length),
1159
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1091
1160
  predicate: (0, import_utils3.hexlify)(predicate),
1092
1161
  predicateData: (0, import_utils3.hexlify)(predicateData)
1093
1162
  };
@@ -1118,8 +1187,8 @@ var inputify = (value) => {
1118
1187
  nonce: (0, import_utils3.hexlify)(value.nonce),
1119
1188
  witnessIndex: value.witnessIndex,
1120
1189
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1121
- predicateLength: predicate.length,
1122
- predicateDataLength: predicateData.length,
1190
+ predicateLength: (0, import_math2.bn)(predicate.length),
1191
+ predicateDataLength: (0, import_math2.bn)(predicateData.length),
1123
1192
  predicate: (0, import_utils3.hexlify)(predicate),
1124
1193
  predicateData: (0, import_utils3.hexlify)(predicateData),
1125
1194
  data: (0, import_utils3.hexlify)(data),
@@ -1235,8 +1304,8 @@ function assembleReceiptByType(receipt) {
1235
1304
  case "CALL" /* Call */: {
1236
1305
  const callReceipt = {
1237
1306
  type: import_transactions3.ReceiptType.Call,
1238
- from: hexOrZero(receipt.contract?.id),
1239
- to: hexOrZero(receipt?.to?.id),
1307
+ from: hexOrZero(receipt.id || receipt.contractId),
1308
+ to: hexOrZero(receipt?.to),
1240
1309
  amount: (0, import_math4.bn)(receipt.amount),
1241
1310
  assetId: hexOrZero(receipt.assetId),
1242
1311
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1250,7 +1319,7 @@ function assembleReceiptByType(receipt) {
1250
1319
  case "RETURN" /* Return */: {
1251
1320
  const returnReceipt = {
1252
1321
  type: import_transactions3.ReceiptType.Return,
1253
- id: hexOrZero(receipt.contract?.id),
1322
+ id: hexOrZero(receipt.id || receipt.contractId),
1254
1323
  val: (0, import_math4.bn)(receipt.val),
1255
1324
  pc: (0, import_math4.bn)(receipt.pc),
1256
1325
  is: (0, import_math4.bn)(receipt.is)
@@ -1260,7 +1329,7 @@ function assembleReceiptByType(receipt) {
1260
1329
  case "RETURN_DATA" /* ReturnData */: {
1261
1330
  const returnDataReceipt = {
1262
1331
  type: import_transactions3.ReceiptType.ReturnData,
1263
- id: hexOrZero(receipt.contract?.id),
1332
+ id: hexOrZero(receipt.id || receipt.contractId),
1264
1333
  ptr: (0, import_math4.bn)(receipt.ptr),
1265
1334
  len: (0, import_math4.bn)(receipt.len),
1266
1335
  digest: hexOrZero(receipt.digest),
@@ -1272,7 +1341,7 @@ function assembleReceiptByType(receipt) {
1272
1341
  case "PANIC" /* Panic */: {
1273
1342
  const panicReceipt = {
1274
1343
  type: import_transactions3.ReceiptType.Panic,
1275
- id: hexOrZero(receipt.contract?.id),
1344
+ id: hexOrZero(receipt.id),
1276
1345
  reason: (0, import_math4.bn)(receipt.reason),
1277
1346
  pc: (0, import_math4.bn)(receipt.pc),
1278
1347
  is: (0, import_math4.bn)(receipt.is),
@@ -1283,7 +1352,7 @@ function assembleReceiptByType(receipt) {
1283
1352
  case "REVERT" /* Revert */: {
1284
1353
  const revertReceipt = {
1285
1354
  type: import_transactions3.ReceiptType.Revert,
1286
- id: hexOrZero(receipt.contract?.id),
1355
+ id: hexOrZero(receipt.id || receipt.contractId),
1287
1356
  val: (0, import_math4.bn)(receipt.ra),
1288
1357
  pc: (0, import_math4.bn)(receipt.pc),
1289
1358
  is: (0, import_math4.bn)(receipt.is)
@@ -1293,7 +1362,7 @@ function assembleReceiptByType(receipt) {
1293
1362
  case "LOG" /* Log */: {
1294
1363
  const logReceipt = {
1295
1364
  type: import_transactions3.ReceiptType.Log,
1296
- id: hexOrZero(receipt.contract?.id),
1365
+ id: hexOrZero(receipt.id || receipt.contractId),
1297
1366
  val0: (0, import_math4.bn)(receipt.ra),
1298
1367
  val1: (0, import_math4.bn)(receipt.rb),
1299
1368
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1306,7 +1375,7 @@ function assembleReceiptByType(receipt) {
1306
1375
  case "LOG_DATA" /* LogData */: {
1307
1376
  const logDataReceipt = {
1308
1377
  type: import_transactions3.ReceiptType.LogData,
1309
- id: hexOrZero(receipt.contract?.id),
1378
+ id: hexOrZero(receipt.id || receipt.contractId),
1310
1379
  val0: (0, import_math4.bn)(receipt.ra),
1311
1380
  val1: (0, import_math4.bn)(receipt.rb),
1312
1381
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1320,8 +1389,8 @@ function assembleReceiptByType(receipt) {
1320
1389
  case "TRANSFER" /* Transfer */: {
1321
1390
  const transferReceipt = {
1322
1391
  type: import_transactions3.ReceiptType.Transfer,
1323
- from: hexOrZero(receipt.contract?.id),
1324
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1392
+ from: hexOrZero(receipt.id || receipt.contractId),
1393
+ to: hexOrZero(receipt.toAddress || receipt?.to),
1325
1394
  amount: (0, import_math4.bn)(receipt.amount),
1326
1395
  assetId: hexOrZero(receipt.assetId),
1327
1396
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1332,8 +1401,8 @@ function assembleReceiptByType(receipt) {
1332
1401
  case "TRANSFER_OUT" /* TransferOut */: {
1333
1402
  const transferOutReceipt = {
1334
1403
  type: import_transactions3.ReceiptType.TransferOut,
1335
- from: hexOrZero(receipt.contract?.id),
1336
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
1404
+ from: hexOrZero(receipt.id || receipt.contractId),
1405
+ to: hexOrZero(receipt.toAddress || receipt.to),
1337
1406
  amount: (0, import_math4.bn)(receipt.amount),
1338
1407
  assetId: hexOrZero(receipt.assetId),
1339
1408
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1376,7 +1445,7 @@ function assembleReceiptByType(receipt) {
1376
1445
  return receiptMessageOut;
1377
1446
  }
1378
1447
  case "MINT" /* Mint */: {
1379
- const contractId = hexOrZero(receipt.contract?.id);
1448
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1380
1449
  const subId = hexOrZero(receipt.subId);
1381
1450
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1382
1451
  const mintReceipt = {
@@ -1391,7 +1460,7 @@ function assembleReceiptByType(receipt) {
1391
1460
  return mintReceipt;
1392
1461
  }
1393
1462
  case "BURN" /* Burn */: {
1394
- const contractId = hexOrZero(receipt.contract?.id);
1463
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
1395
1464
  const subId = hexOrZero(receipt.subId);
1396
1465
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1397
1466
  const burnReceipt = {
@@ -1417,7 +1486,6 @@ var import_errors6 = require("@fuel-ts/errors");
1417
1486
  var import_math5 = require("@fuel-ts/math");
1418
1487
  var import_transactions4 = require("@fuel-ts/transactions");
1419
1488
  var import_utils6 = require("@fuel-ts/utils");
1420
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1421
1489
  var getGasUsedFromReceipts = (receipts) => {
1422
1490
  const scriptResult = receipts.filter(
1423
1491
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1438,18 +1506,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1438
1506
  }
1439
1507
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1440
1508
  const witnessCache = [];
1441
- const totalGas = inputs.reduce((total, input) => {
1509
+ const chargeableInputs = inputs.filter((input) => {
1510
+ const isCoinOrMessage = "owner" in input || "sender" in input;
1511
+ if (isCoinOrMessage) {
1512
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1513
+ return true;
1514
+ }
1515
+ if (!witnessCache.includes(input.witnessIndex)) {
1516
+ witnessCache.push(input.witnessIndex);
1517
+ return true;
1518
+ }
1519
+ }
1520
+ return false;
1521
+ });
1522
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1523
+ const totalGas = chargeableInputs.reduce((total, input) => {
1442
1524
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1443
1525
  return total.add(
1444
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1526
+ vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1445
1527
  );
1446
1528
  }
1447
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
1448
- witnessCache.push(input.witnessIndex);
1449
- return total.add(gasCosts.ecr1);
1450
- }
1451
- return total;
1452
- }, (0, import_math5.bn)());
1529
+ return total.add(gasCosts.ecr1);
1530
+ }, (0, import_math5.bn)(0));
1453
1531
  return totalGas;
1454
1532
  }
1455
1533
  function getMinGas(params) {
@@ -1461,12 +1539,20 @@ function getMinGas(params) {
1461
1539
  return minGas;
1462
1540
  }
1463
1541
  function getMaxGas(params) {
1464
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1542
+ const {
1543
+ gasPerByte,
1544
+ witnessesLength,
1545
+ witnessLimit,
1546
+ minGas,
1547
+ gasLimit = (0, import_math5.bn)(0),
1548
+ maxGasPerTx
1549
+ } = params;
1465
1550
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1466
1551
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1467
1552
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1468
1553
  }
1469
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1554
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1555
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1470
1556
  }
1471
1557
  function calculateMetadataGasForTxCreate({
1472
1558
  gasCosts,
@@ -1488,6 +1574,10 @@ function calculateMetadataGasForTxScript({
1488
1574
  }) {
1489
1575
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1490
1576
  }
1577
+ var calculateGasFee = (params) => {
1578
+ const { gas, gasPrice, priceFactor, tip } = params;
1579
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
1580
+ };
1491
1581
 
1492
1582
  // src/providers/utils/json.ts
1493
1583
  var import_utils7 = require("@fuel-ts/utils");
@@ -1624,7 +1714,7 @@ var witnessify = (value) => {
1624
1714
  // src/providers/transaction-request/transaction-request.ts
1625
1715
  var BaseTransactionRequest = class {
1626
1716
  /** Gas price for transaction */
1627
- gasPrice;
1717
+ tip;
1628
1718
  /** Block until which tx cannot be included */
1629
1719
  maturity;
1630
1720
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1643,7 +1733,7 @@ var BaseTransactionRequest = class {
1643
1733
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1644
1734
  */
1645
1735
  constructor({
1646
- gasPrice,
1736
+ tip,
1647
1737
  maturity,
1648
1738
  maxFee,
1649
1739
  witnessLimit,
@@ -1651,7 +1741,7 @@ var BaseTransactionRequest = class {
1651
1741
  outputs,
1652
1742
  witnesses
1653
1743
  } = {}) {
1654
- this.gasPrice = (0, import_math7.bn)(gasPrice);
1744
+ this.tip = (0, import_math7.bn)(tip);
1655
1745
  this.maturity = maturity ?? 0;
1656
1746
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1657
1747
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1662,9 +1752,9 @@ var BaseTransactionRequest = class {
1662
1752
  static getPolicyMeta(req) {
1663
1753
  let policyTypes = 0;
1664
1754
  const policies = [];
1665
- if (req.gasPrice) {
1666
- policyTypes += import_transactions6.PolicyType.GasPrice;
1667
- policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1755
+ if (req.tip) {
1756
+ policyTypes += import_transactions6.PolicyType.Tip;
1757
+ policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1668
1758
  }
1669
1759
  if (req.witnessLimit) {
1670
1760
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1848,13 +1938,11 @@ var BaseTransactionRequest = class {
1848
1938
  * assetId, if one it was not added yet.
1849
1939
  *
1850
1940
  * @param coin - Coin resource.
1851
- * @param predicate - Predicate bytes.
1852
- * @param predicateData - Predicate data bytes.
1853
1941
  */
1854
- addCoinInput(coin, predicate) {
1942
+ addCoinInput(coin) {
1855
1943
  const { assetId, owner, amount } = coin;
1856
1944
  let witnessIndex;
1857
- if (predicate) {
1945
+ if (coin.predicate) {
1858
1946
  witnessIndex = 0;
1859
1947
  } else {
1860
1948
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1869,8 +1957,7 @@ var BaseTransactionRequest = class {
1869
1957
  amount,
1870
1958
  assetId,
1871
1959
  txPointer: "0x00000000000000000000000000000000",
1872
- witnessIndex,
1873
- predicate: predicate?.bytes
1960
+ witnessIndex
1874
1961
  };
1875
1962
  this.pushInput(input);
1876
1963
  this.addChangeOutput(owner, assetId);
@@ -1880,14 +1967,12 @@ var BaseTransactionRequest = class {
1880
1967
  * baseAssetId, if one it was not added yet.
1881
1968
  *
1882
1969
  * @param message - Message resource.
1883
- * @param predicate - Predicate bytes.
1884
- * @param predicateData - Predicate data bytes.
1885
1970
  */
1886
- addMessageInput(message, predicate) {
1971
+ addMessageInput(message) {
1887
1972
  const { recipient, sender, amount } = message;
1888
1973
  const assetId = import_configs7.BaseAssetId;
1889
1974
  let witnessIndex;
1890
- if (predicate) {
1975
+ if (message.predicate) {
1891
1976
  witnessIndex = 0;
1892
1977
  } else {
1893
1978
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -1901,8 +1986,7 @@ var BaseTransactionRequest = class {
1901
1986
  sender: sender.toB256(),
1902
1987
  recipient: recipient.toB256(),
1903
1988
  amount,
1904
- witnessIndex,
1905
- predicate: predicate?.bytes
1989
+ witnessIndex
1906
1990
  };
1907
1991
  this.pushInput(input);
1908
1992
  this.addChangeOutput(recipient, assetId);
@@ -1933,32 +2017,6 @@ var BaseTransactionRequest = class {
1933
2017
  resources.forEach((resource) => this.addResource(resource));
1934
2018
  return this;
1935
2019
  }
1936
- /**
1937
- * Adds multiple resources to the transaction by adding coin/message inputs and change
1938
- * outputs from the related assetIds.
1939
- *
1940
- * @param resources - The resources to add.
1941
- * @returns This transaction.
1942
- */
1943
- addPredicateResource(resource, predicate) {
1944
- if (isCoin(resource)) {
1945
- this.addCoinInput(resource, predicate);
1946
- } else {
1947
- this.addMessageInput(resource, predicate);
1948
- }
1949
- return this;
1950
- }
1951
- /**
1952
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
1953
- * from the related assetIds.
1954
- *
1955
- * @param resources - The resources to add.
1956
- * @returns This transaction.
1957
- */
1958
- addPredicateResources(resources, predicate) {
1959
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
1960
- return this;
1961
- }
1962
2020
  /**
1963
2021
  * Adds a coin output to the transaction.
1964
2022
  *
@@ -2038,7 +2096,7 @@ var BaseTransactionRequest = class {
2038
2096
  }
2039
2097
  calculateMaxGas(chainInfo, minGas) {
2040
2098
  const { consensusParameters } = chainInfo;
2041
- const { gasPerByte } = consensusParameters;
2099
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2042
2100
  const witnessesLength = this.toTransaction().witnesses.reduce(
2043
2101
  (acc, wit) => acc + wit.dataLength,
2044
2102
  0
@@ -2047,7 +2105,8 @@ var BaseTransactionRequest = class {
2047
2105
  gasPerByte,
2048
2106
  minGas,
2049
2107
  witnessesLength,
2050
- witnessLimit: this.witnessLimit
2108
+ witnessLimit: this.witnessLimit,
2109
+ maxGasPerTx
2051
2110
  });
2052
2111
  }
2053
2112
  /**
@@ -2065,17 +2124,20 @@ var BaseTransactionRequest = class {
2065
2124
  });
2066
2125
  const updateAssetInput = (assetId, quantity) => {
2067
2126
  const assetInput = findAssetInput(assetId);
2127
+ let usedQuantity = quantity;
2128
+ if (assetId === import_configs7.BaseAssetId) {
2129
+ usedQuantity = (0, import_math7.bn)("1000000000000000000");
2130
+ }
2068
2131
  if (assetInput && "assetId" in assetInput) {
2069
2132
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2070
- assetInput.amount = quantity;
2133
+ assetInput.amount = usedQuantity;
2071
2134
  } else {
2072
2135
  this.addResources([
2073
2136
  {
2074
2137
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2075
- amount: quantity,
2138
+ amount: usedQuantity,
2076
2139
  assetId,
2077
2140
  owner: resourcesOwner || import_address.Address.fromRandom(),
2078
- maturity: 0,
2079
2141
  blockCreated: (0, import_math7.bn)(1),
2080
2142
  txCreatedIdx: (0, import_math7.bn)(1)
2081
2143
  }
@@ -2107,7 +2169,7 @@ var BaseTransactionRequest = class {
2107
2169
  toJSON() {
2108
2170
  return normalizeJSON(this);
2109
2171
  }
2110
- updatePredicateInputs(inputs) {
2172
+ updatePredicateGasUsed(inputs) {
2111
2173
  this.inputs.forEach((i) => {
2112
2174
  let correspondingInput;
2113
2175
  switch (i.type) {
@@ -2129,6 +2191,15 @@ var BaseTransactionRequest = class {
2129
2191
  }
2130
2192
  });
2131
2193
  }
2194
+ shiftPredicateData() {
2195
+ this.inputs.forEach((input) => {
2196
+ if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2197
+ input.predicateData = input.padPredicateData(
2198
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2199
+ );
2200
+ }
2201
+ });
2202
+ }
2132
2203
  };
2133
2204
 
2134
2205
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2275,9 +2346,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2275
2346
  return {
2276
2347
  type: import_transactions8.TransactionType.Create,
2277
2348
  ...baseTransaction,
2278
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2279
2349
  bytecodeWitnessIndex,
2280
- storageSlotsCount: storageSlots.length,
2350
+ storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2281
2351
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2282
2352
  storageSlots
2283
2353
  };
@@ -2400,8 +2470,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2400
2470
  type: import_transactions9.TransactionType.Script,
2401
2471
  scriptGasLimit: this.gasLimit,
2402
2472
  ...super.getBaseTransaction(),
2403
- scriptLength: script.length,
2404
- scriptDataLength: scriptData.length,
2473
+ scriptLength: (0, import_math10.bn)(script.length),
2474
+ scriptDataLength: (0, import_math10.bn)(scriptData.length),
2405
2475
  receiptsRoot: import_configs10.ZeroBytes32,
2406
2476
  script: (0, import_utils15.hexlify)(script),
2407
2477
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2465,7 +2535,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2465
2535
  }
2466
2536
  calculateMaxGas(chainInfo, minGas) {
2467
2537
  const { consensusParameters } = chainInfo;
2468
- const { gasPerByte } = consensusParameters;
2538
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
2469
2539
  const witnessesLength = this.toTransaction().witnesses.reduce(
2470
2540
  (acc, wit) => acc + wit.dataLength,
2471
2541
  0
@@ -2475,7 +2545,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2475
2545
  minGas,
2476
2546
  witnessesLength,
2477
2547
  witnessLimit: this.witnessLimit,
2478
- gasLimit: this.gasLimit
2548
+ gasLimit: this.gasLimit,
2549
+ maxGasPerTx
2479
2550
  });
2480
2551
  }
2481
2552
  /**
@@ -2550,15 +2621,32 @@ var transactionRequestify = (obj) => {
2550
2621
  }
2551
2622
  }
2552
2623
  };
2624
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2625
+ (acc, input) => {
2626
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2627
+ acc.utxos.push(input.id);
2628
+ }
2629
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2630
+ acc.messages.push(input.nonce);
2631
+ }
2632
+ return acc;
2633
+ },
2634
+ {
2635
+ utxos: [],
2636
+ messages: []
2637
+ }
2638
+ );
2553
2639
 
2554
2640
  // src/providers/transaction-response/transaction-response.ts
2555
2641
  var import_errors13 = require("@fuel-ts/errors");
2556
- var import_math14 = require("@fuel-ts/math");
2557
- var import_transactions17 = require("@fuel-ts/transactions");
2558
- var import_utils21 = require("@fuel-ts/utils");
2642
+ var import_math15 = require("@fuel-ts/math");
2643
+ var import_transactions18 = require("@fuel-ts/transactions");
2644
+ var import_utils20 = require("@fuel-ts/utils");
2559
2645
 
2560
2646
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2561
- var import_utils19 = require("@fuel-ts/utils");
2647
+ var import_math14 = require("@fuel-ts/math");
2648
+ var import_transactions16 = require("@fuel-ts/transactions");
2649
+ var import_utils18 = require("@fuel-ts/utils");
2562
2650
 
2563
2651
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2564
2652
  var import_math11 = require("@fuel-ts/math");
@@ -2566,9 +2654,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
2566
2654
  var import_utils16 = require("@fuel-ts/utils");
2567
2655
  var calculateTransactionFee = (params) => {
2568
2656
  const {
2569
- gasUsed,
2657
+ gasPrice,
2570
2658
  rawPayload,
2571
- consensusParameters: { gasCosts, feeParams }
2659
+ tip,
2660
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2572
2661
  } = params;
2573
2662
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2574
2663
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2578,8 +2667,7 @@ var calculateTransactionFee = (params) => {
2578
2667
  return {
2579
2668
  fee: (0, import_math11.bn)(0),
2580
2669
  minFee: (0, import_math11.bn)(0),
2581
- maxFee: (0, import_math11.bn)(0),
2582
- feeFromGasUsed: (0, import_math11.bn)(0)
2670
+ maxFee: (0, import_math11.bn)(0)
2583
2671
  };
2584
2672
  }
2585
2673
  const { type, witnesses, inputs, policies } = transaction;
@@ -2611,7 +2699,6 @@ var calculateTransactionFee = (params) => {
2611
2699
  metadataGas,
2612
2700
  txBytesSize: transactionBytes.length
2613
2701
  });
2614
- const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2615
2702
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2616
2703
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2617
2704
  const maxGas = getMaxGas({
@@ -2619,17 +2706,25 @@ var calculateTransactionFee = (params) => {
2619
2706
  minGas,
2620
2707
  witnessesLength,
2621
2708
  gasLimit,
2622
- witnessLimit
2709
+ witnessLimit,
2710
+ maxGasPerTx
2711
+ });
2712
+ const minFee = calculateGasFee({
2713
+ gasPrice,
2714
+ gas: minGas,
2715
+ priceFactor: gasPriceFactor,
2716
+ tip
2717
+ });
2718
+ const maxFee = calculateGasFee({
2719
+ gasPrice,
2720
+ gas: maxGas,
2721
+ priceFactor: gasPriceFactor,
2722
+ tip
2623
2723
  });
2624
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
2625
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
2626
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
2627
- const fee = minFee.add(feeFromGasUsed);
2628
2724
  return {
2629
- fee,
2630
2725
  minFee,
2631
2726
  maxFee,
2632
- feeFromGasUsed
2727
+ fee: maxFee
2633
2728
  };
2634
2729
  };
2635
2730
 
@@ -3196,10 +3291,12 @@ function assembleTransactionSummary(params) {
3196
3291
  gqlTransactionStatus,
3197
3292
  abiMap = {},
3198
3293
  maxInputs,
3199
- gasCosts
3294
+ gasCosts,
3295
+ maxGasPerTx,
3296
+ gasPrice
3200
3297
  } = params;
3201
3298
  const gasUsed = getGasUsedFromReceipts(receipts);
3202
- const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3299
+ const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3203
3300
  const operations = getOperations({
3204
3301
  transactionType: transaction.type,
3205
3302
  inputs: transaction.inputs || [],
@@ -3210,11 +3307,14 @@ function assembleTransactionSummary(params) {
3210
3307
  maxInputs
3211
3308
  });
3212
3309
  const typeName = getTransactionTypeName(transaction.type);
3310
+ const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3213
3311
  const { fee } = calculateTransactionFee({
3214
- gasUsed,
3312
+ gasPrice,
3215
3313
  rawPayload,
3314
+ tip,
3216
3315
  consensusParameters: {
3217
3316
  gasCosts,
3317
+ maxGasPerTx,
3218
3318
  feeParams: {
3219
3319
  gasPerByte,
3220
3320
  gasPriceFactor
@@ -3226,7 +3326,7 @@ function assembleTransactionSummary(params) {
3226
3326
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3227
3327
  let date;
3228
3328
  if (time) {
3229
- date = import_utils19.DateTime.fromTai64(time);
3329
+ date = import_utils18.DateTime.fromTai64(time);
3230
3330
  }
3231
3331
  const transactionSummary = {
3232
3332
  id,
@@ -3254,12 +3354,12 @@ function assembleTransactionSummary(params) {
3254
3354
 
3255
3355
  // src/providers/transaction-response/getDecodedLogs.ts
3256
3356
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3257
- var import_transactions16 = require("@fuel-ts/transactions");
3357
+ var import_transactions17 = require("@fuel-ts/transactions");
3258
3358
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3259
3359
  return receipts.reduce((logs, receipt) => {
3260
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3360
+ if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3261
3361
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3262
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3362
+ const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3263
3363
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3264
3364
  logs.push(decodedLog);
3265
3365
  }
@@ -3274,7 +3374,7 @@ var TransactionResponse = class {
3274
3374
  /** Current provider */
3275
3375
  provider;
3276
3376
  /** Gas used on the transaction */
3277
- gasUsed = (0, import_math14.bn)(0);
3377
+ gasUsed = (0, import_math15.bn)(0);
3278
3378
  /** The graphql Transaction with receipts object. */
3279
3379
  gqlTransaction;
3280
3380
  abis;
@@ -3332,8 +3432,8 @@ var TransactionResponse = class {
3332
3432
  * @returns The decoded transaction.
3333
3433
  */
3334
3434
  decodeTransaction(transactionWithReceipts) {
3335
- return new import_transactions17.TransactionCoder().decode(
3336
- (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3435
+ return new import_transactions18.TransactionCoder().decode(
3436
+ (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3337
3437
  0
3338
3438
  )?.[0];
3339
3439
  }
@@ -3352,20 +3452,27 @@ var TransactionResponse = class {
3352
3452
  const decodedTransaction = this.decodeTransaction(
3353
3453
  transaction
3354
3454
  );
3355
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3356
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3455
+ let txReceipts = [];
3456
+ if (transaction?.status && "receipts" in transaction.status) {
3457
+ txReceipts = transaction.status.receipts;
3458
+ }
3459
+ const receipts = txReceipts.map(processGqlReceipt) || [];
3460
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3461
+ const gasPrice = await this.provider.getLatestGasPrice();
3357
3462
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3358
3463
  const transactionSummary = assembleTransactionSummary({
3359
3464
  id: this.id,
3360
3465
  receipts,
3361
3466
  transaction: decodedTransaction,
3362
- transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3467
+ transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3363
3468
  gqlTransactionStatus: transaction.status,
3364
3469
  gasPerByte,
3365
3470
  gasPriceFactor,
3366
3471
  abiMap: contractsAbiMap,
3367
3472
  maxInputs,
3368
- gasCosts
3473
+ gasCosts,
3474
+ maxGasPerTx,
3475
+ gasPrice
3369
3476
  });
3370
3477
  return transactionSummary;
3371
3478
  }
@@ -3492,29 +3599,29 @@ var processGqlChain = (chain) => {
3492
3599
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3493
3600
  return {
3494
3601
  name,
3495
- baseChainHeight: (0, import_math15.bn)(daHeight),
3602
+ baseChainHeight: (0, import_math16.bn)(daHeight),
3496
3603
  consensusParameters: {
3497
- contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3498
- maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3499
- maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3500
- maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3501
- maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3502
- maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3503
- maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3504
- maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3505
- maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3506
- maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3507
- maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3508
- gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3509
- gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3510
- maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3511
- chainId: (0, import_math15.bn)(consensusParameters.chainId),
3604
+ contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3605
+ maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3606
+ maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3607
+ maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3608
+ maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3609
+ maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3610
+ maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3611
+ maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3612
+ maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3613
+ maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3614
+ maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3615
+ gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3616
+ gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3617
+ maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3618
+ chainId: (0, import_math16.bn)(consensusParameters.chainId),
3512
3619
  gasCosts
3513
3620
  },
3514
3621
  gasCosts,
3515
3622
  latestBlock: {
3516
3623
  id: latestBlock.id,
3517
- height: (0, import_math15.bn)(latestBlock.header.height),
3624
+ height: (0, import_math16.bn)(latestBlock.height),
3518
3625
  time: latestBlock.header.time,
3519
3626
  transactions: latestBlock.transactions.map((i) => ({
3520
3627
  id: i.id
@@ -3608,10 +3715,8 @@ var _Provider = class {
3608
3715
  * Returns some helpful parameters related to gas fees.
3609
3716
  */
3610
3717
  getGasConfig() {
3611
- const { minGasPrice } = this.getNode();
3612
3718
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3613
3719
  return {
3614
- minGasPrice,
3615
3720
  maxGasPerTx,
3616
3721
  maxGasPerPredicate,
3617
3722
  gasPriceFactor,
@@ -3709,7 +3814,7 @@ var _Provider = class {
3709
3814
  */
3710
3815
  async getBlockNumber() {
3711
3816
  const { chain } = await this.operations.getChain();
3712
- return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3817
+ return (0, import_math16.bn)(chain.latestBlock.height, 10);
3713
3818
  }
3714
3819
  /**
3715
3820
  * Returns the chain information.
@@ -3719,13 +3824,11 @@ var _Provider = class {
3719
3824
  async fetchNode() {
3720
3825
  const { nodeInfo } = await this.operations.getNodeInfo();
3721
3826
  const processedNodeInfo = {
3722
- maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3723
- maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3724
- minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3827
+ maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3828
+ maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3725
3829
  nodeVersion: nodeInfo.nodeVersion,
3726
3830
  utxoValidation: nodeInfo.utxoValidation,
3727
- vmBacktrace: nodeInfo.vmBacktrace,
3728
- peers: nodeInfo.peers
3831
+ vmBacktrace: nodeInfo.vmBacktrace
3729
3832
  };
3730
3833
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3731
3834
  return processedNodeInfo;
@@ -3767,9 +3870,9 @@ var _Provider = class {
3767
3870
  if (estimateTxDependencies) {
3768
3871
  await this.estimateTxDependencies(transactionRequest);
3769
3872
  }
3770
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3873
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3771
3874
  let abis;
3772
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3875
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3773
3876
  abis = transactionRequest.abis;
3774
3877
  }
3775
3878
  if (awaitExecution) {
@@ -3810,15 +3913,14 @@ var _Provider = class {
3810
3913
  if (estimateTxDependencies) {
3811
3914
  return this.estimateTxDependencies(transactionRequest);
3812
3915
  }
3813
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3814
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3815
- encodedTransaction,
3916
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3917
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3918
+ encodedTransactions: encodedTransaction,
3816
3919
  utxoValidation: utxoValidation || false
3817
3920
  });
3818
- const receipts = gqlReceipts.map(processGqlReceipt);
3819
- return {
3820
- receipts
3821
- };
3921
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3922
+ const receipts = rawReceipts.map(processGqlReceipt);
3923
+ return { receipts, dryrunStatus: status };
3822
3924
  }
3823
3925
  /**
3824
3926
  * Verifies whether enough gas is available to complete transaction.
@@ -3829,13 +3931,13 @@ var _Provider = class {
3829
3931
  async estimatePredicates(transactionRequest) {
3830
3932
  const shouldEstimatePredicates = Boolean(
3831
3933
  transactionRequest.inputs.find(
3832
- (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()
3934
+ (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()
3833
3935
  )
3834
3936
  );
3835
3937
  if (!shouldEstimatePredicates) {
3836
3938
  return transactionRequest;
3837
3939
  }
3838
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3940
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3839
3941
  const response = await this.operations.estimatePredicates({
3840
3942
  encodedTransaction
3841
3943
  });
@@ -3844,7 +3946,7 @@ var _Provider = class {
3844
3946
  } = response;
3845
3947
  if (inputs) {
3846
3948
  inputs.forEach((input, index) => {
3847
- if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3949
+ if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3848
3950
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3849
3951
  }
3850
3952
  });
@@ -3857,31 +3959,31 @@ var _Provider = class {
3857
3959
  * If there are missing variable outputs,
3858
3960
  * `addVariableOutputs` is called on the transaction.
3859
3961
  *
3860
- * @privateRemarks
3861
- * TODO: Investigate support for missing contract IDs
3862
- * TODO: Add support for missing output messages
3863
3962
  *
3864
3963
  * @param transactionRequest - The transaction request object.
3865
3964
  * @returns A promise.
3866
3965
  */
3867
3966
  async estimateTxDependencies(transactionRequest) {
3868
- if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3967
+ if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3869
3968
  return {
3870
3969
  receipts: [],
3871
3970
  outputVariables: 0,
3872
3971
  missingContractIds: []
3873
3972
  };
3874
3973
  }
3875
- await this.estimatePredicates(transactionRequest);
3876
3974
  let receipts = [];
3877
3975
  const missingContractIds = [];
3878
3976
  let outputVariables = 0;
3977
+ let dryrunStatus;
3879
3978
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3880
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3881
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3979
+ const {
3980
+ dryRun: [{ receipts: rawReceipts, status }]
3981
+ } = await this.operations.dryRun({
3982
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3882
3983
  utxoValidation: false
3883
3984
  });
3884
- receipts = gqlReceipts.map(processGqlReceipt);
3985
+ receipts = rawReceipts.map(processGqlReceipt);
3986
+ dryrunStatus = status;
3885
3987
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3886
3988
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3887
3989
  if (hasMissingOutputs) {
@@ -3891,6 +3993,10 @@ var _Provider = class {
3891
3993
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3892
3994
  missingContractIds.push(contractId);
3893
3995
  });
3996
+ const { maxFee } = await this.estimateTxGasAndFee({
3997
+ transactionRequest
3998
+ });
3999
+ transactionRequest.maxFee = maxFee;
3894
4000
  } else {
3895
4001
  break;
3896
4002
  }
@@ -3898,37 +4004,136 @@ var _Provider = class {
3898
4004
  return {
3899
4005
  receipts,
3900
4006
  outputVariables,
3901
- missingContractIds
4007
+ missingContractIds,
4008
+ dryrunStatus
3902
4009
  };
3903
4010
  }
4011
+ /**
4012
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
4013
+ *
4014
+ * Transactions are dry run in batches. After each dry run, transactions requiring
4015
+ * further modifications are identified. The method iteratively updates these transactions
4016
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4017
+ *
4018
+ * @param transactionRequests - Array of transaction request objects.
4019
+ * @returns A promise that resolves to an array of results for each transaction.
4020
+ */
4021
+ async estimateMultipleTxDependencies(transactionRequests) {
4022
+ const results = transactionRequests.map(() => ({
4023
+ receipts: [],
4024
+ outputVariables: 0,
4025
+ missingContractIds: [],
4026
+ dryrunStatus: void 0
4027
+ }));
4028
+ const allRequests = (0, import_ramda3.clone)(transactionRequests);
4029
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
4030
+ allRequests.forEach((req, index) => {
4031
+ if (req.type === import_transactions19.TransactionType.Script) {
4032
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4033
+ }
4034
+ });
4035
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4036
+ let attempt = 0;
4037
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4038
+ const encodedTransactions = transactionsToProcess.map(
4039
+ (index) => serializedTransactionsMap.get(index)
4040
+ );
4041
+ const dryRunResults = await this.operations.dryRun({
4042
+ encodedTransactions,
4043
+ utxoValidation: false
4044
+ });
4045
+ const nextRoundTransactions = [];
4046
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4047
+ const requestIdx = transactionsToProcess[i];
4048
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4049
+ const result = results[requestIdx];
4050
+ result.receipts = rawReceipts.map(processGqlReceipt);
4051
+ result.dryrunStatus = status;
4052
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4053
+ result.receipts
4054
+ );
4055
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4056
+ const request = allRequests[requestIdx];
4057
+ if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
4058
+ result.outputVariables += missingOutputVariables.length;
4059
+ request.addVariableOutputs(missingOutputVariables.length);
4060
+ missingOutputContractIds.forEach(({ contractId }) => {
4061
+ request.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4062
+ result.missingContractIds.push(contractId);
4063
+ });
4064
+ const { maxFee } = await this.estimateTxGasAndFee({
4065
+ transactionRequest: request
4066
+ });
4067
+ request.maxFee = maxFee;
4068
+ serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4069
+ nextRoundTransactions.push(requestIdx);
4070
+ }
4071
+ }
4072
+ transactionsToProcess = nextRoundTransactions;
4073
+ attempt += 1;
4074
+ }
4075
+ return results;
4076
+ }
4077
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4078
+ if (estimateTxDependencies) {
4079
+ return this.estimateMultipleTxDependencies(transactionRequests);
4080
+ }
4081
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4082
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4083
+ encodedTransactions,
4084
+ utxoValidation: utxoValidation || false
4085
+ });
4086
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4087
+ const receipts = rawReceipts.map(processGqlReceipt);
4088
+ return { receipts, dryrunStatus: status };
4089
+ });
4090
+ return results;
4091
+ }
3904
4092
  /**
3905
4093
  * Estimates the transaction gas and fee based on the provided transaction request.
3906
4094
  * @param transactionRequest - The transaction request object.
3907
4095
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3908
4096
  */
3909
- estimateTxGasAndFee(params) {
4097
+ async estimateTxGasAndFee(params) {
3910
4098
  const { transactionRequest } = params;
3911
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4099
+ let { gasPrice } = params;
3912
4100
  const chainInfo = this.getChain();
3913
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3914
- transactionRequest.gasPrice = gasPrice;
4101
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3915
4102
  const minGas = transactionRequest.calculateMinGas(chainInfo);
3916
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3917
- if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4103
+ if (!gasPrice) {
4104
+ gasPrice = await this.estimateGasPrice(10);
4105
+ }
4106
+ const minFee = calculateGasFee({
4107
+ gasPrice: (0, import_math16.bn)(gasPrice),
4108
+ gas: minGas,
4109
+ priceFactor: gasPriceFactor,
4110
+ tip: transactionRequest.tip
4111
+ }).add(1);
4112
+ let gasLimit = (0, import_math16.bn)(0);
4113
+ if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4114
+ gasLimit = transactionRequest.gasLimit;
3918
4115
  if (transactionRequest.gasLimit.eq(0)) {
3919
4116
  transactionRequest.gasLimit = minGas;
3920
4117
  transactionRequest.gasLimit = maxGasPerTx.sub(
3921
4118
  transactionRequest.calculateMaxGas(chainInfo, minGas)
3922
4119
  );
4120
+ gasLimit = transactionRequest.gasLimit;
3923
4121
  }
3924
4122
  }
3925
4123
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3926
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4124
+ const maxFee = calculateGasFee({
4125
+ gasPrice: (0, import_math16.bn)(gasPrice),
4126
+ gas: maxGas,
4127
+ priceFactor: gasPriceFactor,
4128
+ tip: transactionRequest.tip
4129
+ }).add(1);
3927
4130
  return {
3928
4131
  minGas,
3929
4132
  minFee,
3930
4133
  maxGas,
3931
- maxFee
4134
+ maxFee,
4135
+ gasPrice,
4136
+ gasLimit
3932
4137
  };
3933
4138
  }
3934
4139
  /**
@@ -3946,15 +4151,17 @@ var _Provider = class {
3946
4151
  if (estimateTxDependencies) {
3947
4152
  return this.estimateTxDependencies(transactionRequest);
3948
4153
  }
3949
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3950
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
3951
- encodedTransaction,
4154
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4155
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4156
+ encodedTransactions,
3952
4157
  utxoValidation: true
3953
4158
  });
3954
- const receipts = gqlReceipts.map(processGqlReceipt);
3955
- return {
3956
- receipts
3957
- };
4159
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
4160
+ const { id, receipts, status } = dryRunStatus;
4161
+ const processedReceipts = receipts.map(processGqlReceipt);
4162
+ return { id, receipts: processedReceipts, status };
4163
+ });
4164
+ return { receipts: callResult[0].receipts };
3958
4165
  }
3959
4166
  /**
3960
4167
  * Returns a transaction cost to enable user
@@ -3971,77 +4178,79 @@ var _Provider = class {
3971
4178
  * @param tolerance - The tolerance to add on top of the gasUsed.
3972
4179
  * @returns A promise that resolves to the transaction cost object.
3973
4180
  */
3974
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3975
- estimateTxDependencies = true,
3976
- estimatePredicates = true,
3977
- resourcesOwner,
3978
- signatureCallback
3979
- } = {}) {
4181
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3980
4182
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3981
- const { minGasPrice } = this.getGasConfig();
3982
- const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3983
- const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4183
+ const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3984
4184
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3985
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4185
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3986
4186
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4187
+ txRequestClone.maxFee = (0, import_math16.bn)(0);
3987
4188
  if (isScriptTransaction) {
3988
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4189
+ txRequestClone.gasLimit = (0, import_math16.bn)(0);
3989
4190
  }
3990
- if (estimatePredicates) {
3991
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3992
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3993
- }
3994
- await this.estimatePredicates(txRequestClone);
4191
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4192
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3995
4193
  }
4194
+ const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4195
+ let addedSignatures = 0;
3996
4196
  if (signatureCallback && isScriptTransaction) {
3997
- await signatureCallback(txRequestClone);
4197
+ const lengthBefore = signedRequest.witnesses.length;
4198
+ await signatureCallback(signedRequest);
4199
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
3998
4200
  }
3999
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
- transactionRequest: txRequestClone
4201
+ await this.estimatePredicates(signedRequest);
4202
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4203
+ transactionRequest: signedRequest
4001
4204
  });
4002
4205
  let receipts = [];
4003
4206
  let missingContractIds = [];
4004
4207
  let outputVariables = 0;
4005
- let gasUsed = (0, import_math15.bn)(0);
4006
- if (isScriptTransaction && estimateTxDependencies) {
4007
- txRequestClone.gasPrice = (0, import_math15.bn)(0);
4208
+ let gasUsed = (0, import_math16.bn)(0);
4209
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4210
+ txRequestClone.maxFee = maxFee;
4211
+ if (isScriptTransaction) {
4212
+ txRequestClone.gasLimit = gasLimit;
4213
+ if (signatureCallback) {
4214
+ await signatureCallback(txRequestClone);
4215
+ }
4008
4216
  const result = await this.estimateTxDependencies(txRequestClone);
4009
4217
  receipts = result.receipts;
4010
4218
  outputVariables = result.outputVariables;
4011
4219
  missingContractIds = result.missingContractIds;
4012
4220
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4013
4221
  txRequestClone.gasLimit = gasUsed;
4014
- txRequestClone.gasPrice = setGasPrice;
4015
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4016
- transactionRequest: txRequestClone
4222
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4223
+ transactionRequest: txRequestClone,
4224
+ gasPrice
4017
4225
  }));
4018
4226
  }
4019
4227
  return {
4020
4228
  requiredQuantities: allQuantities,
4021
4229
  receipts,
4022
4230
  gasUsed,
4023
- minGasPrice,
4024
- gasPrice: setGasPrice,
4231
+ gasPrice,
4025
4232
  minGas,
4026
4233
  maxGas,
4027
4234
  minFee,
4028
4235
  maxFee,
4029
- estimatedInputs: txRequestClone.inputs,
4030
4236
  outputVariables,
4031
- missingContractIds
4237
+ missingContractIds,
4238
+ addedSignatures,
4239
+ estimatedPredicates: txRequestClone.inputs
4032
4240
  };
4033
4241
  }
4034
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4242
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4035
4243
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4036
4244
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4037
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4245
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
4246
+ quantitiesToContract
4247
+ });
4038
4248
  transactionRequest.addResources(
4039
4249
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4040
4250
  );
4041
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4042
- transactionRequest,
4043
- forwardingQuantities
4044
- );
4251
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4252
+ quantitiesToContract
4253
+ });
4045
4254
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4046
4255
  return {
4047
4256
  resources,
@@ -4057,17 +4266,16 @@ var _Provider = class {
4057
4266
  const result = await this.operations.getCoins({
4058
4267
  first: 10,
4059
4268
  ...paginationArgs,
4060
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4269
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4061
4270
  });
4062
4271
  const coins = result.coins.edges.map((edge) => edge.node);
4063
4272
  return coins.map((coin) => ({
4064
4273
  id: coin.utxoId,
4065
4274
  assetId: coin.assetId,
4066
- amount: (0, import_math15.bn)(coin.amount),
4275
+ amount: (0, import_math16.bn)(coin.amount),
4067
4276
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4068
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4069
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4070
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4277
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4278
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4071
4279
  }));
4072
4280
  }
4073
4281
  /**
@@ -4081,19 +4289,19 @@ var _Provider = class {
4081
4289
  async getResourcesToSpend(owner, quantities, excludedIds) {
4082
4290
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4083
4291
  const excludeInput = {
4084
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4085
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4292
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4293
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4086
4294
  };
4087
4295
  if (this.cache) {
4088
4296
  const uniqueUtxos = new Set(
4089
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4297
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4090
4298
  );
4091
4299
  excludeInput.utxos = Array.from(uniqueUtxos);
4092
4300
  }
4093
4301
  const coinsQuery = {
4094
4302
  owner: ownerAddress.toB256(),
4095
4303
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4096
- assetId: (0, import_utils23.hexlify)(assetId),
4304
+ assetId: (0, import_utils22.hexlify)(assetId),
4097
4305
  amount: amount.toString(10),
4098
4306
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4099
4307
  })),
@@ -4104,9 +4312,9 @@ var _Provider = class {
4104
4312
  switch (coin.__typename) {
4105
4313
  case "MessageCoin":
4106
4314
  return {
4107
- amount: (0, import_math15.bn)(coin.amount),
4315
+ amount: (0, import_math16.bn)(coin.amount),
4108
4316
  assetId: coin.assetId,
4109
- daHeight: (0, import_math15.bn)(coin.daHeight),
4317
+ daHeight: (0, import_math16.bn)(coin.daHeight),
4110
4318
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4111
4319
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4112
4320
  nonce: coin.nonce
@@ -4114,12 +4322,11 @@ var _Provider = class {
4114
4322
  case "Coin":
4115
4323
  return {
4116
4324
  id: coin.utxoId,
4117
- amount: (0, import_math15.bn)(coin.amount),
4325
+ amount: (0, import_math16.bn)(coin.amount),
4118
4326
  assetId: coin.assetId,
4119
4327
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4120
- maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4121
- blockCreated: (0, import_math15.bn)(coin.blockCreated),
4122
- txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4328
+ blockCreated: (0, import_math16.bn)(coin.blockCreated),
4329
+ txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4123
4330
  };
4124
4331
  default:
4125
4332
  return null;
@@ -4136,13 +4343,13 @@ var _Provider = class {
4136
4343
  async getBlock(idOrHeight) {
4137
4344
  let variables;
4138
4345
  if (typeof idOrHeight === "number") {
4139
- variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4346
+ variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4140
4347
  } else if (idOrHeight === "latest") {
4141
4348
  variables = { height: (await this.getBlockNumber()).toString(10) };
4142
4349
  } else if (idOrHeight.length === 66) {
4143
4350
  variables = { blockId: idOrHeight };
4144
4351
  } else {
4145
- variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4352
+ variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4146
4353
  }
4147
4354
  const { block } = await this.operations.getBlock(variables);
4148
4355
  if (!block) {
@@ -4150,7 +4357,7 @@ var _Provider = class {
4150
4357
  }
4151
4358
  return {
4152
4359
  id: block.id,
4153
- height: (0, import_math15.bn)(block.header.height),
4360
+ height: (0, import_math16.bn)(block.height),
4154
4361
  time: block.header.time,
4155
4362
  transactionIds: block.transactions.map((tx) => tx.id)
4156
4363
  };
@@ -4165,7 +4372,7 @@ var _Provider = class {
4165
4372
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4166
4373
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4167
4374
  id: block.id,
4168
- height: (0, import_math15.bn)(block.header.height),
4375
+ height: (0, import_math16.bn)(block.height),
4169
4376
  time: block.header.time,
4170
4377
  transactionIds: block.transactions.map((tx) => tx.id)
4171
4378
  }));
@@ -4180,7 +4387,7 @@ var _Provider = class {
4180
4387
  async getBlockWithTransactions(idOrHeight) {
4181
4388
  let variables;
4182
4389
  if (typeof idOrHeight === "number") {
4183
- variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4390
+ variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4184
4391
  } else if (idOrHeight === "latest") {
4185
4392
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4186
4393
  } else {
@@ -4192,11 +4399,11 @@ var _Provider = class {
4192
4399
  }
4193
4400
  return {
4194
4401
  id: block.id,
4195
- height: (0, import_math15.bn)(block.header.height, 10),
4402
+ height: (0, import_math16.bn)(block.height, 10),
4196
4403
  time: block.header.time,
4197
4404
  transactionIds: block.transactions.map((tx) => tx.id),
4198
4405
  transactions: block.transactions.map(
4199
- (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4406
+ (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4200
4407
  )
4201
4408
  };
4202
4409
  }
@@ -4211,8 +4418,8 @@ var _Provider = class {
4211
4418
  if (!transaction) {
4212
4419
  return null;
4213
4420
  }
4214
- return new import_transactions18.TransactionCoder().decode(
4215
- (0, import_utils23.arrayify)(transaction.rawPayload),
4421
+ return new import_transactions19.TransactionCoder().decode(
4422
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4216
4423
  0
4217
4424
  )?.[0];
4218
4425
  }
@@ -4239,9 +4446,9 @@ var _Provider = class {
4239
4446
  async getContractBalance(contractId, assetId) {
4240
4447
  const { contractBalance } = await this.operations.getContractBalance({
4241
4448
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4242
- asset: (0, import_utils23.hexlify)(assetId)
4449
+ asset: (0, import_utils22.hexlify)(assetId)
4243
4450
  });
4244
- return (0, import_math15.bn)(contractBalance.amount, 10);
4451
+ return (0, import_math16.bn)(contractBalance.amount, 10);
4245
4452
  }
4246
4453
  /**
4247
4454
  * Returns the balance for the given owner for the given asset ID.
@@ -4253,9 +4460,9 @@ var _Provider = class {
4253
4460
  async getBalance(owner, assetId) {
4254
4461
  const { balance } = await this.operations.getBalance({
4255
4462
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4256
- assetId: (0, import_utils23.hexlify)(assetId)
4463
+ assetId: (0, import_utils22.hexlify)(assetId)
4257
4464
  });
4258
- return (0, import_math15.bn)(balance.amount, 10);
4465
+ return (0, import_math16.bn)(balance.amount, 10);
4259
4466
  }
4260
4467
  /**
4261
4468
  * Returns balances for the given owner.
@@ -4273,7 +4480,7 @@ var _Provider = class {
4273
4480
  const balances = result.balances.edges.map((edge) => edge.node);
4274
4481
  return balances.map((balance) => ({
4275
4482
  assetId: balance.assetId,
4276
- amount: (0, import_math15.bn)(balance.amount)
4483
+ amount: (0, import_math16.bn)(balance.amount)
4277
4484
  }));
4278
4485
  }
4279
4486
  /**
@@ -4291,19 +4498,19 @@ var _Provider = class {
4291
4498
  });
4292
4499
  const messages = result.messages.edges.map((edge) => edge.node);
4293
4500
  return messages.map((message) => ({
4294
- messageId: import_transactions18.InputMessageCoder.getMessageId({
4501
+ messageId: import_transactions19.InputMessageCoder.getMessageId({
4295
4502
  sender: message.sender,
4296
4503
  recipient: message.recipient,
4297
4504
  nonce: message.nonce,
4298
- amount: (0, import_math15.bn)(message.amount),
4505
+ amount: (0, import_math16.bn)(message.amount),
4299
4506
  data: message.data
4300
4507
  }),
4301
4508
  sender: import_address3.Address.fromAddressOrString(message.sender),
4302
4509
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4303
4510
  nonce: message.nonce,
4304
- amount: (0, import_math15.bn)(message.amount),
4305
- data: import_transactions18.InputMessageCoder.decodeData(message.data),
4306
- daHeight: (0, import_math15.bn)(message.daHeight)
4511
+ amount: (0, import_math16.bn)(message.amount),
4512
+ data: import_transactions19.InputMessageCoder.decodeData(message.data),
4513
+ daHeight: (0, import_math16.bn)(message.daHeight)
4307
4514
  }));
4308
4515
  }
4309
4516
  /**
@@ -4356,44 +4563,60 @@ var _Provider = class {
4356
4563
  } = result.messageProof;
4357
4564
  return {
4358
4565
  messageProof: {
4359
- proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4566
+ proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4360
4567
  proofSet: messageProof.proofSet
4361
4568
  },
4362
4569
  blockProof: {
4363
- proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4570
+ proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4364
4571
  proofSet: blockProof.proofSet
4365
4572
  },
4366
4573
  messageBlockHeader: {
4367
4574
  id: messageBlockHeader.id,
4368
- daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4369
- transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4575
+ daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4576
+ transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4370
4577
  transactionsRoot: messageBlockHeader.transactionsRoot,
4371
- height: (0, import_math15.bn)(messageBlockHeader.height),
4578
+ height: (0, import_math16.bn)(messageBlockHeader.height),
4372
4579
  prevRoot: messageBlockHeader.prevRoot,
4373
4580
  time: messageBlockHeader.time,
4374
4581
  applicationHash: messageBlockHeader.applicationHash,
4375
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4376
- messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4582
+ messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4583
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4584
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4585
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
4586
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4377
4587
  },
4378
4588
  commitBlockHeader: {
4379
4589
  id: commitBlockHeader.id,
4380
- daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4381
- transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4590
+ daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4591
+ transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4382
4592
  transactionsRoot: commitBlockHeader.transactionsRoot,
4383
- height: (0, import_math15.bn)(commitBlockHeader.height),
4593
+ height: (0, import_math16.bn)(commitBlockHeader.height),
4384
4594
  prevRoot: commitBlockHeader.prevRoot,
4385
4595
  time: commitBlockHeader.time,
4386
4596
  applicationHash: commitBlockHeader.applicationHash,
4387
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4388
- messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4597
+ messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4598
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4599
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4600
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
4601
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4389
4602
  },
4390
4603
  sender: import_address3.Address.fromAddressOrString(sender),
4391
4604
  recipient: import_address3.Address.fromAddressOrString(recipient),
4392
4605
  nonce,
4393
- amount: (0, import_math15.bn)(amount),
4606
+ amount: (0, import_math16.bn)(amount),
4394
4607
  data
4395
4608
  };
4396
4609
  }
4610
+ async getLatestGasPrice() {
4611
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
4612
+ return (0, import_math16.bn)(latestGasPrice.gasPrice);
4613
+ }
4614
+ async estimateGasPrice(blockHorizon) {
4615
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
4616
+ blockHorizon: String(blockHorizon)
4617
+ });
4618
+ return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4619
+ }
4397
4620
  /**
4398
4621
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4399
4622
  *
@@ -4413,10 +4636,10 @@ var _Provider = class {
4413
4636
  */
4414
4637
  async produceBlocks(amount, startTime) {
4415
4638
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4416
- blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4417
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4639
+ blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4640
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4418
4641
  });
4419
- return (0, import_math15.bn)(latestBlockHeight);
4642
+ return (0, import_math16.bn)(latestBlockHeight);
4420
4643
  }
4421
4644
  // eslint-disable-next-line @typescript-eslint/require-await
4422
4645
  async getTransactionResponse(transactionId) {
@@ -4430,7 +4653,7 @@ cacheInputs_fn = function(inputs) {
4430
4653
  return;
4431
4654
  }
4432
4655
  inputs.forEach((input) => {
4433
- if (input.type === import_transactions18.InputType.Coin) {
4656
+ if (input.type === import_transactions19.InputType.Coin) {
4434
4657
  this.cache?.set(input.id);
4435
4658
  }
4436
4659
  });
@@ -4440,9 +4663,9 @@ __publicField(Provider, "nodeInfoCache", {});
4440
4663
 
4441
4664
  // src/providers/transaction-summary/get-transaction-summary.ts
4442
4665
  var import_errors15 = require("@fuel-ts/errors");
4443
- var import_math16 = require("@fuel-ts/math");
4444
- var import_transactions19 = require("@fuel-ts/transactions");
4445
- var import_utils26 = require("@fuel-ts/utils");
4666
+ var import_math17 = require("@fuel-ts/math");
4667
+ var import_transactions20 = require("@fuel-ts/transactions");
4668
+ var import_utils25 = require("@fuel-ts/utils");
4446
4669
 
4447
4670
  // src/providers/chains.ts
4448
4671
  var CHAIN_IDS = {
@@ -4491,17 +4714,17 @@ var assets = [
4491
4714
 
4492
4715
  // src/utils/formatTransferToContractScriptData.ts
4493
4716
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4494
- var import_math17 = require("@fuel-ts/math");
4495
- var import_utils27 = require("@fuel-ts/utils");
4717
+ var import_math18 = require("@fuel-ts/math");
4718
+ var import_utils26 = require("@fuel-ts/utils");
4496
4719
  var asm = __toESM(require("@fuels/vm-asm"));
4497
4720
  var formatTransferToContractScriptData = (params) => {
4498
4721
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4499
4722
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4500
- const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4723
+ const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4501
4724
  const scriptData = Uint8Array.from([
4502
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4725
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4503
4726
  ...encoded,
4504
- ...(0, import_utils27.arrayify)(assetId)
4727
+ ...(0, import_utils26.arrayify)(assetId)
4505
4728
  ]);
4506
4729
  return scriptData;
4507
4730
  };
@@ -4686,36 +4909,33 @@ var Account = class extends import_interfaces.AbstractAccount {
4686
4909
  * @param fee - The estimated transaction fee.
4687
4910
  * @returns A promise that resolves when the resources are added to the transaction.
4688
4911
  */
4689
- async fund(request, coinQuantities, fee) {
4690
- const updatedQuantities = addAmountToAsset({
4691
- amount: (0, import_math18.bn)(fee),
4912
+ async fund(request, params) {
4913
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4914
+ const txRequest = request;
4915
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4916
+ amount: (0, import_math19.bn)(fee),
4692
4917
  assetId: import_configs12.BaseAssetId,
4693
- coinQuantities
4918
+ coinQuantities: requiredQuantities
4694
4919
  });
4695
4920
  const quantitiesDict = {};
4696
- updatedQuantities.forEach(({ amount, assetId }) => {
4921
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4697
4922
  quantitiesDict[assetId] = {
4698
4923
  required: amount,
4699
- owned: (0, import_math18.bn)(0)
4924
+ owned: (0, import_math19.bn)(0)
4700
4925
  };
4701
4926
  });
4702
- const cachedUtxos = [];
4703
- const cachedMessages = [];
4704
- const owner = this.address.toB256();
4705
- request.inputs.forEach((input) => {
4927
+ txRequest.inputs.forEach((input) => {
4706
4928
  const isResource = "amount" in input;
4707
4929
  if (isResource) {
4708
4930
  const isCoin2 = "owner" in input;
4709
4931
  if (isCoin2) {
4710
4932
  const assetId = String(input.assetId);
4711
- if (input.owner === owner && quantitiesDict[assetId]) {
4712
- const amount = (0, import_math18.bn)(input.amount);
4933
+ if (quantitiesDict[assetId]) {
4934
+ const amount = (0, import_math19.bn)(input.amount);
4713
4935
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4714
- cachedUtxos.push(input.id);
4715
4936
  }
4716
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4937
+ } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4717
4938
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4718
- cachedMessages.push(input.nonce);
4719
4939
  }
4720
4940
  }
4721
4941
  });
@@ -4730,12 +4950,21 @@ var Account = class extends import_interfaces.AbstractAccount {
4730
4950
  });
4731
4951
  const needsToBeFunded = missingQuantities.length;
4732
4952
  if (needsToBeFunded) {
4733
- const resources = await this.getResourcesToSpend(missingQuantities, {
4734
- messages: cachedMessages,
4735
- utxos: cachedUtxos
4736
- });
4737
- request.addResources(resources);
4738
- }
4953
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4954
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4955
+ txRequest.addResources(resources);
4956
+ }
4957
+ txRequest.shiftPredicateData();
4958
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
4959
+ const requestToReestimate = (0, import_ramda4.clone)(txRequest);
4960
+ if (addedSignatures) {
4961
+ Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
4962
+ }
4963
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
4964
+ transactionRequest: requestToReestimate
4965
+ });
4966
+ txRequest.maxFee = maxFee;
4967
+ return txRequest;
4739
4968
  }
4740
4969
  /**
4741
4970
  * A helper that creates a transfer transaction request and returns it.
@@ -4743,28 +4972,24 @@ var Account = class extends import_interfaces.AbstractAccount {
4743
4972
  * @param destination - The address of the destination.
4744
4973
  * @param amount - The amount of coins to transfer.
4745
4974
  * @param assetId - The asset ID of the coins to transfer.
4746
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4975
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4747
4976
  * @returns A promise that resolves to the prepared transaction request.
4748
4977
  */
4749
4978
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4750
- const { minGasPrice } = this.provider.getGasConfig();
4751
- const params = { gasPrice: minGasPrice, ...txParams };
4752
- const request = new ScriptTransactionRequest(params);
4979
+ const request = new ScriptTransactionRequest(txParams);
4753
4980
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4754
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4981
+ const txCost = await this.provider.getTransactionCost(request, {
4755
4982
  estimateTxDependencies: true,
4756
4983
  resourcesOwner: this
4757
4984
  });
4758
- request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4759
- request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4760
- this.validateGas({
4761
- gasUsed,
4762
- gasPrice: request.gasPrice,
4763
- gasLimit: request.gasLimit,
4764
- minGasPrice
4985
+ this.validateGasLimitAndMaxFee({
4986
+ gasUsed: txCost.gasUsed,
4987
+ maxFee: txCost.maxFee,
4988
+ txParams
4765
4989
  });
4766
- await this.fund(request, requiredQuantities, maxFee);
4767
- request.updatePredicateInputs(estimatedInputs);
4990
+ request.gasLimit = txCost.gasUsed;
4991
+ request.maxFee = txCost.maxFee;
4992
+ await this.fund(request, txCost);
4768
4993
  return request;
4769
4994
  }
4770
4995
  /**
@@ -4777,7 +5002,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4777
5002
  * @returns A promise that resolves to the transaction response.
4778
5003
  */
4779
5004
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4780
- if ((0, import_math18.bn)(amount).lte(0)) {
5005
+ if ((0, import_math19.bn)(amount).lte(0)) {
4781
5006
  throw new import_errors16.FuelError(
4782
5007
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4783
5008
  "Transfer amount must be a positive number."
@@ -4796,38 +5021,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4796
5021
  * @returns A promise that resolves to the transaction response.
4797
5022
  */
4798
5023
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4799
- if ((0, import_math18.bn)(amount).lte(0)) {
5024
+ if ((0, import_math19.bn)(amount).lte(0)) {
4800
5025
  throw new import_errors16.FuelError(
4801
5026
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4802
5027
  "Transfer amount must be a positive number."
4803
5028
  );
4804
5029
  }
4805
5030
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4806
- const { minGasPrice } = this.provider.getGasConfig();
4807
- const params = { gasPrice: minGasPrice, ...txParams };
4808
5031
  const { script, scriptData } = await assembleTransferToContractScript({
4809
5032
  hexlifiedContractId: contractAddress.toB256(),
4810
- amountToTransfer: (0, import_math18.bn)(amount),
5033
+ amountToTransfer: (0, import_math19.bn)(amount),
4811
5034
  assetId
4812
5035
  });
4813
5036
  const request = new ScriptTransactionRequest({
4814
- ...params,
5037
+ ...txParams,
4815
5038
  script,
4816
5039
  scriptData
4817
5040
  });
4818
5041
  request.addContractInputAndOutput(contractAddress);
4819
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4820
- request,
4821
- [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4822
- );
4823
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4824
- this.validateGas({
4825
- gasUsed,
4826
- gasPrice: request.gasPrice,
4827
- gasLimit: request.gasLimit,
4828
- minGasPrice
5042
+ const txCost = await this.provider.getTransactionCost(request, {
5043
+ resourcesOwner: this,
5044
+ quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5045
+ });
5046
+ this.validateGasLimitAndMaxFee({
5047
+ gasUsed: txCost.gasUsed,
5048
+ maxFee: txCost.maxFee,
5049
+ txParams
4829
5050
  });
4830
- await this.fund(request, requiredQuantities, maxFee);
5051
+ request.gasLimit = txCost.gasUsed;
5052
+ request.maxFee = txCost.maxFee;
5053
+ await this.fund(request, txCost);
4831
5054
  return this.sendTransaction(request);
4832
5055
  }
4833
5056
  /**
@@ -4839,34 +5062,30 @@ var Account = class extends import_interfaces.AbstractAccount {
4839
5062
  * @returns A promise that resolves to the transaction response.
4840
5063
  */
4841
5064
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
- const { minGasPrice } = this.provider.getGasConfig();
4843
5065
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4844
- const recipientDataArray = (0, import_utils28.arrayify)(
5066
+ const recipientDataArray = (0, import_utils27.arrayify)(
4845
5067
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4846
5068
  );
4847
- const amountDataArray = (0, import_utils28.arrayify)(
4848
- "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5069
+ const amountDataArray = (0, import_utils27.arrayify)(
5070
+ "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4849
5071
  );
4850
5072
  const script = new Uint8Array([
4851
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5073
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4852
5074
  ...recipientDataArray,
4853
5075
  ...amountDataArray
4854
5076
  ]);
4855
- const params = { script, gasPrice: minGasPrice, ...txParams };
5077
+ const params = { script, ...txParams };
4856
5078
  const request = new ScriptTransactionRequest(params);
4857
- const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4858
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4859
- request,
4860
- forwardingQuantities
4861
- );
4862
- request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4863
- this.validateGas({
4864
- gasUsed,
4865
- gasPrice: request.gasPrice,
4866
- gasLimit: request.gasLimit,
4867
- minGasPrice
5079
+ const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5080
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5081
+ this.validateGasLimitAndMaxFee({
5082
+ gasUsed: txCost.gasUsed,
5083
+ maxFee: txCost.maxFee,
5084
+ txParams
4868
5085
  });
4869
- await this.fund(request, requiredQuantities, maxFee);
5086
+ request.maxFee = txCost.maxFee;
5087
+ request.gasLimit = txCost.gasUsed;
5088
+ await this.fund(request, txCost);
4870
5089
  return this.sendTransaction(request);
4871
5090
  }
4872
5091
  async signMessage(message) {
@@ -4924,22 +5143,21 @@ var Account = class extends import_interfaces.AbstractAccount {
4924
5143
  }
4925
5144
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4926
5145
  }
4927
- validateGas({
5146
+ validateGasLimitAndMaxFee({
5147
+ txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
4928
5148
  gasUsed,
4929
- gasPrice,
4930
- gasLimit,
4931
- minGasPrice
5149
+ maxFee
4932
5150
  }) {
4933
- if (minGasPrice.gt(gasPrice)) {
5151
+ if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
4934
5152
  throw new import_errors16.FuelError(
4935
- import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4936
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5153
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5154
+ `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
4937
5155
  );
4938
5156
  }
4939
- if (gasUsed.gt(gasLimit)) {
5157
+ if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
4940
5158
  throw new import_errors16.FuelError(
4941
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
4942
- `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5159
+ import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5160
+ `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
4943
5161
  );
4944
5162
  }
4945
5163
  }
@@ -4949,8 +5167,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4949
5167
  var import_address5 = require("@fuel-ts/address");
4950
5168
  var import_crypto2 = require("@fuel-ts/crypto");
4951
5169
  var import_hasher2 = require("@fuel-ts/hasher");
4952
- var import_math19 = require("@fuel-ts/math");
4953
- var import_utils29 = require("@fuel-ts/utils");
5170
+ var import_math20 = require("@fuel-ts/math");
5171
+ var import_utils28 = require("@fuel-ts/utils");
4954
5172
  var import_secp256k1 = require("@noble/curves/secp256k1");
4955
5173
  var Signer = class {
4956
5174
  address;
@@ -4969,10 +5187,10 @@ var Signer = class {
4969
5187
  privateKey = `0x${privateKey}`;
4970
5188
  }
4971
5189
  }
4972
- const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4973
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4974
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4975
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5190
+ const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5191
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5192
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5193
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4976
5194
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4977
5195
  }
4978
5196
  /**
@@ -4986,11 +5204,11 @@ var Signer = class {
4986
5204
  * @returns hashed signature
4987
5205
  */
4988
5206
  sign(data) {
4989
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4990
- const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4991
- const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5207
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5208
+ const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5209
+ const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
4992
5210
  s[0] |= (signature.recovery || 0) << 7;
4993
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5211
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4994
5212
  }
4995
5213
  /**
4996
5214
  * Add point on the current elliptic curve
@@ -4999,8 +5217,8 @@ var Signer = class {
4999
5217
  * @returns compressed point on the curve
5000
5218
  */
5001
5219
  addPoint(point) {
5002
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5003
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5220
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5221
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5004
5222
  const result = p0.add(p1);
5005
5223
  return `0x${result.toHex(true)}`;
5006
5224
  }
@@ -5012,16 +5230,16 @@ var Signer = class {
5012
5230
  * @returns public key from signature from the
5013
5231
  */
5014
5232
  static recoverPublicKey(data, signature) {
5015
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5233
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5016
5234
  const r = signedMessageBytes.slice(0, 32);
5017
5235
  const s = signedMessageBytes.slice(32, 64);
5018
5236
  const recoveryParam = (s[0] & 128) >> 7;
5019
5237
  s[0] &= 127;
5020
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5238
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5021
5239
  recoveryParam
5022
5240
  );
5023
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5024
- return (0, import_utils29.hexlify)(publicKey);
5241
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5242
+ return (0, import_utils28.hexlify)(publicKey);
5025
5243
  }
5026
5244
  /**
5027
5245
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5040,7 +5258,7 @@ var Signer = class {
5040
5258
  * @returns random 32-byte hashed
5041
5259
  */
5042
5260
  static generatePrivateKey(entropy) {
5043
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5261
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5044
5262
  }
5045
5263
  /**
5046
5264
  * Extended publicKey from a compact publicKey
@@ -5049,8 +5267,8 @@ var Signer = class {
5049
5267
  * @returns extended publicKey
5050
5268
  */
5051
5269
  static extendPublicKey(publicKey) {
5052
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5053
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5270
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5271
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5054
5272
  }
5055
5273
  };
5056
5274
 
@@ -5058,7 +5276,7 @@ var Signer = class {
5058
5276
  var import_address6 = require("@fuel-ts/address");
5059
5277
  var import_crypto3 = require("@fuel-ts/crypto");
5060
5278
  var import_errors17 = require("@fuel-ts/errors");
5061
- var import_utils30 = require("@fuel-ts/utils");
5279
+ var import_utils29 = require("@fuel-ts/utils");
5062
5280
  var import_uuid = require("uuid");
5063
5281
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5064
5282
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5141,7 +5359,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5141
5359
  );
5142
5360
  }
5143
5361
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5144
- const privateKey = (0, import_utils30.hexlify)(buffer);
5362
+ const privateKey = (0, import_utils29.hexlify)(buffer);
5145
5363
  return privateKey;
5146
5364
  }
5147
5365
 
@@ -5186,7 +5404,7 @@ var BaseWalletUnlocked = class extends Account {
5186
5404
  */
5187
5405
  async signMessage(message) {
5188
5406
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5189
- return (0, import_utils31.hexlify)(signedMessage);
5407
+ return (0, import_utils30.hexlify)(signedMessage);
5190
5408
  }
5191
5409
  /**
5192
5410
  * Signs a transaction with the wallet's private key.
@@ -5199,7 +5417,7 @@ var BaseWalletUnlocked = class extends Account {
5199
5417
  const chainId = this.provider.getChainId();
5200
5418
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5201
5419
  const signature = await this.signer().sign(hashedTransaction);
5202
- return (0, import_utils31.hexlify)(signature);
5420
+ return (0, import_utils30.hexlify)(signature);
5203
5421
  }
5204
5422
  /**
5205
5423
  * Populates a transaction with the witnesses signature.
@@ -5219,7 +5437,7 @@ var BaseWalletUnlocked = class extends Account {
5219
5437
  * @param transactionRequestLike - The transaction request to send.
5220
5438
  * @returns A promise that resolves to the TransactionResponse object.
5221
5439
  */
5222
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5440
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5223
5441
  const transactionRequest = transactionRequestify(transactionRequestLike);
5224
5442
  if (estimateTxDependencies) {
5225
5443
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5260,15 +5478,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5260
5478
  // src/hdwallet/hdwallet.ts
5261
5479
  var import_errors20 = require("@fuel-ts/errors");
5262
5480
  var import_hasher6 = require("@fuel-ts/hasher");
5263
- var import_math20 = require("@fuel-ts/math");
5264
- var import_utils35 = require("@fuel-ts/utils");
5481
+ var import_math21 = require("@fuel-ts/math");
5482
+ var import_utils34 = require("@fuel-ts/utils");
5265
5483
  var import_ethers3 = require("ethers");
5266
5484
 
5267
5485
  // src/mnemonic/mnemonic.ts
5268
5486
  var import_crypto4 = require("@fuel-ts/crypto");
5269
5487
  var import_errors19 = require("@fuel-ts/errors");
5270
5488
  var import_hasher5 = require("@fuel-ts/hasher");
5271
- var import_utils33 = require("@fuel-ts/utils");
5489
+ var import_utils32 = require("@fuel-ts/utils");
5272
5490
  var import_ethers2 = require("ethers");
5273
5491
 
5274
5492
  // src/wordlists/words/english.ts
@@ -7326,7 +7544,7 @@ var english = [
7326
7544
  // src/mnemonic/utils.ts
7327
7545
  var import_errors18 = require("@fuel-ts/errors");
7328
7546
  var import_hasher4 = require("@fuel-ts/hasher");
7329
- var import_utils32 = require("@fuel-ts/utils");
7547
+ var import_utils31 = require("@fuel-ts/utils");
7330
7548
  function toUtf8Bytes(stri) {
7331
7549
  const str = stri.normalize("NFKD");
7332
7550
  const result = [];
@@ -7393,14 +7611,14 @@ function entropyToMnemonicIndices(entropy) {
7393
7611
  }
7394
7612
  }
7395
7613
  const checksumBits = entropy.length / 4;
7396
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7614
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7397
7615
  indices[indices.length - 1] <<= checksumBits;
7398
7616
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7399
7617
  return indices;
7400
7618
  }
7401
7619
  function mnemonicWordsToEntropy(words, wordlist) {
7402
7620
  const size = Math.ceil(11 * words.length / 8);
7403
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7621
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7404
7622
  let offset = 0;
7405
7623
  for (let i = 0; i < words.length; i += 1) {
7406
7624
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7420,7 +7638,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7420
7638
  const entropyBits = 32 * words.length / 3;
7421
7639
  const checksumBits = words.length / 3;
7422
7640
  const checksumMask = getUpperMask(checksumBits);
7423
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7641
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7424
7642
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7425
7643
  throw new import_errors18.FuelError(
7426
7644
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7495,7 +7713,7 @@ var Mnemonic = class {
7495
7713
  static mnemonicToEntropy(phrase, wordlist = english) {
7496
7714
  const words = getWords(phrase);
7497
7715
  assertMnemonic(words);
7498
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7716
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7499
7717
  }
7500
7718
  /**
7501
7719
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7503,7 +7721,7 @@ var Mnemonic = class {
7503
7721
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7504
7722
  */
7505
7723
  static entropyToMnemonic(entropy, wordlist = english) {
7506
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7724
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7507
7725
  assertWordList(wordlist);
7508
7726
  assertEntropy(entropyBytes);
7509
7727
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7572,14 +7790,14 @@ var Mnemonic = class {
7572
7790
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7573
7791
  */
7574
7792
  static masterKeysFromSeed(seed) {
7575
- const seedArray = (0, import_utils33.arrayify)(seed);
7793
+ const seedArray = (0, import_utils32.arrayify)(seed);
7576
7794
  if (seedArray.length < 16 || seedArray.length > 64) {
7577
7795
  throw new import_errors19.FuelError(
7578
7796
  import_errors19.ErrorCode.INVALID_SEED,
7579
7797
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7580
7798
  );
7581
7799
  }
7582
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7800
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7583
7801
  }
7584
7802
  /**
7585
7803
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7590,22 +7808,22 @@ var Mnemonic = class {
7590
7808
  */
7591
7809
  static seedToExtendedKey(seed, testnet = false) {
7592
7810
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7593
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7811
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7594
7812
  const depth = "0x00";
7595
7813
  const fingerprint = "0x00000000";
7596
7814
  const index = "0x00000000";
7597
7815
  const chainCode = masterKey.slice(32);
7598
7816
  const privateKey = masterKey.slice(0, 32);
7599
- const extendedKey = (0, import_utils33.concat)([
7817
+ const extendedKey = (0, import_utils32.concat)([
7600
7818
  prefix,
7601
7819
  depth,
7602
7820
  fingerprint,
7603
7821
  index,
7604
7822
  chainCode,
7605
- (0, import_utils33.concat)(["0x00", privateKey])
7823
+ (0, import_utils32.concat)(["0x00", privateKey])
7606
7824
  ]);
7607
7825
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7608
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7826
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7609
7827
  }
7610
7828
  /**
7611
7829
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7620,7 +7838,7 @@ var Mnemonic = class {
7620
7838
  * @returns A randomly generated mnemonic
7621
7839
  */
7622
7840
  static generate(size = 32, extraEntropy = "") {
7623
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7841
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7624
7842
  return Mnemonic.entropyToMnemonic(entropy);
7625
7843
  }
7626
7844
  };
@@ -7628,12 +7846,12 @@ var mnemonic_default = Mnemonic;
7628
7846
 
7629
7847
  // src/hdwallet/hdwallet.ts
7630
7848
  var HARDENED_INDEX = 2147483648;
7631
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7632
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7633
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7634
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7849
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7850
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7851
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7852
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7635
7853
  function base58check(data) {
7636
- 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)]));
7854
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7637
7855
  }
7638
7856
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7639
7857
  if (isPublic) {
@@ -7642,11 +7860,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7642
7860
  return testnet ? TestnetPRV2 : MainnetPRV2;
7643
7861
  }
7644
7862
  function isPublicExtendedKey(extendedKey) {
7645
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7863
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7646
7864
  }
7647
7865
  function isValidExtendedKey(extendedKey) {
7648
7866
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7649
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7867
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7650
7868
  );
7651
7869
  }
7652
7870
  function parsePath(path2, depth = 0) {
@@ -7664,8 +7882,8 @@ function parsePath(path2, depth = 0) {
7664
7882
  var HDWallet = class {
7665
7883
  depth = 0;
7666
7884
  index = 0;
7667
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
7668
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7885
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7886
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7669
7887
  privateKey;
7670
7888
  publicKey;
7671
7889
  chainCode;
@@ -7677,8 +7895,8 @@ var HDWallet = class {
7677
7895
  constructor(config) {
7678
7896
  if (config.privateKey) {
7679
7897
  const signer = new Signer(config.privateKey);
7680
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7681
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7898
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7899
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7682
7900
  } else {
7683
7901
  if (!config.publicKey) {
7684
7902
  throw new import_errors20.FuelError(
@@ -7686,7 +7904,7 @@ var HDWallet = class {
7686
7904
  "Both public and private Key cannot be missing. At least one should be provided."
7687
7905
  );
7688
7906
  }
7689
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7907
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7690
7908
  }
7691
7909
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7692
7910
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7705,9 +7923,9 @@ var HDWallet = class {
7705
7923
  * @returns A new instance of HDWallet on the derived index
7706
7924
  */
7707
7925
  deriveIndex(index) {
7708
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7709
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7710
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7926
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7927
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7928
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7711
7929
  const data = new Uint8Array(37);
7712
7930
  if (index & HARDENED_INDEX) {
7713
7931
  if (!privateKey) {
@@ -7718,15 +7936,15 @@ var HDWallet = class {
7718
7936
  }
7719
7937
  data.set(privateKey, 1);
7720
7938
  } else {
7721
- data.set((0, import_utils35.arrayify)(this.publicKey));
7939
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7722
7940
  }
7723
- data.set((0, import_math20.toBytes)(index, 4), 33);
7724
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7941
+ data.set((0, import_math21.toBytes)(index, 4), 33);
7942
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7725
7943
  const IL = bytes.slice(0, 32);
7726
7944
  const IR = bytes.slice(32);
7727
7945
  if (privateKey) {
7728
7946
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7729
- const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7947
+ const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7730
7948
  return new HDWallet({
7731
7949
  privateKey: ki,
7732
7950
  chainCode: IR,
@@ -7735,7 +7953,7 @@ var HDWallet = class {
7735
7953
  parentFingerprint: this.fingerprint
7736
7954
  });
7737
7955
  }
7738
- const signer = new Signer((0, import_utils35.hexlify)(IL));
7956
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7739
7957
  const Ki = signer.addPoint(publicKey);
7740
7958
  return new HDWallet({
7741
7959
  publicKey: Ki,
@@ -7770,12 +7988,12 @@ var HDWallet = class {
7770
7988
  );
7771
7989
  }
7772
7990
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7773
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7991
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7774
7992
  const parentFingerprint = this.parentFingerprint;
7775
- const index = (0, import_math20.toHex)(this.index, 4);
7993
+ const index = (0, import_math21.toHex)(this.index, 4);
7776
7994
  const chainCode = this.chainCode;
7777
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7778
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7995
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7996
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7779
7997
  return base58check(extendedKey);
7780
7998
  }
7781
7999
  /**
@@ -7787,13 +8005,13 @@ var HDWallet = class {
7787
8005
  static fromSeed(seed) {
7788
8006
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7789
8007
  return new HDWallet({
7790
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7791
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8008
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8009
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7792
8010
  });
7793
8011
  }
7794
8012
  static fromExtendedKey(extendedKey) {
7795
8013
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7796
- const bytes = (0, import_utils35.arrayify)(decoded);
8014
+ const bytes = (0, import_utils34.arrayify)(decoded);
7797
8015
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7798
8016
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7799
8017
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7802,9 +8020,9 @@ var HDWallet = class {
7802
8020
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7803
8021
  }
7804
8022
  const depth = bytes[4];
7805
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7806
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7807
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8023
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8024
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8025
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7808
8026
  const key = bytes.slice(45, 78);
7809
8027
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7810
8028
  throw new import_errors20.FuelError(
@@ -7997,14 +8215,15 @@ var seedTestWallet = async (wallet, quantities) => {
7997
8215
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
7998
8216
  wallet.provider
7999
8217
  );
8000
- const resources = await genesisWallet.getResourcesToSpend(quantities);
8001
- const { minGasPrice } = genesisWallet.provider.getGasConfig();
8002
- const request = new ScriptTransactionRequest({
8003
- gasLimit: 1e4,
8004
- gasPrice: minGasPrice
8218
+ const request = new ScriptTransactionRequest();
8219
+ quantities.forEach((quantity) => {
8220
+ const { amount, assetId } = coinQuantityfy(quantity);
8221
+ request.addCoinOutput(wallet.address, amount, assetId);
8005
8222
  });
8006
- request.addResources(resources);
8007
- quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8223
+ const txCost = await genesisWallet.provider.getTransactionCost(request);
8224
+ request.gasLimit = txCost.gasUsed;
8225
+ request.maxFee = txCost.maxFee;
8226
+ await genesisWallet.fund(request, txCost);
8008
8227
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8009
8228
  };
8010
8229
 
@@ -8018,12 +8237,13 @@ var generateTestWallet = async (provider, quantities) => {
8018
8237
  };
8019
8238
 
8020
8239
  // src/test-utils/launchNode.ts
8240
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
8021
8241
  var import_configs13 = require("@fuel-ts/address/configs");
8022
- var import_math21 = require("@fuel-ts/math");
8023
- var import_utils36 = require("@fuel-ts/utils");
8242
+ var import_crypto6 = require("@fuel-ts/crypto");
8243
+ var import_utils35 = require("@fuel-ts/utils");
8024
8244
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8025
8245
  var import_child_process = require("child_process");
8026
- var import_crypto6 = require("crypto");
8246
+ var import_crypto7 = require("crypto");
8027
8247
  var import_fs = require("fs");
8028
8248
  var import_os = __toESM(require("os"));
8029
8249
  var import_path = __toESM(require("path"));
@@ -8064,7 +8284,6 @@ var launchNode = async ({
8064
8284
  ip,
8065
8285
  port,
8066
8286
  args = [],
8067
- fuelCorePath = void 0,
8068
8287
  useSystemFuelCore = false,
8069
8288
  loggingEnabled = true,
8070
8289
  debugEnabled = false,
@@ -8073,19 +8292,19 @@ var launchNode = async ({
8073
8292
  // eslint-disable-next-line no-async-promise-executor
8074
8293
  new Promise(async (resolve, reject) => {
8075
8294
  const remainingArgs = extractRemainingArgs(args, [
8076
- "--chain",
8295
+ "--snapshot",
8077
8296
  "--consensus-key",
8078
8297
  "--db-type",
8079
8298
  "--poa-instant"
8080
8299
  ]);
8081
- const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8082
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8300
+ const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8301
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8083
8302
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8084
8303
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8085
8304
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8086
8305
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8087
8306
  const graphQLStartSubstring = "Binding GraphQL provider to";
8088
- const binPath = fuelCorePath ?? (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8307
+ const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8089
8308
  const command = useSystemFuelCore ? "fuel-core" : binPath;
8090
8309
  const ipToUse = ip || "0.0.0.0";
8091
8310
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
@@ -8096,37 +8315,55 @@ var launchNode = async ({
8096
8315
  })).toString();
8097
8316
  let chainConfigPathToUse;
8098
8317
  const prefix = basePath || import_os.default.tmpdir();
8099
- const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8100
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8318
+ const suffix = basePath ? "" : (0, import_crypto7.randomUUID)();
8319
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8101
8320
  if (chainConfigPath) {
8102
8321
  chainConfigPathToUse = chainConfigPath;
8103
8322
  } else {
8104
8323
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8105
8324
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8106
8325
  }
8107
- const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8108
- let chainConfig = import_utils36.defaultChainConfig;
8326
+ let { stateConfigJson } = import_utils35.defaultChainConfigs;
8327
+ const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8328
+ stateConfigJson = {
8329
+ ...stateConfigJson,
8330
+ coins: [
8331
+ ...stateConfigJson.coins.map((coin) => ({
8332
+ ...coin,
8333
+ amount: "18446744073709551615"
8334
+ }))
8335
+ ],
8336
+ messages: stateConfigJson.messages.map((message) => ({
8337
+ ...message,
8338
+ amount: "18446744073709551615"
8339
+ }))
8340
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8341
+ };
8109
8342
  if (!process.env.GENESIS_SECRET) {
8110
8343
  const pk = Signer.generatePrivateKey();
8111
8344
  const signer = new Signer(pk);
8112
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8113
- chainConfig = {
8114
- ...import_utils36.defaultChainConfig,
8115
- initial_state: {
8116
- ...import_utils36.defaultChainConfig.initial_state,
8117
- coins: [
8118
- ...import_utils36.defaultChainConfig.initial_state.coins,
8119
- {
8120
- owner: signer.address.toHexString(),
8121
- amount: (0, import_math21.toHex)(1e9),
8122
- asset_id: import_configs13.BaseAssetId
8123
- }
8124
- ]
8125
- }
8126
- };
8345
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8346
+ stateConfigJson.coins.push({
8347
+ tx_id: (0, import_utils35.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8348
+ owner: signer.address.toHexString(),
8349
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8350
+ amount: "18446744073709551615",
8351
+ asset_id: import_configs13.BaseAssetId,
8352
+ output_index: 0,
8353
+ tx_pointer_block_height: 0,
8354
+ tx_pointer_tx_idx: 0
8355
+ });
8127
8356
  }
8128
- (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8129
- chainConfigPathToUse = tempChainConfigFilePath;
8357
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8358
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8359
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8360
+ const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8361
+ const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8362
+ const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8363
+ (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8364
+ (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8365
+ (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8366
+ chainConfigPathToUse = tempDirPath;
8130
8367
  }
8131
8368
  const child = (0, import_child_process.spawn)(
8132
8369
  command,
@@ -8135,10 +8372,10 @@ var launchNode = async ({
8135
8372
  ["--ip", ipToUse],
8136
8373
  ["--port", portToUse],
8137
8374
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8138
- ["--min-gas-price", "0"],
8375
+ ["--min-gas-price", "1"],
8139
8376
  poaInstant ? ["--poa-instant", "true"] : [],
8140
8377
  ["--consensus-key", consensusKey],
8141
- ["--chain", chainConfigPathToUse],
8378
+ ["--snapshot", chainConfigPathToUse],
8142
8379
  "--vm-backtrace",
8143
8380
  "--utxo-validation",
8144
8381
  "--debug",
@@ -8197,7 +8434,7 @@ var launchNodeAndGetWallets = async ({
8197
8434
  walletCount = 10
8198
8435
  } = {}) => {
8199
8436
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8200
- const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8437
+ const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8201
8438
  const wallets = await generateWallets(walletCount, provider);
8202
8439
  const cleanup = () => {
8203
8440
  closeNode();