Skip to content

Commit

Permalink
Switch to using Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Jan 6, 2025
1 parent 1c78ce5 commit a89a968
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { setSearchText } from '@/store/defaultPaymentTokenScreen';
import { useAppDispatch, useAppSelector } from '@/store/hooks';
import { setDefaultPaymentToken } from '@/store/secureStore';
import { Trans, useLingui } from '@lingui/react/macro';
import { Sx, Text, View } from 'dripsy';
import { ScrollView, Sx, Text } from 'dripsy';
import { Check, Search } from 'lucide-react-native';
import useFilteredAssets from './useFilteredAssets';
import TextInputIconStartAdornment from '@/components/TextInputIconStartAdornment';
Expand All @@ -20,7 +20,7 @@ export default function DefaultPaymentTokenScreen() {
const { t } = useLingui();

return (
<View sx={sx.root}>
<ScrollView contentContainerSx={sx.root}>
<Text variant='h4'>
<Trans>Default payment token</Trans>
</Text>
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function DefaultPaymentTokenScreen() {
/>
))}
</List>
</View>
</ScrollView>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { useAppSelector } from '@/store/hooks';
import ASSETS from './assets';
import { PENUMBRA_CHAIN_ID } from '@/utils/constants';
import { ChainRegistryClient } from '@penumbra-labs/registry';
import { useMemo } from 'react';

/**
* @todo: Use remote client? (To avoid having to update the app just to get the
* latest metadatas.)
*/
const ALL_METADATAS = new ChainRegistryClient().bundled.get(PENUMBRA_CHAIN_ID).getAllAssets();

/**
* Returns asset types filtered by the search text from state.
*
Expand All @@ -14,11 +21,11 @@ export default function useFilteredAssets() {

const filteredAssets = useMemo(
() =>
ASSETS.filter(asset => {
ALL_METADATAS.filter(metadata => {
const searchTextLowerCase = searchText.toLocaleLowerCase();

if (asset.name.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
if (asset.symbol.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
if (metadata.name.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
if (metadata.symbol.toLocaleLowerCase().includes(searchTextLowerCase)) return true;

return false;
}),
Expand Down
4 changes: 0 additions & 4 deletions react-native-expo/types/Asset.ts

This file was deleted.

1 change: 1 addition & 0 deletions react-native-expo/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PENUMBRA_CHAIN_ID = 'penumbra-1';

0 comments on commit a89a968

Please sign in to comment.