@hypersokrat/hyper-pay 1.0.1 → 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/package.json +1 -1
- package/.storybook/main.js +0 -9
- package/.storybook/preview.js +0 -41
- package/rollup.config.js +0 -60
- package/src/assets/css/main-theme.css +0 -311
- package/src/assets/fonts/LackRegular/Lack-Regular.eot +0 -0
- package/src/assets/fonts/LackRegular/Lack-Regular.svg +0 -5284
- package/src/assets/fonts/LackRegular/Lack-Regular.ttf +0 -0
- package/src/assets/fonts/LackRegular/Lack-Regular.woff +0 -0
- package/src/assets/fonts/LackRegular/Lack-Regular.woff2 +0 -0
- package/src/assets/fonts/Marcellus/Marcellus-Regular.eot +0 -0
- package/src/assets/fonts/Marcellus/Marcellus-Regular.svg +0 -1966
- package/src/assets/fonts/Marcellus/Marcellus-Regular.ttf +0 -0
- package/src/assets/fonts/Marcellus/Marcellus-Regular.woff +0 -0
- package/src/assets/fonts/Marcellus/Marcellus-Regular.woff2 +0 -0
- package/src/assets/fonts/Marcellus/demo.html +0 -192
- package/src/assets/fonts/Marcellus/stylesheet.css +0 -13
- package/src/assets/fonts/Poppins/Poppins-Regular.eot +0 -0
- package/src/assets/fonts/Poppins/Poppins-Regular.svg +0 -3213
- package/src/assets/fonts/Poppins/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/Poppins/Poppins-Regular.woff +0 -0
- package/src/assets/fonts/Poppins/Poppins-Regular.woff2 +0 -0
- package/src/assets/fonts/Poppins/stylesheet.css +0 -13
- package/src/assets/fonts/UberMove/UberMove-Medium.eot +0 -0
- package/src/assets/fonts/UberMove/UberMove-Medium.svg +0 -4049
- package/src/assets/fonts/UberMove/UberMove-Medium.ttf +0 -0
- package/src/assets/fonts/UberMove/UberMove-Medium.woff +0 -0
- package/src/assets/fonts/UberMove/UberMove-Medium.woff2 +0 -0
- package/src/assets/fonts/UberMove/UberMove-Regular.eot +0 -0
- package/src/assets/fonts/UberMove/UberMove-Regular.svg +0 -4055
- package/src/assets/fonts/UberMove/UberMove-Regular.ttf +0 -0
- package/src/assets/fonts/UberMove/UberMove-Regular.woff +0 -0
- package/src/assets/fonts/UberMove/UberMove-Regular.woff2 +0 -0
- package/src/assets/img/currency/bitcoin.png +0 -0
- package/src/assets/img/currency/bnb.png +0 -0
- package/src/assets/img/currency/ethereum.jpg +0 -0
- package/src/assets/img/currency/ethereum.png +0 -0
- package/src/assets/img/currency/metamask.png +0 -0
- package/src/assets/img/currency/tether.png +0 -0
- package/src/components/Button/Button.css +0 -29
- package/src/components/Button/Button.jsx +0 -20
- package/src/components/Button/index.js +0 -1
- package/src/components/Metamask/Metamask.css +0 -14
- package/src/components/Metamask/Metamask.jsx +0 -79
- package/src/components/Metamask/index.js +0 -1
- package/src/components/Modal/Modal.css +0 -138
- package/src/components/Modal/Modal.jsx +0 -297
- package/src/components/Modal/index.js +0 -1
- package/src/components/Tabs/Tab.jsx +0 -32
- package/src/components/Tabs/Tabs.css +0 -52
- package/src/components/Tabs/Tabs.jsx +0 -15
- package/src/components/Tabs/index.js +0 -2
- package/src/hooks/index.js +0 -1
- package/src/hooks/useConnect.js +0 -136
- package/src/index.js +0 -6
- package/src/stories/Button.stories.js +0 -25
- package/src/stories/Metamask.stories.js +0 -13
- package/src/stories/Modal.stories.js +0 -23
- package/src/stories/Tabs.stories.js +0 -33
- package/src/translates.json +0 -713
- package/src/utils/WBNB.json +0 -153
- package/src/utils/chainConfig.js +0 -47
- package/storybook-static/0.2ab68c35.iframe.bundle.js +0 -3
- package/storybook-static/0.2ab68c35.iframe.bundle.js.LICENSE.txt +0 -8
- package/storybook-static/0.2ab68c35.iframe.bundle.js.map +0 -1
- package/storybook-static/0.e5489f12ab94aa497491.manager.bundle.js +0 -2
- package/storybook-static/0.e5489f12ab94aa497491.manager.bundle.js.LICENSE.txt +0 -8
- package/storybook-static/1.7d0dd704b26935d06a04.manager.bundle.js +0 -1
- package/storybook-static/1.8c220da3.iframe.bundle.js +0 -3
- package/storybook-static/1.8c220da3.iframe.bundle.js.LICENSE.txt +0 -14
- package/storybook-static/1.8c220da3.iframe.bundle.js.map +0 -1
- package/storybook-static/10.398dd7a0522c1ff2b3a8.manager.bundle.js +0 -1
- package/storybook-static/10.dab4e389.iframe.bundle.js +0 -3
- package/storybook-static/10.dab4e389.iframe.bundle.js.LICENSE.txt +0 -12
- package/storybook-static/10.dab4e389.iframe.bundle.js.map +0 -1
- package/storybook-static/11.e487b823.iframe.bundle.js +0 -1
- package/storybook-static/2.21286279.iframe.bundle.js +0 -1
- package/storybook-static/3.17beddd8.iframe.bundle.js +0 -1
- package/storybook-static/5.23ef655b5acff6eac8ad.manager.bundle.js +0 -1
- package/storybook-static/6.d2f96bcf3b11b0f1a44b.manager.bundle.js +0 -1
- package/storybook-static/7.5ef1ca09.iframe.bundle.js +0 -3
- package/storybook-static/7.5ef1ca09.iframe.bundle.js.LICENSE.txt +0 -31
- package/storybook-static/7.5ef1ca09.iframe.bundle.js.map +0 -1
- package/storybook-static/7.a1c5467faea0833b53d1.manager.bundle.js +0 -1
- package/storybook-static/8.65ec2749796fb05c258c.manager.bundle.js +0 -2
- package/storybook-static/8.65ec2749796fb05c258c.manager.bundle.js.LICENSE.txt +0 -12
- package/storybook-static/8.869413af.iframe.bundle.js +0 -1
- package/storybook-static/9.4080b133.iframe.bundle.js +0 -1
- package/storybook-static/9.acd0ef9064e0667433ac.manager.bundle.js +0 -2
- package/storybook-static/9.acd0ef9064e0667433ac.manager.bundle.js.LICENSE.txt +0 -31
- package/storybook-static/favicon.ico +0 -0
- package/storybook-static/iframe.html +0 -364
- package/storybook-static/index.html +0 -51
- package/storybook-static/main.93d2c8aa127bed373c8a.manager.bundle.js +0 -2
- package/storybook-static/main.93d2c8aa127bed373c8a.manager.bundle.js.LICENSE.txt +0 -54
- package/storybook-static/main.f075035f.iframe.bundle.js +0 -3
- package/storybook-static/main.f075035f.iframe.bundle.js.LICENSE.txt +0 -1
- package/storybook-static/main.f075035f.iframe.bundle.js.map +0 -1
- package/storybook-static/project.json +0 -1
- package/storybook-static/runtime~main.8e5cf3a9715a0d32d390.manager.bundle.js +0 -1
- package/storybook-static/runtime~main.f8e70bd7.iframe.bundle.js +0 -1
- package/storybook-static/static/media/Marcellus-Regular.2fb50c7c.eot +0 -0
- package/storybook-static/static/media/Marcellus-Regular.62064e40.woff +0 -0
- package/storybook-static/static/media/Marcellus-Regular.8ae4aad6.woff2 +0 -0
- package/storybook-static/static/media/Marcellus-Regular.e15056e4.ttf +0 -0
- package/storybook-static/static/media/Marcellus-Regular.e719d450.svg +0 -1966
- package/storybook-static/static/media/Poppins-Regular.387f9003.woff +0 -0
- package/storybook-static/static/media/Poppins-Regular.a20e7b73.eot +0 -0
- package/storybook-static/static/media/Poppins-Regular.ad19729d.woff2 +0 -0
- package/storybook-static/static/media/Poppins-Regular.c533b610.svg +0 -3213
- package/storybook-static/static/media/Poppins-Regular.e09d5cf4.ttf +0 -0
- package/storybook-static/vendors~main.7c47903ea43e951c3707.manager.bundle.js +0 -2
- package/storybook-static/vendors~main.7c47903ea43e951c3707.manager.bundle.js.LICENSE.txt +0 -55
- package/storybook-static/vendors~main.aea8d710.iframe.bundle.js +0 -3
- package/storybook-static/vendors~main.aea8d710.iframe.bundle.js.LICENSE.txt +0 -89
- package/storybook-static/vendors~main.aea8d710.iframe.bundle.js.map +0 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
font-family: "Marcellus";
|
|
3
|
-
font-size: 16px;
|
|
4
|
-
color: white;
|
|
5
|
-
padding: 2px 5px;
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
border-radius: 3px;
|
|
10
|
-
transition: .5s;
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
width: auto;
|
|
13
|
-
}
|
|
14
|
-
.primary {
|
|
15
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
16
|
-
background-color: rgba(0, 255, 170, 0.927);
|
|
17
|
-
}
|
|
18
|
-
.secondary {
|
|
19
|
-
color: rgba(0, 255, 170, 0.927);
|
|
20
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
21
|
-
background-color: transparent;
|
|
22
|
-
}
|
|
23
|
-
.primary:hover {
|
|
24
|
-
background-color: rgb(0, 255, 132);
|
|
25
|
-
}
|
|
26
|
-
.secondary:hover {
|
|
27
|
-
background-color: rgba(0, 255, 170, 0.927);
|
|
28
|
-
color: white !important;
|
|
29
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import "./Button.css";
|
|
4
|
-
|
|
5
|
-
export const Button = ({
|
|
6
|
-
customStyles = {},
|
|
7
|
-
label,
|
|
8
|
-
onClick,
|
|
9
|
-
type
|
|
10
|
-
}) => {
|
|
11
|
-
return (
|
|
12
|
-
<div
|
|
13
|
-
className={`button ${type === "primary" ? "primary" : "secondary"}`}
|
|
14
|
-
style={customStyles}
|
|
15
|
-
onClick={onClick}
|
|
16
|
-
>
|
|
17
|
-
{label}
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Button.jsx";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.metamaskBtn {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
border: 2px solid #070b1a;
|
|
6
|
-
border-radius: 10px;
|
|
7
|
-
width: 50px;
|
|
8
|
-
height: 50px;
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
position: absolute;
|
|
11
|
-
background: #070b1a;
|
|
12
|
-
left: calc(50% - 25%);
|
|
13
|
-
top: calc(50% - 25%);
|
|
14
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
|
|
4
|
-
import { useConnect } from "../../hooks";
|
|
5
|
-
|
|
6
|
-
import { Modal } from "../Modal";
|
|
7
|
-
|
|
8
|
-
import metamask from "../../assets/img/currency/metamask.png";
|
|
9
|
-
|
|
10
|
-
import "./Metamask.css";
|
|
11
|
-
|
|
12
|
-
export const Metamask = ({
|
|
13
|
-
connectButtonStyles = {},
|
|
14
|
-
modalStyles = {},
|
|
15
|
-
projectId = ""
|
|
16
|
-
}) => {
|
|
17
|
-
const [modal, setModal] = useState(false);
|
|
18
|
-
const [company, setCompany] = useState({
|
|
19
|
-
companyName: "",
|
|
20
|
-
projectId: "",
|
|
21
|
-
address: "",
|
|
22
|
-
_id: "",
|
|
23
|
-
currencies: []
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const { isMetaMaskConnected, isMetaMaskInstalled, connect } = useConnect();
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const getCompany = async () => {
|
|
30
|
-
try {
|
|
31
|
-
let projectIdUrl = "http://localhost:4000/company/get-company-by-project-id";
|
|
32
|
-
|
|
33
|
-
await axios.post(projectIdUrl, { projectId })
|
|
34
|
-
.then(res => {
|
|
35
|
-
if (res) {
|
|
36
|
-
setCompany(res?.data?.company);
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
.catch(err => {
|
|
40
|
-
console.log(err);
|
|
41
|
-
});
|
|
42
|
-
} catch (err) {
|
|
43
|
-
console.log(err);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
if (projectId) {
|
|
48
|
-
getCompany();
|
|
49
|
-
}
|
|
50
|
-
}, [projectId]);
|
|
51
|
-
|
|
52
|
-
if (!isMetaMaskInstalled) {
|
|
53
|
-
return <div>MetaMask is not installed</div>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (modal && isMetaMaskConnected) {
|
|
57
|
-
return <Modal company={company} handleCloseModal={() => setModal(false)} modalStyles={modalStyles} label="Pay with crypto easy" />;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
{!modal &&
|
|
63
|
-
<div
|
|
64
|
-
className="metamaskBtn"
|
|
65
|
-
style={connectButtonStyles}
|
|
66
|
-
onClick={() => connect(() => {
|
|
67
|
-
setModal(true);
|
|
68
|
-
})}
|
|
69
|
-
>
|
|
70
|
-
<img
|
|
71
|
-
src={metamask}
|
|
72
|
-
alt="metamask"
|
|
73
|
-
style={{ width: "100%", height: "90%" }}
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
}
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Metamask.jsx";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
.modalContainer {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
gap: 20px;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
width: 400px;
|
|
8
|
-
height: auto;
|
|
9
|
-
border: 2px solid #070b1a;
|
|
10
|
-
border-radius: 10px;
|
|
11
|
-
position: fixed;
|
|
12
|
-
left: 25%;
|
|
13
|
-
top: 10%;
|
|
14
|
-
padding: 20px;
|
|
15
|
-
background: #070b1a;
|
|
16
|
-
}
|
|
17
|
-
.title {
|
|
18
|
-
font-size: 20px;
|
|
19
|
-
}
|
|
20
|
-
.modalBody {
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: space-between;
|
|
24
|
-
gap: 20px;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
width: 100%;
|
|
27
|
-
height: 90%;
|
|
28
|
-
position: relative;
|
|
29
|
-
overflow-y: auto;
|
|
30
|
-
}
|
|
31
|
-
.modalItem {
|
|
32
|
-
display: flex;
|
|
33
|
-
gap: 30px;
|
|
34
|
-
width: 100%;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
align-items: center;
|
|
37
|
-
}
|
|
38
|
-
.converterWrapper {
|
|
39
|
-
width: 100%;
|
|
40
|
-
height: 35px;
|
|
41
|
-
position: relative;
|
|
42
|
-
display: flex;
|
|
43
|
-
align-items: center;
|
|
44
|
-
justify-content: space-between;
|
|
45
|
-
margin-bottom: 15px;
|
|
46
|
-
}
|
|
47
|
-
.inputWrapper {
|
|
48
|
-
width: 40%;
|
|
49
|
-
height: 100%;
|
|
50
|
-
position: relative;
|
|
51
|
-
}
|
|
52
|
-
.amountInput {
|
|
53
|
-
background-color: transparent;
|
|
54
|
-
border-radius: 3px;
|
|
55
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
56
|
-
outline: none;
|
|
57
|
-
padding: 3px 3px 3px 10px;
|
|
58
|
-
color: rgba(0, 255, 170, 0.927);
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
font-size: 12px;
|
|
62
|
-
}
|
|
63
|
-
.inputSpan2 {
|
|
64
|
-
background-color: transparent;
|
|
65
|
-
border-radius: 3px;
|
|
66
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
67
|
-
outline: none;
|
|
68
|
-
padding: 3px 10px;
|
|
69
|
-
width: 40%;
|
|
70
|
-
height: 100%;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: space-between;
|
|
74
|
-
}
|
|
75
|
-
.inputSpan2 span {
|
|
76
|
-
color: rgba(0, 255, 170, 0.927)v;
|
|
77
|
-
font-size: 12px;
|
|
78
|
-
color: rgba(0, 255, 170, 0.927)
|
|
79
|
-
}
|
|
80
|
-
::placeholder {
|
|
81
|
-
color: rgba(0, 255, 170, 0.927);
|
|
82
|
-
font-size: 12px;
|
|
83
|
-
}
|
|
84
|
-
.error {
|
|
85
|
-
color: rgba(255, 17, 0, 0.866);
|
|
86
|
-
font-size: 12px;
|
|
87
|
-
margin-top: 5px;
|
|
88
|
-
text-align: center;
|
|
89
|
-
}
|
|
90
|
-
.success {
|
|
91
|
-
color: rgba(0, 255, 170, 0.927);
|
|
92
|
-
font-size: 12px;
|
|
93
|
-
margin-top: 5px;
|
|
94
|
-
text-align: center;
|
|
95
|
-
}
|
|
96
|
-
.inputSpan {
|
|
97
|
-
color: rgba(0, 255, 170, 0.927);
|
|
98
|
-
position: absolute;
|
|
99
|
-
right: -12px;
|
|
100
|
-
top: 6px;
|
|
101
|
-
font-size: 12px;
|
|
102
|
-
}
|
|
103
|
-
.dataItem {
|
|
104
|
-
display: flex;
|
|
105
|
-
width: 100%;
|
|
106
|
-
align-items: center;
|
|
107
|
-
justify-content: flex-start;
|
|
108
|
-
flex-wrap: wrap;
|
|
109
|
-
border-radius: 3px;
|
|
110
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
111
|
-
padding: 5px;
|
|
112
|
-
}
|
|
113
|
-
.dataItem span {
|
|
114
|
-
width: 100%;
|
|
115
|
-
font-size: 12px;
|
|
116
|
-
}
|
|
117
|
-
.increase {
|
|
118
|
-
border-top: 1px solid rgba(0, 255, 170, 0.927);
|
|
119
|
-
border-left: 1px solid rgba(0, 255, 170, 0.927);
|
|
120
|
-
transform: rotate(45deg);
|
|
121
|
-
position: absolute;
|
|
122
|
-
width: 7px;
|
|
123
|
-
height: 7px;
|
|
124
|
-
right: 10px;
|
|
125
|
-
top: 10px;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
}
|
|
128
|
-
.decrease {
|
|
129
|
-
border-right: 1px solid rgba(0, 255, 170, 0.927);
|
|
130
|
-
border-bottom: 1px solid rgba(0, 255, 170, 0.927);
|
|
131
|
-
transform: rotate(45deg);
|
|
132
|
-
position: absolute;
|
|
133
|
-
width: 7px;
|
|
134
|
-
height: 7px;
|
|
135
|
-
right: 10px;
|
|
136
|
-
top: 17px;
|
|
137
|
-
cursor: pointer;
|
|
138
|
-
}
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
|
|
4
|
-
import WBNB from "../../utils/WBNB.json";
|
|
5
|
-
import { useConnect } from "../../hooks";
|
|
6
|
-
|
|
7
|
-
import ethereum from "../../assets/img/currency/ethereum.png";
|
|
8
|
-
import bnb from "../../assets/img/currency/bnb.png";
|
|
9
|
-
import { Button } from "../Button";
|
|
10
|
-
import { Tabs, Tab } from "../Tabs";
|
|
11
|
-
|
|
12
|
-
import "./Modal.css";
|
|
13
|
-
|
|
14
|
-
const tabsData = [
|
|
15
|
-
{
|
|
16
|
-
label: "ETH Mainnet",
|
|
17
|
-
svg: <img style={{ width: "30px", height: "30px "}} src={ethereum} alt="etehereum" />,
|
|
18
|
-
params: [{
|
|
19
|
-
chainId: '0x1',
|
|
20
|
-
chainName: 'Ethereum Mainnet',
|
|
21
|
-
nativeCurrency: {
|
|
22
|
-
name: 'Ether',
|
|
23
|
-
symbol: 'ETH',
|
|
24
|
-
decimals: 18,
|
|
25
|
-
},
|
|
26
|
-
rpcUrls: ['https://rpc.notadegen.com/eth'],
|
|
27
|
-
blockExplorerUrls: ['https://etherscan.io'],
|
|
28
|
-
}]
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: "BSC Smart Chain",
|
|
32
|
-
svg: <img style={{ width: "30px", height: "30px "}} src={bnb} alt="bnb" />,
|
|
33
|
-
params: [{
|
|
34
|
-
chainId: '0x38',
|
|
35
|
-
chainName: 'Binance Smart Chain Mainnet',
|
|
36
|
-
nativeCurrency: {
|
|
37
|
-
name: 'BNB',
|
|
38
|
-
symbol: 'BNB',
|
|
39
|
-
decimals: 18,
|
|
40
|
-
},
|
|
41
|
-
rpcUrls: ['https://bsc-dataseed.binance.org/'],
|
|
42
|
-
blockExplorerUrls: ['https://bscscan.com'],
|
|
43
|
-
}]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
label: "BSC Test Chain",
|
|
47
|
-
svg: <img style={{ width: "30px", height: "30px "}} src={bnb} alt="bnb" />,
|
|
48
|
-
params: [{
|
|
49
|
-
chainId: '0x61', // Chain ID for BSC Testnet
|
|
50
|
-
chainName: 'Binance Smart Chain Testnet',
|
|
51
|
-
nativeCurrency: {
|
|
52
|
-
name: 'BNB',
|
|
53
|
-
symbol: 'BNB',
|
|
54
|
-
decimals: 18,
|
|
55
|
-
},
|
|
56
|
-
rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545'], // RPC endpoint for BSC Testnet
|
|
57
|
-
blockExplorerUrls: ['https://testnet.bscscan.com'],
|
|
58
|
-
}]
|
|
59
|
-
}
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
export const Modal = ({
|
|
63
|
-
modalStyles = {
|
|
64
|
-
container: {},
|
|
65
|
-
title: {}
|
|
66
|
-
},
|
|
67
|
-
label,
|
|
68
|
-
handleCloseModal,
|
|
69
|
-
company
|
|
70
|
-
}) => {
|
|
71
|
-
const [token, setToken] = useState(company?.currencies[0]?.dtsokrat);
|
|
72
|
-
const [tokenSymbol, setTokenSymbol] = useState("");
|
|
73
|
-
const [symbol, setSymbol] = useState("");
|
|
74
|
-
const [amount, setAmount] = useState(0);
|
|
75
|
-
const [convertedAmount, setConvertedAmount] = useState(0);
|
|
76
|
-
const [error, setError] = useState("");
|
|
77
|
-
const [success, setSuccess] = useState("");
|
|
78
|
-
const [activeTab, setActiveTab] = useState(parseInt(localStorage.getItem("activeTab")));
|
|
79
|
-
const [rate, setRate] = useState(null);
|
|
80
|
-
|
|
81
|
-
const {
|
|
82
|
-
getAccountData,
|
|
83
|
-
switchNetwork,
|
|
84
|
-
getTokenBalance,
|
|
85
|
-
account,
|
|
86
|
-
chainId,
|
|
87
|
-
tokenBalance,
|
|
88
|
-
network,
|
|
89
|
-
web3
|
|
90
|
-
} = useConnect();
|
|
91
|
-
|
|
92
|
-
const handleConfirm = async () => {
|
|
93
|
-
if (parseFloat(convertedAmount) < parseFloat(tokenBalance)) {
|
|
94
|
-
let providerAddress = "0xff42A19083aC41318a3e62C3A6176f96184193Db";
|
|
95
|
-
let tokenAddress = network?.tokens[token]?.address;
|
|
96
|
-
const tokenContract = new web3.eth.Contract(WBNB, tokenAddress);
|
|
97
|
-
|
|
98
|
-
const amount = web3.utils.toBN(
|
|
99
|
-
web3.utils.toWei(convertedAmount.toString(), "ether")
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const gasPrice = await web3.eth.getGasPrice();
|
|
103
|
-
|
|
104
|
-
const transferData = tokenContract.methods
|
|
105
|
-
.transfer(providerAddress, amount.toString())
|
|
106
|
-
.encodeABI();
|
|
107
|
-
|
|
108
|
-
const transactionObject = {
|
|
109
|
-
from: account,
|
|
110
|
-
to: tokenAddress,
|
|
111
|
-
data: transferData,
|
|
112
|
-
gasPrice,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
web3.eth
|
|
116
|
-
.sendTransaction(transactionObject)
|
|
117
|
-
.then(async (receipt) => {
|
|
118
|
-
if (receipt) {
|
|
119
|
-
let transactionUrl = "http://localhost:4000/transactions/add-new-transaction";
|
|
120
|
-
await axios.post(transactionUrl, {
|
|
121
|
-
receipt,
|
|
122
|
-
company,
|
|
123
|
-
convertedAmount,
|
|
124
|
-
amount,
|
|
125
|
-
tokenAddress,
|
|
126
|
-
rpcUrl: tabsData[parseInt(activeTab)].params[0].rpcUrls[0]
|
|
127
|
-
})
|
|
128
|
-
.then(res => {
|
|
129
|
-
console.log(res);
|
|
130
|
-
setSuccess(res.data.message);
|
|
131
|
-
})
|
|
132
|
-
.catch(err => {
|
|
133
|
-
console.log(err);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
.catch(async (error) => {
|
|
138
|
-
if (error.message.includes("User denied transaction signature")) {
|
|
139
|
-
console.log(error.message);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const handleSwitchNetwork = async (id, params) => {
|
|
146
|
-
setActiveTab(id);
|
|
147
|
-
switchNetwork(params);
|
|
148
|
-
localStorage.setItem("activeTab", id);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
if (chainId && network) {
|
|
153
|
-
setSymbol(network.symbol);
|
|
154
|
-
setTokenSymbol(network.tokens[token].symbol);
|
|
155
|
-
}
|
|
156
|
-
}, [chainId, network]);
|
|
157
|
-
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
if (account) {
|
|
160
|
-
getAccountData();
|
|
161
|
-
|
|
162
|
-
if (chainId) {
|
|
163
|
-
getTokenBalance(chainId, token);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}, [account, chainId]);
|
|
167
|
-
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
const getRate = async () => {
|
|
170
|
-
const apiUrl = 'https://api.coingecko.com/api/v3/simple/price?ids=tether&vs_currencies=usd';
|
|
171
|
-
|
|
172
|
-
await axios.get(apiUrl)
|
|
173
|
-
.then(res => {
|
|
174
|
-
if (res) {
|
|
175
|
-
let rate = res.data.tether;
|
|
176
|
-
|
|
177
|
-
setRate(rate);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
getRate();
|
|
183
|
-
}, []);
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div
|
|
187
|
-
className="modalContainer"
|
|
188
|
-
style={modalStyles.container}
|
|
189
|
-
>
|
|
190
|
-
<span
|
|
191
|
-
className="title"
|
|
192
|
-
style={modalStyles.title}
|
|
193
|
-
>{label}</span>
|
|
194
|
-
<div className="modalBody">
|
|
195
|
-
<div className="dataItem">
|
|
196
|
-
<span>Account: {account}</span>
|
|
197
|
-
{/* <span>Balance: {balance} {symbol}</span> */}
|
|
198
|
-
<span>Token balance: {tokenBalance} {tokenSymbol}</span>
|
|
199
|
-
</div>
|
|
200
|
-
<span>Switch network</span>
|
|
201
|
-
<Tabs>
|
|
202
|
-
{tabsData && tabsData.map((item, index) => {
|
|
203
|
-
return (
|
|
204
|
-
<Tab
|
|
205
|
-
key={index}
|
|
206
|
-
onClick={() => handleSwitchNetwork(index, item?.params)}
|
|
207
|
-
label={item?.label}
|
|
208
|
-
svg={item?.svg}
|
|
209
|
-
active={activeTab === index}
|
|
210
|
-
/>
|
|
211
|
-
)
|
|
212
|
-
})}
|
|
213
|
-
</Tabs>
|
|
214
|
-
<div className="converterWrapper">
|
|
215
|
-
<div className="inputWrapper">
|
|
216
|
-
<input
|
|
217
|
-
className="amountInput"
|
|
218
|
-
type="number"
|
|
219
|
-
value={amount === 0 ? false : amount}
|
|
220
|
-
placeholder="Put your amount"
|
|
221
|
-
onChange={e => {
|
|
222
|
-
let target = e.target.value;
|
|
223
|
-
|
|
224
|
-
if (target === "") target = 0;
|
|
225
|
-
|
|
226
|
-
let amt = parseFloat(target);
|
|
227
|
-
let converted = amt * rate.usd;
|
|
228
|
-
|
|
229
|
-
setAmount(amt);
|
|
230
|
-
setConvertedAmount(converted.toFixed(2));
|
|
231
|
-
|
|
232
|
-
if (converted > tokenBalance) {
|
|
233
|
-
setError("Insufficient funds");
|
|
234
|
-
setSuccess("");
|
|
235
|
-
} else if (converted < tokenBalance) {
|
|
236
|
-
setSuccess("It's enough money to pay");
|
|
237
|
-
setError("");
|
|
238
|
-
} else {
|
|
239
|
-
setSuccess("");
|
|
240
|
-
setError("");
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (parseFloat(tokenBalance) === 0) {
|
|
244
|
-
setSuccess("You don't have tokens on the balance. Please, first buy some tokens");
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (converted === 0) {
|
|
248
|
-
setSuccess("");
|
|
249
|
-
setError("");
|
|
250
|
-
}
|
|
251
|
-
}}
|
|
252
|
-
/>
|
|
253
|
-
<span className="inputSpan">$</span>
|
|
254
|
-
<div
|
|
255
|
-
className="increase"
|
|
256
|
-
onClick={() => setAmount(amount + 1)}
|
|
257
|
-
></div>
|
|
258
|
-
<div
|
|
259
|
-
className="decrease"
|
|
260
|
-
onClick={() => {
|
|
261
|
-
if (amount > 1) {
|
|
262
|
-
setAmount(amount - 1);
|
|
263
|
-
}
|
|
264
|
-
}}
|
|
265
|
-
></div>
|
|
266
|
-
</div>
|
|
267
|
-
<span className="inputSpan2">
|
|
268
|
-
<span>{convertedAmount}</span>
|
|
269
|
-
<span>{tokenSymbol}</span>
|
|
270
|
-
</span>
|
|
271
|
-
</div>
|
|
272
|
-
<div className="modalItem">
|
|
273
|
-
<Button
|
|
274
|
-
type="primary"
|
|
275
|
-
label="Confirm"
|
|
276
|
-
onClick={handleConfirm}
|
|
277
|
-
customStyles={{
|
|
278
|
-
width: "50%",
|
|
279
|
-
height: "35px"
|
|
280
|
-
}}
|
|
281
|
-
/>
|
|
282
|
-
<Button
|
|
283
|
-
type="secondary"
|
|
284
|
-
label="Cancel"
|
|
285
|
-
onClick={handleCloseModal}
|
|
286
|
-
customStyles={{
|
|
287
|
-
width: "50%",
|
|
288
|
-
height: "35px"
|
|
289
|
-
}}
|
|
290
|
-
/>
|
|
291
|
-
</div>
|
|
292
|
-
</div>
|
|
293
|
-
{error && <span className="error">{error}</span>}
|
|
294
|
-
{success && <span className="success">{success}</span>}
|
|
295
|
-
</div>
|
|
296
|
-
);
|
|
297
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Modal.jsx";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import "./Tabs.css";
|
|
4
|
-
|
|
5
|
-
export const Tab = ({
|
|
6
|
-
customStyles = {},
|
|
7
|
-
label,
|
|
8
|
-
svg,
|
|
9
|
-
onClick,
|
|
10
|
-
active
|
|
11
|
-
}) => {
|
|
12
|
-
if (svg) {
|
|
13
|
-
return (
|
|
14
|
-
<div
|
|
15
|
-
className={`svgTab ${active ? 'active' : ''}`}
|
|
16
|
-
onClick={onClick}
|
|
17
|
-
>
|
|
18
|
-
{svg}
|
|
19
|
-
<span>{label}</span>
|
|
20
|
-
</div>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
className="tab"
|
|
27
|
-
style={customStyles}
|
|
28
|
-
>
|
|
29
|
-
{label}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
.tabsContainer {
|
|
2
|
-
width: 100%;
|
|
3
|
-
height: auto;
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: space-between;
|
|
7
|
-
gap: 30px;
|
|
8
|
-
}
|
|
9
|
-
.tab {
|
|
10
|
-
font-family: "Marcellus";
|
|
11
|
-
font-size: 14px;
|
|
12
|
-
color: white;
|
|
13
|
-
padding: 2px 5px;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
border: 1px solid rgba(0, 255, 170, 0.927);
|
|
18
|
-
background-color: rgba(0, 255, 170, 0.927);
|
|
19
|
-
border-radius: 3px;
|
|
20
|
-
transition: .5s;
|
|
21
|
-
cursor: pointer;
|
|
22
|
-
}
|
|
23
|
-
.tab:hover {
|
|
24
|
-
background-color: transparent;
|
|
25
|
-
color: rgba(0, 255, 170, 0.927);
|
|
26
|
-
}
|
|
27
|
-
.svgTab {
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
}
|
|
34
|
-
.svgTab span {
|
|
35
|
-
font-size: 10px;
|
|
36
|
-
transition: .5s;
|
|
37
|
-
}
|
|
38
|
-
.svgTab svg path {
|
|
39
|
-
transition: .5s;
|
|
40
|
-
}
|
|
41
|
-
.svgTab:hover svg path {
|
|
42
|
-
fill: rgba(0, 255, 170, 0.927);
|
|
43
|
-
}
|
|
44
|
-
.svgTab:hover span {
|
|
45
|
-
color: rgba(0, 255, 170, 0.927);
|
|
46
|
-
}
|
|
47
|
-
.svgTab.active svg path {
|
|
48
|
-
fill: rgba(255, 166, 0, 0.927);
|
|
49
|
-
}
|
|
50
|
-
.svgTab.active span {
|
|
51
|
-
color: rgba(255, 166, 0, 0.927);
|
|
52
|
-
}
|