@pioneer-platform/pioneer-react 0.0.2 → 0.2.33

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.
Files changed (93) hide show
  1. package/.eslintrc.js +24 -0
  2. package/.github/workflows/release.yml +22 -0
  3. package/.github/workflows/update-license.yml +11 -0
  4. package/.lintstagedrc.json +6 -0
  5. package/.prettierrc +7 -0
  6. package/.vscode/extensions.json +8 -0
  7. package/CHANGELOG.md +5 -0
  8. package/LICENSE +21 -0
  9. package/README.md +40 -0
  10. package/commitlint.config.js +3 -0
  11. package/dist/assets/404 Error-rafiki.svg +1 -0
  12. package/dist/assets/Building blocks-amico.svg +1 -0
  13. package/dist/assets/chakra-ui-logomark-colored.svg +10 -0
  14. package/dist/assets/favicon.svg +0 -0
  15. package/dist/assets/react-icon.svg +7 -0
  16. package/dist/assets/ts-logo-512.svg +1 -0
  17. package/dist/assets/vite-logo.svg +15 -0
  18. package/dist/index.js +384249 -0
  19. package/dist/index_3bde86fb.js +205 -0
  20. package/dist/index_49fce0b0.js +384033 -0
  21. package/dist/index_d01e819c.css +63 -0
  22. package/dist/manifest.json +12 -0
  23. package/dist/robots.txt +6 -0
  24. package/index.html +13 -0
  25. package/netlify.toml +10 -0
  26. package/package.json +70 -10
  27. package/public/assets/404 Error-rafiki.svg +1 -0
  28. package/public/assets/Building blocks-amico.svg +1 -0
  29. package/public/assets/chakra-ui-logomark-colored.svg +10 -0
  30. package/public/assets/favicon.svg +0 -0
  31. package/public/assets/react-icon.svg +7 -0
  32. package/public/assets/ts-logo-512.svg +1 -0
  33. package/public/assets/vite-logo.svg +15 -0
  34. package/public/manifest.json +12 -0
  35. package/public/robots.txt +6 -0
  36. package/renovate.json +11 -0
  37. package/src/App.tsx +21 -0
  38. package/src/index.tsx +41 -0
  39. package/src/lib/assets/Icons/KeepKeyIcon.tsx +13 -0
  40. package/src/lib/assets/Icons/KeplrIcon.tsx +140 -0
  41. package/src/lib/assets/Icons/MetaMaskIcon.tsx +126 -0
  42. package/src/lib/assets/Icons/TallyHoIcon.tsx +17 -0
  43. package/src/lib/assets/Icons/XDEFIIcon.tsx +32 -0
  44. package/src/lib/assets/favicon.ico +0 -0
  45. package/src/lib/assets/png/keepkey.png +0 -0
  46. package/src/lib/assets/png/keplr.png +0 -0
  47. package/src/lib/assets/png/metamask.png +0 -0
  48. package/src/lib/assets/png/pioneer.png +0 -0
  49. package/src/lib/components/AssetSelect/index.tsx +166 -0
  50. package/src/lib/components/BlockchainSelect/index.tsx +166 -0
  51. package/src/lib/components/MiddleEllipsis/index.tsx +27 -0
  52. package/src/lib/components/WalletSelect/index.tsx +112 -0
  53. package/src/lib/components/auth/RequireAuth.tsx +22 -0
  54. package/src/lib/components/modals/AssetModal.tsx +67 -0
  55. package/src/lib/components/modals/SettingsModal.tsx +76 -0
  56. package/src/lib/components/pioneer/Pioneer/Balances.tsx +266 -0
  57. package/src/lib/components/pioneer/Pioneer/MiddleEllipsis.tsx +27 -0
  58. package/src/lib/components/pioneer/Pioneer/Nodes.tsx +0 -0
  59. package/src/lib/components/pioneer/Pioneer/Paths.tsx +290 -0
  60. package/src/lib/components/pioneer/Pioneer/Pubkey.tsx +67 -0
  61. package/src/lib/components/pioneer/Pioneer/Pubkeys.tsx +265 -0
  62. package/src/lib/components/pioneer/Pioneer/Receive.tsx +26 -0
  63. package/src/lib/components/pioneer/Pioneer/Send.tsx +135 -0
  64. package/src/lib/components/pioneer/Pioneer/View.tsx +44 -0
  65. package/src/lib/components/pioneer/Pioneer/Wallets.tsx +166 -0
  66. package/src/lib/components/pioneer/index.tsx +525 -0
  67. package/src/lib/components/utils/index.tsx +47 -0
  68. package/src/lib/context/Pioneer/index.tsx +420 -0
  69. package/src/lib/layout/Footer.tsx +22 -0
  70. package/src/lib/layout/Header.tsx +38 -0
  71. package/src/lib/layout/Meta.tsx +25 -0
  72. package/src/lib/layout/Pioneer/Balances.tsx +290 -0
  73. package/src/lib/layout/Pioneer/MiddleEllipsis.tsx +27 -0
  74. package/src/lib/layout/Pioneer/Pubkey.tsx +67 -0
  75. package/src/lib/layout/Pioneer/Receive.tsx +26 -0
  76. package/src/lib/layout/Pioneer/Send.tsx +135 -0
  77. package/src/lib/layout/Pioneer/View.tsx +44 -0
  78. package/src/lib/layout/Pioneer/Wallets.tsx +166 -0
  79. package/src/lib/layout/ThemeToggle.tsx +16 -0
  80. package/src/lib/layout/index.tsx +29 -0
  81. package/src/lib/pages/404/index.tsx +36 -0
  82. package/src/lib/pages/home/components/CTASection.tsx +36 -0
  83. package/src/lib/pages/home/components/SomeImage.tsx +36 -0
  84. package/src/lib/pages/home/components/SomeText.tsx +16 -0
  85. package/src/lib/pages/home/index.tsx +87 -0
  86. package/src/lib/router/Routings.tsx +45 -0
  87. package/src/lib/router/routes.tsx +13 -0
  88. package/src/lib/styles/theme/config.ts +5 -0
  89. package/src/lib/styles/theme/index.ts +17 -0
  90. package/tsconfig.json +19 -9
  91. package/turbo.json +17 -0
  92. package/vercel.json +4 -0
  93. package/vite.config.ts +110 -0
@@ -0,0 +1,205 @@
1
+ import { u as usePioneer, j as jsxRuntimeExports, S as Search2Icon, M as MiddleEllipsis, W as WalletSelect, A as AssetSelect } from "./index_49fce0b0.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("pubkeyContext: ", pubkeyContext);
161
+ setAddress(pubkeyContext.master || pubkeyContext.pubkey);
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
+ (pubkeyContext == null ? void 0 : pubkeyContext.master) || (pubkeyContext == null ? void 0 : pubkeyContext.pubkey),
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
+ };