@pioneer-platform/pioneer-react 0.2.35 → 0.2.36

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.
@@ -14,15 +14,33 @@ import { usePioneer } from "lib/context/Pioneer";
14
14
  import AssetSelect from "lib/components/AssetSelect";
15
15
  import BlockchainSelect from "lib/components/BlockchainSelect";
16
16
  import WalletSelect from "lib/components/WalletSelect";
17
+ import Onboarding from "lib/components/Onboarding";
17
18
 
18
19
  const Home = () => {
19
20
  const { state } = usePioneer();
20
- const { api, app, context, assetContext, blockchainContext, pubkeyContext } =
21
+ const { api, app, context, assetContext, blockchainContext, pubkeyContext, modals } =
21
22
  state;
22
23
  const [address, setAddress] = useState("");
23
24
  const [modalType, setModalType] = useState("");
24
25
  const { isOpen, onOpen, onClose } = useDisclosure();
25
26
 
27
+ const onStart = async function(){
28
+ try{
29
+ console.log("onStart")
30
+ let isOnboarded = await localStorage.getItem("isOnboarded")
31
+ if(!isOnboarded){
32
+ console.log("Starting onboarding process")
33
+ openModal("Onboarding")
34
+ }
35
+ }catch(e){
36
+ console.error(e)
37
+ }
38
+ }
39
+ useEffect(() => {
40
+ onStart()
41
+ }, []);
42
+
43
+
26
44
  useEffect(() => {
27
45
  console.log("2 pubkeyContext: ", pubkeyContext);
28
46
  setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
@@ -33,6 +51,13 @@ const Home = () => {
33
51
  onOpen();
34
52
  };
35
53
 
54
+ let refresh = async () => {
55
+ //TODO why do I need to press refresh?
56
+ console.log("2 pubkeyContext: ", pubkeyContext);
57
+ setAddress(pubkeyContext.master || pubkeyContext.pubkey || pubkeyContext);
58
+ console.log("assetContext: ",assetContext)
59
+ }
60
+
36
61
  return (
37
62
  <div>
38
63
  <Modal isOpen={isOpen} onClose={() => onClose()} size="xl">
@@ -58,6 +83,16 @@ const Home = () => {
58
83
  </div>
59
84
  )}
60
85
  {modalType === "View Address" && <div>address: {address}</div>}
86
+ {modalType === "Select Outbound" && (
87
+ <div>
88
+ <BlockchainSelect onClose={onClose}></BlockchainSelect>
89
+ </div>
90
+ )}
91
+ {modalType === "Onboarding" && (
92
+ <div>
93
+ <Onboarding onClose={onClose}></Onboarding>
94
+ </div>
95
+ )}
61
96
  </ModalBody>
62
97
  <ModalFooter>
63
98
  <Button colorScheme="blue" onClick={onClose}>
@@ -66,7 +101,7 @@ const Home = () => {
66
101
  </ModalFooter>
67
102
  </ModalContent>
68
103
  </Modal>
69
- Context: {context}
104
+ Wallet Context: {context}
70
105
  <Button onClick={() => openModal("Select wallet")}>Select wallet</Button>
71
106
  <br />
72
107
  Asset Context: {assetContext?.name}
@@ -77,9 +112,13 @@ const Home = () => {
77
112
  Select Blockchain
78
113
  </Button>
79
114
  <br />
80
- Address: {address}
115
+ Address for context: {address}
81
116
  <Button onClick={() => openModal("View Address")}>View Address</Button>
82
117
  <br />
118
+ Outbound asset context: {address}
119
+ <Button onClick={() => openModal("Select Outbound")}>Select asset</Button>
120
+ <br />
121
+ <Button onClick={refresh}>refresh</Button>
83
122
  </div>
84
123
  );
85
124
  };
@@ -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
- };