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: Chain Search Menu #323

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Xaroz
Copy link
Contributor

@Xaroz Xaroz commented Nov 14, 2024

  • Replace current chain menu with ChainSearchMenu from widgets
  • Create a chainMetadata (not taken from the registry) with the tokens that come from the warpCore
  • Create a customListItemField object that contains all the routes from a single chain to any other warp core token chain
  • Chain Search Menu will show the routes from the opposing field. EX: If you open "To" chain, it will show all the routes from the "From" field chain to all the chains

image

Copy link

vercel bot commented Nov 14, 2024

@Xaroz is attempting to deploy a commit to the Abacus Works Team on Vercel.

A member of the Team first needs to authorize it.

@Xaroz Xaroz changed the title Feat: Chain Search Menu feat: Chain Search Menu Nov 14, 2024
Copy link
Collaborator

@jmrossy jmrossy left a 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

Comment on lines 37 to 49
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;
}
Copy link
Collaborator

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

Copy link
Contributor Author

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

Comment on lines 119 to 125
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]);
Copy link
Collaborator

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?

Copy link
Contributor Author

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

* Return a customListItemField object that contains the amount of
* routes from a single chain to every other chain
*/
export function getCustomListItemField(
Copy link
Collaborator

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.

Copy link
Contributor Author

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

src/features/chains/utils.ts Outdated Show resolved Hide resolved
Copy link

vercel bot commented Nov 15, 2024

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

Name Status Preview Comments Updated (UTC)
hyperlane-warp-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 5:56pm

@Xaroz Xaroz requested a review from jmrossy November 15, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants