docs(portal): fix syntax and compilation errors in v5 guide snippets#8845
docs(portal): fix syntax and compilation errors in v5 guide snippets#8845TanmayDagur wants to merge 1 commit into
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
@TanmayDagur is attempting to deploy a commit to the thirdweb Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughUpdated TypeScript v5 documentation examples to use the current client configuration, account construction, wallet connection, and balance retrieval parameters. Changesv5 documentation examples
Estimated code review effort: 1 (Trivial) | ~4 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/portal/src/app/typescript/v5/auth/page.mdx`:
- Line 51: Guard the THIRDWEB_PRIVATE_KEY value before the privateKeyToAccount
call in the adminAccount configuration. Validate that the environment-derived
privateKey is present, and fail explicitly before constructing the account when
it is missing; preserve the existing account creation path for a provided key.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f12d2c02-56b5-4742-8f10-2c3529889e88
📒 Files selected for processing (2)
apps/portal/src/app/typescript/v5/auth/page.mdxapps/portal/src/app/typescript/v5/getting-started/page.mdx
| domain: "localhost:3000", | ||
| client: thirdwebClient, | ||
| adminAccount: privateKeyToAccount({client, privateKey}) | ||
| adminAccount: privateKeyToAccount({ client: thirdwebClient, privateKey }), |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,140p' apps/portal/src/app/typescript/v5/auth/page.mdx && printf '\n---\n' && rg -n "privateKeyToAccount|PRIVATE_KEY|process\.env" apps/portal/src/app -SRepository: thirdweb-dev/js
Length of output: 9328
🌐 Web query:
thirdweb privateKeyToAccount undefined replace source code
💡 Result:
If you are encountering an undefined error when using privateKeyToAccount in the thirdweb TypeScript SDK, please note that the function has been renamed to privateKeyAccount in newer versions of the SDK [1]. To resolve this, update your import and usage as follows: 1. Update your import: import { privateKeyAccount } from "thirdweb/wallets"; 2. Update your implementation: const account = privateKeyAccount({ client, privateKey: process.env.PRIVATE_KEY as string, }); If you were previously relying on the source code implementation of privateKeyToAccount, it is worth noting that the internal implementation automatically handles prefixing the private key with 0x [2]: const privateKey = 0x${options.privateKey.replace(/^0x/, "")} satisfies Hex; If you continue to face runtime or build errors (such as issues in specific environments like Expo), ensure your SDK is updated to the latest version [3], as bug fixes related to import/build errors are frequently released [3]. Top results: [3] #3299 [2] https://cdn.jsdelivr.net/npm/thirdweb@5.116.1/src/wallets/private-key.ts [1] https://portal.thirdweb.com/typescript/v5/account-abstraction/get-started
Citations:
- 1: https://portal.thirdweb.com/typescript/v5/account-abstraction/get-started
- 2: https://cdn.jsdelivr.net/npm/thirdweb@5.116.1/src/wallets/private-key.ts
- 3: [React Native][Thirdweb v5] Error trying to implement SIWE on Expo API routes #3299
🏁 Script executed:
python3 - <<'PY'
import urllib.request
url = "https://cdn.jsdelivr.net/npm/thirdweb@5.116.1/src/wallets/private-key.ts"
with urllib.request.urlopen(url, timeout=20) as r:
text = r.read().decode("utf-8")
for i, line in enumerate(text.splitlines(), 1):
if "replace(" in line or "export function privateKey" in line or "privateKeyToAccount" in line:
start = max(1, i-3)
end = min(len(text.splitlines()), i+5)
for j in range(start, end+1):
print(f"{j}:{text.splitlines()[j-1]}")
print("---")
PYRepository: thirdweb-dev/js
Length of output: 2747
Guard THIRDWEB_PRIVATE_KEY before constructing the account. privateKeyToAccount dereferences privateKey immediately, so this example will throw on startup if the env var is missing. Add an explicit check before the call.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/portal/src/app/typescript/v5/auth/page.mdx` at line 51, Guard the
THIRDWEB_PRIVATE_KEY value before the privateKeyToAccount call in the
adminAccount configuration. Validate that the environment-derived privateKey is
present, and fail explicitly before constructing the account when it is missing;
preserve the existing account creation path for a provided key.
docs(portal): fix syntax and compilation errors in v5 guide snippets
What
This PR fixes critical syntax and compilation errors in the code examples on the Getting Started and Auth landing pages in the documentation portal.
Why
Currently, copying and pasting the official snippets results in direct compilation or runtime errors:
getting-started/page.mdxreferenced an undefinedTEST_CLIENTvariable and passed an invalid type togetWalletBalance(missingclientparameter and passingaccountinstead ofaddress).auth/page.mdxcontained a syntax error (semicolon inside an object literal) and used an undefinedclientvariable (should bethirdwebClient).Changes
getting-started/page.mdxwallet connect example andgetWalletBalancesignature.clienttothirdwebClientinauth/page.mdx.PR-Codex overview
This PR focuses on updating the authentication and wallet connection logic in the
page.mdxfiles for improved clarity and consistency in handling client and account data.Detailed summary
In
apps/portal/src/app/typescript/v5/auth/page.mdx:clientreference tothirdwebClientinadminAccount.In
apps/portal/src/app/typescript/v5/getting-started/page.mdx:clientreference in the wallet connection.address: account.addressto thegetWalletBalancefunction call.Summary by CodeRabbit