@pioneer-platform/pioneer-react 0.2.35 → 0.2.37
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 +16103 -14215
- package/package.json +5 -3
- package/src/index.tsx +9 -9
- package/src/lib/components/AssetSelect/index.tsx +3 -3
- package/src/lib/components/Onboarding/index.tsx +251 -0
- package/src/lib/components/modals/SettingsModal.tsx +50 -31
- package/src/lib/components/pioneer/Pioneer/Balances.tsx +1 -1
- package/src/lib/components/pioneer/index.tsx +24 -5
- package/src/lib/components/utils/index.tsx +3 -3
- package/src/lib/context/Pioneer/index.tsx +72 -69
- package/src/lib/pages/home/index.tsx +20 -3
- package/dist/index_622864fe.js +0 -205
- package/dist/index_bc632802.js +0 -392364
- package/src/lib/components/modals/Onboarding.tsx +0 -67
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"author": "highlander",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
"@keepkey/hdwallet-keepkey-rest": "^1.40.29",
|
|
34
34
|
"@keepkey/keepkey-sdk": "^0.2.48",
|
|
35
35
|
"@pioneer-platform/pioneer-client": "^9.0.6",
|
|
36
|
-
"@pioneer-sdk/sdk": "1.1.
|
|
36
|
+
"@pioneer-sdk/sdk": "1.1.160",
|
|
37
37
|
"@shapeshiftoss/hdwallet-core": "^1.50.0",
|
|
38
38
|
"@shapeshiftoss/hdwallet-metamask": "^1.50.0",
|
|
39
39
|
"@shapeshiftoss/hdwallet-native": "^1.50.3",
|
|
40
|
-
"@shapeshiftoss/
|
|
40
|
+
"@shapeshiftoss/hdwallet-shapeshift-multichain": "1.50.5-alpha.70",
|
|
41
|
+
"@shapeshiftoss/metamask-snaps-adapter": "1.0.3",
|
|
41
42
|
"@types/uuid": "^9.0.1",
|
|
42
43
|
"assert": "^2.0.0",
|
|
44
|
+
"bip39": "^3.1.0",
|
|
43
45
|
"dotenv": "^16.3.1",
|
|
44
46
|
"events": "^3.3.0",
|
|
45
47
|
"framer-motion": "^10.12.4",
|
package/src/index.tsx
CHANGED
|
@@ -18,15 +18,15 @@ import App from "./App";
|
|
|
18
18
|
|
|
19
19
|
// To publish run as dev uncomment
|
|
20
20
|
|
|
21
|
-
const root = ReactDOM.createRoot(
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
root.render(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
21
|
+
// const root = ReactDOM.createRoot(
|
|
22
|
+
// document.getElementById("root") as HTMLElement
|
|
23
|
+
// );
|
|
24
|
+
// root.render(
|
|
25
|
+
// <>
|
|
26
|
+
// <ColorModeScript initialColorMode={theme.config?.initialColorMode} />
|
|
27
|
+
// <App />
|
|
28
|
+
// </>
|
|
29
|
+
// );
|
|
30
30
|
|
|
31
31
|
//end dev mode
|
|
32
32
|
|
|
@@ -28,9 +28,9 @@ export default function AssetSelect({ onClose }) {
|
|
|
28
28
|
|
|
29
29
|
const handleSelectClick = async (asset: any) => {
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
//console.log("asset select: ", asset.name);
|
|
32
32
|
const changeAssetContext = await app.setAssetContext(asset);
|
|
33
|
-
|
|
33
|
+
//console.log("changeAssetContext: ", changeAssetContext);
|
|
34
34
|
onClose();
|
|
35
35
|
} catch (e) {
|
|
36
36
|
console.error(e);
|
|
@@ -43,7 +43,7 @@ export default function AssetSelect({ onClose }) {
|
|
|
43
43
|
alert("Failed to init API!");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
//console.log("searchQuery: ", searchQuery);
|
|
47
47
|
const search = {
|
|
48
48
|
limit: itemsPerPage,
|
|
49
49
|
skip: currentPageIndex * itemsPerPage, // Use currentPageIndex for pagination
|
|
@@ -0,0 +1,251 @@
|
|
|
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;
|
|
@@ -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
|
);
|
|
@@ -123,7 +123,7 @@ export default function Balances({ balances }: { balances: Balance[] }) {
|
|
|
123
123
|
useEffect(() => {
|
|
124
124
|
const setUser = async () => {
|
|
125
125
|
try {
|
|
126
|
-
console.log("balances: ",app.balances)
|
|
126
|
+
console.log("balances: ", app.balances);
|
|
127
127
|
if (app && app.wallets) {
|
|
128
128
|
const { wallets, balances } = app;
|
|
129
129
|
const updatedBalances = balances.map((balance: Balance) => {
|
|
@@ -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");
|
|
@@ -224,20 +240,20 @@ const Pioneer = () => {
|
|
|
224
240
|
if (balances) {
|
|
225
241
|
setBalances(balances);
|
|
226
242
|
}
|
|
227
|
-
|
|
243
|
+
|
|
228
244
|
// @ts-ignore
|
|
229
245
|
window.ethereum.on("accountsChanged", async function (accounts: any) {
|
|
230
246
|
// Time to reload your interface with accounts[0]!
|
|
231
|
-
|
|
247
|
+
console.log('accountsChanged: ', accounts);
|
|
232
248
|
// TODO register new pubkeys
|
|
233
249
|
const walletsPaired = app.wallets;
|
|
234
250
|
//console.log("walletsPaired: ", walletsPaired);
|
|
235
251
|
//console.log("pioneer context: ", app?.context);
|
|
236
252
|
//if context is metamask
|
|
237
253
|
if (app?.context === "metamask.wallet") {
|
|
238
|
-
|
|
254
|
+
console.log("MetaMask is in context");
|
|
239
255
|
const addressMetaMask = accounts[0];
|
|
240
|
-
|
|
256
|
+
console.log("addressMetaMask: ", addressMetaMask);
|
|
241
257
|
setPubkeyContext(addressMetaMask);
|
|
242
258
|
if (addressMetaMask !== app.pubkey) {
|
|
243
259
|
//push event
|
|
@@ -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) {
|