-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
162 lines (134 loc) · 7.18 KB
/
Copy pathjustfile
File metadata and controls
162 lines (134 loc) · 7.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Show commands before running (helps debug failures)
set shell := ["bash", "-euo", "pipefail", "-c"]
# Default recipe
default:
@just --list
# Install/update git submodule dependencies
deps:
git submodule update --init --recursive
# Install test tooling (solhint, etc.)
tooling:
bun install
# Clean build artifacts
clean:
forge clean
# Build contracts
build *args:
forge build {{ args }}
# Format contracts
fmt *args:
forge fmt {{ args }}
# Check contract formatting
fmt-check:
forge fmt --check
# Lint contracts (solhint)
lint:
bunx --bun solhint --config .solhint.json 'src/**/*.sol'
bunx --bun solhint --config .solhint.other.json 'test/**/*.sol'
bunx --bun solhint --config .solhint.other.json 'script/**/*.sol'
# Static analysis with slither
static-analysis:
slither .
# Run contract tests
test *args:
forge test --force {{ args }}
# Generate a coverage report, excluding the `test/` dir. Append args, e.g. `just coverage --report lcov`.
coverage *args:
@echo "==> Building..."
@just build
forge coverage --no-match-coverage "(test)" {{ args }}
# Prerequisites check (mirrors CI)
check:
@echo "==> Checking formatting..."
@just fmt-check
@echo "==> Linting..."
@just lint
@echo "==> Static analysis with slither..."
@just static-analysis
@echo "==> Cleaning..."
@just clean
@echo "==> Building..."
@just build
@echo "==> Testing..."
@just test
# --- Deployment ---
# Simulate the XanV1 deployment (dry-run)
deploy-simulate initial-mint-recipient council chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/DeployXanV1.s.sol:DeployXanV1 \
--sig "run(address,address)" {{ initial-mint-recipient }} {{ council }} \
--rpc-url {{ chain }} {{ args }}
# Deploy XanV1 behind a UUPS proxy
deploy deployer initial-mint-recipient council chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/DeployXanV1.s.sol:DeployXanV1 \
--sig "run(address,address)" {{ initial-mint-recipient }} {{ council }} \
--broadcast --rpc-url {{ chain }} --account {{ deployer }} {{ args }}
# Simulate deploying governance + preparing the XanV1→V2 upgrade implementation (dry-run). `sender` is the deployer,
# who becomes the transient timelock admin (`run` broadcasts as `msg.sender`).
prepare-upgrade-simulate sender proxy council chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/PrepareXanV2Upgrade.s.sol:PrepareXanV2Upgrade \
--sig "run(address,address)" {{ proxy }} {{ council }} \
--rpc-url {{ chain }} --sender {{ sender }} {{ args }}
# Deploy governance + prepare the XanV1→V2 upgrade implementation. `sender` (the address behind `deployer`) becomes the
# transient timelock admin. The returned `implV2` must then be scheduled by the V1 council multisig via
# `scheduleCouncilUpgrade(implV2)` before running `upgrade`.
prepare-upgrade deployer sender proxy council chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/PrepareXanV2Upgrade.s.sol:PrepareXanV2Upgrade \
--sig "run(address,address)" {{ proxy }} {{ council }} \
--broadcast --rpc-url {{ chain }} --account {{ deployer }} --sender {{ sender }} {{ args }}
# Simulate executing the scheduled XanV1→V2 upgrade (permissionless) (dry-run)
upgrade-simulate proxy chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/ExecuteXanV2Upgrade.s.sol:ExecuteXanV2Upgrade \
--sig "run(address)" {{ proxy }} \
--rpc-url {{ chain }} {{ args }}
# Execute the scheduled XanV1→V2 upgrade (permissionless)
upgrade deployer proxy chain *args:
@echo "Cleaning contracts to ensure reproducible build..."
@just clean
forge script script/ExecuteXanV2Upgrade.s.sol:ExecuteXanV2Upgrade \
--sig "run(address)" {{ proxy }} \
--broadcast --rpc-url {{ chain }} --account {{ deployer }} {{ args }}
# --- Verification ---
# Verify an implementation contract on sourcify (e.g. contract=src/XanV1.sol:XanV1)
verify-impl-sourcify address contract chain *args:
ETHERSCAN_API_KEY="" forge verify-contract {{ address }} {{ contract }} \
--chain {{ chain }} --verifier sourcify --watch {{ args }}
# Verify an implementation contract on etherscan (e.g. contract=src/XanV1.sol:XanV1)
verify-impl-etherscan address contract chain *args:
forge verify-contract {{ address }} {{ contract }} \
--chain {{ chain }} --verifier etherscan --watch {{ args }}
# Verify an implementation contract on a custom explorer
verify-impl-custom address contract chain verifier-url *args:
forge verify-contract {{ address }} {{ contract }} \
--chain {{ chain }} --verifier-url {{ verifier-url }} --watch {{ args }}
# Verify an implementation contract on both sourcify and etherscan
verify-impl address contract chain: (verify-impl-sourcify address contract chain) (verify-impl-etherscan address contract chain)
# Verify the ERC1967 proxy on sourcify (encodes the constructor args from the deploy inputs)
verify-proxy-sourcify proxy implementation initial-mint-recipient council chain *args:
ETHERSCAN_API_KEY="" forge verify-contract {{ proxy }} \
lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy \
--chain {{ chain }} --verifier sourcify --watch \
--constructor-args "$(cast abi-encode 'c(address,bytes)' {{ implementation }} "$(cast calldata 'initializeV1(address,address)' {{ initial-mint-recipient }} {{ council }})")" {{ args }}
# Verify the ERC1967 proxy on etherscan (encodes the constructor args from the deploy inputs)
verify-proxy-etherscan proxy implementation initial-mint-recipient council chain *args:
forge verify-contract {{ proxy }} \
lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy \
--chain {{ chain }} --verifier etherscan --watch \
--constructor-args "$(cast abi-encode 'c(address,bytes)' {{ implementation }} "$(cast calldata 'initializeV1(address,address)' {{ initial-mint-recipient }} {{ council }})")" {{ args }}
# Verify the ERC1967 proxy on a custom explorer (encodes the constructor args from the deploy inputs)
verify-proxy-custom proxy implementation initial-mint-recipient council chain verifier-url *args:
forge verify-contract {{ proxy }} \
lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy \
--chain {{ chain }} --verifier-url {{ verifier-url }} --watch \
--constructor-args "$(cast abi-encode 'c(address,bytes)' {{ implementation }} "$(cast calldata 'initializeV1(address,address)' {{ initial-mint-recipient }} {{ council }})")" {{ args }}
# Verify the ERC1967 proxy on both sourcify and etherscan
verify-proxy proxy implementation initial-mint-recipient council chain: (verify-proxy-sourcify proxy implementation initial-mint-recipient council chain) (verify-proxy-etherscan proxy implementation initial-mint-recipient council chain)