@@ -12,8 +12,7 @@ import {
12
12
Radio ,
13
13
RadioRoot ,
14
14
} from '@rango-dev/ui' ;
15
- import { namespaces } from '@rango-dev/wallets-shared' ;
16
- import React , { useMemo , useState } from 'react' ;
15
+ import React , { useState } from 'react' ;
17
16
18
17
import { useAppStore } from '../../store/AppStore' ;
19
18
import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles' ;
@@ -23,25 +22,14 @@ import { getBlockchainLogo } from './Namespaces.helpers';
23
22
import { NamespaceList } from './Namespaces.styles' ;
24
23
25
24
export function Namespaces ( props : PropTypes ) {
26
- const { singleNamespace, availableNamespaces, providerImage } = props . value ;
25
+ const { targetWallet } = props . value ;
26
+ const singleNamespace = targetWallet . needsNamespace ?. selection === 'single' ;
27
+ const providerImage = targetWallet . image ;
27
28
28
29
const [ selectedNamespaces , setSelectedNamespaces ] = useState < Namespace [ ] > ( [ ] ) ;
29
30
30
31
const blockchains = useAppStore ( ) . blockchains ( ) ;
31
32
32
- const namespacesInfo = useMemo (
33
- ( ) =>
34
- availableNamespaces ?. map ( ( namespace ) => ( {
35
- name : namespace ,
36
- logo : getBlockchainLogo (
37
- blockchains ,
38
- namespaces [ namespace ] . mainBlockchain
39
- ) ,
40
- title : namespaces [ namespace ] . title ,
41
- } ) ) ,
42
- [ availableNamespaces ]
43
- ) ;
44
-
45
33
const onSelect = ( namespace : Namespace ) => {
46
34
if ( singleNamespace ) {
47
35
setSelectedNamespaces ( [ namespace ] ) ;
@@ -83,28 +71,33 @@ export function Namespaces(props: PropTypes) {
83
71
< NamespaceList >
84
72
{ wrapRadioRoot (
85
73
< >
86
- { namespacesInfo ?. map ( ( namespaceInfoItem ) => (
87
- < ListItemButton
88
- key = { namespaceInfoItem . name }
89
- id = { namespaceInfoItem . name }
90
- title = { namespaceInfoItem . title }
91
- hasDivider
92
- style = { { height : 60 } }
93
- onClick = { ( ) => onSelect ( namespaceInfoItem . name ) }
94
- start = { < Image src = { namespaceInfoItem . logo } size = { 22 } /> }
95
- end = {
96
- singleNamespace ? (
97
- < Radio value = { namespaceInfoItem . name } />
98
- ) : (
99
- < Checkbox
100
- checked = { selectedNamespaces . includes (
101
- namespaceInfoItem . name
102
- ) }
74
+ { targetWallet . needsNamespace ?. data . map ( ( ns ) => {
75
+ return (
76
+ < ListItemButton
77
+ key = { ns . id }
78
+ id = { ns . id }
79
+ title = { ns . label }
80
+ hasDivider
81
+ style = { { height : 60 } }
82
+ onClick = { ( ) => onSelect ( ns . value ) }
83
+ start = {
84
+ < Image
85
+ src = { getBlockchainLogo ( blockchains , ns . id ) }
86
+ size = { 22 }
103
87
/>
104
- )
105
- }
106
- />
107
- ) ) }
88
+ }
89
+ end = {
90
+ singleNamespace ? (
91
+ < Radio value = { ns . value } />
92
+ ) : (
93
+ < Checkbox
94
+ checked = { selectedNamespaces . includes ( ns . value ) }
95
+ />
96
+ )
97
+ }
98
+ />
99
+ ) ;
100
+ } ) }
108
101
</ >
109
102
) }
110
103
</ NamespaceList >
0 commit comments