@pioneer-platform/pioneer-react 0.2.36 → 0.2.38
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/index.js +528 -401
- package/package.json +1 -1
- package/src/lib/components/Onboarding/index.tsx +2 -0
- package/src/lib/components/modals/SettingsModal.tsx +50 -31
- package/src/lib/components/pioneer/index.tsx +20 -1
- package/src/lib/context/Pioneer/index.tsx +25 -19
- package/src/lib/pages/home/index.tsx +0 -22
- package/src/lib/layout/Pioneer/Balances.tsx +0 -290
- package/src/lib/layout/Pioneer/MiddleEllipsis.tsx +0 -27
- package/src/lib/layout/Pioneer/Pubkey.tsx +0 -67
- package/src/lib/layout/Pioneer/Receive.tsx +0 -26
- package/src/lib/layout/Pioneer/Send.tsx +0 -135
- package/src/lib/layout/Pioneer/View.tsx +0 -44
- package/src/lib/layout/Pioneer/Wallets.tsx +0 -166
package/package.json
CHANGED
|
@@ -128,6 +128,8 @@ const Onboarding: React.FC<ModalProps> = ({ onClose }) => {
|
|
|
128
128
|
localStorage.setItem("seedPhrase", seedPhrase);
|
|
129
129
|
// @ts-ignore
|
|
130
130
|
localStorage.setItem("isOnboarded", "true");
|
|
131
|
+
alert("Wallet Saved to localstorage. please restart app /n (Note: this is not secure! use a hardware wallet!)");
|
|
132
|
+
onClose()
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
135
|
|
|
@@ -18,6 +18,7 @@ import Balances from "lib/components/pioneer/Pioneer/Balances";
|
|
|
18
18
|
import Wallets from "lib/components/pioneer/Pioneer/Wallets";
|
|
19
19
|
import Paths from "lib/components/pioneer/Pioneer/Paths";
|
|
20
20
|
import Pubkeys from "lib/components/pioneer/Pioneer/Pubkeys";
|
|
21
|
+
import Onboarding from "lib/components/Onboarding";
|
|
21
22
|
import { usePioneer } from "lib/context/Pioneer";
|
|
22
23
|
|
|
23
24
|
interface SettingsModalProps {
|
|
@@ -28,6 +29,22 @@ interface SettingsModalProps {
|
|
|
28
29
|
const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose }) => {
|
|
29
30
|
const { state } = usePioneer();
|
|
30
31
|
const { app, status } = state;
|
|
32
|
+
const [isOnboarded, setIsOnboarded] = useState(false);
|
|
33
|
+
|
|
34
|
+
const onStart = async function(){
|
|
35
|
+
try{
|
|
36
|
+
console.log("onStart")
|
|
37
|
+
let isOnboarded = await localStorage.getItem("isOnboarded")
|
|
38
|
+
if(!isOnboarded){
|
|
39
|
+
console.log("Starting onboarding process")
|
|
40
|
+
}
|
|
41
|
+
}catch(e){
|
|
42
|
+
console.error(e)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
onStart()
|
|
47
|
+
}, []);
|
|
31
48
|
|
|
32
49
|
useEffect(() => {
|
|
33
50
|
//console.log("app: ", app);
|
|
@@ -37,37 +54,39 @@ const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose }) => {
|
|
|
37
54
|
<Modal isOpen={isOpen} onClose={onClose} size={"xl"}>
|
|
38
55
|
<ModalOverlay />
|
|
39
56
|
<ModalContent>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
{!isOnboarded ? (<Onboarding onClose={onClose} />) : (<div>
|
|
58
|
+
<ModalHeader>Pioneer Settings</ModalHeader>
|
|
59
|
+
<ModalCloseButton />
|
|
60
|
+
<ModalBody>
|
|
61
|
+
<Tabs variant="enclosed">
|
|
62
|
+
<TabList>
|
|
63
|
+
<Tab>Wallets</Tab>
|
|
64
|
+
<Tab>Nodes</Tab>
|
|
65
|
+
<Tab>PubKeys</Tab>
|
|
66
|
+
<Tab>Balances</Tab>
|
|
67
|
+
</TabList>
|
|
68
|
+
<TabPanels>
|
|
69
|
+
<TabPanel>
|
|
70
|
+
<Wallets wallets={app?.wallets || []} />
|
|
71
|
+
</TabPanel>
|
|
72
|
+
{/*<TabPanel>*/}
|
|
73
|
+
{/* <Paths paths={app?.paths || []} />*/}
|
|
74
|
+
{/*</TabPanel>*/}
|
|
75
|
+
<TabPanel>
|
|
76
|
+
<Pubkeys pubkeys={app?.pubkeys || []} />
|
|
77
|
+
</TabPanel>
|
|
78
|
+
<TabPanel>
|
|
79
|
+
<Balances balances={app?.balances || []} />
|
|
80
|
+
</TabPanel>
|
|
81
|
+
</TabPanels>
|
|
82
|
+
</Tabs>
|
|
83
|
+
</ModalBody>
|
|
84
|
+
<ModalFooter>
|
|
85
|
+
<Button colorScheme="blue" mr={3} onClick={onClose}>
|
|
86
|
+
Close
|
|
87
|
+
</Button>
|
|
88
|
+
</ModalFooter>
|
|
89
|
+
</div>)}
|
|
71
90
|
</ModalContent>
|
|
72
91
|
</Modal>
|
|
73
92
|
);
|
|
@@ -136,6 +136,22 @@ const Pioneer = () => {
|
|
|
136
136
|
const [pubkeys, setPubkeys] = useState([]);
|
|
137
137
|
const [balances, setBalances] = useState([]);
|
|
138
138
|
|
|
139
|
+
const onStart = async function(){
|
|
140
|
+
try{
|
|
141
|
+
console.log("onStart")
|
|
142
|
+
let isOnboarded = await localStorage.getItem("isOnboarded")
|
|
143
|
+
if(!isOnboarded){
|
|
144
|
+
console.log("Starting onboarding process")
|
|
145
|
+
onOpen();
|
|
146
|
+
}
|
|
147
|
+
}catch(e){
|
|
148
|
+
console.error(e)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
onStart()
|
|
153
|
+
}, []);
|
|
154
|
+
|
|
139
155
|
const settingsSelected = async function () {
|
|
140
156
|
try {
|
|
141
157
|
//console.log("settingsSelected");
|
|
@@ -248,9 +264,12 @@ const Pioneer = () => {
|
|
|
248
264
|
dispatch({ type: "SET_PUBKEY_CONTEXT", payload: pubkeyContext });
|
|
249
265
|
}
|
|
250
266
|
}
|
|
267
|
+
|
|
251
268
|
//if address[0] !== pubkey
|
|
252
269
|
|
|
253
|
-
//
|
|
270
|
+
//
|
|
271
|
+
|
|
272
|
+
|
|
254
273
|
});
|
|
255
274
|
}
|
|
256
275
|
} catch (e) {
|
|
@@ -353,24 +353,28 @@ export const PioneerProvider = ({
|
|
|
353
353
|
//@ts-ignore
|
|
354
354
|
walletMetaMask.accounts = accounts;
|
|
355
355
|
|
|
356
|
-
const successMetaMask = await appInit.pairWallet(walletMetaMask);
|
|
357
|
-
console.log("successMetaMask: ", successMetaMask);
|
|
358
|
-
if (successMetaMask) {
|
|
359
|
-
// @ts-ignore
|
|
360
|
-
if (appInit.pubkeyContext?.master || appInit?.pubkey) {
|
|
361
|
-
// @ts-ignore
|
|
362
|
-
dispatch({
|
|
363
|
-
type: WalletActions.SET_PUBKEY_CONTEXT,
|
|
364
|
-
// @ts-ignore
|
|
365
|
-
payload: appInit.pubkeyContext?.master || appInit?.pubkey,
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
356
|
// @ts-ignore
|
|
370
357
|
dispatch({
|
|
371
358
|
type: WalletActions.SET_STATUS,
|
|
372
359
|
payload: "MetaMask connected!",
|
|
373
360
|
});
|
|
361
|
+
//@ts-ignore
|
|
362
|
+
dispatch({ type: WalletActions.ADD_WALLET, payload: walletMetaMask });
|
|
363
|
+
|
|
364
|
+
appInit.pairWallet(walletMetaMask);
|
|
365
|
+
// console.log("successMetaMask: ", successMetaMask);
|
|
366
|
+
// if (successMetaMask) {
|
|
367
|
+
// // @ts-ignore
|
|
368
|
+
// if (appInit.pubkeyContext?.master || appInit?.pubkey) {
|
|
369
|
+
// // @ts-ignore
|
|
370
|
+
// dispatch({
|
|
371
|
+
// type: WalletActions.SET_PUBKEY_CONTEXT,
|
|
372
|
+
// // @ts-ignore
|
|
373
|
+
// payload: appInit.pubkeyContext?.master || appInit?.pubkey,
|
|
374
|
+
// });
|
|
375
|
+
// }
|
|
376
|
+
// }
|
|
377
|
+
|
|
374
378
|
}
|
|
375
379
|
} else {
|
|
376
380
|
console.log("MetaMask is not available");
|
|
@@ -399,9 +403,6 @@ export const PioneerProvider = ({
|
|
|
399
403
|
KkRestAdapter.useKeyring(keyring).pairDevice(sdkKeepKey),
|
|
400
404
|
timeout(30000),
|
|
401
405
|
]);
|
|
402
|
-
// pair keepkey
|
|
403
|
-
const successKeepKey = await appInit.pairWallet(walletKeepKey);
|
|
404
|
-
//console.log("successKeepKey: ", successKeepKey);
|
|
405
406
|
//@ts-ignore
|
|
406
407
|
dispatch({ type: WalletActions.ADD_WALLET, payload: walletKeepKey });
|
|
407
408
|
// @ts-ignore
|
|
@@ -409,6 +410,10 @@ export const PioneerProvider = ({
|
|
|
409
410
|
type: WalletActions.SET_STATUS,
|
|
410
411
|
payload: "KeepKey connected!",
|
|
411
412
|
});
|
|
413
|
+
// pair keepkey
|
|
414
|
+
appInit.pairWallet(walletKeepKey);
|
|
415
|
+
//console.log("successKeepKey: ", successKeepKey);
|
|
416
|
+
|
|
412
417
|
} catch (error) {
|
|
413
418
|
//@ts-ignore
|
|
414
419
|
console.error("Error or Timeout:", error.message);
|
|
@@ -430,9 +435,7 @@ export const PioneerProvider = ({
|
|
|
430
435
|
await nativeAdapter.initialize();
|
|
431
436
|
// @ts-ignore
|
|
432
437
|
await walletSoftware.loadDevice({ mnemonic });
|
|
433
|
-
|
|
434
|
-
const successSoftware = await appInit.pairWallet(walletSoftware);
|
|
435
|
-
console.log("successSoftware: ", successSoftware);
|
|
438
|
+
|
|
436
439
|
// @ts-ignore
|
|
437
440
|
dispatch({ type: WalletActions.ADD_WALLET, payload: walletSoftware });
|
|
438
441
|
// @ts-ignore
|
|
@@ -440,6 +443,9 @@ export const PioneerProvider = ({
|
|
|
440
443
|
type: WalletActions.SET_STATUS,
|
|
441
444
|
payload: "Software wallet connected!",
|
|
442
445
|
});
|
|
446
|
+
|
|
447
|
+
console.log("walletSoftware: ", walletSoftware);
|
|
448
|
+
appInit.pairWallet(walletSoftware);
|
|
443
449
|
}
|
|
444
450
|
|
|
445
451
|
|
|
@@ -14,7 +14,6 @@ import { usePioneer } from "lib/context/Pioneer";
|
|
|
14
14
|
import AssetSelect from "lib/components/AssetSelect";
|
|
15
15
|
import BlockchainSelect from "lib/components/BlockchainSelect";
|
|
16
16
|
import WalletSelect from "lib/components/WalletSelect";
|
|
17
|
-
import Onboarding from "lib/components/Onboarding";
|
|
18
17
|
|
|
19
18
|
const Home = () => {
|
|
20
19
|
const { state } = usePioneer();
|
|
@@ -24,22 +23,6 @@ const Home = () => {
|
|
|
24
23
|
const [modalType, setModalType] = useState("");
|
|
25
24
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
26
25
|
|
|
27
|
-
const onStart = async function(){
|
|
28
|
-
try{
|
|
29
|
-
console.log("onStart")
|
|
30
|
-
let isOnboarded = await localStorage.getItem("isOnboarded")
|
|
31
|
-
if(!isOnboarded){
|
|
32
|
-
console.log("Starting onboarding process")
|
|
33
|
-
openModal("Onboarding")
|
|
34
|
-
}
|
|
35
|
-
}catch(e){
|
|
36
|
-
console.error(e)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
onStart()
|
|
41
|
-
}, []);
|
|
42
|
-
|
|
43
26
|
|
|
44
27
|
useEffect(() => {
|
|
45
28
|
console.log("2 pubkeyContext: ", pubkeyContext);
|
|
@@ -88,11 +71,6 @@ const Home = () => {
|
|
|
88
71
|
<BlockchainSelect onClose={onClose}></BlockchainSelect>
|
|
89
72
|
</div>
|
|
90
73
|
)}
|
|
91
|
-
{modalType === "Onboarding" && (
|
|
92
|
-
<div>
|
|
93
|
-
<Onboarding onClose={onClose}></Onboarding>
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
74
|
</ModalBody>
|
|
97
75
|
<ModalFooter>
|
|
98
76
|
<Button colorScheme="blue" onClick={onClose}>
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { Search2Icon } from "@chakra-ui/icons";
|
|
2
|
-
import {
|
|
3
|
-
Avatar,
|
|
4
|
-
AvatarBadge,
|
|
5
|
-
Box,
|
|
6
|
-
Button,
|
|
7
|
-
HStack,
|
|
8
|
-
Stack,
|
|
9
|
-
Image,
|
|
10
|
-
Modal,
|
|
11
|
-
ModalOverlay,
|
|
12
|
-
ModalContent,
|
|
13
|
-
ModalHeader,
|
|
14
|
-
ModalCloseButton,
|
|
15
|
-
ModalBody,
|
|
16
|
-
ModalFooter,
|
|
17
|
-
useDisclosure,
|
|
18
|
-
InputGroup,
|
|
19
|
-
InputLeftElement,
|
|
20
|
-
Input,
|
|
21
|
-
} from "@chakra-ui/react";
|
|
22
|
-
import React, { useState, useEffect } from "react";
|
|
23
|
-
|
|
24
|
-
//@ts-ignore
|
|
25
|
-
import KEEPKEY_ICON from "lib/assets/png/keepkey.png";
|
|
26
|
-
//@ts-ignore
|
|
27
|
-
import METAMASK_ICON from "lib/assets/png/metamask.png";
|
|
28
|
-
//@ts-ignore
|
|
29
|
-
import PIONEER_ICON from "lib/assets/png/pioneer.png";
|
|
30
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
31
|
-
|
|
32
|
-
import Receive from "./Receive";
|
|
33
|
-
import Send from "./Send";
|
|
34
|
-
import View from "./View";
|
|
35
|
-
|
|
36
|
-
// Import icons
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
|
|
41
|
-
interface Balance {
|
|
42
|
-
image?: string;
|
|
43
|
-
symbol: string;
|
|
44
|
-
name?: string;
|
|
45
|
-
balance?: any;
|
|
46
|
-
size?: string;
|
|
47
|
-
context?: string; // Added context field
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const getWalletType = (user: { walletDescriptions: any[] }, context: any) => {
|
|
51
|
-
if (user && user.walletDescriptions) {
|
|
52
|
-
const wallet = user.walletDescriptions.find((w) => w.id === context);
|
|
53
|
-
return wallet ? wallet.type : null;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getWalletBadgeContent = (walletType: string) => {
|
|
59
|
-
const icons: any = {
|
|
60
|
-
metamask: METAMASK_ICON,
|
|
61
|
-
keepkey: KEEPKEY_ICON,
|
|
62
|
-
native: PIONEER_ICON,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const icon = icons[walletType];
|
|
66
|
-
|
|
67
|
-
if (!icon) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<AvatarBadge boxSize="1.25em" bg="green.500">
|
|
73
|
-
<Image rounded="full" src={icon} />
|
|
74
|
-
</AvatarBadge>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export default function Balances({ balances }: { balances: Balance[] }) {
|
|
79
|
-
const { state, dispatch } = usePioneer();
|
|
80
|
-
const { user } = state;
|
|
81
|
-
const [currentPage, setCurrentPage] = useState(1);
|
|
82
|
-
const [selectedBalance, setSelectedBalance] = useState<Balance | null>(null);
|
|
83
|
-
const [selectedAction, setSelectedAction] = useState<string | null>(null);
|
|
84
|
-
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
85
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
86
|
-
const balancesPerPage = 3;
|
|
87
|
-
|
|
88
|
-
const handlePageChange = (pageNumber: any) => {
|
|
89
|
-
setCurrentPage(pageNumber);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const handleSendClick = (balance: Balance) => {
|
|
93
|
-
setSelectedBalance(balance);
|
|
94
|
-
setSelectedAction("send");
|
|
95
|
-
onOpen();
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const handleReceiveClick = (balance: Balance) => {
|
|
99
|
-
setSelectedBalance(balance);
|
|
100
|
-
setSelectedAction("receive");
|
|
101
|
-
onOpen();
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const handleViewClick = (balance: Balance) => {
|
|
105
|
-
setSelectedBalance(balance);
|
|
106
|
-
setSelectedAction("view");
|
|
107
|
-
onOpen();
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
const setUser = async () => {
|
|
112
|
-
try {
|
|
113
|
-
if (user && user.wallets) {
|
|
114
|
-
const { walletDescriptions, balances } = user;
|
|
115
|
-
// console.log("walletDescriptions: ", walletDescriptions);
|
|
116
|
-
const updatedBalances = balances.map((balance: Balance) => {
|
|
117
|
-
const walletType = getWalletType(user, balance.context);
|
|
118
|
-
const badgeContent = getWalletBadgeContent(walletType);
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
return {
|
|
121
|
-
...balance,
|
|
122
|
-
context: {
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
...balance.context,
|
|
125
|
-
badge: badgeContent,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
dispatch({ type: "SET_BALANCES", payload: updatedBalances });
|
|
130
|
-
}
|
|
131
|
-
} catch (e) {
|
|
132
|
-
console.error("Error: ", e);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
setUser();
|
|
137
|
-
}, [user]);
|
|
138
|
-
|
|
139
|
-
// Filter and sort balances based on search query
|
|
140
|
-
const filteredBalances = balances.filter((balance: Balance) => {
|
|
141
|
-
// Convert the search query and balance symbol/name to lowercase for case-insensitive search
|
|
142
|
-
const query = searchQuery.toLowerCase();
|
|
143
|
-
const symbol = balance.symbol.toLowerCase();
|
|
144
|
-
const name = balance.name ? balance.name.toLowerCase() : "";
|
|
145
|
-
|
|
146
|
-
// Check if the symbol or name contains the search query
|
|
147
|
-
return symbol.includes(query) || name.includes(query);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const sortedBalances = filteredBalances.sort(
|
|
151
|
-
(a: Balance, b: Balance) => b.balance - a.balance
|
|
152
|
-
);
|
|
153
|
-
const currentBalances = sortedBalances.slice(
|
|
154
|
-
(currentPage - 1) * balancesPerPage,
|
|
155
|
-
currentPage * balancesPerPage
|
|
156
|
-
);
|
|
157
|
-
const totalPages = Math.ceil(filteredBalances.length / balancesPerPage);
|
|
158
|
-
|
|
159
|
-
// Function to generate custom pagination array
|
|
160
|
-
const generatePaginationArray = () => {
|
|
161
|
-
const paginationArray = [];
|
|
162
|
-
const totalPageButtons = 5; // Number of page buttons to display around the current page
|
|
163
|
-
|
|
164
|
-
if (totalPages <= totalPageButtons) {
|
|
165
|
-
// If total pages are less than or equal to totalPageButtons, show all page numbers
|
|
166
|
-
for (let i = 1; i <= totalPages; i++) {
|
|
167
|
-
paginationArray.push(i);
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
// If total pages are more than totalPageButtons, generate custom pagination
|
|
171
|
-
const middleButton = Math.floor(totalPageButtons / 2);
|
|
172
|
-
const startPage = Math.max(currentPage - middleButton, 1);
|
|
173
|
-
const endPage = Math.min(currentPage + middleButton, totalPages);
|
|
174
|
-
|
|
175
|
-
if (startPage > 1) {
|
|
176
|
-
// Add the first page and ellipsis if the current page is far enough from the first page
|
|
177
|
-
paginationArray.push(1, "...");
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Add page numbers between startPage and endPage (inclusive)
|
|
181
|
-
for (let i = startPage; i <= endPage; i++) {
|
|
182
|
-
paginationArray.push(i);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (endPage < totalPages) {
|
|
186
|
-
// Add the last page and ellipsis if the current page is far enough from the last page
|
|
187
|
-
paginationArray.push("...", totalPages);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return paginationArray;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<Stack spacing={4}>
|
|
196
|
-
<InputGroup>
|
|
197
|
-
<InputLeftElement pointerEvents="none">
|
|
198
|
-
<Search2Icon color="gray.300" />
|
|
199
|
-
</InputLeftElement>
|
|
200
|
-
<Input
|
|
201
|
-
placeholder="Bitcoin..."
|
|
202
|
-
type="text"
|
|
203
|
-
value={searchQuery}
|
|
204
|
-
onChange={(e) => setSearchQuery(e.target.value)}
|
|
205
|
-
/>
|
|
206
|
-
</InputGroup>
|
|
207
|
-
{currentBalances.map((balance: Balance, index: number) => (
|
|
208
|
-
<Box key={index}>
|
|
209
|
-
<HStack spacing={4} alignItems="center">
|
|
210
|
-
<Avatar src={balance.image} />
|
|
211
|
-
<Box>
|
|
212
|
-
<small>asset: {balance.symbol}</small>
|
|
213
|
-
<br />
|
|
214
|
-
<small>balance: {balance.balance}</small>
|
|
215
|
-
</Box>
|
|
216
|
-
</HStack>
|
|
217
|
-
<HStack mt={2} spacing={2}>
|
|
218
|
-
<Button
|
|
219
|
-
size="sm"
|
|
220
|
-
variant="outline"
|
|
221
|
-
onClick={() => handleSendClick(balance)}
|
|
222
|
-
>
|
|
223
|
-
Send
|
|
224
|
-
</Button>
|
|
225
|
-
<Button
|
|
226
|
-
size="sm"
|
|
227
|
-
variant="outline"
|
|
228
|
-
onClick={() => handleReceiveClick(balance)}
|
|
229
|
-
>
|
|
230
|
-
Receive
|
|
231
|
-
</Button>
|
|
232
|
-
<Button
|
|
233
|
-
size="sm"
|
|
234
|
-
variant="outline"
|
|
235
|
-
onClick={() => handleViewClick(balance)}
|
|
236
|
-
>
|
|
237
|
-
View
|
|
238
|
-
</Button>
|
|
239
|
-
</HStack>
|
|
240
|
-
</Box>
|
|
241
|
-
))}
|
|
242
|
-
<Box mt={4}>
|
|
243
|
-
{generatePaginationArray().map((page, index) => (
|
|
244
|
-
<Button
|
|
245
|
-
key={index}
|
|
246
|
-
size="sm"
|
|
247
|
-
variant={currentPage === page ? "solid" : "outline"}
|
|
248
|
-
onClick={() => handlePageChange(page)}
|
|
249
|
-
>
|
|
250
|
-
{page === "..." ? "..." : page}
|
|
251
|
-
</Button>
|
|
252
|
-
))}
|
|
253
|
-
</Box>
|
|
254
|
-
|
|
255
|
-
<Modal isOpen={isOpen} onClose={onClose} isCentered blockScrollOnMount>
|
|
256
|
-
<ModalOverlay />
|
|
257
|
-
<ModalContent>
|
|
258
|
-
<ModalHeader>{selectedAction}</ModalHeader>
|
|
259
|
-
<ModalCloseButton />
|
|
260
|
-
{selectedAction === "send" && (
|
|
261
|
-
<div>
|
|
262
|
-
<h3>Selected Action: Send</h3>
|
|
263
|
-
<p>Selected Asset: {selectedBalance?.symbol}</p>
|
|
264
|
-
<Send asset={selectedBalance} />
|
|
265
|
-
</div>
|
|
266
|
-
)}
|
|
267
|
-
{selectedAction === "receive" && (
|
|
268
|
-
<div>
|
|
269
|
-
<h3>Selected Action: Receive</h3>
|
|
270
|
-
<p>Selected Asset: {selectedBalance?.symbol}</p>
|
|
271
|
-
<Receive />
|
|
272
|
-
</div>
|
|
273
|
-
)}
|
|
274
|
-
{selectedAction === "view" && (
|
|
275
|
-
<div>
|
|
276
|
-
<h3>Selected Action: View</h3>
|
|
277
|
-
<p>Selected Asset: {selectedBalance?.symbol}</p>
|
|
278
|
-
<View />
|
|
279
|
-
</div>
|
|
280
|
-
)}
|
|
281
|
-
<ModalFooter>
|
|
282
|
-
<Button colorScheme="blue" onClick={onClose}>
|
|
283
|
-
Cancel
|
|
284
|
-
</Button>
|
|
285
|
-
</ModalFooter>
|
|
286
|
-
</ModalContent>
|
|
287
|
-
</Modal>
|
|
288
|
-
</Stack>
|
|
289
|
-
);
|
|
290
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
|
|
3
|
-
interface MiddleEllipsisProps {
|
|
4
|
-
text: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const MiddleEllipsis: React.FC<MiddleEllipsisProps> = ({ text }) => {
|
|
8
|
-
const maxLength = 20;
|
|
9
|
-
const ellipsis = "...";
|
|
10
|
-
|
|
11
|
-
if (!text || text.length <= maxLength) {
|
|
12
|
-
return <span>{text}</span>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const frontPart = text.slice(0, 7);
|
|
16
|
-
const backPart = text.slice(-10);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<span>
|
|
20
|
-
{frontPart}
|
|
21
|
-
{ellipsis}
|
|
22
|
-
{backPart}
|
|
23
|
-
</span>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default MiddleEllipsis;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
chakra,
|
|
3
|
-
Stack,
|
|
4
|
-
CircularProgress,
|
|
5
|
-
Drawer,
|
|
6
|
-
DrawerOverlay,
|
|
7
|
-
DrawerContent,
|
|
8
|
-
DrawerHeader,
|
|
9
|
-
DrawerBody,
|
|
10
|
-
Tabs,
|
|
11
|
-
TabList,
|
|
12
|
-
TabPanels,
|
|
13
|
-
Tab,
|
|
14
|
-
TabPanel,
|
|
15
|
-
Avatar,
|
|
16
|
-
AvatarBadge,
|
|
17
|
-
Box,
|
|
18
|
-
Button,
|
|
19
|
-
Flex,
|
|
20
|
-
HStack,
|
|
21
|
-
IconButton,
|
|
22
|
-
Link,
|
|
23
|
-
Menu,
|
|
24
|
-
Image,
|
|
25
|
-
MenuButton,
|
|
26
|
-
MenuDivider,
|
|
27
|
-
Icon,
|
|
28
|
-
MenuItem,
|
|
29
|
-
MenuList,
|
|
30
|
-
Spacer,
|
|
31
|
-
Text,
|
|
32
|
-
useDisclosure,
|
|
33
|
-
Accordion,
|
|
34
|
-
AccordionItem,
|
|
35
|
-
AccordionButton,
|
|
36
|
-
AccordionIcon,
|
|
37
|
-
AccordionPanel,
|
|
38
|
-
SimpleGrid,
|
|
39
|
-
Card,
|
|
40
|
-
CardHeader,
|
|
41
|
-
Heading,
|
|
42
|
-
CardBody,
|
|
43
|
-
CardFooter,
|
|
44
|
-
Modal,
|
|
45
|
-
ModalOverlay,
|
|
46
|
-
ModalContent,
|
|
47
|
-
ModalHeader,
|
|
48
|
-
ModalCloseButton,
|
|
49
|
-
ModalBody,
|
|
50
|
-
ModalFooter,
|
|
51
|
-
} from "@chakra-ui/react";
|
|
52
|
-
import React, { useState } from "react";
|
|
53
|
-
|
|
54
|
-
import MiddleEllipsis from "./MiddleEllipsis";
|
|
55
|
-
|
|
56
|
-
interface Balance {
|
|
57
|
-
rating: number;
|
|
58
|
-
setRating: (rating: number) => void;
|
|
59
|
-
count?: number;
|
|
60
|
-
size?: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default function Pubkey(Balance: any) {
|
|
64
|
-
const [hover, setHover] = useState<number | null>(null);
|
|
65
|
-
|
|
66
|
-
return <div>{JSON.stringify(Balance)}</div>;
|
|
67
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FormControl, FormLabel, Input, Text } from "@chakra-ui/react";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import QRCode from "react-qr-code";
|
|
4
|
-
|
|
5
|
-
const Receive = () => {
|
|
6
|
-
const [address, setAddress] = useState("");
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<>
|
|
10
|
-
<FormControl>
|
|
11
|
-
<FormLabel>Address:</FormLabel>
|
|
12
|
-
<Input value={address} onChange={(e) => setAddress(e.target.value)} />
|
|
13
|
-
</FormControl>
|
|
14
|
-
|
|
15
|
-
{address && (
|
|
16
|
-
<>
|
|
17
|
-
<Text mt={4}>QR Code:</Text>
|
|
18
|
-
<QRCode value={address} size={128} />
|
|
19
|
-
<Text mt={2}>{address}</Text>
|
|
20
|
-
</>
|
|
21
|
-
)}
|
|
22
|
-
</>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default Receive;
|