@pioneer-platform/pioneer-react 0.2.42 → 0.2.43
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.d.ts +1 -6
- package/dist/index.js +16 -14
- package/dist/{index_2ae7b728.js → index_00dd884e.js} +5 -6
- package/dist/{index_d62adee3.js → index_089e7234.js} +1 -1
- package/dist/{index_6fc14522.js → index_1a6a5598.js} +5 -6
- package/dist/{index_5cbed275.js → index_1afbfab1.js} +246 -4473
- package/dist/{index_f59a43d2.js → index_2149ed8d.js} +8 -8
- package/dist/{index_7f071019.js → index_25e511bb.js} +15 -15
- package/dist/{index_b2be5e4e.js → index_28e5444b.js} +3 -4
- package/dist/{index_f575e7b4.js → index_31d055bf.js} +8 -9
- package/dist/{index_ebeabe97.js → index_3433fe56.js} +3 -4
- package/dist/{index_318d1d68.js → index_3ed7e242.js} +28 -28
- package/dist/{index_0d526d38.js → index_3fea9d52.js} +19 -19
- package/dist/{index_47b407db.js → index_40cbc1cb.js} +4 -5
- package/dist/{index_7d621758.js → index_40f2115a.js} +3 -4
- package/dist/{index_ed259edc.js → index_47217799.js} +5 -6
- package/dist/{index_5d556ec6.js → index_51bbd44a.js} +3 -4
- package/dist/{index_8e0864da.js → index_53605da3.js} +2 -2
- package/dist/{index_45b009da.js → index_5c12821e.js} +10 -11
- package/dist/{index_9fef85a2.js → index_5dc59e18.js} +3 -4
- package/dist/{index_ac8af4f0.js → index_61702928.js} +3 -4
- package/dist/{index_4b36612f.js → index_64ff18e7.js} +1 -1
- package/dist/{index_13b1e6a1.js → index_65017d87.js} +1 -1
- package/dist/{index_b752bc5a.js → index_6becad0b.js} +13 -13
- package/dist/{index_89463ea0.js → index_740490f1.js} +4 -5
- package/dist/{index_de955e45.js → index_75f700d8.js} +4 -5
- package/dist/{index_e525ec6b.js → index_7640e861.js} +8 -453
- package/dist/{index_d85153be.js → index_7c11b3c7.js} +3 -3
- package/dist/{index_61bfdb70.js → index_7c574e7d.js} +8 -9
- package/dist/{index_97f1ff39.js → index_7ddfebf7.js} +14 -14
- package/dist/{index_e47e2842.js → index_81dd7d0f.js} +7 -8
- package/dist/{index_a005a882.js → index_87afedd4.js} +8 -8
- package/dist/{index_0bbcbffb.js → index_87d14dd6.js} +6 -7
- package/dist/{index_aa947e34.js → index_9346dd3d.js} +7 -7
- package/dist/{index_70cc14bd.js → index_96d5aad1.js} +1223 -40
- package/dist/{index_ff288a7a.js → index_97081f9b.js} +7 -8
- package/dist/{index_4c07ec7c.js → index_9c378228.js} +11 -13
- package/dist/{index_54e4e367.js → index_a96dcbb2.js} +13 -13
- package/dist/{index_265bb459.js → index_a9d0b958.js} +29 -52
- package/dist/{index_d869d4f8.js → index_abaa7487.js} +6 -7
- package/dist/{index_d90e262e.js → index_b1b7d385.js} +13 -13
- package/dist/index_b4b501fc.js +449 -0
- package/dist/index_b62d8ff4.js +30 -0
- package/dist/{index_81d780b7.js → index_b6e5a809.js} +1 -1
- package/dist/{index_6424cb67.js → index_bd7bbccf.js} +2 -4
- package/dist/{index_381aee34.js → index_c2bc068c.js} +1 -1
- package/dist/{index_7861fcf0.js → index_c587fd1b.js} +3 -4
- package/dist/{index_239b8e07.js → index_c8c2dada.js} +1 -1
- package/dist/{index_bfa7b443.js → index_d26b5754.js} +7 -8
- package/dist/{index_015b6eba.js → index_d77fc157.js} +6154 -32027
- package/dist/{index_e4776b9a.js → index_db264e60.js} +13 -13
- package/dist/{index_2143ad7f.js → index_f044b02a.js} +1 -1
- package/dist/{index_1d49c612.js → index_fad80d95.js} +4 -5
- package/dist/lib/components/pioneer/Pioneer/Balances.js +4 -4
- package/dist/lib/components/pioneer/Pioneer/Paths.js +4 -4
- package/dist/lib/components/pioneer/Pioneer/Pubkeys.js +4 -4
- package/dist/lib/components/pioneer/Pioneer/Send.js +1 -1
- package/dist/lib/components/pioneer/Pioneer/Wallets.js +1 -1
- package/dist/lib/components/pioneer/index.js +7 -7
- package/dist/lib/pages/home/index.js +2 -9
- package/package.json +1 -1
- package/src/index.tsx +19 -19
- package/src/lib/components/pioneer/Pioneer/Balances.tsx +4 -4
- package/src/lib/components/pioneer/Pioneer/Paths.tsx +4 -4
- package/src/lib/components/pioneer/Pioneer/Pubkeys.tsx +4 -4
- package/src/lib/components/pioneer/Pioneer/Send.tsx +1 -1
- package/src/lib/components/pioneer/Pioneer/Wallets.tsx +2 -2
- package/src/lib/components/pioneer/index.tsx +6 -41
- package/src/lib/pages/home/index.tsx +5 -5
- package/dist/index_bbcb3c14.js +0 -31
- package/dist/lib/components/AssetSelect/index.d.ts +0 -4
- package/dist/lib/components/AssetSelect/index.js +0 -72
- package/dist/lib/components/BlockchainSelect/index.d.ts +0 -4
- package/dist/lib/components/BlockchainSelect/index.js +0 -88
- package/dist/lib/components/MiddleEllipsis/index.d.ts +0 -6
- package/dist/lib/components/MiddleEllipsis/index.js +0 -12
- package/dist/lib/components/Onboarding/index.d.ts +0 -6
- package/dist/lib/components/Onboarding/index.js +0 -113
- package/dist/lib/components/WalletSelect/index.d.ts +0 -4
- package/dist/lib/components/WalletSelect/index.js +0 -62
- package/dist/lib/components/modals/AssetModal.d.ts +0 -7
- package/dist/lib/components/modals/AssetModal.js +0 -28
- package/dist/lib/components/modals/SettingsModal.d.ts +0 -7
- package/dist/lib/components/modals/SettingsModal.js +0 -33
- package/src/lib/components/AssetSelect/index.tsx +0 -168
- package/src/lib/components/BlockchainSelect/index.tsx +0 -166
- package/src/lib/components/MiddleEllipsis/index.tsx +0 -27
- package/src/lib/components/Onboarding/index.tsx +0 -251
- package/src/lib/components/WalletSelect/index.tsx +0 -112
- package/src/lib/components/modals/AssetModal.tsx +0 -67
- package/src/lib/components/modals/SettingsModal.tsx +0 -95
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Search2Icon } from "@chakra-ui/icons";
|
|
2
|
-
import {
|
|
3
|
-
Avatar,
|
|
4
|
-
Box,
|
|
5
|
-
Button,
|
|
6
|
-
Checkbox,
|
|
7
|
-
HStack,
|
|
8
|
-
Stack,
|
|
9
|
-
InputGroup,
|
|
10
|
-
InputLeftElement,
|
|
11
|
-
Input,
|
|
12
|
-
Text,
|
|
13
|
-
} from "@chakra-ui/react";
|
|
14
|
-
import { useEffect, useState } from "react";
|
|
15
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
16
|
-
import MiddleEllipsis from "lib/components/MiddleEllipsis";
|
|
17
|
-
|
|
18
|
-
//@ts-ignore
|
|
19
|
-
export default function BlockchainSelect({ onClose }) {
|
|
20
|
-
const { state, dispatch } = usePioneer();
|
|
21
|
-
const { api, app, user } = state;
|
|
22
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
23
|
-
const [currentPage, setCurrentPage] = useState([]);
|
|
24
|
-
const [currentPageIndex, setCurrentPageIndex] = useState(0);
|
|
25
|
-
const [showOwnedAssets, setShowOwnedAssets] = useState(false);
|
|
26
|
-
const [timeOut, setTimeOut] = useState(null); // Added timeout state
|
|
27
|
-
const itemsPerPage = 6;
|
|
28
|
-
|
|
29
|
-
const handleSelectClick = async (asset: any) => {
|
|
30
|
-
try {
|
|
31
|
-
//console.log("asset select: ", asset.name);
|
|
32
|
-
const changeAssetContext = await app.setAssetContext(asset);
|
|
33
|
-
//console.log("changeAssetContext: ", changeAssetContext);
|
|
34
|
-
onClose();
|
|
35
|
-
} catch (e) {
|
|
36
|
-
console.error(e);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const onSearch = async function (searchQuery: string) {
|
|
41
|
-
try {
|
|
42
|
-
if (!api) {
|
|
43
|
-
alert("Failed to init API!");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
//console.log("searchQuery: ", searchQuery);
|
|
47
|
-
const search = {
|
|
48
|
-
limit: itemsPerPage,
|
|
49
|
-
skip: currentPageIndex * itemsPerPage, // Use currentPageIndex for pagination
|
|
50
|
-
collection: "blockchains",
|
|
51
|
-
searchQuery: searchQuery,
|
|
52
|
-
searchFields: ["name", "symbol"],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const info = await api.SearchAtlas(search);
|
|
56
|
-
const currentPageData = info.data.results;
|
|
57
|
-
setCurrentPage(currentPageData);
|
|
58
|
-
setTotalBlockchains(info.data.total); // Update total assets count
|
|
59
|
-
} catch (e) {
|
|
60
|
-
console.error(e);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const fetchPage = async (pageIndex: number) => {
|
|
65
|
-
try {
|
|
66
|
-
if (!api) {
|
|
67
|
-
alert("Failed to init API!");
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const search = {
|
|
72
|
-
limit: itemsPerPage,
|
|
73
|
-
skip: pageIndex * itemsPerPage,
|
|
74
|
-
collection: "blockchains",
|
|
75
|
-
ownedBy: showOwnedAssets ? user.id : undefined,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const info = await api.SearchAtlas(search);
|
|
79
|
-
const currentPageData = info.data.results;
|
|
80
|
-
setCurrentPage(currentPageData);
|
|
81
|
-
setTotalBlockchains(info.data.total); // Update total assets count
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.error(e);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
fetchPage(currentPageIndex);
|
|
89
|
-
}, [currentPageIndex, showOwnedAssets]);
|
|
90
|
-
|
|
91
|
-
const [totalBlockchains, setTotalBlockchains] = useState(0);
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Stack spacing={4}>
|
|
95
|
-
<InputGroup>
|
|
96
|
-
<InputLeftElement pointerEvents="none">
|
|
97
|
-
<Search2Icon color="gray.300" />
|
|
98
|
-
</InputLeftElement>
|
|
99
|
-
<Input
|
|
100
|
-
placeholder="Bitcoin..."
|
|
101
|
-
type="text"
|
|
102
|
-
value={searchQuery}
|
|
103
|
-
onChange={(e) => {
|
|
104
|
-
setSearchQuery(e.target.value);
|
|
105
|
-
if (timeOut) {
|
|
106
|
-
clearTimeout(timeOut);
|
|
107
|
-
}
|
|
108
|
-
setTimeOut(
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
setTimeout(() => {
|
|
111
|
-
setCurrentPageIndex(0); // Reset pageIndex when searching
|
|
112
|
-
onSearch(e.target.value);
|
|
113
|
-
}, 1000)
|
|
114
|
-
);
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
</InputGroup>
|
|
118
|
-
<Box>
|
|
119
|
-
<Text fontSize="2xl">Total Chains: {totalBlockchains}</Text>
|
|
120
|
-
<Checkbox
|
|
121
|
-
isChecked={showOwnedAssets}
|
|
122
|
-
onChange={() => setShowOwnedAssets(!showOwnedAssets)}
|
|
123
|
-
>
|
|
124
|
-
Show only blockchains you have assets on
|
|
125
|
-
</Checkbox>
|
|
126
|
-
{currentPage.map((blockchain: any, index: number) => (
|
|
127
|
-
<Box key={index}>
|
|
128
|
-
<HStack spacing={4} alignItems="center">
|
|
129
|
-
<Avatar src={blockchain?.image} />
|
|
130
|
-
<Box>
|
|
131
|
-
<small>
|
|
132
|
-
blockchain: <MiddleEllipsis text={blockchain?.caip} />
|
|
133
|
-
</small>
|
|
134
|
-
<br />
|
|
135
|
-
<small>name: {blockchain.name}</small>
|
|
136
|
-
</Box>
|
|
137
|
-
</HStack>
|
|
138
|
-
<HStack mt={2} spacing={2}>
|
|
139
|
-
<Button
|
|
140
|
-
size="sm"
|
|
141
|
-
variant="outline"
|
|
142
|
-
onClick={() => handleSelectClick(blockchain)}
|
|
143
|
-
>
|
|
144
|
-
Select
|
|
145
|
-
</Button>
|
|
146
|
-
</HStack>
|
|
147
|
-
</Box>
|
|
148
|
-
))}
|
|
149
|
-
</Box>
|
|
150
|
-
<HStack mt={4}>
|
|
151
|
-
<Button
|
|
152
|
-
isDisabled={currentPageIndex === 0}
|
|
153
|
-
onClick={() => setCurrentPageIndex(currentPageIndex - 1)}
|
|
154
|
-
>
|
|
155
|
-
Previous Page
|
|
156
|
-
</Button>
|
|
157
|
-
<Button
|
|
158
|
-
isDisabled={currentPage.length < itemsPerPage}
|
|
159
|
-
onClick={() => setCurrentPageIndex(currentPageIndex + 1)}
|
|
160
|
-
>
|
|
161
|
-
Next Page
|
|
162
|
-
</Button>
|
|
163
|
-
</HStack>
|
|
164
|
-
</Stack>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
@@ -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,251 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Text,
|
|
4
|
-
Button,
|
|
5
|
-
Modal,
|
|
6
|
-
ModalOverlay,
|
|
7
|
-
ModalContent,
|
|
8
|
-
ModalHeader,
|
|
9
|
-
ModalCloseButton,
|
|
10
|
-
ModalBody,
|
|
11
|
-
ModalFooter,
|
|
12
|
-
Tabs,
|
|
13
|
-
TabList,
|
|
14
|
-
Tab,
|
|
15
|
-
TabPanels,
|
|
16
|
-
Card,
|
|
17
|
-
CardBody,
|
|
18
|
-
TabPanel,
|
|
19
|
-
Avatar,
|
|
20
|
-
SimpleGrid,
|
|
21
|
-
AvatarBadge,
|
|
22
|
-
Input,
|
|
23
|
-
FormControl,
|
|
24
|
-
FormLabel,
|
|
25
|
-
FormErrorMessage,
|
|
26
|
-
VStack,
|
|
27
|
-
Radio,
|
|
28
|
-
RadioGroup
|
|
29
|
-
} from "@chakra-ui/react";
|
|
30
|
-
import { useState, useEffect } from "react";
|
|
31
|
-
import * as bip39 from 'bip39';
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
import KEEPKEY_ICON from "lib/assets/png/keepkey.png";
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
import METAMASK_ICON from "lib/assets/png/metamask.png";
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
import PIONEER_ICON from "lib/assets/png/pioneer.png";
|
|
38
|
-
|
|
39
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
40
|
-
|
|
41
|
-
interface ModalProps {
|
|
42
|
-
onClose: () => void;
|
|
43
|
-
}
|
|
44
|
-
//@ts-ignore
|
|
45
|
-
const Onboarding: React.FC<ModalProps> = ({ onClose }) => {
|
|
46
|
-
const { state, dispatch } = usePioneer();
|
|
47
|
-
const { api, app, user, context } = state;
|
|
48
|
-
const [walletDescriptions, setWalletDescriptions] = useState([]);
|
|
49
|
-
const [balances, setBalances] = useState([]);
|
|
50
|
-
const [metamaskPaired, setMetamaskPaired] = useState(false);
|
|
51
|
-
const [keepkeyPaired, setKeepkeyPaired] = useState(false);
|
|
52
|
-
const [nativePaired, setNativePaired] = useState(false);
|
|
53
|
-
const [walletType, setWalletType] = useState("");
|
|
54
|
-
const [pubkeyContext, setPubkeyContext] = useState("");
|
|
55
|
-
const [seedPhrase, setSeedPhrase] = useState('');
|
|
56
|
-
const [error, setError] = useState(null);
|
|
57
|
-
const [isValid, setIsValid] = useState(false);
|
|
58
|
-
const [action, setAction] = useState(null);
|
|
59
|
-
|
|
60
|
-
const setUser = async function () {
|
|
61
|
-
try {
|
|
62
|
-
if (user && user.wallets) {
|
|
63
|
-
const { wallets, walletDescriptions, balances, pubkeys } = user;
|
|
64
|
-
setWalletDescriptions(walletDescriptions);
|
|
65
|
-
setBalances(balances);
|
|
66
|
-
}
|
|
67
|
-
} catch (e) {
|
|
68
|
-
console.error("header e: ", e);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const setContextWallet = async function (wallet: string) {
|
|
73
|
-
try {
|
|
74
|
-
//console.log("setContextWallet: ", wallet);
|
|
75
|
-
// eslint-disable-next-line no-console
|
|
76
|
-
//console.log("wallets: ", app.wallets);
|
|
77
|
-
const matchedWallet = app.wallets.find(
|
|
78
|
-
(w: { type: string }) => w.type === wallet
|
|
79
|
-
);
|
|
80
|
-
//console.log("matchedWallet: ", matchedWallet);
|
|
81
|
-
if (matchedWallet) {
|
|
82
|
-
setWalletType(matchedWallet.type);
|
|
83
|
-
const context = await app.setContext(matchedWallet.wallet);
|
|
84
|
-
//console.log("result change: ", context);
|
|
85
|
-
//console.log("app.context: ", app.context);
|
|
86
|
-
|
|
87
|
-
//console.log(
|
|
88
|
-
// "app.pubkeyContext: ",
|
|
89
|
-
// app.pubkeyContext.master || app.pubkeyContext.pubkey
|
|
90
|
-
// );
|
|
91
|
-
|
|
92
|
-
const pubkeyContext =
|
|
93
|
-
app.pubkeyContext.master || app.pubkeyContext.pubkey;
|
|
94
|
-
|
|
95
|
-
setPubkeyContext(pubkeyContext);
|
|
96
|
-
dispatch({ type: "SET_CONTEXT", payload: app.context });
|
|
97
|
-
dispatch({ type: "SET_PUBKEY_CONTEXT", payload: app.pubkeyContext });
|
|
98
|
-
// dispatch({ type: "SET_WALLET", payload: wallet });
|
|
99
|
-
} else {
|
|
100
|
-
//console.log("No wallet matched the type of the context");
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {
|
|
103
|
-
console.error("header e: ", e);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
setUser();
|
|
109
|
-
}, [user]); // once on startup
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
const words = seedPhrase.trim().split(' ');
|
|
113
|
-
if (words.length === 12 && words.every(word => word.length > 0)) {
|
|
114
|
-
setError(null);
|
|
115
|
-
setIsValid(true);
|
|
116
|
-
} else {
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
setError('Seed phrase must be exactly 12 words');
|
|
119
|
-
setIsValid(false);
|
|
120
|
-
}
|
|
121
|
-
}, [seedPhrase]);
|
|
122
|
-
|
|
123
|
-
const handleSubmit = (event: { preventDefault: () => void; }) => {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
if (isValid) {
|
|
126
|
-
console.log('Seed Phrase Submitted:', seedPhrase);
|
|
127
|
-
//save to local storage
|
|
128
|
-
localStorage.setItem("seedPhrase", seedPhrase);
|
|
129
|
-
// @ts-ignore
|
|
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()
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const handleActionSelection = (value: string) => {
|
|
137
|
-
console.log("value: ", value);
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
setAction(value);
|
|
140
|
-
if (value === 'import'){
|
|
141
|
-
setSeedPhrase('');
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const handleImport = () => {
|
|
146
|
-
setSeedPhrase("");
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
setAction('import')
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const handleGenerate = () => {
|
|
152
|
-
const newSeedPhrase = bip39.generateMnemonic();
|
|
153
|
-
setSeedPhrase(newSeedPhrase);
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
setAction('generate');
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<Box>
|
|
160
|
-
Welcome to Pioneer SDK! Please select a wallet to continue.
|
|
161
|
-
<br/>
|
|
162
|
-
<Avatar size="lg" src={PIONEER_ICON}>
|
|
163
|
-
</Avatar>
|
|
164
|
-
{action ? (
|
|
165
|
-
<>
|
|
166
|
-
<form onSubmit={handleSubmit}>
|
|
167
|
-
<FormControl isInvalid={!!error}>
|
|
168
|
-
<FormLabel htmlFor="seedPhrase">Seed Phrase</FormLabel>
|
|
169
|
-
<Input
|
|
170
|
-
id="seedPhrase"
|
|
171
|
-
name="seedPhrase"
|
|
172
|
-
type="text"
|
|
173
|
-
value={seedPhrase}
|
|
174
|
-
onChange={(e) => setSeedPhrase(e.target.value)}
|
|
175
|
-
borderColor={isValid ? 'green.500' : 'red.500'}
|
|
176
|
-
/>
|
|
177
|
-
<FormErrorMessage>{error}</FormErrorMessage>
|
|
178
|
-
</FormControl>
|
|
179
|
-
<Button mt={4} colorScheme="teal" type="submit">
|
|
180
|
-
Submit
|
|
181
|
-
</Button>
|
|
182
|
-
</form>
|
|
183
|
-
<Button mt={4} onClick={() => setAction(null)}>
|
|
184
|
-
Go Back
|
|
185
|
-
</Button>
|
|
186
|
-
</>
|
|
187
|
-
) : (
|
|
188
|
-
<VStack spacing={4}>
|
|
189
|
-
<Button colorScheme="teal" onClick={handleGenerate}>
|
|
190
|
-
Generate New Seed Phrase
|
|
191
|
-
</Button>
|
|
192
|
-
<Button colorScheme="teal" onClick={handleImport}>
|
|
193
|
-
Import Seed Phrase
|
|
194
|
-
</Button>
|
|
195
|
-
</VStack>
|
|
196
|
-
)}
|
|
197
|
-
{/*<SimpleGrid columns={3} row={1}>*/}
|
|
198
|
-
{/* <Card align="center" onClick={() => setContextWallet("native")}>*/}
|
|
199
|
-
{/* <CardBody>*/}
|
|
200
|
-
{/* <Avatar src={PIONEER_ICON}>*/}
|
|
201
|
-
{/* {nativePaired ? (*/}
|
|
202
|
-
{/* <div>*/}
|
|
203
|
-
{/* <AvatarBadge boxSize="1.25em" bg="green.500" />*/}
|
|
204
|
-
{/* </div>*/}
|
|
205
|
-
{/* ) : (*/}
|
|
206
|
-
{/* <div>*/}
|
|
207
|
-
{/* <AvatarBadge boxSize="1.25em" bg="red.500" />*/}
|
|
208
|
-
{/* </div>*/}
|
|
209
|
-
{/* )}*/}
|
|
210
|
-
{/* </Avatar>*/}
|
|
211
|
-
{/* </CardBody>*/}
|
|
212
|
-
{/* <small>Pioneer</small>*/}
|
|
213
|
-
{/* </Card>*/}
|
|
214
|
-
{/* <Card align="center" onClick={() => setContextWallet("metamask")}>*/}
|
|
215
|
-
{/* <CardBody>*/}
|
|
216
|
-
{/* <Avatar src={METAMASK_ICON}>*/}
|
|
217
|
-
{/* {metamaskPaired ? (*/}
|
|
218
|
-
{/* <div>*/}
|
|
219
|
-
{/* <AvatarBadge boxSize="1.25em" bg="green.500" />*/}
|
|
220
|
-
{/* </div>*/}
|
|
221
|
-
{/* ) : (*/}
|
|
222
|
-
{/* <div>*/}
|
|
223
|
-
{/* <AvatarBadge boxSize="1.25em" bg="red.500" />*/}
|
|
224
|
-
{/* </div>*/}
|
|
225
|
-
{/* )}*/}
|
|
226
|
-
{/* </Avatar>*/}
|
|
227
|
-
{/* </CardBody>*/}
|
|
228
|
-
{/* <small>MetaMask</small>*/}
|
|
229
|
-
{/* </Card>*/}
|
|
230
|
-
{/* <Card align="center" onClick={() => setContextWallet("keepkey")}>*/}
|
|
231
|
-
{/* <CardBody>*/}
|
|
232
|
-
{/* <Avatar src={KEEPKEY_ICON}>*/}
|
|
233
|
-
{/* {keepkeyPaired ? (*/}
|
|
234
|
-
{/* <div>*/}
|
|
235
|
-
{/* <AvatarBadge boxSize="1.25em" bg="green.500" />*/}
|
|
236
|
-
{/* </div>*/}
|
|
237
|
-
{/* ) : (*/}
|
|
238
|
-
{/* <div>*/}
|
|
239
|
-
{/* <AvatarBadge boxSize="1.25em" bg="red.500" />*/}
|
|
240
|
-
{/* </div>*/}
|
|
241
|
-
{/* )}*/}
|
|
242
|
-
{/* </Avatar>*/}
|
|
243
|
-
{/* </CardBody>*/}
|
|
244
|
-
{/* <small>KeepKey</small>*/}
|
|
245
|
-
{/* </Card>*/}
|
|
246
|
-
{/*</SimpleGrid>*/}
|
|
247
|
-
</Box>
|
|
248
|
-
);
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
export default Onboarding;
|
|
@@ -1,112 +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 { useEffect, useState } from "react";
|
|
23
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
24
|
-
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
export default function WalletSelect({ onClose }) {
|
|
27
|
-
const { state, dispatch } = usePioneer();
|
|
28
|
-
const { api, app, user } = state;
|
|
29
|
-
const [context, setContext] = useState<any>(null);
|
|
30
|
-
const [walletType, setWalletType] = useState("");
|
|
31
|
-
const [pubkeyContext, setPubkeyContext] = useState("");
|
|
32
|
-
|
|
33
|
-
const handleSelectClick = async (wallet: any) => {
|
|
34
|
-
try {
|
|
35
|
-
//
|
|
36
|
-
//console.log("wallet selected! wallet: ", wallet.context);
|
|
37
|
-
//console.log("setContextWallet: ", wallet);
|
|
38
|
-
// eslint-disable-next-line no-console
|
|
39
|
-
//console.log("wallets: ", app.wallets);
|
|
40
|
-
const matchedWallet = app.wallets.find(
|
|
41
|
-
(w: { context: string }) => w.context === wallet.context
|
|
42
|
-
);
|
|
43
|
-
//console.log("matchedWallet: ", matchedWallet);
|
|
44
|
-
if (matchedWallet) {
|
|
45
|
-
setWalletType(matchedWallet.type);
|
|
46
|
-
const context = await app.setContext(matchedWallet.wallet);
|
|
47
|
-
//console.log("result change: ", context);
|
|
48
|
-
//console.log("app.context: ", app.context);
|
|
49
|
-
setContext(app.context);
|
|
50
|
-
//console.log(
|
|
51
|
-
// "app.pubkeyContext: ",
|
|
52
|
-
// app.pubkeyContext.master || app.pubkeyContext.pubkey
|
|
53
|
-
// );
|
|
54
|
-
const pubkeyContext =
|
|
55
|
-
app.pubkeyContext.master || app.pubkeyContext.pubkey;
|
|
56
|
-
setPubkeyContext(pubkeyContext);
|
|
57
|
-
dispatch({ type: "SET_CONTEXT", payload: app.context });
|
|
58
|
-
dispatch({ type: "SET_PUBKEY_CONTEXT", payload: app.pubkeyContext });
|
|
59
|
-
// dispatch({ type: "SET_WALLET", payload: wallet });
|
|
60
|
-
onClose();
|
|
61
|
-
} else {
|
|
62
|
-
//console.log("No wallet matched the type of the context");
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.error(e);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const onRender = async () => {
|
|
70
|
-
try {
|
|
71
|
-
//console.log("context: ", app?.context);
|
|
72
|
-
//console.log("wallets: ", app?.wallets);
|
|
73
|
-
//
|
|
74
|
-
dispatch({ type: "SET_CONTEXT", payload: context });
|
|
75
|
-
setContext(app?.context);
|
|
76
|
-
} catch (e) {
|
|
77
|
-
console.error(e);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
onRender();
|
|
83
|
-
}, [app, app?.context, app?.wallets]); // once on startup
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<Stack spacing={4}>
|
|
87
|
-
<Box>
|
|
88
|
-
{app?.wallets.map((wallet: any, index: number) => (
|
|
89
|
-
<Box key={index}>
|
|
90
|
-
<HStack spacing={4} alignItems="center">
|
|
91
|
-
{/*<Avatar src={balance.image} />*/}
|
|
92
|
-
<Box>
|
|
93
|
-
<small>type: {wallet.type}</small>
|
|
94
|
-
<br />
|
|
95
|
-
<small>context: {wallet.context}</small>
|
|
96
|
-
</Box>
|
|
97
|
-
</HStack>
|
|
98
|
-
<HStack mt={2} spacing={2}>
|
|
99
|
-
<Button
|
|
100
|
-
size="sm"
|
|
101
|
-
variant="outline"
|
|
102
|
-
onClick={() => handleSelectClick(wallet)}
|
|
103
|
-
>
|
|
104
|
-
Select
|
|
105
|
-
</Button>
|
|
106
|
-
</HStack>
|
|
107
|
-
</Box>
|
|
108
|
-
))}
|
|
109
|
-
</Box>
|
|
110
|
-
</Stack>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
Modal,
|
|
4
|
-
ModalOverlay,
|
|
5
|
-
ModalContent,
|
|
6
|
-
ModalHeader,
|
|
7
|
-
ModalCloseButton,
|
|
8
|
-
ModalBody,
|
|
9
|
-
ModalFooter,
|
|
10
|
-
Tabs,
|
|
11
|
-
TabList,
|
|
12
|
-
Tab,
|
|
13
|
-
TabPanels,
|
|
14
|
-
Card,
|
|
15
|
-
CardBody,
|
|
16
|
-
TabPanel,
|
|
17
|
-
} from "@chakra-ui/react";
|
|
18
|
-
import { useState, useEffect } from "react";
|
|
19
|
-
|
|
20
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
21
|
-
|
|
22
|
-
interface ModalProps {
|
|
23
|
-
isOpen: boolean;
|
|
24
|
-
onClose: () => void;
|
|
25
|
-
}
|
|
26
|
-
//@ts-ignore
|
|
27
|
-
const AssetModal: React.FC<ModalProps> = ({ isOpen, onClose }) => {
|
|
28
|
-
const { state, dispatch } = usePioneer();
|
|
29
|
-
const { api, app, user, context } = state;
|
|
30
|
-
const [walletDescriptions, setWalletDescriptions] = useState([]);
|
|
31
|
-
const [balances, setBalances] = useState([]);
|
|
32
|
-
|
|
33
|
-
const setUser = async function () {
|
|
34
|
-
try {
|
|
35
|
-
if (user && user.wallets) {
|
|
36
|
-
const { wallets, walletDescriptions, balances, pubkeys } = user;
|
|
37
|
-
setWalletDescriptions(walletDescriptions);
|
|
38
|
-
setBalances(balances);
|
|
39
|
-
}
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error("header e: ", e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
setUser();
|
|
47
|
-
}, [user]); // once on startup
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
|
51
|
-
<ModalOverlay />
|
|
52
|
-
<ModalContent>
|
|
53
|
-
<ModalHeader>Asset Select</ModalHeader>
|
|
54
|
-
<ModalCloseButton />
|
|
55
|
-
<ModalBody></ModalBody>
|
|
56
|
-
<ModalFooter>
|
|
57
|
-
<Button colorScheme="blue" mr={3} onClick={onClose}>
|
|
58
|
-
Close
|
|
59
|
-
</Button>
|
|
60
|
-
<Button variant="ghost">Secondary Action</Button>
|
|
61
|
-
</ModalFooter>
|
|
62
|
-
</ModalContent>
|
|
63
|
-
</Modal>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default AssetModal;
|