-
Notifications
You must be signed in to change notification settings - Fork 3
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
Testnets #148
Testnets #148
Conversation
Also improves UX on wallet's address/chain changes
feat: env var wallet connect projectId
WalkthroughThe pull request introduces a new environment variable, Changes
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
env.d.tsOops! Something went wrong! :( ESLint: 9.14.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for proof-of-humanity-v2 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (3)
src/components/HighOrder/withClientConnected.tsx (1)
Line range hint
34-38
: Consider making Web3Modal theme configurableThe theme mode is hardcoded to "light". Consider making it configurable through props or a theme context for better flexibility and dark mode support.
- themeMode="light" + themeMode={props.theme || "light"}You'll need to update the component props type to include the optional theme:
type WithClientConnectedProps = T & { theme?: "light" | "dark"; };next.config.js (1)
Line range hint
32-39
: Consider enabling build-time checks for wallet connectivity codeThe configuration currently ignores both ESLint and TypeScript build errors. While this can speed up development, it might hide potential issues in wallet connectivity code, which is critical for security and user experience.
Consider:
- Enabling these checks specifically for wallet-related code
- Gradually fixing the existing errors to enable strict checking
- At minimum, running these checks in CI for critical paths
src/app/[pohid]/[chain]/[request]/ActionBar.tsx (1)
262-270
: Consider splitting the useEffect for better separation of concernsThe current useEffect handles both advance and execute actions, which violates the Single Responsibility Principle. While the dependencies are correctly specified, the effect's logic could be more focused.
Consider splitting into two separate effects:
// Effect for advance action useEffect(() => { if (action === ActionType.ADVANCE && !revocation) { prepareAdvance({ args: [ requester, onChainVouches, offChainVouches.map((v) => { const sig = hexToSignature(v.signature); return { expirationTime: v.expiration, v: Number(sig.v), r: sig.r, s: sig.s, }; }), ], }); } }, [action, requester, revocation, onChainVouches, offChainVouches, prepareAdvance]); // Effect for execute action useEffect(() => { if (action === ActionType.EXECUTE) { prepareExecute({ args: [pohId, BigInt(index)] }); } }, [action, pohId, index, prepareExecute]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
env.d.ts
(1 hunks)next.config.js
(1 hunks)src/app/[pohid]/[chain]/[request]/ActionBar.tsx
(4 hunks)src/components/HighOrder/withClientConnected.tsx
(1 hunks)
🔇 Additional comments (6)
env.d.ts (2)
14-14
: LGTM! Type declaration is correctly added.
The WALLET_CONNECT_PROJECT_ID
environment variable is properly typed as string and appropriately placed within the ProcessEnv interface.
14-14
: Verify environment configuration across deployment targets.
Since this environment variable is crucial for WalletConnect functionality across different networks, ensure it's properly configured in all relevant deployment environments.
src/components/HighOrder/withClientConnected.tsx (2)
10-10
: Verify environment variable configuration
Ensure the WALLET_CONNECT_PROJECT_ID
is properly configured in all necessary environments.
#!/bin/bash
# Check for environment variable configuration
echo "Checking next.config.js for environment variable..."
rg "WALLET_CONNECT_PROJECT_ID" --type javascript
echo "Checking for .env files..."
fd -g ".env*"
echo "Checking TypeScript environment declarations..."
rg "WALLET_CONNECT_PROJECT_ID" --type typescript
Line range hint 15-19
: Consider implications of autoConnect setting
The autoConnect: true
setting will attempt to reconnect to the last used wallet automatically. While convenient, this might lead to unexpected wallet prompts for users. Consider if this aligns with your UX requirements.
✅ Verification successful
autoConnect is only set in withClientConnected.tsx
No other files have autoConnect
configured as true
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if autoConnect is consistently configured across the codebase
rg -l "autoConnect.*true" --type typescript
Length of output: 672
Script:
#!/bin/bash
# Check if autoConnect is consistently configured across TypeScript files
rg -l "autoConnect\s*:\s*true" --glob "*.ts" --glob "*.tsx"
Length of output: 110
next.config.js (1)
20-20
: LGTM! Verify environment variable setup
The addition of WALLET_CONNECT_PROJECT_ID
to the environment configuration is correct and aligns with best practices for managing wallet connectivity across different networks.
Let's verify the environment variable setup:
src/app/[pohid]/[chain]/[request]/ActionBar.tsx (1)
408-408
: LGTM: Chain ID validation prevents cross-chain operations
The addition of userChainId !== chain.id
to the button's disabled state is a crucial security feature that prevents users from performing operations when connected to the wrong network. This is particularly important for testnet support.
Also applies to: 422-422
|
||
const projectId = "9185f693b1bc3d1d3440300c1559a202"; | ||
const projectId = process.env.WALLET_CONNECT_PROJECT_ID; |
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.
🛠️ Refactor suggestion
Add validation for the WalletConnect project ID
The project ID is a critical configuration value. Consider adding validation to ensure it's properly set:
-const projectId = process.env.WALLET_CONNECT_PROJECT_ID;
+const projectId = process.env.WALLET_CONNECT_PROJECT_ID;
+if (!projectId) {
+ throw new Error(
+ 'WALLET_CONNECT_PROJECT_ID environment variable is not set. Please check your configuration.'
+ );
+}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const projectId = process.env.WALLET_CONNECT_PROJECT_ID; | |
const projectId = process.env.WALLET_CONNECT_PROJECT_ID; | |
if (!projectId) { | |
throw new Error( | |
'WALLET_CONNECT_PROJECT_ID environment variable is not set. Please check your configuration.' | |
); | |
} |
!errorRef.current && toast.error("Advance is not possible"); | ||
errorRef.current = true; | ||
setAction(ActionType.VOUCH); | ||
//setAction(ActionType.VOUCH); |
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.
Improve error handling for advance operation
The changes have two potential issues:
- The error message is now less specific, which might make it harder for users to understand why the advance operation failed.
- Commenting out the state reset (
setAction(ActionType.VOUCH)
) could leave the UI in an inconsistent state after a failed advance operation.
Consider:
- Using a more descriptive error message that explains why the advance is not possible
- Implementing proper state management after failed operations
- !errorRef.current && toast.error("Advance is not possible");
+ !errorRef.current && toast.error("Advance is not possible. Please ensure all vouches are valid.");
errorRef.current = true;
- //setAction(ActionType.VOUCH);
+ setAction(ActionType.VOUCH); // Reset to a valid state after failure
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
!errorRef.current && toast.error("Advance is not possible"); | |
errorRef.current = true; | |
setAction(ActionType.VOUCH); | |
//setAction(ActionType.VOUCH); | |
!errorRef.current && toast.error("Advance is not possible. Please ensure all vouches are valid."); | |
errorRef.current = true; | |
setAction(ActionType.VOUCH); // Reset to a valid state after failure |
Summary by CodeRabbit
Release Notes
New Features
WALLET_CONNECT_PROJECT_ID
, enhancing the configuration for Wallet Connect functionality.Improvements
Bug Fixes
Chores
withClientConnected
component to dynamically use theWALLET_CONNECT_PROJECT_ID
from environment variables.