Skip to content

Commit c6d902e

Browse files
authored
add native solc option (#242)
1 parent 6ecf273 commit c6d902e

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

packages/ovm-toolchain/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"@eth-optimism/solc-transpiler": "^0.0.1-alpha.28",
7272
"@nomiclabs/buidler": "^1.4.4",
7373
"bn.js": "^5.1.3",
74+
"child_process": "^1.0.2",
7475
"ethereum-waffle-v2": "npm:ethereum-waffle@2",
7576
"ethereum-waffle-v3": "npm:ethereum-waffle@3",
7677
"ethereumjs-ovm": "git+https://github.com/ethereum-optimism/ethereumjs-vm",

packages/ovm-toolchain/src/buidler-plugins/buidler-ovm-compiler.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { internalTask } from '@nomiclabs/buidler/config'
44
import { SolcInput } from '@nomiclabs/buidler/types'
55
import { Compiler } from '@nomiclabs/buidler/internal/solidity/compiler'
66
import { TASK_COMPILE_RUN_COMPILER } from '@nomiclabs/buidler/builtin-tasks/task-names'
7+
import { execSync } from 'child_process'
78

89
internalTask(TASK_COMPILE_RUN_COMPILER).setAction(
910
async ({ input }: { input: SolcInput }, { config }) => {
@@ -22,7 +23,14 @@ internalTask(TASK_COMPILE_RUN_COMPILER).setAction(
2223
return customCompiler
2324
}
2425
}
25-
26-
return compiler.compile(input)
26+
if ((config as any).solc.native === true) {
27+
console.log(`Using native solidity compiler`)
28+
const output = execSync(`solc --standard-json`, {
29+
input: JSON.stringify(input, undefined, 2),
30+
})
31+
return JSON.parse(output.toString('utf8'))
32+
} else {
33+
return compiler.compile(input)
34+
}
2735
}
2836
)

yarn.lock

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,6 @@
3939
resolved "https://registry.yarnpkg.com/@ensdomains/resolver/-/resolver-0.2.4.tgz#c10fe28bf5efbf49bff4666d909aed0265efbc89"
4040
integrity sha512-bvaTH34PMCbv6anRa9I/0zjLJgY4EuznbEMgbV77JBCQ9KNC46rzi0avuxpOfu+xDjPEtSFGqVEOr5GlUSGudA==
4141

42-
"@eth-optimism/core-db@^0.0.1-alpha.27":
43-
version "0.0.1-alpha.27"
44-
resolved "https://registry.yarnpkg.com/@eth-optimism/core-db/-/core-db-0.0.1-alpha.27.tgz#c1b5bab856d5bca44d26de9685e2fa9f1b48b579"
45-
integrity sha512-kKkGvss/w7q57NTTFWbY1B3VKI0soClBHDvcP1t5CJrNw7ggkSrlgEbx+LsriTd/vn+fL5iUgwCIcUJn711A0Q==
46-
dependencies:
47-
"@eth-optimism/core-utils" "^0.0.1-alpha.27"
48-
abstract-leveldown "^6.2.2"
49-
async-lock "^1.2.2"
50-
chai "^4.2.0"
51-
chai-as-promised "^7.1.1"
52-
debug "^4.1.1"
53-
ethers "^4.0.39"
54-
level "^6.0.0"
55-
memdown "^4.0.0"
56-
57-
"@eth-optimism/core-utils@^0.0.1-alpha.27":
58-
version "0.0.1-alpha.27"
59-
resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.0.1-alpha.27.tgz#b43c8b5cd8ee89de7294c5f93aef5c47ee846cf5"
60-
integrity sha512-OLQONkCevn6xaAyFlxOrL5BkE8BycvicBk0+RDL13g4OXSl/WkLaAjzUJcxYsGDzDUaB7yPUcwLQwUaT6xmcww==
61-
dependencies:
62-
abstract-leveldown "^6.2.2"
63-
async-lock "^1.2.2"
64-
axios "^0.19.0"
65-
bn.js "^4.11.8"
66-
body-parser "^1.19.0"
67-
chai "^4.2.0"
68-
chai-as-promised "^7.1.1"
69-
debug "^4.1.1"
70-
dotenv "^8.2.0"
71-
ethereumjs-util "^6.2.0"
72-
ethers "^4.0.37"
73-
express "^4.17.1"
74-
memdown "^4.0.0"
75-
ts-md5 "^1.2.4"
76-
uuid "^3.3.3"
77-
7842
"@eth-optimism/rollup-core@^0.0.1-alpha.28":
7943
version "0.0.1-alpha.28"
8044
resolved "https://registry.yarnpkg.com/@eth-optimism/rollup-core/-/rollup-core-0.0.1-alpha.28.tgz#845de41ed266e0f1fd738776cb68bfe1fa391104"
@@ -3640,6 +3604,11 @@ checkpoint-store@^1.1.0:
36403604
dependencies:
36413605
functional-red-black-tree "^1.0.1"
36423606

3607+
child_process@^1.0.2:
3608+
version "1.0.2"
3609+
resolved "https://registry.yarnpkg.com/child_process/-/child_process-1.0.2.tgz#b1f7e7fc73d25e7fd1d455adc94e143830182b5a"
3610+
integrity sha1-sffn/HPSXn/R1FWtyU4UODAYK1o=
3611+
36433612
36443613
version "3.3.0"
36453614
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6"

0 commit comments

Comments
 (0)