Skip to content

Conversation

@MiguelLZPF
Copy link
Contributor

@MiguelLZPF MiguelLZPF commented Jan 27, 2026

Description

This PR refactors the smart contracts build pipeline with two major improvements:

  1. Migrate to tsx: Replaced ts-node with tsx for ~3x faster script execution. Removed redundant tsconfig-paths configuration and simplified TypeScript script handling with native path alias support.

  2. Restructure registry generator: Reorganized the monolithic registry generator into a well-structured, modular architecture with clear separation of concerns:

    • extractor.ts: Contract metadata extraction from artifacts
    • scanner.ts: Filesystem scanning and contract discovery
    • generator.ts: Code generation logic
    • pipeline.ts: Main generation orchestration
    • types.ts: Centralized type definitions
    • Utilities: ABI extraction, file I/O, logging, and Solidity parsing

Benefits

  • Performance: Eliminated 6+ second TypeChain import overhead from registry generation
  • Maintainability: Single-responsibility modules with clear boundaries
  • Testability: Isolated concerns enable focused unit testing
  • Flexibility: New caching support via --use-cache flag and npm run generate:registry:cached
  • Convenience: Scripts exposed at monorepo root level (test:scripts, generate:registry, etc.)

Type of change

  • Refactor 🔧

Testing

  • Run npm run ats:contracts:test to verify contract compilation and tests still pass
  • Run npm run generate:registry to test registry generation pipeline
  • Run npm run test:scripts:unit to verify registry generator unit tests

Node version:

  • 20
  • 22
  • 24

Checklist

  • Style Guidelines followed ✅
  • Documentation Updated 📚 (scripts/README.md)
  • Linters - No New Warnings ⚠️
  • Local Tests Pass ✅
  • Effective Tests Added ✔️
  • No reduction of Coverage

@hedera-eng-infrastructure
Copy link

hedera-eng-infrastructure commented Jan 27, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@MiguelLZPF MiguelLZPF self-assigned this Jan 27, 2026
@MiguelLZPF MiguelLZPF added Improvement Code changes driven by non business requirements Contracts Changes related to the “contracts” module labels Jan 27, 2026
@MiguelLZPF MiguelLZPF force-pushed the refactor/new-registry-generator branch from 36e04f7 to 9757261 Compare January 27, 2026 13:24
pull_request:
branches:
- develop
- development
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the development branch is being added, should the develop branch be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah bit weird, I agree. But we have to use a new name because in develop where recurrent DCO problems and was a last minute solution, kind of... So we leave the door open to go back to develop and by keeping both we make sure will not have to make any changes to this workflow later on.

@MiguelLZPF MiguelLZPF force-pushed the refactor/new-registry-generator branch from 9757261 to c930d0a Compare January 28, 2026 10:22
Reorganize the monolithic registry generator into a well-structured module
with clear separation of concerns:

Core Components:
- extractor.ts: Contract metadata extraction from artifacts
- scanner.ts: Filesystem scanning and contract discovery
- generator.ts: Code generation logic (formerly registryGenerator.ts)
- pipeline.ts: Main generation orchestration
- types.ts: Centralized type definitions

Utilities:
- abiExtractor: ABI parsing and extraction
- fileUtils: File I/O operations
- logging: Structured logging
- solidityParser: Comprehensive Solidity parser avoiding TypeChain

Benefits:
- Eliminated 6+ second TypeChain import overhead
- Improved maintainability with single-responsibility modules
- Better testability with isolated concerns
- Flexible caching support via --use-cache flag
- New npm script: npm run generate:registry:cached

Infrastructure:
- Updated barrel exports (index.ts files)
- Cleaned up atsRegistry.data.ts (removed unused exports)
- Updated CLI entry point with improved argument parsing
- Enhanced logging capabilities
- Updated integration tests

Removed:
- Old generateRegistry.ts monolithic entry point
- Duplicated operations from infrastructure layer

Reorganized files:
- scripts/tools/generators/registryGenerator.ts →
  registry-generator/core/generator.ts
- scripts/infrastructure/operations/generateRegistryPipeline.ts →
  registry-generator/pipeline.ts

Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
Migrate from ts-node with tsconfig-paths/register to tsx for faster,
simpler TypeScript script execution. Remove redundant ts-node configuration
from tsconfig.json since tsx handles path aliases natively.

Changes:
- packages/ats/contracts/package.json: Replace all ts-node invocations
  with tsx in CLI entry points (deploy*, upgrade*, generate:registry)
- packages/ats/contracts/tsconfig.json: Remove ts-node configuration block
- package.json: Add convenience scripts for contracts utilities exposed at
  root level (test:scripts:unit:parallel, test:scripts:integration:parallel,
  upgrade:previewnet, generate:registry, local:hardhat, size, slither, doc)

Benefits:
- Faster script execution with tsx (no tsconfig-paths dependency)
- Simpler configuration (one less configuration block)
- Better IDE integration and debugging support
- Scripts available directly from monorepo root for convenience

Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
@MiguelLZPF MiguelLZPF force-pushed the refactor/new-registry-generator branch from c930d0a to bde618b Compare January 28, 2026 12:45
The pre-push hook was incorrectly rejecting commits that had valid GPG
signatures but whose public keys were not in the local keyring. This
caused pushes to fail when rebasing from branches with commits signed
by other team members.

Changed from `git verify-commit` (requires public key) to
`git log --format=%G?` which checks if a signature EXISTS without
requiring verification. The hook now accepts any signature status
except 'N' (no signature).

Signed-off-by: Miguel Carpena <miguel.carpena@io.builders>
Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
@MiguelLZPF MiguelLZPF merged commit f1d22ad into development Jan 28, 2026
14 checks passed
@MiguelLZPF MiguelLZPF deleted the refactor/new-registry-generator branch January 28, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contracts Changes related to the “contracts” module Improvement Code changes driven by non business requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants