TypeChain & Exports
Relevant source files
The following files were used as context for generating this wiki page:
The Canon Guard project includes a specialized workflow for exporting Solidity contracts and interfaces as TypeScript packages. This system utilizes TypeChain to generate strongly-typed interfaces, providing developers with a seamless way to interact with Canon Guard smart contracts in frontend or backend TypeScript environments. The export process is designed to be automated via GitHub Actions and published to the NPM registry.
Sources: README.md:92-94, CLAUDE.md:12-19
Export Architecture and Workflow
The export system is built to transform on-chain logic into consumable off-chain packages. It relies on the defi-wonderland/solidity-exporter-action to handle the heavy lifting of generating TypeChain artifacts from the project's Solidity source files.
Export Process Flow
This diagram illustrates the automated path from Solidity code to a published TypeScript package.
The workflow is conditionally enabled in the CI/CD pipeline, requiring specific organization secrets and configuration parameters to function correctly.
Sources: README.md:92-118
Configuration and Tooling
The export system integrates with the broader project build and dependency management tools.
Key Export Components
| Component | Description | Source File |
|---|---|---|
| Solidity Exporter | A GitHub Action (solidity-exporter-action) that automates TypeChain generation. | README.md:104-106 |
| TypeChain | The underlying tool that creates TypeScript bindings for Ethereum smart contracts. | README.md:93 |
| NPM Token | A required secret (NPM_TOKEN) used for authenticating the publishing process. | README.md:96 |
| Package Name | A configurable parameter (e.g., my-cool-project-interfaces) for the generated package. | README.md:107-108 |
Project Integration
The project uses foundry.toml to define compilation profiles that the exporter interacts with. Specifically, the docs profile is configured to target interfaces, which are often the primary target for TypeChain exports.
[profile.docs]
src = 'src/interfaces/'
Sources: foundry.toml:27-28
The project remappings ensure that the exporter can correctly resolve dependencies like @safe-smart-account and solady during the artifact generation phase.
Sources: remappings.txt:1-7
Deployment and Publishing
Once the TypeScript interfaces are generated, they are organized into subdirectories within an export/ folder and published as public packages.
Sequence of Publishing Actions
The following sequence diagram shows the steps taken by the CI environment to finalize a release.
Sources: README.md:115-117
Implementation Details
The publishing step is handled by a shell command within the workflow:
cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public
This demonstrates that the system supports matrix builds, potentially allowing for simultaneous exports of different contract versions or types (e.g., full contracts vs. interfaces only).
Sources: README.md:116
Summary
The TypeChain & Exports feature in Canon Guard bridges the gap between Solidity development and TypeScript application integration. By leveraging automated GitHub Actions and the solidity-exporter-action, the project ensures that any changes to the core multisig architecture or action builders are reflected in the distributed TypeScript types. This minimizes manual overhead and reduces the risk of type mismatches when building tools around the Canon Guard ecosystem.