Skip to content

Commit ec1cbf1

Browse files
committed
refactor: remove dependencies key and add Safe builds directly to repo
1 parent cf06b2d commit ec1cbf1

8 files changed

Lines changed: 100 additions & 85 deletions

File tree

.github/workflows/test.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ jobs:
7979
with:
8080
python-version: ${{ matrix.python-version }}
8181

82-
- name: Build and Install Contract Dependencies
83-
run: |
84-
ape pm compile
85-
ape run build
86-
8782
- name: Install Package
8883
run: |
8984
python -m pip install --upgrade pip

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Ape stuff
22
.build/
3-
ape_safe/manifests/safe-v*.json
43

54
# NPM Stuff
65
node_modules/

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ python setup.py install
1818
pip install -e .'[dev]'
1919
```
2020

21+
If you need to add support for a new Safe version to the package,
22+
edit the `scripts/build.py` file to add the version to build, then run:
23+
24+
```sh
25+
$ ape run build
26+
```
27+
28+
This will compile the new dependency and install it under `ape_safe/mainfests/`.
29+
Be sure to add the new manifest to a PR and submit it, alongside updates to `tests/conftest.py`
30+
2131
## Pre-Commit Hooks
2232

2333
We use [`pre-commit`](https://pre-commit.com/) hooks to simplify linting and ensure consistent formatting among contributors.

ape-config.yaml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,3 @@ plugins:
99
ethereum:
1010
local:
1111
default_provider: foundry
12-
13-
# NOTE: Build before release w/ `ape pm compile`
14-
dependencies:
15-
- name: safe-contracts
16-
github: safe-global/safe-smart-account
17-
version: v1.1.1
18-
config_override:
19-
compile:
20-
exclude:
21-
- mocks
22-
- interfaces
23-
24-
dependencies:
25-
- name: openzeppelin
26-
github: OpenZeppelin/openzeppelin-contracts
27-
version: 2.2.0
28-
29-
solidity:
30-
version: 0.5.14
31-
import_remapping:
32-
- "@openzeppelin/contracts=openzeppelin/v2.2.0"
33-
34-
- name: safe-contracts
35-
github: safe-global/safe-smart-account
36-
version: v1.3.0
37-
config_override:
38-
compile:
39-
exclude:
40-
- test
41-
- examples
42-
- interfaces
43-
44-
dependencies:
45-
- name: openzeppelin
46-
github: OpenZeppelin/openzeppelin-contracts
47-
version: 3.4.0
48-
49-
solidity:
50-
version: 0.7.6
51-
import_remapping:
52-
- "@openzeppelin/contracts=openzeppelin/v3.4.0"
53-
54-
- name: safe-contracts
55-
github: safe-global/safe-smart-account
56-
version: v1.4.1
57-
config_override:
58-
compile:
59-
exclude:
60-
- test
61-
- examples
62-
- interfaces
63-
64-
dependencies:
65-
- name: openzeppelin
66-
github: OpenZeppelin/openzeppelin-contracts
67-
version: 3.4.0
68-
69-
solidity:
70-
version: 0.7.6
71-
import_remapping:
72-
- "@openzeppelin/contracts=openzeppelin/v3.4.0"

ape_safe/manifests/safe-v1.1.1.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

ape_safe/manifests/safe-v1.3.0.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

ape_safe/manifests/safe-v1.4.1.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

scripts/build.py

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,97 @@
1-
import shutil
21
from pathlib import Path
32

43
import click
4+
import yaml
55
from ape import project
66

77
PLUGIN_MANIFEST_FOLDER = project.path / "ape_safe" / "manifests"
88

9+
VERSIONS = {
10+
"v1.1.1": """
11+
compile:
12+
exclude:
13+
- mocks
14+
- interfaces
15+
16+
dependencies:
17+
- name: openzeppelin
18+
github: OpenZeppelin/openzeppelin-contracts
19+
version: 2.2.0
20+
21+
solidity:
22+
version: 0.5.14
23+
import_remapping:
24+
- "@openzeppelin/contracts=openzeppelin/v2.2.0"
25+
""",
26+
"v1.3.0": """
27+
compile:
28+
exclude:
29+
- test
30+
- examples
31+
- interfaces
32+
33+
dependencies:
34+
- name: openzeppelin
35+
github: OpenZeppelin/openzeppelin-contracts
36+
version: 3.4.0
37+
38+
solidity:
39+
version: 0.7.6
40+
import_remapping:
41+
- "@openzeppelin/contracts=openzeppelin/v3.4.0"
42+
""",
43+
"v1.4.1": """
44+
compile:
45+
exclude:
46+
- test
47+
- examples
48+
- interfaces
49+
50+
dependencies:
51+
- name: openzeppelin
52+
github: OpenZeppelin/openzeppelin-contracts
53+
version: 3.4.0
54+
55+
solidity:
56+
version: 0.7.6
57+
import_remapping:
58+
- "@openzeppelin/contracts=openzeppelin/v3.4.0"
59+
""",
60+
}
61+
62+
63+
def compile_version(version: str, override: bool):
64+
dependency = project.dependencies.install(
65+
name="safe-contracts",
66+
github="safe-global/safe-smart-account",
67+
version=version,
68+
config_override=yaml.safe_load(VERSIONS[version]),
69+
)
70+
plugin_manifest_path = PLUGIN_MANIFEST_FOLDER / f"safe-{version}.json"
71+
if not override and (plugin_manifest_path).is_file():
72+
click.echo(f"Version '{version}' already exists, skipping.'")
73+
return
74+
75+
if not dependency.compiled:
76+
click.echo(f"Safe {version} not compiled, compiling...")
77+
dependency.compile()
78+
79+
click.echo(
80+
f"cp $HOME/{dependency.manifest_path.relative_to(Path.home())}"
81+
f" ./{plugin_manifest_path.relative_to(Path.cwd())}"
82+
)
83+
plugin_manifest_path.write_text(dependency.manifest_path.read_text())
84+
985

1086
@click.command()
1187
@click.option("--override", is_flag=True)
12-
def cli(override):
13-
for version in project.dependencies["safe-contracts"]:
14-
dependency = project.dependencies["safe-contracts"][version]
15-
plugin_manifest_path = PLUGIN_MANIFEST_FOLDER / f"safe-{version}.json"
16-
17-
if plugin_manifest_path.is_file() and not override:
18-
click.echo(f"Version '{version}' already exists, skipping.'")
19-
continue
20-
21-
# OK to delete - either doesn't exist or override set.
22-
plugin_manifest_path.unlink(missing_ok=True)
23-
24-
click.echo(
25-
f"cp $HOME/{dependency.manifest_path.relative_to(Path.home())}"
26-
f" ./{plugin_manifest_path.relative_to(Path.cwd())}"
27-
)
28-
shutil.copyfile(dependency.manifest_path, plugin_manifest_path)
88+
@click.argument(
89+
"versions",
90+
nargs=-1,
91+
type=click.Choice(list(VERSIONS)),
92+
)
93+
def cli(override, versions):
94+
"""Build manifests for Safe protocol"""
95+
96+
for version in iter(versions or VERSIONS):
97+
compile_version(version, override)

0 commit comments

Comments
 (0)