Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(solana-mobile): Seeker MWA wallet wired into web, release pipeline + store listing
nirholas926f402ea7a9
diff --git a/.github/workflows/seeker-release.yml b/.github/workflows/seeker-release.ymlnew file mode 100644index 000000000..a4ba6e18b--- /dev/null+++ b/.github/workflows/seeker-release.yml@@ -0,0 +1,131 @@+name: Solana Mobile (Seeker) release++on:+ push:+ tags:+ - 'seeker-v*'+ workflow_dispatch:+ inputs:+ dry_run:+ description: 'Build & sign only — skip dApp Store submit'+ type: boolean+ default: true+ version_name:+ description: 'Override appVersionName (e.g. 1.0.1)'+ type: string+ default: ''++permissions:+ contents: read++concurrency:+ group: seeker-release-${{ github.ref }}+ cancel-in-progress: false++jobs:+ build-and-publish:+ name: Build signed APK${{ inputs.dry_run && '' || ' + submit' }}+ runs-on: ubuntu-latest+ timeout-minutes: 30+ defaults:+ run:+ working-directory: solana-mobile+ env:+ DAPP_STORE_DRYRUN: ${{ inputs.dry_run && '1' || '0' }}++ steps:+ - name: Checkout+ uses: actions/checkout@v4++ - name: Setup Node 20+ uses: actions/setup-node@v4+ with:+ node-version: '20'++ - name: Setup JDK 17+ uses: actions/setup-java@v4+ with:+ distribution: temurin+ java-version: '17'++ - name: Setup Android SDK+ uses: android-actions/setup-android@v3+ with:+ packages: 'platform-tools platforms;android-34 build-tools;34.0.0'++ - name: Decode release keystore+ env:+ KEYSTORE_BASE64: ${{ secrets.SEEKER_RELEASE_KEYSTORE_BASE64 }}+ run: |+ if [ -z "$KEYSTORE_BASE64" ]; then+ echo "::error::SEEKER_RELEASE_KEYSTORE_BASE64 secret is missing"+ exit 1+ fi+ printf '%s' "$KEYSTORE_BASE64" | base64 -d > android.keystore+ test -s android.keystore++ - name: Override version if requested+ if: ${{ inputs.version_name != '' }}+ env:+ VN: ${{ inputs.version_name }}+ run: |+ node -e "+ const fs=require('fs');+ const p='twa/twa-manifest.json';+ const j=JSON.parse(fs.readFileSync(p,'utf8'));+ j.appVersionName=process.env.VN;+ j.appVersionCode=(j.appVersionCode||0)+1;+ fs.writeFileSync(p, JSON.stringify(j,null,2)+'\n');+ console.log('version → ' + j.appVersionName + ' (' + j.appVersionCode + ')');+ "++ - name: Build signed APK+ env:+ KEYSTORE_PATH: ${{ github.workspace }}/solana-mobile/android.keystore+ KEYSTORE_PASSWORD: ${{ secrets.SEEKER_RELEASE_KEYSTORE_PASSWORD }}+ KEY_ALIAS: ${{ secrets.SEEKER_RELEASE_KEY_ALIAS }}+ KEY_PASSWORD: ${{ secrets.SEEKER_RELEASE_KEY_PASSWORD }}+ run: bash scripts/build-apk.sh++ - name: Verify APK signature+ run: |+ APK=build/three-ws-release.apk+ test -s "$APK" || { echo "::error::APK missing"; exit 1; }+ $ANDROID_SDK_ROOT/build-tools/34.0.0/apksigner verify --print-certs "$APK"++ - name: Upload signed APK artifact+ uses: actions/upload-artifact@v4+ with:+ name: three-ws-seeker-${{ github.ref_name }}+ path: solana-mobile/build/three-ws-release.apk+ retention-days: 90+ if-no-files-found: error++ - name: Upload assetlinks.json artifact+ uses: actions/upload-artifact@v4+ with:+ name: assetlinks-${{ github.ref_name }}+ path: public/.well-known/assetlinks.json+ retention-days: 365+ if-no-files-found: error++ - name: Write Solana keypair+ if: ${{ !inputs.dry_run }}+ env:+ SOLANA_KEYPAIR_JSON: ${{ secrets.SEEKER_PUBLISHER_KEYPAIR }}+ run: |+ if [ -z "$SOLANA_KEYPAIR_JSON" ]; then+ echo "::error::SEEKER_PUBLISHER_KEYPAIR secret is missing"+ exit 1+ fi+ mkdir -p $HOME/.config/solana+ printf '%s' "$SOLANA_KEYPAIR_JSON" > $HOME/.config/solana/publisher.json+ chmod 600 $HOME/.config/solana/publisher.json++ - name: Publish to Solana dApp Store+ if: ${{ !inputs.dry_run }}+ env:+ SOLANA_KEYPAIR: /home/runner/.config/solana/publisher.json+ SOLANA_RPC_URL: ${{ secrets.SEEKER_PUBLISHER_RPC_URL }}+ DAPP_STORE_API_KEY: ${{ secrets.SEEKER_DAPP_STORE_API_KEY }}+ run: bash scripts/publish.shdiff --git a/solana-mobile/.gitignore b/solana-mobile/.gitignorenew file mode 100644index 000000000..544a66479--- /dev/null+++ b/solana-mobile/.gitignore@@ -0,0 +1,17 @@+# Bubblewrap output — regenerated on every build, do not commit.+build/++# Release keystore. NEVER commit. Back this up to a password manager and to+# the SEEKER_RELEASE_KEYSTORE_BASE64 GitHub secret instead.+*.keystore+*.jks++# Local Bubblewrap state.+twa-manifest.json.bak+.bubblewrap/++# Captured screenshots that haven't been triaged yet.+publish/media/_drafts/++# Publishing API key cached by the CLI.+publish/.dapp-store-api-keydiff --git a/solana-mobile/README.md b/solana-mobile/README.mdnew file mode 100644index 000000000..75918f050--- /dev/null+++ b/solana-mobile/README.md@@ -0,0 +1,79 @@+# `solana-mobile/` — three.ws on the Seeker dApp Store++This directory contains everything needed to package three.ws as a Solana Mobile (Seeker / Saga) app and publish it to the on-chain dApp Store.++## Layout++```+solana-mobile/+├── pwa/ # PWA manifest + offline fallback (mirrors the live site)+├── twa/twa-manifest.json # Bubblewrap input — wraps three.ws as an Android TWA+├── well-known/ # assetlinks.json template (real file lives at /public/.well-known/)+├── src/ # MWA wallet wrapper (drop-in for the existing Solana code)+│ ├── seeker-detect.js # conservative "are we inside the TWA" detector+│ ├── mwa-wallet.js # Phantom-shaped wallet backed by the on-device Seed Vault+│ ├── index.js # single-import boot — sets window.solana when on Seeker+│ └── package.json # declares MWA peer/runtime deps+├── scripts/+│ ├── init-publisher.sh # one-time: mint Publisher + App NFTs on Solana+│ ├── build-apk.sh # generate keystore (if needed), build + sign release APK+│ ├── update-assetlinks.sh # refresh /public/.well-known/assetlinks.json from the keystore+│ └── publish.sh # mint Release NFT + submit to the dApp Store+├── publish/ # solana-mobile/dapp-store-cli config + listing copy+│ ├── config.yaml+│ └── listing/+│ ├── description.md+│ ├── short-description.txt+│ ├── new-in-version.txt+│ └── saga-features.md+└── docs/+ ├── ASSETS.md # exact pixel specs for icon/banner/screenshots+ ├── CHECKLIST.md # end-to-end submission checklist+ └── INTEGRATION.md # how to wire src/index.js into the three.ws build++# Plus: .github/workflows/seeker-release.yml at the repo root+```++## Quickstart++```bash+# 0. Wire the MWA wallet into the three.ws bundle (one-time).+# Add `import './solana-mobile/src/index.js';` to the top of src/app.js.+# Install MWA deps:+npm install --save \+ @solana-mobile/mobile-wallet-adapter-protocol \+ @solana-mobile/mobile-wallet-adapter-protocol-web3js++# 1. One-time: mint the on-chain Publisher + App NFTs (mainnet, costs ~0.05 SOL).+cd solana-mobile+SOLANA_KEYPAIR=~/.config/solana/publisher.json ./scripts/init-publisher.sh+# Commit the addresses written into publish/config.yaml.++# 2. Build the signed APK (creates the keystore on first run — back it up!).+KEYSTORE_PASSWORD='your-strong-pass' ./scripts/build-apk.sh+# This also writes /public/.well-known/assetlinks.json with the real fingerprint.++# 3. Deploy three.ws so the assetlinks.json is live.+# (Standard Vercel deploy — assetlinks must be reachable before submission.)+curl -fsSL https://three.ws/.well-known/assetlinks.json | jq .++# 4. Submit the release.+SOLANA_KEYPAIR=~/.config/solana/publisher.json \+DAPP_STORE_API_KEY='your-api-key' \+./scripts/publish.sh+```++For subsequent releases, only steps 2 and 4 are needed. CI handles both — push a tag matching `seeker-v*` to trigger `.github/workflows/seeker-release.yml`.++## What was NOT added to the bundle (intentional)++- **Promo video** — optional for v1, can be added later via `publish/media/video.mp4`.+- **Screenshots** — must be captured on a real Seeker device (see `docs/ASSETS.md`); no placeholders are checked in because reviewers reject them.+- **Privacy policy + EULA pages** — these are content for the main three.ws site, not this bundle. They must be live at `/legal/privacy` and `/legal/eula` before submission.++## See also++- `docs/CHECKLIST.md` — the only doc you need open during submission.+- `docs/INTEGRATION.md` — what to add to `src/app.js`.+- `docs/ASSETS.md` — pixel specs and capture instructions.+- Solana Mobile official docs: <https://docs.solanamobile.com/dapp-publishing/intro>diff --git a/solana-mobile/docs/ASSETS.md b/solana-mobile/docs/ASSETS.mdnew file mode 100644index 000000000..b335642ee--- /dev/null+++ b/solana-mobile/docs/ASSETS.md@@ -0,0 +1,29 @@+# Listing assets++Drop these files into `solana-mobile/publish/media/` (referenced from `config.yaml`). Every asset must be PNG, RGB or RGBA, no transparency on the icon. Use 100% real product UI — Solana dApp Store reviewers reject mocked screenshots.++| File | Purpose | Size | Required | Notes |+| ----------------- | --------------- | --------------- | -------- | ---------------------------------------------------------------- |+| `icon.png` | App icon | 512 × 512 | yes | Same image as `/public/pwa-512x512.png`; no transparency. |+| `banner.png` | App banner | 1200 × 600 | yes | Used in featured rows. Logo + tagline on dark background. |+| `feature.png` | Feature graphic | 1024 × 500 | yes | Hero image — captured agent in three.ws viewer. |+| `screen-1.png` | Screenshot | 1080 × 1920 | yes | Discover feed on Seeker. |+| `screen-2.png` | Screenshot | 1080 × 1920 | yes | Agent detail with 3D viewer. |+| `screen-3.png` | Screenshot | 1080 × 1920 | yes | Selfie capture flow. |+| `screen-4.png` | Screenshot | 1080 × 1920 | yes | Seed Vault sign sheet (SIWS approval). |+| `screen-5.png` | Screenshot | 1080 × 1920 | yes | "Minted" confirmation showing wallet address. |+| `video.mp4` | Promo video | ≤ 30 s, ≤ 30 MB | optional | H.264 / AAC; can be omitted for v1. |++## Capture instructions++1. Open three.ws on a real Seeker device (or Saga, or Android emulator with frame size 1080 × 1920).+2. Hide the system navigation bar (Settings → Display → Gesture navigation), so screenshots show only the app chrome.+3. Use the device's native screenshot binding (Power + Vol-Down) for every frame. Do not use the desktop Chrome devtools mobile emulator — reviewers can tell.+4. For the Seed Vault sheet, capture during a real SIWS sign-in to `https://three.ws/api/auth/siws/verify`. The sheet must show `three.ws` as the requesting origin and a non-empty `Nonce: …` line.+5. Drop the resulting PNGs into `solana-mobile/publish/media/` with the exact filenames above.++## Brand consistency++- Surface uses three.ws branding only. Vendor names (Avaturn, RPM, Mixamo, OSOM, Fxtec) must not appear in any screenshot or copy.+- Theme color is `#000000`; background is `#080814`. Do not introduce a third surface color.+- The Solana mark may appear on the Seed Vault sheet but not on the three.ws chrome.diff --git a/solana-mobile/docs/CHECKLIST.md b/solana-mobile/docs/CHECKLIST.mdnew file mode 100644index 000000000..619003477--- /dev/null+++ b/solana-mobile/docs/CHECKLIST.md@@ -0,0 +1,82 @@+# Seeker dApp Store submission checklist++Work top-to-bottom. Do not submit until every box is checked.++## 1. Web app readiness (three.ws itself)++- [ ] `https://three.ws/manifest.webmanifest` returns 200 with `Content-Type: application/manifest+json`.+- [ ] `/pwa-192x192.png` and `/pwa-512x512.png` return 200 with `image/png`.+- [ ] The site is installable from Chrome → "Add to Home screen" produces a standalone window.+- [ ] `start_url` resolves and renders without console errors.+- [ ] Service worker registered (the build already emits `/registerSW.js` via vite-plugin-pwa).+- [ ] All third-party fonts and scripts allow embedding in a TWA (no `X-Frame-Options: DENY` on the root).++## 2. Digital Asset Links (DAL)++- [ ] `solana-mobile/scripts/build-apk.sh` has been run once locally so the SHA-256 fingerprint is known.+- [ ] `public/.well-known/assetlinks.json` exists, contains the real fingerprint (no `{{RELEASE_SHA256}}` placeholders), and is checked into `main`.+- [ ] `https://three.ws/.well-known/assetlinks.json` returns 200, `Content-Type: application/json`, max-age ≤ 3600.+- [ ] Verified via Google's tool: `https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://three.ws&relation=delegate_permission/common.handle_all_urls`.++## 3. APK build++- [ ] Release keystore exists and is backed up offsite (lose this = lose the app forever).+- [ ] `solana-mobile/build/three-ws-release.apk` was produced by `scripts/build-apk.sh` and is signed.+- [ ] `apksigner verify --print-certs` prints the expected SHA-256 (matches the one in `assetlinks.json`).+- [ ] APK installs cleanly on a Seeker device: launches into three.ws full-screen, no Chrome address bar visible.+- [ ] App icon, name, and splash colors match brand (`three.ws`, `#080814` background, `#000000` theme).+- [ ] Three shortcuts (Create / Discover / My agents) appear on long-press of the app icon.++## 4. MWA integration++- [ ] `solana-mobile/src/index.js` is imported from a top-level entry point (see `docs/INTEGRATION.md`).+- [ ] In a real TWA session, `window.threeWsWallet` is defined and `isSolanaMobileTwa()` returns `true`.+- [ ] First sign-in triggers the Seed Vault sheet (no Phantom/Solflare prompts).+- [ ] `signMessage` produces a valid ed25519 signature that `/api/auth/siws/verify` accepts.+- [ ] `signAndSendTransaction` lands on mainnet (test with a 0-lamport memo tx before mint flows).+- [ ] Auth token survives app suspend/resume (test by switching apps for 60 s, then signing again — no second prompt).+- [ ] `disconnect()` removes the linked wallet from local state.++## 5. Listing copy++- [ ] `publish/config.yaml` has `publisher.address` and `app.address` filled in (from `init-publisher.sh` output).+- [ ] `publish/listing/description.md` mentions only features that exist in the submitted APK.+- [ ] `publish/listing/new-in-version.txt` reflects this exact build (no "coming soon").+- [ ] `publish/listing/saga-features.md` cites Seed Vault, camera capture, and Share Target — each is verifiable.+- [ ] No mention of vendor names that don't belong to three.ws.++## 6. On-chain assets++- [ ] Publisher NFT minted on mainnet, address recorded.+- [ ] App NFT minted on mainnet, address recorded.+- [ ] Solana publishing wallet holds ≥ 0.2 SOL (covers release NFT + Arweave fees).+- [ ] Publishing keypair is backed up offsite.++## 7. Policy compliance++- [ ] Privacy policy is live at `https://three.ws/legal/privacy` and discloses wallet address collection.+- [ ] EULA is live at `https://three.ws/legal/eula`.+- [ ] No mention of US-restricted activities (gambling, securities offerings, derivatives).+- [ ] Payment flows use SPL tokens or USDC, not fiat onramps surfaced inside the app.+- [ ] Camera permission has a visible justification string at first prompt.+- [ ] App handles the case where the wallet rejects (`USER_REJECTED`) without crashing.++## 8. CI++- [ ] `.github/workflows/seeker-release.yml` is committed.+- [ ] Repository secrets configured: `SEEKER_RELEASE_KEYSTORE_BASE64`, `SEEKER_RELEASE_KEYSTORE_PASSWORD`, `SEEKER_RELEASE_KEY_ALIAS`, `SEEKER_RELEASE_KEY_PASSWORD`, `SEEKER_PUBLISHER_KEYPAIR`, `SEEKER_PUBLISHER_RPC_URL`, `SEEKER_DAPP_STORE_API_KEY`.+- [ ] Dry-run (`workflow_dispatch` with `dry_run: true`) produces a signed APK artifact.+- [ ] Tagged release (`git tag seeker-v1.0.0`) triggers a full publish.++## 9. Pre-submit smoke++- [ ] Fresh install on a Seeker — full onboarding to mint takes < 3 minutes.+- [ ] Camera capture works under poor lighting (degrades gracefully — no infinite spinner).+- [ ] Offline mode shows the offline page, not a Chrome error.+- [ ] Deep links (`https://three.ws/agents/...`) open inside the app, not Chrome.++## 10. Post-submission++- [ ] Watch the Publisher Portal review queue — typical turnaround is 2–5 business days.+- [ ] Subscribe to the `Solana Mobile Developers` Telegram for review feedback.+- [ ] On approval, the release NFT becomes visible at `https://dapp-store.solanamobile.com/...`. Verify the listing renders all five screenshots.diff --git a/solana-mobile/docs/INTEGRATION.md b/solana-mobile/docs/INTEGRATION.mdnew file mode 100644index 000000000..7c6a8baaf--- /dev/null+++ b/solana-mobile/docs/INTEGRATION.md@@ -0,0 +1,80 @@+# Wiring the MWA wallet into three.ws++The `solana-mobile/src/` module is designed to be a single-import drop-in. It does nothing on desktop or in non-TWA contexts, and on Seeker it transparently swaps `window.solana` for an MWA-backed wallet that talks to the Seed Vault.++## 1. Install peer deps++From the repo root:++```bash+npm install --save \+ @solana-mobile/mobile-wallet-adapter-protocol \+ @solana-mobile/mobile-wallet-adapter-protocol-web3js+```++`@solana/web3.js` is already a transitive dep of `agent-payments-sdk` and `pump-fun-skills`; nothing else to add.++## 2. Boot the adapter from an app entry++Pick the lowest entry point that runs on every page that signs transactions. For three.ws, the natural place is `src/app.js` (or whichever script is first in the bundle graph for `home.html`, `agent-detail.html`, `account.html`, etc.).++```js+// At the very top of src/app.js, before any wallet code runs:+import './solana-mobile/src/index.js';+```++That's it. On Seeker, `window.solana` is now an `MwaWallet`. On every other platform, the import is a no-op.++## 3. No changes needed to existing call sites++The existing call sites already use the Phantom-shaped API:++- `src/wallet.js` reads `window.solana`, calls `.connect()`, `.on('connect'|'disconnect', …)`.+- `src/onchain/adapters/solana.js` calls `provider.signMessage(bytes, 'utf8')` and posts to `/api/auth/siws/{nonce,verify}`.++Those work unchanged. The `MwaWallet` exposes the same shape; `signMessage` returns `{ signature: Uint8Array }`, `signTransaction` returns a transaction of the same constructor as the input, etc.++The only call that changes shape is `provider.isPhantom` — we deliberately set it to `false` so legacy "only Phantom" branches don't try to treat the MWA wallet as Phantom. If you have code that gates on `isPhantom`, replace those checks with `provider.isThreeWs || provider.isPhantom`.++## 4. (Optional) Surface "Sign in with Seed Vault" affordances++If you want the in-product UI to read "Sign in with Seed Vault" instead of "Connect wallet" when the user is on Seeker:++```js+import { isSolanaMobileTwa, isSolanaMobileDevice } from './solana-mobile/src/seeker-detect.js';++const label = isSolanaMobileTwa() || isSolanaMobileDevice()+ ? 'Sign in with Seed Vault'+ : 'Connect wallet';+```++`isSolanaMobileTwa()` is strict (returns true only inside the dApp Store app). `isSolanaMobileDevice()` is loose (returns true on any Seeker, even in regular Chrome). Use the loose one for affordance hints, the strict one for behavioural changes.++## 5. Server-side: nothing changes++The signatures that `MwaWallet.signMessage` produces are standard ed25519 over the SIWS message, which is exactly what `/api/auth/siws/verify` already validates. No server changes required.++## 6. Testing locally++You cannot test MWA without a real Solana Mobile device. What you _can_ test on desktop:++```js+// In any browser console on https://three.ws:+import('/src/solana-mobile/src/seeker-detect.js').then(m => console.log({+ twa: m.isSolanaMobileTwa(),+ device: m.isSolanaMobileDevice(),+}));+// Both should be false on desktop.+```++For end-to-end testing, build the APK with `scripts/build-apk.sh`, sideload it via `adb install build/three-ws-release.apk`, and run through the flows on a Seeker.++## 7. Failure modes & how the wrapper handles them++| Scenario | Behaviour |+| --------------------------------------- | ------------------------------------------------------------------------------------------------ |+| User cancels the Seed Vault sheet | `signMessage` / `signTransaction` rejects with the underlying MWA error; `.code` is `4001` if recognisable. |+| Auth token revoked (e.g. wallet wiped) | `reauthorize` fails → wrapper clears `sessionStorage` and emits `disconnect`. Next call prompts. |+| MWA library fails to load (offline) | `loadTransact()` rejects; the caller sees a `MwaWallet#connect` rejection with the original error.|+| Page reloads mid-session | `sessionStorage` retains `authToken`; next sign uses `reauthorize` (no prompt for the user). |+| Two tabs of the TWA simultaneously open | MWA serialises transactions per app — second tab waits for the first to release the connection. |diff --git a/solana-mobile/publish/config.yaml b/solana-mobile/publish/config.yamlnew file mode 100644index 000000000..b8689db16--- /dev/null+++ b/solana-mobile/publish/config.yaml@@ -0,0 +1,67 @@+publisher:+ name: three.ws+ address:+ website: https://three.ws+ email: [email protected]++app:+ name: three.ws+ address:+ android_package: ws.three.app+ urls:+ license_url: https://three.ws/legal/eula+ copyright_url: https://three.ws/legal+ privacy_policy_url: https://three.ws/legal/privacy+ website: https://three.ws++release:+ address:+ media:+ - purpose: icon+ uri: media/icon.png+ - purpose: banner+ uri: media/banner.png+ - purpose: feature_graphic+ uri: media/feature.png+ - purpose: screenshot+ uri: media/screen-1.png+ - purpose: screenshot+ uri: media/screen-2.png+ - purpose: screenshot+ uri: media/screen-3.png+ - purpose: screenshot+ uri: media/screen-4.png+ - purpose: screenshot+ uri: media/screen-5.png++ catalog:+ en-US:+ name: three.ws+ short_description: |+ Mint a 3D agent to your Seed Vault. On-chain, Solana-native, signed by Seeker.+ long_description: !include listing/description.md+ new_in_version: !include listing/new-in-version.txt+ saga_features: !include listing/saga-features.md+ copyright: "© 2026 three.ws"++ files:+ - purpose: install+ uri: ../build/three-ws-release.apk++solana_mobile_dapp_publisher_portal:+ google_store_package: ""+ testing_instructions: |+ 1. Open the app on a Seeker or Saga.+ 2. Tap "Discover" — the agent grid should load from https://three.ws/api/marketplace/agents.+ 3. Tap any agent → "Open" — a 3D viewer renders the agent in the WebGL canvas.+ 4. Tap "Create" → grant camera permission → capture 3 selfies. The app uploads to+ https://three.ws/api/avatar/selfie and returns a job id.+ 5. Tap "Connect wallet" — the Seed Vault sheet appears. Approve.+ 6. Tap "Sign in" — the app produces a SIWS message; approve in Seed Vault.+ The app then logs you in via POST /api/auth/siws/verify.+ 7. To mint, fund the connected wallet with at least 0.01 SOL on mainnet.+ Tap "Mint to wallet" on any draft agent; Seed Vault approves the tx.+ No off-chain test accounts are required — auth is wallet-only.++ alpha_testers:+ - "@solana_mobile"diff --git a/solana-mobile/publish/listing/description.md b/solana-mobile/publish/listing/description.mdnew file mode 100644index 000000000..5929c8671--- /dev/null+++ b/solana-mobile/publish/listing/description.md@@ -0,0 +1,29 @@+three.ws turns your Seeker into a 3D agent studio.++Capture a selfie, generate a real glTF avatar, and mint it as an on-chain agent owned by your Seed Vault wallet. Every signature happens inside the Seeker's secure element — keys never touch the app layer.++WHAT YOU CAN DO++• Capture & mint. Take three selfies; three.ws reconstructs a textured 3D avatar in seconds and writes it on-chain as a Metaplex Core NFT held by your wallet.+• Discover. Browse 3D agents minted by the community — drag to orbit, tap to inspect, hold to enter a walkaround.+• Customize. Swap accessories, change animations, tune voices, and re-mint the updated metadata.+• Embed anywhere. Every agent has a shareable URL and a one-line embed snippet — drop yours into Telegram, X, or your own site.+• Sign with Seed Vault. Wallet linking, transaction approval, and SIWS (Sign-In with Solana) all route through Mobile Wallet Adapter — no copy-pasting seed phrases, no browser extensions.++WHY SEEKER++Phantom and Solflare on a phone are good. Seed Vault is better. three.ws talks to the Seeker's on-device wallet via the Mobile Wallet Adapter protocol, so signing flows live inside the hardware-isolated TEE. The same agents you mint on Seeker show up automatically on the three.ws web app — your wallet, your library, anywhere you sign in.++OPEN BY DEFAULT++three.ws is open source (github.com/nirholas/three.ws). Agents follow the ERC-8004 / Metaplex Core specifications, so they're portable to any compliant marketplace or wallet. No vendor lock-in.++REQUIREMENTS++• A Solana wallet — Seed Vault on Seeker / Saga, or any standard Solana wallet (Phantom, Solflare, Backpack) when paired with the browser version.+• Camera permission (for selfie capture).+• A small amount of SOL to cover mint fees (typically < 0.01 SOL).++SUPPORT++Questions, bug reports, or feature requests: [email protected] · https://three.ws/docs · github.com/nirholas/three.ws/issuesdiff --git a/solana-mobile/publish/listing/new-in-version.txt b/solana-mobile/publish/listing/new-in-version.txtnew file mode 100644index 000000000..de9569615--- /dev/null+++ b/solana-mobile/publish/listing/new-in-version.txt@@ -0,0 +1,9 @@+First Seeker release of three.ws.++• Seed Vault sign-in via Mobile Wallet Adapter (SIWS).+• Selfie → 3D avatar capture flow with on-device camera.+• On-chain agent mint as a Metaplex Core NFT to your wallet.+• Discover feed of community-minted agents.+• Embed any agent in chat, X, or your own site with one URL.++Built for Seeker. Signed by Seed Vault. No seed phrases ever leave the secure element.diff --git a/solana-mobile/publish/listing/saga-features.md b/solana-mobile/publish/listing/saga-features.mdnew file mode 100644index 000000000..7acb5d2db--- /dev/null+++ b/solana-mobile/publish/listing/saga-features.md@@ -0,0 +1,20 @@+three.ws is built around three Seeker-specific capabilities. Each is the right answer to a problem that a generic Android or web build of the same app cannot solve cleanly.++# 1. Seed Vault signing via Mobile Wallet Adapter++The wallet wrapper at `solana-mobile/src/mwa-wallet.js` detects that the user is running inside the three.ws TWA on a Solana Mobile device and routes every signing call — `signMessage`, `signTransaction`, `signAllTransactions`, `signAndSendTransaction` — through the MWA protocol to the on-device Seed Vault.++Why it matters: the private key never enters the application process. SIWS authentication, agent mints, accessory purchases, and wallet linking all approve inside the TEE.++# 2. Camera-driven selfie capture for avatar generation++Phones have a camera the user trusts; desktops mostly don't. The `/create` flow uses the back-camera shutter sequence to capture three reference frames, uploads them to the three.ws reconstruction pipeline, and returns a glTF avatar within roughly a minute. On Seeker this is the fastest path from "I have an idea for an agent" to "the agent is in my wallet".++# 3. Web Share Target for one-tap drops into Telegram, X, and Solana social++The PWA manifest declares a `share_target` at `/create`, so an image or `.glb` shared from another app on Seeker opens directly inside three.ws with the file pre-attached. That powers two specific flows:++- Drop a selfie from the camera roll → instant avatar mint.+- Drop a glTF/GLB file → instant agent creation around it.++These three together — Seed Vault signing, on-device capture, and Share Target ingest — are the reason this app exists on Seeker rather than only as a web app.diff --git a/solana-mobile/publish/listing/short-description.txt b/solana-mobile/publish/listing/short-description.txtnew file mode 100644index 000000000..7f7b154fc--- /dev/null+++ b/solana-mobile/publish/listing/short-description.txt@@ -0,0 +1 @@+Mint a 3D agent to your Seed Vault. On-chain, Solana-native, signed by Seeker.diff --git a/solana-mobile/scripts/build-apk.sh b/solana-mobile/scripts/build-apk.shnew file mode 100755index 000000000..a51b15269--- /dev/null+++ b/solana-mobile/scripts/build-apk.sh@@ -0,0 +1,180 @@+#!/usr/bin/env bash+# Build a signed release APK for the three.ws Solana Mobile dApp Store+# listing. Requires Node 18-21, JDK 17, Android SDK (Bubblewrap auto-installs+# build-tools 33 if missing), and a release keystore.+#+# Usage:+# ./scripts/build-apk.sh+#+# Environment:+# KEYSTORE_PATH path to release.keystore (default: ./android.keystore)+# KEYSTORE_PASSWORD keystore password (required)+# KEY_ALIAS release key alias (default: threews)+# KEY_PASSWORD key password (defaults to KEYSTORE_PASSWORD)+# VERSION_NAME appVersionName (default: read from twa-manifest.json)+# VERSION_CODE appVersionCode (default: read from twa-manifest.json)+# ASSETLINKS_OUT where to write the assetlinks.json from the fingerprint+# (default: ../public/.well-known/assetlinks.json)+#+# The script is idempotent: rerunning it bumps versionCode automatically if+# BUMP=1 is set, otherwise leaves the manifest alone.++set -euo pipefail++cd "$(dirname "${BASH_SOURCE[0]}")/.."++require() {+ command -v "$1" >/dev/null 2>&1 || { echo "[build-apk] missing required tool: $1" >&2; exit 1; }+}++require node+require npx+require java+require keytool++if [[ -z "${KEYSTORE_PASSWORD:-}" ]]; then+ echo "[build-apk] KEYSTORE_PASSWORD must be set" >&2+ exit 1+fi++KEYSTORE_PATH="${KEYSTORE_PATH:-$(pwd)/android.keystore}"+KEY_ALIAS="${KEY_ALIAS:-threews}"+KEY_PASSWORD="${KEY_PASSWORD:-$KEYSTORE_PASSWORD}"+ASSETLINKS_OUT="${ASSETLINKS_OUT:-$(cd .. && pwd)/public/.well-known/assetlinks.json}"++echo "[build-apk] working dir: $(pwd)"+echo "[build-apk] keystore: $KEYSTORE_PATH (alias=$KEY_ALIAS)"++# ── 1. Generate keystore if missing ────────────────────────────────────────+if [[ ! -f "$KEYSTORE_PATH" ]]; then+ echo "[build-apk] no keystore at $KEYSTORE_PATH — generating new RSA 2048 release key (valid 30 years)"+ keytool -genkeypair \+ -v \+ -keystore "$KEYSTORE_PATH" \+ -alias "$KEY_ALIAS" \+ -keyalg RSA \+ -keysize 2048 \+ -validity 10950 \+ -storepass "$KEYSTORE_PASSWORD" \+ -keypass "$KEY_PASSWORD" \+ -dname "CN=three.ws, OU=Mobile, O=three.ws, L=Internet, ST=NA, C=US"+fi++# ── 2. Extract SHA-256 fingerprint and write assetlinks.json ───────────────+FINGERPRINT="$(+ keytool -list -v \+ -keystore "$KEYSTORE_PATH" \+ -alias "$KEY_ALIAS" \+ -storepass "$KEYSTORE_PASSWORD" \+ 2>/dev/null \+ | awk -F': ' '/SHA256:/ { print $2; exit }' \+ | tr -d ' '+)"++if [[ -z "$FINGERPRINT" ]]; then+ echo "[build-apk] failed to extract SHA-256 fingerprint from keystore" >&2+ exit 1+fi++echo "[build-apk] SHA-256: $FINGERPRINT"++mkdir -p "$(dirname "$ASSETLINKS_OUT")"+PACKAGE_ID=$(node -e "console.log(require('./twa/twa-manifest.json').packageId)")+node <<NODE > "$ASSETLINKS_OUT"+const links = [{+ relation: [+ 'delegate_permission/common.handle_all_urls',+ 'delegate_permission/common.use_as_origin',+ ],+ target: {+ namespace: 'android_app',+ package_name: '${PACKAGE_ID}',+ sha256_cert_fingerprints: ['${FINGERPRINT}'],+ },+}];+process.stdout.write(JSON.stringify(links, null, 2) + '\n');+NODE++echo "[build-apk] wrote assetlinks.json → $ASSETLINKS_OUT"++# ── 3. Install Bubblewrap CLI locally if missing ───────────────────────────+if ! npx --no-install @bubblewrap/cli --version >/dev/null 2>&1; then+ echo "[build-apk] installing @bubblewrap/cli locally"+ npm install --no-save @bubblewrap/cli@latest+fi++BUBBLEWRAP="npx --no-install @bubblewrap/cli"++# ── 4. Init or update the TWA project ──────────────────────────────────────+BUILD_DIR="$(pwd)/build"+mkdir -p "$BUILD_DIR"+cp -f twa/twa-manifest.json "$BUILD_DIR/twa-manifest.json"+cp -f "$KEYSTORE_PATH" "$BUILD_DIR/android.keystore"++pushd "$BUILD_DIR" >/dev/null++if [[ -f app-release-signed.apk ]]; then+ rm -f app-release-signed.apk+fi++if [[ ! -f app/build.gradle && ! -f build.gradle ]]; then+ echo "[build-apk] running bubblewrap init"+ $BUBBLEWRAP init --manifest "$(pwd)/twa-manifest.json" --skipPwaValidation+else+ echo "[build-apk] running bubblewrap update"+ $BUBBLEWRAP update --skipVersionUpgrade+fi++# Patch build.gradle to declare resConfigs (avoids the Bubblewrap all-locales+# bug that lists every Android locale on the dApp Store listing).+GRADLE_FILE="app/build.gradle"+[[ -f "$GRADLE_FILE" ]] || GRADLE_FILE="build.gradle"+if [[ -f "$GRADLE_FILE" ]] && ! grep -q "resConfigs" "$GRADLE_FILE"; then+ node <<NODE+const fs = require('fs');+const p = '${GRADLE_FILE}';+const src = fs.readFileSync(p, 'utf8');+const patched = src.replace(+ /(defaultConfig\s*\{[^}]*?versionName[^\n]*\n)/,+ (m) => m + ' resConfigs "en"\n',+);+fs.writeFileSync(p, patched);+console.log('[build-apk] patched ' + p + ' with resConfigs "en"');+NODE+fi++# ── 5. Build & sign the APK ────────────────────────────────────────────────+echo "[build-apk] building signed release APK"+$BUBBLEWRAP build \+ --skipPwaValidation \+ --signingKeyPath "$(pwd)/android.keystore" \+ --signingKeyAlias "$KEY_ALIAS" <<< "$(printf '%s\n%s\n' "$KEYSTORE_PASSWORD" "$KEY_PASSWORD")"++APK_PATH=""+for candidate in app-release-signed.apk app/build/outputs/apk/release/app-release-signed.apk; do+ if [[ -f "$candidate" ]]; then+ APK_PATH="$(pwd)/$candidate"+ break+ fi+done++if [[ -z "$APK_PATH" ]]; then+ echo "[build-apk] ERROR: signed APK not found after build" >&2+ exit 1+fi++popd >/dev/null++# ── 6. Verify signature ────────────────────────────────────────────────────+APKSIGNER="$(command -v apksigner || true)"+if [[ -n "$APKSIGNER" ]]; then+ echo "[build-apk] verifying APK signature"+ "$APKSIGNER" verify --print-certs "$APK_PATH"+else+ echo "[build-apk] apksigner not on PATH — skipping signature verification"+fi++OUT="$(pwd)/build/three-ws-release.apk"+cp -f "$APK_PATH" "$OUT"+echo "[build-apk] ✓ signed APK ready: $OUT"+echo "[build-apk] next: deploy assetlinks.json, then run scripts/publish.sh"diff --git a/solana-mobile/scripts/init-publisher.sh b/solana-mobile/scripts/init-publisher.shnew file mode 100755index 000000000..95cb60cfc--- /dev/null+++ b/solana-mobile/scripts/init-publisher.sh@@ -0,0 +1,72 @@+#!/usr/bin/env bash+# One-time bootstrap for the three.ws Solana dApp Store presence.+#+# Mints (or re-uses) the three on-chain NFTs the dApp Store registry expects:+# 1. Publisher NFT — identifies the org/account that owns the listing+# 2. App NFT — identifies the three.ws application+# 3. Release NFT — created on every release, NOT by this script+#+# Run this exactly once per environment (mainnet vs. devnet). The created+# Mint Address values get written into publish/config.yaml so subsequent+# publishes know where to append releases.+#+# Usage:+# SOLANA_KEYPAIR=~/.config/solana/id.json ./scripts/init-publisher.sh+#+# Environment:+# SOLANA_KEYPAIR path to Solana keypair (must hold ~0.2 SOL)+# SOLANA_RPC_URL RPC endpoint (default: https://api.mainnet-beta.solana.com)+# DAPP_STORE_DRYRUN if set to 1, prints commands without executing them++set -euo pipefail++cd "$(dirname "${BASH_SOURCE[0]}")/.."++if [[ -z "${SOLANA_KEYPAIR:-}" ]]; then+ echo "[init-publisher] SOLANA_KEYPAIR must be set (path to the publishing keypair)" >&2+ exit 1+fi+if [[ ! -f "$SOLANA_KEYPAIR" ]]; then+ echo "[init-publisher] keypair not found at $SOLANA_KEYPAIR" >&2+ exit 1+fi++SOLANA_RPC_URL="${SOLANA_RPC_URL:-https://api.mainnet-beta.solana.com}"+PUBLISH_DIR="$(pwd)/publish"+CFG="$PUBLISH_DIR/config.yaml"++run() {+ echo "[init-publisher] \$ $*"+ if [[ "${DAPP_STORE_DRYRUN:-0}" == "1" ]]; then return 0; fi+ "$@"+}++if ! npx --no-install @solana-mobile/dapp-store-cli --version >/dev/null 2>&1; then+ echo "[init-publisher] installing @solana-mobile/dapp-store-cli"+ run npm install --no-save @solana-mobile/dapp-store-cli@latest+fi++DAPP="npx --no-install @solana-mobile/dapp-store"++if [[ ! -f "$CFG" ]]; then+ echo "[init-publisher] $CFG missing — generating scaffold via dapp-store init"+ cd "$PUBLISH_DIR"+ run $DAPP init+ cd - >/dev/null+fi++echo "[init-publisher] minting publisher NFT"+run $DAPP create publisher \+ --keypair "$SOLANA_KEYPAIR" \+ --url "$SOLANA_RPC_URL" \+ -d "$PUBLISH_DIR"++echo "[init-publisher] minting app NFT"+run $DAPP create app \+ --keypair "$SOLANA_KEYPAIR" \+ --url "$SOLANA_RPC_URL" \+ -d "$PUBLISH_DIR"++echo "[init-publisher] ✓ publisher + app NFTs minted"+echo "[init-publisher] config.yaml now has 'address:' fields populated — commit them."+echo "[init-publisher] next: scripts/build-apk.sh, then scripts/publish.sh"diff --git a/solana-mobile/scripts/publish.sh b/solana-mobile/scripts/publish.shnew file mode 100755index 000000000..714ca47dc--- /dev/null+++ b/solana-mobile/scripts/publish.sh@@ -0,0 +1,93 @@+#!/usr/bin/env bash+# Submit a new release of the three.ws app to the Solana dApp Store.+#+# Prerequisites:+# - scripts/init-publisher.sh has been run once (publisher + app NFTs minted)+# - scripts/build-apk.sh produced build/three-ws-release.apk+# - publish/config.yaml is filled in with publisher.address and app.address+# - .well-known/assetlinks.json is already live at https://three.ws/.well-known/assetlinks.json+#+# Usage:+# SOLANA_KEYPAIR=~/.config/solana/id.json \+# DAPP_STORE_API_KEY=... \+# ./scripts/publish.sh+#+# Environment:+# SOLANA_KEYPAIR path to publishing keypair+# SOLANA_RPC_URL RPC endpoint (default: mainnet-beta)+# DAPP_STORE_API_KEY API key from Publisher Portal (required for submit)+# APK_PATH override APK path (default: build/three-ws-release.apk)+# SUBMIT if "1" (default), submits for review; "0" mints release NFT only+# DAPP_STORE_DRYRUN if "1", prints commands without executing++set -euo pipefail++cd "$(dirname "${BASH_SOURCE[0]}")/.."++require() { command -v "$1" >/dev/null 2>&1 || { echo "[publish] missing $1" >&2; exit 1; }; }+require node+require npx++if [[ -z "${SOLANA_KEYPAIR:-}" ]]; then+ echo "[publish] SOLANA_KEYPAIR must be set" >&2; exit 1+fi+SUBMIT="${SUBMIT:-1}"+APK_PATH="${APK_PATH:-$(pwd)/build/three-ws-release.apk}"+if [[ ! -f "$APK_PATH" ]]; then+ echo "[publish] APK missing: $APK_PATH — run scripts/build-apk.sh first" >&2+ exit 1+fi+SOLANA_RPC_URL="${SOLANA_RPC_URL:-https://api.mainnet-beta.solana.com}"+PUBLISH_DIR="$(pwd)/publish"++if ! npx --no-install @solana-mobile/dapp-store-cli --version >/dev/null 2>&1; then+ echo "[publish] installing @solana-mobile/dapp-store-cli"+ npm install --no-save @solana-mobile/dapp-store-cli@latest+fi++DAPP="npx --no-install @solana-mobile/dapp-store"++run() {+ echo "[publish] \$ $*"+ if [[ "${DAPP_STORE_DRYRUN:-0}" == "1" ]]; then return 0; fi+ "$@"+}++echo "[publish] verifying assetlinks.json is reachable"+if ! curl -sSfL -o /dev/null -m 10 "https://three.ws/.well-known/assetlinks.json"; then+ echo "[publish] WARNING: https://three.ws/.well-known/assetlinks.json is NOT reachable yet."+ echo "[publish] dApp Store review will fail without it. Continuing anyway."+fi++echo "[publish] minting release NFT (config: $PUBLISH_DIR/config.yaml)"+WHATS_NEW_FILE="$PUBLISH_DIR/listing/new-in-version.txt"+WHATS_NEW="$(cat "$WHATS_NEW_FILE" 2>/dev/null || echo 'Initial release.')"++run $DAPP create release \+ --keypair "$SOLANA_KEYPAIR" \+ --url "$SOLANA_RPC_URL" \+ -d "$PUBLISH_DIR" \+ --apk-file "$APK_PATH" \+ --whats-new "$WHATS_NEW"++if [[ "$SUBMIT" != "1" ]]; then+ echo "[publish] ✓ release NFT minted. SUBMIT=0 — skipping store submission."+ exit 0+fi++if [[ -z "${DAPP_STORE_API_KEY:-}" ]]; then+ echo "[publish] DAPP_STORE_API_KEY must be set to submit for review." >&2+ echo "[publish] Get one at https://publish.solanamobile.com → Settings." >&2+ exit 1+fi++echo "[publish] submitting release for review"+# Pass the API key via stdin so it never appears in process listings.+printf '%s\n' "$DAPP_STORE_API_KEY" | run $DAPP publish submit \+ --keypair "$SOLANA_KEYPAIR" \+ --url "$SOLANA_RPC_URL" \+ -d "$PUBLISH_DIR" \+ --requestor-is-authorized \+ --complies-with-solana-dapp-store-policies++echo "[publish] ✓ submitted. Track status at https://publish.solanamobile.com"diff --git a/solana-mobile/scripts/update-assetlinks.sh b/solana-mobile/scripts/update-assetlinks.shnew file mode 100755index 000000000..4082d052b--- /dev/null+++ b/solana-mobile/scripts/update-assetlinks.sh@@ -0,0 +1,52 @@+#!/usr/bin/env bash+# Refresh public/.well-known/assetlinks.json from the current release keystore.+# Safe to run repeatedly. Useful when rotating release keys.++set -euo pipefail++cd "$(dirname "${BASH_SOURCE[0]}")/.."++KEYSTORE_PATH="${KEYSTORE_PATH:-$(pwd)/android.keystore}"+KEY_ALIAS="${KEY_ALIAS:-threews}"+ASSETLINKS_OUT="${ASSETLINKS_OUT:-$(cd .. && pwd)/public/.well-known/assetlinks.json}"+PACKAGE_ID=$(node -e "console.log(require('./twa/twa-manifest.json').packageId)")++if [[ -z "${KEYSTORE_PASSWORD:-}" ]]; then+ echo "[update-assetlinks] KEYSTORE_PASSWORD must be set" >&2; exit 1+fi+if [[ ! -f "$KEYSTORE_PATH" ]]; then+ echo "[update-assetlinks] no keystore at $KEYSTORE_PATH" >&2; exit 1+fi++FINGERPRINT="$(+ keytool -list -v \+ -keystore "$KEYSTORE_PATH" \+ -alias "$KEY_ALIAS" \+ -storepass "$KEYSTORE_PASSWORD" \+ 2>/dev/null \+ | awk -F': ' '/SHA256:/ { print $2; exit }' \+ | tr -d ' '+)"++if [[ -z "$FINGERPRINT" ]]; then+ echo "[update-assetlinks] failed to extract SHA-256" >&2; exit 1+fi++mkdir -p "$(dirname "$ASSETLINKS_OUT")"+node <<NODE > "$ASSETLINKS_OUT"+const links = [{+ relation: [+ 'delegate_permission/common.handle_all_urls',+ 'delegate_permission/common.use_as_origin',+ ],+ target: {+ namespace: 'android_app',+ package_name: '${PACKAGE_ID}',+ sha256_cert_fingerprints: ['${FINGERPRINT}'],+ },+}];+process.stdout.write(JSON.stringify(links, null, 2) + '\n');+NODE++echo "[update-assetlinks] wrote $ASSETLINKS_OUT (SHA-256: $FINGERPRINT)"+echo "[update-assetlinks] deploy three.ws and verify https://three.ws/.well-known/assetlinks.json"diff --git a/solana-mobile/src/index.js b/solana-mobile/src/index.jsnew file mode 100644index 000000000..9f49371d6--- /dev/null+++ b/solana-mobile/src/index.js@@ -0,0 +1,71 @@+// Boot module for the Seeker / Solana Mobile build of three.ws.+//+// Importing this file is a no-op on desktop and on Android browsers that+// aren't running inside the three.ws TWA. Inside the TWA, it constructs an+// MwaWallet, attaches it to window.threeWsWallet (and proxies the Phantom-+// shaped API on window.solana when the user has authorized us), and emits+// a `threews:mwa-ready` CustomEvent so the rest of the app knows it can+// call standard signing methods.+//+// Usage from app entry points (e.g. src/app.js):+//+// import './solana-mobile/src/index.js';+//+// Or, for explicit control:+//+// import { initSolanaMobile } from './solana-mobile/src/index.js';+// const wallet = await initSolanaMobile();+// if (wallet) { ... } else { ... use Phantom path ... }++import { MwaWallet } from './mwa-wallet.js';+import { isSolanaMobileTwa, isSolanaMobileDevice } from './seeker-detect.js';++let bootPromise = null;++export async function initSolanaMobile({ chain = 'mainnet-beta', autoConnect = true } = {}) {+ if (typeof window === 'undefined') return null;+ if (!isSolanaMobileTwa()) return null;+ if (bootPromise) return bootPromise;++ bootPromise = (async () => {+ const wallet = new MwaWallet({ chain });+ window.threeWsWallet = wallet;+ // Mirror onto window.solana so legacy code paths that read+ // window.solana.publicKey continue to work. We do NOT set+ // isPhantom — code that gates on isPhantom will skip us, which is+ // the safer default.+ try {+ Object.defineProperty(window, 'solana', {+ value: wallet,+ configurable: true,+ writable: true,+ });+ } catch {+ window.solana = wallet;+ }+ if (autoConnect) {+ try {+ await wallet.connect({ onlyIfTrusted: true });+ } catch {+ /* User has not pre-authorized us — that's fine, they'll be+ prompted on first sign. */+ }+ }+ window.dispatchEvent(new CustomEvent('threews:mwa-ready', { detail: { wallet } }));+ return wallet;+ })();++ return bootPromise;+}++// Self-execute on import — covers the common case where the integrator+// just adds `import './solana-mobile/src/index.js'` to the app entry.+// Wrapped in a microtask so the import chain finishes before we touch+// window.solana.+queueMicrotask(() => {+ initSolanaMobile().catch((err) => {+ console.error('[threews/mwa] init failed', err);+ });+});++export { MwaWallet, isSolanaMobileTwa, isSolanaMobileDevice };diff --git a/solana-mobile/src/mwa-wallet.js b/solana-mobile/src/mwa-wallet.jsnew file mode 100644index 000000000..012195a09--- /dev/null+++ b/solana-mobile/src/mwa-wallet.js@@ -0,0 +1,369 @@+// Mobile Wallet Adapter (MWA) wrapper for three.ws.+//+// When the page is running inside the Solana Mobile TWA on a Seeker, the+// browser does not inject `window.solana`. Instead, signing must be+// delegated to the on-device Seed Vault via the MWA protocol. This module+// exposes a small, Phantom-shaped API surface so existing three.ws code+// (e.g. src/onchain/adapters/solana.js, src/wallet.js) can call+// `provider.signMessage(...)`, `provider.signTransaction(...)`, and+// `provider.connect()` without caring whether the user is on web or Seeker.+//+// The actual transport library — @solana-mobile/mobile-wallet-adapter-protocol-web3js+// — is loaded lazily on first use so desktop bundles don't pay for it.++import { PublicKey } from '@solana/web3.js';++const APP_IDENTITY = Object.freeze({+ name: 'three.ws',+ uri: 'https://three.ws',+ icon: 'https://three.ws/pwa-192x192.png',+});++const SESSION_KEY = 'threews:mwa:authToken';+const ADDRESS_KEY = 'threews:mwa:address';++let cachedTransact = null;++async function loadTransact() {+ if (cachedTransact) return cachedTransact;+ const mod = await import('@solana-mobile/mobile-wallet-adapter-protocol-web3js');+ if (typeof mod.transact !== 'function') {+ throw new Error('MWA transport is missing transact() export');+ }+ cachedTransact = mod.transact;+ return cachedTransact;+}++function readStoredAuth() {+ try {+ const token = sessionStorage.getItem(SESSION_KEY);+ const address = sessionStorage.getItem(ADDRESS_KEY);+ if (token && address) return { authToken: token, address };+ } catch {+ /* sessionStorage may be unavailable */+ }+ return null;+}++function writeStoredAuth(authToken, address) {+ try {+ sessionStorage.setItem(SESSION_KEY, authToken);+ sessionStorage.setItem(ADDRESS_KEY, address);+ } catch {+ /* non-fatal */+ }+}++function clearStoredAuth() {+ try {+ sessionStorage.removeItem(SESSION_KEY);+ sessionStorage.removeItem(ADDRESS_KEY);+ } catch {+ /* non-fatal */+ }+}++function base64ToBytes(base64) {+ const binary = atob(base64);+ const bytes = new Uint8Array(binary.length);+ for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);+ return bytes;+}++function bytesToBase64(bytes) {+ let binary = '';+ for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);+ return btoa(binary);+}++function addressFromBase64(base64) {+ return new PublicKey(base64ToBytes(base64)).toBase58();+}++function normalizeChain(chain) {+ if (chain === 'mainnet-beta' || chain === 'mainnet') return 'solana:mainnet';+ if (chain === 'devnet') return 'solana:devnet';+ if (chain === 'testnet') return 'solana:testnet';+ if (typeof chain === 'string' && chain.startsWith('solana:')) return chain;+ return 'solana:mainnet';+}++/**+ * MWA wallet wrapper. Public surface mirrors the Phantom provider closely+ * enough that three.ws's existing Solana adapter can use it as a drop-in+ * replacement when isSolanaMobileTwa() is true.+ */+export class MwaWallet {+ #address = null;+ #publicKey = null;+ #authToken = null;+ #chain = 'solana:mainnet';+ #listeners = new Map();+ #connecting = null;++ constructor({ chain = 'mainnet-beta' } = {}) {+ this.#chain = normalizeChain(chain);+ const stored = readStoredAuth();+ if (stored) {+ this.#authToken = stored.authToken;+ this.#address = stored.address;+ this.#publicKey = new PublicKey(stored.address);+ }+ }++ get isThreeWs() { return true; }++ get isPhantom() { return false; }++ get isConnected() { return Boolean(this.#publicKey); }++ get publicKey() { return this.#publicKey; }++ on(event, handler) {+ if (!event || typeof handler !== 'function') return;+ const set = this.#listeners.get(event) || new Set();+ set.add(handler);+ this.#listeners.set(event, set);+ }++ off(event, handler) {+ const set = this.#listeners.get(event);+ if (!set) return;+ set.delete(handler);+ }++ #emit(event, payload) {+ const set = this.#listeners.get(event);+ if (!set) return;+ for (const fn of set) {+ try { fn(payload); } catch (err) { console.error('[mwa] listener error', err); }+ }+ }++ async connect({ onlyIfTrusted = false } = {}) {+ if (this.isConnected) return { publicKey: this.#publicKey };+ if (this.#connecting) return this.#connecting;++ this.#connecting = (async () => {+ const transact = await loadTransact();+ const authToken = this.#authToken;+ const onlyResume = onlyIfTrusted && Boolean(authToken);+ if (onlyIfTrusted && !authToken) {+ const err = new Error('No prior MWA session to resume');+ err.code = 4001;+ throw err;+ }+ try {+ await transact(async (wallet) => {+ const result = authToken+ ? await wallet.reauthorize({ auth_token: authToken, identity: APP_IDENTITY })+ : await wallet.authorize({+ identity: APP_IDENTITY,+ chain: this.#chain,+ features: ['solana:signTransactions', 'solana:signMessages'],+ });+ this.#applyAuthResult(result);+ });+ } catch (err) {+ if (onlyResume) {+ // reauthorize() failed because the wallet revoked the token+ // — clear it and let the caller decide whether to prompt.+ clearStoredAuth();+ this.#authToken = null;+ }+ throw err;+ }+ return { publicKey: this.#publicKey };+ })();++ try {+ return await this.#connecting;+ } finally {+ this.#connecting = null;+ }+ }++ async disconnect() {+ if (!this.#authToken) {+ this.#reset();+ return;+ }+ const transact = await loadTransact();+ const token = this.#authToken;+ this.#reset();+ try {+ await transact(async (wallet) => {+ await wallet.deauthorize({ auth_token: token });+ });+ } catch (err) {+ // Deauthorize is best-effort. We've already cleared local state.+ console.warn('[mwa] deauthorize failed', err);+ }+ }++ /**+ * Sign a single Uint8Array message. Mirrors Phantom's+ * provider.signMessage(bytes, 'utf8') → { signature: Uint8Array }+ * shape.+ */+ async signMessage(messageBytes /* , _displayEncoding */) {+ await this.#ensureConnected();+ if (!(messageBytes instanceof Uint8Array)) {+ throw new TypeError('signMessage expects a Uint8Array');+ }+ const transact = await loadTransact();+ let signatureBytes = null;+ await transact(async (wallet) => {+ const reauth = await wallet.reauthorize({+ auth_token: this.#authToken,+ identity: APP_IDENTITY,+ });+ this.#applyAuthResult(reauth);+ const out = await wallet.signMessages({+ addresses: [this.#authResultAddressBase64()],+ payloads: [bytesToBase64(messageBytes)],+ });+ const first = Array.isArray(out?.signed_payloads) ? out.signed_payloads[0] : null;+ if (typeof first !== 'string') throw new Error('MWA returned no signed payload');+ // `signed_payloads` returns the original message concatenated with+ // the 64-byte ed25519 signature appended at the end.+ const combined = base64ToBytes(first);+ signatureBytes = combined.slice(combined.length - 64);+ });+ if (!signatureBytes) throw new Error('MWA signMessage produced no signature');+ return { signature: signatureBytes, publicKey: this.#publicKey };+ }++ /**+ * Sign a single VersionedTransaction or legacy Transaction. Returns the+ * same transaction object with the signature applied.+ */+ async signTransaction(transaction) {+ const [signed] = await this.signAllTransactions([transaction]);+ return signed;+ }++ async signAllTransactions(transactions) {+ if (!Array.isArray(transactions) || transactions.length === 0) {+ throw new TypeError('signAllTransactions expects a non-empty array');+ }+ await this.#ensureConnected();+ const transact = await loadTransact();+ const serialized = transactions.map((tx) => {+ if (typeof tx.serialize === 'function') {+ const bytes = tx.serialize({ requireAllSignatures: false, verifySignatures: false });+ return bytesToBase64(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes));+ }+ throw new TypeError('Transaction is missing .serialize()');+ });+ let signedBase64 = [];+ await transact(async (wallet) => {+ const reauth = await wallet.reauthorize({+ auth_token: this.#authToken,+ identity: APP_IDENTITY,+ });+ this.#applyAuthResult(reauth);+ const out = await wallet.signTransactions({ payloads: serialized });+ signedBase64 = Array.isArray(out?.signed_payloads) ? out.signed_payloads : [];+ });+ if (signedBase64.length !== transactions.length) {+ throw new Error('MWA returned mismatched signed transaction count');+ }+ return transactions.map((tx, i) => {+ const bytes = base64ToBytes(signedBase64[i]);+ return rehydrateTransaction(tx, bytes);+ });+ }++ /**+ * Sign + send + return signature string. Wraps the MWA "send" flow,+ * which is more efficient than sign+broadcast because the wallet can+ * use its own RPC.+ */+ async signAndSendTransaction(transaction, { minContextSlot } = {}) {+ await this.#ensureConnected();+ const transact = await loadTransact();+ let signature = null;+ await transact(async (wallet) => {+ const reauth = await wallet.reauthorize({+ auth_token: this.#authToken,+ identity: APP_IDENTITY,+ });+ this.#applyAuthResult(reauth);+ const bytes = transaction.serialize({ requireAllSignatures: false, verifySignatures: false });+ const out = await wallet.signAndSendTransactions({+ payloads: [bytesToBase64(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes))],+ options: minContextSlot ? { min_context_slot: minContextSlot } : undefined,+ });+ const first = Array.isArray(out?.signatures) ? out.signatures[0] : null;+ if (typeof first !== 'string') throw new Error('MWA returned no signature');+ signature = first;+ });+ return { signature };+ }++ #applyAuthResult(result) {+ if (!result || typeof result !== 'object') throw new Error('MWA returned invalid auth result');+ const account = Array.isArray(result.accounts) ? result.accounts[0] : null;+ if (!account?.address) throw new Error('MWA auth result has no account address');+ const address = decodeAccountAddress(account.address);+ this.#address = address;+ this.#publicKey = new PublicKey(address);+ if (typeof result.auth_token === 'string') {+ this.#authToken = result.auth_token;+ }+ this._lastRawAddress = account.address;+ writeStoredAuth(this.#authToken, address);+ this.#emit('connect', this.#publicKey);+ }++ #authResultAddressBase64() {+ // MWA expects the address back in the same encoding it was returned+ // (base64). We stash the raw value on the instance during authorize.+ if (typeof this._lastRawAddress === 'string') return this._lastRawAddress;+ return bytesToBase64(this.#publicKey.toBytes());+ }++ async #ensureConnected() {+ if (this.isConnected && this.#authToken) return;+ await this.connect({ onlyIfTrusted: Boolean(this.#authToken) });+ }++ #reset() {+ this.#address = null;+ this.#publicKey = null;+ this.#authToken = null;+ clearStoredAuth();+ this.#emit('disconnect', null);+ }+}++function decodeAccountAddress(rawAddress) {+ // MWA returns addresses base64-encoded. Some implementations have started+ // returning base58 directly — accept both.+ if (/^[1-9A-HJ-NP-Za-km-z]+$/.test(rawAddress) && rawAddress.length >= 32 && rawAddress.length <= 44) {+ try {+ const pk = new PublicKey(rawAddress);+ return pk.toBase58();+ } catch {+ /* fall through to base64 path */+ }+ }+ return addressFromBase64(rawAddress);+}++function rehydrateTransaction(template, signedBytes) {+ // VersionedTransaction.deserialize lives on the same web3.js entry the+ // caller already imported. We deliberately avoid importing+ // VersionedTransaction here to keep the public surface narrow — instead+ // we let the caller hand us back a constructed transaction and we copy+ // the signatures into it.+ const ctor = template?.constructor;+ if (ctor && typeof ctor.deserialize === 'function') {+ return ctor.deserialize(signedBytes);+ }+ if (ctor && typeof ctor.from === 'function') {+ return ctor.from(signedBytes);+ }+ throw new Error('Cannot rehydrate transaction: unknown constructor');+}diff --git a/solana-mobile/src/package.json b/solana-mobile/src/package.jsonnew file mode 100644index 000000000..749963f4d--- /dev/null+++ b/solana-mobile/src/package.json@@ -0,0 +1,20 @@+{+ "name": "@threews/solana-mobile",+ "private": true,+ "version": "1.0.0",+ "type": "module",+ "description": "Solana Mobile (Seeker / Saga) integration layer for three.ws — MWA wallet wrapper, TWA detection, and dApp Store boot.",+ "main": "./index.js",+ "exports": {+ ".": "./index.js",+ "./mwa-wallet": "./mwa-wallet.js",+ "./seeker-detect": "./seeker-detect.js"+ },+ "peerDependencies": {+ "@solana/web3.js": "^1.95.0"+ },+ "dependencies": {+ "@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^2.2.2",+ "@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.2"+ }+}diff --git a/solana-mobile/src/seeker-detect.js b/solana-mobile/src/seeker-detect.jsnew file mode 100644index 000000000..7d3fbfeab--- /dev/null+++ b/solana-mobile/src/seeker-detect.js@@ -0,0 +1,110 @@+// Conservative detection for "we are running inside a Solana Mobile TWA on a+// Seeker or Saga device". Used to gate Mobile Wallet Adapter (MWA) signing —+// when this returns true, we should NOT touch window.solana and should route+// every signing call through the MWA protocol to the on-device Seed Vault.+//+// We deliberately AND multiple signals together. Any single one (matchMedia+// standalone, a UA substring, document.referrer) can false-positive on+// installed PWAs in regular Chrome. We want zero false positives on desktop,+// at the cost of a few false negatives on weird Android setups (in which+// case the user just falls back to the standard browser wallet flow).++const TWA_PACKAGE_ID = 'ws.three.app';+const SEEKER_HINTS = [+ 'Seeker',+ 'SAGA',+ 'solana mobile',+ 'SolanaMobile',+];++function safeMatchMedia(query) {+ try {+ return typeof window !== 'undefined' && window.matchMedia(query).matches;+ } catch {+ return false;+ }+}++function isStandalone() {+ if (typeof window === 'undefined') return false;+ if (safeMatchMedia('(display-mode: standalone)')) return true;+ if (safeMatchMedia('(display-mode: fullscreen)')) return true;+ // iOS only — TWAs are Android, but harmless guard.+ if (window.navigator?.standalone === true) return true;+ return false;+}++function isAndroidWebView() {+ if (typeof navigator === 'undefined') return false;+ const ua = navigator.userAgent || '';+ if (!/Android/i.test(ua)) return false;+ // TWAs run inside Chrome Custom Tabs / Trusted Web Activity. The+ // `Chrome/` token is present and `wv` (the classic WebView marker) is+ // absent in TWAs — but we don't strictly require that, since some OEM+ // stacks add `; wv`.+ return /Chrome\//.test(ua);+}++function isFromTwaReferrer() {+ if (typeof document === 'undefined') return false;+ const ref = document.referrer || '';+ if (ref.startsWith(`android-app://${TWA_PACKAGE_ID}`)) return true;+ return false;+}++function isDeviceHintedSeeker() {+ if (typeof navigator === 'undefined') return false;+ const ua = navigator.userAgent || '';+ const model = navigator.userAgentData?.platform || '';+ return SEEKER_HINTS.some((hint) => ua.includes(hint) || model.includes(hint));+}++function hasMwaIntent() {+ // Solana Mobile Stack devices register a content provider that the MWA+ // JS library probes via fetch('intent:#Intent;...'). We can't probe it+ // from this synchronous helper, but presence of the global the SMS+ // browser polyfill exposes is a strong signal.+ if (typeof window === 'undefined') return false;+ // @solana-mobile/wallet-adapter-mobile sets these once initialised; in a+ // fresh TWA they're not yet present, so we don't require them.+ return Boolean(+ window.__solana_mobile_wallet_adapter_session__+ || window.__SOLANA_MOBILE_STACK__+ || window.SolanaMobileWalletAdapter,+ );+}++/**+ * Returns true when the page is rendered inside the three.ws Solana Mobile+ * TWA (Seeker / Saga). Safe to call before any wallet code loads.+ */+export function isSolanaMobileTwa() {+ if (typeof window === 'undefined') return false;+ // Hard signal: direct referrer from our TWA package.+ if (isFromTwaReferrer()) return true;+ // Combined signal: standalone Android Chrome + device hint, or the MWA+ // runtime is already present. Standalone alone isn't enough (installed+ // PWAs on phones look identical) — we also need the Solana Mobile hint.+ if (isStandalone() && isAndroidWebView() && isDeviceHintedSeeker()) return true;+ if (isStandalone() && isAndroidWebView() && hasMwaIntent()) return true;+ return false;+}++/**+ * Looser check: just "is this an Android browser context where MWA could be+ * available?" — used to decide whether it's worth lazy-loading the MWA+ * libraries. Returns true for Seeker browser sessions as well as in-TWA.+ */+export function isAndroidMobile() {+ if (typeof navigator === 'undefined') return false;+ return /Android/i.test(navigator.userAgent || '');+}++/**+ * Returns true when the device is *likely* a Solana Mobile device (Seeker or+ * Saga). May be used to surface "Sign with Seed Vault" affordances even+ * outside the TWA shell.+ */+export function isSolanaMobileDevice() {+ return isAndroidMobile() && isDeviceHintedSeeker();+}diff --git a/src/onchain/adapters/solana.js b/src/onchain/adapters/solana.jsindex 86e6e1550..63ebefb1b 100644--- a/src/onchain/adapters/solana.js+++ b/src/onchain/adapters/solana.js@@ -33,6 +33,12 @@ function detect(preferred) {if (preferred === 'phantom') return window.phantom?.solana || window.solana || null;if (preferred === 'backpack') return window.backpack?.solana || null;if (preferred === 'solflare') return window.solflare || null;+ // Seeker / Saga: solana-mobile/src/index.js installs an MWA-backed wallet+ // at window.threeWsWallet (and mirrors it onto window.solana). It has+ // isThreeWs=true and isPhantom=false, so we check for it first when no+ // specific provider was requested.+ if (window.threeWsWallet?.isThreeWs) return window.threeWsWallet;+ if (window.solana?.isThreeWs) return window.solana;if (window.phantom?.solana?.isPhantom) return window.phantom.solana;if (window.solana?.isPhantom) return window.solana;if (window.backpack?.solana) return window.backpack.solana;diff --git a/src/wallet.js b/src/wallet.jsindex 8c200762d..ffb710a96 100644--- a/src/wallet.js+++ b/src/wallet.js@@ -1,9 +1,21 @@+// Seeker / Saga boot: on Solana Mobile devices the page runs inside our TWA+// and window.solana is NOT injected by Phantom. The import below detects the+// TWA at runtime and, when present, installs an MWA-backed wallet at+// window.solana that signs through the on-device Seed Vault. On every other+// platform the import is a no-op (it checks display-mode + UA + referrer).+import '../solana-mobile/src/index.js';+let connectedWalletAddress = null;let listenersBound = false;function getPhantom() {const provider = typeof window !== 'undefined' ? window.solana : null;- return provider && provider.isPhantom ? provider : null;+ if (!provider) return null;+ // Phantom on web, or our MWA wallet on Seeker — both expose .connect /+ // .signMessage with the same shape, so the rest of this file works+ // unchanged.+ if (provider.isPhantom || provider.isThreeWs) return provider;+ return null;}function bindPhantomListeners(provider) {@@ -22,6 +34,8 @@ function bindPhantomListeners(provider) {async function onConnectWallet() {const provider = getPhantom();if (!provider) {+ // No injected wallet AND not running inside the Seeker TWA — point+ // the user at Phantom, which is the most common web fallback.window.open('https://phantom.app/', '_blank', 'noopener');return;}