@rango-dev/widget-embedded 0.43.1-next.0 → 0.43.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts +2 -2
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +4 -2
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +3 -2
- package/src/components/WalletStatefulConnect/Namespaces.tsx +34 -25
- package/src/components/WalletStatefulConnect/SupportedChainsList.types.ts +2 -2
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +25 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.43.1-next.
|
|
3
|
+
"version": "0.43.1-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.8.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.46.1-next.
|
|
28
|
+
"@rango-dev/provider-all": "^0.46.1-next.2",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.29.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.45.2-next.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.45.2-next.9",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.29.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.39.1-next.3",
|
|
33
|
-
"@rango-dev/ui": "^0.46.2-next.
|
|
34
|
-
"@rango-dev/wallets-core": "^0.43.1-next.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.30.2-next.
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.44.2-next.
|
|
33
|
+
"@rango-dev/ui": "^0.46.2-next.11",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.43.1-next.8",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.30.2-next.10",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.44.2-next.9",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"dayjs": "^1.11.7",
|
|
@@ -44,6 +44,8 @@ export const NamespaceDetachedItem = function NamespaceDetachedItem(
|
|
|
44
44
|
const namespaceState = walletState.namespaces?.get(namespace.value);
|
|
45
45
|
const firstAccountArray = namespaceState.accounts?.[0]?.split(':');
|
|
46
46
|
|
|
47
|
+
const supportedChains = namespace.getSupportedChains(blockchains);
|
|
48
|
+
|
|
47
49
|
useEffect(() => setErrorIsExpanded(false), [error]);
|
|
48
50
|
|
|
49
51
|
useLayoutEffect(() => {
|
|
@@ -145,8 +147,8 @@ export const NamespaceDetachedItem = function NamespaceDetachedItem(
|
|
|
145
147
|
)}
|
|
146
148
|
{!namespaceState.connected &&
|
|
147
149
|
!error &&
|
|
148
|
-
|
|
149
|
-
<SupportedChainsList chains={
|
|
150
|
+
supportedChains.length > 1 && (
|
|
151
|
+
<SupportedChainsList chains={supportedChains} />
|
|
150
152
|
)}
|
|
151
153
|
</NamespaceItemInnerContent>
|
|
152
154
|
{namespaceState.connecting ? (
|
|
@@ -18,7 +18,8 @@ export function NamespaceListItem(props: NamespaceItemPropTypes) {
|
|
|
18
18
|
const { onClick, type, namespace } = props;
|
|
19
19
|
const blockchains = useAppStore().blockchains();
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const supportedChains = namespace.getSupportedChains(blockchains);
|
|
22
|
+
const showSupportedChains = supportedChains.length > 1;
|
|
22
23
|
return (
|
|
23
24
|
<NamespaceItemContainer onClick={onClick} clickable>
|
|
24
25
|
<NamespaceItemContent>
|
|
@@ -31,7 +32,7 @@ export function NamespaceListItem(props: NamespaceItemPropTypes) {
|
|
|
31
32
|
{namespace.label}
|
|
32
33
|
</Typography>
|
|
33
34
|
{showSupportedChains && (
|
|
34
|
-
<SupportedChainsList chains={
|
|
35
|
+
<SupportedChainsList chains={supportedChains} />
|
|
35
36
|
)}
|
|
36
37
|
</NamespaceItemInnerContent>
|
|
37
38
|
{type === 'radio' ? (
|
|
@@ -12,21 +12,30 @@ import {
|
|
|
12
12
|
} from '@rango-dev/ui';
|
|
13
13
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
14
14
|
|
|
15
|
+
import { useAppStore } from '../../store/AppStore';
|
|
16
|
+
|
|
15
17
|
import { NamespaceListItem } from './NamespaceListItem';
|
|
16
18
|
import { NamespaceList, StyledButton } from './Namespaces.styles';
|
|
17
19
|
import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
|
|
18
20
|
|
|
19
21
|
export function Namespaces(props: PropTypes) {
|
|
20
22
|
const { targetWallet } = props.value;
|
|
21
|
-
const
|
|
23
|
+
const namespacesProperty = targetWallet.properties?.find(
|
|
24
|
+
(property) => property.name === 'namespaces'
|
|
25
|
+
);
|
|
26
|
+
const isHub = targetWallet.isHub;
|
|
27
|
+
const singleNamespace = targetWallet.isHub
|
|
28
|
+
? namespacesProperty?.value.selection === 'single'
|
|
29
|
+
: targetWallet.needsNamespace?.selection === 'single';
|
|
30
|
+
const needsNamespace = isHub
|
|
31
|
+
? namespacesProperty?.value
|
|
32
|
+
: targetWallet.needsNamespace;
|
|
22
33
|
const providerImage = targetWallet.image;
|
|
23
34
|
|
|
35
|
+
const blockchains = useAppStore().blockchains();
|
|
24
36
|
const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
|
|
25
37
|
const supportedNamespaces = useMemo(
|
|
26
|
-
() =>
|
|
27
|
-
targetWallet.needsNamespace?.data.filter(
|
|
28
|
-
(namespace) => !namespace.unsupported
|
|
29
|
-
),
|
|
38
|
+
() => needsNamespace?.data.filter((namespace) => !namespace.unsupported),
|
|
30
39
|
[targetWallet?.type]
|
|
31
40
|
);
|
|
32
41
|
|
|
@@ -73,9 +82,11 @@ export function Namespaces(props: PropTypes) {
|
|
|
73
82
|
if (!!props.value.defaultSelectedChains?.length) {
|
|
74
83
|
const namespacesContainingDefaultSelectedChains =
|
|
75
84
|
supportedNamespaces.filter((namespace) =>
|
|
76
|
-
namespace
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
namespace
|
|
86
|
+
.getSupportedChains(blockchains)
|
|
87
|
+
.some((chain) =>
|
|
88
|
+
props.value.defaultSelectedChains?.includes(chain.name)
|
|
89
|
+
)
|
|
79
90
|
);
|
|
80
91
|
setSelectedNamespaces(
|
|
81
92
|
namespacesContainingDefaultSelectedChains.map(
|
|
@@ -132,23 +143,21 @@ export function Namespaces(props: PropTypes) {
|
|
|
132
143
|
<NamespaceList>
|
|
133
144
|
{wrapRadioRoot(
|
|
134
145
|
<>
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{namespace
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
)
|
|
151
|
-
)}
|
|
146
|
+
{needsNamespace?.data.map((namespace, index, array) => (
|
|
147
|
+
<React.Fragment key={namespace.id}>
|
|
148
|
+
{namespace.unsupported ? (
|
|
149
|
+
<NamespaceUnsupportedItem namespace={namespace} />
|
|
150
|
+
) : (
|
|
151
|
+
<NamespaceListItem
|
|
152
|
+
value={selectedNamespaces.includes(namespace.value)}
|
|
153
|
+
namespace={namespace}
|
|
154
|
+
type={singleNamespace ? 'radio' : 'checkbox'}
|
|
155
|
+
onClick={() => onSelect(namespace.value)}
|
|
156
|
+
/>
|
|
157
|
+
)}
|
|
158
|
+
{index !== array.length - 1 && <Divider size={10} />}
|
|
159
|
+
</React.Fragment>
|
|
160
|
+
))}
|
|
152
161
|
</>
|
|
153
162
|
)}
|
|
154
163
|
</NamespaceList>
|
|
@@ -97,25 +97,22 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
97
97
|
|
|
98
98
|
// Legacy and hub have different structure to handle each situation.
|
|
99
99
|
const isHub = !!wallet.isHub;
|
|
100
|
-
const
|
|
101
|
-
(item) => item.name === '
|
|
102
|
-
|
|
100
|
+
const needsNamespace = isHub
|
|
101
|
+
? wallet.properties?.find((item) => item.name === 'namespaces')?.value
|
|
102
|
+
: wallet.needsNamespace;
|
|
103
|
+
|
|
104
|
+
const needsDerivationPath = isHub
|
|
105
|
+
? wallet.properties?.find((item) => item.name === 'derivationPath')
|
|
106
|
+
?.value
|
|
107
|
+
: wallet.needsDerivationPath;
|
|
103
108
|
|
|
104
109
|
// 1. Target wallet does not contain any namespaces
|
|
105
|
-
if (
|
|
106
|
-
(isHub && !detachedInstances?.length) ||
|
|
107
|
-
(!isHub && !wallet.needsNamespace)
|
|
108
|
-
) {
|
|
110
|
+
if (!needsNamespace?.data?.length) {
|
|
109
111
|
return await runConnect(wallet.type, undefined, options);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
// 2. Target wallet contains more than one namespace
|
|
113
|
-
if (
|
|
114
|
-
(isHub && detachedInstances?.length && detachedInstances.length > 1) ||
|
|
115
|
-
(!isHub &&
|
|
116
|
-
wallet.needsNamespace?.data.length &&
|
|
117
|
-
wallet.needsNamespace.data.length > 1)
|
|
118
|
-
) {
|
|
115
|
+
if (needsNamespace?.data.length && needsNamespace.data.length > 1) {
|
|
119
116
|
dispatch({
|
|
120
117
|
type: 'needsNamespace',
|
|
121
118
|
payload: {
|
|
@@ -127,12 +124,9 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
127
124
|
}
|
|
128
125
|
|
|
129
126
|
// 3. Target wallet contains only one namespace
|
|
130
|
-
if (
|
|
131
|
-
(
|
|
132
|
-
|
|
133
|
-
) {
|
|
134
|
-
if (wallet.needsNamespace && wallet.needsDerivationPath) {
|
|
135
|
-
const namespace = wallet.needsNamespace.data[0];
|
|
127
|
+
if (needsNamespace?.data.length === 1) {
|
|
128
|
+
if (needsDerivationPath) {
|
|
129
|
+
const namespace = needsNamespace.data[0];
|
|
136
130
|
|
|
137
131
|
dispatch({
|
|
138
132
|
type: 'needsDerivationPath',
|
|
@@ -146,7 +140,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
146
140
|
}
|
|
147
141
|
return await runConnect(
|
|
148
142
|
wallet.type,
|
|
149
|
-
|
|
143
|
+
needsNamespace?.data?.map((namespace) => ({
|
|
150
144
|
namespace: namespace.value,
|
|
151
145
|
})),
|
|
152
146
|
options
|
|
@@ -182,11 +176,19 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
182
176
|
};
|
|
183
177
|
|
|
184
178
|
const handleNamespace = async (
|
|
185
|
-
wallet:
|
|
179
|
+
wallet: ExtendedModalWalletInfo,
|
|
186
180
|
selectedNamespaces: Namespace[]
|
|
187
181
|
): Promise<Result> => {
|
|
188
|
-
const
|
|
189
|
-
const
|
|
182
|
+
const isHub = !!wallet.isHub;
|
|
183
|
+
const needsNamespace = isHub
|
|
184
|
+
? wallet.properties?.find((item) => item.name === 'namespaces')?.value
|
|
185
|
+
: wallet.needsNamespace;
|
|
186
|
+
|
|
187
|
+
const needsDerivationPath = isHub
|
|
188
|
+
? wallet.properties?.find((item) => item.name === 'derivationPath')?.value
|
|
189
|
+
: wallet.needsDerivationPath;
|
|
190
|
+
|
|
191
|
+
const isSingleNamespace = needsNamespace?.selection === 'single';
|
|
190
192
|
const firstSelectedNamespace = selectedNamespaces[0];
|
|
191
193
|
|
|
192
194
|
if (!firstSelectedNamespace) {
|