-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathjustfile
More file actions
191 lines (155 loc) · 6.02 KB
/
Copy pathjustfile
File metadata and controls
191 lines (155 loc) · 6.02 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# Show commands before running (helps debug failures)
set shell := ["bash", "-euo", "pipefail", "-c"]
# Default recipe
default:
@just --list
# --- Contracts ---
# Install contract dependencies
contracts-deps:
cd contracts && forge soldeer install
# Clean contract dependencies
contracts-deps-clean:
cd contracts && forge soldeer clean
# Clean contracts
contracts-clean:
cd contracts && forge clean
# Build contracts
contracts-build *args:
cd contracts && forge build {{ args }}
# Lint contracts (forge lint + solhint)
contracts-lint:
cd contracts && forge lint --deny warnings
cd contracts && bunx --bun solhint --config .solhint.json 'src/**/*.sol'
cd contracts && bunx --bun solhint --config .solhint.other.json 'test/**/*.sol'
cd contracts && bunx --bun solhint --config .solhint.other.json 'script/**/*.sol'
# Run slither on contracts
contracts-static-analysis:
cd contracts && slither .
@echo "Removing slither compilation artifacts..."
forge clean
# Format contracts
contracts-fmt *args:
cd contracts && forge fmt {{ args }}
# Check contract formatting
contracts-fmt-check:
cd contracts && forge fmt --check
# Run contract tests
contracts-test *args:
cd contracts && forge test {{ args }}
# Regenerate Rust bindings from contracts
contracts-gen-bindings:
cd contracts && forge clean && forge bind \
--skip test --skip script \
--select '^(IProtocolAdapter|ProtocolAdapter|IVersion|VersioningLibExternal|ICommitmentTree|INullifierSet|IForwarder)$' \
--bindings-path ../bindings/src/generated/ \
--module \
--overwrite
# Simulate deployment (dry-run)
contracts-simulate chain *args:
@echo "IS_TEST_DEPLOYMENT: $IS_TEST_DEPLOYMENT"
@echo "EMERGENCY_STOP_CALLER: $EMERGENCY_STOP_CALLER"
@just contracts-clean
cd contracts && forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \
--sig "run(bool,address)" $IS_TEST_DEPLOYMENT $EMERGENCY_STOP_CALLER \
--rpc-url {{chain}} {{ args }}
# Deploy protocol adapter
contracts-deploy deployer chain *args:
@just contracts-clean
cd contracts && forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \
--sig "run(bool,address)" $IS_TEST_DEPLOYMENT $EMERGENCY_STOP_CALLER \
--broadcast --rpc-url {{chain}} --account {{deployer}} {{ args }}
# Execute a transaction binary on a deployed protocol adapter
contracts-execute-tx deployer pa-address filepath chain *args:
cd contracts && forge script script/ExecuteTransaction.s.sol:ExecuteTransaction \
--sig "run(address,string)" {{pa-address}} {{filepath}} \
--broadcast --rpc-url {{chain}} --account {{deployer}} {{ args }}
# Verify on sourcify
contracts-verify-sourcify address chain *args:
cd contracts && env -u ETHERSCAN_API_KEY forge verify-contract {{address}} \
src/ProtocolAdapter.sol:ProtocolAdapter \
--chain {{chain}} --verifier sourcify --watch {{ args }}
# Verify on etherscan
contracts-verify-etherscan address chain *args:
cd contracts && forge verify-contract {{address}} \
src/ProtocolAdapter.sol:ProtocolAdapter \
--chain {{chain}} --verifier etherscan --watch {{ args }}
# Verify on a custom explorer
contracts-verify-custom address chain verifier-url *args:
cd contracts && forge verify-contract {{address}} \
src/ProtocolAdapter.sol:ProtocolAdapter \
--chain {{chain}} --verifier-url {{verifier-url}} --watch {{ args }}
# Verify on both sourcify and etherscan
contracts-verify address chain: (contracts-verify-sourcify address chain) (contracts-verify-etherscan address chain)
# Publish contracts to soldeer. VERSION must be semver (e.g. 1.2.0).
# Flags such as --dry-run go AFTER the version: `just contracts-publish 1.2.0 --dry-run`.
contracts-publish version *args:
@[[ "{{version}}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "error: invalid version '{{version}}'. Expected semver like 1.2.0. Usage: just contracts-publish <version> [flags] (put --dry-run AFTER the version)." >&2; exit 1; }
cd contracts && forge soldeer push anoma-pa-evm~{{version}} {{ args }}
# --- Bindings ---
# Clean bindings
bindings-clean:
cd bindings && cargo clean
# Build bindings
bindings-build *args:
cd bindings && cargo build {{ args }}
# Test bindings
bindings-test *args:
cd bindings && cargo test {{ args }}
# Check bindings are up-to-date
bindings-check: contracts-gen-bindings
git diff --exit-code bindings/src/generated/
# Publish bindings
bindings-publish *args:
cd bindings && cargo publish {{ args }}
# Lint bindings (clippy)
bindings-lint:
cd bindings && cargo clippy --no-deps -- -Dwarnings
cd bindings && cargo clippy --no-deps --tests -- -Dwarnings
# Format bindings
bindings-fmt:
cargo fmt
# Check bindings formatting
bindings-fmt-check:
cargo fmt -- --check
# --- All ---
# Lint all (contracts + bindings)
all-lint:
@echo "==> Linting contracts..."
@just contracts-lint
@echo "==> Linting bindings..."
@just bindings-lint
# Format all (contracts + bindings)
all-fmt:
@echo "==> Formatting contracts..."
@just contracts-fmt
@echo "==> Formatting bindings..."
@just bindings-fmt
# Check formatting for all (contracts + bindings)
all-fmt-check:
@echo "==> Checking contract formatting..."
@just contracts-fmt-check
@echo "==> Checking bindings formatting..."
@just bindings-fmt-check
# Build all (contracts + bindings)
all-build:
@echo "==> Building contracts..."
@just contracts-build
@echo "==> Building bindings..."
@just bindings-build
# Test all (contracts + bindings)
all-test:
@echo "==> Testing contracts..."
@just contracts-test
@echo "==> Testing bindings..."
@just bindings-test
# Prerequisites check (mirrors CI)
all-check:
git status
@echo "==> Static analysis with slither..."
@just contracts-static-analysis
@echo "==> Checking formatting..."
@just all-fmt-check
@echo "==> Linting..."
@just all-lint
@echo "==> Checking bindings are up-to-date..."
@just bindings-check