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

Swaps Rearchitecture #5705

Merged
merged 14 commits into from
May 8, 2024
Merged

Swaps Rearchitecture #5705

merged 14 commits into from
May 8, 2024

Conversation

walmat
Copy link
Contributor

@walmat walmat commented May 7, 2024

Fixes APP-####

What changed (plus any additional context for devs)

This PR introduces some of the changes laid out in the swaps re-architecture document here. Mainly:

  1. introduction of the zustand stores and some general impl. for user assets and swaps storage
  2. changes to swaps context to pre-process asset colors when an asset change occurs

Screen recordings / screenshots

What to test

@walmat walmat added the swaps v2 label May 7, 2024
@walmat walmat requested a review from christianbaroni May 7, 2024 15:18
@walmat walmat self-assigned this May 7, 2024
@walmat walmat changed the title add swapsStore and some changes to the swaps context [WIP]: Swaps Rearchitecture May 7, 2024
@walmat walmat marked this pull request as ready for review May 7, 2024 20:53
@walmat walmat requested a review from benisgold May 7, 2024 20:54
@walmat walmat changed the title [WIP]: Swaps Rearchitecture Swaps Rearchitecture May 8, 2024
filter: UserAssetFilter;
searchQuery: string;
favoriteAssetIds: Hex[]; // this is chain agnostic, so we don't want to store a UniqueId here
setFavorites: (favoriteAssetIds: Hex[]) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there scenarios when we need to set multiple favorites at once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that i'm aware of, but maybe?

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 function is more for initializing the favorites store, but probably unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya i think we'll only need to do that once when we migrate data over from the current react query favorites cache. prob can just have setFavorite and call that iteratively for that single migration

src/state/assets/userAssets.ts Outdated Show resolved Hide resolved
src/state/assets/userAssets.ts Outdated Show resolved Hide resolved
src/state/assets/userAssets.ts Outdated Show resolved Hide resolved
src/state/assets/userAssets.ts Show resolved Hide resolved
@walmat walmat requested a review from benisgold May 8, 2024 16:13
// Removing the value when the input is focused allows the input to be reset to the correct value on blur
const query = isFocused ? undefined : defaultValue;

return { defaultValue, text: query };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think default value needs to be an animated prop but we can change this later

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 agree, but when I removed it typescript was yelling at me for whatever reason..

return SwapInputController.searchQuery.value;
}, [SwapInputController.searchQuery.value]);
const defaultValue = useMemo(() => {
return userAssetsStore.getState().searchQuery;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am most likely just misunderstanding but why do we need to set the default value to the initial searchQuery? Wouldn't the initial searchQuery just be ""?

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 think that assumption is always true, good point.

return userAssetsStore.getState().searchQuery;
}, []);

const onSearchQueryChange = useCallback((event: NativeSyntheticEvent<TextInputChangeEventData>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also unrelated to the main focus of this pr, but i feel like this would be cleaner if it just accepts a string. that way you wouldn't be creating artificial NativeSyntheticEvents below

@walmat walmat merged commit 35150f5 into develop May 8, 2024
6 checks passed
@walmat walmat deleted the @matthew/swaps-architecture branch May 8, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants