forked from SO4-Markets/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.mk
More file actions
75 lines (59 loc) · 3.34 KB
/
Copy pathdeploy.mk
File metadata and controls
75 lines (59 loc) · 3.34 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
# Deployment workflows.
DRY_RUN ?= 0
.PHONY: deploy deploy-all deploy-contract deploy-force deploy-testnet deploy-mainnet deploy-local addresses
deploy: deploy-all
deploy-all: preflight
CONTRACT="$(CONTRACT)" DRY_RUN="$(DRY_RUN)" bash scripts/deploy.sh "$(NETWORK)" "$(SOURCE)"
deploy-force: preflight
CONTRACT="$(CONTRACT)" FORCE=1 DRY_RUN="$(DRY_RUN)" bash scripts/deploy.sh "$(NETWORK)" "$(SOURCE)"
deploy-contract: preflight build
@test -n "$(CONTRACT)" || { printf '%s\n' 'Usage: make deploy-contract CONTRACT=reader NETWORK=testnet SOURCE=deployer'; exit 1; }
@case "$(CONTRACT)" in \
test_token|test_faucet) [ "$(NETWORK)" != "mainnet" ] || \
{ printf 'ERROR: %s must not be deployed to mainnet. Use real SAC IDs instead.\n' "$(CONTRACT)" >&2; exit 1; } ;; \
esac
@test -f "$(WASM_DIR)/$(CONTRACT).wasm" || { printf 'Missing wasm: %s/%s.wasm\n' "$(WASM_DIR)" "$(CONTRACT)"; exit 1; }
wasm_hash="$$(stellar contract upload --wasm "$(WASM_DIR)/$(CONTRACT).wasm" --source "$(SOURCE)" --network "$(NETWORK)")"
contract_id="$$(stellar contract deploy --wasm-hash "$$wasm_hash" --source "$(SOURCE)" --network "$(NETWORK)")"
printf '%s deployed at %s\n' "$(CONTRACT)" "$$contract_id"
printf '%s\n' 'This standalone deploy did not update $(DEPLOY_ENV). Initialize and wire it manually, or use upgrade-contract for an existing protocol deployment.'
deploy-testnet:
$(MAKE) deploy-all NETWORK=testnet SOURCE="$(SOURCE)"
deploy-mainnet:
$(MAKE) deploy-all NETWORK=mainnet SOURCE="$(SOURCE)"
deploy-local:
$(MAKE) deploy-all NETWORK=local SOURCE="$(SOURCE)"
addresses:
@test -f "$(DEPLOY_ENV)" || { printf 'Missing %s. Run make deploy-all first.\n' "$(DEPLOY_ENV)"; exit 1; }
@sed -n '1,220p' "$(DEPLOY_ENV)"
# ── Post-deployment bootstrap ─────────────────────────────────────────────────
#
# Runs after deploy-all to:
# 1. Grant keeper roles to SOURCE (or KEEPER=<key>)
# 2. Create a market via market_factory
# 3. Set per-market config keys in data_store
# 4. Print instructions for seeding liquidity
#
# Example (full fresh testnet bootstrap):
# make token-bootstrap CODE=TWBTC NETWORK=testnet SOURCE=alice
# make token-bootstrap CODE=TUSDC NETWORK=testnet SOURCE=alice
# make deploy-all NETWORK=testnet SOURCE=alice
# make bootstrap NETWORK=testnet SOURCE=alice LONG_CODE=TWBTC SHORT_CODE=TUSDC
KEEPER ?= $(SOURCE)
LONG_CODE ?= TWBTC
SHORT_CODE ?= TUSDC
.PHONY: bootstrap market-init seed-liquidity
bootstrap: preflight
KEEPER="$(KEEPER)" LONG_CODE="$(LONG_CODE)" SHORT_CODE="$(SHORT_CODE)" \
bash scripts/bootstrap.sh "$(NETWORK)" "$(SOURCE)"
market-init: preflight
KEEPER="$(KEEPER)" LONG_CODE="$(LONG_CODE)" SHORT_CODE="$(SHORT_CODE)" \
SKIP_ROLES=1 SKIP_CONFIG=0 SKIP_SEED=1 \
bash scripts/bootstrap.sh "$(NETWORK)" "$(SOURCE)"
seed-liquidity: preflight
@test -f "$(DEPLOY_ENV)" || { printf 'Missing %s. Run make deploy-all first.\n' "$(DEPLOY_ENV)"; exit 1; }
@. "$(DEPLOY_ENV)"; \
test -n "$$MARKET_TOKEN" || { printf 'MARKET_TOKEN not set in %s. Run make bootstrap first.\n' "$(DEPLOY_ENV)"; exit 1; }; \
printf 'Seed LONG_TOKEN (%s) amount=%s\n' "$(LONG_CODE)" "$(SEED_LONG)"; \
printf 'Seed SHORT_TOKEN (%s) amount=%s\n' "$(SHORT_CODE)" "$(SEED_SHORT)"; \
printf 'Edit scripts/bootstrap.sh SKIP_SEED section or call deposit_handler directly.\n'