-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathMakefile
More file actions
417 lines (357 loc) · 12.1 KB
/
Copy pathMakefile
File metadata and controls
417 lines (357 loc) · 12.1 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
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
.PHONY: help install prepare rust-lint clean testnet_reset contract_build contract_test contract_deploy contract_help pre_push_hook
.DEFAULT_GOAL := help
SHELL:=/bin/bash
ifndef network
override network = testnet
endif
ifndef admin
override admin = tansu-$(network)
endif
ifndef wasm
override wasm = target/wasm32v1-none/release/tansu.wasm
endif
ifndef wasm-scf_membership
override wasm-scf_membership = target/wasm32v1-none/release/scf_membership.wasm
endif
override tansu_id = $(shell cat .stellar/tansu_id-$(network))
override scf_membership_id = $(shell cat .stellar/scf_membership_id-$(network))
override collateral_contract_id = $(shell stellar contract id asset --asset native --network $(network))
override nqg_contract_id = CAM3VZX47TCQWCEYGXEDTSIJYKIVM6AWMFR7VTFYTETXFO53I5LOZGBT
override nqg_wasm_hash = c845605a5997fa425cc769dbb50d1b208e78806efaba243e174a950f1f4ae79c
# Add help text after each target name starting with '\#\#'
help: ## show this help
@echo -e "Help for this makefile\n"
@echo "Possible commands are:"
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/ \1: \2/'
install: ## install Rust and Soroban-CLI
# uv for the pre-push hook
curl -LsSf https://astral.sh/uv/install.sh | sh && \
uv tool install pre-commit --with pre-commit-uv && \
# install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && \
# install Soroban and config
rustup target add wasm32v1-none && \
cargo install --locked stellar-cli
prepare-network: ## Setup network
ifeq ($(network),testnet)
stellar network add testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015"
else ifeq ($(network),mainnet)
stellar network add mainnet \
--rpc-url https://rpc.lightsail.network/ \
--network-passphrase "Public Global Stellar Network ; September 2015"
else
stellar network add testnet-local \
--rpc-url http://localhost:8000/soroban/rpc \
--network-passphrase "Standalone Network ; February 2017"
endif
prepare: prepare-network ## Setup network and generate addresses and add funds
stellar keys generate grogu-$(network) --network $(network) && \
stellar keys generate $(admin) --network $(network)
funds:
stellar keys fund grogu-$(network) --network $(network) && \
stellar keys fund $(admin) --network $(network)
rust-lint:
cargo clippy --all-targets --all-features -- -Dwarnings
cargo fmt -- --emit files
clean:
rm target/wasm32v1-none/release/*.wasm
rm target/wasm32v1-none/release/*.d
cargo clean
# --------- Events --------- #
events_test:
echo 0
# --------- Fullstack --------- #
local-stack: ## local stack
docker compose up
# --------- CONTRACT BUILD/TEST/DEPLOY --------- #
contract_build:
stellar contract build --optimize
@ls -l target/wasm32v1-none/release/*.wasm
contract_test:
cargo test
# --contract-id $(tansu_id-$(network))
contract_bindings: contract_build ## Create bindings
stellar contract bindings typescript \
--network $(network) \
--wasm $(wasm) \
--output-dir dapp/packages/tansu \
--overwrite && \
cd dapp/packages/tansu && \
bun install --latest && \
bun update --latest && \
bun run build && \
cd ../../.. && \
stellar contract bindings typescript \
--network $(network) \
--wasm $(wasm-scf_membership) \
--output-dir dapp/packages/scf-membership \
--overwrite && \
cd dapp/packages/scf-membership && \
bun install --latest && \
bun update --latest && \
bun run build && \
cd ../.. && \
bun format
contract_deploy: ## Deploy Soroban contract
stellar contract deploy \
--wasm $(wasm) \
--source-account $(admin) \
--network $(network) \
--salt $(shell printf tansu | openssl sha256 | cut -d " " -f2) \
--inclusion-fee 200000000 \
--cost \
-- \
--admin $(shell stellar keys address $(admin)) \
> .stellar/tansu_id-$(network) && \
cat .stellar/tansu_id-$(network)
contract_unpause: ## Unpause the contract
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
pause \
--admin $(shell stellar keys address $(admin)) \
--paused false
contract_propose_upgrade: contract_build ## After manually pulling the wasm from the pipeline, use it to propose to update the contract
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
propose_upgrade \
--admin $(shell stellar keys address $(admin)) \
--new_wasm_hash $(shell stellar contract upload --source-account $(admin) --network $(network) --wasm $(wasm)) \
--new_admins_config '{"threshold":1,"admins":["$(shell stellar keys address $(admin))","GBMGZFAHF7IS4XTKMH5TMKDGEZL64GXOKCWX7QVMV3J67QDC4L7E5BFD"]}'
contract_approve_upgrade: ## Approve the current upgrade proposal
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
approve_upgrade \
--admin $(shell stellar keys address $(admin))
contract_finalize_upgrade: ## Execute the approved upgrade proposal
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
finalize_upgrade \
--admin $(shell stellar keys address $(admin)) \
--accept true
contract_get_upgrade_proposal: ## Get the current upgrade proposal
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
get_upgrade_proposal
# --------- Radicle --------- #
radicle_push:
git push rad main
radicle_ci: ## Run test and register the results on Radicle
.radicle/ci.sh
radicle_release: ## Publish a release on Radicle
.radicle/release.sh
# --------- Setup --------- #
contract_set_collateral_contract: ## Set the collateral contract address
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
set_collateral_contract \
--admin $(shell stellar keys address $(admin)) \
--collateral_contract '{"address":"$(collateral_contract_id)","wasm_hash":null}'
contract_set_nqg_contract: ## Set the NQG contract address and project using it
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
set_nqg_contract \
--admin $(shell stellar keys address $(admin)) \
--nqg_contract '{"address":"$(nqg_contract_id)","wasm_hash":"$(nqg_wasm_hash)"}' \
--project stellarpg
# --------- Testnet --------- #
testnet_reset: ## Playbook for testnet reset
make funds && \
make contract_bindings && \
make contract_deploy && \
make contract_set_collateral_contract && \
make contract_unpause && \
make contract_register && \
make contract_commit
# --------- CONTRACT USAGE EXAMPLES --------- #
contract_help:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
--help
contract_version:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
version
# bafybeift4uou7f4qdrchrbwebxxvgf2ecmx56qqo6l2fyimmr4skb3iibi for salib
contract_register:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
register \
--maintainer $(shell stellar keys address $(admin)) \
--name tansu \
--maintainers '["$(shell stellar keys address $(admin))", "$(shell stellar keys address grogu-$(network))"]' \
--url https://radicle.network/nodes/radicle.consulting-manao.com/rad%3AzssaAF91kxuquZmZCV2SiK2FNX6s \
--ipfs bafybeicnbbhyc4vhbuokk57lrmg4hkbvkmtcp6p3ubaptbus6kl2idthki
contract_commit:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
commit \
--maintainer $(shell stellar keys address $(admin)) \
--project_key 37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156 \
--hash bc4d84f2b00501ce6c176d797371f65799838720
contract_get_commit:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
get_commit \
--project_key 37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156
contract_get_max_weight:
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
get_max_weight \
--project_key 37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156 \
--member_address $(admin)
# Generate an artifact, upload it to IPFS, and record its CID on-chain.
# Requires FILEBASE_TOKEN (or TANSU_IPFS_UPLOAD_COMMAND) in the environment.
# Override kind/commit/file on the command line, e.g.
# make contract_set_evidence kind=cve file=artifacts/trivy-results.json
ifndef kind
override kind = sbom
endif
ifndef commit
override commit = bc4d84f2b00501ce6c176d797371f65799838720
endif
ifndef file
override file = artifacts/sbom.cyclonedx.json
endif
contract_set_evidence: ## Upload an evidence artifact to IPFS and record its CID on-chain
tools/evidence/publish.sh \
--project-key 37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156 \
--commit-hash $(commit) \
--kind $(kind) \
--file $(file) \
--network $(network) \
--contract-id $(tansu_id) \
--source-account $(admin) \
--maintainer $(shell stellar keys address $(admin))
contract_get_evidence: ## Read the stored evidence history for a commit and kind
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(tansu_id) \
-- \
get_evidence \
--project_key 37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156 \
--commit_hash $(commit) \
--kind Sbom
# --------- Hook --------- #
pre_push_hook:
TANSU_CONTRACT_ID=$(tansu_id) \
TANSU_PROJECT_KEY=37ae83c06fde1043724743335ac2f3919307892ee6307cce8c0c63eaa549e156 \
uv run --with soroban pre-commit/tansu_pre_push.py
# --------- NQG --------- #
nqg:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(nqg_contract_id) \
-- \
get_voting_power_for_user \
--user $(admin)
# --------- NFT --------- #
contract_deploy_nft: contract_build ## Deploy NFT contract
stellar contract deploy \
--wasm $(wasm-scf_membership) \
--source-account $(admin) \
--network $(network) \
--salt $(shell printf scf-nft | openssl sha256 | cut -d " " -f2) \
--inclusion-fee 200000000 \
--cost \
-- \
--admin $(shell stellar keys address $(admin)) \
--name "SCF Membership" --symbol scf \
--uri https://ipfs.io/ipfs/QmVTqJ4EzJThVWobgyaWCetcrXCjftQhgi24E4giJ5EgXr \
--uri_trait https://ipfs.io/ipfs/Qmddf2UgGTQ3z2SZfg2ziZJzDJDRS3Dk7Z3phZ76fMzdLf \
--nqg_contract $(nqg_contract_id) \
> .stellar/scf_membership_id-$(network) && \
cat .stellar/scf_membership_id-$(network)
contract_upgrade_nft: contract_build ## After manually pulling the wasm from the pipeline, use it to propose to update the contract
stellar contract invoke \
--source-account $(admin) \
--network $(network) \
--id $(scf_membership_id) \
-- \
upgrade \
--wasm_hash $(shell stellar contract upload --source-account $(admin) --network $(network) --wasm $(wasm-scf_membership))
contract_nft_mint:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(scf_membership_id) \
-- \
mint \
--to $(admin)
contract_nft_role:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(scf_membership_id) \
-- \
set_trait \
--token_id 0 \
--trait_key role \
--new_value 3
contract_nft_governance:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(scf_membership_id) \
-- \
governance \
--token_id 0
contract_nft_uri:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(scf_membership_id) \
-- \
token_uri \
--token_id 0
contract_nft_trait_value:
stellar contract invoke \
--source-account $(admin) \
--network testnet \
--id $(scf_membership_id) \
-- \
trait_value \
--token_id 0 \
--trait_key role