Skip to content

Commit 7b1f134

Browse files
committed
merge: resolve conflicts with upstream/main
2 parents 0439154 + a37aff0 commit 7b1f134

11 files changed

Lines changed: 552 additions & 14 deletions

File tree

.husky/pre-push

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
#!/usr/bin/env sh
2-
npm test
2+
set -e
3+
4+
# Keep the pre-push hook developer-friendly on machines without Rust installed.
5+
npm run test --prefix soroban-client
6+
7+
if command -v cargo >/dev/null 2>&1; then
8+
cargo test --manifest-path soroban-contract/Cargo.toml --all-targets --all-features
9+
else
10+
echo "[pre-push] cargo not found; skipping Rust tests"
11+
fi

CLI.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# `tokenbound` CLI
2+
3+
Command-line tool to streamline **deployment, upgrade, and management** of the CrowdPass Soroban contracts.
4+
5+
## Prerequisites
6+
7+
- Node.js 18+
8+
- Soroban CLI installed (`soroban`)
9+
10+
## Install
11+
12+
From the repo root:
13+
14+
```bash
15+
npm install
16+
```
17+
18+
## Deploy contracts
19+
20+
```bash
21+
npm run tokenbound -- deploy --network testnet --source deployer
22+
```
23+
24+
Outputs a deployment JSON (default): `soroban-contract/deployments/<network>.json`
25+
26+
## Generic invoke
27+
28+
```bash
29+
npm run tokenbound -- invoke --id C... --fn version --source deployer
30+
```
31+
32+
Pass raw function arguments after `--args`:
33+
34+
```bash
35+
npm run tokenbound -- invoke --id C... --fn get_event --args --event_id 1 --source deployer
36+
```
37+
38+
## Upgrade management (upgradeable contracts)
39+
40+
Schedule an upgrade (timelocked):
41+
42+
```bash
43+
npm run tokenbound -- upgrade --id C... --source deployer schedule --new-wasm-hash <hash>
44+
```
45+
46+
Commit / cancel:
47+
48+
```bash
49+
npm run tokenbound -- upgrade --id C... --source deployer commit
50+
npm run tokenbound -- upgrade --id C... --source deployer cancel
51+
```
52+
53+
Pause / unpause:
54+
55+
```bash
56+
npm run tokenbound -- upgrade --id C... --source deployer pause
57+
npm run tokenbound -- upgrade --id C... --source deployer unpause
58+
```
59+
60+
Transfer admin:
61+
62+
```bash
63+
npm run tokenbound -- upgrade --id C... --source deployer transfer-admin --new-admin G...
64+
```

DEPLOYMENT.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,119 @@ Ensure you have the following installed:
1313
- Stellar CLI
1414
- A funded Stellar testnet account (via Friendbot)
1515

16+
### Recommended: Use the `tokenbound` CLI (cross-platform)
17+
18+
This repo includes a Node-based CLI that wraps the Soroban CLI and automates the dependency-ordered deployment.
19+
20+
From the repo root:
21+
22+
```bash
23+
npm install
24+
npm run tokenbound -- deploy --network testnet --source deployer
25+
```
26+
27+
Deployment output is written to `soroban-contract/deployments/<network>.json` by default.
28+
1629
### Install Soroban CLI
30+
1731
```bash
1832
cargo install --locked soroban-cli
1933
```
2034

2135
### Add WASM target
36+
2237
```bash
2338
rustup target add wasm32-unknown-unknown
2439
```
40+
2541
### 2. Setup Environment
42+
2643
Create environment variables:
44+
2745
```bash
2846
export NETWORK=testnet
2947
export SOROBAN_RPC_URL="https://soroban-testnet.stellar.org"
3048
export ADMIN_SECRET_KEY="S..."
3149
export ADMIN_ADDRESS="G..."
3250
```
51+
3352
Fund your account:
53+
3454
```bash
3555
curl "https://friendbot.stellar.org?addr=$ADMIN_ADDRESS"
3656
```
3757

3858
### 3. Build Contracts
59+
3960
From the root directory:
61+
4062
```bash
4163
cargo build --target wasm32-unknown-unknown --release
4264
```
65+
4366
Optimise contracts:
67+
4468
```bash
4569
soroban contract optimize --wasm target/wasm32-unknown-unknown/release/*.wasm
4670
```
4771

