-
Notifications
You must be signed in to change notification settings - Fork 47
update wallet connect #828
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cea8d3d
chore: wallet connect updates
iamonuwa 9e4c863
refactor: use sn-api endpoints to handle siwe
iamonuwa fe9e7cb
chore: set signOutOnDisconnect to false
iamonuwa 4c4e45b
u
felicio e4f64d3
u
felicio 9e31981
Update wallet connect in changeset
felicio 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "hub": patch | ||
| --- | ||
|
|
||
| update wallet connect |
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # note: next lint doesn't use .env.development | ||
| # note: use .env.local instead for now | ||
| # | ||
| # – https://github.com/vercel/next.js/discussions/32354 | ||
|
|
||
| # .env, .env.development, and .env.production files should be included in your repository as they define defaults. | ||
| # .env*.local should be added to .gitignore, as those files are intended to be ignored. | ||
| # .env.local is where secrets can be stored. | ||
| # | ||
| # – https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#default-environment-variables | ||
|
|
||
| # The vercel env pull sub-command will export development environment variables to a local .env file or a different file of your choice. | ||
| # | ||
| # `vercel env pull .env[.development].local` | ||
| # | ||
| # – https://vercel.com/docs/cli/env#exporting-development-environment-variables | ||
|
|
||
|
|
||
| NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID="" | ||
| NEXT_PUBLIC_STATUS_NETWORK_API_URL="" |
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,25 +1,52 @@ | ||
| import type { Chain } from 'wagmi/chains' | ||
| import { getDefaultConfig } from 'connectkit' | ||
| import { defineChain } from 'viem' | ||
| import { createConfig, http } from 'wagmi' | ||
| import { type Chain, mainnet } from 'wagmi/chains' | ||
|
|
||
| export const statusNetworkTestnet: Chain = { | ||
| id: Number(1660990954), | ||
| import { clientEnv } from './env.client.mjs' | ||
|
|
||
| import type { | ||
| CreateConfigParameters, | ||
| CreateConnectorFn, | ||
| Transport, | ||
| } from 'wagmi' | ||
|
|
||
| export const testnet = defineChain({ | ||
| id: 1660990954, | ||
| name: 'Status Network Testnet', | ||
| nativeCurrency: { | ||
| decimals: 18, | ||
| name: 'Ether', | ||
| symbol: 'ETH', | ||
| }, | ||
| testnet: true, | ||
| sourceId: 1660990954, | ||
| nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, | ||
| rpcUrls: { | ||
| default: { | ||
| http: ['https://public.sepolia.rpc.status.network'], | ||
| }, | ||
| public: { | ||
| http: ['https://public.sepolia.rpc.status.network'], | ||
| }, | ||
| }, | ||
| blockExplorers: { | ||
| default: { | ||
| name: 'Status Explorer', | ||
| url: 'https://sepoliascan.status.network', | ||
| }, | ||
| }, | ||
| } | ||
| }) | ||
|
|
||
| export const getDefaultWagmiConfig = () => | ||
| getDefaultConfig({ | ||
| chains: [mainnet, testnet], | ||
| transports: { | ||
| [mainnet.id]: http(mainnet.rpcUrls.default.http[0]), | ||
| [testnet.id]: http(testnet.rpcUrls.default.http[0]), | ||
| }, | ||
| walletConnectProjectId: | ||
| clientEnv.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string, | ||
| appName: 'Status Hub', | ||
| appDescription: 'Status Network DeFi Dashboard', | ||
| appUrl: 'https://status.app', | ||
| appIcon: 'https://status.app/icon.png', | ||
| }) as CreateConfigParameters< | ||
| readonly [Chain, ...Chain[]], | ||
| Record<number, Transport>, | ||
| readonly CreateConnectorFn[] | ||
| > | ||
|
|
||
| export const wagmiConfig = createConfig(getDefaultWagmiConfig()) |
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,3 +1,4 @@ | ||
| export * from './address' | ||
| export * from './chain' | ||
| export * from './siwe' | ||
| export * from './staking' |
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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { clientEnv } from './env.client.mjs' | ||
|
|
||
| import type { SIWEConfig } from 'connectkit' | ||
|
|
||
| // API configuration | ||
| const API_BASE_URL = clientEnv.NEXT_PUBLIC_STATUS_NETWORK_API_URL | ||
|
|
||
| const AUTH_ENDPOINTS = { | ||
| verify: `${API_BASE_URL}/auth/ethereum`, | ||
| session: `${API_BASE_URL}/auth/me`, | ||
| logout: `${API_BASE_URL}/auth/logout`, | ||
| } as const | ||
|
|
||
| // Helper for API calls | ||
| const fetchAPI = async (url: string, options?: RequestInit) => { | ||
| const response = await fetch(url, { | ||
| credentials: 'include', // Send cookies with cross-origin requests | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| ...options?.headers, | ||
| }, | ||
| ...options, | ||
| }) | ||
| return response | ||
| } | ||
|
|
||
| export const siweConfig: SIWEConfig = { | ||
| getNonce: async () => { | ||
| return Math.random().toString(36).substring(2, 15) | ||
| }, | ||
|
|
||
| createMessage: async () => { | ||
| const payload = { timestamp: Math.floor(Date.now() / 1000) } | ||
| return window.btoa(JSON.stringify(payload)) | ||
| }, | ||
|
|
||
| verifyMessage: async ({ message, signature }) => { | ||
| try { | ||
| const response = await fetchAPI(AUTH_ENDPOINTS.verify, { | ||
| method: 'POST', | ||
| body: JSON.stringify({ payload: message, signature }), | ||
| }) | ||
| return response.ok | ||
| } catch { | ||
| return false | ||
| } | ||
| }, | ||
|
|
||
| getSession: async () => { | ||
| try { | ||
| const response = await fetchAPI(AUTH_ENDPOINTS.session) | ||
| if (!response.ok) return null | ||
|
|
||
| const data = await response.json() | ||
| return data.result ?? null | ||
| } catch { | ||
| return null | ||
| } | ||
| }, | ||
|
|
||
| signOut: async () => { | ||
| try { | ||
| const response = await fetchAPI(AUTH_ENDPOINTS.logout, { | ||
| method: 'POST', | ||
| }) | ||
| return response.ok | ||
| } catch { | ||
| return false | ||
| } | ||
| }, | ||
|
|
||
| signOutOnDisconnect: false, | ||
| } |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
@status-im/web fyi, rename from NEXT_PUBLIC_API_URL to NEXT_PUBLIC_STATUS_NETWORK_API_URL