Skip to content

Commit a6d4e05

Browse files
authored
Merge pull request #133 from Calebux/feat/deployment-scripts
Feat/deployment scripts
2 parents c7f2bc1 + 9d97b96 commit a6d4e05

33 files changed

+720
-284
lines changed

.eslintrc.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,19 @@
1616
"@typescript-eslint/no-explicit-any": "warn",
1717
"no-console": ["warn", { "allow": ["warn", "error"] }]
1818
},
19-
"ignorePatterns": ["node_modules/", "dist/", "android/", "ios/", ".expo/", "src/contracts/types/"]
19+
"ignorePatterns": [
20+
"node_modules/",
21+
"dist/",
22+
"android/",
23+
"ios/",
24+
".expo/",
25+
"src/contracts/types/"
26+
],
27+
"settings": {
28+
"import/resolver": {
29+
"node": {
30+
"extensions": [".js", ".jsx", ".ts", ".tsx"]
31+
}
32+
}
33+
}
2034
}

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ contracts/target/
2323
# Backup/fixed package snapshots
2424
package-fixed.json
2525
package.json.backup
26+
# GitHub API response dumps (UTF-16 encoded)
27+
issue*.json
28+
issues_summary.json

CONTRIBUTING.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ Thank you for taking the time to contribute SubTracker. This document covers eve
1919

2020
### Prerequisites
2121

22-
| Tool | Version | Purpose |
23-
|------|---------|---------|
24-
| Node.js | 20+ | Mobile app development |
25-
| npm | bundled with Node | Package management |
26-
| Rust | 1.77+ | Smart contract development |
27-
| Expo CLI | latest | Running and building the app |
28-
| Soroban CLI | latest | Deploying/interacting with contracts |
22+
| Tool | Version | Purpose |
23+
| ----------- | ----------------- | ------------------------------------ |
24+
| Node.js | 20+ | Mobile app development |
25+
| npm | bundled with Node | Package management |
26+
| Rust | 1.77+ | Smart contract development |
27+
| Expo CLI | latest | Running and building the app |
28+
| Soroban CLI | latest | Deploying/interacting with contracts |
2929

3030
### Mobile App Setup
3131

@@ -60,11 +60,11 @@ npm run contracts:test
6060

6161
Create a `.env` file at the project root if needed:
6262

63-
| Variable | Description |
64-
|----------|-------------|
65-
| `STELLAR_NETWORK` | `testnet` or `public` |
66-
| `CONTRACT_ID` | Deployed Soroban subscription contract ID |
67-
| `WEB3AUTH_CLIENT_ID` | Web3Auth client ID for social login |
63+
| Variable | Description |
64+
| -------------------- | ----------------------------------------- |
65+
| `STELLAR_NETWORK` | `testnet` or `public` |
66+
| `CONTRACT_ID` | Deployed Soroban subscription contract ID |
67+
| `WEB3AUTH_CLIENT_ID` | Web3Auth client ID for social login |
6868

6969
### Generating Contract TypeScript Types
7070

@@ -149,17 +149,17 @@ This project uses **Conventional Commits**. Every commit message must follow thi
149149

150150
### Types
151151

152-
| Type | When to use |
153-
|------|-------------|
154-
| `feat` | New feature |
155-
| `fix` | Bug fix |
156-
| `chore` | Maintenance, dependency updates, tooling |
157-
| `docs` | Documentation only |
152+
| Type | When to use |
153+
| ---------- | ----------------------------------------------- |
154+
| `feat` | New feature |
155+
| `fix` | Bug fix |
156+
| `chore` | Maintenance, dependency updates, tooling |
157+
| `docs` | Documentation only |
158158
| `refactor` | Code change that is neither a fix nor a feature |
159-
| `test` | Adding or updating tests |
160-
| `style` | Formatting, whitespace — no logic change |
161-
| `ci` | CI/CD configuration changes |
162-
| `perf` | Performance improvement |
159+
| `test` | Adding or updating tests |
160+
| `style` | Formatting, whitespace — no logic change |
161+
| `ci` | CI/CD configuration changes |
162+
| `perf` | Performance improvement |
163163

164164
### Scope (optional but encouraged)
165165

@@ -210,10 +210,10 @@ refactor/wallet-service-error-handling
210210

211211
### Protected Branches
212212

213-
| Branch | Purpose |
214-
|--------|---------|
215-
| `main` | Production-ready code — all CI must pass, PR required |
216-
| `dev` / `develop` | Integration branch — CI required |
213+
| Branch | Purpose |
214+
| ----------------- | ----------------------------------------------------- |
215+
| `main` | Production-ready code — all CI must pass, PR required |
216+
| `dev` / `develop` | Integration branch — CI required |
217217

