-
Notifications
You must be signed in to change notification settings - Fork 122
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: Chain Search Menu #323
base: main
Are you sure you want to change the base?
Conversation
@Xaroz is attempting to deploy a commit to the Abacus Works Team on Vercel. A member of the Team first needs to authorize it. |
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.
Excited to get this in! Def a nice UX improvement
src/features/chains/hooks.ts
Outdated
export function useChainMetadataMap(chains: string[]) { | ||
const multiProvider = useMultiProvider(); | ||
|
||
const chainMetadata = useMemo(() => { | ||
return chains.reduce<ChainMap<ChainMetadata>>((obj, chain) => { | ||
const metadata = multiProvider.tryGetChainMetadata(chain); | ||
if (metadata) obj[chain] = metadata; | ||
return obj; | ||
}, {}); | ||
}, [chains, multiProvider]); | ||
|
||
return chainMetadata; | ||
} |
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 don't think you need this hook. IIUC, multiprovider.metadata
is already what you're looking for
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.
This hook is needed because we only need the token chains from the warp core, and that doesn't return the metadata
we need, so we have to create it from scratch.
I renamed this function to useTokenChainsMetadata
and also moved the warpCore
and getting the chains logic inside
const originRoutes = useMemo(() => { | ||
return getCustomListItemField(warpCore, values.origin, chainMetadata); | ||
}, [values.origin, warpCore, chainMetadata]); | ||
|
||
const destinationRoutes = useMemo(() => { | ||
return getCustomListItemField(warpCore, values.destination, chainMetadata); | ||
}, [values.destination, warpCore, chainMetadata]); |
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.
Can we move this into ChainSelectField
?
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.
Reason I didn't do that it is because I think it looks better to separate the logic here instead of having it inside the ChainSelectField
by doing something like name === "origin" ? values.destination : values.origin
src/features/chains/utils.ts
Outdated
* Return a customListItemField object that contains the amount of | ||
* routes from a single chain to every other chain | ||
*/ | ||
export function getCustomListItemField( |
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.
Please move this to ChainSelectField as that's the only place that it will be used.
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.
kept in here but renamed to getAllTokenRoutesFromChain
, please lmk what you think
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
ChainSearchMenu
from widgetschainMetadata
(not taken from the registry) with the tokens that come from the warpCorecustomListItemField
object that contains all the routes from a single chain to any other warp core token chain"To"
chain, it will show all the routes from the"From"
field chain to all the chains