-
Notifications
You must be signed in to change notification settings - Fork 0
[P-1149] Add Porto example (WIP) #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
base: main
Are you sure you want to change the base?
Conversation
|
bugbot run |
|
Skipping Bugbot: Bugbot is disabled for this repository |
|
bugbot run |
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.
Pull Request Overview
This PR adds a comprehensive example application demonstrating the integration of Porto SDK (passkey-based wallet) with Formo Analytics for tracking wallet events and user interactions in a Next.js environment.
- Created a complete Next.js Wagmi app with Porto connector integration
- Implemented Formo Analytics SDK for comprehensive event tracking
- Added testing interface with UI components for all wallet operations
Reviewed Changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wagmi.ts | Wagmi configuration with Porto connector and multi-chain support |
| src/app/providers.tsx | React providers setup for Wagmi, TanStack Query, and Formo Analytics |
| src/app/page.tsx | Main testing interface with wallet operations and event tracking |
| src/app/layout.tsx | Next.js app layout with SSR cookie state initialization |
| src/app/globals.css | Global CSS styles with dark/light theme support |
| package.json | Project dependencies including Porto SDK and Formo Analytics |
| README.md | Comprehensive documentation and setup instructions |
| INTEGRATION_TEST_RESULTS.md | Detailed integration test results and technical documentation |
| .npmrc | NPM configuration for legacy peer dependencies |
| .env.example | Environment variables template |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/wagmi.ts
Outdated
| connectors: [ | ||
| injected(), | ||
| baseAccount(), | ||
| walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID! }), |
Copilot
AI
Sep 15, 2025
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 non-null assertion operator (!) could cause runtime errors if the environment variable is undefined. Consider providing a fallback value or conditional logic to handle missing project ID gracefully.
| walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID! }), | |
| walletConnect({ | |
| projectId: (() => { | |
| const id = process.env.NEXT_PUBLIC_WC_PROJECT_ID; | |
| if (!id) { | |
| throw new Error("Environment variable NEXT_PUBLIC_WC_PROJECT_ID is required for WalletConnect but is not defined."); | |
| } | |
| return id; | |
| })(), | |
| }), |
src/app/page.tsx
Outdated
| const handleCustomEvent = () => { | ||
| if (!customEventName) return | ||
|
|
||
| const eventData = customEventData ? JSON.parse(customEventData) : {} |
Copilot
AI
Sep 15, 2025
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.
JSON.parse could throw an error if customEventData is malformed JSON. Add try-catch error handling to prevent application crashes from invalid user input.
| const eventData = customEventData ? JSON.parse(customEventData) : {} | |
| let eventData = {}; | |
| if (customEventData) { | |
| try { | |
| eventData = JSON.parse(customEventData); | |
| } catch (e) { | |
| eventData = {}; | |
| // Optionally, you could log the error or notify the user here | |
| } | |
| } |
| "@formo/analytics": "^1.20.0", | ||
| "@tanstack/react-query": "5.45.1", | ||
| "next": "14.2.4", | ||
| "porto": "^0.2.5", |
Copilot
AI
Sep 15, 2025
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.
Using 'latest' for version specifications can lead to unpredictable builds. Consider pinning to specific versions for better reproducibility and stability.
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", | ||
| "viem": "latest", | ||
| "wagmi": "latest" |
Copilot
AI
Sep 15, 2025
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.
Using 'latest' for version specifications can lead to unpredictable builds. Consider pinning to specific versions for better reproducibility and stability.
| "wagmi": "latest" | |
| "wagmi": "1.7.0" |
P-1149 SDK: Porto integration
https://x.com/gakonst/status/1927764579028783156
TODOs
Wallet library based on passkeys Formo should be able to detect wallet events (connect wallet, etc)
References
|
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.
Pull Request Overview
Copilot reviewed 10 out of 14 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/wagmi.ts
Outdated
| walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID! }), | ||
| porto(), | ||
| ], |
Copilot
AI
Sep 15, 2025
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 non-null assertion operator (!) will cause a runtime error if NEXT_PUBLIC_WC_PROJECT_ID is undefined. Consider adding validation or making this parameter optional with a fallback.
| walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID! }), | |
| porto(), | |
| ], | |
| process.env.NEXT_PUBLIC_WC_PROJECT_ID | |
| ? walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID }) | |
| : undefined, | |
| porto(), | |
| ].filter(Boolean), |
| to_chain_id: targetChainId, | ||
| address: account.address | ||
| }) | ||
| switchChain({ chainId: targetChainId as any }) |
Copilot
AI
Sep 15, 2025
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.
Using 'as any' type assertion bypasses type safety. The chainId should be properly typed as the expected chain ID type from Wagmi.
| switchChain({ chainId: targetChainId as any }) | |
| switchChain({ chainId: targetChainId }) |
| } catch (error) { | ||
| console.error('Invalid JSON in custom event data:', error) | ||
| alert('Invalid JSON format in event data. Please check your input.') |
Copilot
AI
Sep 15, 2025
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.
Using 'alert()' for error messages provides poor user experience. Consider using a more user-friendly notification system or inline error display.
| "porto": "^0.2.5", | ||
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", | ||
| "viem": "latest", | ||
| "wagmi": "latest" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^20.12.10", | ||
| "@types/react": "^18.3.1", | ||
| "@types/react-dom": "^18.3.0", | ||
| "@wagmi/cli": "latest", |
Copilot
AI
Sep 15, 2025
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.
Using 'latest' for dependencies can lead to unexpected breaking changes. Consider pinning to specific versions for better stability, especially for production applications.
| "porto": "^0.2.5", | |
| "react": "^18.3.1", | |
| "react-dom": "^18.3.1", | |
| "viem": "latest", | |
| "wagmi": "latest" | |
| }, | |
| "devDependencies": { | |
| "@types/node": "^20.12.10", | |
| "@types/react": "^18.3.1", | |
| "@types/react-dom": "^18.3.0", | |
| "@wagmi/cli": "latest", | |
| "porto": "0.2.5", | |
| "react": "^18.3.1", | |
| "react-dom": "^18.3.1", | |
| "viem": "2.8.0", | |
| "wagmi": "2.8.0" | |
| }, | |
| "devDependencies": { | |
| "@types/node": "^20.12.10", | |
| "@types/react": "^18.3.1", | |
| "@types/react-dom": "^18.3.0", | |
| "@wagmi/cli": "2.8.0", |
Wallet events not getting detected
May need wagmi support
TODOs