@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
|
@@ -39,9 +39,15 @@ import { KkRestAdapter } from "@keepkey/hdwallet-keepkey-rest";
|
|
|
39
39
|
import { KeepKeySdk } from "@keepkey/keepkey-sdk";
|
|
40
40
|
import { SDK } from "@pioneer-sdk/sdk";
|
|
41
41
|
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
42
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
enableShapeShiftSnap,
|
|
44
|
+
shapeShiftSnapInstalled,
|
|
45
|
+
} from "@shapeshiftoss/metamask-snaps-adapter";
|
|
43
46
|
// import * as keplr from "@shapeshiftoss/hdwallet-keplr";
|
|
44
|
-
import * as metaMask from "@shapeshiftoss/hdwallet-metamask";
|
|
47
|
+
// import * as metaMask from "@shapeshiftoss/hdwallet-metamask";
|
|
48
|
+
import * as metaMask from "@shapeshiftoss/hdwallet-shapeshift-multichain";
|
|
49
|
+
import { MetaMaskAdapter as MetaMaskSnapAdapter } from '@shapeshiftoss/hdwallet-shapeshift-multichain'
|
|
50
|
+
import { MetaMaskShapeShiftMultiChainHDWallet } from '@shapeshiftoss/hdwallet-shapeshift-multichain'
|
|
45
51
|
import type { NativeHDWallet } from "@shapeshiftoss/hdwallet-native";
|
|
46
52
|
import { EventEmitter } from "events";
|
|
47
53
|
import { NativeAdapter } from "@shapeshiftoss/hdwallet-native";
|
|
@@ -60,11 +66,12 @@ import { checkKeepkeyAvailability, timeout } from "lib/components/utils";
|
|
|
60
66
|
|
|
61
67
|
const eventEmitter = new EventEmitter();
|
|
62
68
|
|
|
63
|
-
const SNAP_ID = "npm:@shapeshiftoss/metamask-snaps"
|
|
69
|
+
const SNAP_ID = "npm:@shapeshiftoss/metamask-snaps";
|
|
64
70
|
|
|
65
71
|
export enum WalletActions {
|
|
66
72
|
SET_STATUS = "SET_STATUS",
|
|
67
73
|
SET_USERNAME = "SET_USERNAME",
|
|
74
|
+
OPEN_MODAL = "OPEN_MODAL",
|
|
68
75
|
SET_API = "SET_API",
|
|
69
76
|
SET_APP = "SET_APP",
|
|
70
77
|
SET_WALLET = "SET_WALLET",
|
|
@@ -124,6 +131,7 @@ export interface IPioneerContext {
|
|
|
124
131
|
export type ActionTypes =
|
|
125
132
|
| { type: WalletActions.SET_STATUS; payload: any }
|
|
126
133
|
| { type: WalletActions.SET_USERNAME; payload: string }
|
|
134
|
+
| { type: WalletActions.OPEN_MODAL; payload: string }
|
|
127
135
|
| { type: WalletActions.SET_APP; payload: any }
|
|
128
136
|
| { type: WalletActions.SET_API; payload: any }
|
|
129
137
|
| { type: WalletActions.SET_CONTEXT; payload: any }
|
|
@@ -153,6 +161,8 @@ const reducer = (state: InitialState, action: ActionTypes) => {
|
|
|
153
161
|
case WalletActions.SET_USERNAME:
|
|
154
162
|
//eventEmitter.emit("SET_USERNAME", action.payload);
|
|
155
163
|
return { ...state, username: action.payload };
|
|
164
|
+
case WalletActions.OPEN_MODAL:
|
|
165
|
+
return { ...state, payload: action.payload };
|
|
156
166
|
case WalletActions.SET_APP:
|
|
157
167
|
return { ...state, app: action.payload };
|
|
158
168
|
case WalletActions.SET_API:
|
|
@@ -181,13 +191,24 @@ export const PioneerProvider = ({
|
|
|
181
191
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
182
192
|
// @ts-ignore
|
|
183
193
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
194
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
195
|
+
|
|
196
|
+
const showModal = (message:string) => {
|
|
197
|
+
console.log("OPEN MODAL: modal: ", message)
|
|
198
|
+
setIsModalOpen(true);
|
|
199
|
+
// Optional: You can also set a message to be displayed in the modal
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const hideModal = () => {
|
|
203
|
+
setIsModalOpen(false);
|
|
204
|
+
};
|
|
184
205
|
|
|
185
206
|
//TODO add wallet to state
|
|
186
|
-
const connectWallet = async function(wallet:string){
|
|
187
|
-
try{
|
|
188
|
-
console.log("connectWallet: ",wallet)
|
|
207
|
+
const connectWallet = async function (wallet: string) {
|
|
208
|
+
try {
|
|
209
|
+
console.log("connectWallet: ", wallet);
|
|
189
210
|
|
|
190
|
-
if(wallet === "metamask"){
|
|
211
|
+
if (wallet === "metamask") {
|
|
191
212
|
// walletMetaMask = await metaMaskAdapter.pairDevice();
|
|
192
213
|
// if (walletMetaMask) {
|
|
193
214
|
// // pair metamask
|
|
@@ -222,16 +243,13 @@ export const PioneerProvider = ({
|
|
|
222
243
|
// payload: "MetaMask connected!",
|
|
223
244
|
// });
|
|
224
245
|
// }
|
|
225
|
-
}else if (wallet === "keepkey"){
|
|
246
|
+
} else if (wallet === "keepkey") {
|
|
226
247
|
|
|
227
248
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}catch(e){
|
|
232
|
-
console.error(e)
|
|
249
|
+
} catch (e) {
|
|
250
|
+
console.error(e);
|
|
233
251
|
}
|
|
234
|
-
}
|
|
252
|
+
};
|
|
235
253
|
|
|
236
254
|
const onStart = async function () {
|
|
237
255
|
try {
|
|
@@ -242,8 +260,11 @@ export const PioneerProvider = ({
|
|
|
242
260
|
dispatch({ type: WalletActions.SET_USERNAME, payload: username });
|
|
243
261
|
|
|
244
262
|
//if auto connecting
|
|
245
|
-
|
|
246
|
-
console.log("
|
|
263
|
+
const isOnboarded = localStorage.getItem("userOnboarded");
|
|
264
|
+
console.log("isOnboarded: ", isOnboarded);
|
|
265
|
+
|
|
266
|
+
//
|
|
267
|
+
|
|
247
268
|
|
|
248
269
|
const isKeepkeyAvailable = await checkKeepkeyAvailability();
|
|
249
270
|
console.log("isKeepkeyAvailable: ", isKeepkeyAvailable);
|
|
@@ -251,15 +272,13 @@ export const PioneerProvider = ({
|
|
|
251
272
|
//is metamask available?
|
|
252
273
|
const isMetaMaskAvailable = (): boolean => {
|
|
253
274
|
return (
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
(window as any).ethereum !== undefined &&
|
|
276
|
+
(window as any).ethereum.isMetaMask
|
|
256
277
|
);
|
|
257
278
|
};
|
|
258
279
|
const keyring = new core.Keyring();
|
|
259
280
|
const metaMaskAdapter = metaMask.MetaMaskAdapter.useKeyring(keyring);
|
|
260
281
|
|
|
261
|
-
|
|
262
|
-
|
|
263
282
|
if (!queryKey) {
|
|
264
283
|
queryKey = `key:${uuidv4()}`;
|
|
265
284
|
localStorage.setItem("queryKey", queryKey);
|
|
@@ -282,7 +301,7 @@ export const PioneerProvider = ({
|
|
|
282
301
|
|
|
283
302
|
// @TODO add custom paths from localstorage
|
|
284
303
|
const paths: any = [];
|
|
285
|
-
console.log("VITE_PIONEER_URL_SPEC: "
|
|
304
|
+
console.log("VITE_PIONEER_URL_SPEC: ");
|
|
286
305
|
const spec =
|
|
287
306
|
//@ts-ignore
|
|
288
307
|
"https://pioneers.dev/spec/swagger.json";
|
|
@@ -304,17 +323,18 @@ export const PioneerProvider = ({
|
|
|
304
323
|
// @ts-ignore
|
|
305
324
|
dispatch({ type: WalletActions.SET_APP, payload: appInit });
|
|
306
325
|
// Example usage
|
|
326
|
+
// @ts-ignore
|
|
307
327
|
let walletMetaMask: metaMask.MetaMaskHDWallet | undefined;
|
|
308
328
|
if (isMetaMaskAvailable()) {
|
|
309
329
|
//is snap enabled?
|
|
310
|
-
|
|
311
|
-
console.log(isSnapInstalled)
|
|
330
|
+
const isSnapInstalled = await shapeShiftSnapInstalled(SNAP_ID);
|
|
331
|
+
console.log(isSnapInstalled);
|
|
312
332
|
|
|
313
333
|
//if not installed install snap
|
|
314
|
-
if(!isSnapInstalled){
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
334
|
+
if (!isSnapInstalled) {
|
|
335
|
+
//install it
|
|
336
|
+
const result = await enableShapeShiftSnap(SNAP_ID,"1.0.0");
|
|
337
|
+
console.log("result: ", result);
|
|
318
338
|
}
|
|
319
339
|
|
|
320
340
|
//console.log("isMetaMaskAvailable ")
|
|
@@ -322,7 +342,7 @@ export const PioneerProvider = ({
|
|
|
322
342
|
if (walletMetaMask) {
|
|
323
343
|
// pair metamask
|
|
324
344
|
await walletMetaMask.initialize();
|
|
325
|
-
|
|
345
|
+
console.log("walletMetaMask: ", walletMetaMask);
|
|
326
346
|
|
|
327
347
|
// get all accounts
|
|
328
348
|
//@ts-ignore
|
|
@@ -335,9 +355,9 @@ export const PioneerProvider = ({
|
|
|
335
355
|
|
|
336
356
|
const successMetaMask = await appInit.pairWallet(walletMetaMask);
|
|
337
357
|
console.log("successMetaMask: ", successMetaMask);
|
|
338
|
-
if(successMetaMask){
|
|
358
|
+
if (successMetaMask) {
|
|
339
359
|
// @ts-ignore
|
|
340
|
-
if (appInit.pubkeyContext?.master || appInit?.pubkey){
|
|
360
|
+
if (appInit.pubkeyContext?.master || appInit?.pubkey) {
|
|
341
361
|
// @ts-ignore
|
|
342
362
|
dispatch({
|
|
343
363
|
type: WalletActions.SET_PUBKEY_CONTEXT,
|
|
@@ -395,57 +415,35 @@ export const PioneerProvider = ({
|
|
|
395
415
|
alert("Please restart your KeepKey and try again.");
|
|
396
416
|
}
|
|
397
417
|
}
|
|
398
|
-
|
|
418
|
+
|
|
399
419
|
let walletSoftware: NativeHDWallet | null;
|
|
400
|
-
|
|
401
|
-
let
|
|
402
|
-
let hash;
|
|
420
|
+
//if native wallet saved
|
|
421
|
+
let mnemonic = localStorage.getItem("seedPhrase");
|
|
403
422
|
const nativeAdapter = NativeAdapter.useKeyring(keyring);
|
|
404
|
-
//is metamask available AND no KeepKey
|
|
405
|
-
hashStored = localStorage.getItem("hash");
|
|
406
|
-
|
|
407
|
-
if (hashStored) {
|
|
408
|
-
//generate software from metamask
|
|
409
|
-
//console.log('hashStored: ', hashStored);
|
|
410
|
-
const hashSplice = (str: string | any[] | null) => {
|
|
411
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
412
|
-
// @ts-ignore
|
|
413
|
-
return str.slice(0, 34);
|
|
414
|
-
};
|
|
415
|
-
// @ts-ignore
|
|
416
|
-
hash = hashSplice(hashStored);
|
|
417
|
-
// eslint-disable-next-line no-console
|
|
418
|
-
//console.log('hash (trimmed): ', hash);
|
|
419
|
-
// @ts-ignore
|
|
420
|
-
const hashBytes = hash.replace("0x", "");
|
|
421
|
-
//console.log('hashBytes', hashBytes);
|
|
422
|
-
//console.log('hashBytes', hashBytes.length);
|
|
423
|
-
mnemonic = entropyToMnemonic(hashBytes.toString(`hex`));
|
|
424
423
|
|
|
424
|
+
if(mnemonic){
|
|
425
|
+
console.log("mnemonic: ", mnemonic);
|
|
426
|
+
|
|
427
|
+
//if no metamask AND no keepkey
|
|
425
428
|
// get walletSoftware
|
|
426
429
|
walletSoftware = await nativeAdapter.pairDevice("testid");
|
|
427
430
|
await nativeAdapter.initialize();
|
|
428
431
|
// @ts-ignore
|
|
429
432
|
await walletSoftware.loadDevice({ mnemonic });
|
|
433
|
+
console.log("walletSoftware: ", walletSoftware);
|
|
430
434
|
const successSoftware = await appInit.pairWallet(walletSoftware);
|
|
431
|
-
|
|
435
|
+
console.log("successSoftware: ", successSoftware);
|
|
436
|
+
// @ts-ignore
|
|
437
|
+
dispatch({ type: WalletActions.ADD_WALLET, payload: walletSoftware });
|
|
438
|
+
// @ts-ignore
|
|
439
|
+
dispatch({
|
|
440
|
+
type: WalletActions.SET_STATUS,
|
|
441
|
+
payload: "Software wallet connected!",
|
|
442
|
+
});
|
|
443
|
+
}
|
|
432
444
|
|
|
433
|
-
//events!
|
|
434
|
-
const events = await appInit.startSocket();
|
|
435
445
|
|
|
436
|
-
events.on("message", (event: any) => {
|
|
437
|
-
//console.log("message: ", event);
|
|
438
|
-
});
|
|
439
446
|
|
|
440
|
-
events.on("blocks", (event: any) => {
|
|
441
|
-
//console.log("blocks: ", event);
|
|
442
|
-
// @ts-ignore
|
|
443
|
-
dispatch({
|
|
444
|
-
type: WalletActions.SET_STATUS,
|
|
445
|
-
payload: "Block Scanned!",
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
447
|
} catch (e) {
|
|
450
448
|
// eslint-disable-next-line no-console
|
|
451
449
|
console.error(e);
|
|
@@ -454,6 +452,7 @@ export const PioneerProvider = ({
|
|
|
454
452
|
|
|
455
453
|
// onstart get data
|
|
456
454
|
useEffect(() => {
|
|
455
|
+
showModal('foo');
|
|
457
456
|
onStart();
|
|
458
457
|
}, []);
|
|
459
458
|
|
|
@@ -465,5 +464,9 @@ export const PioneerProvider = ({
|
|
|
465
464
|
);
|
|
466
465
|
};
|
|
467
466
|
|
|
467
|
+
type ModalProps = {
|
|
468
|
+
onClose: () => void;
|
|
469
|
+
};
|
|
470
|
+
|
|
468
471
|
export const usePioneer = (): any =>
|
|
469
472
|
useContext(PioneerContext as unknown as React.Context<IPioneerContext>);
|
|
@@ -17,12 +17,13 @@ import WalletSelect from "lib/components/WalletSelect";
|
|
|
17
17
|
|
|
18
18
|
const Home = () => {
|
|
19
19
|
const { state } = usePioneer();
|
|
20
|
-
const { api, app, context, assetContext, blockchainContext, pubkeyContext } =
|
|
20
|
+
const { api, app, context, assetContext, blockchainContext, pubkeyContext, modals } =
|
|
21
21
|
state;
|
|
22
22
|
const [address, setAddress] = useState("");
|
|
23
23
|
const [modalType, setModalType] = useState("");
|
|
24
24
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
useEffect(() => {
|
|
27
28
|
console.log("2 pubkeyContext: ", pubkeyContext);
|
|
28
29
|
setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
|
|
@@ -33,6 +34,13 @@ const Home = () => {
|
|
|
33
34
|
onOpen();
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
let refresh = async () => {
|
|
38
|
+
//TODO why do I need to press refresh?
|
|
39
|
+
console.log("2 pubkeyContext: ", pubkeyContext);
|
|
40
|
+
setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
|
|
41
|
+
console.log("assetContext: ",assetContext)
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
return (
|
|
37
45
|
<div>
|
|
38
46
|
<Modal isOpen={isOpen} onClose={() => onClose()} size="xl">
|
|
@@ -58,6 +66,11 @@ const Home = () => {
|
|
|
58
66
|
</div>
|
|
59
67
|
)}
|
|
60
68
|
{modalType === "View Address" && <div>address: {address}</div>}
|
|
69
|
+
{modalType === "Select Outbound" && (
|
|
70
|
+
<div>
|
|
71
|
+
<BlockchainSelect onClose={onClose}></BlockchainSelect>
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
61
74
|
</ModalBody>
|
|
62
75
|
<ModalFooter>
|
|
63
76
|
<Button colorScheme="blue" onClick={onClose}>
|
|
@@ -66,7 +79,7 @@ const Home = () => {
|
|
|
66
79
|
</ModalFooter>
|
|
67
80
|
</ModalContent>
|
|
68
81
|
</Modal>
|
|
69
|
-
Context: {context}
|
|
82
|
+
Wallet Context: {context}
|
|
70
83
|
<Button onClick={() => openModal("Select wallet")}>Select wallet</Button>
|
|
71
84
|
<br />
|
|
72
85
|
Asset Context: {assetContext?.name}
|
|
@@ -77,9 +90,13 @@ const Home = () => {
|
|
|
77
90
|
Select Blockchain
|
|
78
91
|
</Button>
|
|
79
92
|
<br />
|
|
80
|
-
Address: {address}
|
|
93
|
+
Address for context: {address}
|
|
81
94
|
<Button onClick={() => openModal("View Address")}>View Address</Button>
|
|
82
95
|
<br />
|
|
96
|
+
Outbound asset context: {address}
|
|
97
|
+
<Button onClick={() => openModal("Select Outbound")}>Select asset</Button>
|
|
98
|
+
<br />
|
|
99
|
+
<Button onClick={refresh}>refresh</Button>
|
|
83
100
|
</div>
|
|
84
101
|
);
|
|
85
102
|
};
|
package/dist/index_622864fe.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { u as usePioneer, j as jsxRuntimeExports, S as Search2Icon, M as MiddleEllipsis, W as WalletSelect, A as AssetSelect } from "./index_bc632802.js";
|
|
2
|
-
import { Stack, InputGroup, InputLeftElement, Input, Box, Text, Checkbox, HStack, Avatar, Button, useDisclosure, Modal, ModalOverlay, ModalContent, ModalHeader, ModalCloseButton, ModalBody, ModalFooter } from "@chakra-ui/react";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import "react-dom";
|
|
5
|
-
import "@emotion/react";
|
|
6
|
-
function BlockchainSelect({ onClose }) {
|
|
7
|
-
const { state, dispatch } = usePioneer();
|
|
8
|
-
const { api, app, user } = state;
|
|
9
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
10
|
-
const [currentPage, setCurrentPage] = useState([]);
|
|
11
|
-
const [currentPageIndex, setCurrentPageIndex] = useState(0);
|
|
12
|
-
const [showOwnedAssets, setShowOwnedAssets] = useState(false);
|
|
13
|
-
const [timeOut, setTimeOut] = useState(null);
|
|
14
|
-
const itemsPerPage = 6;
|
|
15
|
-
const handleSelectClick = async (asset) => {
|
|
16
|
-
try {
|
|
17
|
-
const changeAssetContext = await app.setAssetContext(asset);
|
|
18
|
-
onClose();
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.error(e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const onSearch = async function(searchQuery2) {
|
|
24
|
-
try {
|
|
25
|
-
if (!api) {
|
|
26
|
-
alert("Failed to init API!");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const search = {
|
|
30
|
-
limit: itemsPerPage,
|
|
31
|
-
skip: currentPageIndex * itemsPerPage,
|
|
32
|
-
// Use currentPageIndex for pagination
|
|
33
|
-
collection: "blockchains",
|
|
34
|
-
searchQuery: searchQuery2,
|
|
35
|
-
searchFields: ["name", "symbol"]
|
|
36
|
-
};
|
|
37
|
-
const info = await api.SearchAtlas(search);
|
|
38
|
-
const currentPageData = info.data.results;
|
|
39
|
-
setCurrentPage(currentPageData);
|
|
40
|
-
setTotalBlockchains(info.data.total);
|
|
41
|
-
} catch (e) {
|
|
42
|
-
console.error(e);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const fetchPage = async (pageIndex) => {
|
|
46
|
-
try {
|
|
47
|
-
if (!api) {
|
|
48
|
-
alert("Failed to init API!");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const search = {
|
|
52
|
-
limit: itemsPerPage,
|
|
53
|
-
skip: pageIndex * itemsPerPage,
|
|
54
|
-
collection: "blockchains",
|
|
55
|
-
ownedBy: showOwnedAssets ? user.id : void 0
|
|
56
|
-
};
|
|
57
|
-
const info = await api.SearchAtlas(search);
|
|
58
|
-
const currentPageData = info.data.results;
|
|
59
|
-
setCurrentPage(currentPageData);
|
|
60
|
-
setTotalBlockchains(info.data.total);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error(e);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
fetchPage(currentPageIndex);
|
|
67
|
-
}, [currentPageIndex, showOwnedAssets]);
|
|
68
|
-
const [totalBlockchains, setTotalBlockchains] = useState(0);
|
|
69
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { spacing: 4, children: [
|
|
70
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(InputGroup, { children: [
|
|
71
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(InputLeftElement, { pointerEvents: "none", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Search2Icon, { color: "gray.300" }) }),
|
|
72
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
73
|
-
Input,
|
|
74
|
-
{
|
|
75
|
-
placeholder: "Bitcoin...",
|
|
76
|
-
type: "text",
|
|
77
|
-
value: searchQuery,
|
|
78
|
-
onChange: (e) => {
|
|
79
|
-
setSearchQuery(e.target.value);
|
|
80
|
-
if (timeOut) {
|
|
81
|
-
clearTimeout(timeOut);
|
|
82
|
-
}
|
|
83
|
-
setTimeOut(
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
setCurrentPageIndex(0);
|
|
87
|
-
onSearch(e.target.value);
|
|
88
|
-
}, 1e3)
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
] }),
|
|
94
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
|
|
95
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { fontSize: "2xl", children: [
|
|
96
|
-
"Total Chains: ",
|
|
97
|
-
totalBlockchains
|
|
98
|
-
] }),
|
|
99
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
100
|
-
Checkbox,
|
|
101
|
-
{
|
|
102
|
-
isChecked: showOwnedAssets,
|
|
103
|
-
onChange: () => setShowOwnedAssets(!showOwnedAssets),
|
|
104
|
-
children: "Show only blockchains you have assets on"
|
|
105
|
-
}
|
|
106
|
-
),
|
|
107
|
-
currentPage.map((blockchain, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
|
|
108
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(HStack, { spacing: 4, alignItems: "center", children: [
|
|
109
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Avatar, { src: blockchain == null ? void 0 : blockchain.image }),
|
|
110
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
|
|
111
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("small", { children: [
|
|
112
|
-
"blockchain: ",
|
|
113
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(MiddleEllipsis, { text: blockchain == null ? void 0 : blockchain.caip })
|
|
114
|
-
] }),
|
|
115
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
116
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("small", { children: [
|
|
117
|
-
"name: ",
|
|
118
|
-
blockchain.name
|
|
119
|
-
] })
|
|
120
|
-
] })
|
|
121
|
-
] }),
|
|
122
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(HStack, { mt: 2, spacing: 2, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
123
|
-
Button,
|
|
124
|
-
{
|
|
125
|
-
size: "sm",
|
|
126
|
-
variant: "outline",
|
|
127
|
-
onClick: () => handleSelectClick(blockchain),
|
|
128
|
-
children: "Select"
|
|
129
|
-
}
|
|
130
|
-
) })
|
|
131
|
-
] }, index))
|
|
132
|
-
] }),
|
|
133
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(HStack, { mt: 4, children: [
|
|
134
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
135
|
-
Button,
|
|
136
|
-
{
|
|
137
|
-
isDisabled: currentPageIndex === 0,
|
|
138
|
-
onClick: () => setCurrentPageIndex(currentPageIndex - 1),
|
|
139
|
-
children: "Previous Page"
|
|
140
|
-
}
|
|
141
|
-
),
|
|
142
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
143
|
-
Button,
|
|
144
|
-
{
|
|
145
|
-
isDisabled: currentPage.length < itemsPerPage,
|
|
146
|
-
onClick: () => setCurrentPageIndex(currentPageIndex + 1),
|
|
147
|
-
children: "Next Page"
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
] })
|
|
151
|
-
] });
|
|
152
|
-
}
|
|
153
|
-
const Home = () => {
|
|
154
|
-
const { state } = usePioneer();
|
|
155
|
-
const { api, app, context, assetContext, blockchainContext, pubkeyContext } = state;
|
|
156
|
-
const [address, setAddress] = useState("");
|
|
157
|
-
const [modalType, setModalType] = useState("");
|
|
158
|
-
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
console.log("2 pubkeyContext: ", pubkeyContext);
|
|
161
|
-
setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
|
|
162
|
-
}, [pubkeyContext]);
|
|
163
|
-
const openModal = (type) => {
|
|
164
|
-
setModalType(type);
|
|
165
|
-
onOpen();
|
|
166
|
-
};
|
|
167
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
168
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, { isOpen, onClose: () => onClose(), size: "xl", children: [
|
|
169
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalOverlay, {}),
|
|
170
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(ModalContent, { children: [
|
|
171
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalHeader, { children: modalType }),
|
|
172
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalCloseButton, {}),
|
|
173
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(ModalBody, { children: [
|
|
174
|
-
modalType === "Select wallet" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(WalletSelect, { onClose }) }),
|
|
175
|
-
modalType === "Select Asset" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AssetSelect, { onClose }) }),
|
|
176
|
-
modalType === "Select Blockchain" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BlockchainSelect, { onClose }) }),
|
|
177
|
-
modalType === "View Address" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
178
|
-
"address: ",
|
|
179
|
-
address
|
|
180
|
-
] })
|
|
181
|
-
] }),
|
|
182
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ModalFooter, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { colorScheme: "blue", onClick: onClose, children: "Close" }) })
|
|
183
|
-
] })
|
|
184
|
-
] }),
|
|
185
|
-
"Context: ",
|
|
186
|
-
context,
|
|
187
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => openModal("Select wallet"), children: "Select wallet" }),
|
|
188
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
189
|
-
"Asset Context: ",
|
|
190
|
-
assetContext == null ? void 0 : assetContext.name,
|
|
191
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => openModal("Select Asset"), children: "Select Asset" }),
|
|
192
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
193
|
-
"Blockchain Context: ",
|
|
194
|
-
blockchainContext == null ? void 0 : blockchainContext.name,
|
|
195
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => openModal("Select Blockchain"), children: "Select Blockchain" }),
|
|
196
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
197
|
-
"Address: ",
|
|
198
|
-
address,
|
|
199
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => openModal("View Address"), children: "View Address" }),
|
|
200
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
|
|
201
|
-
] });
|
|
202
|
-
};
|
|
203
|
-
export {
|
|
204
|
-
Home as default
|
|
205
|
-
};
|