@fuel-ts/account 0.0.0-rc-2021-20240423205052 → 0.0.0-rc-2045-20240424064755

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

Potentially problematic release.


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

Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +589 -861
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +517 -793
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +398 -673
  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 +327 -821
  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.map +1 -1
  46. package/dist/test-utils.global.js +1090 -1579
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +515 -774
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +407 -666
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
@@ -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 {
@@ -430,11 +356,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
430
356
  `;
431
357
  var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
432
358
  fragment GasCostsFragment on GasCosts {
433
- version {
434
- ... on Version {
435
- value
436
- }
437
- }
438
359
  add
439
360
  addi
440
361
  aloc
@@ -447,6 +368,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
447
368
  cb
448
369
  cfei
449
370
  cfsi
371
+ croo
450
372
  div
451
373
  divi
452
374
  ecr1
@@ -529,9 +451,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
529
451
  ccp {
530
452
  ...DependentCostFragment
531
453
  }
532
- croo {
533
- ...DependentCostFragment
534
- }
535
454
  csiz {
536
455
  ...DependentCostFragment
537
456
  }
@@ -591,11 +510,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
591
510
  ${DependentCostFragmentFragmentDoc}`;
592
511
  var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
593
512
  fragment consensusParametersFragment on ConsensusParameters {
594
- version {
595
- ... on Version {
596
- value
597
- }
598
- }
599
513
  txParams {
600
514
  ...TxParametersFragment
601
515
  }
@@ -655,9 +569,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
655
569
  fragment nodeInfoFragment on NodeInfo {
656
570
  utxoValidation
657
571
  vmBacktrace
572
+ minGasPrice
658
573
  maxTx
659
574
  maxDepth
660
575
  nodeVersion
576
+ peers {
577
+ id
578
+ addresses
579
+ clientVersion
580
+ blockHeight
581
+ lastHeartbeatMs
582
+ appScore
583
+ }
661
584
  }
662
585
  `;
663
586
  var GetVersionDocument = import_graphql_tag.default`
@@ -692,9 +615,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
692
615
  query getTransactionWithReceipts($transactionId: TransactionId!) {
693
616
  transaction(id: $transactionId) {
694
617
  ...transactionFragment
618
+ receipts {
619
+ ...receiptFragment
620
+ }
695
621
  }
696
622
  }
697
- ${TransactionFragmentFragmentDoc}`;
623
+ ${TransactionFragmentFragmentDoc}
624
+ ${ReceiptFragmentFragmentDoc}`;
698
625
  var GetTransactionsDocument = import_graphql_tag.default`
699
626
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
700
627
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -822,20 +749,6 @@ var GetBalanceDocument = import_graphql_tag.default`
822
749
  }
823
750
  }
824
751
  ${BalanceFragmentFragmentDoc}`;
825
- var GetLatestGasPriceDocument = import_graphql_tag.default`
826
- query getLatestGasPrice {
827
- latestGasPrice {
828
- gasPrice
829
- }
830
- }
831
- `;
832
- var EstimateGasPriceDocument = import_graphql_tag.default`
833
- query estimateGasPrice($blockHorizon: U32!) {
834
- estimateGasPrice(blockHorizon: $blockHorizon) {
835
- gasPrice
836
- }
837
- }
838
- `;
839
752
  var GetBalancesDocument = import_graphql_tag.default`
840
753
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
841
754
  balances(
@@ -890,12 +803,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
890
803
  }
891
804
  `;
892
805
  var DryRunDocument = import_graphql_tag.default`
893
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
894
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
895
- ...dryRunTransactionExecutionStatusFragment
806
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
807
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
808
+ ...receiptFragment
896
809
  }
897
810
  }
898
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
811
+ ${ReceiptFragmentFragmentDoc}`;
899
812
  var SubmitDocument = import_graphql_tag.default`
