-
Notifications
You must be signed in to change notification settings - Fork 197
docs: add recipe for session keys #2045
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
How to use the Graphite Merge QueueAdd the label graphite-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
🌿 Documentation Preview
|
const createSessionRequest = { | ||
id: 1, | ||
jsonrpc: '2.0', | ||
method: 'wallet_createSession', | ||
params: [body] | ||
}; |
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.
The API endpoint /api/wallet-prepare-calls
is using the incorrect JSON-RPC method. The code currently uses wallet_createSession
, but since this endpoint is specifically for preparing calls, it should use the wallet_prepareCalls
method instead. This mismatch between the endpoint's purpose and the method being called could lead to unexpected behavior.
const createSessionRequest = { | |
id: 1, | |
jsonrpc: '2.0', | |
method: 'wallet_createSession', | |
params: [body] | |
}; | |
const createSessionRequest = { | |
id: 1, | |
jsonrpc: '2.0', | |
method: 'wallet_prepareCalls', | |
params: [body] | |
}; |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
|
||
export function useSignerAddress() { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = (useState < string) | (null > null); |
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.
The TypeScript syntax in this line has formatting issues. The correct syntax for this useState declaration should be:
const [error, setError] = useState<string | null>(null);
The current version has spaces between the angle brackets and types, which will cause a compilation error.
const [error, setError] = (useState < string) | (null > null); | |
const [error, setError] = useState<string | null>(null); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
| 1 | `/api/wallet-create-session` | `wallet_createSession` | Get signer address | | ||
| 2 | `/api/wallet-request-account` | `wallet_requestAccount` | Create smart account | | ||
| 3 | `/api/wallet-create-session` | `wallet_createSession` | Create session key | | ||
| 4 | `/api/wallet-sign-authorization` | `wallet_signAuthorization` | Sign session authorization | |
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.
Documentation table contains incorrect API endpoint mappings. Step 1 shows /api/wallet-create-session
for getting signer address, but the actual hook useSignerAddress
doesn't use any API endpoint. Step 4 shows /api/wallet-sign-authorization
with method wallet_signAuthorization
, but this endpoint doesn't exist in the codebase - the signing is done client-side. These incorrect mappings will mislead developers about the actual implementation.
| 1 | `/api/wallet-create-session` | `wallet_createSession` | Get signer address | | |
| 2 | `/api/wallet-request-account` | `wallet_requestAccount` | Create smart account | | |
| 3 | `/api/wallet-create-session` | `wallet_createSession` | Create session key | | |
| 4 | `/api/wallet-sign-authorization` | `wallet_signAuthorization` | Sign session authorization | | |
| 1 | N/A | N/A | Get signer address | | |
| 2 | `/api/wallet-request-account` | `wallet_requestAccount` | Create smart account | | |
| 3 | `/api/wallet-create-session` | `wallet_createSession` | Create session key | | |
| 4 | N/A | N/A | Sign session authorization | | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
PR-Codex overview
This PR introduces a comprehensive guide for implementing Smart Wallet Session Keys with frontend signing and backend processing using Alchemy. It includes detailed steps, code snippets, and API endpoints for creating and managing smart wallet sessions.
Detailed summary
docs/docs.yml
.docs/pages/recipes/use-session-keys.mdx
with detailed instructions.useSignerAddress
,useSmartAccount
,useSession
,useSessionAuthorization
).wallet_requestAccount
,wallet_prepare-calls
,wallet_send-prepared-calls
).src/app/page.tsx
to integrate the session key workflow..env.local
.