-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: useSkipClient hook [OTE-857] #1133
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
0813bf7
to
46da6d7
Compare
46da6d7
to
1df5b5a
Compare
78deab5
to
fa38dc0
Compare
fa38dc0
to
8135216
Compare
a4fed90
to
278f738
Compare
limit memory usememo
278f738
to
bf65466
Compare
@@ -9,7 +9,7 @@ | |||
}, | |||
"scripts": { | |||
"dev": "cp ./template.html ./index.html && vite", | |||
"build": "pnpm run build:set-last-commit-and-tag && pnpm run build:generate-entry-points && tsc && vite build", | |||
"build": "NODE_OPTIONS='--max_old_space_size=8192' pnpm run build:set-last-commit-and-tag && pnpm run build:generate-entry-points && tsc && vite build", |
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.
our builds are starting to OOM. vercel points out 3 primary suspects:
- large number of dependencies
- large data handling
- inefficient code
we haven't added any data handling and none of the code here is really has the opportunity to very inefficient in terms of build size.
so the primary theory is that our dependencies list has grown big enough where we need to up our node limits. if node crashes via OOM it can cause the vercel container to 137 exit, so we're following vercel's recommendation to increase the node heap size BUT we should probably still revisit this to optimize our build a bit.
default: | ||
return undefined; | ||
} | ||
}; | ||
|
||
export const RPCUrlsByChainId = [mainnet, ...WAGMI_SUPPORTED_CHAINS].reduce( |
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.
i tried for a while to make a test for this, but importing privy seems to break vitest 😢
happy to look into this at a later point but didnt' feel like it was worth the time now
src/hooks/transfers/skipClient.tsx
Outdated
if (chainId === getNobleChainId()) return nobleValidator; | ||
if (chainId === getNeutronChainId()) return neutronValidator; | ||
if (chainId === getOsmosisChainId()) return osmosisValidator; | ||
if (chainId === selectedDydxChainId) return validators[0]; |
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.
should this be using our compositClient.network.validatorConfig.restEndpoint
to get the selected validator rather than the first in the list?
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.
oh nice!!! thank you! is there a reason why we use validators[0]
in the useAccountsBalance hook?
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.
Hmmm oh that should be using compositClient.network.validatorConfig.restEndpoint
as well 😅
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.
ooo okay, no worries i can just refactor that in a smol followup PR. just wanted to make sure i understood 🫡
src/lib/skip.ts
Outdated
getRpcEndpointForChain: async (chainId: string) => { | ||
if (chainId === 'noble-1') return 'https://noble-yx-rpc.polkachu.com/'; | ||
if (chainId === 'dydx-mainnet-1') return 'https://dydx-ops-rpc.kingnodes.com'; | ||
if (chainId === '43114') return 'https://api.avax.network/ext/bc/C/rpc'; |
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.
Maybe we can get these from config as well.
Also interesting that we need to set avax specifically 👀
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.
oh, sorry this was just testing code. this should be replaced by the useSkipClient
hook. forgot to hook that up
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.
actually, i'm unsure how this code even snuck in here in the first place 👀 must have accidentally moved it from another branch. oops!
Add useSkipClient hook to enable use of skip client in react code.
We're constructing the skip client within the react lifecycle to leverage the endpointConfig hook and selectedDydxChainId state items to make sure we're getting the most accurate data for rpc url construction.
Slightly refactors how we construct transports for wagmi to make it easier to access the rpcUrls
Testing Strategy: