@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,88 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Search2Icon } from "@chakra-ui/icons";
|
|
3
|
-
import { Avatar, Box, Button, Checkbox, HStack, Stack, InputGroup, InputLeftElement, Input, Text, } from "@chakra-ui/react";
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
6
|
-
import MiddleEllipsis from "lib/components/MiddleEllipsis";
|
|
7
|
-
//@ts-ignore
|
|
8
|
-
export default function BlockchainSelect({ onClose }) {
|
|
9
|
-
const { state, dispatch } = usePioneer();
|
|
10
|
-
const { api, app, user } = state;
|
|
11
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
12
|
-
const [currentPage, setCurrentPage] = useState([]);
|
|
13
|
-
const [currentPageIndex, setCurrentPageIndex] = useState(0);
|
|
14
|
-
const [showOwnedAssets, setShowOwnedAssets] = useState(false);
|
|
15
|
-
const [timeOut, setTimeOut] = useState(null); // Added timeout state
|
|
16
|
-
const itemsPerPage = 6;
|
|
17
|
-
const handleSelectClick = async (asset) => {
|
|
18
|
-
try {
|
|
19
|
-
//console.log("asset select: ", asset.name);
|
|
20
|
-
const changeAssetContext = await app.setAssetContext(asset);
|
|
21
|
-
//console.log("changeAssetContext: ", changeAssetContext);
|
|
22
|
-
onClose();
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
console.error(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const onSearch = async function (searchQuery) {
|
|
29
|
-
try {
|
|
30
|
-
if (!api) {
|
|
31
|
-
alert("Failed to init API!");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
//console.log("searchQuery: ", searchQuery);
|
|
35
|
-
const search = {
|
|
36
|
-
limit: itemsPerPage,
|
|
37
|
-
skip: currentPageIndex * itemsPerPage,
|
|
38
|
-
collection: "blockchains",
|
|
39
|
-
searchQuery: searchQuery,
|
|
40
|
-
searchFields: ["name", "symbol"],
|
|
41
|
-
};
|
|
42
|
-
const info = await api.SearchAtlas(search);
|
|
43
|
-
const currentPageData = info.data.results;
|
|
44
|
-
setCurrentPage(currentPageData);
|
|
45
|
-
setTotalBlockchains(info.data.total); // Update total assets count
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
console.error(e);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const fetchPage = async (pageIndex) => {
|
|
52
|
-
try {
|
|
53
|
-
if (!api) {
|
|
54
|
-
alert("Failed to init API!");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const search = {
|
|
58
|
-
limit: itemsPerPage,
|
|
59
|
-
skip: pageIndex * itemsPerPage,
|
|
60
|
-
collection: "blockchains",
|
|
61
|
-
ownedBy: showOwnedAssets ? user.id : undefined,
|
|
62
|
-
};
|
|
63
|
-
const info = await api.SearchAtlas(search);
|
|
64
|
-
const currentPageData = info.data.results;
|
|
65
|
-
setCurrentPage(currentPageData);
|
|
66
|
-
setTotalBlockchains(info.data.total); // Update total assets count
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
console.error(e);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
fetchPage(currentPageIndex);
|
|
74
|
-
}, [currentPageIndex, showOwnedAssets]);
|
|
75
|
-
const [totalBlockchains, setTotalBlockchains] = useState(0);
|
|
76
|
-
return (_jsxs(Stack, { spacing: 4, children: [_jsxs(InputGroup, { children: [_jsx(InputLeftElement, { pointerEvents: "none", children: _jsx(Search2Icon, { color: "gray.300" }) }), _jsx(Input, { placeholder: "Bitcoin...", type: "text", value: searchQuery, onChange: (e) => {
|
|
77
|
-
setSearchQuery(e.target.value);
|
|
78
|
-
if (timeOut) {
|
|
79
|
-
clearTimeout(timeOut);
|
|
80
|
-
}
|
|
81
|
-
setTimeOut(
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
setCurrentPageIndex(0); // Reset pageIndex when searching
|
|
85
|
-
onSearch(e.target.value);
|
|
86
|
-
}, 1000));
|
|
87
|
-
} })] }), _jsxs(Box, { children: [_jsxs(Text, { fontSize: "2xl", children: ["Total Chains: ", totalBlockchains] }), _jsx(Checkbox, { isChecked: showOwnedAssets, onChange: () => setShowOwnedAssets(!showOwnedAssets), children: "Show only blockchains you have assets on" }), currentPage.map((blockchain, index) => (_jsxs(Box, { children: [_jsxs(HStack, { spacing: 4, alignItems: "center", children: [_jsx(Avatar, { src: blockchain?.image }), _jsxs(Box, { children: [_jsxs("small", { children: ["blockchain: ", _jsx(MiddleEllipsis, { text: blockchain?.caip })] }), _jsx("br", {}), _jsxs("small", { children: ["name: ", blockchain.name] })] })] }), _jsx(HStack, { mt: 2, spacing: 2, children: _jsx(Button, { size: "sm", variant: "outline", onClick: () => handleSelectClick(blockchain), children: "Select" }) })] }, index)))] }), _jsxs(HStack, { mt: 4, children: [_jsx(Button, { isDisabled: currentPageIndex === 0, onClick: () => setCurrentPageIndex(currentPageIndex - 1), children: "Previous Page" }), _jsx(Button, { isDisabled: currentPage.length < itemsPerPage, onClick: () => setCurrentPageIndex(currentPageIndex + 1), children: "Next Page" })] })] }));
|
|
88
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
const MiddleEllipsis = ({ text }) => {
|
|
3
|
-
const maxLength = 20;
|
|
4
|
-
const ellipsis = "...";
|
|
5
|
-
if (!text || text.length <= maxLength) {
|
|
6
|
-
return _jsx("span", { children: text });
|
|
7
|
-
}
|
|
8
|
-
const frontPart = text.slice(0, 7);
|
|
9
|
-
const backPart = text.slice(-10);
|
|
10
|
-
return (_jsxs("span", { children: [frontPart, ellipsis, backPart] }));
|
|
11
|
-
};
|
|
12
|
-
export default MiddleEllipsis;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Button, Avatar, Input, FormControl, FormLabel, FormErrorMessage, VStack } from "@chakra-ui/react";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import * as bip39 from 'bip39';
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import PIONEER_ICON from "lib/assets/png/pioneer.png";
|
|
7
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
8
|
-
//@ts-ignore
|
|
9
|
-
const Onboarding = ({ onClose }) => {
|
|
10
|
-
const { state, dispatch } = usePioneer();
|
|
11
|
-
const { api, app, user, context } = state;
|
|
12
|
-
const [walletDescriptions, setWalletDescriptions] = useState([]);
|
|
13
|
-
const [balances, setBalances] = useState([]);
|
|
14
|
-
const [metamaskPaired, setMetamaskPaired] = useState(false);
|
|
15
|
-
const [keepkeyPaired, setKeepkeyPaired] = useState(false);
|
|
16
|
-
const [nativePaired, setNativePaired] = useState(false);
|
|
17
|
-
const [walletType, setWalletType] = useState("");
|
|
18
|
-
const [pubkeyContext, setPubkeyContext] = useState("");
|
|
19
|
-
const [seedPhrase, setSeedPhrase] = useState('');
|
|
20
|
-
const [error, setError] = useState(null);
|
|
21
|
-
const [isValid, setIsValid] = useState(false);
|
|
22
|
-
const [action, setAction] = useState(null);
|
|
23
|
-
const setUser = async function () {
|
|
24
|
-
try {
|
|
25
|
-
if (user && user.wallets) {
|
|
26
|
-
const { wallets, walletDescriptions, balances, pubkeys } = user;
|
|
27
|
-
setWalletDescriptions(walletDescriptions);
|
|
28
|
-
setBalances(balances);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
console.error("header e: ", e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const setContextWallet = async function (wallet) {
|
|
36
|
-
try {
|
|
37
|
-
//console.log("setContextWallet: ", wallet);
|
|
38
|
-
// eslint-disable-next-line no-console
|
|
39
|
-
//console.log("wallets: ", app.wallets);
|
|
40
|
-
const matchedWallet = app.wallets.find((w) => w.type === wallet);
|
|
41
|
-
//console.log("matchedWallet: ", matchedWallet);
|
|
42
|
-
if (matchedWallet) {
|
|
43
|
-
setWalletType(matchedWallet.type);
|
|
44
|
-
const context = await app.setContext(matchedWallet.wallet);
|
|
45
|
-
//console.log("result change: ", context);
|
|
46
|
-
//console.log("app.context: ", app.context);
|
|
47
|
-
//console.log(
|
|
48
|
-
// "app.pubkeyContext: ",
|
|
49
|
-
// app.pubkeyContext.master || app.pubkeyContext.pubkey
|
|
50
|
-
// );
|
|
51
|
-
const pubkeyContext = app.pubkeyContext.master || app.pubkeyContext.pubkey;
|
|
52
|
-
setPubkeyContext(pubkeyContext);
|
|
53
|
-
dispatch({ type: "SET_CONTEXT", payload: app.context });
|
|
54
|
-
dispatch({ type: "SET_PUBKEY_CONTEXT", payload: app.pubkeyContext });
|
|
55
|
-
// dispatch({ type: "SET_WALLET", payload: wallet });
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
//console.log("No wallet matched the type of the context");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
console.error("header e: ", e);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
setUser();
|
|
67
|
-
}, [user]); // once on startup
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
const words = seedPhrase.trim().split(' ');
|
|
70
|
-
if (words.length === 12 && words.every(word => word.length > 0)) {
|
|
71
|
-
setError(null);
|
|
72
|
-
setIsValid(true);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
setError('Seed phrase must be exactly 12 words');
|
|
77
|
-
setIsValid(false);
|
|
78
|
-
}
|
|
79
|
-
}, [seedPhrase]);
|
|
80
|
-
const handleSubmit = (event) => {
|
|
81
|
-
event.preventDefault();
|
|
82
|
-
if (isValid) {
|
|
83
|
-
console.log('Seed Phrase Submitted:', seedPhrase);
|
|
84
|
-
//save to local storage
|
|
85
|
-
localStorage.setItem("seedPhrase", seedPhrase);
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
localStorage.setItem("isOnboarded", "true");
|
|
88
|
-
alert("Wallet Saved to localstorage. please restart app /n (Note: this is not secure! use a hardware wallet!)");
|
|
89
|
-
onClose();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const handleActionSelection = (value) => {
|
|
93
|
-
console.log("value: ", value);
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
setAction(value);
|
|
96
|
-
if (value === 'import') {
|
|
97
|
-
setSeedPhrase('');
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const handleImport = () => {
|
|
101
|
-
setSeedPhrase("");
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
setAction('import');
|
|
104
|
-
};
|
|
105
|
-
const handleGenerate = () => {
|
|
106
|
-
const newSeedPhrase = bip39.generateMnemonic();
|
|
107
|
-
setSeedPhrase(newSeedPhrase);
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
setAction('generate');
|
|
110
|
-
};
|
|
111
|
-
return (_jsxs(Box, { children: ["Welcome to Pioneer SDK! Please select a wallet to continue.", _jsx("br", {}), _jsx(Avatar, { size: "lg", src: PIONEER_ICON }), action ? (_jsxs(_Fragment, { children: [_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs(FormControl, { isInvalid: !!error, children: [_jsx(FormLabel, { htmlFor: "seedPhrase", children: "Seed Phrase" }), _jsx(Input, { id: "seedPhrase", name: "seedPhrase", type: "text", value: seedPhrase, onChange: (e) => setSeedPhrase(e.target.value), borderColor: isValid ? 'green.500' : 'red.500' }), _jsx(FormErrorMessage, { children: error })] }), _jsx(Button, { mt: 4, colorScheme: "teal", type: "submit", children: "Submit" })] }), _jsx(Button, { mt: 4, onClick: () => setAction(null), children: "Go Back" })] })) : (_jsxs(VStack, { spacing: 4, children: [_jsx(Button, { colorScheme: "teal", onClick: handleGenerate, children: "Generate New Seed Phrase" }), _jsx(Button, { colorScheme: "teal", onClick: handleImport, children: "Import Seed Phrase" })] }))] }));
|
|
112
|
-
};
|
|
113
|
-
export default Onboarding;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Button, HStack, Stack, } from "@chakra-ui/react";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
export default function WalletSelect({ onClose }) {
|
|
7
|
-
const { state, dispatch } = usePioneer();
|
|
8
|
-
const { api, app, user } = state;
|
|
9
|
-
const [context, setContext] = useState(null);
|
|
10
|
-
const [walletType, setWalletType] = useState("");
|
|
11
|
-
const [pubkeyContext, setPubkeyContext] = useState("");
|
|
12
|
-
const handleSelectClick = async (wallet) => {
|
|
13
|
-
try {
|
|
14
|
-
//
|
|
15
|
-
//console.log("wallet selected! wallet: ", wallet.context);
|
|
16
|
-
//console.log("setContextWallet: ", wallet);
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
//console.log("wallets: ", app.wallets);
|
|
19
|
-
const matchedWallet = app.wallets.find((w) => w.context === wallet.context);
|
|
20
|
-
//console.log("matchedWallet: ", matchedWallet);
|
|
21
|
-
if (matchedWallet) {
|
|
22
|
-
setWalletType(matchedWallet.type);
|
|
23
|
-
const context = await app.setContext(matchedWallet.wallet);
|
|
24
|
-
//console.log("result change: ", context);
|
|
25
|
-
//console.log("app.context: ", app.context);
|
|
26
|
-
setContext(app.context);
|
|
27
|
-
//console.log(
|
|
28
|
-
// "app.pubkeyContext: ",
|
|
29
|
-
// app.pubkeyContext.master || app.pubkeyContext.pubkey
|
|
30
|
-
// );
|
|
31
|
-
const pubkeyContext = app.pubkeyContext.master || app.pubkeyContext.pubkey;
|
|
32
|
-
setPubkeyContext(pubkeyContext);
|
|
33
|
-
dispatch({ type: "SET_CONTEXT", payload: app.context });
|
|
34
|
-
dispatch({ type: "SET_PUBKEY_CONTEXT", payload: app.pubkeyContext });
|
|
35
|
-
// dispatch({ type: "SET_WALLET", payload: wallet });
|
|
36
|
-
onClose();
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
//console.log("No wallet matched the type of the context");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const onRender = async () => {
|
|
47
|
-
try {
|
|
48
|
-
//console.log("context: ", app?.context);
|
|
49
|
-
//console.log("wallets: ", app?.wallets);
|
|
50
|
-
//
|
|
51
|
-
dispatch({ type: "SET_CONTEXT", payload: context });
|
|
52
|
-
setContext(app?.context);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
console.error(e);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
onRender();
|
|
60
|
-
}, [app, app?.context, app?.wallets]); // once on startup
|
|
61
|
-
return (_jsx(Stack, { spacing: 4, children: _jsx(Box, { children: app?.wallets.map((wallet, index) => (_jsxs(Box, { children: [_jsx(HStack, { spacing: 4, alignItems: "center", children: _jsxs(Box, { children: [_jsxs("small", { children: ["type: ", wallet.type] }), _jsx("br", {}), _jsxs("small", { children: ["context: ", wallet.context] })] }) }), _jsx(HStack, { mt: 2, spacing: 2, children: _jsx(Button, { size: "sm", variant: "outline", onClick: () => handleSelectClick(wallet), children: "Select" }) })] }, index))) }) }));
|
|
62
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Modal, ModalOverlay, ModalContent, ModalHeader, ModalCloseButton, ModalBody, ModalFooter, } from "@chakra-ui/react";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
5
|
-
//@ts-ignore
|
|
6
|
-
const AssetModal = ({ isOpen, onClose }) => {
|
|
7
|
-
const { state, dispatch } = usePioneer();
|
|
8
|
-
const { api, app, user, context } = state;
|
|
9
|
-
const [walletDescriptions, setWalletDescriptions] = useState([]);
|
|
10
|
-
const [balances, setBalances] = useState([]);
|
|
11
|
-
const setUser = async function () {
|
|
12
|
-
try {
|
|
13
|
-
if (user && user.wallets) {
|
|
14
|
-
const { wallets, walletDescriptions, balances, pubkeys } = user;
|
|
15
|
-
setWalletDescriptions(walletDescriptions);
|
|
16
|
-
setBalances(balances);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
console.error("header e: ", e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setUser();
|
|
25
|
-
}, [user]); // once on startup
|
|
26
|
-
return (_jsxs(Modal, { isOpen: isOpen, onClose: onClose, size: "xl", children: [_jsx(ModalOverlay, {}), _jsxs(ModalContent, { children: [_jsx(ModalHeader, { children: "Asset Select" }), _jsx(ModalCloseButton, {}), _jsx(ModalBody, {}), _jsxs(ModalFooter, { children: [_jsx(Button, { colorScheme: "blue", mr: 3, onClick: onClose, children: "Close" }), _jsx(Button, { variant: "ghost", children: "Secondary Action" })] })] })] }));
|
|
27
|
-
};
|
|
28
|
-
export default AssetModal;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
import { Button, Modal, ModalOverlay, ModalContent, ModalHeader, ModalCloseButton, ModalBody, ModalFooter, Tabs, Tab, TabList, TabPanel, TabPanels, } from "@chakra-ui/react";
|
|
4
|
-
import Balances from "lib/components/pioneer/Pioneer/Balances";
|
|
5
|
-
import Wallets from "lib/components/pioneer/Pioneer/Wallets";
|
|
6
|
-
import Pubkeys from "lib/components/pioneer/Pioneer/Pubkeys";
|
|
7
|
-
import Onboarding from "lib/components/Onboarding";
|
|
8
|
-
import { usePioneer } from "lib/context/Pioneer";
|
|
9
|
-
const SettingsModal = ({ isOpen, onClose }) => {
|
|
10
|
-
const { state } = usePioneer();
|
|
11
|
-
const { app, status } = state;
|
|
12
|
-
const [isOnboarded, setIsOnboarded] = useState(false);
|
|
13
|
-
const onStart = async function () {
|
|
14
|
-
try {
|
|
15
|
-
console.log("onStart");
|
|
16
|
-
let isOnboarded = await localStorage.getItem("isOnboarded");
|
|
17
|
-
if (!isOnboarded) {
|
|
18
|
-
console.log("Starting onboarding process");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
console.error(e);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
onStart();
|
|
27
|
-
}, []);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
//console.log("app: ", app);
|
|
30
|
-
}, [app, app?.balances, app?.pubkeys, app?.wallets, app?.paths, status]);
|
|
31
|
-
return (_jsxs(Modal, { isOpen: isOpen, onClose: onClose, size: "xl", children: [_jsx(ModalOverlay, {}), _jsx(ModalContent, { children: !isOnboarded ? (_jsx(Onboarding, { onClose: onClose })) : (_jsxs("div", { children: [_jsx(ModalHeader, { children: "Pioneer Settings" }), _jsx(ModalCloseButton, {}), _jsx(ModalBody, { children: _jsxs(Tabs, { variant: "enclosed", children: [_jsxs(TabList, { children: [_jsx(Tab, { children: "Wallets" }), _jsx(Tab, { children: "Nodes" }), _jsx(Tab, { children: "PubKeys" }), _jsx(Tab, { children: "Balances" })] }), _jsxs(TabPanels, { children: [_jsx(TabPanel, { children: _jsx(Wallets, { wallets: app?.wallets || [] }) }), _jsx(TabPanel, { children: _jsx(Pubkeys, { pubkeys: app?.pubkeys || [] }) }), _jsx(TabPanel, { children: _jsx(Balances, { balances: app?.balances || [] }) })] })] }) }), _jsx(ModalFooter, { children: _jsx(Button, { colorScheme: "blue", mr: 3, onClick: onClose, children: "Close" }) })] })) })] }));
|
|
32
|
-
};
|
|
33
|
-
export default SettingsModal;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { Search2Icon, ChevronUpIcon, ChevronDownIcon } from "@chakra-ui/icons";
|
|
2
|
-
import {
|
|
3
|
-
Avatar,
|
|
4
|
-
Box,
|
|
5
|
-
Button,
|
|
6
|
-
Flex,
|
|
7
|
-
Input,
|
|
8
|
-
InputGroup,
|
|
9
|
-
InputLeftElement,
|
|
10
|
-
Stack,
|
|
11
|
-
Text,
|
|
12
|
-
Checkbox,
|
|
13
|
-
} from "@chakra-ui/react";
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import { COIN_MAP_LONG } from "@pioneer-platform/pioneer-coins";
|
|
16
|
-
import { useEffect, useState } from "react";
|
|
17
|
-
|
|
18
|
-
import { usePioneer } from "../../context/Pioneer";
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line react/prop-types
|
|
21
|
-
export default function AssetSelect({ onClose }: { onClose: () => void }) {
|
|
22
|
-
const { state } = usePioneer();
|
|
23
|
-
const { app, balances } = state;
|
|
24
|
-
const [currentPage, setCurrentPage] = useState([]);
|
|
25
|
-
const [currentPageIndex, setCurrentPageIndex] = useState(0);
|
|
26
|
-
const [showOwnedAssets, setShowOwnedAssets] = useState(false);
|
|
27
|
-
const [totalAssets, setTotalAssets] = useState(0);
|
|
28
|
-
const [search, setSearch] = useState("");
|
|
29
|
-
const [sortOrder, setSortOrder] = useState("desc");
|
|
30
|
-
const itemsPerPage = 6;
|
|
31
|
-
// const cardWidth = useBreakpointValue({ base: "90%", md: "60%", lg: "40%" });
|
|
32
|
-
|
|
33
|
-
const handleSelectClick = async (asset: any) => {
|
|
34
|
-
try {
|
|
35
|
-
app.setAssetContext(asset);
|
|
36
|
-
onClose();
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const handleSearchChange = (event: any) => {
|
|
43
|
-
setSearch(event.target.value);
|
|
44
|
-
setCurrentPageIndex(0);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const toggleSortOrder = () => {
|
|
48
|
-
setSortOrder(sortOrder === "asc" ? "desc" : "asc");
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const filteredAssets = currentPage
|
|
52
|
-
.filter((asset: any) => {
|
|
53
|
-
return (
|
|
54
|
-
(showOwnedAssets ? asset.valueUsd !== null : true) &&
|
|
55
|
-
asset?.name?.toLowerCase().includes(search.toLowerCase()) &&
|
|
56
|
-
(asset.valueUsd ? parseFloat(asset.valueUsd) >= 1 : false)
|
|
57
|
-
);
|
|
58
|
-
})
|
|
59
|
-
.sort((a: any, b: any) => {
|
|
60
|
-
if (sortOrder === "asc") {
|
|
61
|
-
return (a.valueUsd || 0) - (b.valueUsd || 0);
|
|
62
|
-
}
|
|
63
|
-
return (b.valueUsd || 0) - (a.valueUsd || 0);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
setTotalAssets(filteredAssets.length);
|
|
68
|
-
}, [showOwnedAssets, currentPage, search, sortOrder]);
|
|
69
|
-
|
|
70
|
-
const fetchPage = async () => {
|
|
71
|
-
try {
|
|
72
|
-
if (balances) {
|
|
73
|
-
setShowOwnedAssets(true);
|
|
74
|
-
setCurrentPage(balances);
|
|
75
|
-
console.log("balances: ", balances);
|
|
76
|
-
setTotalAssets(balances.length);
|
|
77
|
-
}
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.error(e);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
fetchPage();
|
|
85
|
-
}, [balances]);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Stack spacing={4}>
|
|
89
|
-
<InputGroup>
|
|
90
|
-
<InputLeftElement pointerEvents="none">
|
|
91
|
-
<Search2Icon color="gray.300" />
|
|
92
|
-
</InputLeftElement>
|
|
93
|
-
<Input
|
|
94
|
-
value={search}
|
|
95
|
-
onChange={handleSearchChange}
|
|
96
|
-
placeholder="Bitcoin..."
|
|
97
|
-
type="text"
|
|
98
|
-
/>
|
|
99
|
-
</InputGroup>
|
|
100
|
-
<Box>
|
|
101
|
-
<Text fontSize="2xl">Total Assets: {totalAssets}</Text>
|
|
102
|
-
<Checkbox
|
|
103
|
-
isChecked={showOwnedAssets}
|
|
104
|
-
onChange={() => setShowOwnedAssets(!showOwnedAssets)}
|
|
105
|
-
>
|
|
106
|
-
Show only owned assets
|
|
107
|
-
</Checkbox>
|
|
108
|
-
<Button onClick={toggleSortOrder} size="sm">
|
|
109
|
-
Sort by Value{" "}
|
|
110
|
-
{sortOrder === "asc" ? <ChevronUpIcon /> : <ChevronDownIcon />}
|
|
111
|
-
</Button>
|
|
112
|
-
<br />
|
|
113
|
-
<br />
|
|
114
|
-
{filteredAssets.map((asset: any, index: number) => (
|
|
115
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
116
|
-
<Box key={index}>
|
|
117
|
-
<Flex
|
|
118
|
-
alignItems="center"
|
|
119
|
-
borderRadius="md"
|
|
120
|
-
border="1px solid #fff"
|
|
121
|
-
bg="black"
|
|
122
|
-
boxShadow="sm"
|
|
123
|
-
padding={2}
|
|
124
|
-
>
|
|
125
|
-
<Avatar
|
|
126
|
-
size="md"
|
|
127
|
-
src={`https://pioneers.dev/coins/${
|
|
128
|
-
COIN_MAP_LONG[asset?.chain]
|
|
129
|
-
}.png`}
|
|
130
|
-
/>
|
|
131
|
-
<Box ml={3}>
|
|
132
|
-
<Text fontSize="sm">Asset: {asset?.symbol}</Text>
|
|
133
|
-
<Text fontSize="sm">
|
|
134
|
-
Value USD:{" "}
|
|
135
|
-
{typeof asset?.valueUsd === "string"
|
|
136
|
-
? (+asset.valueUsd).toFixed(2).toLocaleString()
|
|
137
|
-
: ""}
|
|
138
|
-
</Text>
|
|
139
|
-
</Box>
|
|
140
|
-
<Button
|
|
141
|
-
ml="auto"
|
|
142
|
-
onClick={() => handleSelectClick(asset)}
|
|
143
|
-
size="sm"
|
|
144
|
-
variant="outline"
|
|
145
|
-
>
|
|
146
|
-
Select
|
|
147
|
-
</Button>
|
|
148
|
-
</Flex>
|
|
149
|
-
</Box>
|
|
150
|
-
))}
|
|
151
|
-
</Box>
|
|
152
|
-
<Flex justifyContent="space-between" mt={4}>
|
|
153
|
-
<Button
|
|
154
|
-
isDisabled={currentPageIndex === 0}
|
|
155
|
-
onClick={() => setCurrentPageIndex(currentPageIndex - 1)}
|
|
156
|
-
>
|
|
157
|
-
Previous Page
|
|
158
|
-
</Button>
|
|
159
|
-
<Button
|
|
160
|
-
isDisabled={filteredAssets.length < itemsPerPage}
|
|
161
|
-
onClick={() => setCurrentPageIndex(currentPageIndex + 1)}
|
|
162
|
-
>
|
|
163
|
-
Next Page
|
|
164
|
-
</Button>
|
|
165
|
-
</Flex>
|
|
166
|
-
</Stack>
|
|
167
|
-
);
|
|
168
|
-
}
|