astra-modal-test 1.0.10 → 1.0.11

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.
Files changed (167) hide show
  1. package/README.md +118 -148
  2. package/dist/{SwapController-DyormRqe.js → SwapController-Ck3TYcMp.js} +1 -1
  3. package/dist/{add-C1zIRxeS.js → add-BmBLHIEe.js} +1 -1
  4. package/dist/{all-wallets-5a2U9fLw.js → all-wallets-H2aaJ2oP.js} +1 -1
  5. package/dist/{app-store-2IKrZeLe.js → app-store-Bvhe1BkA.js} +1 -1
  6. package/dist/{apple-DH9ESSKX.js → apple-BCIKns5c.js} +1 -1
  7. package/dist/{arrow-bottom-circle-Cy5Gjca4.js → arrow-bottom-circle-Dpcn0z0p.js} +1 -1
  8. package/dist/{arrow-bottom-BxAPS43J.js → arrow-bottom-i1ChNkSf.js} +1 -1
  9. package/dist/{arrow-left-CBX7JaHB.js → arrow-left-Dj8tzUf6.js} +1 -1
  10. package/dist/{arrow-right-G72bt1-M.js → arrow-right-DVd3R-0K.js} +1 -1
  11. package/dist/{arrow-top-DCkQG0Dq.js → arrow-top-DcD5wbZL.js} +1 -1
  12. package/dist/astra-sdk.es.js +1 -1
  13. package/dist/{bank-FNxAUs8r.js → bank-CToLOTy3.js} +1 -1
  14. package/dist/{bin-B-c2CIPW.js → bin-D8m48Dk5.js} +1 -1
  15. package/dist/{bitcoin-jk4NLDu1.js → bitcoin-y6S4LO0p.js} +1 -1
  16. package/dist/{browser-D6w0J78l.js → browser-DRhVaQQT.js} +1 -1
  17. package/dist/{card-BLWRKU-r.js → card-BK0q3S4W.js} +1 -1
  18. package/dist/{ccip-DkYvh7hg.js → ccip-CH1B6Zeh.js} +1 -1
  19. package/dist/{checkmark-C1pTfaGr.js → checkmark-C7H1vH4H.js} +1 -1
  20. package/dist/{checkmark-bold-UzogCu8g.js → checkmark-bold-DfvIWKpu.js} +1 -1
  21. package/dist/{chevron-bottom-w_rMAO7x.js → chevron-bottom-CcAEP6cD.js} +1 -1
  22. package/dist/{chevron-left-DGNJGxiP.js → chevron-left-DMnhSBVl.js} +1 -1
  23. package/dist/{chevron-right-VFQCvCyG.js → chevron-right-pPhw9ZBC.js} +1 -1
  24. package/dist/{chevron-top-DVhFmsKp.js → chevron-top-DjqOCRAL.js} +1 -1
  25. package/dist/{chrome-store-BkYX3All.js → chrome-store-B-9bRAPM.js} +1 -1
  26. package/dist/{circle-B1A3j4eP.js → circle-SPbxfVZq.js} +1 -1
  27. package/dist/{clock-BKr-VHDU.js → clock-BLAT4wv4.js} +1 -1
  28. package/dist/{close-BEacRQ8Q.js → close-D1AyyJzy.js} +1 -1
  29. package/dist/{coinPlaceholder-0ZwtMAHl.js → coinPlaceholder-DGk1in74.js} +1 -1
  30. package/dist/{compass-pulK-BFi.js → compass-C0-SVkSt.js} +1 -1
  31. package/dist/{copy-MWCQE0T4.js → copy-CPcvwITz.js} +1 -1
  32. package/dist/{cursor-C2GVfUuM.js → cursor-ChlOWEcO.js} +1 -1
  33. package/dist/{cursor-transparent-Co_5p0du.js → cursor-transparent-BJsEpe-G.js} +1 -1
  34. package/dist/{desktop-C91EoSqM.js → desktop-Z8iZvVCW.js} +1 -1
  35. package/dist/{disconnect-BWg1-rml.js → disconnect-DkPQjiLk.js} +1 -1
  36. package/dist/{discord-Bi0Bfa_e.js → discord-CwRdgvGZ.js} +1 -1
  37. package/dist/{email-U2WCRPFh.js → email-DA_5xt-j.js} +1 -1
  38. package/dist/{embedded-wallet-B6P0kU9A.js → embedded-wallet-DYnGl5tL.js} +1 -1
  39. package/dist/{ethereum-BeZyayQW.js → ethereum-Dwse3Umc.js} +1 -1
  40. package/dist/{etherscan-BQTsufjv.js → etherscan-CNmwyrRn.js} +1 -1
  41. package/dist/{exclamation-triangle-JT-YKNXX.js → exclamation-triangle-CU8gn-bU.js} +1 -1
  42. package/dist/{extension-TnYLHoFA.js → extension-rikwXWrg.js} +1 -1
  43. package/dist/{external-link-Dhgai9sc.js → external-link-mDp8JVE0.js} +1 -1
  44. package/dist/{facebook-C6XFGRDw.js → facebook-c0IS1D9G.js} +1 -1
  45. package/dist/{farcaster-CvYbxZQq.js → farcaster-DpvSDnGl.js} +1 -1
  46. package/dist/{filters-DwVRjAav.js → filters-B42-1BLn.js} +1 -1
  47. package/dist/{github-BVZSx-z9.js → github-DvjZxkXF.js} +1 -1
  48. package/dist/{google-NbJiQLc5.js → google-CLHf_zAz.js} +1 -1
  49. package/dist/{help-circle-Cum2UOMJ.js → help-circle-BI5xgPAz.js} +1 -1
  50. package/dist/{id-kRR6YgVc.js → id-BxI79dX4.js} +1 -1
  51. package/dist/{image-BWUCRAmp.js → image-Cr1qAxG-.js} +1 -1
  52. package/dist/{index-D-T7kk3G.js → index-C0USsgDi.js} +1 -1
  53. package/dist/{index-Dq0LIBEh.js → index-C49-8bCQ.js} +1 -1
  54. package/dist/{index-DSX3HrTS.js → index-CH4T0JAz.js} +1 -1
  55. package/dist/{index-BDE-2VTp.js → index-CWAoFGd1.js} +6 -6
  56. package/dist/{index-RFYbqmu0.js → index-C_3PUMa7.js} +1 -1
  57. package/dist/{index-BZZHE-1t.js → index-D7jufxlk.js} +1 -1
  58. package/dist/{index-CIr4zlVp.js → index-DZiQey0J.js} +1 -1
  59. package/dist/{index-DQ5AZLMt.js → index-DtAG8k9M.js} +1 -1
  60. package/dist/{index-2vYoun4O.js → index-Zh6wUpmX.js} +4007 -3984
  61. package/dist/{index-BjLIiJQa.js → index-utoSbRla.js} +1 -1
  62. package/dist/{info-Br-SBtj3.js → info-BUp5BYav.js} +1 -1
  63. package/dist/{info-circle-Ew4RoR_Q.js → info-circle-D5anzkYK.js} +1 -1
  64. package/dist/{lightbulb-BRBVOE_b.js → lightbulb-DmuhLv29.js} +1 -1
  65. package/dist/{mail-Dzi4AncY.js → mail-D2hRmmgi.js} +1 -1
  66. package/dist/{mobile-BGGxQ5be.js → mobile-Cq-9uJHv.js} +1 -1
  67. package/dist/{more-BmNaKbYJ.js → more-DJMBaB2z.js} +1 -1
  68. package/dist/{network-placeholder-EMiMf4q1.js → network-placeholder-3ip1roR0.js} +1 -1
  69. package/dist/{nftPlaceholder-CvSqy3Sd.js → nftPlaceholder-C7r74zYS.js} +1 -1
  70. package/dist/{off-DF9uz0Nc.js → off-CJE6Z_MK.js} +1 -1
  71. package/dist/{onramp-cKzTmKku.js → onramp-BMRgbt2I.js} +1 -1
  72. package/dist/{play-store-CGxW4MgL.js → play-store-CxusWynI.js} +1 -1
  73. package/dist/{plus-CQ6wWkN0.js → plus-Bjkqj5g6.js} +1 -1
  74. package/dist/{qr-code-VBqx9nAF.js → qr-code-4C0zboga.js} +1 -1
  75. package/dist/{receive-CVzkHmKR.js → receive-Cc8moHBZ.js} +1 -1
  76. package/dist/{recycle-horizontal-Oq1YtvUx.js → recycle-horizontal-BdSgk84g.js} +1 -1
  77. package/dist/{refresh-BDlGAzmY.js → refresh-BsRodAS7.js} +1 -1
  78. package/dist/{reown-logo-BlIpXIlG.js → reown-logo-DOVlqCDK.js} +1 -1
  79. package/dist/{search-DfmCmp0m.js → search-BIyHtky-.js} +1 -1
  80. package/dist/{secp256k1-CsKSDHNi.js → secp256k1-B2Gq-iIr.js} +1 -1
  81. package/dist/{send-BXudz514.js → send-9eSi58hW.js} +1 -1
  82. package/dist/{send-Cz0L5LmE.js → send-CBFTcYtn.js} +3 -3
  83. package/dist/{socials-CDOh8MRf.js → socials-CeOJULFV.js} +1 -1
  84. package/dist/{solana-CbiyOE-8.js → solana-BNptwYvn.js} +1 -1
  85. package/dist/{swapHorizontal-DyU1TH_e.js → swapHorizontal-COlgqyzt.js} +1 -1
  86. package/dist/{swapHorizontalBold-CGXW7Ocj.js → swapHorizontalBold-Odce2JOe.js} +1 -1
  87. package/dist/{swapHorizontalMedium-2KTcj67d.js → swapHorizontalMedium-B9nkEBPD.js} +1 -1
  88. package/dist/{swapHorizontalRoundedBold-TxFtmmda.js → swapHorizontalRoundedBold-DPMzz6nz.js} +1 -1
  89. package/dist/{swapVertical-BKD6lxM3.js → swapVertical-FqQP9GBP.js} +1 -1
  90. package/dist/{swaps-BuGsEQaI.js → swaps-BG9GOayX.js} +3 -3
  91. package/dist/{telegram-CAsl9DeG.js → telegram-BMY9Hs9Z.js} +1 -1
  92. package/dist/{three-dots-BoE2aHZi.js → three-dots-DDKmexHU.js} +1 -1
  93. package/dist/{transactions-C1NtsnD6.js → transactions-C_GII6kW.js} +1 -1
  94. package/dist/{twitch-CvkZZxgT.js → twitch-x_s0neNg.js} +1 -1
  95. package/dist/{twitterIcon-CrhnOl_O.js → twitterIcon-CKsSxEuJ.js} +1 -1
  96. package/dist/{ui-BJcuThPA.js → ui-CZH-vf5h.js} +2 -2
  97. package/dist/{user-BZRWUXG7.js → user-CZfvQDJ_.js} +1 -1
  98. package/dist/{verify-y9F4DcJ4.js → verify-Bnvbadnx.js} +1 -1
  99. package/dist/{verify-filled-X_8-BhMk.js → verify-filled-CnEopkW-.js} +1 -1
  100. package/dist/{w3m-modal-BX--v1Nc.js → w3m-modal-DkI2TPJW.js} +2 -2
  101. package/dist/{wallet-CIaVVkjQ.js → wallet-B3oN4n4q.js} +1 -1
  102. package/dist/{wallet-placeholder-Cq1ofde1.js → wallet-placeholder-CI0oiAcd.js} +1 -1
  103. package/dist/{walletconnect-CINzSCJ3.js → walletconnect-D4vMcjqO.js} +1 -1
  104. package/dist/{warning-circle-BvBNhMKH.js → warning-circle-DjI8aRBs.js} +1 -1
  105. package/dist/{x-xHY7JehW.js → x-BgRWY62H.js} +1 -1
  106. package/dist/{x-mark-DEmnBt6u.js → x-mark-Cdqd-Hm4.js} +1 -1
  107. package/package.json +6 -1
  108. package/.github/workflows/code-quality.yml +0 -43
  109. package/.github/workflows/publish.yml +0 -64
  110. package/eslint.config.mjs +0 -41
  111. package/index.html +0 -13
  112. package/public/font/ClashDisplay-Variable.ttf +0 -0
  113. package/public/font/ClashDisplay-Variable.woff +0 -0
  114. package/public/font/ClashDisplay-Variable.woff2 +0 -0
  115. package/public/vite.svg +0 -1
  116. package/src/App.css +0 -170
  117. package/src/apis/lspApi.js +0 -82
  118. package/src/apis/request.js +0 -59
  119. package/src/assets/arrow-right.svg +0 -3
  120. package/src/assets/astr.svg +0 -13
  121. package/src/assets/bridge-loading.png +0 -0
  122. package/src/assets/ln.png +0 -0
  123. package/src/assets/network/Arbitrum.png +0 -0
  124. package/src/assets/network/Polygon.png +0 -0
  125. package/src/assets/network/Solana.png +0 -0
  126. package/src/assets/network/base.png +0 -0
  127. package/src/assets/network/botanix.png +0 -0
  128. package/src/assets/network/bsc.svg +0 -13
  129. package/src/assets/network/eth.png +0 -0
  130. package/src/assets/network/lighting.png +0 -0
  131. package/src/assets/network/ligtning.svg +0 -22
  132. package/src/assets/network/solona.png +0 -0
  133. package/src/assets/pay.png +0 -0
  134. package/src/assets/powerby.svg +0 -14
  135. package/src/assets/react.svg +0 -1
  136. package/src/assets/success.svg +0 -3
  137. package/src/assets/tip.svg +0 -5
  138. package/src/assets/tokens/sol.png +0 -0
  139. package/src/assets/tokens/usdc.png +0 -0
  140. package/src/assets/tokens/usdt.png +0 -0
  141. package/src/comps/AstraImage.jsx +0 -37
  142. package/src/comps/AstraModal.jsx +0 -202
  143. package/src/comps/AstraModalLogo.jsx +0 -29
  144. package/src/comps/AstraNetwork.jsx +0 -261
  145. package/src/comps/CheckErc20Button.jsx +0 -28
  146. package/src/comps/CommonStyle.jsx +0 -4
  147. package/src/comps/ConnectButton.jsx +0 -19
  148. package/src/comps/EllipsisMiddle.jsx +0 -42
  149. package/src/comps/ResultModal.jsx +0 -312
  150. package/src/comps/ToLightning.jsx +0 -653
  151. package/src/comps/ToToken.jsx +0 -550
  152. package/src/constants/index.js +0 -21
  153. package/src/font/ClashDisplay-Variable.ttf +0 -0
  154. package/src/font/ClashDisplay-Variable.woff +0 -0
  155. package/src/font/ClashDisplay-Variable.woff2 +0 -0
  156. package/src/hooks/useContract.js +0 -179
  157. package/src/hooks/useGetMinAndMax.js +0 -48
  158. package/src/hooks/useLspApi.js +0 -70
  159. package/src/hooks/useParseInvoice.js +0 -95
  160. package/src/index.css +0 -69
  161. package/src/index.jsx +0 -161
  162. package/src/lib/bolt11.min.js +0 -1
  163. package/src/main.jsx +0 -75
  164. package/src/store/index.js +0 -25
  165. package/src/theme.js +0 -108
  166. package/src/utils/index.js +0 -267
  167. 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
- );
@@ -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
- };
@@ -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
- });