@rango-dev/widget-embedded 0.45.1-next.7 → 0.45.1-next.9
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/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.styles.d.ts +161 -0
- package/dist/components/WalletStatefulConnect/Detached.styles.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -0
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
- package/src/components/WalletStatefulConnect/Detached.styles.ts +6 -0
- package/src/components/WalletStatefulConnect/Detached.tsx +19 -3
- package/src/components/WalletStatefulConnect/Detached.types.ts +1 -0
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +1 -1
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +23 -7
- package/src/hooks/useWalletList.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.45.1-next.
|
|
3
|
+
"version": "0.45.1-next.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.9.1-next.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.48.1-next.
|
|
28
|
+
"@rango-dev/provider-all": "^0.48.1-next.4",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.30.1-next.0",
|
|
30
30
|
"@rango-dev/queue-manager-rango-preset": "^0.47.1-next.4",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.30.1-next.0",
|
|
@@ -55,6 +55,7 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
55
55
|
handleNamespace,
|
|
56
56
|
getState,
|
|
57
57
|
resetState,
|
|
58
|
+
handleDisconnect,
|
|
58
59
|
} = useStatefulConnect();
|
|
59
60
|
|
|
60
61
|
const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
|
|
@@ -194,6 +195,9 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
194
195
|
{isOnDetached(getState) && (
|
|
195
196
|
<Detached
|
|
196
197
|
onConfirm={handleDetachedConfirm}
|
|
198
|
+
onDisconnectWallet={() =>
|
|
199
|
+
void handleDisconnect(getState().namespace.targetWallet)
|
|
200
|
+
}
|
|
197
201
|
value={getState().namespace}
|
|
198
202
|
selectedNamespaces={getState().selectedNamespaces}
|
|
199
203
|
/>
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import type { PropTypes } from './Detached.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import { Divider, Image, MessageBox } from '@rango-dev/ui';
|
|
4
|
+
import { Button, Divider, Image, MessageBox } from '@rango-dev/ui';
|
|
5
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import { NamespaceUnsupportedItem } from '../NamespaceItem/NamespaceUnsupportedItem';
|
|
8
9
|
|
|
10
|
+
import { NamespacesHeader } from './Detached.styles';
|
|
9
11
|
import { NamespaceDetachedItem } from './NamespaceDetachedItem';
|
|
10
12
|
import { NamespaceList, StyledButton } from './Namespaces.styles';
|
|
11
13
|
|
|
12
14
|
export function Detached(props: PropTypes) {
|
|
13
|
-
const { selectedNamespaces, value } = props;
|
|
15
|
+
const { selectedNamespaces, value, onDisconnectWallet } = props;
|
|
14
16
|
const { targetWallet } = value;
|
|
15
17
|
|
|
18
|
+
const { state } = useWallets();
|
|
19
|
+
const walletState = state(targetWallet.type);
|
|
20
|
+
|
|
16
21
|
return (
|
|
17
22
|
<>
|
|
18
23
|
<MessageBox
|
|
@@ -25,7 +30,18 @@ export function Detached(props: PropTypes) {
|
|
|
25
30
|
)}
|
|
26
31
|
icon={<Image src={targetWallet.image} size={45} />}
|
|
27
32
|
/>
|
|
28
|
-
<Divider size={
|
|
33
|
+
<Divider size={30} />
|
|
34
|
+
<NamespacesHeader>
|
|
35
|
+
<Button
|
|
36
|
+
id="widget-detached-disconnect-wallet-btn"
|
|
37
|
+
variant="ghost"
|
|
38
|
+
type="error"
|
|
39
|
+
size="xsmall"
|
|
40
|
+
disabled={walletState.connecting || !walletState.connected}
|
|
41
|
+
onClick={onDisconnectWallet}>
|
|
42
|
+
{i18n.t('Disconnect wallet')}
|
|
43
|
+
</Button>
|
|
44
|
+
</NamespacesHeader>
|
|
29
45
|
<NamespaceList id="widget-detached-namespace-list" as={'ul'}>
|
|
30
46
|
{targetWallet.needsNamespace?.data.map((namespace, index, array) => (
|
|
31
47
|
<React.Fragment key={namespace.id}>
|
|
@@ -93,7 +93,7 @@ export const NamespaceDetachedItem = function NamespaceDetachedItem(
|
|
|
93
93
|
id="widget-name-space-connect-btn"
|
|
94
94
|
variant="ghost"
|
|
95
95
|
type={namespaceState.connected ? 'error' : 'primary'}
|
|
96
|
-
size="
|
|
96
|
+
size="xsmall"
|
|
97
97
|
onClick={async () => handleButtonClick(namespaceState)}>
|
|
98
98
|
{getButtonText()}
|
|
99
99
|
</Button>
|
|
@@ -7,6 +7,7 @@ import { WalletState } from '@rango-dev/ui';
|
|
|
7
7
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
8
8
|
import { useReducer } from 'react';
|
|
9
9
|
|
|
10
|
+
import { isOnDetached } from '../../components/StatefulConnectModal';
|
|
10
11
|
import { type ExtendedModalWalletInfo } from '../../utils/wallets';
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -26,7 +27,7 @@ interface UseStatefulConnect {
|
|
|
26
27
|
selectedNamespaces: Namespace[]
|
|
27
28
|
) => Promise<Result>;
|
|
28
29
|
handleDerivationPath: (path: string) => Promise<Result>;
|
|
29
|
-
handleDisconnect: (
|
|
30
|
+
handleDisconnect: (wallet: WalletInfoWithExtra) => Promise<Result>;
|
|
30
31
|
getState(): State;
|
|
31
32
|
resetState(section?: 'derivation'): void;
|
|
32
33
|
}
|
|
@@ -163,7 +164,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
if (options?.disconnectIfConnected) {
|
|
166
|
-
await handleDisconnect(wallet
|
|
167
|
+
await handleDisconnect(wallet);
|
|
167
168
|
return { status: ResultStatus.Disconnected };
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -258,10 +259,25 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
258
259
|
return await runConnect(type, namespaces);
|
|
259
260
|
};
|
|
260
261
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
const getState = () => connectState;
|
|
263
|
+
|
|
264
|
+
const handleDisconnect = async (
|
|
265
|
+
wallet: ExtendedModalWalletInfo
|
|
266
|
+
): Promise<Result> => {
|
|
267
|
+
const walletState = state(wallet.type);
|
|
268
|
+
if (walletState.connected || walletState.connecting) {
|
|
269
|
+
await disconnect(wallet.type);
|
|
270
|
+
|
|
271
|
+
if (isOnDetached(getState)) {
|
|
272
|
+
dispatch({
|
|
273
|
+
type: 'needsNamespace',
|
|
274
|
+
payload: {
|
|
275
|
+
targetWallet: wallet,
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
return { status: ResultStatus.Namespace };
|
|
279
|
+
}
|
|
280
|
+
|
|
265
281
|
return { status: ResultStatus.Disconnected };
|
|
266
282
|
}
|
|
267
283
|
|
|
@@ -273,7 +289,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
273
289
|
handleDisconnect,
|
|
274
290
|
handleNamespace,
|
|
275
291
|
handleDerivationPath,
|
|
276
|
-
getState
|
|
292
|
+
getState,
|
|
277
293
|
resetState: (section?: 'derivation') => {
|
|
278
294
|
if (section === 'derivation') {
|
|
279
295
|
dispatch({
|
|
@@ -78,7 +78,7 @@ export function useWalletList(params?: Params): API {
|
|
|
78
78
|
wallets?.filter((wallet) => wallet.state === WalletState.CONNECTING) ||
|
|
79
79
|
[];
|
|
80
80
|
for (const wallet of connectingWallets) {
|
|
81
|
-
void handleDisconnect(wallet
|
|
81
|
+
void handleDisconnect(wallet);
|
|
82
82
|
}
|
|
83
83
|
}, [hashWalletsState(wallets)]);
|
|
84
84
|
|