astra-modal-test 1.0.10 → 1.0.12
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 +206 -134
- package/dist/{SwapController-DyormRqe.js → SwapController-mYFErPzx.js} +1 -1
- package/dist/{add-C1zIRxeS.js → add-CXtFvysR.js} +1 -1
- package/dist/{all-wallets-5a2U9fLw.js → all-wallets-B9fFXw5x.js} +1 -1
- package/dist/{app-store-2IKrZeLe.js → app-store-BXf1yvR8.js} +1 -1
- package/dist/{apple-DH9ESSKX.js → apple-DtcOcX1n.js} +1 -1
- package/dist/{arrow-bottom-BxAPS43J.js → arrow-bottom-BXeLKqSV.js} +1 -1
- package/dist/{arrow-bottom-circle-Cy5Gjca4.js → arrow-bottom-circle-BVUU200N.js} +1 -1
- package/dist/{arrow-left-CBX7JaHB.js → arrow-left-LguJPyNR.js} +1 -1
- package/dist/{arrow-right-G72bt1-M.js → arrow-right-D9kKZzGG.js} +1 -1
- package/dist/{arrow-top-DCkQG0Dq.js → arrow-top-C5JcaCqz.js} +1 -1
- package/dist/{bank-FNxAUs8r.js → bank-DgbCzr0A.js} +1 -1
- package/dist/{bin-B-c2CIPW.js → bin-ykHym2bC.js} +1 -1
- package/dist/{bitcoin-jk4NLDu1.js → bitcoin-B8jzy_uV.js} +1 -1
- package/dist/{browser-D6w0J78l.js → browser-Bk8u8PAA.js} +1 -1
- package/dist/{card-BLWRKU-r.js → card-DcwQMUca.js} +1 -1
- package/dist/ccip-CwJvuExU.js +239 -0
- package/dist/{checkmark-C1pTfaGr.js → checkmark-D3aEYZ8B.js} +1 -1
- package/dist/{checkmark-bold-UzogCu8g.js → checkmark-bold-5H7N-CDG.js} +1 -1
- package/dist/{chevron-bottom-w_rMAO7x.js → chevron-bottom-BA3C4MR1.js} +1 -1
- package/dist/{chevron-left-DGNJGxiP.js → chevron-left-BX18UWKM.js} +1 -1
- package/dist/{chevron-right-VFQCvCyG.js → chevron-right-DG7ovxTe.js} +1 -1
- package/dist/{chevron-top-DVhFmsKp.js → chevron-top-DHfev7lV.js} +1 -1
- package/dist/{chrome-store-BkYX3All.js → chrome-store-BSVzpGdu.js} +1 -1
- package/dist/{circle-B1A3j4eP.js → circle-SYFB9f2-.js} +1 -1
- package/dist/{clock-BKr-VHDU.js → clock-Cygqlf1g.js} +1 -1
- package/dist/{close-BEacRQ8Q.js → close-B43cuuko.js} +1 -1
- package/dist/{coinPlaceholder-0ZwtMAHl.js → coinPlaceholder-BHdR6bKb.js} +1 -1
- package/dist/{compass-pulK-BFi.js → compass-7S6b6wyA.js} +1 -1
- package/dist/{copy-MWCQE0T4.js → copy-CT53bEwd.js} +1 -1
- package/dist/{cursor-transparent-Co_5p0du.js → cursor-transparent-LmjzjsFm.js} +1 -1
- package/dist/{cursor-C2GVfUuM.js → cursor-vtqRnrF7.js} +1 -1
- package/dist/{desktop-C91EoSqM.js → desktop-Doa7TQsq.js} +1 -1
- package/dist/{disconnect-BWg1-rml.js → disconnect-C5G6Ncu_.js} +1 -1
- package/dist/{discord-Bi0Bfa_e.js → discord-DX7Cl3Ko.js} +1 -1
- package/dist/{email-U2WCRPFh.js → email-CyHWh9wL.js} +1 -1
- package/dist/{embedded-wallet-B6P0kU9A.js → embedded-wallet-BZQImi7s.js} +8 -8
- package/dist/{ethereum-BeZyayQW.js → ethereum-Bwvtk5-_.js} +1 -1
- package/dist/{etherscan-BQTsufjv.js → etherscan-CyVRICvw.js} +1 -1
- package/dist/{exclamation-triangle-JT-YKNXX.js → exclamation-triangle-BDbPL3nL.js} +1 -1
- package/dist/{extension-TnYLHoFA.js → extension-Cx3t2k-R.js} +1 -1
- package/dist/{external-link-Dhgai9sc.js → external-link-DZCYpOZI.js} +1 -1
- package/dist/{facebook-C6XFGRDw.js → facebook-BEnPrhG3.js} +1 -1
- package/dist/{farcaster-CvYbxZQq.js → farcaster-DyBPLb_k.js} +1 -1
- package/dist/{filters-DwVRjAav.js → filters-CTwxivn_.js} +1 -1
- package/dist/{github-BVZSx-z9.js → github-kzQb61pT.js} +1 -1
- package/dist/{google-NbJiQLc5.js → google-DSC-rYNu.js} +1 -1
- package/dist/{help-circle-Cum2UOMJ.js → help-circle-C5XfimVx.js} +1 -1
- package/dist/{id-kRR6YgVc.js → id-B9fQOT4E.js} +1 -1
- package/dist/{image-BWUCRAmp.js → image-1CCj36XM.js} +1 -1
- package/dist/{index-RFYbqmu0.js → index-Bjik7E9u.js} +1 -1
- package/dist/{index-DQ5AZLMt.js → index-C1fgrzi0.js} +16 -16
- package/dist/{index-BZZHE-1t.js → index-CyeGBcX0.js} +1 -1
- package/dist/{index-Dq0LIBEh.js → index-DKEMW9N8.js} +25 -25
- package/dist/{index-2vYoun4O.js → index-LucuShOc.js} +45292 -56275
- package/dist/{info-Br-SBtj3.js → info-Begf9tO0.js} +1 -1
- package/dist/{info-circle-Ew4RoR_Q.js → info-circle-Bo1H2OXh.js} +1 -1
- package/dist/{lightbulb-BRBVOE_b.js → lightbulb-C-SU_z2I.js} +1 -1
- package/dist/{mail-Dzi4AncY.js → mail-CXsYiNAT.js} +1 -1
- package/dist/{mobile-BGGxQ5be.js → mobile-C7bUjgog.js} +1 -1
- package/dist/{more-BmNaKbYJ.js → more-29BC-wmy.js} +1 -1
- package/dist/{network-placeholder-EMiMf4q1.js → network-placeholder-B-x3-6jN.js} +1 -1
- package/dist/{nftPlaceholder-CvSqy3Sd.js → nftPlaceholder-pM-Hmswq.js} +1 -1
- package/dist/nodeflow-sdk.es.js +15 -0
- package/dist/{off-DF9uz0Nc.js → off-DEa_uc7_.js} +1 -1
- package/dist/{onramp-cKzTmKku.js → onramp-ZXqyloYt.js} +10 -10
- package/dist/{play-store-CGxW4MgL.js → play-store-WgSEpEI1.js} +1 -1
- package/dist/{plus-CQ6wWkN0.js → plus-u4UZhYAg.js} +1 -1
- package/dist/{qr-code-VBqx9nAF.js → qr-code-DxZGxoPE.js} +1 -1
- package/dist/{receive-CVzkHmKR.js → receive-Ct_mQWzk.js} +1 -1
- package/dist/{recycle-horizontal-Oq1YtvUx.js → recycle-horizontal-BWVpmHJc.js} +1 -1
- package/dist/{refresh-BDlGAzmY.js → refresh-gi4TfgEU.js} +1 -1
- package/dist/{reown-logo-BlIpXIlG.js → reown-logo-Bg731n4w.js} +1 -1
- package/dist/{search-DfmCmp0m.js → search-BQv7DVJG.js} +1 -1
- package/dist/{send-BXudz514.js → send-BzmnFT2p.js} +1 -1
- package/dist/{send-Cz0L5LmE.js → send-CyxKtrQ9.js} +17 -17
- package/dist/{socials-CDOh8MRf.js → socials-vziOn4zi.js} +5 -5
- package/dist/{solana-CbiyOE-8.js → solana-Dz48awbr.js} +1 -1
- package/dist/{swapHorizontal-DyU1TH_e.js → swapHorizontal-Cwe1PoMp.js} +1 -1
- package/dist/{swapHorizontalBold-CGXW7Ocj.js → swapHorizontalBold-Dxu58sRG.js} +1 -1
- package/dist/{swapHorizontalMedium-2KTcj67d.js → swapHorizontalMedium-DOZZthlB.js} +1 -1
- package/dist/{swapHorizontalRoundedBold-TxFtmmda.js → swapHorizontalRoundedBold-BkIZQXnD.js} +1 -1
- package/dist/{swapVertical-BKD6lxM3.js → swapVertical-LSq66ctC.js} +1 -1
- package/dist/{swaps-BuGsEQaI.js → swaps-C2EO6dQA.js} +9 -9
- package/dist/{telegram-CAsl9DeG.js → telegram-ITq9s69Y.js} +1 -1
- package/dist/{three-dots-BoE2aHZi.js → three-dots-JH3A1TFR.js} +1 -1
- package/dist/{transactions-C1NtsnD6.js → transactions-DpMVZVap.js} +1 -1
- package/dist/{twitch-CvkZZxgT.js → twitch-BKs5FlDf.js} +1 -1
- package/dist/{twitterIcon-CrhnOl_O.js → twitterIcon-CCXEj_Nv.js} +1 -1
- package/dist/{ui-BJcuThPA.js → ui-D5ULRvGt.js} +6 -6
- package/dist/{user-BZRWUXG7.js → user-CBgAUjZv.js} +1 -1
- package/dist/{verify-y9F4DcJ4.js → verify-BPlPPkhG.js} +1 -1
- package/dist/{verify-filled-X_8-BhMk.js → verify-filled-qTRg0OWM.js} +1 -1
- package/dist/{w3m-modal-BX--v1Nc.js → w3m-modal-DSdDfy32.js} +27 -27
- package/dist/{wallet-CIaVVkjQ.js → wallet-BuDEi_8z.js} +1 -1
- package/dist/{wallet-placeholder-Cq1ofde1.js → wallet-placeholder-D4DKTuB_.js} +1 -1
- package/dist/{walletconnect-CINzSCJ3.js → walletconnect-Dt3q5XFc.js} +1 -1
- package/dist/{warning-circle-BvBNhMKH.js → warning-circle-B8Fkc0_4.js} +1 -1
- package/dist/{x-xHY7JehW.js → x-Cm_V3zUI.js} +1 -1
- package/dist/{x-mark-DEmnBt6u.js → x-mark-BVvwdxda.js} +1 -1
- package/package.json +11 -10
- package/.github/workflows/code-quality.yml +0 -43
- package/.github/workflows/publish.yml +0 -64
- package/dist/astra-sdk.es.js +0 -9
- package/dist/ccip-DkYvh7hg.js +0 -149
- package/dist/clsx.m-DCYaa4RU.js +0 -20
- package/dist/index-BDE-2VTp.js +0 -315
- package/dist/index-BjLIiJQa.js +0 -21034
- package/dist/index-CIr4zlVp.js +0 -386
- package/dist/index-ChxXyuZj.js +0 -572
- package/dist/index-D-T7kk3G.js +0 -15911
- package/dist/index-DSX3HrTS.js +0 -10785
- package/dist/secp256k1-CsKSDHNi.js +0 -1257
- package/eslint.config.mjs +0 -41
- package/index.html +0 -13
- package/public/font/ClashDisplay-Variable.ttf +0 -0
- package/public/font/ClashDisplay-Variable.woff +0 -0
- package/public/font/ClashDisplay-Variable.woff2 +0 -0
- package/public/vite.svg +0 -1
- package/src/App.css +0 -170
- package/src/apis/lspApi.js +0 -82
- package/src/apis/request.js +0 -59
- package/src/assets/arrow-right.svg +0 -3
- package/src/assets/astr.svg +0 -13
- package/src/assets/bridge-loading.png +0 -0
- package/src/assets/ln.png +0 -0
- package/src/assets/network/Arbitrum.png +0 -0
- package/src/assets/network/Polygon.png +0 -0
- package/src/assets/network/Solana.png +0 -0
- package/src/assets/network/base.png +0 -0
- package/src/assets/network/botanix.png +0 -0
- package/src/assets/network/bsc.svg +0 -13
- package/src/assets/network/eth.png +0 -0
- package/src/assets/network/lighting.png +0 -0
- package/src/assets/network/ligtning.svg +0 -22
- package/src/assets/network/solona.png +0 -0
- package/src/assets/pay.png +0 -0
- package/src/assets/powerby.svg +0 -14
- package/src/assets/react.svg +0 -1
- package/src/assets/success.svg +0 -3
- package/src/assets/tip.svg +0 -5
- 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 +0 -37
- package/src/comps/AstraModal.jsx +0 -202
- package/src/comps/AstraModalLogo.jsx +0 -29
- package/src/comps/AstraNetwork.jsx +0 -261
- package/src/comps/CheckErc20Button.jsx +0 -28
- package/src/comps/CommonStyle.jsx +0 -4
- package/src/comps/ConnectButton.jsx +0 -19
- package/src/comps/EllipsisMiddle.jsx +0 -42
- package/src/comps/ResultModal.jsx +0 -312
- package/src/comps/ToLightning.jsx +0 -653
- package/src/comps/ToToken.jsx +0 -550
- package/src/constants/index.js +0 -21
- 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 +0 -179
- package/src/hooks/useGetMinAndMax.js +0 -48
- package/src/hooks/useLspApi.js +0 -70
- package/src/hooks/useParseInvoice.js +0 -95
- package/src/index.css +0 -69
- package/src/index.jsx +0 -161
- package/src/lib/bolt11.min.js +0 -1
- package/src/main.jsx +0 -75
- package/src/store/index.js +0 -25
- package/src/theme.js +0 -108
- package/src/utils/index.js +0 -267
- package/vite.config.js +0 -50
package/src/main.jsx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
const projectId = "a9bfbd4c2e362787a57afa3c91acaf90";
|
|
13
|
-
|
|
14
|
-
const env = "development";
|
|
15
|
-
|
|
16
|
-
createRoot(document.getElementById("root")).render(
|
|
17
|
-
<StrictMode>
|
|
18
|
-
<AstraProvider projectId={projectId} env={env}>
|
|
19
|
-
<AstraModal />
|
|
20
|
-
<Button
|
|
21
|
-
onClick={() => {
|
|
22
|
-
astraReceive({
|
|
23
|
-
assetId: "rgb:kmbI~9N8-ruOAnr5-GXZ6ylm-ZhPrR3N-_PydETF-ZyC1jXQ",
|
|
24
|
-
invoice:
|
|
25
|
-
"lnbcrt30u1p5ksaf8dqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q22s0qvdeadh5pkey9q0kdedcuy27rad7pahcw0uzksjjp66r5ezwpp5q67767nnt3c4zhpcqyl53rlufrhjqwppknxdyqlzzsxv8gyzmt7ssp5cg3t22jhw3le5lg3njq5has498tjhtr3wm7s0eldn3fu7gyc9nsq9qyysgqcqpcxqrrsslz5wfnkywntd43yjl3efcuz6un4faqkuu3494r4sk3k09kx6t26dpg8y53nfck475rev3z4g33dtfu5xvt2tpgs7qzlgnzngfqzx9j6eu60hp0aws63f395j2uswczfm0kfsz9s3nr8tguqsczug0tfmddu8wcmqxstfwrqr5wd4nvkw6yexa200wezhuyw77jqprt54ga",
|
|
26
|
-
// assetId:
|
|
27
|
-
// "f7ac99f2c068f1157c787012f50cb043437505c309c6d8685e135cd8481b1e9d",
|
|
28
|
-
// invoice:
|
|
29
|
-
// "lnbcrt116692770p1p5k3qd3pp5rklehrt6f4x34qt8hxwy548kg7349paq3k5dnw7jrf0255rgkgpsdysf3hxv6fmv9ehxet5f9zr5e3hv93njwtxxf3nqd3cvccnzdfhvvmnsdesxyexvdfsvd3rqdpnxsenwdfsx43nxvpevvmxgwpk8q6k2vfnx43kgwp58qckyvt989jrkctdda6kuap6xycnydf6cqzzsxqrrssrzjqf7j7xl8rhpycc932pcy382w7f6d664vydks93nuwmtfxh00hft2dap8k2e8ayrtwsqqqqlgqqqqqqgq2qsp5wx26glsp5amuzh8vyl0jkrp7msfqeelwx2cuvxvtysa6my0gq50q9qxpqysgqcq5qg59ckhlrhn5zv49zza0skcqc0yeglthdc7kscz23r54w5zr9yvhnpwklqc6f0933ltr6kjvprnre2armdr5v7kaesgk2vd889ggpqsnepn",
|
|
30
|
-
});
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
emvToLightning
|
|
34
|
-
</Button>
|
|
35
|
-
<Button
|
|
36
|
-
onClick={() => {
|
|
37
|
-
astraSend({
|
|
38
|
-
assetId:
|
|
39
|
-
"6f9d461d71a18e623c46ceb54aa9602efeab2c137f459c94aec143c9ee5ea29d",
|
|
40
|
-
amount: 999,
|
|
41
|
-
});
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
lightningToEvm
|
|
45
|
-
</Button>
|
|
46
|
-
</AstraProvider>
|
|
47
|
-
{/* <AstraProvider projectId="92461524d3cfcb3d78b38b5dbd6a6ce3" apiUrl="https://devof-astralsp.unift.xyz/" env="development">
|
|
48
|
-
|
|
49
|
-
<AstraModal />
|
|
50
|
-
<Button
|
|
51
|
-
onClick={() => {
|
|
52
|
-
astraReceive({
|
|
53
|
-
assetId:
|
|
54
|
-
"5bd129d549bd68cad64f2c2db141732a523e4546a49662c390e8c14294aa7e84",
|
|
55
|
-
invoice:
|
|
56
|
-
"lnbcrt10u1pncsl97pp5d36zwsnr8zz4njssl8nzrf3uunjgayx0mtme8w9ahtk5a3lng37qdy0f3hxv6fmv9ehxet5f9zr5dtzvscnywtyx56rjcnyxcuxxctyxc6xvvnrxfjxyvf5xymnxvnpx5erxef5x56rvcf58ymrvvnrxvunqefcvvcngv3ex3skzdm98q6rkctdda6kuap6xycrqwscqzzsxqrrssrzjqg3zz9zaagxqxan9fqzr6k7yvf900uf26m0z7c2g0rf55raupqclpa040f0l30n4s5qqqqlgqqqqqqgq2qsp55qzcz8qgfhke67954whzlna58zlsc9s27g43jm32w7l09yr8n5gs9qxpqysgqx2aceldh9plumffk65j23rhuy6ers24p36uf9r9utc34rl85fw387xhtn6x3te50pvpkq3kyq6n4z55dezuz4u2txgm8cf6hnahdhpcp07k2cw",
|
|
57
|
-
});
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
Receive
|
|
61
|
-
</Button>
|
|
62
|
-
<Button
|
|
63
|
-
onClick={() => {
|
|
64
|
-
astraSend({
|
|
65
|
-
assetId:
|
|
66
|
-
"5bd129d549bd68cad64f2c2db141732a523e4546a49662c390e8c14294aa7e84",
|
|
67
|
-
amount: 10,
|
|
68
|
-
});
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
Send
|
|
72
|
-
</Button>
|
|
73
|
-
</AstraProvider> */}
|
|
74
|
-
</StrictMode>
|
|
75
|
-
);
|
package/src/store/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
};
|
package/src/utils/index.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import Decimal from "decimal.js";
|
|
2
|
-
import { BaseError as BaseViemError, stringToHex } from "viem";
|
|
3
|
-
import { sha256 } from "viem/utils";
|
|
4
|
-
import { getAssetPayReq } from "../apis/lspApi";
|
|
5
|
-
/* export const msatsToTprAsset = async (msats, asset_id) => {
|
|
6
|
-
try {
|
|
7
|
-
const response = await fetch(
|
|
8
|
-
`https://bridge-oracle.ln.exchange/napi/price/getOne?transactionType=1&subjectAssetId=${asset_id}&paymentAssetId=0000000000000000000000000000000000000000000000000000000000000000`
|
|
9
|
-
);
|
|
10
|
-
const ret = await response.json();
|
|
11
|
-
|
|
12
|
-
const coefficient = ret?.ok?.assetRates?.subjectAssetRate?.coefficient;
|
|
13
|
-
const scale = ret?.ok?.assetRates?.subjectAssetRate?.scale;
|
|
14
|
-
|
|
15
|
-
//const BTC_TO_USDT_RATE = new Decimal(coefficient).div(10 ** (scale + 8 + 3)).toNumber();
|
|
16
|
-
|
|
17
|
-
const priceOneUnit = new Decimal(coefficient).div(10 ** scale);
|
|
18
|
-
const satToUSDTValue = new Decimal(msats)
|
|
19
|
-
.div(10 ** (8 + 3))
|
|
20
|
-
.mul(priceOneUnit)
|
|
21
|
-
.toFixed(0);
|
|
22
|
-
|
|
23
|
-
return satToUSDTValue;
|
|
24
|
-
} catch (e) {
|
|
25
|
-
console.error(e.message);
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
}; */
|
|
29
|
-
|
|
30
|
-
export const formatAssetByDecimal = (value, decimal) => {
|
|
31
|
-
return new Decimal(value).div(10 ** decimal).toFixed(decimal);
|
|
32
|
-
};
|
|
33
|
-
export function numberWithCommas(x) {
|
|
34
|
-
if (!x && x != 0) {
|
|
35
|
-
return "0";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var parts = x.toString().split(".");
|
|
39
|
-
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
40
|
-
return parts.join(".");
|
|
41
|
-
}
|
|
42
|
-
export function sleep(time = 1000) {
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
resolve(true);
|
|
46
|
-
}, time);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
export const getParsedError = (e) => {
|
|
50
|
-
let message = e.message ?? "An unknown error occurred";
|
|
51
|
-
if (e instanceof BaseViemError) {
|
|
52
|
-
if (e.details) {
|
|
53
|
-
message = e.details;
|
|
54
|
-
} else if (e.shortMessage) {
|
|
55
|
-
message = e.shortMessage;
|
|
56
|
-
const cause = e.cause;
|
|
57
|
-
// if its not generic error, append custom error name and its args to message
|
|
58
|
-
if (cause?.data && cause.data?.abiItem?.name !== "Error") {
|
|
59
|
-
const customErrorArgs = cause.data.args?.toString() ?? "";
|
|
60
|
-
message = `${message.replace(
|
|
61
|
-
/reverted\.$/,
|
|
62
|
-
"reverted with following reason:"
|
|
63
|
-
)}\n${cause.data.errorName}(${customErrorArgs})`;
|
|
64
|
-
}
|
|
65
|
-
} else if (e.message) {
|
|
66
|
-
message = e.message;
|
|
67
|
-
} else if (e.name) {
|
|
68
|
-
message = e.name;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return message;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const toBytes32 = (value) => {
|
|
76
|
-
const inputValue = value.startsWith("0x")
|
|
77
|
-
? value
|
|
78
|
-
: /^[0-9a-fA-F]+$/.test(value)
|
|
79
|
-
? "0x" + value
|
|
80
|
-
: value;
|
|
81
|
-
|
|
82
|
-
const dataToHash = /^0x[0-9a-fA-F]+$/.test(inputValue)
|
|
83
|
-
? inputValue
|
|
84
|
-
: stringToHex(inputValue);
|
|
85
|
-
|
|
86
|
-
const hash = sha256(dataToHash);
|
|
87
|
-
|
|
88
|
-
return hash;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* 解析 Lightning Invoice,获取资产信息
|
|
92
|
-
* 使用后端 assetPayReq API 自动识别资产类型(RGB、Taproot Asset 或 BTC)
|
|
93
|
-
* @param {string} payReq - Lightning Invoice 字符串
|
|
94
|
-
* @param {string} assetId - 可选,指定资产 ID。如果不传入,后端会自动识别
|
|
95
|
-
* @returns {Promise<{amount: string, assetId: string, decimal: number}>}
|
|
96
|
-
*/
|
|
97
|
-
export const invoiceToAssetInfo = async ({ payReq, assetId }) => {
|
|
98
|
-
try {
|
|
99
|
-
// 调用后端 API,后端会自动识别资产类型(RGB/Taproot/BTC)
|
|
100
|
-
const ret = await getAssetPayReq({ payReq: payReq, assetId: assetId });
|
|
101
|
-
const { amount, decimal, asset_id } = ret.data;
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
amount: amount, // 使用后端返回的精确金额
|
|
105
|
-
assetId: asset_id || assetId, // 优先使用后端返回的 asset_id(支持自动识别)
|
|
106
|
-
decimal: decimal,
|
|
107
|
-
};
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error("Failed to parse invoice:", error);
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* 校验资产是否在交易对列表中支持
|
|
115
|
-
* @param {string} assetId - 资产 ID(如 BTC、Taproot Asset ID、RGB Asset ID)
|
|
116
|
-
* @param {Array} allAssetPairs - 所有交易对列表
|
|
117
|
-
* @returns {{isSupported: boolean, supportedPairs: Array, error: string|null}}
|
|
118
|
-
*/
|
|
119
|
-
export function validateAssetSupport(assetId, allAssetPairs) {
|
|
120
|
-
if (!assetId) {
|
|
121
|
-
return {
|
|
122
|
-
isSupported: false,
|
|
123
|
-
supportedPairs: [],
|
|
124
|
-
error: "Asset ID is required",
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!allAssetPairs || allAssetPairs.length === 0) {
|
|
129
|
-
return {
|
|
130
|
-
isSupported: false,
|
|
131
|
-
supportedPairs: [],
|
|
132
|
-
error: "No trading pairs available. Please wait for pairs to load.",
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 查找支持该 asset_id 的交易对
|
|
137
|
-
const supportedPairs = allAssetPairs.filter(
|
|
138
|
-
(pair) => pair?.asset?.assetId === assetId
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
if (supportedPairs.length === 0) {
|
|
142
|
-
const supportedAssetIds = allAssetPairs
|
|
143
|
-
.map((pair) => pair?.asset?.assetId)
|
|
144
|
-
.filter(Boolean);
|
|
145
|
-
return {
|
|
146
|
-
isSupported: false,
|
|
147
|
-
supportedPairs: [],
|
|
148
|
-
error: `Asset "${assetId}" is not supported. Supported assets: ${supportedAssetIds.join(", ")}`,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
isSupported: true,
|
|
154
|
-
supportedPairs,
|
|
155
|
-
error: null,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* 校验 token 地址是否在交易对列表中支持
|
|
161
|
-
* @param {string} tokenAddress - Token 合约地址
|
|
162
|
-
* @param {Array} allAssetPairs - 所有交易对列表
|
|
163
|
-
* @returns {{isSupported: boolean, supportedPairs: Array, error: string|null}}
|
|
164
|
-
*/
|
|
165
|
-
export function validateTokenSupport(tokenAddress, allAssetPairs) {
|
|
166
|
-
if (!tokenAddress) {
|
|
167
|
-
return {
|
|
168
|
-
isSupported: false,
|
|
169
|
-
supportedPairs: [],
|
|
170
|
-
error: "Token address is required",
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!allAssetPairs || allAssetPairs.length === 0) {
|
|
175
|
-
return {
|
|
176
|
-
isSupported: false,
|
|
177
|
-
supportedPairs: [],
|
|
178
|
-
error: "No trading pairs available. Please wait for pairs to load.",
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// 查找支持该 token 地址的交易对(不区分大小写)
|
|
183
|
-
const normalizedAddress = tokenAddress.toLowerCase();
|
|
184
|
-
const supportedPairs = allAssetPairs.filter(
|
|
185
|
-
(pair) => pair?.token?.address?.toLowerCase() === normalizedAddress
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
if (supportedPairs.length === 0) {
|
|
189
|
-
const supportedTokens = allAssetPairs
|
|
190
|
-
.map((pair) => pair?.token?.address)
|
|
191
|
-
.filter(Boolean);
|
|
192
|
-
return {
|
|
193
|
-
isSupported: false,
|
|
194
|
-
supportedPairs: [],
|
|
195
|
-
error: `Token "${tokenAddress}" is not supported. Supported tokens: ${supportedTokens.join(", ")}`,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
isSupported: true,
|
|
201
|
-
supportedPairs,
|
|
202
|
-
error: null,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export function balanceToFixed(balance, decimals) {
|
|
207
|
-
const fixedBalance = balance
|
|
208
|
-
? new Decimal(balance)
|
|
209
|
-
.div(10 ** decimals)
|
|
210
|
-
.toFixed(decimals, Decimal.ROUND_DOWN)
|
|
211
|
-
.toString()
|
|
212
|
-
: 0;
|
|
213
|
-
return fixedBalance;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* @deprecated 此函数已废弃,建议使用 invoiceToAssetInfo 代替
|
|
217
|
-
* 提取 invoice 中的资产信息(从 memo/description 解析)
|
|
218
|
-
*
|
|
219
|
-
* 废弃原因:
|
|
220
|
-
* 1. 依赖 memo 格式,不够稳定
|
|
221
|
-
* 2. 无法支持 RGB 资产
|
|
222
|
-
* 3. 后端 API 已支持自动识别资产类型,更准确
|
|
223
|
-
*
|
|
224
|
-
* @param {string} inputString - invoice description 字符串
|
|
225
|
-
* @returns {{assetID: string|null, amount: string|null}}
|
|
226
|
-
*/
|
|
227
|
-
export function extractAssetInfo(inputString) {
|
|
228
|
-
console.warn("⚠️ extractAssetInfo is deprecated. Use invoiceToAssetInfo instead.");
|
|
229
|
-
|
|
230
|
-
const result = {
|
|
231
|
-
assetID: null,
|
|
232
|
-
amount: null,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
if (!inputString) {
|
|
236
|
-
return result; // Handle empty/null input
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// --- Extract assetID ---
|
|
240
|
-
// Regex looks for "assetID:" followed by capturing non-semicolon characters
|
|
241
|
-
const assetIDMatch = inputString.match(/assetID:([^;]+)/);
|
|
242
|
-
if (assetIDMatch && assetIDMatch[1]) {
|
|
243
|
-
// Get the captured value (group 1)
|
|
244
|
-
let value = assetIDMatch[1].trim();
|
|
245
|
-
// Remove potential trailing colon
|
|
246
|
-
if (value.endsWith(":")) {
|
|
247
|
-
value = value.slice(0, -1);
|
|
248
|
-
}
|
|
249
|
-
result.assetID = value;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// --- Extract amount ---
|
|
253
|
-
// Regex looks for "amount:" followed by capturing non-semicolon characters
|
|
254
|
-
const amountMatch = inputString.match(/amount:([^;]+)/);
|
|
255
|
-
if (amountMatch && amountMatch[1]) {
|
|
256
|
-
// Get the captured value (group 1)
|
|
257
|
-
let value = amountMatch[1].trim();
|
|
258
|
-
// Remove potential trailing colon
|
|
259
|
-
if (value.endsWith(":")) {
|
|
260
|
-
value = value.slice(0, -1);
|
|
261
|
-
}
|
|
262
|
-
result.amount = value;
|
|
263
|
-
// Optional number conversion can be done here
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return result;
|
|
267
|
-
}
|
package/vite.config.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
formats: ['es']
|
|
13
|
-
},
|
|
14
|
-
rollupOptions: {
|
|
15
|
-
external: ['react', 'react-dom', 'antd', 'ahooks', 'axios', 'decimal.js', '@ant-design/icons'],
|
|
16
|
-
output: {
|
|
17
|
-
exports: "named",
|
|
18
|
-
format: 'esm',
|
|
19
|
-
preserveModules: false,
|
|
20
|
-
inlineDynamicImports: false,
|
|
21
|
-
globals: {
|
|
22
|
-
react: 'React',
|
|
23
|
-
'react-dom': 'ReactDOM',
|
|
24
|
-
antd: 'antd',
|
|
25
|
-
'@ant-design/icons': 'icons',
|
|
26
|
-
'decimal.js': 'Decimal',
|
|
27
|
-
ahooks: 'ahooks',
|
|
28
|
-
axios: 'axios',
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
plugins: [
|
|
35
|
-
react(),
|
|
36
|
-
nodePolyfills({
|
|
37
|
-
protocolImports: true,
|
|
38
|
-
exclude: ["stream", "crypto"]
|
|
39
|
-
}),
|
|
40
|
-
createStyleImportPlugin({
|
|
41
|
-
libs: [
|
|
42
|
-
{
|
|
43
|
-
libraryName: 'antd',
|
|
44
|
-
esModule: true,
|
|
45
|
-
resolveStyle: (name) => `antd/es/${name}/style/index.js`,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
}),
|
|
49
|
-
],
|
|
50
|
-
});
|