-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
353 lines (303 loc) · 11.2 KB
/
Taskfile.yml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
---
version: '3'
env:
ENV: '{{.ENV | default ".local/dev" }}'
PROFILE: '{{.PROFILE | default ""}}'
DEPLOYCLI: "node node_modules/@polysensus/diamond-deploy/dist/deploycli.esm.js"
vars:
# The input file for diamond-deploy --exclu
FACETS_EXCLUDE: abi/facets-exclude.json
DIAMOND_DEPLOY_JSON: '{{.ENV}}/diamond-deploy.json'
CICD_DEV_CURL: "curl -s -H 'Accept: application/vnd.github.v3.raw' -L https://api.github.com/repos/polysensus/cicd-dev-infra/contents"
TUSKS: ".local/dev"
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
# tasks are primarily for actions local to this repository. task is for things
# that usually don't need options (or can be configured once via a .env) use it
# especially when you have things that depend on other things
tasks:
bootstrap:
desc: fetch the shared cicd development infra we use here
cmds:
- |
mkdir -p {{.TUSKS}}
cd {{.TUSKS}}
{{.CICD_DEV_CURL}}/js/tusk-jspkg.yml?ref=v0.0.2 -O
release:patch:
desc: create patch release
cmds:
- |
tusk -q -f {{.TUSKS}}/tusk-jspkg.yml version-update {{.CLI_ARGS}}
format:
desc: format all the sources (javascript and solidity using prettier)
cmds:
- |
npx prettier --write 'chaintrap/**/*.sol'
npx prettier --write 'lib/**/*.sol'
npx prettier --write 'scripts/**/*.sol'
npx prettier --write 'chaintrap/**/*.{js,mjs,ts}'
npx prettier --write 'tests/hh/**/*.{js,mjs,ts}'
build:
desc: build the npm package
cmds:
- task: format
- task: build:contracts
- task: build:types
- npx rollup -c
verify:deployed:
desc: verify contracts in a diamond-deploy deployment record file
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
DEPLOYED_JSON: '{{.DEPLOYED_JSON | default ""}}'
cmds:
- |
[ -z "{{.DEPLOYED_JSON}}" ] && echo 'DEPLOYED_JSON must be set' && exit 1
verify:diamond:sourcify:
desc: verify the contracts
cmds:
- |
# use https://louper.dev to inspect the facet addresses
# Diamond constructor args abi like this
CONSTRUCTOR_ARGS=0x000000000000000000000000b179a6f44472a0446e003117dc870b5c99ccea22000000000000000000000000e2205b98c12c5c2f5e58299e7ef2247215cfbef6
CONSTRUCTOR_ARGS=$(cast abi-encode "constructor(address,address)" $(cat .local/dev/arena-owner.addr) 0xe2205b98c12c5c2f5e58299e7ef2247215cfbef6)
echo $CONSTRUCTOR_ARGS
forge verify-contract \
--constructor-args $CONSTRUCTOR_ARGS \
--chain ${ARENASTATE_CHAINID} \
--watch \
0x0c075885e9EBB701997bA3e1B8D291688Dc0bCEE \
chaintrap/diamond/Diamond.sol:Diamond \
--verifier sourcify
verify:diamond:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z $ARENASTATE_ARENA ] && echo 'ARENASTATE_ARENA must be provided' && exit 1
[ -z $ARENASTATE_DIAMOND_CUTTER ] && echo 'ARENASTATE_DIAMOND_CUTTER must be provided' && exit 1
[ ! -f .local/dev/arena-owner.addr ] && echo '.local/dev/arena-owner.addr must exist' && exit 1
# Diamond constructor args abi like this
CONSTRUCTOR_ARGS=$(cast abi-encode "constructor(address,address)" $(cat .local/dev/arena-owner.addr) $ARENASTATE_DIAMOND_CUTTER)
echo $CONSTRUCTOR_ARGS
forge verify-contract \
--constructor-args $CONSTRUCTOR_ARGS \
--chain ${ARENASTATE_CHAINID} \
--watch \
$ARENASTATE_ARENA \
chaintrap/diamond/Diamond.sol:Diamond \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key=$ARENASTATE_ETHERSCAN_API_KEY
verify:erc1155arenafacet:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
FACET_ADDRESS: '{{.FACET_ADDRESS | default ""}}'
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z "{{.FACET_ADDRESS}}" ] && echo 'FACET_ADDRESS must be set' && exit 1
forge verify-contract \
--chain ${ARENASTATE_CHAINID} \
--watch \
{{.FACET_ADDRESS}} \
chaintrap/facets/arena/ERC1155ArenaFacet.sol:ERC1155ArenaFacet \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key=$ARENASTATE_ETHERSCAN_API_KEY
verify:arenafacet:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
FACET_ADDRESS: '{{.FACET_ADDRESS | default ""}}'
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z "{{.FACET_ADDRESS}}" ] && echo 'FACET_ADDRESS must be set' && exit 1
echo "VERIFYING: {{.FACET_ADDRESS}}"
export ETHERSCAN_API_KEY=$ARENASTATE_ETHERSCAN_API_KEY
echo "ETHERSCAN_API_KEY=$ARENASTATE_ETHERSCAN_API_KEY"
forge verify-contract \
--chain ${ARENASTATE_CHAINID} \
--watch \
{{.FACET_ADDRESS}} \
chaintrap/facets/arena/ArenaFacet.sol:ArenaFacet \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key $ARENASTATE_ETHERSCAN_API_KEY
verify:loupefacet:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
FACET_ADDRESS: '{{.FACET_ADDRESS | default ""}}'
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z "{{.FACET_ADDRESS}}" ] && echo 'FACET_ADDRESS must be set' && exit 1
echo "VERIFYING: {{.FACET_ADDRESS}}"
forge verify-contract \
--chain ${ARENASTATE_CHAINID} \
--watch \
{{.FACET_ADDRESS}} \
chaintrap/diamond/facets/DiamondLoupeFacet.sol:DiamondLoupeFacet \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key=$ARENASTATE_ETHERSCAN_API_KEY
verify:cutfacet:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
FACET_ADDRESS: '{{.FACET_ADDRESS | default ""}}'
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z "{{.FACET_ADDRESS}}" ] && echo 'FACET_ADDRESS must be set' && exit 1
echo "VERIFYING: {{.FACET_ADDRESS}}"
forge verify-contract \
--chain ${ARENASTATE_CHAINID} \
--watch \
{{.FACET_ADDRESS}} \
chaintrap/diamond/facets/DiamondCutFacet.sol:DiamondCutFacet \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key=$ARENASTATE_ETHERSCAN_API_KEY
verify:ownershipfacet:
desc: verify the contracts
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
FACET_ADDRESS: '{{.FACET_ADDRESS | default ""}}'
cmds:
- |
# use https://louper.dev to inspect the facet addresses
[ -z "{{.FACET_ADDRESS}}" ] && echo 'FACET_ADDRESS must be set' && exit 1
echo "VERIFYING: {{.FACET_ADDRESS}}"
forge verify-contract \
--chain ${ARENASTATE_CHAINID} \
--watch \
{{.FACET_ADDRESS}} \
chaintrap/diamond/facets/OwnershipFacet.sol:OwnershipFacet \
--verifier etherscan \
--verifier-url $ARENASTATE_ETHERSCAN_URL \
--etherscan-api-key=$ARENASTATE_ETHERSCAN_API_KEY
build:contracts:
desc: build the contracts and prepare the abi and exclusions file
cmds:
- rm -rf abi && mkdir -p abi
- mkdir -p .local/dev
- forge build --sizes
- task: build:facets-exclude
- task: build:diamond-deploy
- |
echo "copying abi files from build"
cp build/forge/out/Diamond.sol/Diamond.json abi/
cp build/forge/out/DiamondNew.sol/DiamondNew.json abi/
for d in $(ls -d build/forge/out/*Facet.sol); do cp $d/*Facet.json abi/; done
build:types:
desc: "generate typescript types using typechain"
cmds:
- |
npx typechain \
--glob "abi/**/*.json" \
--target=ethers-v5 \
--out-dir=types
build:facets-exclude:
desc: |
re generate the current diamond deploy exclusions
note: this command needs to be maintained to account for any new
collisions introduces in future changes. facet:collisions can help with
that.
cmds:
- |
${DEPLOYCLI} \
select \
--select-excluded -I facet -i build/forge/out \
| tee {{.FACETS_EXCLUDE}}
build:diamond-deploy:
desc: generate the deployable list of facets
cmds:
- |
${DEPLOYCLI} \
list \
-I facet -i build/forge/out \
-n Diamond DiamondNew \
--exclude {{.FACETS_EXCLUDE}} \
--format json | tee {{.DIAMOND_DEPLOY_JSON}}
test:
desc: run the forge and hardhat tests
cmds:
- task: test:forge
- task: test:hh
test:forge:
desc: run the forge tests
cmds:
- forge test -vvv --ffi {{.CLI_ARGS}}
test:hh:
desc: run the hardhat tests
cmds:
- npx hardhat test
deploy:
cmds:
- task: deploy-caimst
- task: deploy-pol
deploy-hh:
cmds:
- task: deploy-to
vars: { RPC_URL: "http://localhost:8545" }
deploy-caimst:
cmds:
- task: deploy-to
vars: { RPC_URL: "https://chains.hoy.polysensus.io/chains/caimst-209301/node/ethnode0/WWdEOHJUNVFDRXpPZ0VDb1IxTVpYOmFyZ29uMmlkIDMgNjRNQiAzMi5Kdkt6cEU5U09HNW02a3RBXzViYk8yRFZNeUw3cXBEdm5vQjhlOEtQMk5rPS5pR2JMMXpDRzBxbVRKdnRUN2RkLURxWlhSbDkxTWlYQm1RNDlKVzhjOF9jPQ==" }
deploy-pol:
cmds:
- task: deploy-to
vars:
PRIVATE_KEY:
sh: cat .local/dev/wallet-deploy.key
DEPLOYER_ADDR:
sh: cat .local/dev/wallet-deploy.addr
RPC_URL: "https://polygon-mumbai.g.alchemy.com/v2/zyiZCXLwVEOZPVoixfOBBVvp7KE1oiqf"
deploy-to:
desc: deploy the contracts
cmds:
- |
PRIVATE_KEY='{{.PRIVATE_KEY | default "hardhat:0" }}'
DEPLOYER_ADDR='{{.DEPLOYER_ADDR | default "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"}}'
echo "PRIVATE_KEY: $PRIVATE_KEY"
echo "DEPLOYER_ADDR: $DEPLOYER_ADDR"
[ -z "$PRIVATE_KEY" ] && echo "no deployment key" && exit 1
echo "RPC_URL: {{.RPC_URL}}"
echo "Deployer: $DEPLOYER_ADDR"
CONTRACT=chaintrap/arena.sol:Arena
forge create $CONTRACT \
--legacy \
--rpc-url={{.RPC_URL}} \
--private-key=$PRIVATE_KEY \
--gas-limit=5000000
facet:collisions:
desc: show the json formatted list of diamond facet collisions
cmds:
- |
${DEPLOYCLI} select \
-I facet -i build/forge/out \
-n Diamond DiamondNew \
--show-collisions --format json
facet:list:
desc: generate the deployable list of facets
cmds:
- |
${DEPLOYCLI} \
list \
-I facet -i build/forge/out \
-n Diamond DiamondNew \
--exclude {{.FACETS_EXCLUDE}} \
--format json
facet:list-names:
desc: generate the deployable list of facets
cmds:
- |
${DEPLOYCLI} \
list \
-I facet -i build/forge/out \
-n Diamond DiamondNew \
--exclude {{.FACETS_EXCLUDE}} \
--format json | jq -r .[].name | tr -s '\n' ' '