4872
### 4. Deployment Order
73+
4974
Deploy contracts in the following order:
75+
5076
1. `ticket_factory`
5177
2. `event_manager`
5278
3. `tba_registry`
5379

5480
### 5. Deploy Contracts
81+
5582
**Deploy Ticket Factory**
83+
5684
```bash
5785
soroban contract deploy \
5886
--wasm <path_to_ticket_factory.wasm> \
5987
--source $ADMIN_SECRET_KEY \
6088
--rpc-url $SOROBAN_RPC_URL
6189
```
90+
6291
Save the returned Contract ID:
92+
6393
```bash
6494
export TICKET_FACTORY_ID="C..."
6595
```
96+
6697
**Deploy Event Manager**
98+
6799
```bash
68100
soroban contract deploy \
69101
--wasm <path_to_event_manager.wasm> \
70102
--source $ADMIN_SECRET_KEY \
71103
--rpc-url $SOROBAN_RPC_URL
72104
```
105+
73106
```bash
74107
export EVENT_MANAGER_ID="C..."
75108
```
109+
76110
**Deploy TBA Registry**
111+
77112
```bash
78113
soroban contract deploy \
79114
--wasm <path_to_tba_registry.wasm> \
80115
--source $ADMIN_SECRET_KEY \
81116
--rpc-url $SOROBAN_RPC_URL
82117
```
118+
83119
```bash
84120
export TBA_REGISTRY_ID="C..."
85121
```
86122

87123
### 6. Contract Initialization
124+
88125
Initialize each contract with required parameters.
89126

90127
Example:
128+
91129
```bash
92130
soroban contract invoke \
93131
--id $TICKET_FACTORY_ID \
@@ -96,42 +134,51 @@ soroban contract invoke \
96134
-- initialize \
97135
--admin $ADMIN_ADDRESS
98136
```
137+
99138
Repeat for other contracts using their respective parameters.
100139

101140
### 7. Verification Steps
141+
102142
After deployment:
143+
103144
- Confirm contract IDs are returned
104145
- Call a read method:
146+
105147
```bash
106148
soroban contract invoke \
107149
--id $TICKET_FACTORY_ID \
108150
--source $ADMIN_SECRET_KEY \
109151
--rpc-url $SOROBAN_RPC_URL \
110152
-- some_view_function
111153
```
154+
112155
- Ensure no errors are returned
113156
- Check events on Soroban explorer
114157

115-
116158
### 8. Troubleshooting
159+
117160
**Contract fails to deploy**
161+
118162
- Ensure account has enough XLM
119163
- Check RPC URL
120164

121165
**WASM not found**
166+
122167
- Ensure build step completed successfully
123168

124169
**Initialization fails**
170+
125171
- Ensure correct parameters are passed
126172
- Check contract already initialized
127173

128174
**CLI errors**
175+
129176
```bash
130177
soroban --version
131178
```
132179

133180
### 9. Notes
181+
134182
- Always deploy in the correct order
135183
- Store contract IDs securely
136184
- Never expose secret keys in code
137-

package-lock.json

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "tokenbound-impl",
33
"private": true,
4+
"bin": {
5+
"tokenbound": "scripts/tokenbound-cli.mjs"
6+
},
47
"scripts": {
58
"prepare": "husky",
69
"precommit": "lint-staged && npm run precommit:rust",
@@ -11,7 +14,11 @@
1114
"format:check": "npm run format:check:js && npm run format:check:rust",
1215
"format:check:js": "prettier --check .",
1316
"format:check:rust": "cargo fmt --manifest-path soroban-contract/Cargo.toml --all --check",
14-
"test": "npm run test --prefix soroban-client && cargo test --manifest-path soroban-contract/Cargo.toml --all-targets --all-features"
17+
"test": "npm run test --prefix soroban-client && cargo test --manifest-path soroban-contract/Cargo.toml --all-targets --all-features",
18+
"tokenbound": "node scripts/tokenbound-cli.mjs"
19+
},
20+
"dependencies": {
21+
"commander": "^14.0.1"
1522
},
1623
"devDependencies": {
1724
"husky": "^9.1.7",

0 commit comments

Comments
 (0)