-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
467 lines (396 loc) · 16 KB
/
Makefile
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
CANDYMACHINE_REPO=teritori-nfts
BUNKER_MINTER_PACKAGE=teritori-bunker-minter
GO?=go
GOFMT?=$(shell $(GO) env GOROOT)/bin/gofmt
CAT := $(if $(filter $(OS),Windows_NT),type,cat)
COSMWASM_CONTRACTS_DIR=rust/cw-contracts
INTERNAL_COSMWASM_CONTRACTS=$(wildcard $(COSMWASM_CONTRACTS_DIR)/*)
TOKEN_REPO=teritori-nfts
TOKEN_PACKAGE=teritori-nft
SQUAD_STAKING_PACKAGE=teritori-squad-staking
BREEDING_PACKAGE=teritori-breeding
DISTRIBUTOR_PACKAGE=teritori-distributor
NAME_SERVICE_REPO=teritori-name-service
NAME_SERVICE_PACKAGE=teritori-name-service
ADDR_LIST_REPO=cw_addr_list
ADDR_LIST_PACKAGE=cw-address-list
CONTRACTS_CLIENTS_DIR=packages/contracts-clients
DOCKER_REGISTRY=rg.nl-ams.scw.cloud/teritori
INDEXER_DOCKER_IMAGE=$(DOCKER_REGISTRY)/teritori-indexer:$(shell git rev-parse --short HEAD)
EVM_INDEXER_IMAGE=$(DOCKER_REGISTRY)/evm-indexer:$(shell git rev-parse --short HEAD)
GNO_INDEXER_DOCKER_IMAGE=$(DOCKER_REGISTRY)/gno-indexer:$(shell git rev-parse --short HEAD)
FLUSH_DATA_IMAGE=$(DOCKER_REGISTRY)/flush-data:$(shell git rev-parse --short HEAD)
BACKEND_DOCKER_IMAGE=$(DOCKER_REGISTRY)/teritori-dapp-backend:$(shell git rev-parse --short HEAD)
PRICES_SERVICE_DOCKER_IMAGE=$(DOCKER_REGISTRY)/prices-service:$(shell git rev-parse --short HEAD)
PRICES_OHLC_REFRESH_DOCKER_IMAGE=$(DOCKER_REGISTRY)/prices-ohlc-refresh:$(shell git rev-parse --short HEAD)
P2E_DOCKER_IMAGE=$(DOCKER_REGISTRY)/p2e-update-leaderboard:$(shell git rev-parse --short HEAD)
FEED_DOCKER_IMAGE=$(DOCKER_REGISTRY)/feed-clean-pinata-keys:$(shell git rev-parse --short HEAD)
MULTISIG_DOCKER_IMAGE=$(DOCKER_REGISTRY)/cosmos-multisig-backend:$(shell git rev-parse --short HEAD)
GNODEV=gnodev --add-account g193vp9tjhfpldvgg3gn433ayv8pn7rtfv8shyeq $$(find gno -name gno.mod -type f -exec dirname {} \;)
GNODEV_E2E=$(GNODEV) --unsafe-api --server-mode
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH := amd64
else ifeq ($(ARCH),aarch64)
ARCH := arm64
endif
node_modules: package.json yarn.lock
yarn
touch $@
.PHONY: go-mod-tidy
go-mod-tidy:
go mod tidy
.PHONY: generate
generate: generate.protobuf generate.graphql generate.contracts-clients generate.go-networks networks.json
.PHONY: generate.protobuf
generate.protobuf: node_modules packages/api/weshnet
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
buf generate api
.PHONY: packages/api/weshnet
packages/api/weshnet: node_modules
rm -fr $@
buf generate --template ./weshnet.buf.gen.yaml buf.build/berty/weshnet -o .weshgen
cp -r .weshgen/packages/api $@
rm -fr .weshgen
.PHONY: generate.graphql
generate.graphql:
go run github.com/Khan/genqlient@85e2e8dffd211c83a2be626474993ef68e44a242 go/pkg/holagql/genqlient.yaml
go run github.com/Khan/genqlient@85e2e8dffd211c83a2be626474993ef68e44a242 go/pkg/gnoindexerql/genqlient.yaml
.PHONY: generate.graphql-thegraph
generate.graphql-thegraph:
rover graph introspect https://api.studio.thegraph.com/query/40379/teritori-mainnet/v1 > go/pkg/thegraph/thegraph-schema.graphql
go run github.com/Khan/genqlient@85e2e8dffd211c83a2be626474993ef68e44a242 go/pkg/thegraph/genqlient.yaml
.PHONY: lint
lint: lint.buf lint.js lint.rust
.PHONY: lint.buf
lint.buf:
buf lint api
buf breaking --against 'https://github.com/TERITORI/teritori-dapp.git#branch=main' --path api
.PHONY: lint.js
lint.js: node_modules
yarn lint
.PHONY: lint.rust
lint.rust:
cargo clippy
.PHONY: fmt.rust
fmt.rust:
cargo fmt
.PHONY: go/pkg/holagql/holaplex-schema.graphql
go/pkg/holagql/holaplex-schema.graphql:
rover graph introspect https://graph.65.108.73.219.nip.io/v1 > $@
.PHONY: go/pkg/gnoindexerql/indexer-schema.graphql
go/pkg/gnoindexerql/indexer-schema.graphql:
rover graph introspect http://localhost:8546/graphql/query > $@
.PHONY: docker.backend
docker.backend:
docker build . -f go/cmd/teritori-dapp-backend/Dockerfile -t teritori/teritori-dapp-backend:$(shell git rev-parse --short HEAD)
.PHONY: generate.contracts-clients
generate.contracts-clients: generate.internal-contracts-clients $(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(NAME_SERVICE_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(RIOTER_FOOTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(TOKEN_PACKAGE)
.PHONY: generate.go-networks
generate.go-networks: node_modules validate-networks
npx tsx packages/scripts/generateGoNetworks.ts | $(GOFMT) > go/pkg/networks/networks.gen.go
npx tsx packages/scripts/codegen/generateGoNetworkFeatures.ts | $(GOFMT) > go/pkg/networks/features.gen.go
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE): node_modules
rm -fr $(CANDYMACHINE_REPO)
git clone [email protected]:TERITORI/$(CANDYMACHINE_REPO).git
cd $(CANDYMACHINE_REPO) && git checkout 61028f26c8ca2662bab39eff23f28c322d1aa60e
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(CANDYMACHINE_REPO)/schema/nft-minter \
--out $@ \
--name $(BUNKER_MINTER_PACKAGE) \
--no-bundle
mkdir -p go/pkg/contracts/bunker_minter_types
go run github.com/a-h/generate/cmd/[email protected] -i $(CANDYMACHINE_REPO)/schema/nft-minter/instantiate_msg.json -o go/pkg/contracts/bunker_minter_types/instantiate_msg.go -p bunker_minter_types
go fmt ./go/pkg/contracts/bunker_minter_types
rm -fr $(CANDYMACHINE_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(NAME_SERVICE_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(NAME_SERVICE_PACKAGE): node_modules
rm -fr $(NAME_SERVICE_REPO)
git clone [email protected]:TERITORI/$(NAME_SERVICE_REPO).git
cd $(NAME_SERVICE_REPO) && git checkout 1a03f93e9d7b96712a7a2585a079cbe97e384724
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(NAME_SERVICE_REPO)/schema \
--out $@ \
--name $(NAME_SERVICE_PACKAGE) \
--no-bundle
mkdir -p go/pkg/contracts/name_service_types
go run github.com/a-h/generate/cmd/[email protected] -i $(NAME_SERVICE_REPO)/schema/contract_info_response.json -o go/pkg/contracts/name_service_types/contract_info_response.go -p name_service_types
go fmt ./go/pkg/contracts/name_service_types
rm -fr $(NAME_SERVICE_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(TOKEN_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(TOKEN_PACKAGE): node_modules
rm -fr $(TOKEN_REPO)
git clone [email protected]:TERITORI/$(TOKEN_REPO).git
cd $(TOKEN_REPO) && git checkout c368eba82348c0f9cc538cee7401bcf673847dcc
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(TOKEN_REPO)/schema/nft-token \
--out $@ \
--name $(TOKEN_PACKAGE) \
--no-bundle
rm -fr $(TOKEN_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(DISTRIBUTOR_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(DISTRIBUTOR_PACKAGE): node_modules
rm -fr $(TOKEN_REPO)
git clone [email protected]:TERITORI/$(TOKEN_REPO).git
cd $(TOKEN_REPO) && git checkout 61028f26c8ca2662bab39eff23f28c322d1aa60e
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(TOKEN_REPO)/schema/distributor \
--out $@ \
--name $(DISTRIBUTOR_PACKAGE) \
--no-bundle
rm -fr $(TOKEN_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(SQUAD_STAKING_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(SQUAD_STAKING_PACKAGE): node_modules
rm -fr $(TOKEN_REPO)
git clone [email protected]:TERITORI/$(TOKEN_REPO).git
cd $(TOKEN_REPO) && git checkout afacbd6e9ad9561f98fd7e0eaa5580c916fda276
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(TOKEN_REPO)/schema/squad-staking \
--out $@ \
--name $(SQUAD_STAKING_PACKAGE) \
--no-bundle
rm -fr $(TOKEN_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(BREEDING_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(BREEDING_PACKAGE): node_modules
rm -fr $(CANDYMACHINE_REPO)
git clone [email protected]:TERITORI/$(CANDYMACHINE_REPO).git
cd $(CANDYMACHINE_REPO) && git checkout 26e37212a24d8e9e4b52af3c8f0ec3837633732c
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(CANDYMACHINE_REPO)/schema/nft-breeding \
--out $@ \
--name $(BREEDING_PACKAGE) \
--no-bundle
mkdir -p go/pkg/contracts/breeding_types
go run github.com/a-h/generate/cmd/[email protected] -i $(CANDYMACHINE_REPO)/schema/nft-breeding/instantiate_msg.json -o go/pkg/contracts/breeding_types/instantiate_msg.go -p breeding_types
go fmt ./go/pkg/contracts/breeding_minter_types
rm -fr $(CANDYMACHINE_REPO)
.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(ADDR_LIST_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(ADDR_LIST_PACKAGE): node_modules
rm -fr $(ADDR_LIST_REPO)
git clone [email protected]:TERITORI/cw_addr_list.git
cd $(ADDR_LIST_REPO) && git checkout 01dad8e4ec2998c74145f7be0901630b3720787b
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(ADDR_LIST_REPO)/schema \
--out $@ \
--name $(ADDR_LIST_PACKAGE) \
--no-bundle
rm -fr $(ADDR_LIST_REPO)
.PHONY: publish.backend
publish.backend:
docker build -f go/cmd/teritori-dapp-backend/Dockerfile . --platform linux/amd64 -t $(BACKEND_DOCKER_IMAGE)
docker push $(BACKEND_DOCKER_IMAGE)
.PHONY: publish.flush-data
publish.flush-data:
docker build -f go/cmd/flush-data/Dockerfile . --platform linux/amd64 -t $(FLUSH_DATA_IMAGE)
docker push $(FLUSH_DATA_IMAGE)
.PHONY: publish.evm-indexer
publish.evm-indexer:
docker build -f go/cmd/evm-indexer/Dockerfile . --platform linux/amd64 -t $(EVM_INDEXER_IMAGE)
docker push $(EVM_INDEXER_IMAGE)
.PHONY: publish.indexer
publish.indexer:
docker build -f go/cmd/teritori-indexer/Dockerfile . --platform linux/amd64 -t $(INDEXER_DOCKER_IMAGE)
docker push $(INDEXER_DOCKER_IMAGE)
.PHONY: publish.prices-service
publish.prices-service:
docker build -f go/cmd/prices-service/Dockerfile . --platform linux/amd64 -t $(PRICES_SERVICE_DOCKER_IMAGE)
docker push $(PRICES_SERVICE_DOCKER_IMAGE)
.PHONY: publish.prices-ohlc-refresh
publish.prices-ohlc-refresh:
docker build -f go/cmd/prices-ohlc-refresh/Dockerfile . --platform linux/amd64 -t $(PRICES_OHLC_REFRESH_DOCKER_IMAGE)
docker push $(PRICES_OHLC_REFRESH_DOCKER_IMAGE)
.PHONY: generate.sqlboiler-prices
generate.sqlboiler-prices:
go install github.com/volatiletech/sqlboiler/v4@latest
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest
sqlboiler psql
.PHONY: publish.p2e-update-leaderboard
publish.p2e-update-leaderboard:
docker build -f go/cmd/p2e-update-leaderboard/Dockerfile . --platform linux/amd64 -t $(P2E_DOCKER_IMAGE)
docker push $(P2E_DOCKER_IMAGE)
.PHONY: publish.feed-clean-pinata-keys
publish.feed-clean-pinata-keys:
docker build -f go/cmd/feed-clean-pinata-keys/Dockerfile . --platform linux/amd64 -t $(FEED_DOCKER_IMAGE)
docker push $(FEED_DOCKER_IMAGE)
.PHONY: publish.multisig-backend
publish.multisig-backend:
docker build -f go/cmd/multisig-backend/Dockerfile . --platform linux/amd64 -t $(MULTISIG_DOCKER_IMAGE)
docker push $(MULTISIG_DOCKER_IMAGE)
.PHONY: publish.gno-indexer
publish.gno-indexer:
docker build -f go/cmd/gno_social_feed_indexer/Dockerfile . --platform linux/amd64 -t $(GNO_INDEXER_DOCKER_IMAGE)
docker push $(GNO_INDEXER_DOCKER_IMAGE)
.PHONY: validate-networks
validate-networks: node_modules
yarn validate-networks
.PHONY: networks.json
networks.json: node_modules validate-networks
npx tsx packages/scripts/generateJSONNetworks.ts > $@
.PHONY: unused-exports
unused-exports: node_modules
## TODO unexclude all paths except packages/api;packages/contracts-clients;packages/evm-contracts-clients
yarn unused-exports
.PHONY: prepare-electron
prepare-electron: node_modules
yarn rimraf ./dist
yarn cross-env isElectron=prod expo export -p web
yarn rimraf ./electron/web-build
mkdir ./electron/web-build
cp -r ./dist/* ./electron/web-build
yarn tsx ./packages/scripts/electron/fixHTML.ts
# requires prepare-electron
.PHONY: build-electron-mac-amd64
build-electron-macos-amd64:
rm -fr ./electron/dist
rm -fr ./electron/build
cd ./electron && npm i
cd ./weshd && GOOS=darwin GOARCH=amd64 $(GO) build -tags noNativeLogger -o ../electron/build/mac ./go/electron/prod.go
cd ./electron && node ./builder/mac.js amd64
# requires prepare-electron
.PHONY: build-electron-mac-arm64
build-electron-macos-arm64:
rm -fr ./electron/dist
rm -fr ./electron/build
cd ./electron && npm i
cd ./weshd && GOOS=darwin GOARCH=arm64 $(GO) build -tags noNativeLogger -o ../electron/build/mac ./go/electron/prod.go
cd ./electron && node ./builder/mac.js arm64
# requires prepare-electron
.PHONY: build-electron-win
build-electron-windows-amd64:
rm -fr ./electron/dist
rm -fr ./electron/build
cd ./electron && npm i
cd ./weshd && GOOS=windows GOARCH=amd64 $(GO) build -tags noNativeLogger -o ../electron/build/win.exe ./go/electron/prod.go
cd ./electron && node ./builder/win.js
# requires prepare-electron
.PHONY: build-electron-linux
build-electron-linux-amd64:
rm -fr ./electron/dist
rm -fr ./electron/build
cd ./electron && npm i
cd ./weshd && GOOS=linux GOARCH=amd64 $(GO) build -tags noNativeLogger -o ../electron/build/linux ./go/electron/prod.go
cd ./electron && node ./builder/linux.js
.PHONY: check-ios-weshframework
check-ios-weshframework:
@if [ ! -e ./weshd/ios/Frameworks/WeshFramework.xcframework ]; then \
echo "WeshFramework does not exist. Running a command to create it."; \
$(MAKE) build-ios-weshframework; \
fi
.PHONY: build-ios-weshframework
build-ios-weshframework:
$(MAKE) init-weshd-go
cd ./weshd && GOARCH=$(ARCH) gomobile bind -v \
-o ./ios/Frameworks/WeshFramework.xcframework \
-tags 'nowatchdog' -target ios \
./go/app
.PHONY: check-android-weshframework
check-android-weshframework:
@if [ ! -e ./weshd/android/libs/WeshFramework.aar ]; then \
echo "WeshFramework does not exist. Running a command to create it."; \
$(MAKE) build-android-weshframework; \
fi
.PHONY: build-android-weshframework
build-android-weshframework:
mkdir -p ./weshd/android/libs
$(MAKE) init-weshd-go
cd ./weshd && gomobile bind \
-javapkg=com.weshnet \
-o ./android/libs/WeshFramework.aar \
-tags 'nowatchdog' -target android -androidapi 23 \
./go/app
.PHONY: init-weshd-go
init-weshd-go:
cd ./weshd && go mod tidy
cd ./weshd && go get golang.org/x/mobile/cmd/gobind
cd ./weshd && go get golang.org/x/mobile/cmd/gomobile
cd ./weshd && go install golang.org/x/mobile/cmd/gobind
cd ./weshd && go install golang.org/x/mobile/cmd/gomobile
cd ./weshd && gomobile init
.PHONY: bump-app-build-number
bump-app-build-number:
npx tsx packages/scripts/app-build/bumpBuildNumber.ts $(shell echo $$(($$(git rev-list HEAD --count) + 10)))
.PHONY: test.rust
test.rust:
set -e ; \
for file in $(INTERNAL_COSMWASM_CONTRACTS); do \
echo "> Testing $${file}" ; \
cd $${file} ; \
cargo test ; \
cd - ; \
done
.PHONY: build.rust
build.rust:
set -e ; \
for file in $(INTERNAL_COSMWASM_CONTRACTS); do \
echo "> Building $${file}" ; \
cd $${file} ; \
cargo wasm ; \
cd - ; \
done
.PHONY: generate.internal-contracts-clients
generate.internal-contracts-clients: node_modules
set -e ; \
for indir in $(INTERNAL_COSMWASM_CONTRACTS) ; do \
echo "> Generating client for $${indir}" ; \
rm -fr $${indir}/schema ; \
cd $${indir} && cargo schema && cd - ; \
pkgname="$$(basename $${indir})" ; \
outdir="$(CONTRACTS_CLIENTS_DIR)/$${pkgname}" ; \
rm -fr $${outdir} ; \
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $${indir}/schema \
--out $${outdir} \
--name $${pkgname} \
--no-bundle \
;\
npx tsx packages/scripts/makeTypescriptIndex $${outdir} ; \
done
.PHONY: install-gno
install-gno: node_modules
yarn install-gno
.PHONY: start.gnodev
start.gnodev:
$(GNODEV)
.PHONY: start.gnodev-e2e
start.gnodev-e2e:
$(GNODEV_E2E)
.PHONY: clone-gno
clone-gno:
rm -fr gnobuild
mkdir -p gnobuild
cd gnobuild && git clone https://github.com/gnolang/gno.git && cd gno && git checkout $(shell $(CAT) .gnoversion)
cp -r ./gno/p ./gnobuild/gno/examples/gno.land/p/teritori
cp -r ./gno/r ./gnobuild/gno/examples/gno.land/r/teritori
.PHONY: build-gno
build-gno:
cd gnobuild/gno/gnovm && make build
.PHONY: lint-gno
lint-gno:
./gnobuild/gno/gnovm/build/gno lint ./gno/. -v
.PHONY: test-gno
test-gno:
./gnobuild/gno/gnovm/build/gno test ./gno/... -v
.PHONY: gno-mod-tidy
gno-mod-tidy:
export gno=$$(pwd)/gnobuild/gno/gnovm/build/gno; \
find gno -name gno.mod -type f | xargs -I'{}' sh -c 'cd $$(dirname {}); $$gno mod tidy' \;
.PHONY: clean-gno
clean-gno:
rm -rf gnobuild