Skip to content

Commit

Permalink
Merge pull request #28 from gnosis/add_cronos
Browse files Browse the repository at this point in the history
Closes #25: Add cronos network
  • Loading branch information
rmeissner authored Apr 26, 2022
2 parents a0c8b62 + 891cf42 commit ade6a48
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MNEMONIC=""
MNEMONIC=""
RPC=""
7 changes: 7 additions & 0 deletions artifacts/25/deployment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"gasPrice": 10000000000000,
"gasLimit": 100000,
"signerAddress": "0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37",
"transaction": "0xf8a6808609184e72a000830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf355a054b6bc11ebcdd492b5083f82e745b27cf9aabd3afedc969a1fe863219c1094a9a00cd431f6d8e76c58b4ae488c96f95df8c57850088dd362a268cf051b226de259",
"address": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7"
}
7 changes: 7 additions & 0 deletions artifacts/338/deployment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"gasPrice": 10000000000000,
"gasLimit": 100000,
"signerAddress": "0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37",
"transaction": "0xf8a8808609184e72a000830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf38202c8a0749cead18bfc5151c8414fab334577f8c56120de5cda871c2237c855962184b3a042f0b6ed04459c15e37381167292f965a93f63e399f99b3c4f0f504b5b934dbb",
"address": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"scripts": {
"compile": "ts-node scripts/compile.ts",
"estimate": "ts-node scripts/estimate.ts",
"build": "yarn rimraf dist && tsc",
"prepublish": "yarn build"
},
Expand Down
45 changes: 1 addition & 44 deletions scripts/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CompilerOutput, CompilerInput, compileStandardWrapper, CompilerOutputCo
import { ethers } from 'ethers'
import dotenv from "dotenv";
import yargs from 'yargs/yargs';
import { compileContracts } from './utils';

dotenv.config()

Expand All @@ -16,50 +17,6 @@ export async function ensureDirectoryExists(absoluteDirectoryPath: string) {
}
}

async function compileContracts(): Promise<CompilerOutput> {
const solidityFilePath = path.join(__dirname, '..', 'source', 'deterministic-deployment-proxy.yul')
const soliditySourceCode = await filesystem.readFile(solidityFilePath, 'utf8')
const compilerInput: CompilerInput = {
language: "Yul",
settings: {
optimizer: {
enabled: true,
details: {
yul: true,
},
},
outputSelection: {
"*": {
"*": [ "abi", "evm.bytecode.object", "evm.gasEstimates" ]
},
},
},
sources: {
'deterministic-deployment-proxy.yul': {
content: soliditySourceCode,
},
},
}
const compilerInputJson = JSON.stringify(compilerInput)
const compilerOutputJson = compileStandardWrapper(compilerInputJson)
const compilerOutput = JSON.parse(compilerOutputJson) as CompilerOutput
const errors = compilerOutput.errors
if (errors) {
let concatenatedErrors = "";

for (let error of errors) {
if (/Yul is still experimental/.test(error.message)) continue
concatenatedErrors += error.formattedMessage + "\n";
}

if (concatenatedErrors.length > 0) {
throw new Error("The following errors/warnings were returned by solc:\n\n" + concatenatedErrors);
}
}

return compilerOutput
}

async function writeBytecode(bytecode: string) {
const filePath = path.join(__dirname, '..', 'artifacts', `bytecode.txt`)
await filesystem.writeFile(filePath, bytecode, { encoding: 'utf8', flag: 'w' })
Expand Down
30 changes: 30 additions & 0 deletions scripts/estimate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { promises as filesystem } from 'fs'
import * as path from 'path'
import { CompilerOutput, CompilerInput, compileStandardWrapper, CompilerOutputContract } from 'solc'
import { ethers } from 'ethers'
import dotenv from "dotenv";
import yargs from 'yargs/yargs';
import { compileContracts } from './utils';

dotenv.config()

async function doStuff() {
const rpcUrl = process.env.RPC
const provider = new ethers.providers.JsonRpcProvider(rpcUrl)
const chainId = (await provider.getNetwork()).chainId
console.log({chainId})
const compilerOutput = await compileContracts()
const contract = compilerOutput.contracts['deterministic-deployment-proxy.yul']['Proxy']
const data = "0x" + contract.evm.bytecode.object
const estimate = await provider.estimateGas({ data })
console.log({estimate: estimate.toString() })
const gasPrice = await provider.getGasPrice()
console.log({gasPriceGwei: ethers.utils.formatUnits(gasPrice, "gwei"), gasPrice: gasPrice.toString() })
}

doStuff().then(() => {
process.exit(0)
}).catch(error => {
console.error(error)
process.exit(1)
})
47 changes: 47 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { promises as filesystem } from 'fs'
import * as path from 'path'
import { CompilerOutput, CompilerInput, compileStandardWrapper } from 'solc'

export async function compileContracts(): Promise<CompilerOutput> {
const solidityFilePath = path.join(__dirname, '..', 'source', 'deterministic-deployment-proxy.yul')
const soliditySourceCode = await filesystem.readFile(solidityFilePath, 'utf8')
const compilerInput: CompilerInput = {
language: "Yul",
settings: {
optimizer: {
enabled: true,
details: {
yul: true,
},
},
outputSelection: {
"*": {
"*": [ "abi", "evm.bytecode.object", "evm.gasEstimates" ]
},
},
},
sources: {
'deterministic-deployment-proxy.yul': {
content: soliditySourceCode,
},
},
}
const compilerInputJson = JSON.stringify(compilerInput)
const compilerOutputJson = compileStandardWrapper(compilerInputJson)
const compilerOutput = JSON.parse(compilerOutputJson) as CompilerOutput
const errors = compilerOutput.errors
if (errors) {
let concatenatedErrors = "";

for (let error of errors) {
if (/Yul is still experimental/.test(error.message)) continue
concatenatedErrors += error.formattedMessage + "\n";
}

if (concatenatedErrors.length > 0) {
throw new Error("The following errors/warnings were returned by solc:\n\n" + concatenatedErrors);
}
}

return compilerOutput
}

0 comments on commit ade6a48

Please sign in to comment.