Skip to content
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

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Conversation

yogurtandjam
Copy link
Contributor

@yogurtandjam yogurtandjam commented Oct 14, 2024

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:

  • regression test: just make sure that the app runs and balances show properly (you may need to pull the branch down locally and run it on mainnet to confirm this. i have confirmed it on my end)

@yogurtandjam yogurtandjam requested a review from a team as a code owner October 14, 2024 19:43
Copy link

linear bot commented Oct 14, 2024

Copy link

vercel bot commented Oct 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2024 10:36pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2024 10:36pm

@yogurtandjam yogurtandjam force-pushed the jerms/OTE-857_useSkipClient branch from 46da6d7 to 1df5b5a Compare October 14, 2024 19:49
@yogurtandjam yogurtandjam force-pushed the jerms/OTE-857_useSkipClient branch from 78deab5 to fa38dc0 Compare October 14, 2024 20:25
@yogurtandjam yogurtandjam force-pushed the jerms/OTE-857_useSkipClient branch from fa38dc0 to 8135216 Compare October 14, 2024 20:32
@yogurtandjam yogurtandjam force-pushed the jerms/OTE-857_useSkipClient branch from a4fed90 to 278f738 Compare October 14, 2024 21:01
limit memory

usememo
@yogurtandjam yogurtandjam force-pushed the jerms/OTE-857_useSkipClient branch from 278f738 to bf65466 Compare October 14, 2024 21:05
@@ -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",
Copy link
Contributor Author

@yogurtandjam yogurtandjam Oct 14, 2024

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(
Copy link
Contributor Author

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

if (chainId === getNobleChainId()) return nobleValidator;
if (chainId === getNeutronChainId()) return neutronValidator;
if (chainId === getOsmosisChainId()) return osmosisValidator;
if (chainId === selectedDydxChainId) return validators[0];
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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 😅

Copy link
Contributor Author

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';
Copy link
Contributor

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 👀

Copy link
Contributor Author

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

Copy link
Contributor Author

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!

@yogurtandjam yogurtandjam merged commit 5c9915d into main Oct 15, 2024
9 checks passed
@yogurtandjam yogurtandjam deleted the jerms/OTE-857_useSkipClient branch October 15, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants