Skip to content

Commit e348aee

Browse files
committed
v0.2
1 parent 347c938 commit e348aee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3314
-736
lines changed
0 Bytes
Binary file not shown.

scripts/build-cairo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ mkdir -p cairo_contracts
55

66
scripts/starknet-compile.py src --contract-path src::permissioned_erc20::PermissionedERC20 cairo_contracts/PermissionedERC20.sierra
77
scripts/starknet-compile.py src --contract-path src::token_bridge::TokenBridge cairo_contracts/TokenBridge.sierra
8+
scripts/starknet-compile.py src --contract-path openzeppelin::token::erc20::erc20::ERC20 cairo_contracts/ERC20.sierra
9+
scripts/starknet-compile.py src --contract-path openzeppelin::token::erc20::presets::erc20votes::ERC20VotesPreset cairo_contracts/ERC20VotesPreset.sierra
810

911
popd

scripts/build-solidity.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pushd $(dirname $0)/..
33

44
mkdir -p artifacts
55

6-
.downloads/solc-0.8.20 $(cat src/solidity/files_to_compile.txt) --allow-paths .=., --overwrite --combined-json abi,bin -o artifacts
6+
.downloads/solc-0.8.20 $(cat src/solidity/files_to_compile.txt) --allow-paths .=., --optimize --optimize-runs 200 --overwrite --combined-json abi,bin -o artifacts
77
scripts/extract_artifacts.py
88

99
popd

scripts/cairo-format.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "cairo-format")
10-
EXPECTED_EXECUTABLE_VERSION = "cairo-format 2.0.0-rc5"
10+
EXPECTED_EXECUTABLE_VERSION = "cairo-format 2.2.0"
1111

1212

1313
def main():
@@ -22,9 +22,10 @@ def main():
2222
print("Setup Error! Run : 'sh ./scripts/setup.sh' to solve this problem.")
2323
sys.exit(1)
2424

25-
assert (
26-
executable_version == EXPECTED_EXECUTABLE_VERSION
27-
), f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}. Run : 'sh ./scripts/setup.sh' to solve this problem."
25+
assert executable_version == EXPECTED_EXECUTABLE_VERSION, (
26+
f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}."
27+
"Run : 'sh ./scripts/setup.sh' to solve this problem."
28+
)
2829

2930
try:
3031
subprocess.check_call([EXECUTABLE, *args])

scripts/cairo-test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "cairo-test")
10-
EXPECTED_EXECUTABLE_VERSION = "cairo-test 2.0.0-rc5"
10+
EXPECTED_EXECUTABLE_VERSION = "cairo-test 2.2.0"
1111

1212

1313
def main():
@@ -22,9 +22,10 @@ def main():
2222
print("Setup Error! Run : 'sh ./scripts/setup.sh' to solve this problem.")
2323
sys.exit(1)
2424

25-
assert (
26-
executable_version == EXPECTED_EXECUTABLE_VERSION
27-
), f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}. Run : 'sh ./scripts/setup.sh' to solve this problem."
25+
assert executable_version == EXPECTED_EXECUTABLE_VERSION, (
26+
f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}."
27+
"Run : 'sh ./scripts/setup.sh' to solve this problem."
28+
)
2829

2930
try:
3031
subprocess.check_call([EXECUTABLE, *args])

scripts/line_length.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3.9
2+
3+
import argparse
4+
import sys
5+
from script_utils import changed_files, color_txt, git_files
6+
7+
8+
def main():
9+
parser = argparse.ArgumentParser(description="Check that all code lines are not too long.")
10+
parser.add_argument(
11+
"--max_line_length",
12+
"-l",
13+
type=int,
14+
default=100,
15+
help="The maximal amount of characters a line can have (default: 100)",
16+
)
17+
parser.add_argument("--files", nargs="+", help="Run on specified files. Ignore other flags.")
18+
parser.add_argument("--changes_only", action="store_true", help="Run only on changed files.")
19+
parser.add_argument("--quiet", "-q", dest="verbose", action="store_false")
20+
21+
args = parser.parse_args()
22+
23+
extensions = ["py", "cairo"]
24+
if args.files:
25+
files = [path for path in args.files if path.endswith(tuple(extensions))]
26+
elif args.changes_only:
27+
files = changed_files(extensions)
28+
else:
29+
files = git_files(extensions)
30+
31+
if args.verbose:
32+
print(color_txt("yellow", "=== checking the following files: ===\n" + "\n".join(files)))
33+
sys.stdout.flush()
34+
35+
long_lines = []
36+
for f in files:
37+
for line_num, line in enumerate(open(f), 1):
38+
line = line.rstrip("\n")
39+
if line.startswith("from") or line.startswith("import"):
40+
continue
41+
if len(line) > args.max_line_length:
42+
long_lines.append((f, line_num))
43+
44+
if len(long_lines) > 0:
45+
print(color_txt("red", "The following lines are too long:"))
46+
for file_name, line_num in long_lines:
47+
print(f"{file_name}:{line_num}")
48+
sys.exit(1)
49+
50+
if args.verbose:
51+
print(color_txt("green", "=== Line length check completed successfully ==="))
52+
53+
54+
if __name__ == "__main__":
55+
main()

scripts/script_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def color_print(
8080
print(f"\033[{bold}{additional}{bg}{color}m{message}\033[m", file=file)
8181

8282

83+
def get_parent_branch():
84+
return open(os.path.join(os.path.dirname(__file__), "parent_branch.txt")).read().strip()
85+
86+
8387
def create_grep_pipe_command(extensions):
8488
if extensions is None:
8589
return ""
@@ -90,6 +94,14 @@ def git_files(extensions=None) -> List[str]:
9094
return get_files("git ls-tree -r --name-only HEAD", extensions)
9195

9296

97+
def changed_files(extensions=None, with_excluded_files=False) -> List[str]:
98+
return get_files(
99+
f"git diff --name-only $(git merge-base origin/{get_parent_branch()} HEAD)",
100+
extensions=extensions,
101+
with_excluded_files=with_excluded_files,
102+
)
103+
104+
93105
def get_files(git_cmd: str, extensions, with_excluded_files=False, cwd=None) -> List[str]:
94106
if cwd is None:
95107
cwd = os.getcwd()

scripts/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ printf "${COLOR_OFF}"
3030
mkdir -p .downloads
3131
cd .downloads
3232

33-
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.0.0-rc5/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz
33+
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.2.0/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz
3434
curl https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.8.20+commit.a1b79de6 -o solc-0.8.20 && chmod +x solc-0.8.20
3535

3636
cd ..

scripts/starknet-compile.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "starknet-compile")
10-
EXPECTED_EXECUTABLE_VERSION = "starknet-compile 2.0.0-rc5"
10+
EXPECTED_EXECUTABLE_VERSION = "starknet-compile 2.2.0"
1111

1212

1313
def main():
@@ -22,9 +22,10 @@ def main():
2222
print("Setup Error! Run : 'sh ./scripts/setup.sh' to solve this problem.")
2323
sys.exit(1)
2424

25-
assert (
26-
executable_version == EXPECTED_EXECUTABLE_VERSION
27-
), f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}. Run : 'sh ./scripts/setup.sh' to solve this problem."
25+
assert executable_version == EXPECTED_EXECUTABLE_VERSION, (
26+
f"Wrong version got: {executable_version}, Expected: {EXPECTED_EXECUTABLE_VERSION}."
27+
"Run : 'sh ./scripts/setup.sh' to solve this problem."
28+
)
2829

2930
try:
3031
subprocess.check_call([EXECUTABLE, *args])

scripts/tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ else
1717
exit 1
1818
fi
1919

20+
21+
printf "${YELLOW}Check Line Length...\n"
22+
scripts/line_length.py -l 110
23+
if [ $? -ne 0 ]; then
24+
exit 1
25+
fi
26+
27+
2028
printf "${YELLOW}Run black...\n"
2129
black -l 100 --diff --check --color --diff .
2230
if [ $? -eq 0 ]; then

0 commit comments

Comments
 (0)