Skip to content

Commit bef44f7

Browse files
authored
feat(Project): add deploy and release project mgmt scripts (#10)
1 parent 953c83d commit bef44f7

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ ruffsack = ["manifests/*.json"]
3131
name = "solidity"
3232
[[tool.ape.plugins]]
3333
name = "vyper"
34+
35+
[[tool.ape.deployments.ethereum.local]]
36+
address = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
37+
contract_type = "RuffsackFactory"
38+
[[tool.ape.deployments.ethereum.local]]
39+
address = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
40+
contract_type = "Ruffsack"

scripts/deploy.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import click
2+
from ape import project
3+
from ape.cli import ConnectedProviderCommand, account_option
4+
from ruffsack.packages import MANIFESTS
5+
6+
7+
@click.group()
8+
def cli():
9+
"""Deploy the Ruffsack system contracts"""
10+
11+
12+
@cli.command(cls=ConnectedProviderCommand)
13+
@account_option()
14+
@click.argument("governance", default=None, required=False)
15+
def factory(account, governance):
16+
"""Deploy Proxy Factory to the specified network"""
17+
18+
proxy_initcode = project.RuffsackProxy.contract_type.get_deployment_bytecode()
19+
account.deploy(project.RuffsackFactory, governance or account, proxy_initcode)
20+
# TODO: Adapt to use https://ercs.ethereum.org/ERCS/erc-7955?
21+
22+
23+
@cli.command(cls=ConnectedProviderCommand)
24+
@click.option(
25+
"--version",
26+
default=str(max(MANIFESTS)),
27+
help="Version to use when deploying the contract. Defaults to latest in SDK.",
28+
)
29+
@account_option()
30+
def singleton(version, account):
31+
"""Deploy the given version of singleton contract"""
32+
33+
account.deploy(project.Ruffsack, version)

scripts/release.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import click
2+
from ape import project
3+
from ape.cli import ConnectedProviderCommand, account_option
4+
from ape.utils import ZERO_ADDRESS
5+
6+
7+
@click.command(cls=ConnectedProviderCommand)
8+
@account_option()
9+
def cli(account):
10+
"""Create a new release in the Factory"""
11+
12+
if len(project.Ruffsack.deployments) == 0:
13+
raise click.UsageError("Cannot autodetect last release of Singleton")
14+
15+
release = project.Ruffsack.deployments[-1]
16+
17+
if len(project.RuffsackFactory.deployments) == 0:
18+
raise click.UsageError("Cannot autodetect Factory to link Singleton")
19+
20+
elif (factory := project.RuffsackFactory.deployments[-1]).governance() != account:
21+
raise click.UsageError(
22+
"Cannot link Singleton without governance account access"
23+
)
24+
25+
elif factory.releases(release.VERSION()) != ZERO_ADDRESS:
26+
raise click.UsageError("Release process will fail. Release already set.")
27+
28+
if click.confirm(f"Set 'v{release.VERSION()}' to {release.address}?"):
29+
factory.add_release(release, sender=account)

0 commit comments

Comments
 (0)