@blu1606/create-walrus-app 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/context.js +1 -0
  2. package/dist/generator/layers.js +3 -0
  3. package/dist/index.js +1 -0
  4. package/dist/post-install/index.js +5 -0
  5. package/dist/post-install/walrus-deploy.d.ts +6 -0
  6. package/dist/post-install/walrus-deploy.js +77 -0
  7. package/dist/prompts.js +17 -0
  8. package/dist/types.d.ts +1 -0
  9. package/package.json +1 -1
  10. package/presets/react-mysten-gallery/README.md +60 -0
  11. package/presets/react-mysten-gallery/package.json +2 -1
  12. package/presets/react-mysten-gallery/scripts/setup-walrus-deploy.sh +282 -0
  13. package/presets/react-mysten-simple-upload/README.md +60 -0
  14. package/presets/react-mysten-simple-upload/package.json +2 -1
  15. package/presets/react-mysten-simple-upload/scripts/setup-walrus-deploy.sh +286 -0
  16. package/presets/react-mysten-simple-upload-enoki/.env.example +40 -0
  17. package/presets/react-mysten-simple-upload-enoki/.gitkeep +4 -0
  18. package/presets/react-mysten-simple-upload-enoki/README.md +332 -0
  19. package/presets/react-mysten-simple-upload-enoki/index.html +13 -0
  20. package/presets/react-mysten-simple-upload-enoki/package.json +37 -0
  21. package/presets/react-mysten-simple-upload-enoki/scripts/setup-walrus-deploy.sh +286 -0
  22. package/presets/react-mysten-simple-upload-enoki/src/App.tsx +27 -0
  23. package/presets/react-mysten-simple-upload-enoki/src/components/features/enoki-auth-button.tsx +29 -0
  24. package/presets/react-mysten-simple-upload-enoki/src/components/features/file-preview.tsx +73 -0
  25. package/presets/react-mysten-simple-upload-enoki/src/components/features/upload-form.tsx +61 -0
  26. package/presets/react-mysten-simple-upload-enoki/src/components/features/wallet-connect.tsx +38 -0
  27. package/presets/react-mysten-simple-upload-enoki/src/components/layout/app-layout.tsx +21 -0
  28. package/presets/react-mysten-simple-upload-enoki/src/hooks/use-download.ts +24 -0
  29. package/presets/react-mysten-simple-upload-enoki/src/hooks/use-enoki-auth.ts +52 -0
  30. package/presets/react-mysten-simple-upload-enoki/src/hooks/use-upload.ts +45 -0
  31. package/presets/react-mysten-simple-upload-enoki/src/hooks/use-wallet.ts +32 -0
  32. package/presets/react-mysten-simple-upload-enoki/src/index.css +322 -0
  33. package/presets/react-mysten-simple-upload-enoki/src/index.ts +24 -0
  34. package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/constants.ts +23 -0
  35. package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/index.ts +6 -0
  36. package/presets/react-mysten-simple-upload-enoki/src/lib/enoki/storage-adapter.ts +31 -0
  37. package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/adapter.ts +197 -0
  38. package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/client.ts +87 -0
  39. package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/index.ts +4 -0
  40. package/presets/react-mysten-simple-upload-enoki/src/lib/walrus/types.ts +92 -0
  41. package/presets/react-mysten-simple-upload-enoki/src/main.tsx +19 -0
  42. package/presets/react-mysten-simple-upload-enoki/src/providers/EnokiProvider.tsx +23 -0
  43. package/presets/react-mysten-simple-upload-enoki/src/providers/QueryProvider.tsx +18 -0
  44. package/presets/react-mysten-simple-upload-enoki/src/providers/WalletProvider.tsx +52 -0
  45. package/presets/react-mysten-simple-upload-enoki/src/providers/index.ts +7 -0
  46. package/presets/react-mysten-simple-upload-enoki/src/utils/env.ts +41 -0
  47. package/presets/react-mysten-simple-upload-enoki/src/utils/mime-type.ts +97 -0
  48. package/presets/react-mysten-simple-upload-enoki/tsconfig.json +39 -0
  49. package/presets/react-mysten-simple-upload-enoki/tsconfig.node.json +10 -0
  50. package/presets/react-mysten-simple-upload-enoki/vite.config.ts +19 -0
