File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed
.github/actions/generate-evm-artifacts Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 2727 - name : Build Foundry
2828 shell : bash
2929 run : forge build --skip test script
30+ - name : Generate Typechain artifacts
31+ shell : bash
32+ run : npx ts-node scripts/typechainArtifacts.ts
3033 - name : Generate Typechain
3134 shell : bash
32- run : npx typechain --target ethers-v5 "out/!(build-info)/**/+([a-zA-Z0-9_]).json " --out-dir typechain
35+ run : npx typechain --target ethers-v5 "typechain-artifacts " --out-dir typechain
3336 - name : Archive EVM artifacts (for caching)
3437 shell : bash
3538 env :
Original file line number Diff line number Diff line change 3131zkout
3232cache-foundry
3333
34+ # Typechain
35+ .typechain-artifacts
36+
3437# Upgradeability files
3538.openzeppelin
3639
Original file line number Diff line number Diff line change 1+ import fs from "fs" ;
2+ import path from "path" ;
3+ import fg from "fast-glob" ;
4+
5+ type ArtifactJson = {
6+ contractName ?: string ;
7+ [ key : string ] : unknown ;
8+ } ;
9+
10+ const OUT_DIR = "out" ;
11+ const STAGE_DIR = ".typechain-artifacts" ;
12+
13+ function main ( ) {
14+ if ( fs . existsSync ( STAGE_DIR ) ) {
15+ fs . rmdirSync ( STAGE_DIR , { recursive : true } ) ;
16+ }
17+ fs . mkdirSync ( STAGE_DIR , { recursive : true } ) ;
18+
19+ const files = fg . sync ( [ `${ OUT_DIR } /**/*.json` , `!${ OUT_DIR } /build-info/**` ] , {
20+ dot : false ,
21+ onlyFiles : true ,
22+ } ) ;
23+
24+ const seen = new Map < string , string > ( ) ; // contractName -> first file path kept
25+ const dups : Array < { name : string ; kept : string ; dropped : string } > = [ ] ;
26+
27+ for ( const file of files ) {
28+ const name = file . split ( "/" ) . pop ( ) ?. split ( "." ) [ 0 ] ;
29+ if ( ! name ) continue ;
30+
31+ const already = seen . get ( name ) ;
32+ if ( already ) {
33+ dups . push ( { name, kept : already , dropped : file } ) ;
34+ continue ;
35+ }
36+
37+ seen . set ( name , file ) ;
38+
39+ // One artifact per name => stable TypeChain inputs
40+ const dest = path . join ( STAGE_DIR , `${ name } .json` ) ;
41+ fs . copyFileSync ( file , dest ) ;
42+ }
43+
44+ if ( dups . length > 0 ) {
45+ console . warn ( `\nTypeChain dedupe: dropped ${ dups . length } duplicate contract names:\n` ) ;
46+ }
47+
48+ console . log ( `Staged ${ seen . size } unique artifacts into ${ STAGE_DIR } /` ) ;
49+ }
50+
51+ main ( ) ;
You can’t perform that action at this time.
0 commit comments