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

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -6
  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 +583 -863
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +513 -793
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +395 -674
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +326 -828
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  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 +29 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts +4 -2
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1055 -1551
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +513 -775
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +406 -668
  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,16 +58,15 @@ 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_utils30 = require("@fuel-ts/utils");
61
+ var import_utils31 = 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_math19 = require("@fuel-ts/math");
69
- var import_utils27 = require("@fuel-ts/utils");
70
- var import_ramda4 = require("ramda");
68
+ var import_math18 = require("@fuel-ts/math");
69
+ var import_utils28 = require("@fuel-ts/utils");
71
70
 
72
71
  // src/providers/coin-quantity.ts
73
72
  var import_configs = require("@fuel-ts/address/configs");
@@ -76,24 +75,24 @@ var import_utils = require("@fuel-ts/utils");
76
75
  var coinQuantityfy = (coinQuantityLike) => {
77
76
  let assetId;
78
77
  let amount;
79
- let max;
78
+ let max2;
80
79
  if (Array.isArray(coinQuantityLike)) {
81
80
  amount = coinQuantityLike[0];
82
81
  assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
83
- max = coinQuantityLike[2] ?? void 0;
82
+ max2 = coinQuantityLike[2] ?? void 0;
84
83
  } else {
85
84
  amount = coinQuantityLike.amount;
86
85
  assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
87
- max = coinQuantityLike.max ?? void 0;
86
+ max2 = coinQuantityLike.max ?? void 0;
88
87
  }
89
88
  const bnAmount = (0, import_math.bn)(amount);
90
89
  return {
91
90
  assetId: (0, import_utils.hexlify)(assetId),
92
91
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
93
- max: max ? (0, import_math.bn)(max) : void 0
92
+ max: max2 ? (0, import_math.bn)(max2) : void 0
94
93
  };
95
94
  };
