forked from vestflow-labs/vestflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
168 lines (153 loc) · 6 KB
/
Copy pathMakefile
File metadata and controls
168 lines (153 loc) · 6 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
# =============================================================================
# VestFlow — Hardhat-style task runner
# Targets: build, optimize, deploy, upgrade, create-schedule, claim, revoke
#
# Environment variables (with defaults):
# NETWORK = testnet | mainnet (default: testnet)
# RPC_URL = Soroban RPC endpoint
# SOURCE = Stellar CLI key identity / seed
# CONTRACT_ID = Deployed contract ID
# =============================================================================
SHELL := /usr/bin/env bash
.DEFAULT_GOAL := help
# ── Config (overridable via env) ─────────────────────────────────────────────
NETWORK ?= testnet
RPC_URL ?= https://soroban-testnet.stellar.org
SOURCE ?= $(or $(STELLAR_ACCOUNT),admin)
CONTRACT_ID ?= $(NEXT_PUBLIC_CONTRACT_ID)
ifeq ($(NETWORK),mainnet)
NETWORK_PASSPHRASE := "Public Global Stellar Network ; September 2015"
else
NETWORK_PASSPHRASE := "Test SDF Network ; September 2015"
endif
WASM_PATH := contracts/target/wasm32v1-none/release/vestflow.wasm
OPT_WASM_PATH := contracts/target/wasm32v1-none/release/vestflow.optimized.wasm
# ── Help ─────────────────────────────────────────────────────────────────────
help:
@echo "Usage: make <target> [NETWORK=mainnet] [CONTRACT_ID=...]"
@echo ""
@echo "Targets:"
@echo " build Build release WASM"
@echo " optimize Build and optimize release WASM"
@echo " cost Profile a read-only entry point with stellar contract invoke --cost"
@echo " deploy Build, optimize, and deploy the VestFlow contract"
@echo " upload-wasm Upload optimized WASM and print the WASM hash"
@echo " announce-upgrade Announce a WASM hash for the configured contract"
@echo " execute-upgrade Execute the announced upgrade after the timelock"
@echo " create-schedule Create a new vesting schedule"
@echo " claim Claim vested tokens for a schedule"
@echo " revoke Revoke a vesting schedule"
@echo ""
@echo "Variables:"
@echo " NETWORK Network (testnet/mainnet, default: testnet)"
@echo " RPC_URL Soroban RPC URL"
@echo " SOURCE Stellar CLI key identity"
@echo " CONTRACT_ID Deployed contract ID"
@echo ""
@echo "Examples:"
@echo " make deploy"
@echo " make create-schedule NETWORK=mainnet CONTRACT_ID=CC..."
@echo " make claim CONTRACT_ID=CC... SCHEDULE_ID=1"
# ── Build ────────────────────────────────────────────────────────────────────
.PHONY: build
build:
cargo build --target wasm32v1-none --release --manifest-path contracts/Cargo.toml
.PHONY: optimize
optimize: build
stellar contract optimize \
--wasm $(WASM_PATH) \
--wasm-out $(OPT_WASM_PATH)
.PHONY: cost
cost:
stellar contract invoke --cost \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
$(METHOD) $(ARGS)
# ── Deploy ───────────────────────────────────────────────────────────────────
.PHONY: deploy
deploy: optimize
stellar contract deploy \
--wasm $(OPT_WASM_PATH) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE)
.PHONY: upload-wasm
upload-wasm: optimize
stellar contract upload \
--wasm $(OPT_WASM_PATH) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE)
.PHONY: announce-upgrade
announce-upgrade:
stellar contract invoke \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
announce_upgrade \
--authority $(SOURCE) \
--wasm-hash $(WASM_HASH)
.PHONY: execute-upgrade
execute-upgrade:
stellar contract invoke \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
execute_upgrade \
--authority $(SOURCE)
# ── Create Schedule ──────────────────────────────────────────────────────────
.PHONY: create-schedule
create-schedule:
stellar contract invoke \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
create_schedule \
--grantor $(GRANTOR) \
--beneficiary $(BENEFICIARY) \
--token $(TOKEN) \
--total-amount $(TOTAL_AMOUNT) \
--start-time $(START_TIME) \
--duration $(DURATION) \
--cliff-duration $(CLIFF_DURATION) \
--kind $(KIND) \
--revocable $(REVOCABLE)
# ── Claim ────────────────────────────────────────────────────────────────────
.PHONY: claim
claim:
stellar contract invoke \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
claim \
--schedule-id $(SCHEDULE_ID)
# ── Revoke ───────────────────────────────────────────────────────────────────
.PHONY: revoke
revoke:
stellar contract invoke \
--id $(CONTRACT_ID) \
--source $(SOURCE) \
--network $(NETWORK) \
--rpc-url $(RPC_URL) \
--network-passphrase $(NETWORK_PASSPHRASE) \
-- \
revoke \
--schedule-id $(SCHEDULE_ID)