-
Notifications
You must be signed in to change notification settings - Fork 2
⚡️ app: misc optimizations #679
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@exactly/mobile": patch | ||
| --- | ||
|
|
||
| ⚡️ defer lifi sdk initialization |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@exactly/mobile": patch | ||
| --- | ||
|
|
||
| ⚡️ remove startup-blocking viem/chains import |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,25 +2,31 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; | |
|
|
||
| import { sdk } from "@farcaster/miniapp-sdk"; | ||
| import { farcasterMiniApp as miniAppConnector } from "@farcaster/miniapp-wagmi-connector"; | ||
| import { http } from "viem"; | ||
| import * as chains from "viem/chains"; | ||
| import { createClient, http, type Chain } from "viem"; | ||
| import { createConfig, createStorage, custom, injected } from "wagmi"; | ||
|
|
||
| import chain from "@exactly/common/generated/chain"; | ||
|
|
||
| import publicClient from "../publicClient"; | ||
|
|
||
| const config = createConfig({ | ||
| chains: [chain, ...Object.values(chains)], | ||
| chains: [chain], | ||
| connectors: [miniAppConnector(), injected()], | ||
| transports: { | ||
| ...Object.fromEntries(Object.values(chains).map((c) => [c.id, http()])), | ||
| [chain.id]: custom(publicClient), | ||
| client({ chain: c }) { | ||
| return createClient({ chain: c, transport: c.id === chain.id ? custom(publicClient) : http() }); | ||
| }, | ||
| storage: createStorage({ key: "wagmi.owner", storage: AsyncStorage }), | ||
| }); | ||
| export default config; | ||
|
|
||
| export function addChains(newChains: readonly Chain[]) { | ||
| const current = config.chains; | ||
| const ids = new Set(current.map((c) => c.id)); | ||
| const toAdd = newChains.filter((c) => !ids.has(c.id)); | ||
| if (toAdd.length === 0) return; | ||
| config._internal.chains.setState([...current, ...toAdd]); | ||
| } | ||
|
Comment on lines
+22
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n src/utils/wagmi/owner.tsRepository: exactly/exa Length of output: 1981 🏁 Script executed: # Search for wagmi config initialization and imports in the project
rg "config\s*=" src/utils/wagmi/ -A 3 -B 3Repository: exactly/exa Length of output: 397 🌐 Web query:
💡 Result: wagmi does not expose a public
Practical pattern: include all chains you may need up-front in Sources: 🌐 Web query:
💡 Result: In wagmi v2+, anything on
Practical takeaway: don’t rely on Sources: [1] Remove use of wagmi's private The If dynamic chain support is required, either pre-configure all chains upfront in the 🤖 Prompt for AI Agents |
||
|
|
||
| export async function getConnector() { | ||
| const miniApp = await sdk.isInMiniApp(); | ||
| const connector = miniApp | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: exactly/exa
Length of output: 1822
🏁 Script executed:
Repository: exactly/exa
Length of output: 1120
🏁 Script executed:
# Check the component structure and imports head -50 src/components/activity/PendingProposals.tsxRepository: exactly/exa
Length of output: 1455
🌐 Web query:
TanStack Query v5 subscribe to query cache updates non-reactive getQueriesData💡 Result:
queryClient.getQueriesData()is synchronous and returns a snapshot; it won’t “react” to cache changes by itself. To get updates, subscribe to the QueryCache, and on each event re-readgetQueriesData()(optionally batching the callback). [1] [2]Sources: QueryCache subscription API [1], QueryClient
getQueriesData()andgetQueryCache()[2],notifyManager.batchCalls()[3].References: [1] [2] [3]
getQueriesDatais non-reactive; chain names won't update when bridge sources are cached.queryClient.getQueriesData(...)returns a snapshot and won't trigger re-renders when the cache updates, leaving the UI stuck with the "Chain {id}" fallback even after bridge sources arrive. UseuseQueryto subscribe reactively to bridge sources instead of querying the cache directly.🤖 Prompt for AI Agents