96
- var addAmountToCoinQuantities = (params) => {
95
+ var addAmountToAsset = (params) => {
97
96
  const { amount, assetId } = params;
98
97
  const coinQuantities = [...params.coinQuantities];
99
98
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -108,51 +107,27 @@ var addAmountToCoinQuantities = (params) => {
108
107
  // src/providers/provider.ts
109
108
  var import_address3 = require("@fuel-ts/address");
110
109
  var import_errors14 = require("@fuel-ts/errors");
111
- var import_math16 = require("@fuel-ts/math");
112
- var import_transactions19 = require("@fuel-ts/transactions");
113
- var import_utils22 = require("@fuel-ts/utils");
110
+ var import_math15 = require("@fuel-ts/math");
111
+ var import_transactions18 = require("@fuel-ts/transactions");
112
+ var import_utils23 = require("@fuel-ts/utils");
114
113
  var import_versions = require("@fuel-ts/versions");
115
- var import_utils23 = require("@noble/curves/abstract/utils");
114
+ var import_utils24 = require("@noble/curves/abstract/utils");
116
115
  var import_ethers = require("ethers");
117
116
  var import_graphql_request = require("graphql-request");
118
117
  var import_ramda3 = require("ramda");
119
118
 
120
119
  // src/providers/__generated__/operations.ts
121
120
  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 SubmittedStatus {
126
- time
127
- }
128
- ... on SuccessStatus {
129
- block {
130
- id
131
- }
132
- time
133
- programState {
134
- returnType
135
- data
136
- }
137
- }
138
- ... on FailureStatus {
139
- block {
140
- id
141
- }
142
- time
143
- reason
144
- }
145
- ... on SqueezedOutStatus {
146
- reason
147
- }
148
- }
149
- `;
150
121
  var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
151
122
  fragment receiptFragment on Receipt {
152
- id
123
+ contract {
124
+ id
125
+ }
153
126
  pc
154
127
  is
155
- to
128
+ to {
129
+ id
130
+ }
156
131
  toAddress
157
132
  amount
158
133
  assetId
@@ -190,16 +165,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
190
165
  id
191
166
  }
192
167
  time
193
- receipts {
194
- ...receiptFragment
195
- }
196
168
  programState {
197
169
  returnType
198
170
  data
199
171
  }
200
- receipts {
201
- ...receiptFragment
202
- }
203
172
  }
204
173
  ... on FailureStatus {
205
174
  block {
@@ -207,24 +176,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
207
176
  }
208
177
  time
209
178
  reason
210
- receipts {
211
- ...receiptFragment
212
- }
213
179
  }
214
180
  ... on SqueezedOutStatus {
215
181
  reason
216
182
  }
217
183
  }
218
- ${ReceiptFragmentFragmentDoc}`;
184
+ `;
219
185
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
220
186
  fragment transactionFragment on Transaction {
221
187
  id
222
188
  rawPayload
189
+ gasPrice
190
+ receipts {
191
+ ...receiptFragment
192
+ }
223
193
  status {
224
194
  ...transactionStatusFragment
225
195
  }
226
196
  }
227
- ${TransactionStatusFragmentFragmentDoc}`;
197
+ ${ReceiptFragmentFragmentDoc}
198
+ ${TransactionStatusFragmentFragmentDoc}`;
228
199
  var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
229
200
  fragment inputEstimatePredicatesFragment on Input {
230
201
  ... on InputCoin {
@@ -242,46 +213,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
242
213
  }
243
214
  }
244
215
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
245
- var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
246
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
247
- reason
248
- programState {
249
- returnType
250
- data
251
- }
252
- }
253
- `;
254
- var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
255
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
256
- programState {
257
- returnType
258
- data
259
- }
260
- }
261
- `;
262
- var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
263
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
264
- ... on DryRunFailureStatus {
265
- ...dryRunFailureStatusFragment
266
- }
267
- ... on DryRunSuccessStatus {
268
- ...dryRunSuccessStatusFragment
269
- }
270
- }
271
- ${DryRunFailureStatusFragmentFragmentDoc}
272
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
273
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
274
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
275
- id
276
- status {
277
- ...dryRunTransactionStatusFragment
278
- }
279
- receipts {
280
- ...receiptFragment
281
- }
282
- }
283
- ${DryRunTransactionStatusFragmentFragmentDoc}
284
- ${ReceiptFragmentFragmentDoc}`;
285
216
  var CoinFragmentFragmentDoc = import_graphql_tag.default`
286
217
  fragment coinFragment on Coin {
287
218
  __typename
@@ -289,6 +220,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
289
220
  owner
290
221
  amount
291
222
  assetId
223
+ maturity
292
224
  blockCreated
293
225
  txCreatedIdx
294
226
  }
@@ -327,32 +259,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
327
259
  messageBlockHeader {
328
260
  id
329
261
  daHeight
330
- consensusParametersVersion
331
- stateTransitionBytecodeVersion
332
262
  transactionsCount
333
- messageReceiptCount
334
263
  transactionsRoot
335
- messageOutboxRoot
336
- eventInboxRoot
337
264
  height
338
265
  prevRoot
339
266
  time
340
267
  applicationHash
268
+ messageReceiptRoot
269
+ messageReceiptCount
341
270
  }
342
271
  commitBlockHeader {
343
272
  id
344
273
  daHeight
345
- consensusParametersVersion
346
- stateTransitionBytecodeVersion
347
274
  transactionsCount
348
- messageReceiptCount
349
275
  transactionsRoot
350
- messageOutboxRoot
351
- eventInboxRoot
352
276
  height
353
277
  prevRoot
354
278
  time
355
279
  applicationHash
280
+ messageReceiptRoot
281
+ messageReceiptCount
356
282
  }
357
283
  sender
358
284
  recipient
@@ -371,8 +297,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
371
297
  var BlockFragmentFragmentDoc = import_graphql_tag.default`
372
298
  fragment blockFragment on Block {
373
299
  id
374
- height
375
300
  header {
301
+ height
376
302
  time
377
303
  }
378
304
  transactions {
@@ -382,7 +308,6 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
382
308
  `;
383
309
  var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
384
310
  fragment TxParametersFragment on TxParameters {
385
- version
386
311
  maxInputs
387
312
  maxOutputs
388
313
  maxWitnesses
@@ -392,7 +317,6 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
392
317
  `;
393
318
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
394
319
  fragment PredicateParametersFragment on PredicateParameters {
395
- version
396
320
  maxPredicateLength
397
321
  maxPredicateDataLength
398
322
  maxGasPerPredicate
@@ -401,21 +325,18 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
401
325
  `;
402
326
  var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
403
327
  fragment ScriptParametersFragment on ScriptParameters {
404
- version
405
328
  maxScriptLength
406
329
  maxScriptDataLength
407
330
  }
408
331
  `;
409
332
  var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
410
333
  fragment ContractParametersFragment on ContractParameters {
411
- version
412
334
  contractMaxSize
413
335
  maxStorageSlots
414
336
  }
415
337
  `;
416
338
  var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
417
339
  fragment FeeParametersFragment on FeeParameters {
418
- version
419
340
  gasPriceFactor
420
341
  gasPerByte
421
342
  }
@@ -435,7 +356,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
435
356
  `;
436
357
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
437
358
  fragment GasCostsFragment on GasCosts {
438
- version
439
359
  add
440
360
  addi
441
361
  aloc
@@ -448,6 +368,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
448
368
  cb
449
369
  cfei
450
370
  cfsi
371
+ croo
451
372
  div
452
373
  divi
453
374
  ecr1
@@ -530,9 +451,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
530
451
  ccp {
531
452
  ...DependentCostFragment
532
453
  }
533
- croo {
534
- ...DependentCostFragment
535
- }
536
454
  csiz {
537
455
  ...DependentCostFragment
538
456
  }
@@ -592,7 +510,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
592
510
  ${DependentCostFragmentFragmentDoc}`;
593
511
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
594
512
  fragment consensusParametersFragment on ConsensusParameters {
595
- version
596
513
  txParams {
597
514
  ...TxParametersFragment
598
515
  }
@@ -652,9 +569,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
652
569
  fragment nodeInfoFragment on NodeInfo {
653
570
  utxoValidation
654
571
  vmBacktrace
572
+ minGasPrice
655
573
  maxTx
656
574
  maxDepth
657
575
  nodeVersion
576
+ peers {
577
+ id
578
+ addresses
579
+ clientVersion
580
+ blockHeight
581
+ lastHeartbeatMs
582
+ appScore
583
+ }
658
584
  }
659
585
  `;
660
586
  var GetVersionDocument = import_graphql_tag.default`
@@ -689,9 +615,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
689
615
  query getTransactionWithReceipts($transactionId: TransactionId!) {
690
616
  transaction(id: $transactionId) {
691
617
  ...transactionFragment
618
+ receipts {
619
+ ...receiptFragment
620
+ }
692
621
  }
693
622
  }
694
- ${TransactionFragmentFragmentDoc}`;
623
+ ${TransactionFragmentFragmentDoc}
624
+ ${ReceiptFragmentFragmentDoc}`;
695
625
  var GetTransactionsDocument = import_graphql_tag.default`
696
626
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
697
627
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -819,20 +749,6 @@ var GetBalanceDocument = import_graphql_tag.default`
819
749
  }
820
750
  }
821
751
  ${BalanceFragmentFragmentDoc}`;
822
- var GetLatestGasPriceDocument = import_graphql_tag.default`
823
- query getLatestGasPrice {
824
- latestGasPrice {
825
- gasPrice
826
- }
827
- }
828
- `;
829
- var EstimateGasPriceDocument = import_graphql_tag.default`
830
- query estimateGasPrice($blockHorizon: U32!) {
831
- estimateGasPrice(blockHorizon: $blockHorizon) {
832
- gasPrice
833
- }
834
- }
835
- `;
836
752
  var GetBalancesDocument = import_graphql_tag.default`
837
753
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
838
754
  balances(
@@ -887,12 +803,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
887
803
  }
888
804
  `;
889
805
  var DryRunDocument = import_graphql_tag.default`
890
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
891
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
892
- ...dryRunTransactionExecutionStatusFragment
806
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
807
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
808
+ ...receiptFragment
893
809
  }
894
810
  }
895
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
811
+ ${ReceiptFragmentFragmentDoc}`;
896
812
  var SubmitDocument = import_graphql_tag.default`
897
813
  mutation submit($encodedTransaction: HexString!) {
898
814
  submit(tx: $encodedTransaction) {
@@ -911,17 +827,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
911
827
  var SubmitAndAwaitDocument = import_graphql_tag.default`
912
828
  subscription submitAndAwait($encodedTransaction: HexString!) {
913
829
  submitAndAwait(tx: $encodedTransaction) {
914
- ...transactionStatusSubscriptionFragment
830
+ ...transactionStatusFragment
915
831
  }
916
832
  }
917
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
833
+ ${TransactionStatusFragmentFragmentDoc}`;
918
834
  var StatusChangeDocument = import_graphql_tag.default`
919
835
  subscription statusChange($transactionId: TransactionId!) {
920
836
  statusChange(id: $transactionId) {
921
- ...transactionStatusSubscriptionFragment
837
+ ...transactionStatusFragment
922
838
  }
923
839
  }
924
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
840
+ ${TransactionStatusFragmentFragmentDoc}`;
925
841
  function getSdk(requester) {
926
842
  return {
927
843
  getVersion(variables, options) {
@@ -975,12 +891,6 @@ function getSdk(requester) {
975
891
  getBalance(variables, options) {
976
892
  return requester(GetBalanceDocument, variables, options);
977
893
  },
978
- getLatestGasPrice(variables, options) {
979
- return requester(GetLatestGasPriceDocument, variables, options);
980
- },
981
- estimateGasPrice(variables, options) {
982
- return requester(EstimateGasPriceDocument, variables, options);
983
- },
984
894
  getBalances(variables, options) {
985
895
  return requester(GetBalancesDocument, variables, options);
986
896
  },
@@ -1174,9 +1084,10 @@ var inputify = (value) => {
1174
1084
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1175
1085
  },
1176
1086
  witnessIndex: value.witnessIndex,
1087
+ maturity: value.maturity ?? 0,
1177
1088
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1178
- predicateLength: (0, import_math2.bn)(predicate.length),
1179
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1089
+ predicateLength: predicate.length,
1090
+ predicateDataLength: predicateData.length,
1180
1091
  predicate: (0, import_utils3.hexlify)(predicate),
1181
1092
  predicateData: (0, import_utils3.hexlify)(predicateData)
1182
1093
  };
@@ -1207,8 +1118,8 @@ var inputify = (value) => {
1207
1118
  nonce: (0, import_utils3.hexlify)(value.nonce),
1208
1119
  witnessIndex: value.witnessIndex,
1209
1120
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1210
- predicateLength: (0, import_math2.bn)(predicate.length),
1211
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1121
+ predicateLength: predicate.length,
1122
+ predicateDataLength: predicateData.length,
1212
1123
  predicate: (0, import_utils3.hexlify)(predicate),
1213
1124
  predicateData: (0, import_utils3.hexlify)(predicateData),
1214
1125
  data: (0, import_utils3.hexlify)(data),
@@ -1324,8 +1235,8 @@ function assembleReceiptByType(receipt) {
1324
1235
  case "CALL" /* Call */: {
1325
1236
  const callReceipt = {
1326
1237
  type: import_transactions3.ReceiptType.Call,
1327
- from: hexOrZero(receipt.id || receipt.contractId),
1328
- to: hexOrZero(receipt?.to),
1238
+ from: hexOrZero(receipt.contract?.id),
1239
+ to: hexOrZero(receipt?.to?.id),
1329
1240
  amount: (0, import_math4.bn)(receipt.amount),
1330
1241
  assetId: hexOrZero(receipt.assetId),
1331
1242
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1339,7 +1250,7 @@ function assembleReceiptByType(receipt) {
1339
1250
  case "RETURN" /* Return */: {
1340
1251
  const returnReceipt = {
1341
1252
  type: import_transactions3.ReceiptType.Return,
1342
- id: hexOrZero(receipt.id || receipt.contractId),
1253
+ id: hexOrZero(receipt.contract?.id),
1343
1254
  val: (0, import_math4.bn)(receipt.val),
1344
1255
  pc: (0, import_math4.bn)(receipt.pc),
1345
1256
  is: (0, import_math4.bn)(receipt.is)
@@ -1349,7 +1260,7 @@ function assembleReceiptByType(receipt) {
1349
1260
  case "RETURN_DATA" /* ReturnData */: {
1350
1261
  const returnDataReceipt = {
1351
1262
  type: import_transactions3.ReceiptType.ReturnData,
1352
- id: hexOrZero(receipt.id || receipt.contractId),
1263
+ id: hexOrZero(receipt.contract?.id),
1353
1264
  ptr: (0, import_math4.bn)(receipt.ptr),
1354
1265
  len: (0, import_math4.bn)(receipt.len),
1355
1266
  digest: hexOrZero(receipt.digest),
@@ -1361,7 +1272,7 @@ function assembleReceiptByType(receipt) {
1361
1272
  case "PANIC" /* Panic */: {
1362
1273
  const panicReceipt = {
1363
1274
  type: import_transactions3.ReceiptType.Panic,
1364
- id: hexOrZero(receipt.id),
1275
+ id: hexOrZero(receipt.contract?.id),
1365
1276
  reason: (0, import_math4.bn)(receipt.reason),
1366
1277
  pc: (0, import_math4.bn)(receipt.pc),
1367
1278
  is: (0, import_math4.bn)(receipt.is),
@@ -1372,7 +1283,7 @@ function assembleReceiptByType(receipt) {
1372
1283
  case "REVERT" /* Revert */: {
1373
1284
  const revertReceipt = {
1374
1285
  type: import_transactions3.ReceiptType.Revert,
1375
- id: hexOrZero(receipt.id || receipt.contractId),
1286
+ id: hexOrZero(receipt.contract?.id),
1376
1287
  val: (0, import_math4.bn)(receipt.ra),
1377
1288
  pc: (0, import_math4.bn)(receipt.pc),
1378
1289
  is: (0, import_math4.bn)(receipt.is)
@@ -1382,7 +1293,7 @@ function assembleReceiptByType(receipt) {
1382
1293
  case "LOG" /* Log */: {
1383
1294
  const logReceipt = {
1384
1295
  type: import_transactions3.ReceiptType.Log,
1385
- id: hexOrZero(receipt.id || receipt.contractId),
1296
+ id: hexOrZero(receipt.contract?.id),
1386
1297
  val0: (0, import_math4.bn)(receipt.ra),
1387
1298
  val1: (0, import_math4.bn)(receipt.rb),
1388
1299
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1395,7 +1306,7 @@ function assembleReceiptByType(receipt) {
1395
1306
  case "LOG_DATA" /* LogData */: {
1396
1307
  const logDataReceipt = {
1397
1308
  type: import_transactions3.ReceiptType.LogData,
1398
- id: hexOrZero(receipt.id || receipt.contractId),
1309
+ id: hexOrZero(receipt.contract?.id),
1399
1310
  val0: (0, import_math4.bn)(receipt.ra),
1400
1311
  val1: (0, import_math4.bn)(receipt.rb),
1401
1312
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1409,8 +1320,8 @@ function assembleReceiptByType(receipt) {
1409
1320
  case "TRANSFER" /* Transfer */: {
1410
1321
  const transferReceipt = {
1411
1322
  type: import_transactions3.ReceiptType.Transfer,
1412
- from: hexOrZero(receipt.id || receipt.contractId),
1413
- to: hexOrZero(receipt.toAddress || receipt?.to),
1323
+ from: hexOrZero(receipt.contract?.id),
1324
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1414
1325
  amount: (0, import_math4.bn)(receipt.amount),
1415
1326
  assetId: hexOrZero(receipt.assetId),
1416
1327
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1421,8 +1332,8 @@ function assembleReceiptByType(receipt) {
1421
1332
  case "TRANSFER_OUT" /* TransferOut */: {
1422
1333
  const transferOutReceipt = {
1423
1334
  type: import_transactions3.ReceiptType.TransferOut,
1424
- from: hexOrZero(receipt.id || receipt.contractId),
1425
- to: hexOrZero(receipt.toAddress || receipt.to),
1335
+ from: hexOrZero(receipt.contract?.id),
1336
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1426
1337
  amount: (0, import_math4.bn)(receipt.amount),
1427
1338
  assetId: hexOrZero(receipt.assetId),
1428
1339
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1465,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1465
1376
  return receiptMessageOut;
1466
1377
  }
1467
1378
  case "MINT" /* Mint */: {
1468
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1379
+ const contractId = hexOrZero(receipt.contract?.id);
1469
1380
  const subId = hexOrZero(receipt.subId);
1470
1381
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1471
1382
  const mintReceipt = {
@@ -1480,7 +1391,7 @@ function assembleReceiptByType(receipt) {
1480
1391
  return mintReceipt;
1481
1392
  }
1482
1393
  case "BURN" /* Burn */: {
1483
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1394
+ const contractId = hexOrZero(receipt.contract?.id);
1484
1395
  const subId = hexOrZero(receipt.subId);
1485
1396
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1486
1397
  const burnReceipt = {
@@ -1506,6 +1417,7 @@ var import_errors6 = require("@fuel-ts/errors");
1506
1417
  var import_math5 = require("@fuel-ts/math");
1507
1418
  var import_transactions4 = require("@fuel-ts/transactions");
1508
1419
  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()));
1509
1421
  var getGasUsedFromReceipts = (receipts) => {
1510
1422
  const scriptResult = receipts.filter(
1511
1423
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1526,28 +1438,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1526
1438
  }
1527
1439
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1528
1440
  const witnessCache = [];
1529
- const chargeableInputs = inputs.filter((input) => {
1530
- const isCoinOrMessage = "owner" in input || "sender" in input;
1531
- if (isCoinOrMessage) {
1532
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1533
- return true;
1534
- }
1535
- if (!witnessCache.includes(input.witnessIndex)) {
1536
- witnessCache.push(input.witnessIndex);
1537
- return true;
1538
- }
1539
- }
1540
- return false;
1541
- });
1542
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1543
- const totalGas = chargeableInputs.reduce((total, input) => {
1441
+ const totalGas = inputs.reduce((total, input) => {
1544
1442
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1545
1443
  return total.add(
1546
- vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1444
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1547
1445
  );
1548
1446
  }
1549
- return total.add(gasCosts.ecr1);
1550
- }, (0, import_math5.bn)(0));
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)());
1551
1453
  return totalGas;
1552
1454
  }
1553
1455
  function getMinGas(params) {
@@ -1559,20 +1461,12 @@ function getMinGas(params) {
1559
1461
  return minGas;
1560
1462
  }
1561
1463
  function getMaxGas(params) {
1562
- const {
1563
- gasPerByte,
1564
- witnessesLength,
1565
- witnessLimit,
1566
- minGas,
1567
- gasLimit = (0, import_math5.bn)(0),
1568
- maxGasPerTx
1569
- } = params;
1464
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1570
1465
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1571
1466
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1572
1467
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1573
1468
  }
1574
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1575
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1469
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1576
1470
  }
1577
1471
  function calculateMetadataGasForTxCreate({
1578
1472
  gasCosts,
@@ -1594,10 +1488,6 @@ function calculateMetadataGasForTxScript({
1594
1488
  }) {
1595
1489
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1596
1490
  }
1597
- var calculateGasFee = (params) => {
1598
- const { gas, gasPrice, priceFactor, tip } = params;
1599
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1600
- };
1601
1491
 
1602
1492
  // src/providers/utils/json.ts
1603
1493
  var import_utils7 = require("@fuel-ts/utils");
@@ -1734,7 +1624,7 @@ var witnessify = (value) => {
1734
1624
  // src/providers/transaction-request/transaction-request.ts
1735
1625
  var BaseTransactionRequest = class {
1736
1626
  /** Gas price for transaction */
1737
- tip;
1627
+ gasPrice;
1738
1628
  /** Block until which tx cannot be included */
1739
1629
  maturity;
1740
1630
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1753,7 +1643,7 @@ var BaseTransactionRequest = class {
1753
1643
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1754
1644
  */
1755
1645
  constructor({
1756
- tip,
1646
+ gasPrice,
1757
1647
  maturity,
1758
1648
  maxFee,
1759
1649
  witnessLimit,
@@ -1761,7 +1651,7 @@ var BaseTransactionRequest = class {
1761
1651
  outputs,
1762
1652
  witnesses
1763
1653
  } = {}) {
1764
- this.tip = (0, import_math7.bn)(tip);
1654
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1765
1655
  this.maturity = maturity ?? 0;
1766
1656
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1767
1657
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1772,9 +1662,9 @@ var BaseTransactionRequest = class {
1772
1662
  static getPolicyMeta(req) {
1773
1663
  let policyTypes = 0;
1774
1664
  const policies = [];
1775
- if (req.tip) {
1776
- policyTypes += import_transactions6.PolicyType.Tip;
1777
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1665
+ if (req.gasPrice) {
1666
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1667
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1778
1668
  }
1779
1669
  if (req.witnessLimit) {
1780
1670
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1958,11 +1848,13 @@ var BaseTransactionRequest = class {
1958
1848
  * assetId, if one it was not added yet.
1959
1849
  *
1960
1850
  * @param coin - Coin resource.
1851
+ * @param predicate - Predicate bytes.
1852
+ * @param predicateData - Predicate data bytes.
1961
1853
  */
1962
- addCoinInput(coin) {
1854
+ addCoinInput(coin, predicate) {
1963
1855
  const { assetId, owner, amount } = coin;
1964
1856
  let witnessIndex;
1965
- if (coin.predicate) {
1857
+ if (predicate) {
1966
1858
  witnessIndex = 0;
1967
1859
  } else {
1968
1860
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1977,7 +1869,8 @@ var BaseTransactionRequest = class {
1977
1869
  amount,
1978
1870
  assetId,
1979
1871
  txPointer: "0x00000000000000000000000000000000",
1980
- witnessIndex
1872
+ witnessIndex,
1873
+ predicate: predicate?.bytes
1981
1874
  };
1982
1875
  this.pushInput(input);
1983
1876
  this.addChangeOutput(owner, assetId);
@@ -1987,12 +1880,14 @@ var BaseTransactionRequest = class {
1987
1880
  * baseAssetId, if one it was not added yet.
1988
1881
  *
1989
1882
  * @param message - Message resource.
1883
+ * @param predicate - Predicate bytes.
1884
+ * @param predicateData - Predicate data bytes.
1990
1885
  */
1991
- addMessageInput(message) {
1886
+ addMessageInput(message, predicate) {
1992
1887
  const { recipient, sender, amount } = message;
1993
1888
  const assetId = import_configs7.BaseAssetId;
1994
1889
  let witnessIndex;
1995
- if (message.predicate) {
1890
+ if (predicate) {
1996
1891
  witnessIndex = 0;
1997
1892
  } else {
1998
1893
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2006,7 +1901,8 @@ var BaseTransactionRequest = class {
2006
1901
  sender: sender.toB256(),
2007
1902
  recipient: recipient.toB256(),
2008
1903
  amount,
2009
- witnessIndex
1904
+ witnessIndex,
1905
+ predicate: predicate?.bytes
2010
1906
  };
2011
1907
  this.pushInput(input);
2012
1908
  this.addChangeOutput(recipient, assetId);
@@ -2037,6 +1933,32 @@ var BaseTransactionRequest = class {
2037
1933
  resources.forEach((resource) => this.addResource(resource));
2038
1934
  return this;
2039
1935
  }
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
+ }
2040
1962
  /**
2041
1963
  * Adds a coin output to the transaction.
2042
1964
  *
@@ -2116,7 +2038,7 @@ var BaseTransactionRequest = class {
2116
2038
  }
2117
2039
  calculateMaxGas(chainInfo, minGas) {
2118
2040
  const { consensusParameters } = chainInfo;
2119
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2041
+ const { gasPerByte } = consensusParameters;
2120
2042
  const witnessesLength = this.toTransaction().witnesses.reduce(
2121
2043
  (acc, wit) => acc + wit.dataLength,
2122
2044
  0
@@ -2125,8 +2047,7 @@ var BaseTransactionRequest = class {
2125
2047
  gasPerByte,
2126
2048
  minGas,
2127
2049
  witnessesLength,
2128
- witnessLimit: this.witnessLimit,
2129
- maxGasPerTx
2050
+ witnessLimit: this.witnessLimit
2130
2051
  });
2131
2052
  }
2132
2053
  /**
@@ -2144,20 +2065,17 @@ var BaseTransactionRequest = class {
2144
2065
  });
2145
2066
  const updateAssetInput = (assetId, quantity) => {
2146
2067
  const assetInput = findAssetInput(assetId);
2147
- let usedQuantity = quantity;
2148
- if (assetId === import_configs7.BaseAssetId) {
2149
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2150
- }
2151
2068
  if (assetInput && "assetId" in assetInput) {
2152
2069
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2153
- assetInput.amount = usedQuantity;
2070
+ assetInput.amount = quantity;
2154
2071
  } else {
2155
2072
  this.addResources([
2156
2073
  {
2157
2074
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2158
- amount: usedQuantity,
2075
+ amount: quantity,
2159
2076
  assetId,
2160
2077
  owner: resourcesOwner || import_address.Address.fromRandom(),
2078
+ maturity: 0,
2161
2079
  blockCreated: (0, import_math7.bn)(1),
2162
2080
  txCreatedIdx: (0, import_math7.bn)(1)
2163
2081
  }
@@ -2189,7 +2107,7 @@ var BaseTransactionRequest = class {
2189
2107
  toJSON() {
2190
2108
  return normalizeJSON(this);
2191
2109
  }
2192
- updatePredicateGasUsed(inputs) {
2110
+ updatePredicateInputs(inputs) {
2193
2111
  this.inputs.forEach((i) => {
2194
2112
  let correspondingInput;
2195
2113
  switch (i.type) {
@@ -2211,15 +2129,6 @@ var BaseTransactionRequest = class {
2211
2129
  }
2212
2130
  });
2213
2131
  }
2214
- shiftPredicateData() {
2215
- this.inputs.forEach((input) => {
2216
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2217
- input.predicateData = input.padPredicateData(
2218
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2219
- );
2220
- }
2221
- });
2222
- }
2223
2132
  };
2224
2133
 
2225
2134
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2366,8 +2275,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2366
2275
  return {
2367
2276
  type: import_transactions8.TransactionType.Create,
2368
2277
  ...baseTransaction,
2278
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2369
2279
  bytecodeWitnessIndex,
2370
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2280
+ storageSlotsCount: storageSlots.length,
2371
2281
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2372
2282
  storageSlots
2373
2283
  };
@@ -2490,8 +2400,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2490
2400
  type: import_transactions9.TransactionType.Script,
2491
2401
  scriptGasLimit: this.gasLimit,
2492
2402
  ...super.getBaseTransaction(),
2493
- scriptLength: (0, import_math10.bn)(script.length),
2494
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2403
+ scriptLength: script.length,
2404
+ scriptDataLength: scriptData.length,
2495
2405
  receiptsRoot: import_configs10.ZeroBytes32,
2496
2406
  script: (0, import_utils15.hexlify)(script),
2497
2407
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2555,7 +2465,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2555
2465
  }
2556
2466
  calculateMaxGas(chainInfo, minGas) {
2557
2467
  const { consensusParameters } = chainInfo;
2558
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2468
+ const { gasPerByte } = consensusParameters;
2559
2469
  const witnessesLength = this.toTransaction().witnesses.reduce(
2560
2470
  (acc, wit) => acc + wit.dataLength,
2561
2471
  0
@@ -2565,8 +2475,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2565
2475
  minGas,
2566
2476
  witnessesLength,
2567
2477
  witnessLimit: this.witnessLimit,
2568
- gasLimit: this.gasLimit,
2569
- maxGasPerTx
2478
+ gasLimit: this.gasLimit
2570
2479
  });
2571
2480
  }
2572
2481
  /**
@@ -2641,32 +2550,15 @@ var transactionRequestify = (obj) => {
2641
2550
  }
2642
2551
  }
2643
2552
  };
2644
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2645
- (acc, input) => {
2646
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2647
- acc.utxos.push(input.id);
2648
- }
2649
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2650
- acc.messages.push(input.nonce);
2651
- }
2652
- return acc;
2653
- },
2654
- {
2655
- utxos: [],
2656
- messages: []
2657
- }
2658
- );
2659
2553
 
2660
2554
  // src/providers/transaction-response/transaction-response.ts
2661
2555
  var import_errors13 = require("@fuel-ts/errors");
2662
- var import_math15 = require("@fuel-ts/math");
2663
- var import_transactions18 = require("@fuel-ts/transactions");
2664
- var import_utils20 = require("@fuel-ts/utils");
2556
+ var import_math14 = require("@fuel-ts/math");
2557
+ var import_transactions17 = require("@fuel-ts/transactions");
2558
+ var import_utils21 = require("@fuel-ts/utils");
2665
2559
 
2666
2560
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2667
- var import_math14 = require("@fuel-ts/math");
2668
- var import_transactions16 = require("@fuel-ts/transactions");
2669
- var import_utils18 = require("@fuel-ts/utils");
2561
+ var import_utils19 = require("@fuel-ts/utils");
2670
2562
 
2671
2563
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2672
2564
  var import_math11 = require("@fuel-ts/math");
@@ -2674,10 +2566,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2674
2566
  var import_utils16 = require("@fuel-ts/utils");
2675
2567
  var calculateTransactionFee = (params) => {
2676
2568
  const {
2677
- gasPrice,
2569
+ gasUsed,
2678
2570
  rawPayload,
2679
- tip,
2680
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2571
+ consensusParameters: { gasCosts, feeParams }
2681
2572
  } = params;
2682
2573
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2683
2574
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2687,7 +2578,8 @@ var calculateTransactionFee = (params) => {
2687
2578
  return {
2688
2579
  fee: (0, import_math11.bn)(0),
2689
2580
  minFee: (0, import_math11.bn)(0),
2690
- maxFee: (0, import_math11.bn)(0)
2581
+ maxFee: (0, import_math11.bn)(0),
2582
+ feeFromGasUsed: (0, import_math11.bn)(0)
2691
2583
  };
2692
2584
  }
2693
2585
  const { type, witnesses, inputs, policies } = transaction;
@@ -2719,6 +2611,7 @@ var calculateTransactionFee = (params) => {
2719
2611
  metadataGas,
2720
2612
  txBytesSize: transactionBytes.length
2721
2613
  });
2614
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2722
2615
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2723
2616
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2724
2617
  const maxGas = getMaxGas({
@@ -2726,25 +2619,17 @@ var calculateTransactionFee = (params) => {
2726
2619
  minGas,
2727
2620
  witnessesLength,
2728
2621
  gasLimit,
2729
- witnessLimit,
2730
- maxGasPerTx
2731
- });
2732
- const minFee = calculateGasFee({
2733
- gasPrice,
2734
- gas: minGas,
2735
- priceFactor: gasPriceFactor,
2736
- tip
2737
- });
2738
- const maxFee = calculateGasFee({
2739
- gasPrice,
2740
- gas: maxGas,
2741
- priceFactor: gasPriceFactor,
2742
- tip
2622
+ witnessLimit
2743
2623
  });
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);
2744
2628
  return {
2629
+ fee,
2745
2630
  minFee,
2746
2631
  maxFee,
2747
- fee: maxFee
2632
+ feeFromGasUsed
2748
2633
  };
2749
2634
  };
2750
2635
 
@@ -3311,12 +3196,10 @@ function assembleTransactionSummary(params) {
3311
3196
  gqlTransactionStatus,
3312
3197
  abiMap = {},
3313
3198
  maxInputs,
3314
- gasCosts,
3315
- maxGasPerTx,
3316
- gasPrice
3199
+ gasCosts
3317
3200
  } = params;
3318
3201
  const gasUsed = getGasUsedFromReceipts(receipts);
3319
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3202
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3320
3203
  const operations = getOperations({
3321
3204
  transactionType: transaction.type,
3322
3205
  inputs: transaction.inputs || [],
@@ -3327,14 +3210,11 @@ function assembleTransactionSummary(params) {
3327
3210
  maxInputs
3328
3211
  });
3329
3212
  const typeName = getTransactionTypeName(transaction.type);
3330
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3331
3213
  const { fee } = calculateTransactionFee({
3332
- gasPrice,
3214
+ gasUsed,
3333
3215
  rawPayload,
3334
- tip,
3335
3216
  consensusParameters: {
3336
3217
  gasCosts,
3337
- maxGasPerTx,
3338
3218
  feeParams: {
3339
3219
  gasPerByte,
3340
3220
  gasPriceFactor
@@ -3346,7 +3226,7 @@ function assembleTransactionSummary(params) {
3346
3226
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3347
3227
  let date;
3348
3228
  if (time) {
3349
- date = import_utils18.DateTime.fromTai64(time);
3229
+ date = import_utils19.DateTime.fromTai64(time);
3350
3230
  }
3351
3231
  const transactionSummary = {
3352
3232
  id,
@@ -3374,12 +3254,12 @@ function assembleTransactionSummary(params) {
3374
3254
 
3375
3255
  // src/providers/transaction-response/getDecodedLogs.ts
3376
3256
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3377
- var import_transactions17 = require("@fuel-ts/transactions");
3257
+ var import_transactions16 = require("@fuel-ts/transactions");
3378
3258
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3379
3259
  return receipts.reduce((logs, receipt) => {
3380
- if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
3260
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3381
3261
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3382
- const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3262
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3383
3263
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3384
3264
  logs.push(decodedLog);
3385
3265
  }
@@ -3394,7 +3274,7 @@ var TransactionResponse = class {
3394
3274
  /** Current provider */
3395
3275
  provider;
3396
3276
  /** Gas used on the transaction */
3397
- gasUsed = (0, import_math15.bn)(0);
3277
+ gasUsed = (0, import_math14.bn)(0);
3398
3278
  /** The graphql Transaction with receipts object. */
3399
3279
  gqlTransaction;
3400
3280
  abis;
@@ -3452,8 +3332,8 @@ var TransactionResponse = class {
3452
3332
  * @returns The decoded transaction.
3453
3333
  */
3454
3334
  decodeTransaction(transactionWithReceipts) {
3455
- return new import_transactions18.TransactionCoder().decode(
3456
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3335
+ return new import_transactions17.TransactionCoder().decode(
3336
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3457
3337
  0
3458
3338
  )?.[0];
3459
3339
  }
@@ -3472,27 +3352,20 @@ var TransactionResponse = class {
3472
3352
  const decodedTransaction = this.decodeTransaction(
3473
3353
  transaction
3474
3354
  );
3475
- let txReceipts = [];
3476
- if (transaction?.status && "receipts" in transaction.status) {
3477
- txReceipts = transaction.status.receipts;
3478
- }
3479
- const receipts = txReceipts.map(processGqlReceipt) || [];
3480
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3481
- const gasPrice = await this.provider.getLatestGasPrice();
3355
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3356
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3482
3357
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3483
3358
  const transactionSummary = assembleTransactionSummary({
3484
3359
  id: this.id,
3485
3360
  receipts,
3486
3361
  transaction: decodedTransaction,
3487
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3362
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3488
3363
  gqlTransactionStatus: transaction.status,
3489
3364
  gasPerByte,
3490
3365
  gasPriceFactor,
3491
3366
  abiMap: contractsAbiMap,
3492
3367
  maxInputs,
3493
- gasCosts,
3494
- maxGasPerTx,
3495
- gasPrice
3368
+ gasCosts
3496
3369
  });
3497
3370
  return transactionSummary;
3498
3371
  }
@@ -3619,29 +3492,29 @@ var processGqlChain = (chain) => {
3619
3492
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3620
3493
  return {
3621
3494
  name,
3622
- baseChainHeight: (0, import_math16.bn)(daHeight),
3495
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3623
3496
  consensusParameters: {
3624
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3625
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3626
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3627
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3628
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3629
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3630
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3631
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3632
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3633
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3634
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3635
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3636
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3637
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3638
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
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),
3639
3512
  gasCosts
3640
3513
  },
3641
3514
  gasCosts,
3642
3515
  latestBlock: {
3643
3516
  id: latestBlock.id,
3644
- height: (0, import_math16.bn)(latestBlock.height),
3517
+ height: (0, import_math15.bn)(latestBlock.header.height),
3645
3518
  time: latestBlock.header.time,
3646
3519
  transactions: latestBlock.transactions.map((i) => ({
3647
3520
  id: i.id
@@ -3735,8 +3608,10 @@ var _Provider = class {
3735
3608
  * Returns some helpful parameters related to gas fees.
3736
3609
  */
3737
3610
  getGasConfig() {
3611
+ const { minGasPrice } = this.getNode();
3738
3612
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3739
3613
  return {
3614
+ minGasPrice,
3740
3615
  maxGasPerTx,
3741
3616
  maxGasPerPredicate,
3742
3617
  gasPriceFactor,
@@ -3834,7 +3709,7 @@ var _Provider = class {
3834
3709
  */
3835
3710
  async getBlockNumber() {
3836
3711
  const { chain } = await this.operations.getChain();
3837
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3712
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3838
3713
  }
3839
3714
  /**
3840
3715
  * Returns the chain information.
@@ -3844,11 +3719,13 @@ var _Provider = class {
3844
3719
  async fetchNode() {
3845
3720
  const { nodeInfo } = await this.operations.getNodeInfo();
3846
3721
  const processedNodeInfo = {
3847
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3848
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3722
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3723
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3724
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3849
3725
  nodeVersion: nodeInfo.nodeVersion,
3850
3726
  utxoValidation: nodeInfo.utxoValidation,
3851
- vmBacktrace: nodeInfo.vmBacktrace
3727
+ vmBacktrace: nodeInfo.vmBacktrace,
3728
+ peers: nodeInfo.peers
3852
3729
  };
3853
3730
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3854
3731
  return processedNodeInfo;
@@ -3890,9 +3767,9 @@ var _Provider = class {
3890
3767
  if (estimateTxDependencies) {
3891
3768
  await this.estimateTxDependencies(transactionRequest);
3892
3769
  }
3893
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3770
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3894
3771
  let abis;
3895
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3772
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3896
3773
  abis = transactionRequest.abis;
3897
3774
  }
3898
3775
  if (awaitExecution) {
@@ -3933,14 +3810,15 @@ var _Provider = class {
3933
3810
  if (estimateTxDependencies) {
3934
3811
  return this.estimateTxDependencies(transactionRequest);
3935
3812
  }
3936
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3937
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3938
- encodedTransactions: encodedTransaction,
3813
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3814
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3815
+ encodedTransaction,
3939
3816
  utxoValidation: utxoValidation || false
3940
3817
  });
3941
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3942
- const receipts = rawReceipts.map(processGqlReceipt);
3943
- return { receipts, dryrunStatus: status };
3818
+ const receipts = gqlReceipts.map(processGqlReceipt);
3819
+ return {
3820
+ receipts
3821
+ };
3944
3822
  }
3945
3823
  /**
3946
3824
  * Verifies whether enough gas is available to complete transaction.
@@ -3951,13 +3829,13 @@ var _Provider = class {
3951
3829
  async estimatePredicates(transactionRequest) {
3952
3830
  const shouldEstimatePredicates = Boolean(
3953
3831
  transactionRequest.inputs.find(
3954
- (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()
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()
3955
3833
  )
3956
3834
  );
3957
3835
  if (!shouldEstimatePredicates) {
3958
3836
  return transactionRequest;
3959
3837
  }
3960
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3838
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3961
3839
  const response = await this.operations.estimatePredicates({
3962
3840
  encodedTransaction
3963
3841
  });
@@ -3966,7 +3844,7 @@ var _Provider = class {
3966
3844
  } = response;
3967
3845
  if (inputs) {
3968
3846
  inputs.forEach((input, index) => {
3969
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
3847
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3970
3848
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3971
3849
  }
3972
3850
  });
@@ -3979,31 +3857,31 @@ var _Provider = class {
3979
3857
  * If there are missing variable outputs,
3980
3858
  * `addVariableOutputs` is called on the transaction.
3981
3859
  *
3860
+ * @privateRemarks
3861
+ * TODO: Investigate support for missing contract IDs
3862
+ * TODO: Add support for missing output messages
3982
3863
  *
3983
3864
  * @param transactionRequest - The transaction request object.
3984
3865
  * @returns A promise.
3985
3866
  */
3986
3867
  async estimateTxDependencies(transactionRequest) {
3987
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3868
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3988
3869
  return {
3989
3870
  receipts: [],
3990
3871
  outputVariables: 0,
3991
3872
  missingContractIds: []
3992
3873
  };
3993
3874
  }
3875
+ await this.estimatePredicates(transactionRequest);
3994
3876
  let receipts = [];
3995
3877
  const missingContractIds = [];
3996
3878
  let outputVariables = 0;
3997
- let dryrunStatus;
3998
3879
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3999
- const {
4000
- dryRun: [{ receipts: rawReceipts, status }]
4001
- } = await this.operations.dryRun({
4002
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3880
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3881
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4003
3882
  utxoValidation: false
4004
3883
  });
4005
- receipts = rawReceipts.map(processGqlReceipt);
4006
- dryrunStatus = status;
3884
+ receipts = gqlReceipts.map(processGqlReceipt);
4007
3885
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4008
3886
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4009
3887
  if (hasMissingOutputs) {
@@ -4013,10 +3891,6 @@ var _Provider = class {
4013
3891
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4014
3892
  missingContractIds.push(contractId);
4015
3893
  });
4016
- const { maxFee } = await this.estimateTxGasAndFee({
4017
- transactionRequest
4018
- });
4019
- transactionRequest.maxFee = maxFee;
4020
3894
  } else {
4021
3895
  break;
4022
3896
  }
@@ -4024,139 +3898,37 @@ var _Provider = class {
4024
3898
  return {
4025
3899
  receipts,
4026
3900
  outputVariables,
4027
- missingContractIds,
4028
- dryrunStatus
3901
+ missingContractIds
4029
3902
  };
4030
3903
  }
4031
- /**
4032
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4033
- *
4034
- * Transactions are dry run in batches. After each dry run, transactions requiring
4035
- * further modifications are identified. The method iteratively updates these transactions
4036
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4037
- *
4038
- * @param transactionRequests - Array of transaction request objects.
4039
- * @returns A promise that resolves to an array of results for each transaction.
4040
- */
4041
- async estimateMultipleTxDependencies(transactionRequests) {
4042
- const results = transactionRequests.map(() => ({
4043
- receipts: [],
4044
- outputVariables: 0,
4045
- missingContractIds: [],
4046
- dryrunStatus: void 0
4047
- }));
4048
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4049
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4050
- allRequests.forEach((req, index) => {
4051
- if (req.type === import_transactions19.TransactionType.Script) {
4052
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4053
- }
4054
- });
4055
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4056
- let attempt = 0;
4057
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4058
- const encodedTransactions = transactionsToProcess.map(
4059
- (index) => serializedTransactionsMap.get(index)
4060
- );
4061
- const dryRunResults = await this.operations.dryRun({
4062
- encodedTransactions,
4063
- utxoValidation: false
4064
- });
4065
- const nextRoundTransactions = [];
4066
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4067
- const currentResultIndex = transactionsToProcess[i];
4068
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4069
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4070
- results[currentResultIndex].dryrunStatus = status;
4071
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4072
- results[currentResultIndex].receipts
4073
- );
4074
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4075
- const requestToProcess = allRequests[currentResultIndex];
4076
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4077
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4078
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4079
- missingOutputContractIds.forEach(({ contractId }) => {
4080
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4081
- results[currentResultIndex].missingContractIds.push(contractId);
4082
- });
4083
- const { maxFee } = await this.estimateTxGasAndFee({
4084
- transactionRequest: requestToProcess
4085
- });
4086
- requestToProcess.maxFee = maxFee;
4087
- serializedTransactionsMap.set(
4088
- currentResultIndex,
4089
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4090
- );
4091
- nextRoundTransactions.push(currentResultIndex);
4092
- allRequests[currentResultIndex] = requestToProcess;
4093
- }
4094
- }
4095
- transactionsToProcess = nextRoundTransactions;
4096
- attempt += 1;
4097
- }
4098
- return results;
4099
- }
4100
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4101
- if (estimateTxDependencies) {
4102
- return this.estimateMultipleTxDependencies(transactionRequests);
4103
- }
4104
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4105
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4106
- encodedTransactions,
4107
- utxoValidation: utxoValidation || false
4108
- });
4109
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4110
- const receipts = rawReceipts.map(processGqlReceipt);
4111
- return { receipts, dryrunStatus: status };
4112
- });
4113
- return results;
4114
- }
4115
3904
  /**
4116
3905
  * Estimates the transaction gas and fee based on the provided transaction request.
4117
3906
  * @param transactionRequest - The transaction request object.
4118
3907
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4119
3908
  */
4120
- async estimateTxGasAndFee(params) {
3909
+ estimateTxGasAndFee(params) {
4121
3910
  const { transactionRequest } = params;
4122
- let { gasPrice } = params;
3911
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4123
3912
  const chainInfo = this.getChain();
4124
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3913
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3914
+ transactionRequest.gasPrice = gasPrice;
4125
3915
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4126
- if (!gasPrice) {
4127
- gasPrice = await this.estimateGasPrice(10);
4128
- }
4129
- const minFee = calculateGasFee({
4130
- gasPrice: (0, import_math16.bn)(gasPrice),
4131
- gas: minGas,
4132
- priceFactor: gasPriceFactor,
4133
- tip: transactionRequest.tip
4134
- }).add(1);
4135
- let gasLimit = (0, import_math16.bn)(0);
4136
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4137
- gasLimit = transactionRequest.gasLimit;
3916
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3917
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4138
3918
  if (transactionRequest.gasLimit.eq(0)) {
4139
3919
  transactionRequest.gasLimit = minGas;
4140
3920
  transactionRequest.gasLimit = maxGasPerTx.sub(
4141
3921
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4142
3922
  );
4143
- gasLimit = transactionRequest.gasLimit;
4144
3923
  }
4145
3924
  }
4146
3925
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4147
- const maxFee = calculateGasFee({
4148
- gasPrice: (0, import_math16.bn)(gasPrice),
4149
- gas: maxGas,
4150
- priceFactor: gasPriceFactor,
4151
- tip: transactionRequest.tip
4152
- }).add(1);
3926
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4153
3927
  return {
4154
3928
  minGas,
4155
3929
  minFee,
4156
3930
  maxGas,
4157
- maxFee,
4158
- gasPrice,
4159
- gasLimit
3931
+ maxFee
4160
3932
  };
4161
3933
  }
4162
3934
  /**
@@ -4174,17 +3946,15 @@ var _Provider = class {
4174
3946
  if (estimateTxDependencies) {
4175
3947
  return this.estimateTxDependencies(transactionRequest);
4176
3948
  }
4177
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4178
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4179
- encodedTransactions,
3949
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3950
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3951
+ encodedTransaction,
4180
3952
  utxoValidation: true
4181
3953
  });
4182
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4183
- const { id, receipts, status } = dryRunStatus;
4184
- const processedReceipts = receipts.map(processGqlReceipt);
4185
- return { id, receipts: processedReceipts, status };
4186
- });
4187
- return { receipts: callResult[0].receipts };
3954
+ const receipts = gqlReceipts.map(processGqlReceipt);
3955
+ return {
3956
+ receipts
3957
+ };
4188
3958
  }
4189
3959
  /**
4190
3960
  * Returns a transaction cost to enable user
@@ -4201,79 +3971,77 @@ var _Provider = class {
4201
3971
  * @param tolerance - The tolerance to add on top of the gasUsed.
4202
3972
  * @returns A promise that resolves to the transaction cost object.
4203
3973
  */
4204
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3974
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3975
+ estimateTxDependencies = true,
3976
+ estimatePredicates = true,
3977
+ resourcesOwner,
3978
+ signatureCallback
3979
+ } = {}) {
4205
3980
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4206
- const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
3981
+ const { minGasPrice } = this.getGasConfig();
3982
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3983
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4207
3984
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4208
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3985
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4209
3986
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4210
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4211
3987
  if (isScriptTransaction) {
4212
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
3988
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4213
3989
  }
4214
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4215
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3990
+ if (estimatePredicates) {
3991
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3992
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3993
+ }
3994
+ await this.estimatePredicates(txRequestClone);
4216
3995
  }
4217
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4218
- let addedSignatures = 0;
4219
3996
  if (signatureCallback && isScriptTransaction) {
4220
- const lengthBefore = signedRequest.witnesses.length;
4221
- await signatureCallback(signedRequest);
4222
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3997
+ await signatureCallback(txRequestClone);
4223
3998
  }
4224
- await this.estimatePredicates(signedRequest);
4225
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4226
- transactionRequest: signedRequest
3999
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
+ transactionRequest: txRequestClone
4227
4001
  });
4228
4002
  let receipts = [];
4229
4003
  let missingContractIds = [];
4230
4004
  let outputVariables = 0;
4231
- let gasUsed = (0, import_math16.bn)(0);
4232
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4233
- txRequestClone.maxFee = maxFee;
4234
- if (isScriptTransaction) {
4235
- txRequestClone.gasLimit = gasLimit;
4236
- if (signatureCallback) {
4237
- await signatureCallback(txRequestClone);
4238
- }
4005
+ let gasUsed = (0, import_math15.bn)(0);
4006
+ if (isScriptTransaction && estimateTxDependencies) {
4007
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4239
4008
  const result = await this.estimateTxDependencies(txRequestClone);
4240
4009
  receipts = result.receipts;
4241
4010
  outputVariables = result.outputVariables;
4242
4011
  missingContractIds = result.missingContractIds;
4243
4012
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4244
4013
  txRequestClone.gasLimit = gasUsed;
4245
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4246
- transactionRequest: txRequestClone,
4247
- gasPrice
4014
+ txRequestClone.gasPrice = setGasPrice;
4015
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4016
+ transactionRequest: txRequestClone
4248
4017
  }));
4249
4018
  }
4250
4019
  return {
4251
4020
  requiredQuantities: allQuantities,
4252
4021
  receipts,
4253
4022
  gasUsed,
4254
- gasPrice,
4023
+ minGasPrice,
4024
+ gasPrice: setGasPrice,
4255
4025
  minGas,
4256
4026
  maxGas,
4257
4027
  minFee,
4258
4028
  maxFee,
4029
+ estimatedInputs: txRequestClone.inputs,
4259
4030
  outputVariables,
4260
- missingContractIds,
4261
- addedSignatures,
4262
- estimatedPredicates: txRequestClone.inputs
4031
+ missingContractIds
4263
4032
  };
4264
4033
  }
4265
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4034
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4266
4035
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4267
4036
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4268
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4269
- quantitiesToContract
4270
- });
4037
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4271
4038
  transactionRequest.addResources(
4272
4039
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4273
4040
  );
4274
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4275
- quantitiesToContract
4276
- });
4041
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4042
+ transactionRequest,
4043
+ forwardingQuantities
4044
+ );
4277
4045
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4278
4046
  return {
4279
4047
  resources,
@@ -4289,16 +4057,17 @@ var _Provider = class {
4289
4057
  const result = await this.operations.getCoins({
4290
4058
  first: 10,
4291
4059
  ...paginationArgs,
4292
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4060
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4293
4061
  });
4294
4062
  const coins = result.coins.edges.map((edge) => edge.node);
4295
4063
  return coins.map((coin) => ({
4296
4064
  id: coin.utxoId,
4297
4065
  assetId: coin.assetId,
4298
- amount: (0, import_math16.bn)(coin.amount),
4066
+ amount: (0, import_math15.bn)(coin.amount),
4299
4067
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4300
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4301
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
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)
4302
4071
  }));
4303
4072
  }
4304
4073
  /**
@@ -4312,19 +4081,19 @@ var _Provider = class {
4312
4081
  async getResourcesToSpend(owner, quantities, excludedIds) {
4313
4082
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4314
4083
  const excludeInput = {
4315
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4316
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4084
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4085
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4317
4086
  };
4318
4087
  if (this.cache) {
4319
4088
  const uniqueUtxos = new Set(
4320
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4089
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4321
4090
  );
4322
4091
  excludeInput.utxos = Array.from(uniqueUtxos);
4323
4092
  }
4324
4093
  const coinsQuery = {
4325
4094
  owner: ownerAddress.toB256(),
4326
4095
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4327
- assetId: (0, import_utils22.hexlify)(assetId),
4096
+ assetId: (0, import_utils23.hexlify)(assetId),
4328
4097
  amount: amount.toString(10),
4329
4098
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4330
4099
  })),
@@ -4335,9 +4104,9 @@ var _Provider = class {
4335
4104
  switch (coin.__typename) {
4336
4105
  case "MessageCoin":
4337
4106
  return {
4338
- amount: (0, import_math16.bn)(coin.amount),
4107
+ amount: (0, import_math15.bn)(coin.amount),
4339
4108
  assetId: coin.assetId,
4340
- daHeight: (0, import_math16.bn)(coin.daHeight),
4109
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4341
4110
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4342
4111
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4343
4112
  nonce: coin.nonce
@@ -4345,11 +4114,12 @@ var _Provider = class {
4345
4114
  case "Coin":
4346
4115
  return {
4347
4116
  id: coin.utxoId,
4348
- amount: (0, import_math16.bn)(coin.amount),
4117
+ amount: (0, import_math15.bn)(coin.amount),
4349
4118
  assetId: coin.assetId,
4350
4119
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4351
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4352
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
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)
4353
4123
  };
4354
4124
  default:
4355
4125
  return null;
@@ -4366,13 +4136,13 @@ var _Provider = class {
4366
4136
  async getBlock(idOrHeight) {
4367
4137
  let variables;
4368
4138
  if (typeof idOrHeight === "number") {
4369
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4139
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4370
4140
  } else if (idOrHeight === "latest") {
4371
4141
  variables = { height: (await this.getBlockNumber()).toString(10) };
4372
4142
  } else if (idOrHeight.length === 66) {
4373
4143
  variables = { blockId: idOrHeight };
4374
4144
  } else {
4375
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4145
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4376
4146
  }
4377
4147
  const { block } = await this.operations.getBlock(variables);
4378
4148
  if (!block) {
@@ -4380,7 +4150,7 @@ var _Provider = class {
4380
4150
  }
4381
4151
  return {
4382
4152
  id: block.id,
4383
- height: (0, import_math16.bn)(block.height),
4153
+ height: (0, import_math15.bn)(block.header.height),
4384
4154
  time: block.header.time,
4385
4155
  transactionIds: block.transactions.map((tx) => tx.id)
4386
4156
  };
@@ -4395,7 +4165,7 @@ var _Provider = class {
4395
4165
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4396
4166
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4397
4167
  id: block.id,
4398
- height: (0, import_math16.bn)(block.height),
4168
+ height: (0, import_math15.bn)(block.header.height),
4399
4169
  time: block.header.time,
4400
4170
  transactionIds: block.transactions.map((tx) => tx.id)
4401
4171
  }));
@@ -4410,7 +4180,7 @@ var _Provider = class {
4410
4180
  async getBlockWithTransactions(idOrHeight) {
4411
4181
  let variables;
4412
4182
  if (typeof idOrHeight === "number") {
4413
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4183
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4414
4184
  } else if (idOrHeight === "latest") {
4415
4185
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4416
4186
  } else {
@@ -4422,11 +4192,11 @@ var _Provider = class {
4422
4192
  }
4423
4193
  return {
4424
4194
  id: block.id,
4425
- height: (0, import_math16.bn)(block.height, 10),
4195
+ height: (0, import_math15.bn)(block.header.height, 10),
4426
4196
  time: block.header.time,
4427
4197
  transactionIds: block.transactions.map((tx) => tx.id),
4428
4198
  transactions: block.transactions.map(
4429
- (tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4199
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4430
4200
  )
4431
4201
  };
4432
4202
  }
@@ -4441,8 +4211,8 @@ var _Provider = class {
4441
4211
  if (!transaction) {
4442
4212
  return null;
4443
4213
  }
4444
- return new import_transactions19.TransactionCoder().decode(
4445
- (0, import_utils22.arrayify)(transaction.rawPayload),
4214
+ return new import_transactions18.TransactionCoder().decode(
4215
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4446
4216
  0
4447
4217
  )?.[0];
4448
4218
  }
@@ -4469,9 +4239,9 @@ var _Provider = class {
4469
4239
  async getContractBalance(contractId, assetId) {
4470
4240
  const { contractBalance } = await this.operations.getContractBalance({
4471
4241
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4472
- asset: (0, import_utils22.hexlify)(assetId)
4242
+ asset: (0, import_utils23.hexlify)(assetId)
4473
4243
  });
4474
- return (0, import_math16.bn)(contractBalance.amount, 10);
4244
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4475
4245
  }
4476
4246
  /**
4477
4247
  * Returns the balance for the given owner for the given asset ID.
@@ -4483,9 +4253,9 @@ var _Provider = class {
4483
4253
  async getBalance(owner, assetId) {
4484
4254
  const { balance } = await this.operations.getBalance({
4485
4255
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4486
- assetId: (0, import_utils22.hexlify)(assetId)
4256
+ assetId: (0, import_utils23.hexlify)(assetId)
4487
4257
  });
4488
- return (0, import_math16.bn)(balance.amount, 10);
4258
+ return (0, import_math15.bn)(balance.amount, 10);
4489
4259
  }
4490
4260
  /**
4491
4261
  * Returns balances for the given owner.
@@ -4503,7 +4273,7 @@ var _Provider = class {
4503
4273
  const balances = result.balances.edges.map((edge) => edge.node);
4504
4274
  return balances.map((balance) => ({
4505
4275
  assetId: balance.assetId,
4506
- amount: (0, import_math16.bn)(balance.amount)
4276
+ amount: (0, import_math15.bn)(balance.amount)
4507
4277
  }));
4508
4278
  }
4509
4279
  /**
@@ -4521,19 +4291,19 @@ var _Provider = class {
4521
4291
  });
4522
4292
  const messages = result.messages.edges.map((edge) => edge.node);
4523
4293
  return messages.map((message) => ({
4524
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4294
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4525
4295
  sender: message.sender,
4526
4296
  recipient: message.recipient,
4527
4297
  nonce: message.nonce,
4528
- amount: (0, import_math16.bn)(message.amount),
4298
+ amount: (0, import_math15.bn)(message.amount),
4529
4299
  data: message.data
4530
4300
  }),
4531
4301
  sender: import_address3.Address.fromAddressOrString(message.sender),
4532
4302
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4533
4303
  nonce: message.nonce,
4534
- amount: (0, import_math16.bn)(message.amount),
4535
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4536
- daHeight: (0, import_math16.bn)(message.daHeight)
4304
+ amount: (0, import_math15.bn)(message.amount),
4305
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4306
+ daHeight: (0, import_math15.bn)(message.daHeight)
4537
4307
  }));
4538
4308
  }
4539
4309
  /**
@@ -4586,60 +4356,44 @@ var _Provider = class {
4586
4356
  } = result.messageProof;
4587
4357
  return {
4588
4358
  messageProof: {
4589
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4359
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4590
4360
  proofSet: messageProof.proofSet
4591
4361
  },
4592
4362
  blockProof: {
4593
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4363
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4594
4364
  proofSet: blockProof.proofSet
4595
4365
  },
4596
4366
  messageBlockHeader: {
4597
4367
  id: messageBlockHeader.id,
4598
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4599
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4368
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4369
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4600
4370
  transactionsRoot: messageBlockHeader.transactionsRoot,
4601
- height: (0, import_math16.bn)(messageBlockHeader.height),
4371
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4602
4372
  prevRoot: messageBlockHeader.prevRoot,
4603
4373
  time: messageBlockHeader.time,
4604
4374
  applicationHash: messageBlockHeader.applicationHash,
4605
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4606
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4607
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4608
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4609
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4375
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4376
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4610
4377
  },
4611
4378
  commitBlockHeader: {
4612
4379
  id: commitBlockHeader.id,
4613
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4614
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4380
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4381
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4615
4382
  transactionsRoot: commitBlockHeader.transactionsRoot,
4616
- height: (0, import_math16.bn)(commitBlockHeader.height),
4383
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4617
4384
  prevRoot: commitBlockHeader.prevRoot,
4618
4385
  time: commitBlockHeader.time,
4619
4386
  applicationHash: commitBlockHeader.applicationHash,
4620
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4621
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4622
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4623
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4624
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4387
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4388
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4625
4389
  },
4626
4390
  sender: import_address3.Address.fromAddressOrString(sender),
4627
4391
  recipient: import_address3.Address.fromAddressOrString(recipient),
4628
4392
  nonce,
4629
- amount: (0, import_math16.bn)(amount),
4393
+ amount: (0, import_math15.bn)(amount),
4630
4394
  data
4631
4395
  };
4632
4396
  }
4633
- async getLatestGasPrice() {
4634
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4635
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4636
- }
4637
- async estimateGasPrice(blockHorizon) {
4638
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4639
- blockHorizon: String(blockHorizon)
4640
- });
4641
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4642
- }
4643
4397
  /**
4644
4398
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4645
4399
  *
@@ -4659,10 +4413,10 @@ var _Provider = class {
4659
4413
  */
4660
4414
  async produceBlocks(amount, startTime) {
4661
4415
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4662
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4663
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4416
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4417
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4664
4418
  });
4665
- return (0, import_math16.bn)(latestBlockHeight);
4419
+ return (0, import_math15.bn)(latestBlockHeight);
4666
4420
  }
4667
4421
  // eslint-disable-next-line @typescript-eslint/require-await
4668
4422
  async getTransactionResponse(transactionId) {
@@ -4676,7 +4430,7 @@ cacheInputs_fn = function(inputs) {
4676
4430
  return;
4677
4431
  }
4678
4432
  inputs.forEach((input) => {
4679
- if (input.type === import_transactions19.InputType.Coin) {
4433
+ if (input.type === import_transactions18.InputType.Coin) {
4680
4434
  this.cache?.set(input.id);
4681
4435
  }
4682
4436
  });
@@ -4686,9 +4440,9 @@ __publicField(Provider, "nodeInfoCache", {});
4686
4440
 
4687
4441
  // src/providers/transaction-summary/get-transaction-summary.ts
4688
4442
  var import_errors15 = require("@fuel-ts/errors");
4689
- var import_math17 = require("@fuel-ts/math");
4690
- var import_transactions20 = require("@fuel-ts/transactions");
4691
- var import_utils25 = require("@fuel-ts/utils");
4443
+ var import_math16 = require("@fuel-ts/math");
4444
+ var import_transactions19 = require("@fuel-ts/transactions");
4445
+ var import_utils26 = require("@fuel-ts/utils");
4692
4446
 
4693
4447
  // src/providers/chains.ts
4694
4448
  var CHAIN_IDS = {
@@ -4737,17 +4491,17 @@ var assets = [
4737
4491
 
4738
4492
  // src/utils/formatTransferToContractScriptData.ts
4739
4493
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4740
- var import_math18 = require("@fuel-ts/math");
4741
- var import_utils26 = require("@fuel-ts/utils");
4494
+ var import_math17 = require("@fuel-ts/math");
4495
+ var import_utils27 = require("@fuel-ts/utils");
4742
4496
  var asm = __toESM(require("@fuels/vm-asm"));
4743
4497
  var formatTransferToContractScriptData = (params) => {
4744
4498
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4745
4499
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4746
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4500
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4747
4501
  const scriptData = Uint8Array.from([
4748
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4502
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4749
4503
  ...encoded,
4750
- ...(0, import_utils26.arrayify)(assetId)
4504
+ ...(0, import_utils27.arrayify)(assetId)
4751
4505
  ]);
4752
4506
  return scriptData;
4753
4507
  };
@@ -4932,33 +4686,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4932
4686
  * @param fee - The estimated transaction fee.
4933
4687
  * @returns A promise that resolves when the resources are added to the transaction.
4934
4688
  */
4935
- async fund(request, params) {
4936
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4937
- const txRequest = request;
4938
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4939
- amount: (0, import_math19.bn)(fee),
4689
+ async fund(request, coinQuantities, fee) {
4690
+ const updatedQuantities = addAmountToAsset({
4691
+ amount: (0, import_math18.bn)(fee),
4940
4692
  assetId: import_configs12.BaseAssetId,
4941
- coinQuantities: requiredQuantities
4693
+ coinQuantities
4942
4694
  });
4943
4695
  const quantitiesDict = {};
4944
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4696
+ updatedQuantities.forEach(({ amount, assetId }) => {
4945
4697
  quantitiesDict[assetId] = {
4946
4698
  required: amount,
4947
- owned: (0, import_math19.bn)(0)
4699
+ owned: (0, import_math18.bn)(0)
4948
4700
  };
4949
4701
  });
4950
- txRequest.inputs.forEach((input) => {
4702
+ const cachedUtxos = [];
4703
+ const cachedMessages = [];
4704
+ const owner = this.address.toB256();
4705
+ request.inputs.forEach((input) => {
4951
4706
  const isResource = "amount" in input;
4952
4707
  if (isResource) {
4953
4708
  const isCoin2 = "owner" in input;
4954
4709
  if (isCoin2) {
4955
4710
  const assetId = String(input.assetId);
4956
- if (quantitiesDict[assetId]) {
4957
- const amount = (0, import_math19.bn)(input.amount);
4711
+ if (input.owner === owner && quantitiesDict[assetId]) {
4712
+ const amount = (0, import_math18.bn)(input.amount);
4958
4713
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4714
+ cachedUtxos.push(input.id);
4959
4715
  }
4960
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4716
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4961
4717
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4718
+ cachedMessages.push(input.nonce);
4962
4719
  }
4963
4720
  }
4964
4721
  });
@@ -4973,23 +4730,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4973
4730
  });
4974
4731
  const needsToBeFunded = missingQuantities.length;
4975
4732
  if (needsToBeFunded) {
4976
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4977
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4978
- txRequest.addResources(resources);
4979
- }
4980
- txRequest.shiftPredicateData();
4981
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4982
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4983
- if (addedSignatures) {
4984
- Array.from({ length: addedSignatures }).forEach(
4985
- () => requestToBeReEstimate.addEmptyWitness()
4986
- );
4733
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4734
+ messages: cachedMessages,
4735
+ utxos: cachedUtxos
4736
+ });
4737
+ request.addResources(resources);
4987
4738
  }
4988
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4989
- transactionRequest: requestToBeReEstimate
4990
- });
4991
- txRequest.maxFee = maxFee;
4992
- return txRequest;
4993
4739
  }
4994
4740
  /**
4995
4741
  * A helper that creates a transfer transaction request and returns it.
@@ -4997,24 +4743,28 @@ var Account = class extends import_interfaces.AbstractAccount {
4997
4743
  * @param destination - The address of the destination.
4998
4744
  * @param amount - The amount of coins to transfer.
4999
4745
  * @param assetId - The asset ID of the coins to transfer.
5000
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4746
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5001
4747
  * @returns A promise that resolves to the prepared transaction request.
5002
4748
  */
5003
4749
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5004
- const request = new ScriptTransactionRequest(txParams);
4750
+ const { minGasPrice } = this.provider.getGasConfig();
4751
+ const params = { gasPrice: minGasPrice, ...txParams };
4752
+ const request = new ScriptTransactionRequest(params);
5005
4753
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5006
- const txCost = await this.provider.getTransactionCost(request, {
4754
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5007
4755
  estimateTxDependencies: true,
5008
4756
  resourcesOwner: this
5009
4757
  });
5010
- this.validateGasLimitAndMaxFee({
5011
- gasUsed: txCost.gasUsed,
5012
- maxFee: txCost.maxFee,
5013
- txParams
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
5014
4765
  });
5015
- request.gasLimit = txCost.gasUsed;
5016
- request.maxFee = txCost.maxFee;
5017
- await this.fund(request, txCost);
4766
+ await this.fund(request, requiredQuantities, maxFee);
4767
+ request.updatePredicateInputs(estimatedInputs);
5018
4768
  return request;
5019
4769
  }
5020
4770
  /**
@@ -5027,7 +4777,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5027
4777
  * @returns A promise that resolves to the transaction response.
5028
4778
  */
5029
4779
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5030
- if ((0, import_math19.bn)(amount).lte(0)) {
4780
+ if ((0, import_math18.bn)(amount).lte(0)) {
5031
4781
  throw new import_errors16.FuelError(
5032
4782
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5033
4783
  "Transfer amount must be a positive number."
@@ -5046,36 +4796,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5046
4796
  * @returns A promise that resolves to the transaction response.
5047
4797
  */
5048
4798
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5049
- if ((0, import_math19.bn)(amount).lte(0)) {
4799
+ if ((0, import_math18.bn)(amount).lte(0)) {
5050
4800
  throw new import_errors16.FuelError(
5051
4801
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5052
4802
  "Transfer amount must be a positive number."
5053
4803
  );
5054
4804
  }
5055
4805
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4806
+ const { minGasPrice } = this.provider.getGasConfig();
4807
+ const params = { gasPrice: minGasPrice, ...txParams };
5056
4808
  const { script, scriptData } = await assembleTransferToContractScript({
5057
4809
  hexlifiedContractId: contractAddress.toB256(),
5058
- amountToTransfer: (0, import_math19.bn)(amount),
4810
+ amountToTransfer: (0, import_math18.bn)(amount),
5059
4811
  assetId
5060
4812
  });
5061
4813
  const request = new ScriptTransactionRequest({
5062
- ...txParams,
4814
+ ...params,
5063
4815
  script,
5064
4816
  scriptData
5065
4817
  });
5066
4818
  request.addContractInputAndOutput(contractAddress);
5067
- const txCost = await this.provider.getTransactionCost(request, {
5068
- resourcesOwner: this,
5069
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
5070
- });
5071
- this.validateGasLimitAndMaxFee({
5072
- gasUsed: txCost.gasUsed,
5073
- maxFee: txCost.maxFee,
5074
- txParams
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
5075
4829
  });
5076
- request.gasLimit = txCost.gasUsed;
5077
- request.maxFee = txCost.maxFee;
5078
- await this.fund(request, txCost);
4830
+ await this.fund(request, requiredQuantities, maxFee);
5079
4831
  return this.sendTransaction(request);
5080
4832
  }
5081
4833
  /**
@@ -5087,30 +4839,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5087
4839
  * @returns A promise that resolves to the transaction response.
5088
4840
  */
5089
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
+ const { minGasPrice } = this.provider.getGasConfig();
5090
4843
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5091
- const recipientDataArray = (0, import_utils27.arrayify)(
4844
+ const recipientDataArray = (0, import_utils28.arrayify)(
5092
4845
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5093
4846
  );
5094
- const amountDataArray = (0, import_utils27.arrayify)(
5095
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
4847
+ const amountDataArray = (0, import_utils28.arrayify)(
4848
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5096
4849
  );
5097
4850
  const script = new Uint8Array([
5098
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4851
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5099
4852
  ...recipientDataArray,
5100
4853
  ...amountDataArray
5101
4854
  ]);
5102
- const params = { script, ...txParams };
4855
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5103
4856
  const request = new ScriptTransactionRequest(params);
5104
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5105
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5106
- this.validateGasLimitAndMaxFee({
5107
- gasUsed: txCost.gasUsed,
5108
- maxFee: txCost.maxFee,
5109
- txParams
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
5110
4868
  });
5111
- request.maxFee = txCost.maxFee;
5112
- request.gasLimit = txCost.gasUsed;
5113
- await this.fund(request, txCost);
4869
+ await this.fund(request, requiredQuantities, maxFee);
5114
4870
  return this.sendTransaction(request);
5115
4871
  }
5116
4872
  async signMessage(message) {
@@ -5168,21 +4924,22 @@ var Account = class extends import_interfaces.AbstractAccount {
5168
4924
  }
5169
4925
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5170
4926
  }
5171
- validateGasLimitAndMaxFee({
5172
- txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
4927
+ validateGas({
5173
4928
  gasUsed,
5174
- maxFee
4929
+ gasPrice,
4930
+ gasLimit,
4931
+ minGasPrice
5175
4932
  }) {
5176
- if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
4933
+ if (minGasPrice.gt(gasPrice)) {
5177
4934
  throw new import_errors16.FuelError(
5178
- import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5179
- `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
4935
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4936
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5180
4937
  );
5181
4938
  }
5182
- if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
4939
+ if (gasUsed.gt(gasLimit)) {
5183
4940
  throw new import_errors16.FuelError(
5184
- import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
5185
- `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
4941
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
4942
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5186
4943
  );
5187
4944
  }
5188
4945
  }
@@ -5192,8 +4949,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5192
4949
  var import_address5 = require("@fuel-ts/address");
5193
4950
  var import_crypto2 = require("@fuel-ts/crypto");
5194
4951
  var import_hasher2 = require("@fuel-ts/hasher");
5195
- var import_math20 = require("@fuel-ts/math");
5196
- var import_utils28 = require("@fuel-ts/utils");
4952
+ var import_math19 = require("@fuel-ts/math");
4953
+ var import_utils29 = require("@fuel-ts/utils");
5197
4954
  var import_secp256k1 = require("@noble/curves/secp256k1");
5198
4955
  var Signer = class {
5199
4956
  address;
@@ -5212,10 +4969,10 @@ var Signer = class {
5212
4969
  privateKey = `0x${privateKey}`;
5213
4970
  }
5214
4971
  }
5215
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5216
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5217
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5218
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
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));
5219
4976
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5220
4977
  }
5221
4978
  /**
@@ -5229,11 +4986,11 @@ var Signer = class {
5229
4986
  * @returns hashed signature
5230
4987
  */
5231
4988
  sign(data) {
5232
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5233
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5234
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
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);
5235
4992
  s[0] |= (signature.recovery || 0) << 7;
5236
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4993
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5237
4994
  }
5238
4995
  /**
5239
4996
  * Add point on the current elliptic curve
@@ -5242,8 +4999,8 @@ var Signer = class {
5242
4999
  * @returns compressed point on the curve
5243
5000
  */
5244
5001
  addPoint(point) {
5245
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5246
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(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));
5247
5004
  const result = p0.add(p1);
5248
5005
  return `0x${result.toHex(true)}`;
5249
5006
  }
@@ -5255,16 +5012,16 @@ var Signer = class {
5255
5012
  * @returns public key from signature from the
5256
5013
  */
5257
5014
  static recoverPublicKey(data, signature) {
5258
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5015
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5259
5016
  const r = signedMessageBytes.slice(0, 32);
5260
5017
  const s = signedMessageBytes.slice(32, 64);
5261
5018
  const recoveryParam = (s[0] & 128) >> 7;
5262
5019
  s[0] &= 127;
5263
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5020
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5264
5021
  recoveryParam
5265
5022
  );
5266
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5267
- return (0, import_utils28.hexlify)(publicKey);
5023
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5024
+ return (0, import_utils29.hexlify)(publicKey);
5268
5025
  }
5269
5026
  /**
5270
5027
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5283,7 +5040,7 @@ var Signer = class {
5283
5040
  * @returns random 32-byte hashed
5284
5041
  */
5285
5042
  static generatePrivateKey(entropy) {
5286
- 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);
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);
5287
5044
  }
5288
5045
  /**
5289
5046
  * Extended publicKey from a compact publicKey
@@ -5292,8 +5049,8 @@ var Signer = class {
5292
5049
  * @returns extended publicKey
5293
5050
  */
5294
5051
  static extendPublicKey(publicKey) {
5295
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5296
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5052
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5053
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5297
5054
  }
5298
5055
  };
5299
5056
 
@@ -5301,7 +5058,7 @@ var Signer = class {
5301
5058
  var import_address6 = require("@fuel-ts/address");
5302
5059
  var import_crypto3 = require("@fuel-ts/crypto");
5303
5060
  var import_errors17 = require("@fuel-ts/errors");
5304
- var import_utils29 = require("@fuel-ts/utils");
5061
+ var import_utils30 = require("@fuel-ts/utils");
5305
5062
  var import_uuid = require("uuid");
5306
5063
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5307
5064
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5384,7 +5141,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5384
5141
  );
5385
5142
  }
5386
5143
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5387
- const privateKey = (0, import_utils29.hexlify)(buffer);
5144
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5388
5145
  return privateKey;
5389
5146
  }
5390
5147
 
@@ -5429,7 +5186,7 @@ var BaseWalletUnlocked = class extends Account {
5429
5186
  */
5430
5187
  async signMessage(message) {
5431
5188
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5432
- return (0, import_utils30.hexlify)(signedMessage);
5189
+ return (0, import_utils31.hexlify)(signedMessage);
5433
5190
  }
5434
5191
  /**
5435
5192
  * Signs a transaction with the wallet's private key.
@@ -5442,7 +5199,7 @@ var BaseWalletUnlocked = class extends Account {
5442
5199
  const chainId = this.provider.getChainId();
5443
5200
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5444
5201
  const signature = await this.signer().sign(hashedTransaction);
5445
- return (0, import_utils30.hexlify)(signature);
5202
+ return (0, import_utils31.hexlify)(signature);
5446
5203
  }
5447
5204
  /**
5448
5205
  * Populates a transaction with the witnesses signature.
@@ -5462,7 +5219,7 @@ var BaseWalletUnlocked = class extends Account {
5462
5219
  * @param transactionRequestLike - The transaction request to send.
5463
5220
  * @returns A promise that resolves to the TransactionResponse object.
5464
5221
  */
5465
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5222
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5466
5223
  const transactionRequest = transactionRequestify(transactionRequestLike);
5467
5224
  if (estimateTxDependencies) {
5468
5225
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5503,15 +5260,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5503
5260
  // src/hdwallet/hdwallet.ts
5504
5261
  var import_errors20 = require("@fuel-ts/errors");
5505
5262
  var import_hasher6 = require("@fuel-ts/hasher");
5506
- var import_math21 = require("@fuel-ts/math");
5507
- var import_utils34 = require("@fuel-ts/utils");
5263
+ var import_math20 = require("@fuel-ts/math");
5264
+ var import_utils35 = require("@fuel-ts/utils");
5508
5265
  var import_ethers3 = require("ethers");
5509
5266
 
5510
5267
  // src/mnemonic/mnemonic.ts
5511
5268
  var import_crypto4 = require("@fuel-ts/crypto");
5512
5269
  var import_errors19 = require("@fuel-ts/errors");
5513
5270
  var import_hasher5 = require("@fuel-ts/hasher");
5514
- var import_utils32 = require("@fuel-ts/utils");
5271
+ var import_utils33 = require("@fuel-ts/utils");
5515
5272
  var import_ethers2 = require("ethers");
5516
5273
 
5517
5274
  // src/wordlists/words/english.ts
@@ -7569,7 +7326,7 @@ var english = [
7569
7326
  // src/mnemonic/utils.ts
7570
7327
  var import_errors18 = require("@fuel-ts/errors");
7571
7328
  var import_hasher4 = require("@fuel-ts/hasher");
7572
- var import_utils31 = require("@fuel-ts/utils");
7329
+ var import_utils32 = require("@fuel-ts/utils");
7573
7330
  function toUtf8Bytes(stri) {
7574
7331
  const str = stri.normalize("NFKD");
7575
7332
  const result = [];
@@ -7636,14 +7393,14 @@ function entropyToMnemonicIndices(entropy) {
7636
7393
  }
7637
7394
  }
7638
7395
  const checksumBits = entropy.length / 4;
7639
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7396
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7640
7397
  indices[indices.length - 1] <<= checksumBits;
7641
7398
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7642
7399
  return indices;
7643
7400
  }
7644
7401
  function mnemonicWordsToEntropy(words, wordlist) {
7645
7402
  const size = Math.ceil(11 * words.length / 8);
7646
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7403
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7647
7404
  let offset = 0;
7648
7405
  for (let i = 0; i < words.length; i += 1) {
7649
7406
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7663,7 +7420,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7663
7420
  const entropyBits = 32 * words.length / 3;
7664
7421
  const checksumBits = words.length / 3;
7665
7422
  const checksumMask = getUpperMask(checksumBits);
7666
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7423
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7667
7424
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7668
7425
  throw new import_errors18.FuelError(
7669
7426
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7738,7 +7495,7 @@ var Mnemonic = class {
7738
7495
  static mnemonicToEntropy(phrase, wordlist = english) {
7739
7496
  const words = getWords(phrase);
7740
7497
  assertMnemonic(words);
7741
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7498
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7742
7499
  }
7743
7500
  /**
7744
7501
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7746,7 +7503,7 @@ var Mnemonic = class {
7746
7503
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7747
7504
  */
7748
7505
  static entropyToMnemonic(entropy, wordlist = english) {
7749
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7506
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7750
7507
  assertWordList(wordlist);
7751
7508
  assertEntropy(entropyBytes);
7752
7509
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7815,14 +7572,14 @@ var Mnemonic = class {
7815
7572
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7816
7573
  */
7817
7574
  static masterKeysFromSeed(seed) {
7818
- const seedArray = (0, import_utils32.arrayify)(seed);
7575
+ const seedArray = (0, import_utils33.arrayify)(seed);
7819
7576
  if (seedArray.length < 16 || seedArray.length > 64) {
7820
7577
  throw new import_errors19.FuelError(
7821
7578
  import_errors19.ErrorCode.INVALID_SEED,
7822
7579
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7823
7580
  );
7824
7581
  }
7825
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7582
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7826
7583
  }
7827
7584
  /**
7828
7585
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7833,22 +7590,22 @@ var Mnemonic = class {
7833
7590
  */
7834
7591
  static seedToExtendedKey(seed, testnet = false) {
7835
7592
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7836
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7593
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7837
7594
  const depth = "0x00";
7838
7595
  const fingerprint = "0x00000000";
7839
7596
  const index = "0x00000000";
7840
7597
  const chainCode = masterKey.slice(32);
7841
7598
  const privateKey = masterKey.slice(0, 32);
7842
- const extendedKey = (0, import_utils32.concat)([
7599
+ const extendedKey = (0, import_utils33.concat)([
7843
7600
  prefix,
7844
7601
  depth,
7845
7602
  fingerprint,
7846
7603
  index,
7847
7604
  chainCode,
7848
- (0, import_utils32.concat)(["0x00", privateKey])
7605
+ (0, import_utils33.concat)(["0x00", privateKey])
7849
7606
  ]);
7850
7607
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7851
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7608
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7852
7609
  }
7853
7610
  /**
7854
7611
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7863,7 +7620,7 @@ var Mnemonic = class {
7863
7620
  * @returns A randomly generated mnemonic
7864
7621
  */
7865
7622
  static generate(size = 32, extraEntropy = "") {
7866
- 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);
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);
7867
7624
  return Mnemonic.entropyToMnemonic(entropy);
7868
7625
  }
7869
7626
  };
@@ -7871,12 +7628,12 @@ var mnemonic_default = Mnemonic;
7871
7628
 
7872
7629
  // src/hdwallet/hdwallet.ts
7873
7630
  var HARDENED_INDEX = 2147483648;
7874
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7875
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7876
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7877
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
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");
7878
7635
  function base58check(data) {
7879
- 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)]));
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)]));
7880
7637
  }
7881
7638
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7882
7639
  if (isPublic) {
@@ -7885,11 +7642,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7885
7642
  return testnet ? TestnetPRV2 : MainnetPRV2;
7886
7643
  }
7887
7644
  function isPublicExtendedKey(extendedKey) {
7888
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7645
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7889
7646
  }
7890
7647
  function isValidExtendedKey(extendedKey) {
7891
7648
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7892
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7649
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7893
7650
  );
7894
7651
  }
7895
7652
  function parsePath(path2, depth = 0) {
@@ -7907,8 +7664,8 @@ function parsePath(path2, depth = 0) {
7907
7664
  var HDWallet = class {
7908
7665
  depth = 0;
7909
7666
  index = 0;
7910
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7911
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7667
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7668
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7912
7669
  privateKey;
7913
7670
  publicKey;
7914
7671
  chainCode;
@@ -7920,8 +7677,8 @@ var HDWallet = class {
7920
7677
  constructor(config) {
7921
7678
  if (config.privateKey) {
7922
7679
  const signer = new Signer(config.privateKey);
7923
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7924
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7680
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7681
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7925
7682
  } else {
7926
7683
  if (!config.publicKey) {
7927
7684
  throw new import_errors20.FuelError(
@@ -7929,7 +7686,7 @@ var HDWallet = class {
7929
7686
  "Both public and private Key cannot be missing. At least one should be provided."
7930
7687
  );
7931
7688
  }
7932
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7689
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7933
7690
  }
7934
7691
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7935
7692
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7948,9 +7705,9 @@ var HDWallet = class {
7948
7705
  * @returns A new instance of HDWallet on the derived index
7949
7706
  */
7950
7707
  deriveIndex(index) {
7951
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7952
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7953
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
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);
7954
7711
  const data = new Uint8Array(37);
7955
7712
  if (index & HARDENED_INDEX) {
7956
7713
  if (!privateKey) {
@@ -7961,15 +7718,15 @@ var HDWallet = class {
7961
7718
  }
7962
7719
  data.set(privateKey, 1);
7963
7720
  } else {
7964
- data.set((0, import_utils34.arrayify)(this.publicKey));
7721
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7965
7722
  }
7966
- data.set((0, import_math21.toBytes)(index, 4), 33);
7967
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7723
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7724
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7968
7725
  const IL = bytes.slice(0, 32);
7969
7726
  const IR = bytes.slice(32);
7970
7727
  if (privateKey) {
7971
7728
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7972
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
7729
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7973
7730
  return new HDWallet({
7974
7731
  privateKey: ki,
7975
7732
  chainCode: IR,
@@ -7978,7 +7735,7 @@ var HDWallet = class {
7978
7735
  parentFingerprint: this.fingerprint
7979
7736
  });
7980
7737
  }
7981
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7738
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7982
7739
  const Ki = signer.addPoint(publicKey);
7983
7740
  return new HDWallet({
7984
7741
  publicKey: Ki,
@@ -8013,12 +7770,12 @@ var HDWallet = class {
8013
7770
  );
8014
7771
  }
8015
7772
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8016
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7773
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8017
7774
  const parentFingerprint = this.parentFingerprint;
8018
- const index = (0, import_math21.toHex)(this.index, 4);
7775
+ const index = (0, import_math20.toHex)(this.index, 4);
8019
7776
  const chainCode = this.chainCode;
8020
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8021
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
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]));
8022
7779
  return base58check(extendedKey);
8023
7780
  }
8024
7781
  /**
@@ -8030,13 +7787,13 @@ var HDWallet = class {
8030
7787
  static fromSeed(seed) {
8031
7788
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8032
7789
  return new HDWallet({
8033
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8034
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7790
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7791
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8035
7792
  });
8036
7793
  }
8037
7794
  static fromExtendedKey(extendedKey) {
8038
7795
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8039
- const bytes = (0, import_utils34.arrayify)(decoded);
7796
+ const bytes = (0, import_utils35.arrayify)(decoded);
8040
7797
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8041
7798
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8042
7799
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8045,9 +7802,9 @@ var HDWallet = class {
8045
7802
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8046
7803
  }
8047
7804
  const depth = bytes[4];
8048
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8049
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8050
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
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));
8051
7808
  const key = bytes.slice(45, 78);
8052
7809
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8053
7810
  throw new import_errors20.FuelError(
@@ -8240,15 +7997,14 @@ var seedTestWallet = async (wallet, quantities) => {
8240
7997
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8241
7998
  wallet.provider
8242
7999
  );
8243
- const request = new ScriptTransactionRequest();
8244
- quantities.forEach((quantity) => {
8245
- const { amount, assetId } = coinQuantityfy(quantity);
8246
- request.addCoinOutput(wallet.address, amount, assetId);
8000
+ const resources = await genesisWallet.getResourcesToSpend(quantities);
8001
+ const { minGasPrice } = genesisWallet.provider.getGasConfig();
8002
+ const request = new ScriptTransactionRequest({
8003
+ gasLimit: 1e4,
8004
+ gasPrice: minGasPrice
8247
8005
  });
8248
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8249
- request.gasLimit = txCost.gasUsed;
8250
- request.maxFee = txCost.maxFee;
8251
- await genesisWallet.fund(request, txCost);
8006
+ request.addResources(resources);
8007
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8252
8008
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8253
8009
  };
8254
8010
 
@@ -8262,13 +8018,12 @@ var generateTestWallet = async (provider, quantities) => {
8262
8018
  };
8263
8019
 
8264
8020
  // src/test-utils/launchNode.ts
8265
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
8266
8021
  var import_configs13 = require("@fuel-ts/address/configs");
8267
- var import_crypto6 = require("@fuel-ts/crypto");
8268
- var import_utils35 = require("@fuel-ts/utils");
8022
+ var import_math21 = require("@fuel-ts/math");
8023
+ var import_utils36 = require("@fuel-ts/utils");
8269
8024
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8270
8025
  var import_child_process = require("child_process");
8271
- var import_crypto7 = require("crypto");
8026
+ var import_crypto6 = require("crypto");
8272
8027
  var import_fs = require("fs");
8273
8028
  var import_os = __toESM(require("os"));
8274
8029
  var import_path = __toESM(require("path"));
@@ -8309,6 +8064,7 @@ var launchNode = async ({
8309
8064
  ip,
8310
8065
  port,
8311
8066
  args = [],
8067
+ fuelCorePath = void 0,
8312
8068
  useSystemFuelCore = false,
8313
8069
  loggingEnabled = true,
8314
8070
  debugEnabled = false,
@@ -8317,19 +8073,19 @@ var launchNode = async ({
8317
8073
  // eslint-disable-next-line no-async-promise-executor
8318
8074
  new Promise(async (resolve, reject) => {
8319
8075
  const remainingArgs = extractRemainingArgs(args, [
8320
- "--snapshot",
8076
+ "--chain",
8321
8077
  "--consensus-key",
8322
8078
  "--db-type",
8323
8079
  "--poa-instant"
8324
8080
  ]);
8325
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8326
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8081
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8082
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8327
8083
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8328
8084
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8329
8085
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8330
8086
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8331
8087
  const graphQLStartSubstring = "Binding GraphQL provider to";
8332
- const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8088
+ const binPath = fuelCorePath ?? (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8333
8089
  const command = useSystemFuelCore ? "fuel-core" : binPath;
8334
8090
  const ipToUse = ip || "0.0.0.0";
8335
8091
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
@@ -8340,55 +8096,37 @@ var launchNode = async ({
8340
8096
  })).toString();
8341
8097
  let chainConfigPathToUse;
8342
8098
  const prefix = basePath || import_os.default.tmpdir();
8343
- const suffix = basePath ? "" : (0, import_crypto7.randomUUID)();
8344
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8099
+ const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8100
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8345
8101
  if (chainConfigPath) {
8346
8102
  chainConfigPathToUse = chainConfigPath;
8347
8103
  } else {
8348
8104
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8349
8105
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8350
8106
  }
8351
- let { stateConfigJson } = import_utils35.defaultChainConfigs;
8352
- const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8353
- stateConfigJson = {
8354
- ...stateConfigJson,
8355
- coins: [
8356
- ...stateConfigJson.coins.map((coin) => ({
8357
- ...coin,
8358
- amount: "18446744073709551615"
8359
- }))
8360
- ],
8361
- messages: stateConfigJson.messages.map((message) => ({
8362
- ...message,
8363
- amount: "18446744073709551615"
8364
- }))
8365
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8366
- };
8107
+ const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8108
+ let chainConfig = import_utils36.defaultChainConfig;
8367
8109
  if (!process.env.GENESIS_SECRET) {
8368
8110
  const pk = Signer.generatePrivateKey();
8369
8111
  const signer = new Signer(pk);
8370
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8371
- stateConfigJson.coins.push({
8372
- tx_id: (0, import_utils35.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8373
- owner: signer.address.toHexString(),
8374
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8375
- amount: "18446744073709551615",
8376
- asset_id: import_configs13.BaseAssetId,
8377
- output_index: 0,
8378
- tx_pointer_block_height: 0,
8379
- tx_pointer_tx_idx: 0
8380
- });
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
+ };
8381
8127
  }
8382
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8383
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8384
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8385
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8386
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8387
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8388
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8389
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8390
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8391
- chainConfigPathToUse = tempDirPath;
8128
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8129
+ chainConfigPathToUse = tempChainConfigFilePath;
8392
8130
  }
8393
8131
  const child = (0, import_child_process.spawn)(
8394
8132
  command,
@@ -8397,10 +8135,10 @@ var launchNode = async ({
8397
8135
  ["--ip", ipToUse],
8398
8136
  ["--port", portToUse],
8399
8137
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8400
- ["--min-gas-price", "1"],
8138
+ ["--min-gas-price", "0"],
8401
8139
  poaInstant ? ["--poa-instant", "true"] : [],
8402
8140
  ["--consensus-key", consensusKey],
8403
- ["--snapshot", chainConfigPathToUse],
8141
+ ["--chain", chainConfigPathToUse],
8404
8142
  "--vm-backtrace",
8405
8143
  "--utxo-validation",
8406
8144
  "--debug",
@@ -8459,7 +8197,7 @@ var launchNodeAndGetWallets = async ({
8459
8197
  walletCount = 10
8460
8198
  } = {}) => {
8461
8199
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8462
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8200
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8463
8201
  const wallets = await generateWallets(walletCount, provider);
8464
8202
  const cleanup = () => {
8465
8203
  closeNode();