@@ -17,7 +17,8 @@ const ROOT = join(__dirname, "..");
1717const ARTIFACTS = join ( ROOT , "artifacts" , "solidity" , "precompiles" ) ;
1818const SOLIDITY_SOURCE = join ( ROOT , "solidity" ) ;
1919const DIST = join ( ROOT , "dist" ) ;
20- const DIST_ABI = join ( DIST , "abi" ) ;
20+ const OUT_PRECOMPILES = join ( DIST , "precompiles" ) ;
21+ const OUT_ABI = join ( DIST , "abi" ) ;
2122
2223const EXCLUDED_DIRS = [ "testdata" , "testutil" ] ;
2324
@@ -66,7 +67,8 @@ function buildPrecompiles() {
6667 process . exit ( 1 ) ;
6768 }
6869
69- ensureDir ( DIST_ABI ) ;
70+ ensureDir ( OUT_PRECOMPILES ) ;
71+ ensureDir ( OUT_ABI ) ;
7072
7173 const copiedSol = new Set ( ) ;
7274 let count = 0 ;
@@ -81,8 +83,8 @@ function buildPrecompiles() {
8183
8284 const relFromSolidity = sourceName . replace ( / ^ s o l i d i t y \/ / , "" ) ; // precompiles/bank/IBank.sol
8385 const solPath = join ( SOLIDITY_SOURCE , relFromSolidity ) ;
84- const abiOutPath = join ( DIST_ABI , relFromSolidity . replace ( ".sol" , ".json" ) ) ;
85- const solOutPath = join ( DIST , relFromSolidity ) ;
86+ const abiOutPath = join ( OUT_ABI , relFromSolidity . replace ( ".sol" , ".json" ) ) ;
87+ const solOutPath = join ( OUT_PRECOMPILES , relFromSolidity . replace ( / ^ p r e c o m p i l e s \/ / , "" ) ) ;
8688
8789 ensureDir ( dirname ( abiOutPath ) ) ;
8890 ensureDir ( dirname ( solOutPath ) ) ;
@@ -102,14 +104,30 @@ function buildPrecompiles() {
102104 const relFromSolidity = join ( "precompiles" , rel ) ;
103105 if ( copiedSol . has ( relFromSolidity ) ) continue ;
104106 const solPath = join ( SOLIDITY_SOURCE , relFromSolidity ) ;
105- const solOutPath = join ( DIST , relFromSolidity ) ;
107+ const solOutPath = join ( OUT_PRECOMPILES , rel ) ;
106108 ensureDir ( dirname ( solOutPath ) ) ;
107109 cpSync ( solPath , solOutPath ) ;
108110 count ++ ;
109111 console . log ( " " , relFromSolidity , "(no ABI)" ) ;
110112 }
111113
112- console . log ( "\nDone. Built" , count , "precompile file(s) to dist/ (OpenZeppelin style)." ) ;
114+ // Copy README and create package.json for publishing from dist/
115+ cpSync ( join ( ROOT , "README.md" ) , join ( DIST , "README.md" ) ) ;
116+ const rootPkg = JSON . parse ( readFileSync ( join ( ROOT , "package.json" ) , "utf8" ) ) ;
117+ const distPkg = {
118+ name : rootPkg . name ,
119+ version : rootPkg . version ,
120+ description : rootPkg . description ,
121+ repository : rootPkg . repository ,
122+ author : rootPkg . author ,
123+ license : rootPkg . license ,
124+ bugs : rootPkg . bugs ,
125+ homepage : rootPkg . homepage ,
126+ files : [ "precompiles" , "abi" , "README.md" ] ,
127+ } ;
128+ writeFileSync ( join ( DIST , "package.json" ) , JSON . stringify ( distPkg , null , 2 ) , "utf8" ) ;
129+
130+ console . log ( "\nDone. Built" , count , "precompile file(s) to dist/ (ready to publish from dist/)." ) ;
113131}
114132
115133buildPrecompiles ( ) ;
0 commit comments