-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC: run all contracts through solc with bazel
- Loading branch information
Showing
24 changed files
with
1,758 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
bazel-out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") | ||
|
||
########## | ||
# Protobuf | ||
|
@@ -91,3 +91,34 @@ go_rules_dependencies() | |
go_register_toolchains(version = "1.18") | ||
|
||
gazelle_dependencies() | ||
|
||
load("//sol:repositories.bzl", "LATEST_VERSION", "rules_sol_dependencies", "sol_register_toolchains") | ||
|
||
rules_sol_dependencies() | ||
|
||
sol_register_toolchains( | ||
name = "solc", | ||
sol_version = LATEST_VERSION, | ||
) | ||
|
||
# Fetch our contracts dependencies directly from git repos, like Forge does it: | ||
# https://book.getfoundry.sh/projects/dependencies | ||
new_git_repository( | ||
name = "openzeppelin-contracts", | ||
remote = "[email protected]:OpenZeppelin/openzeppelin-contracts.git", | ||
# NOTE: this version ought to match what appears in yarn.lock, or behavior | ||
# between Bazel and legacy npm-based dependency management will vary. | ||
commit = "8c49ad74eae76ee389d038780d407cf90b4ae1de", # v4.7.0 | ||
shallow_since = "1656493217 +0200", | ||
build_file = "openzeppelin-contracts.BUILD", | ||
) | ||
|
||
new_git_repository( | ||
name = "erc721a", | ||
remote = "[email protected]:chiru-labs/ERC721A.git", | ||
# NOTE: this version ought to match what appears in yarn.lock, or behavior | ||
# between Bazel and legacy npm-based dependency management will vary. | ||
commit = "9859cd2edb1a8b4c2db5e46031abbb3253e42467", # v4.2.2 | ||
shallow_since = "1659313679 -0700", | ||
build_file = "erc721a.BUILD", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "crypto", | ||
srcs = glob(["*.sol"]), | ||
deps = ["@openzeppelin-contracts"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "erc721", | ||
srcs = glob(["*.sol"]), | ||
deps = [ | ||
"//contracts/utils", | ||
"@erc721a", | ||
"@openzeppelin-contracts", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "factories", | ||
srcs = glob(["*.sol"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "random", | ||
srcs = glob(["*.sol"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "sales", | ||
srcs = glob(["*.sol"]), | ||
deps = [ | ||
"//contracts/utils", | ||
"@openzeppelin-contracts", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "opensea", | ||
srcs = glob(["*.sol"]), | ||
deps = [ | ||
"//contracts/utils", | ||
"@openzeppelin-contracts", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
load("//sol:defs.bzl", "sol_binary") | ||
|
||
sol_binary( | ||
name = "weth", | ||
srcs = glob(["*.sol"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("//sol:defs.bzl", "sol_sources") | ||
|
||
sol_sources( | ||
name = "utils", | ||
srcs = glob(["*.sol"]), | ||
visibility = ["//visibility:public"], | ||
deps = ["@openzeppelin-contracts"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@//sol:defs.bzl", "sol_sources") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
sol_sources( | ||
name = "erc721a", | ||
srcs = glob(["**/*.sol"]), | ||
remappings = {"erc721a/": "./external/erc721a/"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@//sol:defs.bzl", "sol_sources") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
sol_sources( | ||
name = "openzeppelin-contracts", | ||
srcs = glob(["**/*.sol"]), | ||
remappings = {"@openzeppelin/contracts/": "./external/openzeppelin-contracts/contracts/"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
# For stardoc to reference the files | ||
exports_files(["defs.bzl"]) | ||
|
||
# This is the target rule authors should put in their "toolchains" | ||
# attribute in order to get a runtime for the correct platform. | ||
# See https://docs.bazel.build/versions/main/toolchains.html#writing-rules-that-use-toolchains | ||
toolchain_type( | ||
name = "toolchain_type", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
bzl_library( | ||
name = "repositories", | ||
srcs = ["repositories.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//sol/private:toolchains_repo", | ||
"//sol/private:versions", | ||
"@bazel_tools//tools/build_defs/repo:http.bzl", | ||
"@bazel_tools//tools/build_defs/repo:utils.bzl", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "defs", | ||
srcs = ["defs.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//sol/private:sol_binary", | ||
"//sol/private:sol_sources", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "providers", | ||
srcs = ["providers.bzl"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
bzl_library( | ||
name = "toolchain", | ||
srcs = ["toolchain.bzl"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""# Bazel rules for Solidity | ||
See <https://docs.soliditylang.org> | ||
""" | ||
|
||
load("//sol/private:sol_binary.bzl", lib = "sol_binary") | ||
load("//sol/private:sol_sources.bzl", src = "sol_sources") | ||
load(":providers.bzl", "SolSourcesInfo") | ||
|
||
sol_binary = rule( | ||
implementation = lib.implementation, | ||
attrs = lib.attrs, | ||
doc = """sol_binary compiles Solidity source files with solc""", | ||
toolchains = lib.toolchains, | ||
) | ||
|
||
sol_sources = rule( | ||
implementation = src.implementation, | ||
attrs = src.attrs, | ||
doc = """Collect .sol source files to be imported as library code. | ||
Performs no actions, so semantically equivalent to filegroup(). | ||
""", | ||
provides = [SolSourcesInfo], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
bzl_library( | ||
name = "toolchains_repo", | ||
srcs = ["toolchains_repo.bzl"], | ||
visibility = ["//sol:__subpackages__"], | ||
) | ||
|
||
bzl_library( | ||
name = "versions", | ||
srcs = ["versions.bzl"], | ||
visibility = ["//sol:__subpackages__"], | ||
) | ||
|
||
bzl_library( | ||
name = "sol_binary", | ||
srcs = ["sol_binary.bzl"], | ||
visibility = ["//sol:__subpackages__"], | ||
deps = [ | ||
"//sol:providers", | ||
"@aspect_rules_js//js:libs", | ||
"@aspect_rules_js//js:providers", | ||
"@bazel_skylib//lib:paths", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "sol_sources", | ||
srcs = ["sol_sources.bzl"], | ||
visibility = ["//sol:__subpackages__"], | ||
deps = [ | ||
"//sol:providers", | ||
"@aspect_rules_js//js:libs", | ||
"@aspect_rules_js//js:providers", | ||
], | ||
) |
Oops, something went wrong.