218218
Never commit directly to `main`. All changes must go through a pull request.
219219

@@ -232,16 +232,16 @@ Never commit directly to `main`. All changes must go through a pull request.
232232

233233
All of the following CI jobs must pass before a PR can be merged:
234234

235-
| Check | Command |
236-
|-------|---------|
237-
| Prettier format | `npm run format:check` |
238-
| ESLint | `npm run lint` |
239-
| TypeScript type check | `npm run typecheck` |
240-
| Jest tests | `npm test` |
241-
| Expo build | `npm run build` |
242-
| Rust formatting | `npm run contracts:fmt` |
243-
| Rust Clippy | `npm run contracts:clippy` |
244-
| Rust tests | `npm run contracts:test` |
235+
| Check | Command |
236+
| --------------------- | -------------------------- |
237+
| Prettier format | `npm run format:check` |
238+
| ESLint | `npm run lint` |
239+
| TypeScript type check | `npm run typecheck` |
240+
| Jest tests | `npm test` |
241+
| Expo build | `npm run build` |
242+
| Rust formatting | `npm run contracts:fmt` |
243+
| Rust Clippy | `npm run contracts:clippy` |
244+
| Rust tests | `npm run contracts:test` |
245245

246246
### PR Checklist
247247

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ SubTrackr/
6868
### 1. Clone the Repository
6969

7070
First, clone the repository to your local machine:
71+
7172
```bash
7273
git clone https://github.com/Smartdevs17/SubTrackr.git
7374
cd SubTrackr
@@ -76,30 +77,36 @@ cd SubTrackr
7677
### 2. Install Prerequisites
7778

7879
#### Required for all development:
80+
7981
- **Node.js 20+**: We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage Node.js versions:
82+
8083
```bash
8184
# Install nvm (if not already installed)
8285
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
83-
86+
8487
# Install and use Node.js 20
8588
nvm install 20
8689
nvm use 20
8790
```
91+
8892
- **Expo CLI**: Install the Expo command line tools globally:
8993
```bash
9094
npm install -g expo-cli
9195
```
9296
- **Freighter Wallet**: Install the [Freighter Wallet](https://freighter.app/) browser extension for Stellar transaction signing.
9397

9498
#### Required only for smart contract development:
99+
95100
- **Rust**: Install Rust and the WASM target:
101+
96102
```bash
97103
# Install Rust (if not already installed)
98104
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
99-
105+
100106
# Add WASM target
101107
rustup target add wasm32-unknown-unknown
102108
```
109+
103110
- **Soroban CLI**: Install the Soroban command line tools:
104111
```bash
105112
cargo install --locked soroban-cli
@@ -108,21 +115,23 @@ cd SubTrackr
108115
### 3. Configure Environment Variables
109116

110117
Create a `.env` file in the root directory of the project:
118+
111119
```bash
112120
cp .env.example .env
113121
```
114122

115123
> **Note**: If `.env.example` doesn't exist, create a new `.env` file with the following variables:
116124
117-
| Variable | Description | Example Value |
118-
| -------------------- | ----------------------------------------- | ------------------------------------------ |
119-
| `STELLAR_NETWORK` | `testnet` or `public` Stellar network | `testnet` |
120-
| `CONTRACT_ID` | Deployed Soroban subscription contract ID | `CB64...` (your deployed contract address) |
125+
| Variable | Description | Example Value |
126+
| -------------------- | ----------------------------------------- | ----------------------------------------------------------------- |
127+
| `STELLAR_NETWORK` | `testnet` or `public` Stellar network | `testnet` |
128+
| `CONTRACT_ID` | Deployed Soroban subscription contract ID | `CB64...` (your deployed contract address) |
121129
| `WEB3AUTH_CLIENT_ID` | Web3Auth client ID for social login | Get one from [Web3Auth Dashboard](https://dashboard.web3auth.io/) |
122130

123131
### 4. Run the Mobile App
124132

125133
Install dependencies and start the Expo development server:
134+
126135
```bash
127136
# Install dependencies
128137
npm install
@@ -132,13 +141,15 @@ npx expo start
132141
```
133142

134143
You can then run the app on:
144+
135145
- **iOS Simulator**: Press `i` in the Expo terminal
136146
- **Android Emulator**: Press `a` in the Expo terminal
137147
- **Physical Device**: Scan the QR code with the Expo Go app (iOS/Android)
138148

139149
### 5. (Optional) Deploy Smart Contracts
140150

141151
If you want to work on the smart contracts:
152+
142153
```bash
143154
# Navigate to contracts directory
144155
cd contracts
@@ -153,6 +164,7 @@ soroban contract deploy --wasm target/wasm32-unknown-unknown/release/subtrackr.w
153164
### 6. Run Tests
154165

155166
Run the test suite to ensure everything is working correctly:
167+
156168
```bash
157169
# Run unit tests
158170
npm test
@@ -220,4 +232,4 @@ npm run release:dry-run
220232

221233
## License
222234

223-
MIT
235+
MIT

contracts/DEPLOYMENT.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SubTrackr Contract Deployment Guide
2+
3+
This guide describes how to deploy SubTrackr smart contracts to various Stellar networks using the provided automation scripts.
4+
5+
## Prerequisites
6+
7+
- [Soroban CLI](https://developers.stellar.org/docs/smart-contracts/getting-started/setup#install-the-soroban-cli) installed.
8+
- [Rust](https://rustup.rs/) and `wasm32-unknown-unknown` target installed.
9+
- A Stellar account with enough XLM for the target network.
10+
11+
## Deployment Scripts
12+
13+
All scripts are located in the `scripts/` directory at the project root.
14+
15+
### 1. Local Deployment
16+
17+
For development and testing on a local Soroban network.
18+
19+
```bash
20+
./scripts/deploy-local.sh
21+
```
22+
23+
**Note**: Assumes a local network is running and an identity `alice` exists.
24+
25+
### 2. Testnet Deployment
26+
27+
For deploying to the Stellar Testnet.
28+
29+
```bash
30+
export SOROBAN_ACCOUNT="your-testnet-account-name"
31+
export ADMIN_ADDRESS="GB..."
32+
./scripts/deploy-testnet.sh
33+
```
34+
35+
### 3. Mainnet Deployment
36+
37+
For deploying to the Stellar Public network (Mainnet).
38+
39+
```bash
40+
export SOROBAN_ACCOUNT="your-mainnet-account-name"
41+
export ADMIN_ADDRESS="GD..."
42+
./scripts/deploy-mainnet.sh
43+
```
44+
45+
**⚠️ WARNING**: Mainnet deployment costs real XLM. Ensure you have sufficient funds and have reviewed the contract code.
46+
47+
## Environment Variables
48+
49+
| Variable | Description | Required For |
50+
|---|---|---|
51+
| `SOROBAN_ACCOUNT` | The identity name (configured in Soroban CLI) or secret key to use for deployment. | Testnet, Mainnet |
52+
| `ADMIN_ADDRESS` | The Stellar address that will be set as the contract admin during initialization. | Testnet, Mainnet |
53+
54+
## Verification
55+
56+
After deployment, you can verify that the contract is active by running:
57+
58+
```bash
59+
./scripts/verify.sh <CONTRACT_ID> <NETWORK>
60+
```
61+
62+
Replace `<CONTRACT_ID>` with the ID returned by the deployment script and `<NETWORK>` with `local`, `testnet`, or `public`.
63+
64+
## Rollback Procedure
65+
66+
Since smart contracts on Soroban are immutable (unless explicitly designed otherwise), a "rollback" typically involves:
67+
68+
1. Fixing the issue in the contract source code.
69+
2. Deploying a new version of the contract.
70+
3. Updating the application (frontend/backend) to use the new `CONTRACT_ID`.
71+
72+
Ensure you keep track of the `CONTRACT_ID` for each deployment (these are automatically saved to `contracts/.env.<network>`).

contracts/test_snapshots/test/test_cancel_subscription.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,4 +1185,4 @@
11851185
"failed_call": false
11861186
}
11871187
]
1188-
}
1188+
}

contracts/test_snapshots/test/test_charge_paused_subscription.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,4 +1065,4 @@
10651065
"failed_call": false
10661066
}
10671067
]
1068-
}
1068+
}

contracts/test_snapshots/test/test_charge_subscription_not_due.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,4 +956,4 @@
956956
"failed_call": false
957957
}
958958
]
959-
}
959+
}

contracts/test_snapshots/test/test_create_plan_and_subscribe.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,4 +1178,4 @@
11781178
"failed_call": false
11791179
}
11801180
]
1181-
}
1181+
}

contracts/test_snapshots/test/test_double_subscribe.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,4 +969,4 @@
969969
"failed_call": false
970970
}
971971
]
972-
}
972+
}

0 commit comments

Comments
 (0)