@aptos-labs/wallet-adapter-ant-design 2.4.10 → 2.5.0
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/CHANGELOG.md +18 -0
- package/README.md +4 -1
- package/dist/index.css +51 -28
- package/dist/index.d.ts +12 -1
- package/dist/index.js +123 -89
- package/dist/index.mjs +129 -92
- package/package.json +3 -3
- package/src/WalletSelector.tsx +148 -88
- package/src/styles.css +57 -30
- package/src/utils.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-ant-design
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9f0d3de: Updated wallet selector modal to new design for Aptos Connect.
|
|
8
|
+
- 9f0d3de: Added `sortDefaultWallets` and `sortMoreWallets` props for controlling the order of wallets in the modal.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- @aptos-labs/wallet-adapter-react@3.3.1
|
|
13
|
+
|
|
14
|
+
## 2.4.11
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [07ee265]
|
|
19
|
+
- @aptos-labs/wallet-adapter-react@3.3.0
|
|
20
|
+
|
|
3
21
|
## 2.4.10
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ That would add a `Connect Wallet` button when clicked opens up a `wallet selecto
|
|
|
38
38
|
You can override these classes
|
|
39
39
|
|
|
40
40
|
```
|
|
41
|
+
.wallet-selector-modal
|
|
42
|
+
.wallet-selector-icon
|
|
41
43
|
.wallet-selector-text
|
|
42
44
|
.wallet-menu-wrapper
|
|
43
45
|
.wallet-name-wrapper
|
|
@@ -45,13 +47,14 @@ You can override these classes
|
|
|
45
47
|
.wallet-connect-install
|
|
46
48
|
.wallet-button
|
|
47
49
|
.wallet-modal-title
|
|
50
|
+
aptos-connect-button
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
For example, to override the `connect wallet` button background color, you can use the `.wallet-button` class in your local `.css` file
|
|
51
54
|
|
|
52
55
|
```
|
|
53
56
|
.wallet-button{
|
|
54
|
-
background-color:red;
|
|
57
|
+
background-color: red;
|
|
55
58
|
}
|
|
56
59
|
```
|
|
57
60
|
|
package/dist/index.css
CHANGED
|
@@ -1,53 +1,76 @@
|
|
|
1
1
|
/* src/styles.css */
|
|
2
|
-
.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
margin-bottom: 10px !important;
|
|
10
|
-
}
|
|
11
|
-
.ant-menu-item-selected {
|
|
12
|
-
background-color: rgba(0, 0, 0, 0.06) !important;
|
|
13
|
-
color: black !important;
|
|
2
|
+
.wallet-button {
|
|
3
|
+
padding: 10px 20px;
|
|
4
|
+
height: auto;
|
|
5
|
+
border-radius: 6px;
|
|
6
|
+
font-size: 16px;
|
|
7
|
+
background-color: #3f67ff;
|
|
8
|
+
color: white;
|
|
14
9
|
}
|
|
15
|
-
.wallet-
|
|
16
|
-
|
|
10
|
+
.wallet-modal-title {
|
|
11
|
+
text-align: center;
|
|
12
|
+
font-size: 1.5rem;
|
|
13
|
+
line-height: 2rem;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
margin-bottom: 32px;
|
|
17
17
|
}
|
|
18
|
-
.
|
|
19
|
-
color:
|
|
18
|
+
.aptos-connect-button {
|
|
19
|
+
color: #3f67ff;
|
|
20
|
+
border-color: #3f67ff;
|
|
20
21
|
}
|
|
21
22
|
.wallet-menu-wrapper {
|
|
22
23
|
display: flex;
|
|
23
24
|
justify-content: space-between;
|
|
24
25
|
font-size: 20px;
|
|
26
|
+
border: solid 1px;
|
|
27
|
+
border-color: rgba(0, 0, 0, 0.1);
|
|
28
|
+
padding-inline: 16px;
|
|
29
|
+
padding-block: 12px;
|
|
30
|
+
border-radius: 8px;
|
|
25
31
|
}
|
|
26
32
|
.wallet-name-wrapper {
|
|
27
33
|
display: flex;
|
|
28
34
|
align-items: center;
|
|
29
35
|
}
|
|
36
|
+
.wallet-selector-icon {
|
|
37
|
+
height: 24px;
|
|
38
|
+
width: 24px;
|
|
39
|
+
margin-right: 12px;
|
|
40
|
+
}
|
|
41
|
+
.wallet-selector-text {
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
}
|
|
30
44
|
.wallet-connect-button {
|
|
31
45
|
align-self: center;
|
|
32
46
|
background-color: #3f67ff;
|
|
47
|
+
color: white;
|
|
33
48
|
height: auto;
|
|
34
49
|
}
|
|
35
50
|
.wallet-connect-install {
|
|
36
51
|
align-self: center;
|
|
37
52
|
color: #3f67ff;
|
|
38
|
-
padding-right:
|
|
53
|
+
padding-right: 16px;
|
|
39
54
|
font-size: 16px;
|
|
40
|
-
|
|
41
|
-
padding-bottom: 3px;
|
|
55
|
+
line-height: 32px;
|
|
42
56
|
}
|
|
43
|
-
.wallet-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
background-color: #3f67ff;
|
|
48
|
-
color: white;
|
|
57
|
+
:where(.wallet-selector-modal .ant-modal-body) {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 16px;
|
|
49
61
|
}
|
|
50
|
-
.wallet-modal-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
:where(.wallet-selector-modal .ant-divider-inner-text) {
|
|
63
|
+
color: rgba(0, 0, 0, 0.5);
|
|
64
|
+
}
|
|
65
|
+
:where(.wallet-selector-modal .ant-collapse-header) {
|
|
66
|
+
justify-content: center !important;
|
|
67
|
+
color: rgba(0, 0, 0, 0.5) !important;
|
|
68
|
+
}
|
|
69
|
+
:where(.wallet-selector-modal .ant-collapse-header-text) {
|
|
70
|
+
flex: unset !important;
|
|
71
|
+
margin-inline-end: 0 !important;
|
|
72
|
+
}
|
|
73
|
+
:where(.wallet-selector-modal .ant-collapse-content-box) {
|
|
74
|
+
padding: 0px !important;
|
|
75
|
+
padding-top: 8px !important;
|
|
53
76
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { AnyAptosWallet } from '@aptos-labs/wallet-adapter-react';
|
|
2
3
|
import { Dispatch, SetStateAction } from 'react';
|
|
3
4
|
|
|
4
5
|
type WalletSelectorProps = {
|
|
5
6
|
isModalOpen?: boolean;
|
|
6
7
|
setModalOpen?: Dispatch<SetStateAction<boolean>>;
|
|
8
|
+
/**
|
|
9
|
+
* An optional function for sorting wallets that are currently installed or
|
|
10
|
+
* loadable in the wallet selector modal.
|
|
11
|
+
*/
|
|
12
|
+
sortDefaultWallets?: (a: AnyAptosWallet, b: AnyAptosWallet) => number;
|
|
13
|
+
/**
|
|
14
|
+
* An optional function for sorting wallets that are NOT currently installed or
|
|
15
|
+
* loadable in the wallet selector modal.
|
|
16
|
+
*/
|
|
17
|
+
sortMoreWallets?: (a: AnyAptosWallet, b: AnyAptosWallet) => number;
|
|
7
18
|
};
|
|
8
|
-
declare function WalletSelector({ isModalOpen, setModalOpen, }: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function WalletSelector({ isModalOpen, setModalOpen, sortDefaultWallets, sortMoreWallets, }: WalletSelectorProps): react_jsx_runtime.JSX.Element;
|
|
9
20
|
|
|
10
21
|
export { WalletSelector };
|
package/dist/index.js
CHANGED
|
@@ -25,23 +25,16 @@ __export(src_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
27
|
// src/WalletSelector.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_antd = require("antd");
|
|
30
28
|
var import_wallet_adapter_react = require("@aptos-labs/wallet-adapter-react");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var truncateAddress = (address) => {
|
|
34
|
-
if (!address)
|
|
35
|
-
return;
|
|
36
|
-
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/WalletSelector.tsx
|
|
29
|
+
var import_antd = require("antd");
|
|
30
|
+
var import_react = require("react");
|
|
40
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
32
|
var { Text } = import_antd.Typography;
|
|
42
33
|
function WalletSelector({
|
|
43
34
|
isModalOpen,
|
|
44
|
-
setModalOpen
|
|
35
|
+
setModalOpen,
|
|
36
|
+
sortDefaultWallets,
|
|
37
|
+
sortMoreWallets
|
|
45
38
|
}) {
|
|
46
39
|
const [walletSelectorModalOpen, setWalletSelectorModalOpen] = (0, import_react.useState)(false);
|
|
47
40
|
(0, import_react.useEffect)(() => {
|
|
@@ -49,7 +42,20 @@ function WalletSelector({
|
|
|
49
42
|
setWalletSelectorModalOpen(isModalOpen);
|
|
50
43
|
}
|
|
51
44
|
}, [isModalOpen]);
|
|
52
|
-
const {
|
|
45
|
+
const { account, connected, disconnect, wallets = [] } = (0, import_wallet_adapter_react.useWallet)();
|
|
46
|
+
const {
|
|
47
|
+
aptosConnectWallets,
|
|
48
|
+
otherWallets
|
|
49
|
+
} = (0, import_wallet_adapter_react.getAptosConnectWallets)(wallets);
|
|
50
|
+
const {
|
|
51
|
+
defaultWallets,
|
|
52
|
+
moreWallets
|
|
53
|
+
} = (0, import_wallet_adapter_react.partitionWallets)(otherWallets);
|
|
54
|
+
if (sortDefaultWallets)
|
|
55
|
+
defaultWallets.sort(sortDefaultWallets);
|
|
56
|
+
if (sortMoreWallets)
|
|
57
|
+
moreWallets.sort(sortMoreWallets);
|
|
58
|
+
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
53
59
|
const onWalletButtonClick = () => {
|
|
54
60
|
if (connected) {
|
|
55
61
|
disconnect();
|
|
@@ -57,118 +63,146 @@ function WalletSelector({
|
|
|
57
63
|
setWalletSelectorModalOpen(true);
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
|
-
const
|
|
61
|
-
connect(wallet);
|
|
66
|
+
const closeModal = () => {
|
|
62
67
|
setWalletSelectorModalOpen(false);
|
|
63
68
|
if (setModalOpen) {
|
|
64
69
|
setModalOpen(false);
|
|
65
70
|
}
|
|
66
71
|
};
|
|
67
|
-
const
|
|
68
|
-
setWalletSelectorModalOpen(false);
|
|
69
|
-
if (setModalOpen) {
|
|
70
|
-
setModalOpen(false);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const buttonText = (account == null ? void 0 : account.ansName) ? account == null ? void 0 : account.ansName : truncateAddress(account == null ? void 0 : account.address);
|
|
72
|
+
const buttonText = (account == null ? void 0 : account.ansName) || (0, import_wallet_adapter_react.truncateAddress)(account == null ? void 0 : account.address) || "Unknown";
|
|
74
73
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
75
74
|
children: [
|
|
76
75
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, {
|
|
77
76
|
className: "wallet-button",
|
|
78
|
-
onClick:
|
|
77
|
+
onClick: onWalletButtonClick,
|
|
79
78
|
children: connected ? buttonText : "Connect Wallet"
|
|
80
79
|
}),
|
|
81
80
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Modal, {
|
|
82
81
|
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
83
82
|
className: "wallet-modal-title",
|
|
84
|
-
children:
|
|
83
|
+
children: hasAptosConnectWallets ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
86
|
+
children: "Log in or sign up"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
89
|
+
children: "with Social + Aptos Connect"
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
}) : "Connect Wallet"
|
|
85
93
|
}),
|
|
86
94
|
centered: true,
|
|
87
95
|
open: walletSelectorModalOpen,
|
|
88
|
-
onCancel,
|
|
96
|
+
onCancel: closeModal,
|
|
89
97
|
footer: [],
|
|
90
98
|
closable: false,
|
|
91
99
|
zIndex: 9999,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return walletView(wallet, onWalletSelected);
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
]
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
var walletView = (wallet, onWalletSelected) => {
|
|
102
|
-
const isWalletReady = wallet.readyState === import_wallet_adapter_react.WalletReadyState.Installed || wallet.readyState === import_wallet_adapter_react.WalletReadyState.Loadable;
|
|
103
|
-
if (!isWalletReady && (0, import_wallet_adapter_react.isRedirectable)()) {
|
|
104
|
-
const mobileSupport = wallet.deeplinkProvider;
|
|
105
|
-
if (mobileSupport) {
|
|
106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Menu.Item, {
|
|
107
|
-
onClick: () => onWalletSelected(wallet.name),
|
|
108
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
109
|
-
className: "wallet-menu-wrapper",
|
|
100
|
+
className: "wallet-selector-modal",
|
|
101
|
+
children: !connected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
110
102
|
children: [
|
|
111
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
112
|
-
className: "wallet-name-wrapper",
|
|
103
|
+
hasAptosConnectWallets && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
113
104
|
children: [
|
|
114
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Flex, {
|
|
106
|
+
vertical: true,
|
|
107
|
+
gap: 12,
|
|
108
|
+
children: aptosConnectWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AptosConnectWalletRow, {
|
|
109
|
+
wallet,
|
|
110
|
+
onConnect: closeModal
|
|
111
|
+
}, wallet.name))
|
|
118
112
|
}),
|
|
119
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
|
-
|
|
121
|
-
children: wallet.name
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Divider, {
|
|
114
|
+
children: "Or"
|
|
122
115
|
})
|
|
123
116
|
]
|
|
124
117
|
}),
|
|
125
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Flex, {
|
|
119
|
+
vertical: true,
|
|
120
|
+
gap: 12,
|
|
121
|
+
children: defaultWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WalletRow, {
|
|
122
|
+
wallet,
|
|
123
|
+
onConnect: closeModal
|
|
124
|
+
}, wallet.name))
|
|
125
|
+
}),
|
|
126
|
+
!!moreWallets.length && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Collapse, {
|
|
127
|
+
ghost: true,
|
|
128
|
+
expandIconPosition: "end",
|
|
129
|
+
items: [
|
|
130
|
+
{
|
|
131
|
+
key: "more-wallets",
|
|
132
|
+
label: "More Wallets",
|
|
133
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Flex, {
|
|
134
|
+
vertical: true,
|
|
135
|
+
gap: 12,
|
|
136
|
+
children: moreWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WalletRow, {
|
|
137
|
+
wallet,
|
|
138
|
+
onConnect: closeModal
|
|
139
|
+
}, wallet.name))
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
]
|
|
131
143
|
})
|
|
132
144
|
]
|
|
133
145
|
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function WalletRow({ wallet, onConnect }) {
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem, {
|
|
152
|
+
wallet,
|
|
153
|
+
onConnect,
|
|
154
|
+
asChild: true,
|
|
155
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
156
|
+
className: "wallet-menu-wrapper",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
159
|
+
className: "wallet-name-wrapper",
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.Icon, {
|
|
162
|
+
className: "wallet-selector-icon"
|
|
163
|
+
}),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.Name, {
|
|
165
|
+
asChild: true,
|
|
166
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
152
167
|
className: "wallet-selector-text",
|
|
153
168
|
children: wallet.name
|
|
154
169
|
})
|
|
155
|
-
]
|
|
156
|
-
}),
|
|
157
|
-
wallet.readyState === import_wallet_adapter_react.WalletReadyState.Installed || wallet.readyState === import_wallet_adapter_react.WalletReadyState.Loadable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, {
|
|
158
|
-
className: "wallet-connect-button",
|
|
159
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
160
|
-
className: "wallet-connect-button-text",
|
|
161
|
-
children: "Connect"
|
|
162
170
|
})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
(0, import_wallet_adapter_react.isInstallRequired)(wallet) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.InstallLink, {
|
|
174
|
+
className: "wallet-connect-install"
|
|
175
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.ConnectButton, {
|
|
176
|
+
asChild: true,
|
|
177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, {
|
|
178
|
+
className: "wallet-connect-button",
|
|
179
|
+
children: "Connect"
|
|
166
180
|
})
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function AptosConnectWalletRow({ wallet, onConnect }) {
|
|
187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem, {
|
|
188
|
+
wallet,
|
|
189
|
+
onConnect,
|
|
190
|
+
asChild: true,
|
|
191
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.ConnectButton, {
|
|
192
|
+
asChild: true,
|
|
193
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd.Button, {
|
|
194
|
+
size: "large",
|
|
195
|
+
className: "aptos-connect-button",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.Icon, {
|
|
198
|
+
className: "wallet-selector-icon"
|
|
199
|
+
}),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.WalletItem.Name, {})
|
|
167
201
|
]
|
|
168
202
|
})
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
}
|
|
172
206
|
// Annotate the CommonJS export names for ESM import in node:
|
|
173
207
|
0 && (module.exports = {
|
|
174
208
|
WalletSelector
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
// src/WalletSelector.tsx
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { Button, Menu, Modal, Typography } from "antd";
|
|
4
2
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
WalletItem,
|
|
4
|
+
getAptosConnectWallets,
|
|
5
|
+
isInstallRequired,
|
|
6
|
+
partitionWallets,
|
|
7
|
+
truncateAddress,
|
|
8
|
+
useWallet
|
|
8
9
|
} from "@aptos-labs/wallet-adapter-react";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var truncateAddress = (address) => {
|
|
12
|
-
if (!address)
|
|
13
|
-
return;
|
|
14
|
-
return `${address.slice(0, 6)}...${address.slice(-5)}`;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/WalletSelector.tsx
|
|
10
|
+
import { Button, Collapse, Divider, Flex, Modal, Typography } from "antd";
|
|
11
|
+
import { useEffect, useState } from "react";
|
|
18
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
13
|
var { Text } = Typography;
|
|
20
14
|
function WalletSelector({
|
|
21
15
|
isModalOpen,
|
|
22
|
-
setModalOpen
|
|
16
|
+
setModalOpen,
|
|
17
|
+
sortDefaultWallets,
|
|
18
|
+
sortMoreWallets
|
|
23
19
|
}) {
|
|
24
20
|
const [walletSelectorModalOpen, setWalletSelectorModalOpen] = useState(false);
|
|
25
21
|
useEffect(() => {
|
|
@@ -27,7 +23,20 @@ function WalletSelector({
|
|
|
27
23
|
setWalletSelectorModalOpen(isModalOpen);
|
|
28
24
|
}
|
|
29
25
|
}, [isModalOpen]);
|
|
30
|
-
const {
|
|
26
|
+
const { account, connected, disconnect, wallets = [] } = useWallet();
|
|
27
|
+
const {
|
|
28
|
+
aptosConnectWallets,
|
|
29
|
+
otherWallets
|
|
30
|
+
} = getAptosConnectWallets(wallets);
|
|
31
|
+
const {
|
|
32
|
+
defaultWallets,
|
|
33
|
+
moreWallets
|
|
34
|
+
} = partitionWallets(otherWallets);
|
|
35
|
+
if (sortDefaultWallets)
|
|
36
|
+
defaultWallets.sort(sortDefaultWallets);
|
|
37
|
+
if (sortMoreWallets)
|
|
38
|
+
moreWallets.sort(sortMoreWallets);
|
|
39
|
+
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
31
40
|
const onWalletButtonClick = () => {
|
|
32
41
|
if (connected) {
|
|
33
42
|
disconnect();
|
|
@@ -35,118 +44,146 @@ function WalletSelector({
|
|
|
35
44
|
setWalletSelectorModalOpen(true);
|
|
36
45
|
}
|
|
37
46
|
};
|
|
38
|
-
const
|
|
39
|
-
connect(wallet);
|
|
40
|
-
setWalletSelectorModalOpen(false);
|
|
41
|
-
if (setModalOpen) {
|
|
42
|
-
setModalOpen(false);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const onCancel = () => {
|
|
47
|
+
const closeModal = () => {
|
|
46
48
|
setWalletSelectorModalOpen(false);
|
|
47
49
|
if (setModalOpen) {
|
|
48
50
|
setModalOpen(false);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
|
-
const buttonText = (account == null ? void 0 : account.ansName)
|
|
53
|
+
const buttonText = (account == null ? void 0 : account.ansName) || truncateAddress(account == null ? void 0 : account.address) || "Unknown";
|
|
52
54
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
53
55
|
children: [
|
|
54
56
|
/* @__PURE__ */ jsx(Button, {
|
|
55
57
|
className: "wallet-button",
|
|
56
|
-
onClick:
|
|
58
|
+
onClick: onWalletButtonClick,
|
|
57
59
|
children: connected ? buttonText : "Connect Wallet"
|
|
58
60
|
}),
|
|
59
61
|
/* @__PURE__ */ jsx(Modal, {
|
|
60
62
|
title: /* @__PURE__ */ jsx("div", {
|
|
61
63
|
className: "wallet-modal-title",
|
|
62
|
-
children:
|
|
64
|
+
children: hasAptosConnectWallets ? /* @__PURE__ */ jsxs(Fragment, {
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", {
|
|
67
|
+
children: "Log in or sign up"
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsx("span", {
|
|
70
|
+
children: "with Social + Aptos Connect"
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}) : "Connect Wallet"
|
|
63
74
|
}),
|
|
64
75
|
centered: true,
|
|
65
76
|
open: walletSelectorModalOpen,
|
|
66
|
-
onCancel,
|
|
77
|
+
onCancel: closeModal,
|
|
67
78
|
footer: [],
|
|
68
79
|
closable: false,
|
|
69
80
|
zIndex: 9999,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return walletView(wallet, onWalletSelected);
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
var walletView = (wallet, onWalletSelected) => {
|
|
80
|
-
const isWalletReady = wallet.readyState === WalletReadyState.Installed || wallet.readyState === WalletReadyState.Loadable;
|
|
81
|
-
if (!isWalletReady && isRedirectable()) {
|
|
82
|
-
const mobileSupport = wallet.deeplinkProvider;
|
|
83
|
-
if (mobileSupport) {
|
|
84
|
-
return /* @__PURE__ */ jsx(Menu.Item, {
|
|
85
|
-
onClick: () => onWalletSelected(wallet.name),
|
|
86
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
87
|
-
className: "wallet-menu-wrapper",
|
|
81
|
+
className: "wallet-selector-modal",
|
|
82
|
+
children: !connected && /* @__PURE__ */ jsxs(Fragment, {
|
|
88
83
|
children: [
|
|
89
|
-
/* @__PURE__ */ jsxs(
|
|
90
|
-
className: "wallet-name-wrapper",
|
|
84
|
+
hasAptosConnectWallets && /* @__PURE__ */ jsxs(Fragment, {
|
|
91
85
|
children: [
|
|
92
|
-
/* @__PURE__ */ jsx(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
/* @__PURE__ */ jsx(Flex, {
|
|
87
|
+
vertical: true,
|
|
88
|
+
gap: 12,
|
|
89
|
+
children: aptosConnectWallets.map((wallet) => /* @__PURE__ */ jsx(AptosConnectWalletRow, {
|
|
90
|
+
wallet,
|
|
91
|
+
onConnect: closeModal
|
|
92
|
+
}, wallet.name))
|
|
96
93
|
}),
|
|
97
|
-
/* @__PURE__ */ jsx(
|
|
98
|
-
|
|
99
|
-
children: wallet.name
|
|
94
|
+
/* @__PURE__ */ jsx(Divider, {
|
|
95
|
+
children: "Or"
|
|
100
96
|
})
|
|
101
97
|
]
|
|
102
98
|
}),
|
|
103
|
-
/* @__PURE__ */ jsx(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
/* @__PURE__ */ jsx(Flex, {
|
|
100
|
+
vertical: true,
|
|
101
|
+
gap: 12,
|
|
102
|
+
children: defaultWallets.map((wallet) => /* @__PURE__ */ jsx(WalletRow, {
|
|
103
|
+
wallet,
|
|
104
|
+
onConnect: closeModal
|
|
105
|
+
}, wallet.name))
|
|
106
|
+
}),
|
|
107
|
+
!!moreWallets.length && /* @__PURE__ */ jsx(Collapse, {
|
|
108
|
+
ghost: true,
|
|
109
|
+
expandIconPosition: "end",
|
|
110
|
+
items: [
|
|
111
|
+
{
|
|
112
|
+
key: "more-wallets",
|
|
113
|
+
label: "More Wallets",
|
|
114
|
+
children: /* @__PURE__ */ jsx(Flex, {
|
|
115
|
+
vertical: true,
|
|
116
|
+
gap: 12,
|
|
117
|
+
children: moreWallets.map((wallet) => /* @__PURE__ */ jsx(WalletRow, {
|
|
118
|
+
wallet,
|
|
119
|
+
onConnect: closeModal
|
|
120
|
+
}, wallet.name))
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
]
|
|
109
124
|
})
|
|
110
125
|
]
|
|
111
126
|
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function WalletRow({ wallet, onConnect }) {
|
|
132
|
+
return /* @__PURE__ */ jsx(WalletItem, {
|
|
133
|
+
wallet,
|
|
134
|
+
onConnect,
|
|
135
|
+
asChild: true,
|
|
136
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: "wallet-menu-wrapper",
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("div", {
|
|
140
|
+
className: "wallet-name-wrapper",
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsx(WalletItem.Icon, {
|
|
143
|
+
className: "wallet-selector-icon"
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx(WalletItem.Name, {
|
|
146
|
+
asChild: true,
|
|
147
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
130
148
|
className: "wallet-selector-text",
|
|
131
149
|
children: wallet.name
|
|
132
150
|
})
|
|
133
|
-
]
|
|
134
|
-
}),
|
|
135
|
-
wallet.readyState === WalletReadyState.Installed || wallet.readyState === WalletReadyState.Loadable ? /* @__PURE__ */ jsx(Button, {
|
|
136
|
-
className: "wallet-connect-button",
|
|
137
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
138
|
-
className: "wallet-connect-button-text",
|
|
139
|
-
children: "Connect"
|
|
140
151
|
})
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
isInstallRequired(wallet) ? /* @__PURE__ */ jsx(WalletItem.InstallLink, {
|
|
155
|
+
className: "wallet-connect-install"
|
|
156
|
+
}) : /* @__PURE__ */ jsx(WalletItem.ConnectButton, {
|
|
157
|
+
asChild: true,
|
|
158
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
159
|
+
className: "wallet-connect-button",
|
|
160
|
+
children: "Connect"
|
|
144
161
|
})
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function AptosConnectWalletRow({ wallet, onConnect }) {
|
|
168
|
+
return /* @__PURE__ */ jsx(WalletItem, {
|
|
169
|
+
wallet,
|
|
170
|
+
onConnect,
|
|
171
|
+
asChild: true,
|
|
172
|
+
children: /* @__PURE__ */ jsx(WalletItem.ConnectButton, {
|
|
173
|
+
asChild: true,
|
|
174
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
175
|
+
size: "large",
|
|
176
|
+
className: "aptos-connect-button",
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ jsx(WalletItem.Icon, {
|
|
179
|
+
className: "wallet-selector-icon"
|
|
180
|
+
}),
|
|
181
|
+
/* @__PURE__ */ jsx(WalletItem.Name, {})
|
|
145
182
|
]
|
|
146
183
|
})
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
150
187
|
export {
|
|
151
188
|
WalletSelector
|
|
152
189
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-ant-design",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter ant-design",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@aptos-labs/wallet-adapter-tsconfig": "0.0.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"antd": "^5.
|
|
47
|
-
"@aptos-labs/wallet-adapter-react": "3.
|
|
46
|
+
"antd": "^5.18.3",
|
|
47
|
+
"@aptos-labs/wallet-adapter-react": "3.3.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": "^18",
|
package/src/WalletSelector.tsx
CHANGED
|
@@ -1,35 +1,69 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
2
|
-
import { Button, Menu, Modal, Typography } from "antd";
|
|
3
1
|
import {
|
|
4
|
-
|
|
2
|
+
AnyAptosWallet,
|
|
3
|
+
WalletItem,
|
|
4
|
+
getAptosConnectWallets,
|
|
5
|
+
isInstallRequired,
|
|
6
|
+
partitionWallets,
|
|
7
|
+
truncateAddress,
|
|
5
8
|
useWallet,
|
|
6
|
-
Wallet,
|
|
7
|
-
WalletReadyState,
|
|
8
|
-
WalletName,
|
|
9
|
-
AptosStandardSupportedWallet,
|
|
10
9
|
} from "@aptos-labs/wallet-adapter-react";
|
|
10
|
+
import { Button, Collapse, Divider, Flex, Modal, Typography } from "antd";
|
|
11
|
+
import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
11
12
|
import "./styles.css";
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
const { Text } = Typography;
|
|
14
15
|
|
|
15
16
|
type WalletSelectorProps = {
|
|
16
17
|
isModalOpen?: boolean;
|
|
17
18
|
setModalOpen?: Dispatch<SetStateAction<boolean>>;
|
|
19
|
+
/**
|
|
20
|
+
* An optional function for sorting wallets that are currently installed or
|
|
21
|
+
* loadable in the wallet selector modal.
|
|
22
|
+
*/
|
|
23
|
+
sortDefaultWallets?: (a: AnyAptosWallet, b: AnyAptosWallet) => number;
|
|
24
|
+
/**
|
|
25
|
+
* An optional function for sorting wallets that are NOT currently installed or
|
|
26
|
+
* loadable in the wallet selector modal.
|
|
27
|
+
*/
|
|
28
|
+
sortMoreWallets?: (a: AnyAptosWallet, b: AnyAptosWallet) => number;
|
|
18
29
|
};
|
|
19
30
|
|
|
20
31
|
export function WalletSelector({
|
|
21
32
|
isModalOpen,
|
|
22
33
|
setModalOpen,
|
|
34
|
+
sortDefaultWallets,
|
|
35
|
+
sortMoreWallets,
|
|
23
36
|
}: WalletSelectorProps) {
|
|
24
37
|
const [walletSelectorModalOpen, setWalletSelectorModalOpen] = useState(false);
|
|
25
38
|
|
|
26
39
|
useEffect(() => {
|
|
40
|
+
// If the component is being used as a controlled component,
|
|
41
|
+
// sync the external and internal modal state.
|
|
27
42
|
if (isModalOpen !== undefined) {
|
|
28
43
|
setWalletSelectorModalOpen(isModalOpen);
|
|
29
44
|
}
|
|
30
45
|
}, [isModalOpen]);
|
|
31
46
|
|
|
32
|
-
const {
|
|
47
|
+
const { account, connected, disconnect, wallets = [] } = useWallet();
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
/** Wallets that use social login to create an account on the blockchain */
|
|
51
|
+
aptosConnectWallets,
|
|
52
|
+
/** Wallets that use traditional wallet extensions */
|
|
53
|
+
otherWallets,
|
|
54
|
+
} = getAptosConnectWallets(wallets);
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
/** Wallets that are currently installed or loadable. */
|
|
58
|
+
defaultWallets,
|
|
59
|
+
/** Wallets that are NOT currently installed or loadable. */
|
|
60
|
+
moreWallets,
|
|
61
|
+
} = partitionWallets(otherWallets);
|
|
62
|
+
|
|
63
|
+
if (sortDefaultWallets) defaultWallets.sort(sortDefaultWallets);
|
|
64
|
+
if (sortMoreWallets) moreWallets.sort(sortMoreWallets);
|
|
65
|
+
|
|
66
|
+
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
33
67
|
|
|
34
68
|
const onWalletButtonClick = () => {
|
|
35
69
|
if (connected) {
|
|
@@ -39,107 +73,133 @@ export function WalletSelector({
|
|
|
39
73
|
}
|
|
40
74
|
};
|
|
41
75
|
|
|
42
|
-
const
|
|
43
|
-
connect(wallet);
|
|
44
|
-
setWalletSelectorModalOpen(false);
|
|
45
|
-
if (setModalOpen) {
|
|
46
|
-
setModalOpen(false);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const onCancel = () => {
|
|
76
|
+
const closeModal = () => {
|
|
50
77
|
setWalletSelectorModalOpen(false);
|
|
51
78
|
if (setModalOpen) {
|
|
52
79
|
setModalOpen(false);
|
|
53
80
|
}
|
|
54
81
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
82
|
+
|
|
83
|
+
const buttonText =
|
|
84
|
+
account?.ansName || truncateAddress(account?.address) || "Unknown";
|
|
85
|
+
|
|
58
86
|
return (
|
|
59
87
|
<>
|
|
60
|
-
<Button className="wallet-button" onClick={
|
|
88
|
+
<Button className="wallet-button" onClick={onWalletButtonClick}>
|
|
61
89
|
{connected ? buttonText : "Connect Wallet"}
|
|
62
90
|
</Button>
|
|
63
91
|
<Modal
|
|
64
|
-
title={
|
|
92
|
+
title={
|
|
93
|
+
<div className="wallet-modal-title">
|
|
94
|
+
{hasAptosConnectWallets ? (
|
|
95
|
+
<>
|
|
96
|
+
<span>Log in or sign up</span>
|
|
97
|
+
<span>with Social + Aptos Connect</span>
|
|
98
|
+
</>
|
|
99
|
+
) : (
|
|
100
|
+
"Connect Wallet"
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
}
|
|
65
104
|
centered
|
|
66
105
|
open={walletSelectorModalOpen}
|
|
67
|
-
onCancel={
|
|
106
|
+
onCancel={closeModal}
|
|
68
107
|
footer={[]}
|
|
69
108
|
closable={false}
|
|
70
109
|
zIndex={9999}
|
|
110
|
+
className="wallet-selector-modal"
|
|
71
111
|
>
|
|
72
112
|
{!connected && (
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
113
|
+
<>
|
|
114
|
+
{hasAptosConnectWallets && (
|
|
115
|
+
<>
|
|
116
|
+
<Flex vertical gap={12}>
|
|
117
|
+
{aptosConnectWallets.map((wallet) => (
|
|
118
|
+
<AptosConnectWalletRow
|
|
119
|
+
key={wallet.name}
|
|
120
|
+
wallet={wallet}
|
|
121
|
+
onConnect={closeModal}
|
|
122
|
+
/>
|
|
123
|
+
))}
|
|
124
|
+
</Flex>
|
|
125
|
+
<Divider>Or</Divider>
|
|
126
|
+
</>
|
|
127
|
+
)}
|
|
128
|
+
<Flex vertical gap={12}>
|
|
129
|
+
{defaultWallets.map((wallet) => (
|
|
130
|
+
<WalletRow
|
|
131
|
+
key={wallet.name}
|
|
132
|
+
wallet={wallet}
|
|
133
|
+
onConnect={closeModal}
|
|
134
|
+
/>
|
|
135
|
+
))}
|
|
136
|
+
</Flex>
|
|
137
|
+
{!!moreWallets.length && (
|
|
138
|
+
<Collapse
|
|
139
|
+
ghost
|
|
140
|
+
expandIconPosition="end"
|
|
141
|
+
items={[
|
|
142
|
+
{
|
|
143
|
+
key: "more-wallets",
|
|
144
|
+
label: "More Wallets",
|
|
145
|
+
children: (
|
|
146
|
+
<Flex vertical gap={12}>
|
|
147
|
+
{moreWallets.map((wallet) => (
|
|
148
|
+
<WalletRow
|
|
149
|
+
key={wallet.name}
|
|
150
|
+
wallet={wallet}
|
|
151
|
+
onConnect={closeModal}
|
|
152
|
+
/>
|
|
153
|
+
))}
|
|
154
|
+
</Flex>
|
|
155
|
+
),
|
|
156
|
+
},
|
|
157
|
+
]}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</>
|
|
78
161
|
)}
|
|
79
162
|
</Modal>
|
|
80
163
|
</>
|
|
81
164
|
);
|
|
82
165
|
}
|
|
83
166
|
|
|
84
|
-
|
|
85
|
-
wallet:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (mobileSupport) {
|
|
97
|
-
return (
|
|
98
|
-
<Menu.Item
|
|
99
|
-
key={wallet.name}
|
|
100
|
-
onClick={() => onWalletSelected(wallet.name)}
|
|
101
|
-
>
|
|
102
|
-
<div className="wallet-menu-wrapper">
|
|
103
|
-
<div className="wallet-name-wrapper">
|
|
104
|
-
<img src={wallet.icon} width={25} style={{ marginRight: 10 }} />
|
|
105
|
-
<Text className="wallet-selector-text">{wallet.name}</Text>
|
|
106
|
-
</div>
|
|
107
|
-
<Button className="wallet-connect-button">
|
|
108
|
-
<Text className="wallet-connect-button-text">Connect</Text>
|
|
109
|
-
</Button>
|
|
110
|
-
</div>
|
|
111
|
-
</Menu.Item>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
// Otherwise don't show anything
|
|
115
|
-
return null;
|
|
116
|
-
} else {
|
|
117
|
-
// The user is on a desktop device
|
|
118
|
-
return (
|
|
119
|
-
<Menu.Item
|
|
120
|
-
key={wallet.name}
|
|
121
|
-
onClick={
|
|
122
|
-
wallet.readyState === WalletReadyState.Installed ||
|
|
123
|
-
wallet.readyState === WalletReadyState.Loadable
|
|
124
|
-
? () => onWalletSelected(wallet.name)
|
|
125
|
-
: () => window.open(wallet.url)
|
|
126
|
-
}
|
|
127
|
-
>
|
|
128
|
-
<div className="wallet-menu-wrapper">
|
|
129
|
-
<div className="wallet-name-wrapper">
|
|
130
|
-
<img src={wallet.icon} width={25} style={{ marginRight: 10 }} />
|
|
167
|
+
interface WalletRowProps {
|
|
168
|
+
wallet: AnyAptosWallet;
|
|
169
|
+
onConnect?: () => void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function WalletRow({ wallet, onConnect }: WalletRowProps) {
|
|
173
|
+
return (
|
|
174
|
+
<WalletItem wallet={wallet} onConnect={onConnect} asChild>
|
|
175
|
+
<div className="wallet-menu-wrapper">
|
|
176
|
+
<div className="wallet-name-wrapper">
|
|
177
|
+
<WalletItem.Icon className="wallet-selector-icon" />
|
|
178
|
+
<WalletItem.Name asChild>
|
|
131
179
|
<Text className="wallet-selector-text">{wallet.name}</Text>
|
|
132
|
-
</
|
|
133
|
-
{wallet.readyState === WalletReadyState.Installed ||
|
|
134
|
-
wallet.readyState === WalletReadyState.Loadable ? (
|
|
135
|
-
<Button className="wallet-connect-button">
|
|
136
|
-
<Text className="wallet-connect-button-text">Connect</Text>
|
|
137
|
-
</Button>
|
|
138
|
-
) : (
|
|
139
|
-
<Text className="wallet-connect-install">Install</Text>
|
|
140
|
-
)}
|
|
180
|
+
</WalletItem.Name>
|
|
141
181
|
</div>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
182
|
+
{isInstallRequired(wallet) ? (
|
|
183
|
+
<WalletItem.InstallLink className="wallet-connect-install" />
|
|
184
|
+
) : (
|
|
185
|
+
<WalletItem.ConnectButton asChild>
|
|
186
|
+
<Button className="wallet-connect-button">Connect</Button>
|
|
187
|
+
</WalletItem.ConnectButton>
|
|
188
|
+
)}
|
|
189
|
+
</div>
|
|
190
|
+
</WalletItem>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function AptosConnectWalletRow({ wallet, onConnect }: WalletRowProps) {
|
|
195
|
+
return (
|
|
196
|
+
<WalletItem wallet={wallet} onConnect={onConnect} asChild>
|
|
197
|
+
<WalletItem.ConnectButton asChild>
|
|
198
|
+
<Button size="large" className="aptos-connect-button">
|
|
199
|
+
<WalletItem.Icon className="wallet-selector-icon" />
|
|
200
|
+
<WalletItem.Name />
|
|
201
|
+
</Button>
|
|
202
|
+
</WalletItem.ConnectButton>
|
|
203
|
+
</WalletItem>
|
|
204
|
+
);
|
|
205
|
+
}
|
package/src/styles.css
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
background-color:
|
|
7
|
-
|
|
8
|
-
height: auto !important;
|
|
9
|
-
margin-bottom: 10px !important;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.ant-menu-item-selected {
|
|
13
|
-
background-color: rgba(0, 0, 0, 0.06) !important;
|
|
14
|
-
color: black !important;
|
|
1
|
+
.wallet-button {
|
|
2
|
+
padding: 10px 20px;
|
|
3
|
+
height: auto;
|
|
4
|
+
border-radius: 6px;
|
|
5
|
+
font-size: 16px;
|
|
6
|
+
background-color: #3f67ff;
|
|
7
|
+
color: white;
|
|
15
8
|
}
|
|
16
9
|
|
|
17
|
-
.wallet-
|
|
18
|
-
|
|
10
|
+
.wallet-modal-title {
|
|
11
|
+
text-align: center;
|
|
12
|
+
font-size: 1.5rem;
|
|
13
|
+
line-height: 2rem;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
margin-bottom: 32px;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
.
|
|
22
|
-
color:
|
|
19
|
+
.aptos-connect-button {
|
|
20
|
+
color: #3f67ff;
|
|
21
|
+
border-color: #3f67ff;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
.wallet-menu-wrapper {
|
|
26
25
|
display: flex;
|
|
27
26
|
justify-content: space-between;
|
|
28
27
|
font-size: 20px;
|
|
28
|
+
border: solid 1px;
|
|
29
|
+
border-color: rgba(0, 0, 0, 0.1);
|
|
30
|
+
padding-inline: 16px;
|
|
31
|
+
padding-block: 12px;
|
|
32
|
+
border-radius: 8px;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
.wallet-name-wrapper {
|
|
@@ -33,30 +37,53 @@
|
|
|
33
37
|
align-items: center;
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
.wallet-selector-icon {
|
|
41
|
+
height: 24px;
|
|
42
|
+
width: 24px;
|
|
43
|
+
margin-right: 12px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.wallet-selector-text {
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
.wallet-connect-button {
|
|
37
51
|
align-self: center;
|
|
38
52
|
background-color: #3f67ff;
|
|
53
|
+
color: white;
|
|
39
54
|
height: auto;
|
|
40
55
|
}
|
|
41
56
|
|
|
42
57
|
.wallet-connect-install {
|
|
43
58
|
align-self: center;
|
|
44
59
|
color: #3f67ff;
|
|
45
|
-
padding-right:
|
|
60
|
+
padding-right: 16px;
|
|
46
61
|
font-size: 16px;
|
|
47
|
-
|
|
48
|
-
padding-bottom: 3px;
|
|
62
|
+
line-height: 32px;
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
/* Scoped Ant CSS overrides */
|
|
66
|
+
|
|
67
|
+
:where(.wallet-selector-modal .ant-modal-body) {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 16px;
|
|
57
71
|
}
|
|
58
72
|
|
|
59
|
-
.wallet-modal-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
:where(.wallet-selector-modal .ant-divider-inner-text) {
|
|
74
|
+
color: rgba(0, 0, 0, 0.5);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:where(.wallet-selector-modal .ant-collapse-header) {
|
|
78
|
+
justify-content: center !important;
|
|
79
|
+
color: rgba(0, 0, 0, 0.5) !important;
|
|
80
|
+
}
|
|
81
|
+
:where(.wallet-selector-modal .ant-collapse-header-text) {
|
|
82
|
+
flex: unset !important;
|
|
83
|
+
margin-inline-end: 0 !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:where(.wallet-selector-modal .ant-collapse-content-box) {
|
|
87
|
+
padding: 0px !important;
|
|
88
|
+
padding-top: 8px !important;
|
|
62
89
|
}
|
package/src/utils.ts
DELETED