@xyo-network/react-chain-network 1.0.2
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/LICENSE +165 -0
- package/README.md +13 -0
- package/dist/browser/index.mjs +213 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/components/menu/Icon.d.ts +6 -0
- package/dist/types/components/menu/Icon.d.ts.map +1 -0
- package/dist/types/components/menu/MenuItem.d.ts +10 -0
- package/dist/types/components/menu/MenuItem.d.ts.map +1 -0
- package/dist/types/components/menu/index.d.ts +3 -0
- package/dist/types/components/menu/index.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +2 -0
- package/dist/types/context/index.d.ts.map +1 -0
- package/dist/types/context/network/Provider.d.ts +10 -0
- package/dist/types/context/network/Provider.d.ts.map +1 -0
- package/dist/types/context/network/context.d.ts +3 -0
- package/dist/types/context/network/context.d.ts.map +1 -0
- package/dist/types/context/network/index.d.ts +5 -0
- package/dist/types/context/network/index.d.ts.map +1 -0
- package/dist/types/context/network/state.d.ts +9 -0
- package/dist/types/context/network/state.d.ts.map +1 -0
- package/dist/types/context/network/use.d.ts +2 -0
- package/dist/types/context/network/use.d.ts.map +1 -0
- package/dist/types/helpers/Networks.d.ts +5 -0
- package/dist/types/helpers/Networks.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +2 -0
- package/dist/types/helpers/index.d.ts.map +1 -0
- package/dist/types/images/icons/LocalNetwork.d.ts +5 -0
- package/dist/types/images/icons/LocalNetwork.d.ts.map +1 -0
- package/dist/types/images/icons/index.d.ts +3 -0
- package/dist/types/images/icons/index.d.ts.map +1 -0
- package/dist/types/images/icons/xyoColorLogo.d.ts +5 -0
- package/dist/types/images/icons/xyoColorLogo.d.ts.map +1 -0
- package/dist/types/images/index.d.ts +2 -0
- package/dist/types/images/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/models/Bootstrap.d.ts +40 -0
- package/dist/types/models/Bootstrap.d.ts.map +1 -0
- package/dist/types/models/index.d.ts +2 -0
- package/dist/types/models/index.d.ts.map +1 -0
- package/eslint.config.mjs +1 -0
- package/package.json +82 -0
- package/src/components/index.ts +1 -0
- package/src/components/menu/Icon.tsx +19 -0
- package/src/components/menu/MenuItem.tsx +37 -0
- package/src/components/menu/index.ts +2 -0
- package/src/context/index.ts +1 -0
- package/src/context/network/Provider.tsx +67 -0
- package/src/context/network/context.ts +5 -0
- package/src/context/network/index.ts +4 -0
- package/src/context/network/state.ts +10 -0
- package/src/context/network/use.ts +5 -0
- package/src/helpers/Networks.ts +33 -0
- package/src/helpers/index.ts +1 -0
- package/src/images/icons/LocalNetwork.tsx +16 -0
- package/src/images/icons/index.ts +2 -0
- package/src/images/icons/xyoColorLogo.tsx +54 -0
- package/src/images/index.ts +1 -0
- package/src/index.ts +4 -0
- package/src/models/Bootstrap.ts +49 -0
- package/src/models/index.ts +1 -0
- package/src/types/images.d.ts +5 -0
- package/typedoc.json +5 -0
- package/xy.config.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[![logo][]](https://xyo.network)
|
|
2
|
+
|
|
3
|
+
Part of [@xyo-network/sdk-xyo-react](https://www.npmjs.com/package/@xyo-network/sdk-xyo-react)
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
> See the [LICENSE](LICENSE) file for license details
|
|
8
|
+
|
|
9
|
+
## Credits
|
|
10
|
+
|
|
11
|
+
[Made with 🔥 and ❄️ by XYO](https://xyo.network)
|
|
12
|
+
|
|
13
|
+
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/components/menu/Icon.tsx
|
|
5
|
+
import { Icon } from "@mui/material";
|
|
6
|
+
import React from "react";
|
|
7
|
+
var NetworkIcon = /* @__PURE__ */ __name(({ icon, ...props }) => {
|
|
8
|
+
return /* @__PURE__ */ React.createElement(Icon, {
|
|
9
|
+
sx: {
|
|
10
|
+
display: "inline-flex",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center"
|
|
13
|
+
},
|
|
14
|
+
ref: /* @__PURE__ */ __name((ref) => {
|
|
15
|
+
if (ref && icon) {
|
|
16
|
+
ref.innerHTML = icon;
|
|
17
|
+
}
|
|
18
|
+
}, "ref"),
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
}, "NetworkIcon");
|
|
22
|
+
|
|
23
|
+
// src/components/menu/MenuItem.tsx
|
|
24
|
+
import { ListItemText } from "@mui/material";
|
|
25
|
+
import { ActiveMenuItem } from "@xyo-network/react-chain-shared";
|
|
26
|
+
import React2 from "react";
|
|
27
|
+
var NetworkMenuItem = /* @__PURE__ */ __name(({ active, network, onClick, updateActiveNetwork, ...props }) => {
|
|
28
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
29
|
+
if (network === void 0) throw new Error("Network is undefined");
|
|
30
|
+
updateActiveNetwork?.(network.id);
|
|
31
|
+
onClick?.(event);
|
|
32
|
+
}, "handleClick");
|
|
33
|
+
return /* @__PURE__ */ React2.createElement(ActiveMenuItem, {
|
|
34
|
+
title: network?.name,
|
|
35
|
+
disableRipple: true,
|
|
36
|
+
onClick: handleClick,
|
|
37
|
+
active,
|
|
38
|
+
...props
|
|
39
|
+
}, /* @__PURE__ */ React2.createElement(NetworkIcon, {
|
|
40
|
+
icon: network?.icon
|
|
41
|
+
}), /* @__PURE__ */ React2.createElement(ListItemText, null, network?.name));
|
|
42
|
+
}, "NetworkMenuItem");
|
|
43
|
+
|
|
44
|
+
// src/context/network/context.ts
|
|
45
|
+
import { createContextEx } from "@xylabs/react-shared";
|
|
46
|
+
var ChainNetworkContext = createContextEx();
|
|
47
|
+
|
|
48
|
+
// src/context/network/Provider.tsx
|
|
49
|
+
import { ErrorRender } from "@xylabs/react-error";
|
|
50
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
51
|
+
import React5, { useCallback, useMemo, useState } from "react";
|
|
52
|
+
|
|
53
|
+
// src/images/icons/LocalNetwork.tsx
|
|
54
|
+
import { createSvgIcon } from "@mui/material";
|
|
55
|
+
import React3 from "react";
|
|
56
|
+
var LocalNetworkIcon = createSvgIcon(/* @__PURE__ */ React3.createElement("svg", {
|
|
57
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
58
|
+
viewBox: "0 -960 960 960"
|
|
59
|
+
}, /* @__PURE__ */ React3.createElement("path", {
|
|
60
|
+
fill: "currentColor",
|
|
61
|
+
d: "M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z"
|
|
62
|
+
})), "LocalNetworkIcon");
|
|
63
|
+
var LocalNetworkIconString = `
|
|
64
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 -960 960 960">
|
|
65
|
+
<path fill="currentColor" d="M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z" />
|
|
66
|
+
</svg>
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
// src/images/icons/xyoColorLogo.tsx
|
|
70
|
+
import { createSvgIcon as createSvgIcon2 } from "@mui/material";
|
|
71
|
+
import React4 from "react";
|
|
72
|
+
var XyoColorLogo = createSvgIcon2(/* @__PURE__ */ React4.createElement("svg", {
|
|
73
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
+
viewBox: "0 0 256 238"
|
|
75
|
+
}, /* @__PURE__ */ React4.createElement("path", {
|
|
76
|
+
className: "cls-1",
|
|
77
|
+
d: "M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z",
|
|
78
|
+
fill: "#8d8fc6"
|
|
79
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
80
|
+
className: "cls-2",
|
|
81
|
+
d: "M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z",
|
|
82
|
+
fill: "#579fd6"
|
|
83
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
84
|
+
className: "cls-3",
|
|
85
|
+
d: "M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z",
|
|
86
|
+
fill: "#f27046"
|
|
87
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
88
|
+
className: "cls-4",
|
|
89
|
+
d: "M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z",
|
|
90
|
+
fill: "#eb407a"
|
|
91
|
+
})), "XyoColorLogo");
|
|
92
|
+
var XyoColorLogoString = `
|
|
93
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 238">
|
|
94
|
+
<path
|
|
95
|
+
className="cls-1"
|
|
96
|
+
d="M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z"
|
|
97
|
+
fill="#8d8fc6"
|
|
98
|
+
/>
|
|
99
|
+
<path
|
|
100
|
+
className="cls-2"
|
|
101
|
+
d="M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z"
|
|
102
|
+
fill="#579fd6"
|
|
103
|
+
/>
|
|
104
|
+
<path
|
|
105
|
+
className="cls-3"
|
|
106
|
+
d="M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z"
|
|
107
|
+
fill="#f27046"
|
|
108
|
+
/>
|
|
109
|
+
<path
|
|
110
|
+
className="cls-4"
|
|
111
|
+
d="M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z"
|
|
112
|
+
fill="#eb407a"
|
|
113
|
+
/>
|
|
114
|
+
</svg>
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
// src/models/Bootstrap.ts
|
|
118
|
+
import { AsObjectFactory } from "@xylabs/object";
|
|
119
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
120
|
+
var NetworkBootstrapSchema = "network.xyo.network.bootstrap";
|
|
121
|
+
var isNetworkBootstrap = isPayloadOfSchemaType(NetworkBootstrapSchema);
|
|
122
|
+
var asOptionalNetwork = AsObjectFactory.createOptional(isNetworkBootstrap);
|
|
123
|
+
|
|
124
|
+
// src/helpers/Networks.ts
|
|
125
|
+
var MainNetwork = {
|
|
126
|
+
description: "Main Node for the XYO Network",
|
|
127
|
+
icon: XyoColorLogoString,
|
|
128
|
+
id: "mainnet",
|
|
129
|
+
name: "Mainnet",
|
|
130
|
+
schema: NetworkBootstrapSchema,
|
|
131
|
+
symbol: "XYOG",
|
|
132
|
+
url: "https://api.chain.xyo.network"
|
|
133
|
+
};
|
|
134
|
+
var KerplunkNetwork = {
|
|
135
|
+
description: "Test Node for the XYO Network",
|
|
136
|
+
icon: XyoColorLogoString,
|
|
137
|
+
id: "testnet",
|
|
138
|
+
name: "Testnet",
|
|
139
|
+
schema: NetworkBootstrapSchema,
|
|
140
|
+
symbol: "XYOG",
|
|
141
|
+
url: "https://beta.api.chain.xyo.network/"
|
|
142
|
+
};
|
|
143
|
+
var LocalNetwork = {
|
|
144
|
+
description: "Local Node",
|
|
145
|
+
icon: LocalNetworkIconString,
|
|
146
|
+
id: "local",
|
|
147
|
+
name: "Local",
|
|
148
|
+
schema: NetworkBootstrapSchema,
|
|
149
|
+
symbol: "XYOG",
|
|
150
|
+
url: "http://localhost:8080"
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/context/network/Provider.tsx
|
|
154
|
+
var ChainNetworkProvider = /* @__PURE__ */ __name(({ children, getActiveNetwork, networks, setActiveNetwork: setActiveNetworkExternal }) => {
|
|
155
|
+
const [activeNetwork, setActiveNetwork] = useState();
|
|
156
|
+
const [error, setError] = useState();
|
|
157
|
+
const [, activeNetworkError] = usePromise(async () => {
|
|
158
|
+
if (!networks) return;
|
|
159
|
+
const activeNetwork2 = await getActiveNetwork?.();
|
|
160
|
+
if (activeNetwork2) {
|
|
161
|
+
setActiveNetwork(activeNetwork2);
|
|
162
|
+
} else {
|
|
163
|
+
const defaultNetwork = networks.find((network) => network.id === MainNetwork.id) ?? networks[0];
|
|
164
|
+
await setActiveNetworkExternal?.(defaultNetwork.id);
|
|
165
|
+
setActiveNetwork(defaultNetwork);
|
|
166
|
+
}
|
|
167
|
+
}, [
|
|
168
|
+
networks
|
|
169
|
+
]);
|
|
170
|
+
const updateActiveNetwork = useCallback((networkId) => {
|
|
171
|
+
setError(void 0);
|
|
172
|
+
const network = networks?.find((network2) => network2.id === networkId);
|
|
173
|
+
setActiveNetwork(network);
|
|
174
|
+
void setActiveNetworkExternal?.(networkId);
|
|
175
|
+
}, [
|
|
176
|
+
networks
|
|
177
|
+
]);
|
|
178
|
+
const value = useMemo(() => ({
|
|
179
|
+
activeNetwork,
|
|
180
|
+
networks,
|
|
181
|
+
provided: true,
|
|
182
|
+
updateActiveNetwork,
|
|
183
|
+
walletNetworkError: error ?? activeNetworkError
|
|
184
|
+
}), [
|
|
185
|
+
activeNetwork,
|
|
186
|
+
networks,
|
|
187
|
+
updateActiveNetwork
|
|
188
|
+
]);
|
|
189
|
+
return /* @__PURE__ */ React5.createElement(ChainNetworkContext, {
|
|
190
|
+
value
|
|
191
|
+
}, /* @__PURE__ */ React5.createElement(ErrorRender, {
|
|
192
|
+
error: error ?? activeNetworkError,
|
|
193
|
+
scope: "WalletNetworkProvider"
|
|
194
|
+
}), children);
|
|
195
|
+
}, "ChainNetworkProvider");
|
|
196
|
+
|
|
197
|
+
// src/context/network/use.ts
|
|
198
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
199
|
+
var useChainNetwork = /* @__PURE__ */ __name((required = true) => useContextEx(ChainNetworkContext, "WalletNetwork", required), "useChainNetwork");
|
|
200
|
+
export {
|
|
201
|
+
ChainNetworkContext,
|
|
202
|
+
ChainNetworkProvider,
|
|
203
|
+
KerplunkNetwork,
|
|
204
|
+
LocalNetwork,
|
|
205
|
+
MainNetwork,
|
|
206
|
+
NetworkBootstrapSchema,
|
|
207
|
+
NetworkIcon,
|
|
208
|
+
NetworkMenuItem,
|
|
209
|
+
asOptionalNetwork,
|
|
210
|
+
isNetworkBootstrap,
|
|
211
|
+
useChainNetwork
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/menu/Icon.tsx","../../src/components/menu/MenuItem.tsx","../../src/context/network/context.ts","../../src/context/network/Provider.tsx","../../src/images/icons/LocalNetwork.tsx","../../src/images/icons/xyoColorLogo.tsx","../../src/models/Bootstrap.ts","../../src/helpers/Networks.ts","../../src/context/network/use.ts"],"sourcesContent":["import type { IconProps } from '@mui/material'\nimport { Icon } from '@mui/material'\nimport React from 'react'\n\nexport const NetworkIcon: React.FC<IconProps & { icon?: string }> = ({ icon, ...props }) => {\n return (\n <Icon\n sx={{\n display: 'inline-flex', alignItems: 'center', justifyContent: 'center',\n }}\n ref={(ref) => {\n if (ref && icon) {\n ref.innerHTML = icon\n }\n }}\n {...props}\n />\n )\n}\n","import type { MenuItemProps } from '@mui/material'\nimport { ListItemText } from '@mui/material'\nimport { ActiveMenuItem } from '@xyo-network/react-chain-shared'\nimport type { MouseEvent as ReactMouseEvent } from 'react'\nimport React from 'react'\n\nimport type { NetworkBootstrap } from '../../models/index.ts'\nimport { NetworkIcon } from './Icon.tsx'\n\nexport interface NetworkMenuItemProps extends MenuItemProps {\n active?: boolean\n network?: NetworkBootstrap\n updateActiveNetwork?: (networkId: string) => void\n}\n\nexport const NetworkMenuItem: React.FC<NetworkMenuItemProps> = ({\n active, network, onClick, updateActiveNetwork, ...props\n}) => {\n const handleClick = (event: ReactMouseEvent<HTMLLIElement, MouseEvent>) => {\n if (network === undefined) throw new Error('Network is undefined')\n updateActiveNetwork?.(network.id)\n onClick?.(event)\n }\n\n return (\n <ActiveMenuItem\n title={network?.name}\n disableRipple\n onClick={handleClick}\n active={active}\n {...props}\n >\n <NetworkIcon icon={network?.icon} />\n <ListItemText>{network?.name}</ListItemText>\n </ActiveMenuItem>\n )\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { ChainNetworkState } from './state.ts'\n\nexport const ChainNetworkContext = createContextEx<ChainNetworkState>()\n","import { ErrorRender } from '@xylabs/react-error'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useCallback, useMemo, useState,\n} from 'react'\n\nimport { MainNetwork } from '../../helpers/index.ts'\nimport type { NetworkBootstrap } from '../../models/index.ts'\nimport { ChainNetworkContext } from './context.ts'\nimport type { ChainNetworkState } from './state.ts'\n\nexport interface ChainNetworkProviderProps extends PropsWithChildren {\n getActiveNetwork?: () => Promise<NetworkBootstrap | undefined>\n networks?: NetworkBootstrap[]\n setActiveNetwork?: (networkId: NetworkBootstrap['id']) => Promise<NetworkBootstrap>\n}\n\nexport const ChainNetworkProvider: React.FC<ChainNetworkProviderProps> = ({\n children, getActiveNetwork, networks, setActiveNetwork: setActiveNetworkExternal,\n}) => {\n const [activeNetwork, setActiveNetwork] = useState<NetworkBootstrap>()\n const [error, setError] = useState<Error>()\n\n // Set the active network upon initialization\n const [, activeNetworkError] = usePromise(async () => {\n // ensure networks are loaded\n if (!networks) return\n // get last saved active network\n const activeNetwork = await getActiveNetwork?.()\n if (activeNetwork) {\n // Set the active network if it exists\n setActiveNetwork(activeNetwork)\n } else {\n // Set the default network if no active network exists\n const defaultNetwork = networks.find(network => network.id === MainNetwork.id) ?? networks[0]\n await setActiveNetworkExternal?.(defaultNetwork.id)\n\n // Set the active network in the context\n setActiveNetwork(defaultNetwork)\n }\n }, [networks])\n\n const updateActiveNetwork = useCallback((networkId: NetworkBootstrap['id']) => {\n setError(undefined)\n const network = networks?.find(network => network.id === networkId)\n // set internally\n setActiveNetwork(network)\n // set externally\n void setActiveNetworkExternal?.(networkId)\n }, [networks])\n\n const value = useMemo<ChainNetworkState>(() => ({\n activeNetwork,\n networks,\n provided: true,\n updateActiveNetwork,\n walletNetworkError: error ?? activeNetworkError,\n }), [activeNetwork, networks, updateActiveNetwork])\n\n return (\n <ChainNetworkContext value={value}>\n <ErrorRender error={error ?? activeNetworkError} scope=\"WalletNetworkProvider\" />\n {children}\n </ChainNetworkContext>\n )\n}\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const LocalNetworkIcon = createSvgIcon(\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\">\n <path fill=\"currentColor\" d=\"M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z\" />\n </svg>,\n 'LocalNetworkIcon',\n)\n\nexport const LocalNetworkIconString = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"18\" width=\"18\" viewBox=\"0 -960 960 960\">\n <path fill=\"currentColor\" d=\"M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z\" />\n </svg>\n`\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const XyoColorLogo = createSvgIcon(\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 238\">\n <path\n className=\"cls-1\"\n d=\"M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z\"\n fill=\"#8d8fc6\"\n />\n <path\n className=\"cls-2\"\n d=\"M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z\"\n fill=\"#579fd6\"\n />\n <path\n className=\"cls-3\"\n d=\"M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z\"\n fill=\"#f27046\"\n />\n <path\n className=\"cls-4\"\n d=\"M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z\"\n fill=\"#eb407a\"\n />\n </svg>,\n 'XyoColorLogo',\n)\n\nexport const XyoColorLogoString = `\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 238\">\n <path\n className=\"cls-1\"\n d=\"M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z\"\n fill=\"#8d8fc6\"\n />\n <path\n className=\"cls-2\"\n d=\"M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z\"\n fill=\"#579fd6\"\n />\n <path\n className=\"cls-3\"\n d=\"M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z\"\n fill=\"#f27046\"\n />\n <path\n className=\"cls-4\"\n d=\"M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z\"\n fill=\"#eb407a\"\n />\n </svg>\n`\n","import type { Address } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type { ChainInformation } from '@xyo-network/chain-model'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\nexport const NetworkBootstrapSchema = 'network.xyo.network.bootstrap' as const\nexport type NetworkBootstrapSchema = typeof NetworkBootstrapSchema\n\nexport interface ChainForkFields {\n /** Block Number at which the chain was forked from */\n forkedAtLastBlockNumber?: string\n /** Hash in the last block the chain was forked from */\n forkedAtLastHash?: string\n /** Address of the forked chain */\n forkedChainId?: Address\n}\n\nexport interface NetworkFields {\n /** Description of the network */\n description: string\n /** string representation of the icon (svg) */\n icon?: string\n /** Machine-readable identifier */\n id: string\n /** Human-readable identifier */\n name: string\n schema: NetworkBootstrapSchema\n /** Symbol of the network */\n symbol?: string\n /** Url for accessing the network */\n url: string\n}\n\n/** Note: Optional Properties can be found walking the chain to the genesis block */\nexport interface NetworkBootstrapFields extends NetworkFields, ChainForkFields {\n /** Address of the chain, i.e. smart contract address */\n chainInfo?: ChainInformation\n}\n\nexport interface Network extends NetworkBootstrap {\n custom: boolean\n}\n\nexport type NetworkBootstrap = Payload<NetworkBootstrapFields, NetworkBootstrapSchema>\n\nexport const isNetworkBootstrap = isPayloadOfSchemaType<NetworkBootstrap>(NetworkBootstrapSchema)\n\nexport const asOptionalNetwork = AsObjectFactory.createOptional(isNetworkBootstrap)\n","import { LocalNetworkIconString, XyoColorLogoString } from '../images/index.ts'\nimport type { NetworkBootstrap } from '../models/index.ts'\nimport { NetworkBootstrapSchema } from '../models/index.ts'\n\nexport const MainNetwork: NetworkBootstrap = {\n description: 'Main Node for the XYO Network',\n icon: XyoColorLogoString,\n id: 'mainnet',\n name: 'Mainnet',\n schema: NetworkBootstrapSchema,\n symbol: 'XYOG',\n url: 'https://api.chain.xyo.network',\n}\n\nexport const KerplunkNetwork: NetworkBootstrap = {\n description: 'Test Node for the XYO Network',\n icon: XyoColorLogoString,\n id: 'testnet',\n name: 'Testnet',\n schema: NetworkBootstrapSchema,\n symbol: 'XYOG',\n url: 'https://beta.api.chain.xyo.network/',\n}\n\nexport const LocalNetwork: NetworkBootstrap = {\n description: 'Local Node',\n icon: LocalNetworkIconString,\n id: 'local',\n name: 'Local',\n schema: NetworkBootstrapSchema,\n symbol: 'XYOG',\n url: 'http://localhost:8080',\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { ChainNetworkContext } from './context.ts'\n\nexport const useChainNetwork = (required = true) => useContextEx(ChainNetworkContext, 'WalletNetwork', required)\n"],"mappings":"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","names":["Icon","React","NetworkIcon","icon","props","Icon","sx","display","alignItems","justifyContent","ref","innerHTML","ListItemText","ActiveMenuItem","React","NetworkMenuItem","active","network","onClick","updateActiveNetwork","props","handleClick","event","undefined","Error","id","React","ActiveMenuItem","title","name","disableRipple","NetworkIcon","icon","ListItemText","createContextEx","ChainNetworkContext","ErrorRender","usePromise","React","useCallback","useMemo","useState","createSvgIcon","React","LocalNetworkIcon","svg","xmlns","viewBox","path","fill","d","LocalNetworkIconString","createSvgIcon","React","XyoColorLogo","svg","xmlns","viewBox","path","className","d","fill","XyoColorLogoString","AsObjectFactory","isPayloadOfSchemaType","NetworkBootstrapSchema","isNetworkBootstrap","asOptionalNetwork","createOptional","MainNetwork","description","icon","XyoColorLogoString","id","name","schema","NetworkBootstrapSchema","symbol","url","KerplunkNetwork","LocalNetwork","LocalNetworkIconString","ChainNetworkProvider","children","getActiveNetwork","networks","setActiveNetwork","setActiveNetworkExternal","activeNetwork","useState","error","setError","activeNetworkError","usePromise","defaultNetwork","find","network","id","MainNetwork","updateActiveNetwork","useCallback","networkId","undefined","value","useMemo","provided","walletNetworkError","React","ChainNetworkContext","ErrorRender","scope","useContextEx","useChainNetwork","required","useContextEx","ChainNetworkContext"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAc/D,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MenuItemProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { NetworkBootstrap } from '../../models/index.ts';
|
|
4
|
+
export interface NetworkMenuItemProps extends MenuItemProps {
|
|
5
|
+
active?: boolean;
|
|
6
|
+
network?: NetworkBootstrap;
|
|
7
|
+
updateActiveNetwork?: (networkId: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const NetworkMenuItem: React.FC<NetworkMenuItemProps>;
|
|
10
|
+
//# sourceMappingURL=MenuItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/MenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIlD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;CAClD;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqB1D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/menu/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { NetworkBootstrap } from '../../models/index.ts';
|
|
4
|
+
export interface ChainNetworkProviderProps extends PropsWithChildren {
|
|
5
|
+
getActiveNetwork?: () => Promise<NetworkBootstrap | undefined>;
|
|
6
|
+
networks?: NetworkBootstrap[];
|
|
7
|
+
setActiveNetwork?: (networkId: NetworkBootstrap['id']) => Promise<NetworkBootstrap>;
|
|
8
|
+
}
|
|
9
|
+
export declare const ChainNetworkProvider: React.FC<ChainNetworkProviderProps>;
|
|
10
|
+
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/context/network/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAEN,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAI7D,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAA;IAC9D,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;CACpF;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgDpE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/context/network/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,eAAO,MAAM,mBAAmB,4FAAuC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/context/network/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContextExState } from '@xyo-network/react-shared';
|
|
2
|
+
import type { NetworkBootstrap } from '../../models/index.ts';
|
|
3
|
+
export interface ChainNetworkState extends ContextExState {
|
|
4
|
+
activeNetwork?: NetworkBootstrap;
|
|
5
|
+
networks?: NetworkBootstrap[];
|
|
6
|
+
updateActiveNetwork?: (networkId: NetworkBootstrap['id']) => void;
|
|
7
|
+
walletNetworkError?: Error;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/context/network/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACvD,aAAa,CAAC,EAAE,gBAAgB,CAAA;IAChC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC7B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAA;IACjE,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../../src/context/network/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,GAAI,kBAAe,6GAAiE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Networks.d.ts","sourceRoot":"","sources":["../../../src/helpers/Networks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,eAAO,MAAM,WAAW,EAAE,gBAQzB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,gBAQ7B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,gBAQ1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const LocalNetworkIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
2
|
+
muiName: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const LocalNetworkIconString = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"18\" width=\"18\" viewBox=\"0 -960 960 960\">\n <path fill=\"currentColor\" d=\"M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z\" />\n </svg>\n";
|
|
5
|
+
//# sourceMappingURL=LocalNetwork.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalNetwork.d.ts","sourceRoot":"","sources":["../../../../src/images/icons/LocalNetwork.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB;;CAK5B,CAAA;AAED,eAAO,MAAM,sBAAsB,iVAIlC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/images/icons/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const XyoColorLogo: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
2
|
+
muiName: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const XyoColorLogoString = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 238\">\n <path\n className=\"cls-1\"\n d=\"M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z\"\n fill=\"#8d8fc6\"\n />\n <path\n className=\"cls-2\"\n d=\"M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z\"\n fill=\"#579fd6\"\n />\n <path\n className=\"cls-3\"\n d=\"M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z\"\n fill=\"#f27046\"\n />\n <path\n className=\"cls-4\"\n d=\"M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z\"\n fill=\"#eb407a\"\n />\n </svg>\n";
|
|
5
|
+
//# sourceMappingURL=xyoColorLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xyoColorLogo.d.ts","sourceRoot":"","sources":["../../../../src/images/icons/xyoColorLogo.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;CAwBxB,CAAA;AAED,eAAO,MAAM,kBAAkB,0oDAuB9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/images/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex';
|
|
2
|
+
import type { ChainInformation } from '@xyo-network/chain-model';
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model';
|
|
4
|
+
export declare const NetworkBootstrapSchema: "network.xyo.network.bootstrap";
|
|
5
|
+
export type NetworkBootstrapSchema = typeof NetworkBootstrapSchema;
|
|
6
|
+
export interface ChainForkFields {
|
|
7
|
+
/** Block Number at which the chain was forked from */
|
|
8
|
+
forkedAtLastBlockNumber?: string;
|
|
9
|
+
/** Hash in the last block the chain was forked from */
|
|
10
|
+
forkedAtLastHash?: string;
|
|
11
|
+
/** Address of the forked chain */
|
|
12
|
+
forkedChainId?: Address;
|
|
13
|
+
}
|
|
14
|
+
export interface NetworkFields {
|
|
15
|
+
/** Description of the network */
|
|
16
|
+
description: string;
|
|
17
|
+
/** string representation of the icon (svg) */
|
|
18
|
+
icon?: string;
|
|
19
|
+
/** Machine-readable identifier */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Human-readable identifier */
|
|
22
|
+
name: string;
|
|
23
|
+
schema: NetworkBootstrapSchema;
|
|
24
|
+
/** Symbol of the network */
|
|
25
|
+
symbol?: string;
|
|
26
|
+
/** Url for accessing the network */
|
|
27
|
+
url: string;
|
|
28
|
+
}
|
|
29
|
+
/** Note: Optional Properties can be found walking the chain to the genesis block */
|
|
30
|
+
export interface NetworkBootstrapFields extends NetworkFields, ChainForkFields {
|
|
31
|
+
/** Address of the chain, i.e. smart contract address */
|
|
32
|
+
chainInfo?: ChainInformation;
|
|
33
|
+
}
|
|
34
|
+
export interface Network extends NetworkBootstrap {
|
|
35
|
+
custom: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type NetworkBootstrap = Payload<NetworkBootstrapFields, NetworkBootstrapSchema>;
|
|
38
|
+
export declare const isNetworkBootstrap: (x?: unknown | null) => x is NetworkBootstrap;
|
|
39
|
+
export declare const asOptionalNetwork: <TType extends NetworkBootstrap>(value: import("@xylabs/promise").AnyNonPromise) => TType | undefined;
|
|
40
|
+
//# sourceMappingURL=Bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bootstrap.d.ts","sourceRoot":"","sources":["../../../src/models/Bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAGzD,eAAO,MAAM,sBAAsB,EAAG,+BAAwC,CAAA;AAC9E,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAA;AAElE,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kCAAkC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,sBAAsB,CAAA;IAC9B,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,oFAAoF;AACpF,MAAM,WAAW,sBAAuB,SAAQ,aAAa,EAAE,eAAe;IAC5E,wDAAwD;IACxD,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B;AAED,MAAM,WAAW,OAAQ,SAAQ,gBAAgB;IAC/C,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAA;AAEtF,eAAO,MAAM,kBAAkB,+CAAkE,CAAA;AAEjG,eAAO,MAAM,iBAAiB,iDAlCF,iBACrB,qCAiC4E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { config as default } from '@xylabs/eslint-config-flat'
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@xyo-network/react-chain-network",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"description": "XYO Layer One React SDK",
|
|
6
|
+
"homepage": "https://xylabs.com",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "git+https://github.com/xylabs/xyo-chain/issues",
|
|
9
|
+
"email": "support@xylabs.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/xylabs/xyo-chain.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "LGPL-3.0-only",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "XY Labs Development Team",
|
|
18
|
+
"email": "support@xylabs.com",
|
|
19
|
+
"url": "https://xylabs.com"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"browser": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"default": "./dist/browser/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"default": "./dist/browser/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"module": "dist/browser/index.mjs",
|
|
35
|
+
"types": "dist/types/index.d.ts",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build-storybook": "storybook build",
|
|
38
|
+
"start": "storybook dev -p 6006"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@xylabs/array": "^4.6.4",
|
|
42
|
+
"@xylabs/eslint-config-flat": "^6.1.4",
|
|
43
|
+
"@xylabs/hex": "^4.6.4",
|
|
44
|
+
"@xylabs/promise": "^4.6.4",
|
|
45
|
+
"@xylabs/react-error": "^6.0.7",
|
|
46
|
+
"@xylabs/react-promise": "^6.0.7",
|
|
47
|
+
"@xylabs/react-shared": "^6.0.7",
|
|
48
|
+
"@xyo-network/chain-model": "^1.0.2",
|
|
49
|
+
"@xyo-network/payload-model": "^3.9.38"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@emotion/react": "^11.14.0",
|
|
53
|
+
"@emotion/styled": "^11.14.0",
|
|
54
|
+
"@mui/icons-material": "^6.4.7",
|
|
55
|
+
"@mui/material": "^6.4.7",
|
|
56
|
+
"@mui/styles": "^6.4.7",
|
|
57
|
+
"@xylabs/ts-scripts-yarn3": "^6.0.9",
|
|
58
|
+
"@xylabs/tsconfig-react": "^6.0.9",
|
|
59
|
+
"eslint": "^9.22.0",
|
|
60
|
+
"ethers": "^6.13.5",
|
|
61
|
+
"react": "^19.0.0",
|
|
62
|
+
"react-dom": "^19.0.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@emotion/react": "^11",
|
|
66
|
+
"@emotion/styled": "^11",
|
|
67
|
+
"@mui/icons-material": "^6",
|
|
68
|
+
"@mui/material": "^6",
|
|
69
|
+
"@mui/styles": "^6",
|
|
70
|
+
"ethers": "^6",
|
|
71
|
+
"react": "^19",
|
|
72
|
+
"react-dom": "^19"
|
|
73
|
+
},
|
|
74
|
+
"volta": {
|
|
75
|
+
"node": "22.3.0",
|
|
76
|
+
"yarn": "4.6.0"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "restricted"
|
|
80
|
+
},
|
|
81
|
+
"docs": "dist/docs.json"
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './menu/index.ts'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IconProps } from '@mui/material'
|
|
2
|
+
import { Icon } from '@mui/material'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
export const NetworkIcon: React.FC<IconProps & { icon?: string }> = ({ icon, ...props }) => {
|
|
6
|
+
return (
|
|
7
|
+
<Icon
|
|
8
|
+
sx={{
|
|
9
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
10
|
+
}}
|
|
11
|
+
ref={(ref) => {
|
|
12
|
+
if (ref && icon) {
|
|
13
|
+
ref.innerHTML = icon
|
|
14
|
+
}
|
|
15
|
+
}}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MenuItemProps } from '@mui/material'
|
|
2
|
+
import { ListItemText } from '@mui/material'
|
|
3
|
+
import { ActiveMenuItem } from '@xyo-network/react-chain-shared'
|
|
4
|
+
import type { MouseEvent as ReactMouseEvent } from 'react'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
|
|
7
|
+
import type { NetworkBootstrap } from '../../models/index.ts'
|
|
8
|
+
import { NetworkIcon } from './Icon.tsx'
|
|
9
|
+
|
|
10
|
+
export interface NetworkMenuItemProps extends MenuItemProps {
|
|
11
|
+
active?: boolean
|
|
12
|
+
network?: NetworkBootstrap
|
|
13
|
+
updateActiveNetwork?: (networkId: string) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const NetworkMenuItem: React.FC<NetworkMenuItemProps> = ({
|
|
17
|
+
active, network, onClick, updateActiveNetwork, ...props
|
|
18
|
+
}) => {
|
|
19
|
+
const handleClick = (event: ReactMouseEvent<HTMLLIElement, MouseEvent>) => {
|
|
20
|
+
if (network === undefined) throw new Error('Network is undefined')
|
|
21
|
+
updateActiveNetwork?.(network.id)
|
|
22
|
+
onClick?.(event)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ActiveMenuItem
|
|
27
|
+
title={network?.name}
|
|
28
|
+
disableRipple
|
|
29
|
+
onClick={handleClick}
|
|
30
|
+
active={active}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
<NetworkIcon icon={network?.icon} />
|
|
34
|
+
<ListItemText>{network?.name}</ListItemText>
|
|
35
|
+
</ActiveMenuItem>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './network/index.ts'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ErrorRender } from '@xylabs/react-error'
|
|
2
|
+
import { usePromise } from '@xylabs/react-promise'
|
|
3
|
+
import type { PropsWithChildren } from 'react'
|
|
4
|
+
import React, {
|
|
5
|
+
useCallback, useMemo, useState,
|
|
6
|
+
} from 'react'
|
|
7
|
+
|
|
8
|
+
import { MainNetwork } from '../../helpers/index.ts'
|
|
9
|
+
import type { NetworkBootstrap } from '../../models/index.ts'
|
|
10
|
+
import { ChainNetworkContext } from './context.ts'
|
|
11
|
+
import type { ChainNetworkState } from './state.ts'
|
|
12
|
+
|
|
13
|
+
export interface ChainNetworkProviderProps extends PropsWithChildren {
|
|
14
|
+
getActiveNetwork?: () => Promise<NetworkBootstrap | undefined>
|
|
15
|
+
networks?: NetworkBootstrap[]
|
|
16
|
+
setActiveNetwork?: (networkId: NetworkBootstrap['id']) => Promise<NetworkBootstrap>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ChainNetworkProvider: React.FC<ChainNetworkProviderProps> = ({
|
|
20
|
+
children, getActiveNetwork, networks, setActiveNetwork: setActiveNetworkExternal,
|
|
21
|
+
}) => {
|
|
22
|
+
const [activeNetwork, setActiveNetwork] = useState<NetworkBootstrap>()
|
|
23
|
+
const [error, setError] = useState<Error>()
|
|
24
|
+
|
|
25
|
+
// Set the active network upon initialization
|
|
26
|
+
const [, activeNetworkError] = usePromise(async () => {
|
|
27
|
+
// ensure networks are loaded
|
|
28
|
+
if (!networks) return
|
|
29
|
+
// get last saved active network
|
|
30
|
+
const activeNetwork = await getActiveNetwork?.()
|
|
31
|
+
if (activeNetwork) {
|
|
32
|
+
// Set the active network if it exists
|
|
33
|
+
setActiveNetwork(activeNetwork)
|
|
34
|
+
} else {
|
|
35
|
+
// Set the default network if no active network exists
|
|
36
|
+
const defaultNetwork = networks.find(network => network.id === MainNetwork.id) ?? networks[0]
|
|
37
|
+
await setActiveNetworkExternal?.(defaultNetwork.id)
|
|
38
|
+
|
|
39
|
+
// Set the active network in the context
|
|
40
|
+
setActiveNetwork(defaultNetwork)
|
|
41
|
+
}
|
|
42
|
+
}, [networks])
|
|
43
|
+
|
|
44
|
+
const updateActiveNetwork = useCallback((networkId: NetworkBootstrap['id']) => {
|
|
45
|
+
setError(undefined)
|
|
46
|
+
const network = networks?.find(network => network.id === networkId)
|
|
47
|
+
// set internally
|
|
48
|
+
setActiveNetwork(network)
|
|
49
|
+
// set externally
|
|
50
|
+
void setActiveNetworkExternal?.(networkId)
|
|
51
|
+
}, [networks])
|
|
52
|
+
|
|
53
|
+
const value = useMemo<ChainNetworkState>(() => ({
|
|
54
|
+
activeNetwork,
|
|
55
|
+
networks,
|
|
56
|
+
provided: true,
|
|
57
|
+
updateActiveNetwork,
|
|
58
|
+
walletNetworkError: error ?? activeNetworkError,
|
|
59
|
+
}), [activeNetwork, networks, updateActiveNetwork])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ChainNetworkContext value={value}>
|
|
63
|
+
<ErrorRender error={error ?? activeNetworkError} scope="WalletNetworkProvider" />
|
|
64
|
+
{children}
|
|
65
|
+
</ChainNetworkContext>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContextExState } from '@xyo-network/react-shared'
|
|
2
|
+
|
|
3
|
+
import type { NetworkBootstrap } from '../../models/index.ts'
|
|
4
|
+
|
|
5
|
+
export interface ChainNetworkState extends ContextExState {
|
|
6
|
+
activeNetwork?: NetworkBootstrap
|
|
7
|
+
networks?: NetworkBootstrap[]
|
|
8
|
+
updateActiveNetwork?: (networkId: NetworkBootstrap['id']) => void
|
|
9
|
+
walletNetworkError?: Error
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LocalNetworkIconString, XyoColorLogoString } from '../images/index.ts'
|
|
2
|
+
import type { NetworkBootstrap } from '../models/index.ts'
|
|
3
|
+
import { NetworkBootstrapSchema } from '../models/index.ts'
|
|
4
|
+
|
|
5
|
+
export const MainNetwork: NetworkBootstrap = {
|
|
6
|
+
description: 'Main Node for the XYO Network',
|
|
7
|
+
icon: XyoColorLogoString,
|
|
8
|
+
id: 'mainnet',
|
|
9
|
+
name: 'Mainnet',
|
|
10
|
+
schema: NetworkBootstrapSchema,
|
|
11
|
+
symbol: 'XYOG',
|
|
12
|
+
url: 'https://api.chain.xyo.network',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const KerplunkNetwork: NetworkBootstrap = {
|
|
16
|
+
description: 'Test Node for the XYO Network',
|
|
17
|
+
icon: XyoColorLogoString,
|
|
18
|
+
id: 'testnet',
|
|
19
|
+
name: 'Testnet',
|
|
20
|
+
schema: NetworkBootstrapSchema,
|
|
21
|
+
symbol: 'XYOG',
|
|
22
|
+
url: 'https://beta.api.chain.xyo.network/',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const LocalNetwork: NetworkBootstrap = {
|
|
26
|
+
description: 'Local Node',
|
|
27
|
+
icon: LocalNetworkIconString,
|
|
28
|
+
id: 'local',
|
|
29
|
+
name: 'Local',
|
|
30
|
+
schema: NetworkBootstrapSchema,
|
|
31
|
+
symbol: 'XYOG',
|
|
32
|
+
url: 'http://localhost:8080',
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Networks.ts'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable @stylistic/max-len */
|
|
2
|
+
import { createSvgIcon } from '@mui/material'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
export const LocalNetworkIcon = createSvgIcon(
|
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960">
|
|
7
|
+
<path fill="currentColor" d="M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z" />
|
|
8
|
+
</svg>,
|
|
9
|
+
'LocalNetworkIcon',
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
export const LocalNetworkIconString = `
|
|
13
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 -960 960 960">
|
|
14
|
+
<path fill="currentColor" d="M40-120v-80h880v80H40Zm120-120q-33 0-56.5-23.5T80-320v-440q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v440q0 33-23.5 56.5T800-240H160Zm0-80h640v-440H160v440Zm0 0v-440 440Z" />
|
|
15
|
+
</svg>
|
|
16
|
+
`
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-disable @stylistic/max-len */
|
|
2
|
+
import { createSvgIcon } from '@mui/material'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
export const XyoColorLogo = createSvgIcon(
|
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 238">
|
|
7
|
+
<path
|
|
8
|
+
className="cls-1"
|
|
9
|
+
d="M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z"
|
|
10
|
+
fill="#8d8fc6"
|
|
11
|
+
/>
|
|
12
|
+
<path
|
|
13
|
+
className="cls-2"
|
|
14
|
+
d="M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z"
|
|
15
|
+
fill="#579fd6"
|
|
16
|
+
/>
|
|
17
|
+
<path
|
|
18
|
+
className="cls-3"
|
|
19
|
+
d="M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z"
|
|
20
|
+
fill="#f27046"
|
|
21
|
+
/>
|
|
22
|
+
<path
|
|
23
|
+
className="cls-4"
|
|
24
|
+
d="M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z"
|
|
25
|
+
fill="#eb407a"
|
|
26
|
+
/>
|
|
27
|
+
</svg>,
|
|
28
|
+
'XyoColorLogo',
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export const XyoColorLogoString = `
|
|
32
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 238">
|
|
33
|
+
<path
|
|
34
|
+
className="cls-1"
|
|
35
|
+
d="M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z"
|
|
36
|
+
fill="#8d8fc6"
|
|
37
|
+
/>
|
|
38
|
+
<path
|
|
39
|
+
className="cls-2"
|
|
40
|
+
d="M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z"
|
|
41
|
+
fill="#579fd6"
|
|
42
|
+
/>
|
|
43
|
+
<path
|
|
44
|
+
className="cls-3"
|
|
45
|
+
d="M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z"
|
|
46
|
+
fill="#f27046"
|
|
47
|
+
/>
|
|
48
|
+
<path
|
|
49
|
+
className="cls-4"
|
|
50
|
+
d="M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z"
|
|
51
|
+
fill="#eb407a"
|
|
52
|
+
/>
|
|
53
|
+
</svg>
|
|
54
|
+
`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './icons/index.ts'
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { ChainInformation } from '@xyo-network/chain-model'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
6
|
+
|
|
7
|
+
export const NetworkBootstrapSchema = 'network.xyo.network.bootstrap' as const
|
|
8
|
+
export type NetworkBootstrapSchema = typeof NetworkBootstrapSchema
|
|
9
|
+
|
|
10
|
+
export interface ChainForkFields {
|
|
11
|
+
/** Block Number at which the chain was forked from */
|
|
12
|
+
forkedAtLastBlockNumber?: string
|
|
13
|
+
/** Hash in the last block the chain was forked from */
|
|
14
|
+
forkedAtLastHash?: string
|
|
15
|
+
/** Address of the forked chain */
|
|
16
|
+
forkedChainId?: Address
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NetworkFields {
|
|
20
|
+
/** Description of the network */
|
|
21
|
+
description: string
|
|
22
|
+
/** string representation of the icon (svg) */
|
|
23
|
+
icon?: string
|
|
24
|
+
/** Machine-readable identifier */
|
|
25
|
+
id: string
|
|
26
|
+
/** Human-readable identifier */
|
|
27
|
+
name: string
|
|
28
|
+
schema: NetworkBootstrapSchema
|
|
29
|
+
/** Symbol of the network */
|
|
30
|
+
symbol?: string
|
|
31
|
+
/** Url for accessing the network */
|
|
32
|
+
url: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Note: Optional Properties can be found walking the chain to the genesis block */
|
|
36
|
+
export interface NetworkBootstrapFields extends NetworkFields, ChainForkFields {
|
|
37
|
+
/** Address of the chain, i.e. smart contract address */
|
|
38
|
+
chainInfo?: ChainInformation
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Network extends NetworkBootstrap {
|
|
42
|
+
custom: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type NetworkBootstrap = Payload<NetworkBootstrapFields, NetworkBootstrapSchema>
|
|
46
|
+
|
|
47
|
+
export const isNetworkBootstrap = isPayloadOfSchemaType<NetworkBootstrap>(NetworkBootstrapSchema)
|
|
48
|
+
|
|
49
|
+
export const asOptionalNetwork = AsObjectFactory.createOptional(isNetworkBootstrap)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Bootstrap.ts'
|
package/typedoc.json
ADDED