900
813
  mutation submit($encodedTransaction: HexString!) {
901
814
  submit(tx: $encodedTransaction) {
@@ -914,17 +827,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
914
827
  var SubmitAndAwaitDocument = import_graphql_tag.default`
915
828
  subscription submitAndAwait($encodedTransaction: HexString!) {
916
829
  submitAndAwait(tx: $encodedTransaction) {
917
- ...transactionStatusSubscriptionFragment
830
+ ...transactionStatusFragment
918
831
  }
919
832
  }
920
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
833
+ ${TransactionStatusFragmentFragmentDoc}`;
921
834
  var StatusChangeDocument = import_graphql_tag.default`
922
835
  subscription statusChange($transactionId: TransactionId!) {
923
836
  statusChange(id: $transactionId) {
924
- ...transactionStatusSubscriptionFragment
837
+ ...transactionStatusFragment
925
838
  }
926
839
  }
927
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
840
+ ${TransactionStatusFragmentFragmentDoc}`;
928
841
  function getSdk(requester) {
929
842
  return {
930
843
  getVersion(variables, options) {
@@ -978,12 +891,6 @@ function getSdk(requester) {
978
891
  getBalance(variables, options) {
979
892
  return requester(GetBalanceDocument, variables, options);
980
893
  },
981
- getLatestGasPrice(variables, options) {
982
- return requester(GetLatestGasPriceDocument, variables, options);
983
- },
984
- estimateGasPrice(variables, options) {
985
- return requester(EstimateGasPriceDocument, variables, options);
986
- },
987
894
  getBalances(variables, options) {
988
895
  return requester(GetBalancesDocument, variables, options);
989
896
  },
@@ -1177,9 +1084,10 @@ var inputify = (value) => {
1177
1084
  txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1178
1085
  },
1179
1086
  witnessIndex: value.witnessIndex,
1087
+ maturity: value.maturity ?? 0,
1180
1088
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1181
- predicateLength: (0, import_math2.bn)(predicate.length),
1182
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1089
+ predicateLength: predicate.length,
1090
+ predicateDataLength: predicateData.length,
1183
1091
  predicate: (0, import_utils3.hexlify)(predicate),
1184
1092
  predicateData: (0, import_utils3.hexlify)(predicateData)
1185
1093
  };
@@ -1210,8 +1118,8 @@ var inputify = (value) => {
1210
1118
  nonce: (0, import_utils3.hexlify)(value.nonce),
1211
1119
  witnessIndex: value.witnessIndex,
1212
1120
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1213
- predicateLength: (0, import_math2.bn)(predicate.length),
1214
- predicateDataLength: (0, import_math2.bn)(predicateData.length),
1121
+ predicateLength: predicate.length,
1122
+ predicateDataLength: predicateData.length,
1215
1123
  predicate: (0, import_utils3.hexlify)(predicate),
1216
1124
  predicateData: (0, import_utils3.hexlify)(predicateData),
1217
1125
  data: (0, import_utils3.hexlify)(data),
@@ -1327,8 +1235,8 @@ function assembleReceiptByType(receipt) {
1327
1235
  case "CALL" /* Call */: {
1328
1236
  const callReceipt = {
1329
1237
  type: import_transactions3.ReceiptType.Call,
1330
- from: hexOrZero(receipt.id || receipt.contractId),
1331
- to: hexOrZero(receipt?.to),
1238
+ from: hexOrZero(receipt.contract?.id),
1239
+ to: hexOrZero(receipt?.to?.id),
1332
1240
  amount: (0, import_math4.bn)(receipt.amount),
1333
1241
  assetId: hexOrZero(receipt.assetId),
1334
1242
  gas: (0, import_math4.bn)(receipt.gas),
@@ -1342,7 +1250,7 @@ function assembleReceiptByType(receipt) {
1342
1250
  case "RETURN" /* Return */: {
1343
1251
  const returnReceipt = {
1344
1252
  type: import_transactions3.ReceiptType.Return,
1345
- id: hexOrZero(receipt.id || receipt.contractId),
1253
+ id: hexOrZero(receipt.contract?.id),
1346
1254
  val: (0, import_math4.bn)(receipt.val),
1347
1255
  pc: (0, import_math4.bn)(receipt.pc),
1348
1256
  is: (0, import_math4.bn)(receipt.is)
@@ -1352,7 +1260,7 @@ function assembleReceiptByType(receipt) {
1352
1260
  case "RETURN_DATA" /* ReturnData */: {
1353
1261
  const returnDataReceipt = {
1354
1262
  type: import_transactions3.ReceiptType.ReturnData,
1355
- id: hexOrZero(receipt.id || receipt.contractId),
1263
+ id: hexOrZero(receipt.contract?.id),
1356
1264
  ptr: (0, import_math4.bn)(receipt.ptr),
1357
1265
  len: (0, import_math4.bn)(receipt.len),
1358
1266
  digest: hexOrZero(receipt.digest),
@@ -1364,7 +1272,7 @@ function assembleReceiptByType(receipt) {
1364
1272
  case "PANIC" /* Panic */: {
1365
1273
  const panicReceipt = {
1366
1274
  type: import_transactions3.ReceiptType.Panic,
1367
- id: hexOrZero(receipt.id),
1275
+ id: hexOrZero(receipt.contract?.id),
1368
1276
  reason: (0, import_math4.bn)(receipt.reason),
1369
1277
  pc: (0, import_math4.bn)(receipt.pc),
1370
1278
  is: (0, import_math4.bn)(receipt.is),
@@ -1375,7 +1283,7 @@ function assembleReceiptByType(receipt) {
1375
1283
  case "REVERT" /* Revert */: {
1376
1284
  const revertReceipt = {
1377
1285
  type: import_transactions3.ReceiptType.Revert,
1378
- id: hexOrZero(receipt.id || receipt.contractId),
1286
+ id: hexOrZero(receipt.contract?.id),
1379
1287
  val: (0, import_math4.bn)(receipt.ra),
1380
1288
  pc: (0, import_math4.bn)(receipt.pc),
1381
1289
  is: (0, import_math4.bn)(receipt.is)
@@ -1385,7 +1293,7 @@ function assembleReceiptByType(receipt) {
1385
1293
  case "LOG" /* Log */: {
1386
1294
  const logReceipt = {
1387
1295
  type: import_transactions3.ReceiptType.Log,
1388
- id: hexOrZero(receipt.id || receipt.contractId),
1296
+ id: hexOrZero(receipt.contract?.id),
1389
1297
  val0: (0, import_math4.bn)(receipt.ra),
1390
1298
  val1: (0, import_math4.bn)(receipt.rb),
1391
1299
  val2: (0, import_math4.bn)(receipt.rc),
@@ -1398,7 +1306,7 @@ function assembleReceiptByType(receipt) {
1398
1306
  case "LOG_DATA" /* LogData */: {
1399
1307
  const logDataReceipt = {
1400
1308
  type: import_transactions3.ReceiptType.LogData,
1401
- id: hexOrZero(receipt.id || receipt.contractId),
1309
+ id: hexOrZero(receipt.contract?.id),
1402
1310
  val0: (0, import_math4.bn)(receipt.ra),
1403
1311
  val1: (0, import_math4.bn)(receipt.rb),
1404
1312
  ptr: (0, import_math4.bn)(receipt.ptr),
@@ -1412,8 +1320,8 @@ function assembleReceiptByType(receipt) {
1412
1320
  case "TRANSFER" /* Transfer */: {
1413
1321
  const transferReceipt = {
1414
1322
  type: import_transactions3.ReceiptType.Transfer,
1415
- from: hexOrZero(receipt.id || receipt.contractId),
1416
- to: hexOrZero(receipt.toAddress || receipt?.to),
1323
+ from: hexOrZero(receipt.contract?.id),
1324
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
1417
1325
  amount: (0, import_math4.bn)(receipt.amount),
1418
1326
  assetId: hexOrZero(receipt.assetId),
1419
1327
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1424,8 +1332,8 @@ function assembleReceiptByType(receipt) {
1424
1332
  case "TRANSFER_OUT" /* TransferOut */: {
1425
1333
  const transferOutReceipt = {
1426
1334
  type: import_transactions3.ReceiptType.TransferOut,
1427
- from: hexOrZero(receipt.id || receipt.contractId),
1428
- to: hexOrZero(receipt.toAddress || receipt.to),
1335
+ from: hexOrZero(receipt.contract?.id),
1336
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
1429
1337
  amount: (0, import_math4.bn)(receipt.amount),
1430
1338
  assetId: hexOrZero(receipt.assetId),
1431
1339
  pc: (0, import_math4.bn)(receipt.pc),
@@ -1468,7 +1376,7 @@ function assembleReceiptByType(receipt) {
1468
1376
  return receiptMessageOut;
1469
1377
  }
1470
1378
  case "MINT" /* Mint */: {
1471
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1379
+ const contractId = hexOrZero(receipt.contract?.id);
1472
1380
  const subId = hexOrZero(receipt.subId);
1473
1381
  const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
1474
1382
  const mintReceipt = {
@@ -1483,7 +1391,7 @@ function assembleReceiptByType(receipt) {
1483
1391
  return mintReceipt;
1484
1392
  }
1485
1393
  case "BURN" /* Burn */: {
1486
- const contractId = hexOrZero(receipt.id || receipt.contractId);
1394
+ const contractId = hexOrZero(receipt.contract?.id);
1487
1395
  const subId = hexOrZero(receipt.subId);
1488
1396
  const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
1489
1397
  const burnReceipt = {
@@ -1509,6 +1417,7 @@ var import_errors6 = require("@fuel-ts/errors");
1509
1417
  var import_math5 = require("@fuel-ts/math");
1510
1418
  var import_transactions4 = require("@fuel-ts/transactions");
1511
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()));
1512
1421
  var getGasUsedFromReceipts = (receipts) => {
1513
1422
  const scriptResult = receipts.filter(
1514
1423
  (receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
@@ -1529,28 +1438,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
1529
1438
  }
1530
1439
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1531
1440
  const witnessCache = [];
1532
- const chargeableInputs = inputs.filter((input) => {
1533
- const isCoinOrMessage = "owner" in input || "sender" in input;
1534
- if (isCoinOrMessage) {
1535
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1536
- return true;
1537
- }
1538
- if (!witnessCache.includes(input.witnessIndex)) {
1539
- witnessCache.push(input.witnessIndex);
1540
- return true;
1541
- }
1542
- }
1543
- return false;
1544
- });
1545
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
1546
- const totalGas = chargeableInputs.reduce((total, input) => {
1441
+ const totalGas = inputs.reduce((total, input) => {
1547
1442
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1548
1443
  return total.add(
1549
- 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))
1550
1445
  );
1551
1446
  }
1552
- return total.add(gasCosts.ecr1);
1553
- }, (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)());
1554
1453
  return totalGas;
1555
1454
  }
1556
1455
  function getMinGas(params) {
@@ -1562,20 +1461,12 @@ function getMinGas(params) {
1562
1461
  return minGas;
1563
1462
  }
1564
1463
  function getMaxGas(params) {
1565
- const {
1566
- gasPerByte,
1567
- witnessesLength,
1568
- witnessLimit,
1569
- minGas,
1570
- gasLimit = (0, import_math5.bn)(0),
1571
- maxGasPerTx
1572
- } = params;
1464
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
1573
1465
  let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
1574
1466
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
1575
1467
  remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
1576
1468
  }
1577
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1578
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
1469
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
1579
1470
  }
1580
1471
  function calculateMetadataGasForTxCreate({
1581
1472
  gasCosts,
@@ -1597,10 +1488,6 @@ function calculateMetadataGasForTxScript({
1597
1488
  }) {
1598
1489
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1599
1490
  }
1600
- var calculateGasFee = (params) => {
1601
- const { gas, gasPrice, priceFactor, tip } = params;
1602
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1603
- };
1604
1491
 
1605
1492
  // src/providers/utils/json.ts
1606
1493
  var import_utils7 = require("@fuel-ts/utils");
@@ -1737,7 +1624,7 @@ var witnessify = (value) => {
1737
1624
  // src/providers/transaction-request/transaction-request.ts
1738
1625
  var BaseTransactionRequest = class {
1739
1626
  /** Gas price for transaction */
1740
- tip;
1627
+ gasPrice;
1741
1628
  /** Block until which tx cannot be included */
1742
1629
  maturity;
1743
1630
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -1756,7 +1643,7 @@ var BaseTransactionRequest = class {
1756
1643
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
1757
1644
  */
1758
1645
  constructor({
1759
- tip,
1646
+ gasPrice,
1760
1647
  maturity,
1761
1648
  maxFee,
1762
1649
  witnessLimit,
@@ -1764,7 +1651,7 @@ var BaseTransactionRequest = class {
1764
1651
  outputs,
1765
1652
  witnesses
1766
1653
  } = {}) {
1767
- this.tip = (0, import_math7.bn)(tip);
1654
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1768
1655
  this.maturity = maturity ?? 0;
1769
1656
  this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1770
1657
  this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
@@ -1775,9 +1662,9 @@ var BaseTransactionRequest = class {
1775
1662
  static getPolicyMeta(req) {
1776
1663
  let policyTypes = 0;
1777
1664
  const policies = [];
1778
- if (req.tip) {
1779
- policyTypes += import_transactions6.PolicyType.Tip;
1780
- 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 });
1781
1668
  }
1782
1669
  if (req.witnessLimit) {
1783
1670
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
@@ -1961,11 +1848,13 @@ var BaseTransactionRequest = class {
1961
1848
  * assetId, if one it was not added yet.
1962
1849
  *
1963
1850
  * @param coin - Coin resource.
1851
+ * @param predicate - Predicate bytes.
1852
+ * @param predicateData - Predicate data bytes.
1964
1853
  */
1965
- addCoinInput(coin) {
1854
+ addCoinInput(coin, predicate) {
1966
1855
  const { assetId, owner, amount } = coin;
1967
1856
  let witnessIndex;
1968
- if (coin.predicate) {
1857
+ if (predicate) {
1969
1858
  witnessIndex = 0;
1970
1859
  } else {
1971
1860
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -1980,7 +1869,8 @@ var BaseTransactionRequest = class {
1980
1869
  amount,
1981
1870
  assetId,
1982
1871
  txPointer: "0x00000000000000000000000000000000",
1983
- witnessIndex
1872
+ witnessIndex,
1873
+ predicate: predicate?.bytes
1984
1874
  };
1985
1875
  this.pushInput(input);
1986
1876
  this.addChangeOutput(owner, assetId);
@@ -1990,12 +1880,14 @@ var BaseTransactionRequest = class {
1990
1880
  * baseAssetId, if one it was not added yet.
1991
1881
  *
1992
1882
  * @param message - Message resource.
1883
+ * @param predicate - Predicate bytes.
1884
+ * @param predicateData - Predicate data bytes.
1993
1885
  */
1994
- addMessageInput(message) {
1886
+ addMessageInput(message, predicate) {
1995
1887
  const { recipient, sender, amount } = message;
1996
1888
  const assetId = import_configs7.BaseAssetId;
1997
1889
  let witnessIndex;
1998
- if (message.predicate) {
1890
+ if (predicate) {
1999
1891
  witnessIndex = 0;
2000
1892
  } else {
2001
1893
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -2009,7 +1901,8 @@ var BaseTransactionRequest = class {
2009
1901
  sender: sender.toB256(),
2010
1902
  recipient: recipient.toB256(),
2011
1903
  amount,
2012
- witnessIndex
1904
+ witnessIndex,
1905
+ predicate: predicate?.bytes
2013
1906
  };
2014
1907
  this.pushInput(input);
2015
1908
  this.addChangeOutput(recipient, assetId);
@@ -2040,6 +1933,32 @@ var BaseTransactionRequest = class {
2040
1933
  resources.forEach((resource) => this.addResource(resource));
2041
1934
  return this;
2042
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
+ }
2043
1962
  /**
2044
1963
  * Adds a coin output to the transaction.
2045
1964
  *
@@ -2119,7 +2038,7 @@ var BaseTransactionRequest = class {
2119
2038
  }
2120
2039
  calculateMaxGas(chainInfo, minGas) {
2121
2040
  const { consensusParameters } = chainInfo;
2122
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2041
+ const { gasPerByte } = consensusParameters;
2123
2042
  const witnessesLength = this.toTransaction().witnesses.reduce(
2124
2043
  (acc, wit) => acc + wit.dataLength,
2125
2044
  0
@@ -2128,8 +2047,7 @@ var BaseTransactionRequest = class {
2128
2047
  gasPerByte,
2129
2048
  minGas,
2130
2049
  witnessesLength,
2131
- witnessLimit: this.witnessLimit,
2132
- maxGasPerTx
2050
+ witnessLimit: this.witnessLimit
2133
2051
  });
2134
2052
  }
2135
2053
  /**
@@ -2147,20 +2065,17 @@ var BaseTransactionRequest = class {
2147
2065
  });
2148
2066
  const updateAssetInput = (assetId, quantity) => {
2149
2067
  const assetInput = findAssetInput(assetId);
2150
- let usedQuantity = quantity;
2151
- if (assetId === import_configs7.BaseAssetId) {
2152
- usedQuantity = (0, import_math7.bn)("1000000000000000000");
2153
- }
2154
2068
  if (assetInput && "assetId" in assetInput) {
2155
2069
  assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2156
- assetInput.amount = usedQuantity;
2070
+ assetInput.amount = quantity;
2157
2071
  } else {
2158
2072
  this.addResources([
2159
2073
  {
2160
2074
  id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2161
- amount: usedQuantity,
2075
+ amount: quantity,
2162
2076
  assetId,
2163
2077
  owner: resourcesOwner || import_address.Address.fromRandom(),
2078
+ maturity: 0,
2164
2079
  blockCreated: (0, import_math7.bn)(1),
2165
2080
  txCreatedIdx: (0, import_math7.bn)(1)
2166
2081
  }
@@ -2192,7 +2107,7 @@ var BaseTransactionRequest = class {
2192
2107
  toJSON() {
2193
2108
  return normalizeJSON(this);
2194
2109
  }
2195
- updatePredicateGasUsed(inputs) {
2110
+ updatePredicateInputs(inputs) {
2196
2111
  this.inputs.forEach((i) => {
2197
2112
  let correspondingInput;
2198
2113
  switch (i.type) {
@@ -2214,15 +2129,6 @@ var BaseTransactionRequest = class {
2214
2129
  }
2215
2130
  });
2216
2131
  }
2217
- shiftPredicateData() {
2218
- this.inputs.forEach((input) => {
2219
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
2220
- input.predicateData = input.paddPredicateData(
2221
- BaseTransactionRequest.getPolicyMeta(this).policies.length
2222
- );
2223
- }
2224
- });
2225
- }
2226
2132
  };
2227
2133
 
2228
2134
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2369,8 +2275,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2369
2275
  return {
2370
2276
  type: import_transactions8.TransactionType.Create,
2371
2277
  ...baseTransaction,
2278
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2372
2279
  bytecodeWitnessIndex,
2373
- storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
2280
+ storageSlotsCount: storageSlots.length,
2374
2281
  salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2375
2282
  storageSlots
2376
2283
  };
@@ -2493,8 +2400,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2493
2400
  type: import_transactions9.TransactionType.Script,
2494
2401
  scriptGasLimit: this.gasLimit,
2495
2402
  ...super.getBaseTransaction(),
2496
- scriptLength: (0, import_math10.bn)(script.length),
2497
- scriptDataLength: (0, import_math10.bn)(scriptData.length),
2403
+ scriptLength: script.length,
2404
+ scriptDataLength: scriptData.length,
2498
2405
  receiptsRoot: import_configs10.ZeroBytes32,
2499
2406
  script: (0, import_utils15.hexlify)(script),
2500
2407
  scriptData: (0, import_utils15.hexlify)(scriptData)
@@ -2558,7 +2465,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2558
2465
  }
2559
2466
  calculateMaxGas(chainInfo, minGas) {
2560
2467
  const { consensusParameters } = chainInfo;
2561
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2468
+ const { gasPerByte } = consensusParameters;
2562
2469
  const witnessesLength = this.toTransaction().witnesses.reduce(
2563
2470
  (acc, wit) => acc + wit.dataLength,
2564
2471
  0
@@ -2568,8 +2475,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2568
2475
  minGas,
2569
2476
  witnessesLength,
2570
2477
  witnessLimit: this.witnessLimit,
2571
- gasLimit: this.gasLimit,
2572
- maxGasPerTx
2478
+ gasLimit: this.gasLimit
2573
2479
  });
2574
2480
  }
2575
2481
  /**
@@ -2644,32 +2550,15 @@ var transactionRequestify = (obj) => {
2644
2550
  }
2645
2551
  }
2646
2552
  };
2647
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2648
- (acc, input) => {
2649
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2650
- acc.utxos.push(input.id);
2651
- }
2652
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2653
- acc.messages.push(input.nonce);
2654
- }
2655
- return acc;
2656
- },
2657
- {
2658
- utxos: [],
2659
- messages: []
2660
- }
2661
- );
2662
2553
 
2663
2554
  // src/providers/transaction-response/transaction-response.ts
2664
2555
  var import_errors13 = require("@fuel-ts/errors");
2665
- var import_math15 = require("@fuel-ts/math");
2666
- var import_transactions18 = require("@fuel-ts/transactions");
2667
- 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");
2668
2559
 
2669
2560
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2670
- var import_math14 = require("@fuel-ts/math");
2671
- var import_transactions16 = require("@fuel-ts/transactions");
2672
- var import_utils18 = require("@fuel-ts/utils");
2561
+ var import_utils19 = require("@fuel-ts/utils");
2673
2562
 
2674
2563
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2675
2564
  var import_math11 = require("@fuel-ts/math");
@@ -2677,10 +2566,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
2677
2566
  var import_utils16 = require("@fuel-ts/utils");
2678
2567
  var calculateTransactionFee = (params) => {
2679
2568
  const {
2680
- gasPrice,
2569
+ gasUsed,
2681
2570
  rawPayload,
2682
- tip,
2683
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2571
+ consensusParameters: { gasCosts, feeParams }
2684
2572
  } = params;
2685
2573
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2686
2574
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
@@ -2690,7 +2578,8 @@ var calculateTransactionFee = (params) => {
2690
2578
  return {
2691
2579
  fee: (0, import_math11.bn)(0),
2692
2580
  minFee: (0, import_math11.bn)(0),
2693
- maxFee: (0, import_math11.bn)(0)
2581
+ maxFee: (0, import_math11.bn)(0),
2582
+ feeFromGasUsed: (0, import_math11.bn)(0)
2694
2583
  };
2695
2584
  }
2696
2585
  const { type, witnesses, inputs, policies } = transaction;
@@ -2722,6 +2611,7 @@ var calculateTransactionFee = (params) => {
2722
2611
  metadataGas,
2723
2612
  txBytesSize: transactionBytes.length
2724
2613
  });
2614
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2725
2615
  const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2726
2616
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2727
2617
  const maxGas = getMaxGas({
@@ -2729,25 +2619,17 @@ var calculateTransactionFee = (params) => {
2729
2619
  minGas,
2730
2620
  witnessesLength,
2731
2621
  gasLimit,
2732
- witnessLimit,
2733
- maxGasPerTx
2734
- });
2735
- const minFee = calculateGasFee({
2736
- gasPrice,
2737
- gas: minGas,
2738
- priceFactor: gasPriceFactor,
2739
- tip
2740
- });
2741
- const maxFee = calculateGasFee({
2742
- gasPrice,
2743
- gas: maxGas,
2744
- priceFactor: gasPriceFactor,
2745
- tip
2622
+ witnessLimit
2746
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);
2747
2628
  return {
2629
+ fee,
2748
2630
  minFee,
2749
2631
  maxFee,
2750
- fee: maxFee
2632
+ feeFromGasUsed
2751
2633
  };
2752
2634
  };
2753
2635
 
@@ -3314,12 +3196,10 @@ function assembleTransactionSummary(params) {
3314
3196
  gqlTransactionStatus,
3315
3197
  abiMap = {},
3316
3198
  maxInputs,
3317
- gasCosts,
3318
- maxGasPerTx,
3319
- gasPrice
3199
+ gasCosts
3320
3200
  } = params;
3321
3201
  const gasUsed = getGasUsedFromReceipts(receipts);
3322
- const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
3202
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3323
3203
  const operations = getOperations({
3324
3204
  transactionType: transaction.type,
3325
3205
  inputs: transaction.inputs || [],
@@ -3330,14 +3210,11 @@ function assembleTransactionSummary(params) {
3330
3210
  maxInputs
3331
3211
  });
3332
3212
  const typeName = getTransactionTypeName(transaction.type);
3333
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3334
3213
  const { fee } = calculateTransactionFee({
3335
- gasPrice,
3214
+ gasUsed,
3336
3215
  rawPayload,
3337
- tip,
3338
3216
  consensusParameters: {
3339
3217
  gasCosts,
3340
- maxGasPerTx,
3341
3218
  feeParams: {
3342
3219
  gasPerByte,
3343
3220
  gasPriceFactor
@@ -3349,7 +3226,7 @@ function assembleTransactionSummary(params) {
3349
3226
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3350
3227
  let date;
3351
3228
  if (time) {
3352
- date = import_utils18.DateTime.fromTai64(time);
3229
+ date = import_utils19.DateTime.fromTai64(time);
3353
3230
  }
3354
3231
  const transactionSummary = {
3355
3232
  id,
@@ -3377,12 +3254,12 @@ function assembleTransactionSummary(params) {
3377
3254
 
3378
3255
  // src/providers/transaction-response/getDecodedLogs.ts
3379
3256
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
3380
- var import_transactions17 = require("@fuel-ts/transactions");
3257
+ var import_transactions16 = require("@fuel-ts/transactions");
3381
3258
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3382
3259
  return receipts.reduce((logs, receipt) => {
3383
- 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) {
3384
3261
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3385
- 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;
3386
3263
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3387
3264
  logs.push(decodedLog);
3388
3265
  }
@@ -3397,7 +3274,7 @@ var TransactionResponse = class {
3397
3274
  /** Current provider */
3398
3275
  provider;
3399
3276
  /** Gas used on the transaction */
3400
- gasUsed = (0, import_math15.bn)(0);
3277
+ gasUsed = (0, import_math14.bn)(0);
3401
3278
  /** The graphql Transaction with receipts object. */
3402
3279
  gqlTransaction;
3403
3280
  abis;
@@ -3455,8 +3332,8 @@ var TransactionResponse = class {
3455
3332
  * @returns The decoded transaction.
3456
3333
  */
3457
3334
  decodeTransaction(transactionWithReceipts) {
3458
- return new import_transactions18.TransactionCoder().decode(
3459
- (0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
3335
+ return new import_transactions17.TransactionCoder().decode(
3336
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3460
3337
  0
3461
3338
  )?.[0];
3462
3339
  }
@@ -3475,27 +3352,20 @@ var TransactionResponse = class {
3475
3352
  const decodedTransaction = this.decodeTransaction(
3476
3353
  transaction
3477
3354
  );
3478
- let txReceipts = [];
3479
- if (transaction?.status && "receipts" in transaction.status) {
3480
- txReceipts = transaction.status.receipts;
3481
- }
3482
- const receipts = txReceipts.map(processGqlReceipt) || [];
3483
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3484
- const gasPrice = await this.provider.getLatestGasPrice();
3355
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
3356
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
3485
3357
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3486
3358
  const transactionSummary = assembleTransactionSummary({
3487
3359
  id: this.id,
3488
3360
  receipts,
3489
3361
  transaction: decodedTransaction,
3490
- transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
3362
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3491
3363
  gqlTransactionStatus: transaction.status,
3492
3364
  gasPerByte,
3493
3365
  gasPriceFactor,
3494
3366
  abiMap: contractsAbiMap,
3495
3367
  maxInputs,
3496
- gasCosts,
3497
- maxGasPerTx,
3498
- gasPrice
3368
+ gasCosts
3499
3369
  });
3500
3370
  return transactionSummary;
3501
3371
  }
@@ -3622,29 +3492,29 @@ var processGqlChain = (chain) => {
3622
3492
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3623
3493
  return {
3624
3494
  name,
3625
- baseChainHeight: (0, import_math16.bn)(daHeight),
3495
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3626
3496
  consensusParameters: {
3627
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3628
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3629
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3630
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3631
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3632
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3633
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3634
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3635
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3636
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3637
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3638
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3639
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3640
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3641
- 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),
3642
3512
  gasCosts
3643
3513
  },
3644
3514
  gasCosts,
3645
3515
  latestBlock: {
3646
3516
  id: latestBlock.id,
3647
- height: (0, import_math16.bn)(latestBlock.height),
3517
+ height: (0, import_math15.bn)(latestBlock.header.height),
3648
3518
  time: latestBlock.header.time,
3649
3519
  transactions: latestBlock.transactions.map((i) => ({
3650
3520
  id: i.id
@@ -3738,8 +3608,10 @@ var _Provider = class {
3738
3608
  * Returns some helpful parameters related to gas fees.
3739
3609
  */
3740
3610
  getGasConfig() {
3611
+ const { minGasPrice } = this.getNode();
3741
3612
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3742
3613
  return {
3614
+ minGasPrice,
3743
3615
  maxGasPerTx,
3744
3616
  maxGasPerPredicate,
3745
3617
  gasPriceFactor,
@@ -3837,7 +3709,7 @@ var _Provider = class {
3837
3709
  */
3838
3710
  async getBlockNumber() {
3839
3711
  const { chain } = await this.operations.getChain();
3840
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3712
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3841
3713
  }
3842
3714
  /**
3843
3715
  * Returns the chain information.
@@ -3847,11 +3719,13 @@ var _Provider = class {
3847
3719
  async fetchNode() {
3848
3720
  const { nodeInfo } = await this.operations.getNodeInfo();
3849
3721
  const processedNodeInfo = {
3850
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3851
- 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),
3852
3725
  nodeVersion: nodeInfo.nodeVersion,
3853
3726
  utxoValidation: nodeInfo.utxoValidation,
3854
- vmBacktrace: nodeInfo.vmBacktrace
3727
+ vmBacktrace: nodeInfo.vmBacktrace,
3728
+ peers: nodeInfo.peers
3855
3729
  };
3856
3730
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
3857
3731
  return processedNodeInfo;
@@ -3893,9 +3767,9 @@ var _Provider = class {
3893
3767
  if (estimateTxDependencies) {
3894
3768
  await this.estimateTxDependencies(transactionRequest);
3895
3769
  }
3896
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3770
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3897
3771
  let abis;
3898
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
3772
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3899
3773
  abis = transactionRequest.abis;
3900
3774
  }
3901
3775
  if (awaitExecution) {
@@ -3936,14 +3810,15 @@ var _Provider = class {
3936
3810
  if (estimateTxDependencies) {
3937
3811
  return this.estimateTxDependencies(transactionRequest);
3938
3812
  }
3939
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3940
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
3941
- encodedTransactions: encodedTransaction,
3813
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3814
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3815
+ encodedTransaction,
3942
3816
  utxoValidation: utxoValidation || false
3943
3817
  });
3944
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3945
- const receipts = rawReceipts.map(processGqlReceipt);
3946
- return { receipts, dryrunStatus: status };
3818
+ const receipts = gqlReceipts.map(processGqlReceipt);
3819
+ return {
3820
+ receipts
3821
+ };
3947
3822
  }
3948
3823
  /**
3949
3824
  * Verifies whether enough gas is available to complete transaction.
@@ -3954,13 +3829,13 @@ var _Provider = class {
3954
3829
  async estimatePredicates(transactionRequest) {
3955
3830
  const shouldEstimatePredicates = Boolean(
3956
3831
  transactionRequest.inputs.find(
3957
- (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()
3958
3833
  )
3959
3834
  );
3960
3835
  if (!shouldEstimatePredicates) {
3961
3836
  return transactionRequest;
3962
3837
  }
3963
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3838
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3964
3839
  const response = await this.operations.estimatePredicates({
3965
3840
  encodedTransaction
3966
3841
  });
@@ -3969,7 +3844,7 @@ var _Provider = class {
3969
3844
  } = response;
3970
3845
  if (inputs) {
3971
3846
  inputs.forEach((input, index) => {
3972
- 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)) {
3973
3848
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3974
3849
  }
3975
3850
  });
@@ -3982,31 +3857,31 @@ var _Provider = class {
3982
3857
  * If there are missing variable outputs,
3983
3858
  * `addVariableOutputs` is called on the transaction.
3984
3859
  *
3860
+ * @privateRemarks
3861
+ * TODO: Investigate support for missing contract IDs
3862
+ * TODO: Add support for missing output messages
3985
3863
  *
3986
3864
  * @param transactionRequest - The transaction request object.
3987
3865
  * @returns A promise.
3988
3866
  */
3989
3867
  async estimateTxDependencies(transactionRequest) {
3990
- if (transactionRequest.type === import_transactions19.TransactionType.Create) {
3868
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3991
3869
  return {
3992
3870
  receipts: [],
3993
3871
  outputVariables: 0,
3994
3872
  missingContractIds: []
3995
3873
  };
3996
3874
  }
3875
+ await this.estimatePredicates(transactionRequest);
3997
3876
  let receipts = [];
3998
3877
  const missingContractIds = [];
3999
3878
  let outputVariables = 0;
4000
- let dryrunStatus;
4001
3879
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4002
- const {
4003
- dryRun: [{ receipts: rawReceipts, status }]
4004
- } = await this.operations.dryRun({
4005
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
3880
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3881
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4006
3882
  utxoValidation: false
4007
3883
  });
4008
- receipts = rawReceipts.map(processGqlReceipt);
4009
- dryrunStatus = status;
3884
+ receipts = gqlReceipts.map(processGqlReceipt);
4010
3885
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4011
3886
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4012
3887
  if (hasMissingOutputs) {
@@ -4016,10 +3891,6 @@ var _Provider = class {
4016
3891
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4017
3892
  missingContractIds.push(contractId);
4018
3893
  });
4019
- const { maxFee } = await this.estimateTxGasAndFee({
4020
- transactionRequest
4021
- });
4022
- transactionRequest.maxFee = maxFee;
4023
3894
  } else {
4024
3895
  break;
4025
3896
  }
@@ -4027,139 +3898,37 @@ var _Provider = class {
4027
3898
  return {
4028
3899
  receipts,
4029
3900
  outputVariables,
4030
- missingContractIds,
4031
- dryrunStatus
3901
+ missingContractIds
4032
3902
  };
4033
3903
  }
4034
- /**
4035
- * Dry runs multiple transactions and checks for missing dependencies in batches.
4036
- *
4037
- * Transactions are dry run in batches. After each dry run, transactions requiring
4038
- * further modifications are identified. The method iteratively updates these transactions
4039
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
4040
- *
4041
- * @param transactionRequests - Array of transaction request objects.
4042
- * @returns A promise that resolves to an array of results for each transaction.
4043
- */
4044
- async estimateMultipleTxDependencies(transactionRequests) {
4045
- const results = transactionRequests.map(() => ({
4046
- receipts: [],
4047
- outputVariables: 0,
4048
- missingContractIds: [],
4049
- dryrunStatus: void 0
4050
- }));
4051
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4052
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
4053
- allRequests.forEach((req, index) => {
4054
- if (req.type === import_transactions19.TransactionType.Script) {
4055
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4056
- }
4057
- });
4058
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
4059
- let attempt = 0;
4060
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
4061
- const encodedTransactions = transactionsToProcess.map(
4062
- (index) => serializedTransactionsMap.get(index)
4063
- );
4064
- const dryRunResults = await this.operations.dryRun({
4065
- encodedTransactions,
4066
- utxoValidation: false
4067
- });
4068
- const nextRoundTransactions = [];
4069
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
4070
- const currentResultIndex = transactionsToProcess[i];
4071
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4072
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
4073
- results[currentResultIndex].dryrunStatus = status;
4074
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4075
- results[currentResultIndex].receipts
4076
- );
4077
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4078
- const requestToProcess = allRequests[currentResultIndex];
4079
- if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
4080
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
4081
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
4082
- missingOutputContractIds.forEach(({ contractId }) => {
4083
- requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4084
- results[currentResultIndex].missingContractIds.push(contractId);
4085
- });
4086
- const { maxFee } = await this.estimateTxGasAndFee({
4087
- transactionRequest: requestToProcess
4088
- });
4089
- requestToProcess.maxFee = maxFee;
4090
- serializedTransactionsMap.set(
4091
- currentResultIndex,
4092
- (0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
4093
- );
4094
- nextRoundTransactions.push(currentResultIndex);
4095
- allRequests[currentResultIndex] = requestToProcess;
4096
- }
4097
- }
4098
- transactionsToProcess = nextRoundTransactions;
4099
- attempt += 1;
4100
- }
4101
- return results;
4102
- }
4103
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
4104
- if (estimateTxDependencies) {
4105
- return this.estimateMultipleTxDependencies(transactionRequests);
4106
- }
4107
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4108
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4109
- encodedTransactions,
4110
- utxoValidation: utxoValidation || false
4111
- });
4112
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4113
- const receipts = rawReceipts.map(processGqlReceipt);
4114
- return { receipts, dryrunStatus: status };
4115
- });
4116
- return results;
4117
- }
4118
3904
  /**
4119
3905
  * Estimates the transaction gas and fee based on the provided transaction request.
4120
3906
  * @param transactionRequest - The transaction request object.
4121
3907
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4122
3908
  */
4123
- async estimateTxGasAndFee(params) {
3909
+ estimateTxGasAndFee(params) {
4124
3910
  const { transactionRequest } = params;
4125
- let { gasPrice } = params;
3911
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4126
3912
  const chainInfo = this.getChain();
4127
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
3913
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3914
+ transactionRequest.gasPrice = gasPrice;
4128
3915
  const minGas = transactionRequest.calculateMinGas(chainInfo);
4129
- if (!gasPrice) {
4130
- gasPrice = await this.estimateGasPrice(10);
4131
- }
4132
- const minFee = calculateGasFee({
4133
- gasPrice: (0, import_math16.bn)(gasPrice),
4134
- gas: minGas,
4135
- priceFactor: gasPriceFactor,
4136
- tip: transactionRequest.tip
4137
- }).add(1);
4138
- let gasLimit = (0, import_math16.bn)(0);
4139
- if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4140
- gasLimit = transactionRequest.gasLimit;
3916
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3917
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4141
3918
  if (transactionRequest.gasLimit.eq(0)) {
4142
3919
  transactionRequest.gasLimit = minGas;
4143
3920
  transactionRequest.gasLimit = maxGasPerTx.sub(
4144
3921
  transactionRequest.calculateMaxGas(chainInfo, minGas)
4145
3922
  );
4146
- gasLimit = transactionRequest.gasLimit;
4147
3923
  }
4148
3924
  }
4149
3925
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4150
- const maxFee = calculateGasFee({
4151
- gasPrice: (0, import_math16.bn)(gasPrice),
4152
- gas: maxGas,
4153
- priceFactor: gasPriceFactor,
4154
- tip: transactionRequest.tip
4155
- }).add(1);
3926
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4156
3927
  return {
4157
3928
  minGas,
4158
3929
  minFee,
4159
3930
  maxGas,
4160
- maxFee,
4161
- gasPrice,
4162
- gasLimit
3931
+ maxFee
4163
3932
  };
4164
3933
  }
4165
3934
  /**
@@ -4177,17 +3946,15 @@ var _Provider = class {
4177
3946
  if (estimateTxDependencies) {
4178
3947
  return this.estimateTxDependencies(transactionRequest);
4179
3948
  }
4180
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4181
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4182
- encodedTransactions,
3949
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3950
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
3951
+ encodedTransaction,
4183
3952
  utxoValidation: true
4184
3953
  });
4185
- const callResult = dryRunStatuses.map((dryRunStatus) => {
4186
- const { id, receipts, status } = dryRunStatus;
4187
- const processedReceipts = receipts.map(processGqlReceipt);
4188
- return { id, receipts: processedReceipts, status };
4189
- });
4190
- return { receipts: callResult[0].receipts };
3954
+ const receipts = gqlReceipts.map(processGqlReceipt);
3955
+ return {
3956
+ receipts
3957
+ };
4191
3958
  }
4192
3959
  /**
4193
3960
  * Returns a transaction cost to enable user
@@ -4204,79 +3971,77 @@ var _Provider = class {
4204
3971
  * @param tolerance - The tolerance to add on top of the gasUsed.
4205
3972
  * @returns A promise that resolves to the transaction cost object.
4206
3973
  */
4207
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
3974
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
3975
+ estimateTxDependencies = true,
3976
+ estimatePredicates = true,
3977
+ resourcesOwner,
3978
+ signatureCallback
3979
+ } = {}) {
4208
3980
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4209
- 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;
4210
3984
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4211
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
3985
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4212
3986
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4213
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4214
3987
  if (isScriptTransaction) {
4215
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
3988
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4216
3989
  }
4217
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4218
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
3990
+ if (estimatePredicates) {
3991
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3992
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3993
+ }
3994
+ await this.estimatePredicates(txRequestClone);
4219
3995
  }
4220
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
4221
- let addedSignatures = 0;
4222
3996
  if (signatureCallback && isScriptTransaction) {
4223
- const lengthBefore = signedRequest.witnesses.length;
4224
- await signatureCallback(signedRequest);
4225
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
3997
+ await signatureCallback(txRequestClone);
4226
3998
  }
4227
- await this.estimatePredicates(signedRequest);
4228
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
4229
- transactionRequest: signedRequest
3999
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
+ transactionRequest: txRequestClone
4230
4001
  });
4231
4002
  let receipts = [];
4232
4003
  let missingContractIds = [];
4233
4004
  let outputVariables = 0;
4234
- let gasUsed = (0, import_math16.bn)(0);
4235
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4236
- txRequestClone.maxFee = maxFee;
4237
- if (isScriptTransaction) {
4238
- txRequestClone.gasLimit = gasLimit;
4239
- if (signatureCallback) {
4240
- await signatureCallback(txRequestClone);
4241
- }
4005
+ let gasUsed = (0, import_math15.bn)(0);
4006
+ if (isScriptTransaction && estimateTxDependencies) {
4007
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4242
4008
  const result = await this.estimateTxDependencies(txRequestClone);
4243
4009
  receipts = result.receipts;
4244
4010
  outputVariables = result.outputVariables;
4245
4011
  missingContractIds = result.missingContractIds;
4246
4012
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4247
4013
  txRequestClone.gasLimit = gasUsed;
4248
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4249
- transactionRequest: txRequestClone,
4250
- gasPrice
4014
+ txRequestClone.gasPrice = setGasPrice;
4015
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4016
+ transactionRequest: txRequestClone
4251
4017
  }));
4252
4018
  }
4253
4019
  return {
4254
4020
  requiredQuantities: allQuantities,
4255
4021
  receipts,
4256
4022
  gasUsed,
4257
- gasPrice,
4023
+ minGasPrice,
4024
+ gasPrice: setGasPrice,
4258
4025
  minGas,
4259
4026
  maxGas,
4260
4027
  minFee,
4261
4028
  maxFee,
4029
+ estimatedInputs: txRequestClone.inputs,
4262
4030
  outputVariables,
4263
- missingContractIds,
4264
- addedSignatures,
4265
- estimatedPredicates: txRequestClone.inputs
4031
+ missingContractIds
4266
4032
  };
4267
4033
  }
4268
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4034
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
4269
4035
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4270
4036
  const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
4271
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4272
- quantitiesToContract
4273
- });
4037
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
4274
4038
  transactionRequest.addResources(
4275
4039
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4276
4040
  );
4277
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4278
- quantitiesToContract
4279
- });
4041
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
4042
+ transactionRequest,
4043
+ forwardingQuantities
4044
+ );
4280
4045
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4281
4046
  return {
4282
4047
  resources,
@@ -4292,16 +4057,17 @@ var _Provider = class {
4292
4057
  const result = await this.operations.getCoins({
4293
4058
  first: 10,
4294
4059
  ...paginationArgs,
4295
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4060
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4296
4061
  });
4297
4062
  const coins = result.coins.edges.map((edge) => edge.node);
4298
4063
  return coins.map((coin) => ({
4299
4064
  id: coin.utxoId,
4300
4065
  assetId: coin.assetId,
4301
- amount: (0, import_math16.bn)(coin.amount),
4066
+ amount: (0, import_math15.bn)(coin.amount),
4302
4067
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4303
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4304
- 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)
4305
4071
  }));
4306
4072
  }
4307
4073
  /**
@@ -4315,19 +4081,19 @@ var _Provider = class {
4315
4081
  async getResourcesToSpend(owner, quantities, excludedIds) {
4316
4082
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4317
4083
  const excludeInput = {
4318
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4319
- 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)) || []
4320
4086
  };
4321
4087
  if (this.cache) {
4322
4088
  const uniqueUtxos = new Set(
4323
- 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)))
4324
4090
  );
4325
4091
  excludeInput.utxos = Array.from(uniqueUtxos);
4326
4092
  }
4327
4093
  const coinsQuery = {
4328
4094
  owner: ownerAddress.toB256(),
4329
4095
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4330
- assetId: (0, import_utils22.hexlify)(assetId),
4096
+ assetId: (0, import_utils23.hexlify)(assetId),
4331
4097
  amount: amount.toString(10),
4332
4098
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4333
4099
  })),
@@ -4338,9 +4104,9 @@ var _Provider = class {
4338
4104
  switch (coin.__typename) {
4339
4105
  case "MessageCoin":
4340
4106
  return {
4341
- amount: (0, import_math16.bn)(coin.amount),
4107
+ amount: (0, import_math15.bn)(coin.amount),
4342
4108
  assetId: coin.assetId,
4343
- daHeight: (0, import_math16.bn)(coin.daHeight),
4109
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4344
4110
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4345
4111
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4346
4112
  nonce: coin.nonce
@@ -4348,11 +4114,12 @@ var _Provider = class {
4348
4114
  case "Coin":
4349
4115
  return {
4350
4116
  id: coin.utxoId,
4351
- amount: (0, import_math16.bn)(coin.amount),
4117
+ amount: (0, import_math15.bn)(coin.amount),
4352
4118
  assetId: coin.assetId,
4353
4119
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4354
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4355
- 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)
4356
4123
  };
4357
4124
  default:
4358
4125
  return null;
@@ -4369,13 +4136,13 @@ var _Provider = class {
4369
4136
  async getBlock(idOrHeight) {
4370
4137
  let variables;
4371
4138
  if (typeof idOrHeight === "number") {
4372
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4139
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4373
4140
  } else if (idOrHeight === "latest") {
4374
4141
  variables = { height: (await this.getBlockNumber()).toString(10) };
4375
4142
  } else if (idOrHeight.length === 66) {
4376
4143
  variables = { blockId: idOrHeight };
4377
4144
  } else {
4378
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4145
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4379
4146
  }
4380
4147
  const { block } = await this.operations.getBlock(variables);
4381
4148
  if (!block) {
@@ -4383,7 +4150,7 @@ var _Provider = class {
4383
4150
  }
4384
4151
  return {
4385
4152
  id: block.id,
4386
- height: (0, import_math16.bn)(block.height),
4153
+ height: (0, import_math15.bn)(block.header.height),
4387
4154
  time: block.header.time,
4388
4155
  transactionIds: block.transactions.map((tx) => tx.id)
4389
4156
  };
@@ -4398,7 +4165,7 @@ var _Provider = class {
4398
4165
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4399
4166
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4400
4167
  id: block.id,
4401
- height: (0, import_math16.bn)(block.height),
4168
+ height: (0, import_math15.bn)(block.header.height),
4402
4169
  time: block.header.time,
4403
4170
  transactionIds: block.transactions.map((tx) => tx.id)
4404
4171
  }));
@@ -4413,7 +4180,7 @@ var _Provider = class {
4413
4180
  async getBlockWithTransactions(idOrHeight) {
4414
4181
  let variables;
4415
4182
  if (typeof idOrHeight === "number") {
4416
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4183
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4417
4184
  } else if (idOrHeight === "latest") {
4418
4185
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4419
4186
  } else {
@@ -4425,11 +4192,11 @@ var _Provider = class {
4425
4192
  }
4426
4193
  return {
4427
4194
  id: block.id,
4428
- height: (0, import_math16.bn)(block.height, 10),
4195
+ height: (0, import_math15.bn)(block.header.height, 10),
4429
4196
  time: block.header.time,
4430
4197
  transactionIds: block.transactions.map((tx) => tx.id),
4431
4198
  transactions: block.transactions.map(
4432
- (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]
4433
4200
  )
4434
4201
  };
4435
4202
  }
@@ -4444,8 +4211,8 @@ var _Provider = class {
4444
4211
  if (!transaction) {
4445
4212
  return null;
4446
4213
  }
4447
- return new import_transactions19.TransactionCoder().decode(
4448
- (0, import_utils22.arrayify)(transaction.rawPayload),
4214
+ return new import_transactions18.TransactionCoder().decode(
4215
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4449
4216
  0
4450
4217
  )?.[0];
4451
4218
  }
@@ -4472,9 +4239,9 @@ var _Provider = class {
4472
4239
  async getContractBalance(contractId, assetId) {
4473
4240
  const { contractBalance } = await this.operations.getContractBalance({
4474
4241
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4475
- asset: (0, import_utils22.hexlify)(assetId)
4242
+ asset: (0, import_utils23.hexlify)(assetId)
4476
4243
  });
4477
- return (0, import_math16.bn)(contractBalance.amount, 10);
4244
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4478
4245
  }
4479
4246
  /**
4480
4247
  * Returns the balance for the given owner for the given asset ID.
@@ -4486,9 +4253,9 @@ var _Provider = class {
4486
4253
  async getBalance(owner, assetId) {
4487
4254
  const { balance } = await this.operations.getBalance({
4488
4255
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4489
- assetId: (0, import_utils22.hexlify)(assetId)
4256
+ assetId: (0, import_utils23.hexlify)(assetId)
4490
4257
  });
4491
- return (0, import_math16.bn)(balance.amount, 10);
4258
+ return (0, import_math15.bn)(balance.amount, 10);
4492
4259
  }
4493
4260
  /**
4494
4261
  * Returns balances for the given owner.
@@ -4506,7 +4273,7 @@ var _Provider = class {
4506
4273
  const balances = result.balances.edges.map((edge) => edge.node);
4507
4274
  return balances.map((balance) => ({
4508
4275
  assetId: balance.assetId,
4509
- amount: (0, import_math16.bn)(balance.amount)
4276
+ amount: (0, import_math15.bn)(balance.amount)
4510
4277
  }));
4511
4278
  }
4512
4279
  /**
@@ -4524,19 +4291,19 @@ var _Provider = class {
4524
4291
  });
4525
4292
  const messages = result.messages.edges.map((edge) => edge.node);
4526
4293
  return messages.map((message) => ({
4527
- messageId: import_transactions19.InputMessageCoder.getMessageId({
4294
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4528
4295
  sender: message.sender,
4529
4296
  recipient: message.recipient,
4530
4297
  nonce: message.nonce,
4531
- amount: (0, import_math16.bn)(message.amount),
4298
+ amount: (0, import_math15.bn)(message.amount),
4532
4299
  data: message.data
4533
4300
  }),
4534
4301
  sender: import_address3.Address.fromAddressOrString(message.sender),
4535
4302
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4536
4303
  nonce: message.nonce,
4537
- amount: (0, import_math16.bn)(message.amount),
4538
- data: import_transactions19.InputMessageCoder.decodeData(message.data),
4539
- 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)
4540
4307
  }));
4541
4308
  }
4542
4309
  /**
@@ -4589,60 +4356,44 @@ var _Provider = class {
4589
4356
  } = result.messageProof;
4590
4357
  return {
4591
4358
  messageProof: {
4592
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4359
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4593
4360
  proofSet: messageProof.proofSet
4594
4361
  },
4595
4362
  blockProof: {
4596
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4363
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4597
4364
  proofSet: blockProof.proofSet
4598
4365
  },
4599
4366
  messageBlockHeader: {
4600
4367
  id: messageBlockHeader.id,
4601
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4602
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4368
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4369
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4603
4370
  transactionsRoot: messageBlockHeader.transactionsRoot,
4604
- height: (0, import_math16.bn)(messageBlockHeader.height),
4371
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4605
4372
  prevRoot: messageBlockHeader.prevRoot,
4606
4373
  time: messageBlockHeader.time,
4607
4374
  applicationHash: messageBlockHeader.applicationHash,
4608
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4609
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4610
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4611
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
4612
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4375
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4376
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4613
4377
  },
4614
4378
  commitBlockHeader: {
4615
4379
  id: commitBlockHeader.id,
4616
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4617
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4380
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4381
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4618
4382
  transactionsRoot: commitBlockHeader.transactionsRoot,
4619
- height: (0, import_math16.bn)(commitBlockHeader.height),
4383
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4620
4384
  prevRoot: commitBlockHeader.prevRoot,
4621
4385
  time: commitBlockHeader.time,
4622
4386
  applicationHash: commitBlockHeader.applicationHash,
4623
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4624
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4625
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4626
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
4627
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4387
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4388
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4628
4389
  },
4629
4390
  sender: import_address3.Address.fromAddressOrString(sender),
4630
4391
  recipient: import_address3.Address.fromAddressOrString(recipient),
4631
4392
  nonce,
4632
- amount: (0, import_math16.bn)(amount),
4393
+ amount: (0, import_math15.bn)(amount),
4633
4394
  data
4634
4395
  };
4635
4396
  }
4636
- async getLatestGasPrice() {
4637
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
4638
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4639
- }
4640
- async estimateGasPrice(blockHorizon) {
4641
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
4642
- blockHorizon: String(blockHorizon)
4643
- });
4644
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4645
- }
4646
4397
  /**
4647
4398
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
4648
4399
  *
@@ -4662,10 +4413,10 @@ var _Provider = class {
4662
4413
  */
4663
4414
  async produceBlocks(amount, startTime) {
4664
4415
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4665
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4666
- 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
4667
4418
  });
4668
- return (0, import_math16.bn)(latestBlockHeight);
4419
+ return (0, import_math15.bn)(latestBlockHeight);
4669
4420
  }
4670
4421
  // eslint-disable-next-line @typescript-eslint/require-await
4671
4422
  async getTransactionResponse(transactionId) {
@@ -4679,7 +4430,7 @@ cacheInputs_fn = function(inputs) {
4679
4430
  return;
4680
4431
  }
4681
4432
  inputs.forEach((input) => {
4682
- if (input.type === import_transactions19.InputType.Coin) {
4433
+ if (input.type === import_transactions18.InputType.Coin) {
4683
4434
  this.cache?.set(input.id);
4684
4435
  }
4685
4436
  });
@@ -4689,9 +4440,9 @@ __publicField(Provider, "nodeInfoCache", {});
4689
4440
 
4690
4441
  // src/providers/transaction-summary/get-transaction-summary.ts
4691
4442
  var import_errors15 = require("@fuel-ts/errors");
4692
- var import_math17 = require("@fuel-ts/math");
4693
- var import_transactions20 = require("@fuel-ts/transactions");
4694
- 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");
4695
4446
 
4696
4447
  // src/providers/chains.ts
4697
4448
  var CHAIN_IDS = {
@@ -4740,17 +4491,17 @@ var assets = [
4740
4491
 
4741
4492
  // src/utils/formatTransferToContractScriptData.ts
4742
4493
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4743
- var import_math18 = require("@fuel-ts/math");
4744
- var import_utils26 = require("@fuel-ts/utils");
4494
+ var import_math17 = require("@fuel-ts/math");
4495
+ var import_utils27 = require("@fuel-ts/utils");
4745
4496
  var asm = __toESM(require("@fuels/vm-asm"));
4746
4497
  var formatTransferToContractScriptData = (params) => {
4747
4498
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4748
4499
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4749
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4500
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4750
4501
  const scriptData = Uint8Array.from([
4751
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4502
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4752
4503
  ...encoded,
4753
- ...(0, import_utils26.arrayify)(assetId)
4504
+ ...(0, import_utils27.arrayify)(assetId)
4754
4505
  ]);
4755
4506
  return scriptData;
4756
4507
  };
@@ -4935,33 +4686,36 @@ var Account = class extends import_interfaces.AbstractAccount {
4935
4686
  * @param fee - The estimated transaction fee.
4936
4687
  * @returns A promise that resolves when the resources are added to the transaction.
4937
4688
  */
4938
- async fund(request, params) {
4939
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4940
- const txRequest = request;
4941
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4942
- amount: (0, import_math19.bn)(fee),
4689
+ async fund(request, coinQuantities, fee) {
4690
+ const updatedQuantities = addAmountToAsset({
4691
+ amount: (0, import_math18.bn)(fee),
4943
4692
  assetId: import_configs12.BaseAssetId,
4944
- coinQuantities: requiredQuantities
4693
+ coinQuantities
4945
4694
  });
4946
4695
  const quantitiesDict = {};
4947
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4696
+ updatedQuantities.forEach(({ amount, assetId }) => {
4948
4697
  quantitiesDict[assetId] = {
4949
4698
  required: amount,
4950
- owned: (0, import_math19.bn)(0)
4699
+ owned: (0, import_math18.bn)(0)
4951
4700
  };
4952
4701
  });
4953
- txRequest.inputs.forEach((input) => {
4702
+ const cachedUtxos = [];
4703
+ const cachedMessages = [];
4704
+ const owner = this.address.toB256();
4705
+ request.inputs.forEach((input) => {
4954
4706
  const isResource = "amount" in input;
4955
4707
  if (isResource) {
4956
4708
  const isCoin2 = "owner" in input;
4957
4709
  if (isCoin2) {
4958
4710
  const assetId = String(input.assetId);
4959
- if (quantitiesDict[assetId]) {
4960
- const amount = (0, import_math19.bn)(input.amount);
4711
+ if (input.owner === owner && quantitiesDict[assetId]) {
4712
+ const amount = (0, import_math18.bn)(input.amount);
4961
4713
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4714
+ cachedUtxos.push(input.id);
4962
4715
  }
4963
- } else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4716
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4964
4717
  quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4718
+ cachedMessages.push(input.nonce);
4965
4719
  }
4966
4720
  }
4967
4721
  });
@@ -4976,23 +4730,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4976
4730
  });
4977
4731
  const needsToBeFunded = missingQuantities.length;
4978
4732
  if (needsToBeFunded) {
4979
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4980
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4981
- txRequest.addResources(resources);
4982
- }
4983
- txRequest.shiftPredicateData();
4984
- txRequest.updatePredicateGasUsed(estimatedPredicates);
4985
- const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
4986
- if (addedSignatures) {
4987
- Array.from({ length: addedSignatures }).forEach(
4988
- () => requestToBeReEstimate.addEmptyWitness()
4989
- );
4733
+ const resources = await this.getResourcesToSpend(missingQuantities, {
4734
+ messages: cachedMessages,
4735
+ utxos: cachedUtxos
4736
+ });
4737
+ request.addResources(resources);
4990
4738
  }
4991
- const { maxFee } = await this.provider.estimateTxGasAndFee({
4992
- transactionRequest: requestToBeReEstimate
4993
- });
4994
- txRequest.maxFee = maxFee;
4995
- return txRequest;
4996
4739
  }
4997
4740
  /**
4998
4741
  * A helper that creates a transfer transaction request and returns it.
@@ -5000,25 +4743,28 @@ var Account = class extends import_interfaces.AbstractAccount {
5000
4743
  * @param destination - The address of the destination.
5001
4744
  * @param amount - The amount of coins to transfer.
5002
4745
  * @param assetId - The asset ID of the coins to transfer.
5003
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
4746
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5004
4747
  * @returns A promise that resolves to the prepared transaction request.
5005
4748
  */
5006
4749
  async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5007
- const request = new ScriptTransactionRequest(txParams);
4750
+ const { minGasPrice } = this.provider.getGasConfig();
4751
+ const params = { gasPrice: minGasPrice, ...txParams };
4752
+ const request = new ScriptTransactionRequest(params);
5008
4753
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
5009
- const txCost = await this.provider.getTransactionCost(request, {
4754
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5010
4755
  estimateTxDependencies: true,
5011
4756
  resourcesOwner: this
5012
4757
  });
5013
- if ("gasLimit" in txParams) {
5014
- this.validateGas({
5015
- gasUsed: txCost.gasUsed,
5016
- gasLimit: request.gasLimit
5017
- });
5018
- }
5019
- request.gasLimit = txCost.gasUsed;
5020
- request.maxFee = txCost.maxFee;
5021
- await this.fund(request, txCost);
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
4765
+ });
4766
+ await this.fund(request, requiredQuantities, maxFee);
4767
+ request.updatePredicateInputs(estimatedInputs);
5022
4768
  return request;
5023
4769
  }
5024
4770
  /**
@@ -5031,7 +4777,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5031
4777
  * @returns A promise that resolves to the transaction response.
5032
4778
  */
5033
4779
  async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5034
- if ((0, import_math19.bn)(amount).lte(0)) {
4780
+ if ((0, import_math18.bn)(amount).lte(0)) {
5035
4781
  throw new import_errors16.FuelError(
5036
4782
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5037
4783
  "Transfer amount must be a positive number."
@@ -5050,37 +4796,38 @@ var Account = class extends import_interfaces.AbstractAccount {
5050
4796
  * @returns A promise that resolves to the transaction response.
5051
4797
  */
5052
4798
  async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5053
- if ((0, import_math19.bn)(amount).lte(0)) {
4799
+ if ((0, import_math18.bn)(amount).lte(0)) {
5054
4800
  throw new import_errors16.FuelError(
5055
4801
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5056
4802
  "Transfer amount must be a positive number."
5057
4803
  );
5058
4804
  }
5059
4805
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4806
+ const { minGasPrice } = this.provider.getGasConfig();
4807
+ const params = { gasPrice: minGasPrice, ...txParams };
5060
4808
  const { script, scriptData } = await assembleTransferToContractScript({
5061
4809
  hexlifiedContractId: contractAddress.toB256(),
5062
- amountToTransfer: (0, import_math19.bn)(amount),
4810
+ amountToTransfer: (0, import_math18.bn)(amount),
5063
4811
  assetId
5064
4812
  });
5065
4813
  const request = new ScriptTransactionRequest({
5066
- ...txParams,
4814
+ ...params,
5067
4815
  script,
5068
4816
  scriptData
5069
4817
  });
5070
4818
  request.addContractInputAndOutput(contractAddress);
5071
- const txCost = await this.provider.getTransactionCost(request, {
5072
- resourcesOwner: this,
5073
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
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
5074
4829
  });
5075
- if (txParams.gasLimit) {
5076
- this.validateGas({
5077
- gasUsed: txCost.gasUsed,
5078
- gasLimit: request.gasLimit
5079
- });
5080
- }
5081
- request.gasLimit = txCost.gasUsed;
5082
- request.maxFee = txCost.maxFee;
5083
- await this.fund(request, txCost);
4830
+ await this.fund(request, requiredQuantities, maxFee);
5084
4831
  return this.sendTransaction(request);
5085
4832
  }
5086
4833
  /**
@@ -5092,31 +4839,34 @@ var Account = class extends import_interfaces.AbstractAccount {
5092
4839
  * @returns A promise that resolves to the transaction response.
5093
4840
  */
5094
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4842
+ const { minGasPrice } = this.provider.getGasConfig();
5095
4843
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5096
- const recipientDataArray = (0, import_utils27.arrayify)(
4844
+ const recipientDataArray = (0, import_utils28.arrayify)(
5097
4845
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5098
4846
  );
5099
- const amountDataArray = (0, import_utils27.arrayify)(
5100
- "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"))
5101
4849
  );
5102
4850
  const script = new Uint8Array([
5103
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4851
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5104
4852
  ...recipientDataArray,
5105
4853
  ...amountDataArray
5106
4854
  ]);
5107
- const params = { script, ...txParams };
4855
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5108
4856
  const request = new ScriptTransactionRequest(params);
5109
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
5110
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5111
- if (txParams.gasLimit) {
5112
- this.validateGas({
5113
- gasUsed: txCost.gasUsed,
5114
- gasLimit: request.gasLimit
5115
- });
5116
- }
5117
- request.maxFee = txCost.maxFee;
5118
- request.gasLimit = txCost.gasUsed;
5119
- await this.fund(request, txCost);
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
4868
+ });
4869
+ await this.fund(request, requiredQuantities, maxFee);
5120
4870
  return this.sendTransaction(request);
5121
4871
  }
5122
4872
  async signMessage(message) {
@@ -5174,7 +4924,18 @@ var Account = class extends import_interfaces.AbstractAccount {
5174
4924
  }
5175
4925
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5176
4926
  }
5177
- validateGas({ gasUsed, gasLimit }) {
4927
+ validateGas({
4928
+ gasUsed,
4929
+ gasPrice,
4930
+ gasLimit,
4931
+ minGasPrice
4932
+ }) {
4933
+ if (minGasPrice.gt(gasPrice)) {
4934
+ throw new import_errors16.FuelError(
4935
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4936
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4937
+ );
4938
+ }
5178
4939
  if (gasUsed.gt(gasLimit)) {
5179
4940
  throw new import_errors16.FuelError(
5180
4941
  import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -5188,8 +4949,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5188
4949
  var import_address5 = require("@fuel-ts/address");
5189
4950
  var import_crypto2 = require("@fuel-ts/crypto");
5190
4951
  var import_hasher2 = require("@fuel-ts/hasher");
5191
- var import_math20 = require("@fuel-ts/math");
5192
- var import_utils28 = require("@fuel-ts/utils");
4952
+ var import_math19 = require("@fuel-ts/math");
4953
+ var import_utils29 = require("@fuel-ts/utils");
5193
4954
  var import_secp256k1 = require("@noble/curves/secp256k1");
5194
4955
  var Signer = class {
5195
4956
  address;
@@ -5208,10 +4969,10 @@ var Signer = class {
5208
4969
  privateKey = `0x${privateKey}`;
5209
4970
  }
5210
4971
  }
5211
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5212
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5213
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5214
- 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));
5215
4976
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5216
4977
  }
5217
4978
  /**
@@ -5225,11 +4986,11 @@ var Signer = class {
5225
4986
  * @returns hashed signature
5226
4987
  */
5227
4988
  sign(data) {
5228
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5229
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5230
- 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);
5231
4992
  s[0] |= (signature.recovery || 0) << 7;
5232
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4993
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5233
4994
  }
5234
4995
  /**
5235
4996
  * Add point on the current elliptic curve
@@ -5238,8 +4999,8 @@ var Signer = class {
5238
4999
  * @returns compressed point on the curve
5239
5000
  */
5240
5001
  addPoint(point) {
5241
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5242
- 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));
5243
5004
  const result = p0.add(p1);
5244
5005
  return `0x${result.toHex(true)}`;
5245
5006
  }
@@ -5251,16 +5012,16 @@ var Signer = class {
5251
5012
  * @returns public key from signature from the
5252
5013
  */
5253
5014
  static recoverPublicKey(data, signature) {
5254
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5015
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5255
5016
  const r = signedMessageBytes.slice(0, 32);
5256
5017
  const s = signedMessageBytes.slice(32, 64);
5257
5018
  const recoveryParam = (s[0] & 128) >> 7;
5258
5019
  s[0] &= 127;
5259
- 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(
5260
5021
  recoveryParam
5261
5022
  );
5262
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5263
- 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);
5264
5025
  }
5265
5026
  /**
5266
5027
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5279,7 +5040,7 @@ var Signer = class {
5279
5040
  * @returns random 32-byte hashed
5280
5041
  */
5281
5042
  static generatePrivateKey(entropy) {
5282
- 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);
5283
5044
  }
5284
5045
  /**
5285
5046
  * Extended publicKey from a compact publicKey
@@ -5288,8 +5049,8 @@ var Signer = class {
5288
5049
  * @returns extended publicKey
5289
5050
  */
5290
5051
  static extendPublicKey(publicKey) {
5291
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5292
- 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));
5293
5054
  }
5294
5055
  };
5295
5056
 
@@ -5297,7 +5058,7 @@ var Signer = class {
5297
5058
  var import_address6 = require("@fuel-ts/address");
5298
5059
  var import_crypto3 = require("@fuel-ts/crypto");
5299
5060
  var import_errors17 = require("@fuel-ts/errors");
5300
- var import_utils29 = require("@fuel-ts/utils");
5061
+ var import_utils30 = require("@fuel-ts/utils");
5301
5062
  var import_uuid = require("uuid");
5302
5063
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5303
5064
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5380,7 +5141,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5380
5141
  );
5381
5142
  }
5382
5143
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5383
- const privateKey = (0, import_utils29.hexlify)(buffer);
5144
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5384
5145
  return privateKey;
5385
5146
  }
5386
5147
 
@@ -5425,7 +5186,7 @@ var BaseWalletUnlocked = class extends Account {
5425
5186
  */
5426
5187
  async signMessage(message) {
5427
5188
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5428
- return (0, import_utils30.hexlify)(signedMessage);
5189
+ return (0, import_utils31.hexlify)(signedMessage);
5429
5190
  }
5430
5191
  /**
5431
5192
  * Signs a transaction with the wallet's private key.
@@ -5438,7 +5199,7 @@ var BaseWalletUnlocked = class extends Account {
5438
5199
  const chainId = this.provider.getChainId();
5439
5200
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5440
5201
  const signature = await this.signer().sign(hashedTransaction);
5441
- return (0, import_utils30.hexlify)(signature);
5202
+ return (0, import_utils31.hexlify)(signature);
5442
5203
  }
5443
5204
  /**
5444
5205
  * Populates a transaction with the witnesses signature.
@@ -5458,7 +5219,7 @@ var BaseWalletUnlocked = class extends Account {
5458
5219
  * @param transactionRequestLike - The transaction request to send.
5459
5220
  * @returns A promise that resolves to the TransactionResponse object.
5460
5221
  */
5461
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
5222
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
5462
5223
  const transactionRequest = transactionRequestify(transactionRequestLike);
5463
5224
  if (estimateTxDependencies) {
5464
5225
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -5499,15 +5260,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5499
5260
  // src/hdwallet/hdwallet.ts
5500
5261
  var import_errors20 = require("@fuel-ts/errors");
5501
5262
  var import_hasher6 = require("@fuel-ts/hasher");
5502
- var import_math21 = require("@fuel-ts/math");
5503
- var import_utils34 = require("@fuel-ts/utils");
5263
+ var import_math20 = require("@fuel-ts/math");
5264
+ var import_utils35 = require("@fuel-ts/utils");
5504
5265
  var import_ethers3 = require("ethers");
5505
5266
 
5506
5267
  // src/mnemonic/mnemonic.ts
5507
5268
  var import_crypto4 = require("@fuel-ts/crypto");
5508
5269
  var import_errors19 = require("@fuel-ts/errors");
5509
5270
  var import_hasher5 = require("@fuel-ts/hasher");
5510
- var import_utils32 = require("@fuel-ts/utils");
5271
+ var import_utils33 = require("@fuel-ts/utils");
5511
5272
  var import_ethers2 = require("ethers");
5512
5273
 
5513
5274
  // src/wordlists/words/english.ts
@@ -7565,7 +7326,7 @@ var english = [
7565
7326
  // src/mnemonic/utils.ts
7566
7327
  var import_errors18 = require("@fuel-ts/errors");
7567
7328
  var import_hasher4 = require("@fuel-ts/hasher");
7568
- var import_utils31 = require("@fuel-ts/utils");
7329
+ var import_utils32 = require("@fuel-ts/utils");
7569
7330
  function toUtf8Bytes(stri) {
7570
7331
  const str = stri.normalize("NFKD");
7571
7332
  const result = [];
@@ -7632,14 +7393,14 @@ function entropyToMnemonicIndices(entropy) {
7632
7393
  }
7633
7394
  }
7634
7395
  const checksumBits = entropy.length / 4;
7635
- 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);
7636
7397
  indices[indices.length - 1] <<= checksumBits;
7637
7398
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7638
7399
  return indices;
7639
7400
  }
7640
7401
  function mnemonicWordsToEntropy(words, wordlist) {
7641
7402
  const size = Math.ceil(11 * words.length / 8);
7642
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7403
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7643
7404
  let offset = 0;
7644
7405
  for (let i = 0; i < words.length; i += 1) {
7645
7406
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7659,7 +7420,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7659
7420
  const entropyBits = 32 * words.length / 3;
7660
7421
  const checksumBits = words.length / 3;
7661
7422
  const checksumMask = getUpperMask(checksumBits);
7662
- 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;
7663
7424
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7664
7425
  throw new import_errors18.FuelError(
7665
7426
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7734,7 +7495,7 @@ var Mnemonic = class {
7734
7495
  static mnemonicToEntropy(phrase, wordlist = english) {
7735
7496
  const words = getWords(phrase);
7736
7497
  assertMnemonic(words);
7737
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7498
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7738
7499
  }
7739
7500
  /**
7740
7501
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7742,7 +7503,7 @@ var Mnemonic = class {
7742
7503
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7743
7504
  */
7744
7505
  static entropyToMnemonic(entropy, wordlist = english) {
7745
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7506
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7746
7507
  assertWordList(wordlist);
7747
7508
  assertEntropy(entropyBytes);
7748
7509
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7811,14 +7572,14 @@ var Mnemonic = class {
7811
7572
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7812
7573
  */
7813
7574
  static masterKeysFromSeed(seed) {
7814
- const seedArray = (0, import_utils32.arrayify)(seed);
7575
+ const seedArray = (0, import_utils33.arrayify)(seed);
7815
7576
  if (seedArray.length < 16 || seedArray.length > 64) {
7816
7577
  throw new import_errors19.FuelError(
7817
7578
  import_errors19.ErrorCode.INVALID_SEED,
7818
7579
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7819
7580
  );
7820
7581
  }
7821
- 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));
7822
7583
  }
7823
7584
  /**
7824
7585
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7829,22 +7590,22 @@ var Mnemonic = class {
7829
7590
  */
7830
7591
  static seedToExtendedKey(seed, testnet = false) {
7831
7592
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7832
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7593
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7833
7594
  const depth = "0x00";
7834
7595
  const fingerprint = "0x00000000";
7835
7596
  const index = "0x00000000";
7836
7597
  const chainCode = masterKey.slice(32);
7837
7598
  const privateKey = masterKey.slice(0, 32);
7838
- const extendedKey = (0, import_utils32.concat)([
7599
+ const extendedKey = (0, import_utils33.concat)([
7839
7600
  prefix,
7840
7601
  depth,
7841
7602
  fingerprint,
7842
7603
  index,
7843
7604
  chainCode,
7844
- (0, import_utils32.concat)(["0x00", privateKey])
7605
+ (0, import_utils33.concat)(["0x00", privateKey])
7845
7606
  ]);
7846
7607
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7847
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7608
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7848
7609
  }
7849
7610
  /**
7850
7611
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7859,7 +7620,7 @@ var Mnemonic = class {
7859
7620
  * @returns A randomly generated mnemonic
7860
7621
  */
7861
7622
  static generate(size = 32, extraEntropy = "") {
7862
- 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);
7863
7624
  return Mnemonic.entropyToMnemonic(entropy);
7864
7625
  }
7865
7626
  };
@@ -7867,12 +7628,12 @@ var mnemonic_default = Mnemonic;
7867
7628
 
7868
7629
  // src/hdwallet/hdwallet.ts
7869
7630
  var HARDENED_INDEX = 2147483648;
7870
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7871
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7872
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7873
- 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");
7874
7635
  function base58check(data) {
7875
- 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)]));
7876
7637
  }
7877
7638
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7878
7639
  if (isPublic) {
@@ -7881,11 +7642,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7881
7642
  return testnet ? TestnetPRV2 : MainnetPRV2;
7882
7643
  }
7883
7644
  function isPublicExtendedKey(extendedKey) {
7884
- 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)));
7885
7646
  }
7886
7647
  function isValidExtendedKey(extendedKey) {
7887
7648
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7888
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7649
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7889
7650
  );
7890
7651
  }
7891
7652
  function parsePath(path2, depth = 0) {
@@ -7903,8 +7664,8 @@ function parsePath(path2, depth = 0) {
7903
7664
  var HDWallet = class {
7904
7665
  depth = 0;
7905
7666
  index = 0;
7906
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7907
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7667
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7668
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7908
7669
  privateKey;
7909
7670
  publicKey;
7910
7671
  chainCode;
@@ -7916,8 +7677,8 @@ var HDWallet = class {
7916
7677
  constructor(config) {
7917
7678
  if (config.privateKey) {
7918
7679
  const signer = new Signer(config.privateKey);
7919
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7920
- 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);
7921
7682
  } else {
7922
7683
  if (!config.publicKey) {
7923
7684
  throw new import_errors20.FuelError(
@@ -7925,7 +7686,7 @@ var HDWallet = class {
7925
7686
  "Both public and private Key cannot be missing. At least one should be provided."
7926
7687
  );
7927
7688
  }
7928
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7689
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7929
7690
  }
7930
7691
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7931
7692
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7944,9 +7705,9 @@ var HDWallet = class {
7944
7705
  * @returns A new instance of HDWallet on the derived index
7945
7706
  */
7946
7707
  deriveIndex(index) {
7947
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7948
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7949
- 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);
7950
7711
  const data = new Uint8Array(37);
7951
7712
  if (index & HARDENED_INDEX) {
7952
7713
  if (!privateKey) {
@@ -7957,15 +7718,15 @@ var HDWallet = class {
7957
7718
  }
7958
7719
  data.set(privateKey, 1);
7959
7720
  } else {
7960
- data.set((0, import_utils34.arrayify)(this.publicKey));
7721
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7961
7722
  }
7962
- data.set((0, import_math21.toBytes)(index, 4), 33);
7963
- 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));
7964
7725
  const IL = bytes.slice(0, 32);
7965
7726
  const IR = bytes.slice(32);
7966
7727
  if (privateKey) {
7967
7728
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7968
- 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);
7969
7730
  return new HDWallet({
7970
7731
  privateKey: ki,
7971
7732
  chainCode: IR,
@@ -7974,7 +7735,7 @@ var HDWallet = class {
7974
7735
  parentFingerprint: this.fingerprint
7975
7736
  });
7976
7737
  }
7977
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7738
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7978
7739
  const Ki = signer.addPoint(publicKey);
7979
7740
  return new HDWallet({
7980
7741
  publicKey: Ki,
@@ -8009,12 +7770,12 @@ var HDWallet = class {
8009
7770
  );
8010
7771
  }
8011
7772
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8012
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7773
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8013
7774
  const parentFingerprint = this.parentFingerprint;
8014
- const index = (0, import_math21.toHex)(this.index, 4);
7775
+ const index = (0, import_math20.toHex)(this.index, 4);
8015
7776
  const chainCode = this.chainCode;
8016
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8017
- 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]));
8018
7779
  return base58check(extendedKey);
8019
7780
  }
8020
7781
  /**
@@ -8026,13 +7787,13 @@ var HDWallet = class {
8026
7787
  static fromSeed(seed) {
8027
7788
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8028
7789
  return new HDWallet({
8029
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8030
- 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))
8031
7792
  });
8032
7793
  }
8033
7794
  static fromExtendedKey(extendedKey) {
8034
7795
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8035
- const bytes = (0, import_utils34.arrayify)(decoded);
7796
+ const bytes = (0, import_utils35.arrayify)(decoded);
8036
7797
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8037
7798
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8038
7799
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8041,9 +7802,9 @@ var HDWallet = class {
8041
7802
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8042
7803
  }
8043
7804
  const depth = bytes[4];
8044
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8045
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8046
- 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));
8047
7808
  const key = bytes.slice(45, 78);
8048
7809
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8049
7810
  throw new import_errors20.FuelError(
@@ -8236,15 +7997,14 @@ var seedTestWallet = async (wallet, quantities) => {
8236
7997
  process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
8237
7998
  wallet.provider
8238
7999
  );
8239
- const request = new ScriptTransactionRequest();
8240
- quantities.forEach((quantity) => {
8241
- const { amount, assetId } = coinQuantityfy(quantity);
8242
- 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
8243
8005
  });
8244
- const txCost = await genesisWallet.provider.getTransactionCost(request);
8245
- request.gasLimit = txCost.gasUsed;
8246
- request.maxFee = txCost.maxFee;
8247
- await genesisWallet.fund(request, txCost);
8006
+ request.addResources(resources);
8007
+ quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
8248
8008
  await genesisWallet.sendTransaction(request, { awaitExecution: true });
8249
8009
  };
8250
8010
 
@@ -8258,13 +8018,12 @@ var generateTestWallet = async (provider, quantities) => {
8258
8018
  };
8259
8019
 
8260
8020
  // src/test-utils/launchNode.ts
8261
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
8262
8021
  var import_configs13 = require("@fuel-ts/address/configs");
8263
- var import_crypto6 = require("@fuel-ts/crypto");
8264
- var import_utils35 = require("@fuel-ts/utils");
8022
+ var import_math21 = require("@fuel-ts/math");
8023
+ var import_utils36 = require("@fuel-ts/utils");
8265
8024
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8266
8025
  var import_child_process = require("child_process");
8267
- var import_crypto7 = require("crypto");
8026
+ var import_crypto6 = require("crypto");
8268
8027
  var import_fs = require("fs");
8269
8028
  var import_os = __toESM(require("os"));
8270
8029
  var import_path = __toESM(require("path"));
@@ -8313,13 +8072,13 @@ var launchNode = async ({
8313
8072
  // eslint-disable-next-line no-async-promise-executor
8314
8073
  new Promise(async (resolve, reject) => {
8315
8074
  const remainingArgs = extractRemainingArgs(args, [
8316
- "--snapshot",
8075
+ "--chain",
8317
8076
  "--consensus-key",
8318
8077
  "--db-type",
8319
8078
  "--poa-instant"
8320
8079
  ]);
8321
- const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
8322
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8080
+ const chainConfigPath = getFlagValueFromArgs(args, "--chain");
8081
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8323
8082
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8324
8083
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8325
8084
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8336,55 +8095,37 @@ var launchNode = async ({
8336
8095
  })).toString();
8337
8096
  let chainConfigPathToUse;
8338
8097
  const prefix = basePath || import_os.default.tmpdir();
8339
- const suffix = basePath ? "" : (0, import_crypto7.randomUUID)();
8340
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
8098
+ const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
8099
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
8341
8100
  if (chainConfigPath) {
8342
8101
  chainConfigPathToUse = chainConfigPath;
8343
8102
  } else {
8344
8103
  if (!(0, import_fs.existsSync)(tempDirPath)) {
8345
8104
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8346
8105
  }
8347
- let { stateConfigJson } = import_utils35.defaultChainConfigs;
8348
- const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
8349
- stateConfigJson = {
8350
- ...stateConfigJson,
8351
- coins: [
8352
- ...stateConfigJson.coins.map((coin) => ({
8353
- ...coin,
8354
- amount: "18446744073709551615"
8355
- }))
8356
- ],
8357
- messages: stateConfigJson.messages.map((message) => ({
8358
- ...message,
8359
- amount: "18446744073709551615"
8360
- }))
8361
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8362
- };
8106
+ const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
8107
+ let chainConfig = import_utils36.defaultChainConfig;
8363
8108
  if (!process.env.GENESIS_SECRET) {
8364
8109
  const pk = Signer.generatePrivateKey();
8365
8110
  const signer = new Signer(pk);
8366
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8367
- stateConfigJson.coins.push({
8368
- tx_id: (0, import_utils35.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8369
- owner: signer.address.toHexString(),
8370
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8371
- amount: "18446744073709551615",
8372
- asset_id: import_configs13.BaseAssetId,
8373
- output_index: 0,
8374
- tx_pointer_block_height: 0,
8375
- tx_pointer_tx_idx: 0
8376
- });
8111
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8112
+ chainConfig = {
8113
+ ...import_utils36.defaultChainConfig,
8114
+ initial_state: {
8115
+ ...import_utils36.defaultChainConfig.initial_state,
8116
+ coins: [
8117
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8118
+ {
8119
+ owner: signer.address.toHexString(),
8120
+ amount: (0, import_math21.toHex)(1e9),
8121
+ asset_id: import_configs13.BaseAssetId
8122
+ }
8123
+ ]
8124
+ }
8125
+ };
8377
8126
  }
8378
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8379
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8380
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8381
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8382
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8383
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8384
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8385
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8386
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8387
- chainConfigPathToUse = tempDirPath;
8127
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
8128
+ chainConfigPathToUse = tempChainConfigFilePath;
8388
8129
  }
8389
8130
  const child = (0, import_child_process.spawn)(
8390
8131
  command,
@@ -8393,10 +8134,10 @@ var launchNode = async ({
8393
8134
  ["--ip", ipToUse],
8394
8135
  ["--port", portToUse],
8395
8136
  useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8396
- ["--min-gas-price", "1"],
8137
+ ["--min-gas-price", "0"],
8397
8138
  poaInstant ? ["--poa-instant", "true"] : [],
8398
8139
  ["--consensus-key", consensusKey],
8399
- ["--snapshot", chainConfigPathToUse],
8140
+ ["--chain", chainConfigPathToUse],
8400
8141
  "--vm-backtrace",
8401
8142
  "--utxo-validation",
8402
8143
  "--debug",
@@ -8455,7 +8196,7 @@ var launchNodeAndGetWallets = async ({
8455
8196
  walletCount = 10
8456
8197
  } = {}) => {
8457
8198
  const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
8458
- const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
8199
+ const provider = await Provider.create(`http://${ip}:${port}/graphql`);
8459
8200
  const wallets = await generateWallets(walletCount, provider);
8460
8201
  const cleanup = () => {
8461
8202
  closeNode();