astra-modal-test 1.0.0
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/README.md +0 -0
- package/dist/astra-sdk.es.js +8 -0
- package/dist/astra-sdk.umd.js +12576 -0
- package/dist/ccip-Bpb4GlU6.mjs +146 -0
- package/dist/hooks.module-BBZfodGH.mjs +506 -0
- package/dist/index-BTsa09iy.mjs +84805 -0
- package/dist/index-CEtKkuP2.mjs +133 -0
- package/dist/index-CbWGAz3l.mjs +445 -0
- package/dist/index-DRPxIWUd.mjs +13720 -0
- package/dist/index-h9_6XS0r.mjs +2929 -0
- package/dist/secp256k1-3OC5y4qp.mjs +1578 -0
- package/dist/vite.svg +1 -0
- package/dist/w3m-modal-R9m1z1SQ.mjs +267 -0
- package/eslint.config.js +39 -0
- package/index.html +13 -0
- package/package.json +50 -0
- package/public/vite.svg +1 -0
- package/src/App.css +170 -0
- package/src/apis/lspApi.js +59 -0
- package/src/apis/request.js +59 -0
- package/src/assets/arrow-right.svg +3 -0
- package/src/assets/astr.svg +13 -0
- package/src/assets/bridge-loading.png +0 -0
- package/src/assets/network/base.png +0 -0
- package/src/assets/network/eth.png +0 -0
- package/src/assets/network/lighting.png +0 -0
- package/src/assets/network/ligtning.svg +22 -0
- package/src/assets/network/solona.png +0 -0
- package/src/assets/powerby.svg +14 -0
- package/src/assets/react.svg +1 -0
- package/src/assets/success.svg +3 -0
- package/src/assets/tip.svg +5 -0
- package/src/assets/tokens/sol.png +0 -0
- package/src/assets/tokens/usdc.png +0 -0
- package/src/assets/tokens/usdt.png +0 -0
- package/src/comps/AstraImage.jsx +23 -0
- package/src/comps/AstraModal.jsx +207 -0
- package/src/comps/AstraModalLogo.jsx +53 -0
- package/src/comps/AstraNetwork.jsx +115 -0
- package/src/comps/CheckErc20Button.jsx +28 -0
- package/src/comps/ConnectButton.jsx +37 -0
- package/src/comps/EllipsisMiddle.jsx +42 -0
- package/src/comps/ResultModal.jsx +307 -0
- package/src/comps/ToLightning.jsx +502 -0
- package/src/comps/ToToken.jsx +467 -0
- package/src/constants/contracts/abi/bridge.js +1246 -0
- package/src/constants/contracts/abi/index.js +3 -0
- package/src/constants/contracts/abi/usdt.js +130 -0
- package/src/constants/contracts/abi/watcher.js +523 -0
- package/src/constants/contracts/index.js +37 -0
- package/src/constants/index.js +5 -0
- package/src/font/ClashDisplay-Variable.ttf +0 -0
- package/src/font/ClashDisplay-Variable.woff +0 -0
- package/src/font/ClashDisplay-Variable.woff2 +0 -0
- package/src/hooks/useContract.js +127 -0
- package/src/hooks/useLspApi.js +53 -0
- package/src/hooks/useParseInvoice.js +85 -0
- package/src/index.css +69 -0
- package/src/index.jsx +112 -0
- package/src/lib/bolt11.min.js +1 -0
- package/src/main.jsx +41 -0
- package/src/store/index.js +25 -0
- package/src/theme.js +108 -0
- package/src/utils/index.js +36 -0
- package/vite.config.js +44 -0
package/src/main.jsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { Button } from "antd";
|
|
4
|
+
import "./App.css";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
import AstraProvider, {
|
|
7
|
+
AstraModal,
|
|
8
|
+
astraSend,
|
|
9
|
+
astraReceive,
|
|
10
|
+
} from "./index.jsx";
|
|
11
|
+
|
|
12
|
+
createRoot(document.getElementById("root")).render(
|
|
13
|
+
<StrictMode>
|
|
14
|
+
<AstraProvider projectId="92461524d3cfcb3d78b38b5dbd6a6ce3">
|
|
15
|
+
<AstraModal astraApiUri="https://devof-astralsp.unift.xyz/" />
|
|
16
|
+
<Button
|
|
17
|
+
onClick={() => {
|
|
18
|
+
astraReceive({
|
|
19
|
+
assetId:
|
|
20
|
+
"23b5c71c64a4d58735d43cdd8272939c367f3104e6d37782af347d99d7b99fb1",
|
|
21
|
+
invoice:
|
|
22
|
+
"lnbcrt10630900p1pnk4xy4pp53w8esm6mquekyn9gh65twfkrtf73zpn624lcm2gt07mzxamkxmyqdy0f3hxv6fmv9ehxet5f9zr5dtzvscnywtyx56rjcnyxcuxxctyxc6xvvnrxfjxyvf5xymnxvnpx5erxef5x56rvcf58ymrvvnrxvunqefcvvcngv3ex3skzdm98q6rkctdda6kuap6xycrqwscqzzsxqrrssrzjqg3zz9zaagxqxan9fqzr6k7yvf900uf26m0z7c2g0rf55raupqclpa6u4xvgrtgmxsqqqqlgqqqqqqgq2qsp5wcrmfqfvm4hpqac4pwzvwqpsnm2qddymqrskjhpst7ecpss9rtds9qxpqysgqm46zhst2htl432nu52v8rlfq0zzxzg3xyx7dc9yv23yy2zjxef9ppyqhy2le30perfr3p504k208f34pg859f6ggjkqgrsurk6sjaggpea0ylp",
|
|
23
|
+
});
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
Receive
|
|
27
|
+
</Button>
|
|
28
|
+
<Button
|
|
29
|
+
onClick={() => {
|
|
30
|
+
astraSend({
|
|
31
|
+
assetId:
|
|
32
|
+
"23b5c71c64a4d58735d43cdd8272939c367f3104e6d37782af347d99d7b99fb1",
|
|
33
|
+
amount: 1,
|
|
34
|
+
});
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
Send
|
|
38
|
+
</Button>
|
|
39
|
+
</AstraProvider>
|
|
40
|
+
</StrictMode>
|
|
41
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { MODAL_DISPLAY_TYPE } from "../constants";
|
|
3
|
+
const useStore = create((set) => ({
|
|
4
|
+
astraApiUrl: "",
|
|
5
|
+
setAstrApiUrl: (url) => set({ astraApiUrl: url }),
|
|
6
|
+
targetNetwork: null,
|
|
7
|
+
setTargetNetwork: (network) => set({ targetNetwork: network }),
|
|
8
|
+
currentAssetPair: null,
|
|
9
|
+
setCurrentAssetPair: (pair) => set({ currentAssetPair: pair }),
|
|
10
|
+
allAssetPairs: [],
|
|
11
|
+
setAllAssetPairs: (pairs) => set({ allAssetPairs: pairs }),
|
|
12
|
+
astraModalShow: false,
|
|
13
|
+
setAstraModalShow: (show) => set({ astraModalShow: show }),
|
|
14
|
+
receiveArgs: null,
|
|
15
|
+
setReceiveArgs: (args) => set({ receiveArgs: args }),
|
|
16
|
+
sendArgs: null,
|
|
17
|
+
setSendArgs: (args) => set({ sendArgs: args }),
|
|
18
|
+
modalDisplayType: MODAL_DISPLAY_TYPE.DEFAULT,
|
|
19
|
+
setModalDisplayType: (type) => set({ modalDisplayType: type }),
|
|
20
|
+
onAstraInvoice: null,
|
|
21
|
+
wagmiAdapter: null,
|
|
22
|
+
setWagmiAdapter: (adapter) => set({ wagmiAdapter: adapter })
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
export default useStore;
|
package/src/theme.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export const themeConfig = {
|
|
2
|
+
token: {
|
|
3
|
+
colorPrimary: "#caff33",
|
|
4
|
+
colorInfo: "#caff33",
|
|
5
|
+
fontSize: 16,
|
|
6
|
+
sizeStep: 4,
|
|
7
|
+
borderRadius: 10,
|
|
8
|
+
},
|
|
9
|
+
components: {
|
|
10
|
+
Form: {
|
|
11
|
+
controlHeight: 32,
|
|
12
|
+
controlHeightSM: 32,
|
|
13
|
+
},
|
|
14
|
+
Button: {
|
|
15
|
+
defaultBg: "transparent",
|
|
16
|
+
defaultColor: "rgb(202,255,51)",
|
|
17
|
+
primaryColor: "rgba(26, 26, 26, 1)",
|
|
18
|
+
colorPrimary: "rgba(202, 255, 51, 1)",
|
|
19
|
+
colorPrimaryActive: "rgba(202, 255, 51, 1)",
|
|
20
|
+
colorPrimaryHover: "rgba(202, 255, 51, 1)",
|
|
21
|
+
defaultHoverBg: "rgba(202, 255, 51, 1)",
|
|
22
|
+
defaultHoverColor: "rgb(4, 16, 17)",
|
|
23
|
+
defaultActiveBg: "rgba(202, 255, 51, 1)",
|
|
24
|
+
defaultActiveColor: "rgb(4, 16, 17)",
|
|
25
|
+
paddingBlock: 0,
|
|
26
|
+
paddingBlockSM: 0,
|
|
27
|
+
paddingInline: 12,
|
|
28
|
+
contentFontSize: 14,
|
|
29
|
+
contentFontSizeSM: 12,
|
|
30
|
+
controlHeight: 44,
|
|
31
|
+
controlHeightSM: 32,
|
|
32
|
+
borderRadius: 12,
|
|
33
|
+
contentLineHeight: 0,
|
|
34
|
+
borderRadiusSM: 24,
|
|
35
|
+
paddingInlineSM: 12,
|
|
36
|
+
defaultBorderColor: "rgb(202,255,51)",
|
|
37
|
+
defaultGhostColor: "rgb(202,255,51)",
|
|
38
|
+
defaultGhostBorderColor: "rgb(202,255,51)",
|
|
39
|
+
},
|
|
40
|
+
Select: {
|
|
41
|
+
controlHeight: 32,
|
|
42
|
+
borderRadius: 32,
|
|
43
|
+
borderRadiusLG: 6,
|
|
44
|
+
colorBorder: "rgb(62, 67, 66)",
|
|
45
|
+
colorPrimary: "#67BE6A",
|
|
46
|
+
colorPrimaryHover: "#67BE6A",
|
|
47
|
+
singleItemHeightLG: 32,
|
|
48
|
+
controlHeightLG: 32,
|
|
49
|
+
fontSizeSM: 14,
|
|
50
|
+
controlHeightSM: 32,
|
|
51
|
+
borderRadiusSM: 6,
|
|
52
|
+
paddingSM: 12,
|
|
53
|
+
selectorBg: "transparent",
|
|
54
|
+
algorithm: false,
|
|
55
|
+
},
|
|
56
|
+
Input: {
|
|
57
|
+
colorBgContainer: "transparent",
|
|
58
|
+
controlHeight: 32,
|
|
59
|
+
controlHeightLG: 48,
|
|
60
|
+
controlHeightSM: 32,
|
|
61
|
+
borderRadius: 32,
|
|
62
|
+
borderRadiusLG: 32,
|
|
63
|
+
borderRadiusSM: 24,
|
|
64
|
+
paddingInline: 16,
|
|
65
|
+
paddingInlineSM: 16,
|
|
66
|
+
hoverBorderColor: "rgb(255, 252, 228)",
|
|
67
|
+
algorithm: false,
|
|
68
|
+
},
|
|
69
|
+
InputNumber: {
|
|
70
|
+
paddingInline: 12,
|
|
71
|
+
colorBgContainer: "transparent",
|
|
72
|
+
controlHeight: 32,
|
|
73
|
+
controlHeightLG: 48,
|
|
74
|
+
borderRadius: 32,
|
|
75
|
+
borderRadiusLG: 32,
|
|
76
|
+
hoverBorderColor: "rgb(255, 252, 228)",
|
|
77
|
+
algorithm: false,
|
|
78
|
+
},
|
|
79
|
+
Radio: {
|
|
80
|
+
controlHeight: 32,
|
|
81
|
+
borderRadius: 32,
|
|
82
|
+
algorithm: false,
|
|
83
|
+
colorBgContainer: "transparent",
|
|
84
|
+
},
|
|
85
|
+
DatePicker: {
|
|
86
|
+
colorBgContainer: "transparent",
|
|
87
|
+
controlHeight: 32,
|
|
88
|
+
controlHeightLG: 32,
|
|
89
|
+
borderRadius: 32,
|
|
90
|
+
borderRadiusLG: 32,
|
|
91
|
+
paddingInline: 12,
|
|
92
|
+
},
|
|
93
|
+
List: {
|
|
94
|
+
borderRadius: 0,
|
|
95
|
+
},
|
|
96
|
+
Tooltip: {
|
|
97
|
+
colorBgSpotlight: "rgb(19, 33, 40)",
|
|
98
|
+
},
|
|
99
|
+
Popover: {
|
|
100
|
+
colorBgElevated: "rgb(19, 33, 40)",
|
|
101
|
+
},
|
|
102
|
+
Dropdown: {
|
|
103
|
+
colorBgElevated: "rgb(19, 33, 40)",
|
|
104
|
+
colorPrimaryBorder: "rgb(62, 67, 66)",
|
|
105
|
+
controlItemBgHover: "rgb(4, 16, 17)",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
export const msatsToTprAsset = async (msats, asset_id) => {
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(
|
|
6
|
+
`https://oracle.ln.exchange/napi/price/getOne?transactionType=1&subjectAssetId=${asset_id}&paymentAssetId=0000000000000000000000000000000000000000000000000000000000000000`,
|
|
7
|
+
);
|
|
8
|
+
const ret = await response.json();
|
|
9
|
+
|
|
10
|
+
const coefficient = ret?.ok?.assetRates?.subjectAssetRate?.coefficient;
|
|
11
|
+
const scale = ret?.ok?.assetRates?.subjectAssetRate?.scale;
|
|
12
|
+
|
|
13
|
+
//const BTC_TO_USDT_RATE = new Decimal(coefficient).div(10 ** (scale + 8 + 3)).toNumber();
|
|
14
|
+
|
|
15
|
+
const priceOneUnit = new Decimal(coefficient).div(10 ** scale)
|
|
16
|
+
const satToUSDTValue = new Decimal(msats).div(10 ** (8 + 3)).mul(priceOneUnit).toFixed(0)
|
|
17
|
+
|
|
18
|
+
return satToUSDTValue;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e.message);
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const formatAssetByDecimal = (value, decimal) => {
|
|
26
|
+
return new Decimal(value).div(10 ** decimal).toFixed(decimal)
|
|
27
|
+
}
|
|
28
|
+
export function numberWithCommas(x) {
|
|
29
|
+
if (!x && x != 0) {
|
|
30
|
+
return "0";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var parts = x.toString().split(".");
|
|
34
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
35
|
+
return parts.join(".");
|
|
36
|
+
}
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
|
+
import { createStyleImportPlugin } from 'vite-plugin-style-import';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: 'src/index.jsx',
|
|
10
|
+
name: 'astra-sdk',
|
|
11
|
+
fileName: (format) => `astra-sdk.${format}.js`,
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: ['react', 'react-dom', 'antd', 'ahooks', 'axios', 'decimal.js', '@ant-design/icons'],
|
|
15
|
+
output: {
|
|
16
|
+
globals: {
|
|
17
|
+
react: 'React',
|
|
18
|
+
'react-dom': 'ReactDOM',
|
|
19
|
+
antd: 'antd',
|
|
20
|
+
'@ant-design/icons': 'icons',
|
|
21
|
+
'decimal.js': 'Decimal',
|
|
22
|
+
ahooks: 'ahooks',
|
|
23
|
+
axios: 'axios',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
plugins: [
|
|
29
|
+
react(),
|
|
30
|
+
nodePolyfills({
|
|
31
|
+
protocolImports: true,
|
|
32
|
+
exclude: ["stream", "crypto"]
|
|
33
|
+
}),
|
|
34
|
+
createStyleImportPlugin({
|
|
35
|
+
libs: [
|
|
36
|
+
{
|
|
37
|
+
libraryName: 'antd',
|
|
38
|
+
esModule: true,
|
|
39
|
+
resolveStyle: (name) => `antd/es/${name}/style/index.js`,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|