Skip to content

Commit bef7ca4

Browse files
committed
Switch to using Metadata
1 parent 145d162 commit bef7ca4

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/assets.ts

-11
This file was deleted.

react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setSearchText } from '@/store/defaultPaymentTokenScreen';
77
import { useAppDispatch, useAppSelector } from '@/store/hooks';
88
import { setDefaultPaymentToken } from '@/store/secureStore';
99
import { Trans, useLingui } from '@lingui/react/macro';
10-
import { Sx, Text, View } from 'dripsy';
10+
import { ScrollView, Sx, Text } from 'dripsy';
1111
import { Check, Search } from 'lucide-react-native';
1212
import useFilteredAssets from './useFilteredAssets';
1313
import TextInputIconStartAdornment from '@/components/TextInputIconStartAdornment';
@@ -20,7 +20,7 @@ export default function DefaultPaymentTokenScreen() {
2020
const { t } = useLingui();
2121

2222
return (
23-
<View sx={sx.root}>
23+
<ScrollView contentContainerSx={sx.root}>
2424
<Text variant='h4'>
2525
<Trans>Default payment token</Trans>
2626
</Text>
@@ -49,7 +49,7 @@ export default function DefaultPaymentTokenScreen() {
4949
/>
5050
))}
5151
</List>
52-
</View>
52+
</ScrollView>
5353
);
5454
}
5555

react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { useAppSelector } from '@/store/hooks';
2-
import ASSETS from './assets';
2+
import { PENUMBRA_CHAIN_ID } from '@/utils/constants';
3+
import { ChainRegistryClient } from '@penumbra-labs/registry';
34
import { useMemo } from 'react';
45

6+
/**
7+
* @todo: Use remote client? (To avoid having to update the app just to get the
8+
* latest metadatas.)
9+
*/
10+
const ALL_METADATAS = new ChainRegistryClient().bundled.get(PENUMBRA_CHAIN_ID).getAllAssets();
11+
512
/**
613
* Returns asset types filtered by the search text from state.
714
*
@@ -14,11 +21,11 @@ export default function useFilteredAssets() {
1421

1522
const filteredAssets = useMemo(
1623
() =>
17-
ASSETS.filter(asset => {
24+
ALL_METADATAS.filter(metadata => {
1825
const searchTextLowerCase = searchText.toLocaleLowerCase();
1926

20-
if (asset.name.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
21-
if (asset.symbol.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
27+
if (metadata.name.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
28+
if (metadata.symbol.toLocaleLowerCase().includes(searchTextLowerCase)) return true;
2229

2330
return false;
2431
}),

react-native-expo/utils/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const PENUMBRA_CHAIN_ID = 'penumbra-1';

0 commit comments

Comments
 (0)