@@ -0,0 +1,286 @@
1
+ #!/bin/bash
2
+ # setup-walrus-deploy.sh - Zero-config Walrus Sites deployment setup (testnet)
3
+ # Auto-installs dependencies, downloads tools, clones portal
4
+ # Supports: Linux, macOS, Windows (Git Bash/WSL)
5
+
6
+ set -e # Exit on error
7
+
8
+ echo "🦭 Walrus Sites Zero-Config Setup (testnet)"
9
+ echo ""
10
+
11
+ # ============================================================================
12
+ # 1. Detect OS & Architecture
13
+ # ============================================================================
14
+ detect_os() {
15
+ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
16
+ ARCH=$(uname -m)
17
+
18
+ case "$OS" in
19
+ linux*) OS_TYPE="linux" ;;
20
+ darwin*) OS_TYPE="macos" ;;
21
+ mingw*|msys*|cygwin*) OS_TYPE="windows" ;;
22
+ *)
23
+ echo "❌ Unsupported OS: $OS"
24
+ exit 1
25
+ ;;
26
+ esac
27
+
28
+ echo "✅ Detected: $OS_TYPE ($ARCH)"
29
+ }
30
+
31
+ # ============================================================================
32
+ # 2. Auto-install Bun (if not exists)
33
+ # ============================================================================
34
+ setup_bun() {
35
+ if command -v bun &>/dev/null; then
36
+ echo "✅ Bun already installed: $(bun --version)"
37
+ return 0
38
+ fi
39
+
40
+ echo "📥 Installing Bun..."
41
+ if [ "$OS_TYPE" = "windows" ]; then
42
+ # Windows (PowerShell install via Git Bash)
43
+ powershell -c "irm bun.sh/install.ps1 | iex"
44
+ else
45
+ # Linux/macOS
46
+ curl -fsSL https://bun.sh/install | bash
47
+ fi
48
+
49
+ # Add to PATH for current session
50
+ if [ "$OS_TYPE" = "windows" ]; then
51
+ export PATH="$USERPROFILE/.bun/bin:$PATH"
52
+ else
53
+ export BUN_INSTALL="$HOME/.bun"
54
+ export PATH="$BUN_INSTALL/bin:$PATH"
55
+ fi
56
+
57
+ # Verify installation
58
+ if command -v bun &>/dev/null; then
59
+ echo "✅ Bun installed: $(bun --version)"
60
+ else
61
+ echo "⚠️ Bun installed but not in PATH. Restart terminal or run:"
62
+ echo " export PATH=\"\$HOME/.bun/bin:\$PATH\""
63
+ fi
64
+ }
65
+
66
+ # ============================================================================
67
+ # 3. Download site-builder binary (if not exists)
68
+ # ============================================================================
69
+ setup_site_builder() {
70
+ # Set install directory based on OS
71
+ if [ "$OS_TYPE" = "windows" ]; then
72
+ WALRUS_BIN="$USERPROFILE/.walrus/bin"
73
+ SITE_BUILDER="$WALRUS_BIN/site-builder.exe"
74
+ else
75
+ WALRUS_BIN="$HOME/.walrus/bin"
76
+ SITE_BUILDER="$WALRUS_BIN/site-builder"
77
+ fi
78
+
79
+ # Check if already exists
80
+ if [ -f "$SITE_BUILDER" ]; then
81
+ echo "✅ site-builder already exists: $SITE_BUILDER"
82
+ chmod +x "$SITE_BUILDER" 2>/dev/null || true
83
+ return 0
84
+ fi
85
+
86
+ echo "📥 Downloading site-builder for $OS_TYPE..."
87
+ mkdir -p "$WALRUS_BIN"
88
+
89
+ # Select binary based on OS
90
+ case "$OS_TYPE" in
91
+ linux) BINARY_NAME="site-builder-linux" ;;
92
+ macos) BINARY_NAME="site-builder-macos" ;;
93
+ windows) BINARY_NAME="site-builder-windows.exe" ;;
94
+ esac
95
+
96
+ DOWNLOAD_URL="https://github.com/MystenLabs/walrus-sites/releases/latest/download/$BINARY_NAME"
97
+
98
+ # Download with retry
99
+ if ! curl -fsSL -o "$SITE_BUILDER" "$DOWNLOAD_URL"; then
100
+ echo "❌ Failed to download site-builder from: $DOWNLOAD_URL"
101
+ exit 1
102
+ fi
103
+
104
+ chmod +x "$SITE_BUILDER"
105
+ echo "✅ site-builder installed: $SITE_BUILDER"
106
+
107
+ # Add to PATH hint (won't persist after script)
108
+ if [ "$OS_TYPE" = "windows" ]; then
109
+ export PATH="$USERPROFILE/.walrus/bin:$PATH"
110
+ else
111
+ export PATH="$HOME/.walrus/bin:$PATH"
112
+ fi
113
+ }
114
+
115
+ # ============================================================================
116
+ # 4. Clone Walrus Portal (if not exists)
117
+ # ============================================================================
118
+ setup_portal() {
119
+ if [ "$OS_TYPE" = "windows" ]; then
120
+ PORTAL_DIR="$USERPROFILE/.walrus/portal"
121
+ else
122
+ PORTAL_DIR="$HOME/.walrus/portal"
123
+ fi
124
+
125
+ if [ -d "$PORTAL_DIR" ]; then
126
+ echo "✅ Portal already exists: $PORTAL_DIR"
127
+ echo " Updating..."
128
+ cd "$PORTAL_DIR"
129
+ git pull --quiet || echo "⚠️ Git pull failed (may be offline)"
130
+ else
131
+ echo "📂 Cloning Walrus Sites portal..."
132
+ mkdir -p "$(dirname "$PORTAL_DIR")"
133
+
134
+ # Clone with depth=1 for faster download
135
+ if ! git clone --depth=1 https://github.com/MystenLabs/walrus-sites.git "$PORTAL_DIR"; then
136
+ echo "❌ Failed to clone portal repository"
137
+ exit 1
138
+ fi
139
+
140
+ cd "$PORTAL_DIR"
141
+ echo "✅ Portal cloned to: $PORTAL_DIR"
142
+ fi
143
+
144
+ # Setup .env if not exists
145
+ if [ ! -f ".env" ]; then
146
+ if [ -f ".env.example" ]; then
147
+ cp .env.example .env
148
+ echo "✅ Created .env from .env.example"
149
+ else
150
+ # Create minimal .env
151
+ cat > .env << 'EOF'
152
+ # Walrus Portal Configuration (Testnet)
153
+ WALRUS_NETWORK=testnet
154
+ SUI_PRIVATE_KEY=
155
+
156
+ # Optional: Uncomment to customize
157
+ # PORTAL_PORT=3000
158
+ EOF
159
+ echo "✅ Created .env template"
160
+ fi
161
+
162
+ echo ""
163
+ echo "⚠️ ACTION REQUIRED:"
164
+ echo " Edit $PORTAL_DIR/.env"
165
+ echo " Add your SUI_PRIVATE_KEY=0x..."
166
+ echo ""
167
+ else
168
+ echo "✅ .env already configured"
169
+ fi
170
+
171
+ # Install portal dependencies
172
+ echo "📦 Installing portal dependencies..."
173
+ if ! bun install --silent; then
174
+ echo "❌ Bun install failed"
175
+ exit 1
176
+ fi
177
+
178
+ echo "✅ Portal dependencies installed"
179
+ }
180
+
181
+ # ============================================================================
182
+ # 5. Add npm scripts to project package.json
183
+ # ============================================================================
184
+ add_project_scripts() {
185
+ PROJECT_DIR="${1:-.}" # Default to current directory
186
+ cd "$PROJECT_DIR" || { echo "❌ Invalid project directory"; exit 1; }
187
+
188
+ if [ ! -f "package.json" ]; then
189
+ echo "❌ No package.json found in $PROJECT_DIR"
190
+ exit 1
191
+ fi
192
+
193
+ echo "📝 Adding Walrus deploy scripts to package.json..."
194
+
195
+ # Use Node.js to safely modify package.json (guaranteed to exist in Node projects)
196
+ node -e "
197
+ const fs = require('fs');
198
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
199
+
200
+ pkg.scripts = pkg.scripts || {};
201
+
202
+ // Add scripts (only if not already exists)
203
+ if (!pkg.scripts['setup-walrus-deploy']) {
204
+ pkg.scripts['setup-walrus-deploy'] = 'bash scripts/setup-walrus-deploy.sh';
205
+ }
206
+
207
+ if (!pkg.scripts['deploy:walrus']) {
208
+ const siteBuilderPath = process.platform === 'win32'
209
+ ? '%USERPROFILE%/.walrus/bin/site-builder.exe'
210
+ : '~/.walrus/bin/site-builder';
211
+ pkg.scripts['deploy:walrus'] = siteBuilderPath + ' --context=testnet deploy ./dist --epochs 10';
212
+ }
213
+
214
+ if (!pkg.scripts['walrus:portal']) {
215
+ const portalPath = process.platform === 'win32'
216
+ ? 'cd %USERPROFILE%/.walrus/portal'
217
+ : 'cd ~/.walrus/portal';
218
+ pkg.scripts['walrus:portal'] = portalPath + ' && bun run server';
219
+ }
220
+
221
+ fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');
222
+ " || {
223
+ echo "❌ Failed to update package.json"
224
+ exit 1
225
+ }
226
+
227
+ echo "✅ Scripts added to package.json:"
228
+ echo " - setup-walrus-deploy"
229
+ echo " - deploy:walrus"
230
+ echo " - walrus:portal"
231
+ }
232
+
233
+ # ============================================================================
234
+ # Main Execution
235
+ # ============================================================================
236
+ main() {
237
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
238
+
239
+ # Trap errors
240
+ trap 'echo "❌ Setup failed at line $LINENO"' ERR
241
+
242
+ # Prerequisites check
243
+ if ! command -v git &>/dev/null; then
244
+ echo "❌ Git not found. Install: https://git-scm.com"
245
+ exit 1
246
+ fi
247
+
248
+ if ! command -v node &>/dev/null; then
249
+ echo "❌ Node.js not found. Install: https://nodejs.org"
250
+ exit 1
251
+ fi
252
+
253
+ # Run setup steps
254
+ detect_os
255
+ setup_bun
256
+ setup_site_builder
257
+ setup_portal
258
+ add_project_scripts "$@"
259
+
260
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
261
+ echo ""
262
+ echo "🎉 Setup Complete!"
263
+ echo ""
264
+ echo "Next Steps:"
265
+ echo " 1. Configure your SUI private key:"
266
+ if [ "$OS_TYPE" = "windows" ]; then
267
+ echo " notepad %USERPROFILE%\\.walrus\\portal\\.env"
268
+ else
269
+ echo " nano ~/.walrus/portal/.env"
270
+ fi
271
+ echo " Add: SUI_PRIVATE_KEY=0x..."
272
+ echo ""
273
+ echo " 2. Build your project:"
274
+ echo " pnpm build"
275
+ echo ""
276
+ echo " 3. Deploy to Walrus Sites:"
277
+ echo " pnpm deploy:walrus"
278
+ echo ""
279
+ echo " 4. (Optional) Preview locally:"
280
+ echo " pnpm walrus:portal"
281
+ echo ""
282
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
283
+ }
284
+
285
+ # Run main with all script arguments
286
+ main "$@"
@@ -0,0 +1,40 @@
1
+ ## ==============================================
2
+ ## Walrus Application - Environment Configuration
3
+ ## ==============================================
4
+
5
+ ## ENOKI ZKLOGIN AUTHENTICATION
6
+ ## Enoki API Key (get from: https://portal.enoki.mystenlabs.com/)
7
+ VITE_ENOKI_API_KEY=enoki_public_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
8
+
9
+ ## Google OAuth Client ID (get from: https://console.cloud.google.com/)
10
+ VITE_GOOGLE_CLIENT_ID=xxxxxxxxxxxxx.apps.googleusercontent.com
11
+
12
+ ## WALRUS NETWORK SETTINGS
13
+ ## Network: testnet | mainnet | devnet
14
+ VITE_WALRUS_NETWORK=testnet
15
+
16
+ ## Walrus Aggregator URL (for downloads)
17
+ VITE_WALRUS_AGGREGATOR=https://aggregator.walrus-testnet.walrus.space
18
+
19
+ ## Walrus Publisher URL (for uploads)
20
+ VITE_WALRUS_PUBLISHER=https://publisher.walrus-testnet.walrus.space
21
+
22
+ ## SUI BLOCKCHAIN SETTINGS
23
+ ## Sui Network: testnet | mainnet | devnet
24
+ VITE_SUI_NETWORK=testnet
25
+
26
+ ## Sui RPC URL (for wallet interactions)
27
+ VITE_SUI_RPC=https://fullnode.testnet.sui.io:443
28
+
29
+ ## OPTIONAL FEATURES
30
+ ## Blockberry Analytics API Key (leave empty to disable)
31
+ VITE_BLOCKBERRY_KEY=
32
+
33
+ ## ==============================================
34
+ ## PREREQUISITES
35
+ ## ==============================================
36
+ ## 1. Create Enoki account: https://portal.enoki.mystenlabs.com/
37
+ ## 2. Get Enoki API key and Google OAuth Client ID
38
+ ## 3. Install Sui Wallet browser extension (optional, for wallet fallback)
39
+ ## 4. Get testnet SUI from faucet: https://faucet.testnet.sui.io/
40
+ ## 5. Copy this file to .env and fill in your API keys
@@ -0,0 +1,4 @@
1
+ # Preset: react-mysten-simple-upload
2
+
3
+ Structure created based on 2025/2026 React standards.
4
+ Populate with code from layer merging or manual upload.
@@ -0,0 +1,332 @@
1
+ # {{projectName}}
2
+
3
+ Simple Upload Walrus application with Enoki zkLogin authentication.
4
+
5
+ ## Features
6
+
7
+ - 🔐 **Google OAuth zkLogin** - Sign in with your Google account using Enoki zkLogin
8
+ - 📤 **Upload to Walrus** - Upload any file to decentralized storage
9
+ - 📥 **Download Files** - Retrieve files by Blob ID
10
+ - 💰 **Gasless Transactions** - Sponsored transactions via Enoki (no SUI required)
11
+ - 🔄 **Dual Wallet Support** - zkLogin or standard Sui wallet fallback
12
+ - 🔒 **Tab-Isolated Sessions** - sessionStorage auto-cleanup on tab close
13
+
14
+ ## Prerequisites
15
+
16
+ Before starting, you'll need:
17
+
18
+ 1. **Enoki Account** - Create project at [portal.enoki.mystenlabs.com](https://portal.enoki.mystenlabs.com/)
19
+ 2. **Google OAuth Credentials** - Set up at [console.cloud.google.com](https://console.cloud.google.com/)
20
+ 3. **Node.js 18+** and **pnpm** installed
21
+ 4. **Testnet SUI** (for wallet fallback) - Get from [faucet.testnet.sui.io](https://faucet.testnet.sui.io/)
22
+
23
+ ## Quick Start
24
+
25
+ ### 1. Install Dependencies
26
+
27
+ ```bash
28
+ pnpm install
29
+ ```
30
+
31
+ ### 2. Setup Environment
32
+
33
+ ```bash
34
+ cp .env.example .env
35
+ ```
36
+
37
+ Edit `.env` with your credentials (see Setup Guides below):
38
+
39
+ ```env
40
+ # Enoki zkLogin Authentication
41
+ VITE_ENOKI_API_KEY=enoki_public_xxxxxxxxxxxxxxxx
42
+ VITE_GOOGLE_CLIENT_ID=xxxxxxxxx.apps.googleusercontent.com
43
+
44
+ # Walrus Network Settings
45
+ VITE_WALRUS_NETWORK=testnet
46
+ VITE_WALRUS_AGGREGATOR=https://aggregator.walrus-testnet.walrus.space
47
+ VITE_WALRUS_PUBLISHER=https://publisher.walrus-testnet.walrus.space
48
+
49
+ # Sui Blockchain Settings
50
+ VITE_SUI_NETWORK=testnet
51
+ VITE_SUI_RPC=https://fullnode.testnet.sui.io:443
52
+
53
+ # Optional: Blockberry Analytics (leave empty to disable)
54
+ VITE_BLOCKBERRY_KEY=
55
+ ```
56
+
57
+ ### 3. Start Development Server
58
+
59
+ ```bash
60
+ pnpm dev
61
+ ```
62
+
63
+ Open [http://localhost:5173](http://localhost:5173) in your browser.
64
+
65
+ ---
66
+
67
+ ## Setup Guides
68
+
69
+ ### Enoki Console Configuration
70
+
71
+ 1. Visit [portal.enoki.mystenlabs.com](https://portal.enoki.mystenlabs.com/) and sign in
72
+ 2. Click **Create Project** and name it (e.g., "Walrus Upload")
73
+ 3. Copy the **Public API Key** (starts with `enoki_public_`)
74
+ 4. Navigate to **OAuth Providers** → Enable **Google**
75
+ 5. Add redirect URIs:
76
+ - Development: `http://localhost:5173/auth`
77
+ - Production: `https://yourdomain.com/auth` (update when deploying)
78
+ 6. Save configuration
79
+
80
+ ### Google OAuth Setup
81
+
82
+ 1. Go to [console.cloud.google.com](https://console.cloud.google.com/)
83
+ 2. Create a new project or select existing one
84
+ 3. Navigate to **APIs & Services** → **OAuth consent screen**
85
+ - User Type: External
86
+ - App name: Your app name
87
+ - Add your email as test user
88
+ 4. Go to **Credentials** → **Create Credentials** → **OAuth 2.0 Client ID**
89
+ - Application type: Web application
90
+ - Authorized redirect URIs:
91
+ - `http://localhost:5173/auth` (development)
92
+ - `https://yourdomain.com/auth` (production)
93
+ 5. Copy the **Client ID** (ends with `.apps.googleusercontent.com`)
94
+
95
+ ### Environment Variables Reference
96
+
97
+ | Variable | Required | Description | Example |
98
+ |----------|----------|-------------|---------|
99
+ | `VITE_ENOKI_API_KEY` | **Yes** | Public API key from Enoki Console | `enoki_public_xxx` |
100
+ | `VITE_GOOGLE_CLIENT_ID` | **Yes** | OAuth Client ID from Google Cloud | `xxx.apps.googleusercontent.com` |
101
+ | `VITE_WALRUS_NETWORK` | **Yes** | Walrus network environment | `testnet`, `mainnet`, `devnet` |
102
+ | `VITE_WALRUS_AGGREGATOR` | **Yes** | Walrus aggregator URL for downloads | `https://aggregator.walrus-testnet.walrus.space` |
103
+ | `VITE_WALRUS_PUBLISHER` | **Yes** | Walrus publisher URL for uploads | `https://publisher.walrus-testnet.walrus.space` |
104
+ | `VITE_SUI_NETWORK` | **Yes** | Sui network environment | `testnet`, `mainnet`, `devnet` |
105
+ | `VITE_SUI_RPC` | No | Custom Sui RPC endpoint (optional) | `https://fullnode.testnet.sui.io:443` |
106
+ | `VITE_BLOCKBERRY_KEY` | No | Blockberry Analytics API key (optional) | Leave empty to disable |
107
+
108
+ **Security Note:** Never commit `.env` files to version control. The `.env.example` file is provided as a template.
109
+
110
+ ---
111
+
112
+ ## Usage
113
+
114
+ ### Authentication Flow
115
+
116
+ This app supports two authentication methods (automatically prioritizes zkLogin):
117
+
118
+ 1. **Google zkLogin (Recommended)**
119
+ - Click **"🔐 Login with Google"** button
120
+ - Authorize with your Google account
121
+ - Redirected back to app with zkLogin session active
122
+ - Keys stored in sessionStorage (tab-isolated, auto-cleanup on tab close)
123
+
124
+ 2. **Standard Sui Wallet (Fallback)**
125
+ - If not logged in with Google, click **"Connect Wallet"**
126
+ - Select your preferred Sui wallet extension (Sui Wallet, Suiet, etc.)
127
+ - Approve connection request
128
+
129
+ ### Upload Files
130
+
131
+ 1. Ensure you're authenticated (Google or wallet)
132
+ 2. Click **"Choose File"** and select any file
133
+ 3. Click **"Upload to Walrus"**
134
+ 4. Transaction is signed and submitted (gasless with Enoki zkLogin)
135
+ 5. Copy the **Blob ID** from the success message
136
+
137
+ ### Download Files
138
+
139
+ 1. Paste a Blob ID in the download section
140
+ 2. Click **"Download File"**
141
+ 3. File will be retrieved from Walrus and downloaded
142
+
143
+ ### Logout
144
+
145
+ - If using Google zkLogin: Click the **"Logout"** button next to your address
146
+ - If using wallet: Use your wallet extension to disconnect
147
+
148
+ ---
149
+
150
+ ## Troubleshooting
151
+
152
+ ### "VITE_ENOKI_API_KEY is required"
153
+
154
+ **Cause:** Missing or invalid environment variable
155
+
156
+ **Solution:**
157
+ 1. Ensure `.env` file exists in project root
158
+ 2. Verify `VITE_ENOKI_API_KEY` is set and starts with `enoki_public_`
159
+ 3. Restart the development server (`pnpm dev`)
160
+
161
+ ### "Redirect URI mismatch" OAuth Error
162
+
163
+ **Cause:** Google OAuth redirect URI doesn't match configuration
164
+
165
+ **Solution:**
166
+ 1. Verify redirect URI in Google Cloud Console exactly matches:
167
+ - Development: `http://localhost:5173/auth`
168
+ - Production: `https://yourdomain.com/auth`
169
+ 2. No trailing slashes
170
+ 3. Protocol must match (http vs https)
171
+ 4. Wait 5-10 minutes after changing Google Console settings
172
+
173
+ ### Upload Fails with zkLogin
174
+
175
+ **Cause:** Enoki sponsorship balance depleted or network mismatch
176
+
177
+ **Solution:**
178
+ 1. Check [Enoki Console](https://portal.enoki.mystenlabs.com/) sponsorship balance
179
+ 2. Verify `VITE_SUI_NETWORK` in `.env` matches your Enoki project network
180
+ 3. Ensure your Enoki project has the correct network configured
181
+
182
+ ### "No wallet connected" Error
183
+
184
+ **Cause:** Neither zkLogin nor wallet is connected
185
+
186
+ **Solution:**
187
+ 1. Click "Login with Google" for zkLogin authentication
188
+ 2. Or click "Connect Wallet" and approve wallet connection
189
+ 3. Refresh page if session was lost
190
+
191
+ ### TypeScript / Build Errors
192
+
193
+ **Cause:** Dependencies not installed or outdated
194
+
195
+ **Solution:**
196
+ ```bash
197
+ rm -rf node_modules pnpm-lock.yaml
198
+ pnpm install
199
+ pnpm build
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Code Structure
205
+
206
+ ```
207
+ src/
208
+ ├── components/
209
+ │ ├── features/
210
+ │ │ ├── upload-form.tsx # File upload UI with drag-drop
211
+ │ │ ├── file-preview.tsx # Download UI by Blob ID
212
+ │ │ ├── wallet-connect.tsx # Dual auth UI (zkLogin + wallet)
213
+ │ │ └── enoki-auth-button.tsx # Google login/logout button
214
+ │ └── layout/
215
+ │ └── app-layout.tsx # Main layout wrapper
216
+ ├── hooks/
217
+ │ ├── use-upload.ts # Upload mutation with dual auth
218
+ │ ├── use-enoki-auth.ts # Google OAuth state & signer
219
+ │ └── use-wallet.ts # Standard wallet state & signer
220
+ ├── providers/
221
+ │ ├── EnokiProvider.tsx # Enoki zkLogin provider
222
+ │ ├── WalletProvider.tsx # Sui wallet provider
223
+ │ ├── QueryProvider.tsx # React Query provider
224
+ │ └── index.ts # Barrel exports
225
+ ├── lib/
226
+ │ ├── enoki/
227
+ │ │ ├── constants.ts # Env validation with Zod
228
+ │ │ ├── storage-adapter.ts # sessionStorage wrapper
229
+ │ │ └── index.ts # Barrel exports
230
+ │ └── walrus/
231
+ │ ├── storage-adapter.ts # Upload/download logic
232
+ │ ├── types.ts # TypeScript interfaces
233
+ │ └── index.ts # Barrel exports
234
+ ├── App.tsx # Main app component
235
+ └── main.tsx # Entry point with providers
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Deploy to Walrus Sites
241
+
242
+ ### First-time Setup
243
+
244
+ ```bash
245
+ pnpm setup-walrus-deploy
246
+ ```
247
+
248
+ This automatically:
249
+ - Installs Bun (if not installed)
250
+ - Downloads site-builder binary for your OS
251
+ - Clones Walrus Sites portal to `~/.walrus/portal`
252
+ - Adds deployment scripts to package.json
253
+
254
+ ### Configure SUI Private Key
255
+
256
+ Edit the portal configuration:
257
+
258
+ **Linux/macOS:**
259
+ ```bash
260
+ nano ~/.walrus/portal/.env
261
+ ```
262
+
263
+ **Windows:**
264
+ ```bash
265
+ notepad %USERPROFILE%\.walrus\portal\.env
266
+ ```
267
+
268
+ Add your private key:
269
+ ```env
270
+ SUI_PRIVATE_KEY=0x...
271
+ WALRUS_NETWORK=testnet
272
+ ```
273
+
274
+ ### Update OAuth Redirect URI for Production
275
+
276
+ **IMPORTANT:** Before deploying, update your Google OAuth redirect URI:
277
+
278
+ 1. Deploy once to get your Walrus Sites URL (e.g., `https://abcd1234.walrus.site`)
279
+ 2. Add this URL + `/auth` to Google Cloud Console:
280
+ - Go to [console.cloud.google.com](https://console.cloud.google.com/)
281
+ - Navigate to **Credentials** → Select your OAuth Client
282
+ - Add `https://your-site-id.walrus.site/auth` to Authorized redirect URIs
283
+ 3. Also add to Enoki Console redirect URIs
284
+
285
+ ### Build & Deploy
286
+
287
+ ```bash
288
+ # Build production bundle
289
+ pnpm build
290
+
291
+ # Deploy to Walrus Sites (testnet, 10 epochs)
292
+ pnpm deploy:walrus
293
+ ```
294
+
295
+ After deployment, you'll receive a URL like `https://abcd1234.walrus.site`
296
+
297
+ ### Preview Locally
298
+
299
+ ```bash
300
+ pnpm walrus:portal
301
+ ```
302
+
303
+ This starts the local portal server to preview your deployed site.
304
+
305
+ ---
306
+
307
+ ## Available Scripts
308
+
309
+ | Script | Description |
310
+ |--------|-------------|
311
+ | `pnpm dev` | Start development server (http://localhost:5173) |
312
+ | `pnpm build` | Build for production (output: `dist/`) |
313
+ | `pnpm preview` | Preview production build locally |
314
+ | `pnpm setup-walrus-deploy` | One-time Walrus Sites deployment setup |
315
+ | `pnpm deploy:walrus` | Deploy to Walrus Sites (testnet, 10 epochs) |
316
+ | `pnpm walrus:portal` | Start local portal server to preview deployed site |
317
+
318
+ ---
319
+
320
+ ## External Documentation
321
+
322
+ - **Enoki Documentation:** [docs.enoki.mystenlabs.com](https://docs.enoki.mystenlabs.com/)
323
+ - **Walrus Documentation:** [docs.walrus.site](https://docs.walrus.site/)
324
+ - **Google OAuth Guide:** [developers.google.com/identity/protocols/oauth2](https://developers.google.com/identity/protocols/oauth2)
325
+ - **Sui Documentation:** [docs.sui.io](https://docs.sui.io/)
326
+ - **@mysten/dapp-kit:** [sdk.mystenlabs.com/dapp-kit](https://sdk.mystenlabs.com/dapp-kit)
327
+
328
+ ---
329
+
330
+ ## License
331
+
332
+ MIT
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Walrus App</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>