11import { promises as filesystem } from 'fs'
22import * as path from 'path'
3- import { AbiFunction , AbiEvent } from 'ethereum'
43import { CompilerOutput , CompilerInput , compileStandardWrapper , CompilerOutputContract } from 'solc'
54import { rlpEncode } from '@zoltu/rlp-encoder'
65import { keccak256 } from 'js-sha3'
@@ -18,34 +17,35 @@ export async function ensureDirectoryExists(absoluteDirectoryPath: string) {
1817
1918async function doStuff ( ) {
2019 const compilerOutput = await compileContracts ( )
21- const contract = compilerOutput . contracts [ 'deterministic-deployment-proxy.sol ' ] [ 'DeterministicDeploymentProxy ' ]
20+ const contract = compilerOutput . contracts [ 'deterministic-deployment-proxy.yul ' ] [ 'Proxy ' ]
2221 await ensureDirectoryExists ( path . join ( __dirname , '..' , '/output/' ) )
23- await writeAbiJson ( contract . abi )
2422 await writeBytecode ( contract . evm . bytecode . object )
2523 await writeFactoryDeployerTransaction ( contract )
2624}
2725
2826async function compileContracts ( ) : Promise < CompilerOutput > {
29- const solidityFilePath = path . join ( __dirname , '..' , 'source' , 'deterministic-deployment-proxy.sol ' )
27+ const solidityFilePath = path . join ( __dirname , '..' , 'source' , 'deterministic-deployment-proxy.yul ' )
3028 const soliditySourceCode = await filesystem . readFile ( solidityFilePath , 'utf8' )
3129 const compilerInput : CompilerInput = {
32- language : "Solidity " ,
30+ language : "Yul " ,
3331 settings : {
3432 optimizer : {
3533 enabled : true ,
36- runs : 500
34+ details : {
35+ yul : true ,
36+ } ,
3737 } ,
3838 outputSelection : {
3939 "*" : {
4040 "*" : [ "abi" , "evm.bytecode.object" , "evm.gasEstimates" ]
41- }
42- }
41+ } ,
42+ } ,
4343 } ,
4444 sources : {
45- 'deterministic-deployment-proxy.sol ' : {
46- content : soliditySourceCode
47- }
48- }
45+ 'deterministic-deployment-proxy.yul ' : {
46+ content : soliditySourceCode ,
47+ } ,
48+ } ,
4949 }
5050 const compilerInputJson = JSON . stringify ( compilerInput )
5151 const compilerOutputJson = compileStandardWrapper ( compilerInputJson )
@@ -55,6 +55,7 @@ async function compileContracts(): Promise<CompilerOutput> {
5555 let concatenatedErrors = "" ;
5656
5757 for ( let error of errors ) {
58+ if ( / Y u l i s s t i l l e x p e r i m e n t a l / . test ( error . message ) ) continue
5859 concatenatedErrors += error . formattedMessage + "\n" ;
5960 }
6061
@@ -66,20 +67,13 @@ async function compileContracts(): Promise<CompilerOutput> {
6667 return compilerOutput
6768}
6869
69- async function writeAbiJson ( abi : ( AbiFunction | AbiEvent ) [ ] ) {
70- const filePath = path . join ( __dirname , '../output/abi.json' )
71- const fileContents = JSON . stringify ( abi , undefined , '\t' )
72- return await filesystem . writeFile ( filePath , fileContents , { encoding : 'utf8' , flag : 'w' } )
73- }
74-
7570async function writeBytecode ( bytecode : string ) {
7671 const filePath = path . join ( __dirname , '..' , 'output' , `bytecode.txt` )
7772 await filesystem . writeFile ( filePath , bytecode , { encoding : 'utf8' , flag : 'w' } )
7873}
7974
8075async function writeFactoryDeployerTransaction ( contract : CompilerOutputContract ) {
81- // https://github.com/ethereum/solidity/issues/6724 2x seems to be enough for this case... :this-is-fine:
82- const deploymentGas = Number . parseInt ( contract . evm . gasEstimates ! . creation . totalCost ) * 2
76+ const deploymentGas = 100000 // actual gas costs last measure: 59159; we don't want to run too close though because gas costs can change in forks and we want our address to be retained
8377 const deploymentBytecode = contract . evm . bytecode . object
8478
8579 const nonce = new Uint8Array ( 0 )
0 commit comments