recon-generate 0.0.24 → 0.0.25

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.
Files changed (2) hide show
  1. package/dist/info.js +24 -6
  2. package/package.json +1 -1
package/dist/info.js CHANGED
@@ -167,6 +167,25 @@ const formatLiteralValue = (lit) => {
167
167
  }
168
168
  return (_a = lit.value) !== null && _a !== void 0 ? _a : '';
169
169
  };
170
+ /**
171
+ * Get the effective type of a literal, considering type conversions.
172
+ * e.g., for `address(0x100)`, returns 'address' instead of 'int_const'
173
+ */
174
+ const getEffectiveLiteralType = (lit) => {
175
+ var _a;
176
+ const value = formatLiteralValue(lit);
177
+ // Check if the literal is inside a type conversion like address(0x100)
178
+ const parent = lit.parent;
179
+ if (parent instanceof solc_typed_ast_1.FunctionCall && parent.kind === solc_typed_ast_1.FunctionCallKind.TypeConversion) {
180
+ // Use the conversion target type
181
+ const targetType = parent.typeString;
182
+ if (targetType) {
183
+ return typeStringToSolidityType(targetType, value);
184
+ }
185
+ }
186
+ // Fall back to the literal's own type
187
+ return typeStringToSolidityType((_a = lit.typeString) !== null && _a !== void 0 ? _a : '', value);
188
+ };
170
189
  const getAllContracts = (sourceUnits) => {
171
190
  const contracts = new Map();
172
191
  for (const unit of sourceUnits) {
@@ -455,19 +474,19 @@ const collectAssertStatements = (contract, foundryRoot, sourceContents) => {
455
474
  * Also includes Z3-solved values from constraint expressions
456
475
  */
457
476
  const collectConstantsUsed = async (contract) => {
458
- var _a;
459
477
  const constantsUsed = {};
478
+ // Collect constants from ALL functions in the C3 linearization (including internal/private)
479
+ // This is critical for fuzzing as constants in setup() and internal helpers are relevant
460
480
  const allFunctions = (0, utils_1.getDefinitions)(contract, 'vFunctions', true).reverse();
461
481
  for (const fnDef of allFunctions) {
462
- if (fnDef.visibility !== solc_typed_ast_1.FunctionVisibility.External && fnDef.visibility !== solc_typed_ast_1.FunctionVisibility.Public) {
463
- continue;
464
- }
482
+ // No visibility filter - we want constants from all functions in the inheritance chain
465
483
  const sig = signatureFromFnDef(fnDef);
466
484
  const literals = [];
467
485
  // Collect literal constants
468
486
  for (const lit of fnDef.getChildrenByType(solc_typed_ast_1.Literal)) {
469
487
  const value = formatLiteralValue(lit);
470
- const type = typeStringToSolidityType((_a = lit.typeString) !== null && _a !== void 0 ? _a : '', value);
488
+ // Use effective type which considers type conversions like address(0x100)
489
+ const type = getEffectiveLiteralType(lit);
471
490
  // Each constant is wrapped in an array (matching slither format)
472
491
  literals.push([{ value, type }]);
473
492
  }
@@ -764,7 +783,6 @@ const buildCoverageBlockFromBody = (definition, sourceContents, contract, callTr
764
783
  */
765
784
  const buildCoverageBlockFromIfStatement = (ifStmt, sourceContents, absolutePath) => {
766
785
  const blocks = [];
767
- const content = sourceContents.get(absolutePath) || '';
768
786
  // True branch
769
787
  if (ifStmt.vTrueBody) {
770
788
  const trueBranch = buildCoverageBlockFromStatementOrBlock(ifStmt.vTrueBody, sourceContents, absolutePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recon-generate",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "CLI to scaffold Recon fuzzing suite inside Foundry projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {