-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
413 lines (361 loc) · 12.8 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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
---
version: "3"
vars:
CURL_CICD_DEV: "curl -s -H 'Accept: application/vnd.github.v3.raw' -L https://api.github.com/repos/polysensus/cicd-dev-infra/contents"
TUSKS: "{{.ROOT_DIR}}/.local/dev"
FACETS_EXCLUDE: "{{.ROOT_DIR}}/node_modules/@polysensus/chaintrap-contracts/abi/facets-exclude.json"
FACETS_DEPLOYED: "facets-deployed.json"
CHAINTRAP_CONTRACTS_ABI_DIR: "{{.ROOT_DIR}}/node_modules/@polysensus/chaintrap-contracts/abi"
DIAMOND_DEPLOY_JSON: "{{.ROOT_DIR}}/.local/dev/diamond-deploy.json"
DEPLOYCLI: "node {{.ROOT_DIR}}/node_modules/@polysensus/diamond-deploy/dist/deploycli.esm.js"
#DEPLOYCLI: "node node_modules/@polysensus/diamond-deploy/deploycli.js"
FURNITURE_FILE: "{{.ROOT_DIR}}/data/maps/map02-furnishings.json"
MAP_FILE: "{{.ROOT_DIR}}/data/maps/map02.json"
MAP_NAME: "map02"
CODEX_FILENAME: "map02.codex.json"
CODEX_PASSWORD: "very-secret"
OPENAI_IMAGE_PROMPT: "A stylised icon representing a turn based random dungeon crawler game"
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
includes:
op:game:
taskfile: ./taskfiles/Taskfile_game.yml
vars:
PROVIDER_ID: "opsepolia"
hh:game:
taskfile: ./taskfiles/Taskfile_game.yml
vars:
PROVIDER_ID: "hh"
# ----
# Milestone demos
# ----
hh:cms3:
taskfile: ./taskfiles/Taskfile_cms3.yml
vars:
PROVIDER_ID: "hh"
op:cms3:
taskfile: ./taskfiles/Taskfile_cms3.yml
vars:
PROVIDER_ID: "op"
hh:cms4:
taskfile: ./taskfiles/Taskfile_cms3.yml
vars:
PROVIDER_ID: "hh"
op:cms4:
taskfile: ./taskfiles/Taskfile_cms4.yml
vars:
PROVIDER_ID: "op"
tasks:
bootstrap:
desc: fetch the pre-requisites for all workflows
cmds:
- |
mkdir -p {{.TUSKS}}
cd {{.TUSKS}}
{{.CURL_CICD_DEV}}/js/tusk-jspkg.yml?ref=v0.0.5 -o tusk-jspkg.yml
{{.CURL_CICD_DEV}}/hardhat/tusk-hardhat.yml?ref=v0.0.5 -o tusk-hardhat.yml
release:patch:
desc: create patch release
cmds:
- |
tusk -q -f {{.TUSKS}}/tusk-jspkg.yml version-update {{.CLI_ARGS}}
fmt:
- npm run format
format:
desc: automatic code formatting - run prettier and then lint
cmds:
- |
npm run format
npm run lint
build:
cmds:
- task: build:js
- task: build:diamond-deploy
test:prepare:cd:
desc: start hardhat and deploy contracts for CI/CD
cmds:
- task: test:prepare
test:prepare:
desc: start hardhat and deploy contracts for test:integ
cmds:
- |
cat .env.example.hh | envsubst > .env.hh
cat .env.hh | grep ARENASTATE_
- task: dev:hh:restart
- |
task -s deploy:new PROVIDER_ID=hh -- --commit
ADDRESS=$(task -s find PROVIDER_ID=hh)
echo "# test:prepare:cd resolved the following address after deploying" >> .env.hh
echo "export ARENASTATE_ARENA=${ADDRESS}" >> .env.hh
cp .env.hh .env.test
test:
desc: run the unit tests
cmds:
- npx mocha './**/*.mocha.js' {{.CLI_ARGS}}
build:js:
desc: format and lint the code, then build the package
deps: [format]
cmds:
- npm run build
build:diamond-deploy:
desc: generate the deployable list of facets
cmds:
- |
mkdir -p .local/dev
{{.DEPLOYCLI}} \
list \
-I facet -i {{.CHAINTRAP_CONTRACTS_ABI_DIR}} \
--exclude {{.FACETS_EXCLUDE}} \
-n Diamond DiamondNew \
--format json | tee {{.DIAMOND_DEPLOY_JSON}}
# ----
# game commands
# ----
game:maptool:
desc: load a map file and save it in a game codex
dotenv: [".env.{{.PROVIDER_ID}}"]
cmds:
- |
echo "PROVIDER_ID: {{.PROVIDER_ID}}"
./cli.js \
--map-name {{.MAP_NAME}} \
maptool \
--map-load \
--map-filename {{.MAP_FILE}} \
--codex-filename {{.CODEX_FILENAME}} \
--codex-password {{.CODEX_PASSWORD}}
deploy:
desc: deploy the contracts to all supported networks
cmds:
- task: deploy:new
vars:
PROVIDER_ID: "hh"
COMMIT: "yes"
- task: deploy:new
vars:
PROVIDER_ID: "caimst"
- task: deploy:mumbai
- task: deploy
vars:
PROVIDER_ID: opsepolia
op:bridge-eth:
dotenv: [".env.opsepolia"]
desc: |
bridge eth from Optimism L1 to L2.
example use
task op:bridge-eth -- $(cat .local/dev/wallets/wallet-deploy.key) 0.5 --commit
cmds:
- |
echo needs porting from tusk syntax
exit 1
set -e
${diamond-deploy} \
-u "${rpc}" \
op-deposit \
--l1-url=${l1-url} \
--eth-fiat=1453 \
--units=${units} \
$(${commit} && echo -n '--commit' ) \
${key} ${amount}
deploy:op:
desc: deploy the contracts to optimism testnet
cmds:
- task: deploy:up
vars:
PROVIDER_ID: "opsepolia"
GAS_PRICE: "0.001"
deploy:op-new:
desc: deploy the contracts to optimism testnet
cmds:
- task: deploy:new
vars:
PROVIDER_ID: "opsepolia"
GAS_PRICE: "0.001"
#GAS_LIMIT: "1514"
#CUTTER_GAS_LIMIT: "1514"
#GAS_LIMIT: "1514136"
#CUTTER_GAS_LIMIT: "1514136"
GAS_LIMIT: '{{.GAS_LIMIT | default ""}}'
CUTTER_GAS_LIMIT: '{{.CUTTER_GAS_LIMIT | default ""}}'
deploy:mumbai:
desc: deploy the contracts to polygon mumbai testnet
cmds:
- task: deploy:up
vars:
PROVIDER_ID: "mumbai"
GAS_PRICE: "2.6"
deploy:mumbai-new:
desc: deploy the contracts to polygon mumbai testnet
cmds:
- task: deploy:new
vars:
PROVIDER_ID: "mumbai"
GAS_PRICE: "2.6"
deploy:up:
desc: |
deploy the contracts to the chosen provider
This command is dry run by default, add '-- --commit' to deploy
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
GAS_PRICE: '{{.GAS_PRICE | default "0.001"}}'
DIAMOND_ADDRESS: '{{.DIAMOND_ADDRESS | default ""}}'
DIAMOND_NONCE: '{{.DIAMOND_NONCE | default ""}}'
GAS_LIMIT: '{{.GAS_LIMIT | default ""}}'
CUTTER_GAS_LIMIT: '{{.CUTTER_GAS_LIMIT | default ""}}'
COMMIT: '{{.COMMIT | default ""}}'
cmds:
- |
echo "ARENASTATE_DEPLOY_KEY: $ARENASTATE_DEPLOY_KEY"
echo "PROVIDER_ID {{.PROVIDER_ID}}"
echo "ARENASTATE_ARENA: $ARENASTATE_ARENA"
DIAMOND_ADDRESS=${ARENASTATE_ARENA:-"{{.DIAMOND_ADDRESS}}"}
echo "DIAMOND_ADDRESS: $DIAMOND_ADDRESS"
DIAMOND_NONCE=${ARENASTATE_DIAMOND_NONCE:-"{{.DIAMOND_NONCE}}"}
echo "DIAMOND_NONCE: $DIAMOND_NONCE"
echo "GAS_PRICE: {{.GAS_PRICE}}"
echo "GAS_PRICE: {{.GAS_LIMIT}}"
echo "CUTTER_GAS_PRICE: {{.CUTTER_GAS_LIMIT}}"
{{.DEPLOYCLI}} list \
-I facet -n Diamond DiamondNew \
-i node_modules/@polysensus/chaintrap-contracts/abi \
--format json -x node_modules/@polysensus/chaintrap-contracts/abi/facets-exclude.json \
> diamond-deploy.json
{{.DEPLOYCLI}} \
-u "${ARENASTATE_PROVIDER_URL}" \
-d "${ARENASTATE_DEPLOY_KEY}" \
diamond-up \
$([ -n '{{.DIAMOND_NONCE}}' ] && echo -n '--diamond-nonce {{.DIAMOND_NONCE}}' ) \
$([ -n '{{.DIAMOND_ADDRESS}}' ] && echo -n '--diamond-address {{.DIAMOND_ADDRESS}}' ) \
--replace \
$([ -n '{{.GAS_PRICE}}' ] && echo -n '--gasprice {{.GAS_PRICE}}' ) \
$([ -n '{{.GAS_LIMIT}}' ] && echo -n '--gaslimit {{.GAS_LIMIT}}' ) \
$([ -n '{{.CUTTER_GAS_LIMIT}}' ] && echo -n '--cutter-gaslimit {{.CUTTER_GAS_LIMIT}}' ) \
--legacy \
--diamond-owner-key ${ARENASTATE_OWNER_KEY} \
--diamond-init-name DiamondNew \
--diamond-init-args \
'[{"typeURIs": ["GAME_TYPE", "TRANSCRIPT_TYPE", "FURNITURE_TYPE"]}]' \
-f diamond-deploy.json \
{{.CLI_ARGS}}
if [ ! $(echo '{{.CLI_ARGS}}' | grep '\-\-\commit') ]; then
echo "append '-- --commit' to your options to issue the transactions"
fi
deploy:new:
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
GAS_PRICE: '{{.GAS_PRICE | default "0.001"}}'
GAS_LIMIT: '{{.GAS_LIMIT | default ""}}'
CUTTER_GAS_LIMIT: '{{.CUTTER_GAS_LIMIT | default ""}}'
COMMIT: '{{.COMMIT | default ""}}'
desc: |
deploy the contracts
This command is dry run by default, add '-- --commit' to deploy
cmds:
- |
# source .env.{{.PROVIDER_ID}}
echo "PROVIDER_ID {{.PROVIDER_ID}}"
echo "PROVIDER_URL: $ARENASTATE_PROVIDER_URL"
echo "ARENASTATE_DEPLOY_KEY: $ARENASTATE_DEPLOY_KEY"
echo "ARENASTATE_ARENA: $ARENASTATE_ARENA"
echo "ARENASTATE_OWNER_KEY: $ARENASTATE_OWNER_KEY"
FACETS_DEPLOYED="{{.PROVIDER_ID}}.{{.FACETS_DEPLOYED}}"
[ -z $FACETS_DEPLOYED ] && echo 'A filename for --facets-deployed is required' && exit 1
if [ ! -f $FACETS_DEPLOYED ]; then
echo '{}' > $FACETS_DEPLOYED
else
echo "**** re-using deployed facets from $FACETS_DEPLOYED ***"
fi
{{.DEPLOYCLI}} list \
-I facet -n Diamond DiamondNew \
-i node_modules/@polysensus/chaintrap-contracts/abi \
--format json -x node_modules/@polysensus/chaintrap-contracts/abi/facets-exclude.json \
> diamond-deploy.json
{{.DEPLOYCLI}} \
-u "${ARENASTATE_PROVIDER_URL}" \
-d "${ARENASTATE_DEPLOY_KEY}" \
diamond-new \
--replace \
$([ -n '{{.GAS_PRICE}}' ] && echo -n '--gasprice {{.GAS_PRICE}}' ) \
$([ -n '{{.GAS_LIMIT}}' ] && echo -n '--gaslimit {{.GAS_LIMIT}}' ) \
$([ -n '{{.CUTTER_GAS_LIMIT}}' ] && echo -n '--cutter-gaslimit {{.CUTTER_GAS_LIMIT}}' ) \
--legacy \
--diamond-owner-key ${ARENASTATE_OWNER_KEY} \
--diamond-init-name DiamondNew \
--diamond-init-args \
'[{"typeURIs": ["GAME_TYPE", "TRANSCRIPT_TYPE", "FURNITURE_TYPE"]}]' \
--facets diamond-deploy.json \
--facets-deployed=$FACETS_DEPLOYED \
--save-facets-deployed=$FACETS_DEPLOYED \
{{.CLI_ARGS}}
if [ ! $(echo '{{.CLI_ARGS}}' | grep '\-\-\commit') ]; then
echo "append '-- --commit' to your options to issue the transactions"
fi
find:
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
DIAMOND_NONCE: '{{.DIAMOND_NONCE | default ""}}'
desc: find the arena on the chosen PROVIDER_ID
cmds:
- |
{{.DEPLOYCLI}} \
-u "${ARENASTATE_PROVIDER_URL}" \
-d "${ARENASTATE_DEPLOY_KEY}" \
find \
$([ -n '{{.DIAMOND_NONCE}}' ] && echo -n '--diamond-nonce {{.DIAMOND_NONCE}}' )
dev:hh:start:
desc: start a local hardhat node (if there isn't one running)
cmds:
- tusk -q -f {{.TUSKS}}/tusk-hardhat.yml start-node -d .local/hh
- rm -f hh.{{.FACETS_DEPLOYED}}
dev:hh:restart:
desc: restart the local hardhat node
deps: [dev:hh:stop]
cmds:
- task: dev:hh:start
dev:hh:stop:
desc: stop a local hardhat node (according to pid in .local/hh/hh-pid)
cmds:
- |
set -x
ls -la {{.TUSKS}}
tusk -q -f {{.TUSKS}}/tusk-hardhat.yml stop-node -d .local/hh
resolve-key:
desc: |
resolve the key to use
Intended for internal use to fall back to a task specific 'default' named key.
task file user MAY set KEY
calling task always sets KEY_ENV_DEFAULT
If the user hasn't set KEY, then ARENASTATE_<KEY_ENV_DEFAULT>_KEY is used
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
# taskfile user sets KEY if they want to override.
KEY: '{{.KEY | default ""}}'
# calling task sets this un-conditionaly to specify the key to default to
KEY_ENV_DEFAULT: '{{.KEY_ENV_DEFAULT | default "GUARDIAN"}}'
cmds:
- |
KEY={{.KEY}}
KEY=${KEY:-$ARENASTATE_{{.KEY_ENV_DEFAULT}}_KEY}
[ -z "$KEY" ] && echo "failed to resolve key" && exit 1
echo $KEY
resolve-arena:
desc: |
resolve the arena contract proxy address
For the hardhat provider we find the latest deployed
For all other providers we *require* that ARENASTATE_ARENA is set in the
env and not empty.
dotenv: [".env.{{.PROVIDER_ID}}"]
vars:
PROVIDER_ID: '{{.PROVIDER_ID | default "hh"}}'
cmds:
- |
if [ "{{.PROVIDER_ID}}" = "hh" ]; then
task -s find PROVIDER_ID={{.PROVIDER_ID}}
exit 0
elif [ -z "$ARENASTATE_ARENA" ]; then
echo "The arena proxy address must be supplied explicitly unless using hardhat"
exit 1
fi
echo $ARENASTATE_ARENA