-
Notifications
You must be signed in to change notification settings - Fork 0
YNU-906: Refine Nitrolite store example #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ihsraham
wants to merge
6
commits into
main
Choose a base branch
from
ynu-906-store-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3091963
Refactor demo into store example
ihsraham 1538749
Address store API review feedback
ihsraham ce98d35
Add deposit recovery checkpoint
ihsraham 23384e2
Guard deposit checkpoints
ihsraham e97735a
Add channel setup for received off-chain funds
ihsraham b1c171a
Expose Nitronode submit errors
ihsraham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,26 @@ | ||
| # API Contract Rules | ||
|
|
||
| - prefix all API routes with `/api/v1` | ||
| - active API routes are only: | ||
| - `GET /api/store/bootstrap` | ||
| - `POST /api/store/init` | ||
| - `POST /api/store/update` | ||
| - `GET /api/store/content/{id}` | ||
| - amounts are decimal strings, never floats | ||
| - error envelope: | ||
| ```json | ||
| {"error":{"code":"snake_case","message":"lowercase message"}} | ||
| ``` | ||
| - raw mutation routes in `/advanced` use `requireWriteAccess()` | ||
| - `requireWriteAccess()` accepts: | ||
| - bearer key | ||
| - unlocked write-session cookie | ||
| - store product routes are browser-cookie scoped and do not require write unlock for normal use | ||
| - `POST /api/v1/app-session/submit-state` is the single store mutation endpoint | ||
| - `POST /api/v1/app-session/submit-state` must dispatch from `session_data.action` | ||
| - store state-changing routes are wallet-signature scoped | ||
| - `POST /api/store/init` verifies `packCreateAppSessionRequestV1(definition, session_data)` | ||
| - `POST /api/store/update` verifies `packAppStateUpdateV1(app_state_update)` | ||
| - `POST /api/store/update` dispatches from `app_state_update.intent` | ||
| - deposit responses are app-signed checkpoints; bootstrap may return `pending_action` until the browser-side Clearnode submit is observed | ||
| - `GET /api/store/content/{id}` is a public demo read path and must still require a submitted wallet purchase | ||
| - do not present the content read gate as production-grade authorization | ||
| - supported public actions are: | ||
| - `deposit` | ||
| - `user_deposit` | ||
| - `purchase` | ||
| - `user_withdraw` | ||
| - hidden developer-only action: | ||
| - `app_withdraw` | ||
| - only allowed when write access is present | ||
| - server must never trust client purchase price or allocation math | ||
| - one browser-scoped store session per asset | ||
| - supported demo assets are `yusd` and `yellow` | ||
| - one wallet-scoped store session per supported asset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,23 @@ | ||
| # Clearnode WebSocket URL - use sandbox for development | ||
| CLEARNODE_WS_URL=wss://clearnode-sandbox.yellow.org/v1/ws | ||
| # Nitronode endpoint URL | ||
| CLEARNODE_WS_URL=wss://nitronode-stress.yellow.org/v1/ws | ||
|
|
||
| # Demo signer private key (generate a new key: openssl rand -hex 32) | ||
| # This wallet must have sandbox funds. Never use a mainnet key here. | ||
| DEMO_PRIVATE_KEY=0xyour_private_key_here | ||
|
|
||
| # Console API key - required for all mutation endpoints (min 32 chars) | ||
| # Generate: openssl rand -hex 32 | ||
| CONSOLE_API_KEY=your_random_32_char_key_here | ||
|
|
||
| # Blockchain RPC endpoints (JSON map of chainID -> RPC URL) | ||
| BLOCKCHAIN_RPC_URLS={"11155111":"https://sepolia.example.rpc"} | ||
|
|
||
| # Home blockchain per asset (JSON map of asset symbol -> chainID) | ||
| HOME_BLOCKCHAINS={"yusd":11155111,"yellow":11155111} | ||
|
|
||
| # Default amount used when preparing a home channel from on-chain test tokens | ||
| STORE_CHANNEL_BOOTSTRAP_AMOUNTS={"yusd":"10","yellow":"10"} | ||
|
|
||
| # Optional | ||
| PORT=8080 | ||
| LOG_LEVEL=info | ||
| SQLITE_PATH=./data/nitrolite-go-example.db | ||
| SQLITE_PATH=./data/nitrolite-store-example.db | ||
| STORE_NAME=Nitrolite App Session Store | ||
| STORE_APP_ID=default | ||
| STORE_APP_PRIVATE_KEY= | ||
| MERCHANT_NAME=Nitrolite Sandbox Merchant | ||
| MERCHANT_APP_ID=default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename
depositandwithdrawtouser_depositanduser_withdrawrespectively to give more clarity and leave space forapp_withdrawlaterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 1538749. i kept the nitrolite protocol intent values as deposit and withdraw, and changed only our session_data intent values to user_deposit and user_withdraw. docs and tests are updated too.