@xswap-link/sdk 0.1.0 → 0.1.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/.github/workflows/main.yml +1 -0
- package/.github/workflows/publish.yml +1 -0
- package/CHANGELOG.md +24 -0
- package/dist/index.css +128 -32
- package/dist/index.d.mts +22 -19
- package/dist/index.d.ts +22 -19
- package/dist/index.js +1167 -32978
- package/dist/index.mjs +1152 -32988
- package/nodemon.json +5 -0
- package/package.json +17 -6
- package/src/components/TxConfigForm/BalanceComponent.tsx +51 -0
- package/src/components/TxConfigForm/ChainListElement.tsx +36 -0
- package/src/components/TxConfigForm/Description.tsx +15 -0
- package/src/components/TxConfigForm/ErrorField.tsx +17 -0
- package/src/components/TxConfigForm/FeesDetails.tsx +105 -0
- package/src/components/TxConfigForm/Form.tsx +129 -447
- package/src/components/TxConfigForm/History.tsx +67 -122
- package/src/components/TxConfigForm/HistoryCard.tsx +3 -2
- package/src/components/TxConfigForm/Settings.tsx +137 -0
- package/src/components/TxConfigForm/Summary.tsx +57 -0
- package/src/components/TxConfigForm/SwapPanel.tsx +191 -0
- package/src/components/TxConfigForm/TokenPicker.tsx +76 -67
- package/src/components/TxConfigForm/TopBar.tsx +53 -0
- package/src/components/TxConfigForm/index.tsx +121 -0
- package/src/components/icons/ArrowDownIcon.tsx +16 -0
- package/src/components/icons/ChainlinkCCIPIcon.tsx +23 -0
- package/src/components/icons/ChevronDownIcon.tsx +2 -2
- package/src/components/icons/ChevronUpIcon.tsx +2 -2
- package/src/components/icons/CloseIcon.tsx +2 -2
- package/src/components/icons/CoinsIcon.tsx +8 -6
- package/src/components/icons/HistoryIcon.tsx +8 -5
- package/src/components/icons/InfoIcon.tsx +13 -0
- package/src/components/icons/SettingsIcon.tsx +16 -0
- package/src/components/icons/TimerIcon.tsx +15 -0
- package/src/components/icons/XSwapBadgeIcon.tsx +23 -0
- package/src/components/icons/index.ts +6 -0
- package/src/config/index.ts +1 -0
- package/src/config/wagmiConfig.ts +45 -0
- package/src/constants/index.ts +6 -3
- package/tailwind.config.js +11 -2
- package/src/components/TxConfigForm/index.jsx +0 -100
- package/src/components/global.d.ts +0 -6
package/src/constants/index.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { Ecosystem } from "@src/models";
|
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
|
|
4
4
|
export const NUMBER_INPUT_REGEX = /^[0-9]*[.,]?[0-9]*$/;
|
|
5
|
-
export const SLIPPAGE_PRESETS: number[] = [0.5, 1.5, 3];
|
|
6
|
-
export const
|
|
5
|
+
export const SLIPPAGE_PRESETS: number[] = [0.5, 1.5, 3.0];
|
|
6
|
+
export const DELIVERY_TIME = 30 * 1000 * 60;
|
|
7
|
+
export const EXPRESS_DELIVERY_TIME = 30 * 1000;
|
|
7
8
|
export const BALANCES_CHUNK_SIZE = 500;
|
|
8
|
-
export const
|
|
9
|
+
export const ROUTE_TIMEOUT_MS = 5000;
|
|
10
|
+
export const MINIMUM_DISPLAYED_TOKEN_AMOUNT = 0.0001;
|
|
11
|
+
export const DEFAULT_SOURCE_CHAIN_ID = "1";
|
package/tailwind.config.js
CHANGED
|
@@ -4,9 +4,18 @@ module.exports = {
|
|
|
4
4
|
theme: {
|
|
5
5
|
extend: {
|
|
6
6
|
colors: {
|
|
7
|
-
x_alert: "rgb(255,
|
|
8
|
-
x_alert_light: "rgb(255,
|
|
7
|
+
x_alert: "rgb(255,183,77)",
|
|
8
|
+
x_alert_light: "rgb(255,226,183)",
|
|
9
9
|
x_blue: "#3396FF",
|
|
10
|
+
x_green: "#66bb6a",
|
|
11
|
+
x_error_background: "rgba(255,202,40,0.1)",
|
|
12
|
+
x_error_border: "rgba(255,111,0,1)",
|
|
13
|
+
x_blue_light: "rgba(54,129,198,1)",
|
|
14
|
+
x_blue_dark: "rgba(43,74,157,1)",
|
|
15
|
+
},
|
|
16
|
+
width: {
|
|
17
|
+
x_desktop: "600px",
|
|
18
|
+
x_mobile: "356px",
|
|
10
19
|
},
|
|
11
20
|
},
|
|
12
21
|
},
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import "@src/global.css";
|
|
2
|
-
import { Form } from "./Form";
|
|
3
|
-
import { CloseIcon } from "@src/components/icons/CloseIcon";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import ReactDOM from "react-dom";
|
|
6
|
-
|
|
7
|
-
const TxConfigForm = ({ isOpen, onClose, content }) => {
|
|
8
|
-
const onBackdropClick = (e) => {
|
|
9
|
-
e.stopPropagation();
|
|
10
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
11
|
-
if (e.target === e.currentTarget) {
|
|
12
|
-
onClose();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
if (!isOpen) return null;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className="top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10"
|
|
21
|
-
onClick={onBackdropClick}
|
|
22
|
-
>
|
|
23
|
-
<div className="relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]">
|
|
24
|
-
{content}
|
|
25
|
-
<div
|
|
26
|
-
className="absolute top-3.5 right-3 cursor-pointer text-white"
|
|
27
|
-
onClick={onClose}
|
|
28
|
-
>
|
|
29
|
-
<CloseIcon />
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
class TxConfigModalWrapper extends React.Component {
|
|
37
|
-
constructor(props) {
|
|
38
|
-
super(props);
|
|
39
|
-
this.state = { isOpen: false, content: "No wallet connected" };
|
|
40
|
-
this.closeModal = this.closeModal.bind(this);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
openModal(content) {
|
|
44
|
-
this.setState({ isOpen: true, content });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
closeModal() {
|
|
48
|
-
this.setState({ isOpen: false });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
render() {
|
|
52
|
-
return this.state.isOpen ? (
|
|
53
|
-
<TxConfigForm
|
|
54
|
-
isOpen={this.state.isOpen}
|
|
55
|
-
onClose={this.closeModal}
|
|
56
|
-
content={this.state.content}
|
|
57
|
-
/>
|
|
58
|
-
) : null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// skip on server-side integrations
|
|
63
|
-
let modalWrapperInstance;
|
|
64
|
-
if (typeof document !== "undefined") {
|
|
65
|
-
// Create a div element that will host the modal, and append it to the body
|
|
66
|
-
const modalDiv = document.createElement("div");
|
|
67
|
-
modalDiv.classList.add("xswap");
|
|
68
|
-
document.body.appendChild(modalDiv);
|
|
69
|
-
|
|
70
|
-
// // Render the ModalWrapper component into the modalDiv
|
|
71
|
-
modalWrapperInstance = ReactDOM.render(<TxConfigModalWrapper />, modalDiv);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export const openTxConfigForm = async ({
|
|
75
|
-
dstChainId,
|
|
76
|
-
dstTokenAddr,
|
|
77
|
-
customContractCalls,
|
|
78
|
-
desc,
|
|
79
|
-
supportedChains,
|
|
80
|
-
}) => {
|
|
81
|
-
try {
|
|
82
|
-
return await new Promise((resolve) => {
|
|
83
|
-
modalWrapperInstance.openModal(
|
|
84
|
-
<Form
|
|
85
|
-
dstChainId={dstChainId}
|
|
86
|
-
dstTokenAddr={dstTokenAddr}
|
|
87
|
-
customContractCalls={customContractCalls}
|
|
88
|
-
desc={desc}
|
|
89
|
-
supportedChains={supportedChains}
|
|
90
|
-
onSubmit={(route) => {
|
|
91
|
-
resolve(route);
|
|
92
|
-
modalWrapperInstance.closeModal();
|
|
93
|
-
}}
|
|
94
|
-
/>,
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
} catch (err) {
|
|
98
|
-
throw new Error(`User input failed, ${err}`);
|
|
99
|
-
}
|
|
100
|
-
};
|