@directcryptopay/sdk 0.2.2 → 0.2.4
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/dist/ExchangeController-CbO41bcH.js +217 -0
- package/dist/HelpersUtil-DHm6EVSE.js +120 -0
- package/dist/NavigationUtil-kj9LEOOd.js +8 -0
- package/dist/PhArrowCircleDown-lsK25DCk.js +73 -0
- package/dist/PhArrowClockwise-NeKHZ1co.js +73 -0
- package/dist/PhArrowDown-C9AkNvLs.js +73 -0
- package/dist/PhArrowLeft-RNfIQP1X.js +73 -0
- package/dist/PhArrowRight-DM1tna0G.js +73 -0
- package/dist/PhArrowSquareOut-S5XYbAZj.js +73 -0
- package/dist/PhArrowUp-DmktzOWy.js +73 -0
- package/dist/PhArrowUpRight-BkNeW_5i.js +73 -0
- package/dist/PhArrowsClockwise-CQ4pG76b.js +73 -0
- package/dist/PhArrowsDownUp-H6gxaNM6.js +73 -0
- package/dist/PhArrowsLeftRight-DZSsfMR6.js +73 -0
- package/dist/PhBank-4_9QzqIB.js +73 -0
- package/dist/PhBrowser-B-JSznId.js +73 -0
- package/dist/PhCaretDown-vV5oHMNi.js +73 -0
- package/dist/PhCaretLeft-BLo6Y_f4.js +73 -0
- package/dist/PhCaretRight-CqQN4TT3.js +73 -0
- package/dist/PhCaretUp-Df7UCAHy.js +73 -0
- package/dist/PhCheck-gtpfK4ed.js +73 -0
- package/dist/PhCircleHalf-Uq7dwDYw.js +73 -0
- package/dist/PhClock-SDCW-NmF.js +73 -0
- package/dist/PhCompass-B7hgtdx-.js +73 -0
- package/dist/PhCopy-BcnhyXCy.js +73 -0
- package/dist/PhCreditCard-BJjByVgu.js +73 -0
- package/dist/PhCurrencyDollar-B7ZXqXBy.js +73 -0
- package/dist/PhDesktop-B3VKPuJx.js +73 -0
- package/dist/PhDeviceMobile-Bnd0TYEH.js +73 -0
- package/dist/PhDotsThree-yyMWyZ-R.js +73 -0
- package/dist/PhEnvelope-67uzHbI9.js +73 -0
- package/dist/PhFunnelSimple-B-DCsloI.js +73 -0
- package/dist/PhGlobe-TMm_6qGk.js +73 -0
- package/dist/PhIdentificationCard-CePPD2xc.js +73 -0
- package/dist/PhImage-gY96WtHR.js +73 -0
- package/dist/PhInfo-DRQM_ZDP.js +73 -0
- package/dist/PhLightbulb-B0TxPfZ1.js +73 -0
- package/dist/PhMagnifyingGlass-B8si5_6W.js +73 -0
- package/dist/PhPaperPlaneRight-DVu5PLYd.js +73 -0
- package/dist/PhPlus-BfTsQnUz.js +73 -0
- package/dist/PhPower-CxYUGOWn.js +73 -0
- package/dist/PhPuzzlePiece-CQ4wh0gV.js +73 -0
- package/dist/PhQrCode-BuJ97NYJ.js +73 -0
- package/dist/PhQuestion-kJoP8Mja.js +73 -0
- package/dist/PhQuestionMark-C46ZkFpu.js +73 -0
- package/dist/PhSealCheck-Eh8jVqSN.js +73 -0
- package/dist/PhSignOut-jk97OSVt.js +73 -0
- package/dist/PhSpinner-CiYOhwMg.js +73 -0
- package/dist/PhTrash-pxerMqzd.js +73 -0
- package/dist/PhUser-BMg0VV4A.js +73 -0
- package/dist/PhVault-DYQvx5A-.js +73 -0
- package/dist/PhWarning-NLC5Mj87.js +73 -0
- package/dist/PhWarningCircle-Ch2jU9fA.js +73 -0
- package/dist/PhX-Bx4wpwm3.js +73 -0
- package/dist/SwapController-Ch0FFTEt.js +457 -0
- package/dist/{ccip-BIGqktC1.js → ccip-BrGhNXIM.js} +4 -4
- package/dist/data-capture-CpafmuCb.js +490 -0
- package/dist/dcp-sdk.umd.js +7400 -6589
- package/dist/email-Dcg4jlai.js +344 -0
- package/dist/embedded-wallet-DeoRdAPw.js +820 -0
- package/dist/features-B9Nde43h.js +274 -0
- package/dist/{hashTypedData-ZH9ZnWu3.js → hashTypedData-a7b8tdkO.js} +6 -6
- package/dist/if-defined-k21LutCn.js +10 -0
- package/dist/index-9vLw53Xl.js +228 -0
- package/dist/index-B5wUyynz.js +107 -0
- package/dist/index-B8LkUrww.js +86 -0
- package/dist/{index-CPTcEPbD.js → index-BA0VwKg0.js} +296 -298
- package/dist/index-BB9JJ24N.js +125 -0
- package/dist/index-BCkEvPQ6.js +172 -0
- package/dist/index-BDeO_csr.js +171 -0
- package/dist/index-Bb7babLF.js +1281 -0
- package/dist/index-BjOhprVS.js +199 -0
- package/dist/{index-Dy4NyE6l.js → index-BjyMgZsf.js} +7 -7
- package/dist/index-BkThIDLX.js +159 -0
- package/dist/index-BmFs6nb7.js +209 -0
- package/dist/{index-5mp7WkhV.js → index-C4qc4PdD.js} +2 -2
- package/dist/{index-BdSIrl-R.js → index-CAPvUh14.js} +578 -570
- package/dist/index-CBMU3PTE.js +65 -0
- package/dist/index-CGwPkJLF.js +355 -0
- package/dist/index-CNGEqX3D.js +153 -0
- package/dist/index-CRlCq6IB.js +7981 -0
- package/dist/index-Cg_o-i9X.js +118 -0
- package/dist/index-D1BvhCbI.js +62 -0
- package/dist/index-DFi8TiHc.js +128 -0
- package/dist/index-DLwuveL9.js +555 -0
- package/dist/index-DMn7ktUQ.js +56 -0
- package/dist/index-DOXwtuwa.js +117 -0
- package/dist/index-DPPOW_Tp.js +118 -0
- package/dist/{index-f3LXSfM5.js → index-DQpzHpW-.js} +56 -142
- package/dist/{index-D6h-qfpt.js → index-DXHg5C-W.js} +5 -5
- package/dist/index-DcYjZV4H.js +110 -0
- package/dist/{index-BJ7cbG3N.js → index-DeL88Lwc.js} +36769 -40177
- package/dist/index-DrWVlf8b.js +46 -0
- package/dist/index-Dsfuc4rB.js +123 -0
- package/dist/index-DuTny38n.js +1175 -0
- package/dist/{index-D5r0iSq4.js → index-Nfjb6bV0.js} +1 -1
- package/dist/index-WwwdQSN2.js +85 -0
- package/dist/index-Yha9Afch.js +174 -0
- package/dist/index-cbQHN7GC.js +100 -0
- package/dist/{index-DobBVPe4.js → index-hyG3cYsv.js} +481 -236
- package/dist/index-qLxmmPaL.js +257 -0
- package/dist/index.js +1 -1
- package/dist/{localBatchGatewayRequest-CjGcn5nM.js → localBatchGatewayRequest-vfcvRH0G.js} +1 -1
- package/dist/onramp-BSiyOX4L.js +855 -0
- package/dist/{parseSignature-S8VEpRHC.js → parseSignature-CdCMAPZN.js} +2312 -2313
- package/dist/pay-with-exchange-CduNoMEz.js +525 -0
- package/dist/property-Bd8U3_QP.js +618 -0
- package/dist/receive-CrmptJlq.js +232 -0
- package/dist/ref-SOwYtCZb.js +107 -0
- package/dist/send-oMcHMEr6.js +1166 -0
- package/dist/socials-C0A4-FbY.js +620 -0
- package/dist/swaps-CbJJ9Ciu.js +1760 -0
- package/dist/{transactions-DujFkB-M.js → transactions-BDfCoBS5.js} +10 -10
- package/dist/w3m-modal-BjsTkny7.js +1706 -0
- package/package.json +3 -3
- package/dist/ConstantsUtil-B-_-u8aQ.js +0 -6
- package/dist/add-sji6scSD.js +0 -19
- package/dist/all-wallets-B4H-890E.js +0 -10
- package/dist/app-store-Z433s97G.js +0 -21
- package/dist/apple-b8Lxj7nb.js +0 -22
- package/dist/arrow-bottom-M9oWWo_9.js +0 -12
- package/dist/arrow-bottom-circle-N9c4CXY1.js +0 -15
- package/dist/arrow-left-Dw8AKfwf.js +0 -12
- package/dist/arrow-right-DwLQZSC_.js +0 -12
- package/dist/arrow-top-zhUjkBe1.js +0 -12
- package/dist/bank-CbQdnILK.js +0 -18
- package/dist/browser-xAqNwt7z.js +0 -18
- package/dist/card-Dr1QBmWp.js +0 -18
- package/dist/checkmark-BhT1dTgG.js +0 -15
- package/dist/checkmark-bold-CPB29wqQ.js +0 -12
- package/dist/chevron-bottom-BhNyx2II.js +0 -12
- package/dist/chevron-left-CGuEjQlY.js +0 -12
- package/dist/chevron-right-CvIRRsqZ.js +0 -12
- package/dist/chevron-top-RSzCqjBd.js +0 -12
- package/dist/chrome-store-Cs8dAgs0.js +0 -65
- package/dist/clock-fhZO5otC.js +0 -12
- package/dist/close-BPuztrdR.js +0 -12
- package/dist/coinPlaceholder-C8X2i7Kh.js +0 -12
- package/dist/compass-WMc5huk0.js +0 -12
- package/dist/copy-DVAeT17y.js +0 -19
- package/dist/cursor-BJ4YLXfy.js +0 -7
- package/dist/cursor-transparent-DN2fLQN4.js +0 -16
- package/dist/desktop-6avxisBw.js +0 -13
- package/dist/disconnect-AReVI8Gk.js +0 -12
- package/dist/discord-CxrI30BZ.js +0 -21
- package/dist/email-B8dIIaay.js +0 -696
- package/dist/embedded-wallet-C_5hF7rM.js +0 -468
- package/dist/etherscan-BnAy8cIF.js +0 -10
- package/dist/exclamation-triangle-Bu7nHwx9.js +0 -8
- package/dist/extension-F0LIhvcf.js +0 -12
- package/dist/external-link-CP6phyaM.js +0 -12
- package/dist/facebook-BtQ-Io2y.js +0 -30
- package/dist/farcaster-BmaN1ugd.js +0 -16
- package/dist/filters-DpEwoOmy.js +0 -12
- package/dist/github-q7qO9V-b.js +0 -22
- package/dist/google-DH_ZE8bW.js +0 -22
- package/dist/help-circle-BAQVmKas.js +0 -16
- package/dist/id-Cj68Zwgo.js +0 -16
- package/dist/if-defined-CNte9B3N.js +0 -744
- package/dist/image-BKJDw6N-.js +0 -8
- package/dist/index-7toZMdtG.js +0 -573
- package/dist/index-B1uKzdvN.js +0 -170
- package/dist/index-BHFZVF-b.js +0 -257
- package/dist/index-BKwa5JSA.js +0 -559
- package/dist/index-BP4B9VUt.js +0 -54
- package/dist/index-BVdzXHpO.js +0 -181
- package/dist/index-BYND0GJ9.js +0 -146
- package/dist/index-BaJ0zEbh.js +0 -97
- package/dist/index-Bh0MPFwP.js +0 -58
- package/dist/index-Bsh7_qTp.js +0 -511
- package/dist/index-BwnXTNNg.js +0 -199
- package/dist/index-C0kPDbg_.js +0 -77
- package/dist/index-CKikVKe2.js +0 -75
- package/dist/index-ChVh0Hkp.js +0 -243
- package/dist/index-Cle_NnnS.js +0 -305
- package/dist/index-CmWdvIFT.js +0 -51
- package/dist/index-D2AMA8Bu.js +0 -65
- package/dist/index-DAUM8CO4.js +0 -65
- package/dist/index-DGjZW6uR.js +0 -78
- package/dist/index-DQe94z7X.js +0 -265
- package/dist/index-DTo6w99t.js +0 -7864
- package/dist/index-DYdXjap2.js +0 -320
- package/dist/index-DceCxNV5.js +0 -181
- package/dist/index-Uw9cSw0q.js +0 -294
- package/dist/index-qiuyrukh.js +0 -45
- package/dist/index-zddvaohA.js +0 -78
- package/dist/info-RfPsmroW.js +0 -7
- package/dist/info-circle-DFKHB_ZN.js +0 -16
- package/dist/lightbulb-B-Bykj9X.js +0 -7
- package/dist/mail-mBAgGuw5.js +0 -12
- package/dist/mobile-Dhh3ndkf.js +0 -13
- package/dist/more-D1h7UTvg.js +0 -15
- package/dist/network-placeholder-Dqynvc-t.js +0 -18
- package/dist/nftPlaceholder-Df7MW4MM.js +0 -12
- package/dist/off-BmG3cHTX.js +0 -12
- package/dist/onramp-C401Aenb.js +0 -1279
- package/dist/play-store-4q1fzL_P.js +0 -36
- package/dist/plus-603Gs3yG.js +0 -17
- package/dist/qr-code-Dgwhf6M1.js +0 -10
- package/dist/receive-CYXbbEUR.js +0 -186
- package/dist/recycle-horizontal-Bu8zZ563.js +0 -13
- package/dist/ref-DpmKRWBK.js +0 -41
- package/dist/refresh-BMZFu0mu.js +0 -12
- package/dist/reown-logo-BXph7ThY.js +0 -16
- package/dist/search-Cm_V42Y_.js +0 -12
- package/dist/secp256k1-C0iX1TUr.js +0 -1510
- package/dist/secp256k1-DOQBqE4Z.js +0 -1302
- package/dist/send-BSMYxDuP.js +0 -19
- package/dist/send-C8EeIzRB.js +0 -1038
- package/dist/socials-DQrHQajs.js +0 -574
- package/dist/swapHorizontal-98rnJewS.js +0 -12
- package/dist/swapHorizontalBold-C299FjEt.js +0 -12
- package/dist/swapHorizontalMedium-Cqm6i4WJ.js +0 -20
- package/dist/swapHorizontalRoundedBold-De7hFfqZ.js +0 -12
- package/dist/swapVertical-DSL75l8L.js +0 -12
- package/dist/swaps-BuTNp65Y.js +0 -1637
- package/dist/telegram-cJP7hgUb.js +0 -20
- package/dist/three-dots-DHnEh28O.js +0 -9
- package/dist/twitch-CR2iGcBo.js +0 -22
- package/dist/twitterIcon-E5TAQjOn.js +0 -10
- package/dist/verify-DEukUJp0.js +0 -12
- package/dist/verify-filled-BXsx1i_p.js +0 -12
- package/dist/w3m-modal-Bm7BqVng.js +0 -1037
- package/dist/wallet-CzyyvdrT.js +0 -12
- package/dist/wallet-placeholder-BrcmyGEe.js +0 -18
- package/dist/walletconnect-BSYogWiE.js +0 -36
- package/dist/warning-circle-Cgp2BW3m.js +0 -16
- package/dist/x-BJinLpTw.js +0 -16
package/dist/image-BKJDw6N-.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { cD as C } from "./index-BJ7cbG3N.js";
|
|
2
|
-
const l = C`<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
|
|
3
|
-
<path d="M4.98926 3.73932C4.2989 3.73932 3.73926 4.29896 3.73926 4.98932C3.73926 5.67968 4.2989 6.23932 4.98926 6.23932C5.67962 6.23932 6.23926 5.67968 6.23926 4.98932C6.23926 4.29896 5.67962 3.73932 4.98926 3.73932Z" fill="currentColor"/>
|
|
4
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.60497 0.500001H6.39504C5.41068 0.499977 4.59185 0.499958 3.93178 0.571471C3.24075 0.64634 2.60613 0.809093 2.04581 1.21619C1.72745 1.44749 1.44749 1.72745 1.21619 2.04581C0.809093 2.60613 0.64634 3.24075 0.571471 3.93178C0.499958 4.59185 0.499977 5.41065 0.500001 6.39501V7.57815C0.499998 8.37476 0.499995 9.05726 0.534869 9.62725C0.570123 10.2034 0.644114 10.7419 0.828442 11.2302C0.925651 11.4877 1.05235 11.7287 1.21619 11.9542C1.44749 12.2726 1.72745 12.5525 2.04581 12.7838C2.60613 13.1909 3.24075 13.3537 3.93178 13.4285C4.59185 13.5001 5.41066 13.5 6.39503 13.5H7.60496C8.58933 13.5 9.40815 13.5001 10.0682 13.4285C10.7593 13.3537 11.3939 13.1909 11.9542 12.7838C12.2726 12.5525 12.5525 12.2726 12.7838 11.9542C13.1909 11.3939 13.3537 10.7593 13.4285 10.0682C13.5 9.40816 13.5 8.58935 13.5 7.60497V6.39505C13.5 5.41068 13.5 4.59185 13.4285 3.93178C13.3537 3.24075 13.1909 2.60613 12.7838 2.04581C12.5525 1.72745 12.2726 1.44749 11.9542 1.21619C11.3939 0.809093 10.7593 0.64634 10.0682 0.571471C9.40816 0.499958 8.58933 0.499977 7.60497 0.500001ZM3.22138 2.83422C3.38394 2.71612 3.62634 2.61627 4.14721 2.55984C4.68679 2.50138 5.39655 2.5 6.45 2.5H7.55C8.60345 2.5 9.31322 2.50138 9.8528 2.55984C10.3737 2.61627 10.6161 2.71612 10.7786 2.83422C10.9272 2.94216 11.0578 3.07281 11.1658 3.22138C11.2839 3.38394 11.3837 3.62634 11.4402 4.14721C11.4986 4.68679 11.5 5.39655 11.5 6.45V6.49703C10.9674 6.11617 10.386 5.84936 9.74213 5.81948C8.40536 5.75745 7.3556 6.73051 6.40509 7.84229C6.33236 7.92737 6.27406 7.98735 6.22971 8.02911L6.1919 8.00514L6.17483 7.99427C6.09523 7.94353 5.98115 7.87083 5.85596 7.80302C5.56887 7.64752 5.18012 7.4921 4.68105 7.4921C4.66697 7.4921 4.6529 7.49239 4.63884 7.49299C3.79163 7.52878 3.09922 8.1106 2.62901 8.55472C2.58751 8.59392 2.54594 8.6339 2.50435 8.6745C2.50011 8.34653 2.5 7.97569 2.5 7.55V6.45C2.5 5.39655 2.50138 4.68679 2.55984 4.14721C2.61627 3.62634 2.71612 3.38394 2.83422 3.22138C2.94216 3.07281 3.07281 2.94216 3.22138 2.83422ZM10.3703 8.14825C10.6798 8.37526 11.043 8.71839 11.4832 9.20889C11.4744 9.44992 11.4608 9.662 11.4402 9.8528C11.3837 10.3737 11.2839 10.6161 11.1658 10.7786C11.0578 10.9272 10.9272 11.0578 10.7786 11.1658C10.6161 11.2839 10.3737 11.3837 9.8528 11.4402C9.31322 11.4986 8.60345 11.5 7.55 11.5H6.45C5.39655 11.5 4.68679 11.4986 4.14721 11.4402C3.62634 11.3837 3.38394 11.2839 3.22138 11.1658C3.15484 11.1174 3.0919 11.0645 3.03298 11.0075C3.10126 10.9356 3.16806 10.8649 3.23317 10.7959L3.29772 10.7276C3.55763 10.4525 3.78639 10.2126 4.00232 10.0087C4.22016 9.80294 4.39412 9.66364 4.53524 9.57742C4.63352 9.51738 4.69022 9.49897 4.71275 9.49345C4.76387 9.49804 4.81803 9.51537 4.90343 9.56162C4.96409 9.59447 5.02355 9.63225 5.11802 9.69238L5.12363 9.69595C5.20522 9.74789 5.32771 9.82587 5.46078 9.89278C5.76529 10.0459 6.21427 10.186 6.74977 10.0158C7.21485 9.86796 7.59367 9.52979 7.92525 9.14195C8.91377 7.98571 9.38267 7.80495 9.64941 7.81733C9.7858 7.82366 10.0101 7.884 10.3703 8.14825Z" fill="currentColor"/>
|
|
5
|
-
</svg>`;
|
|
6
|
-
export {
|
|
7
|
-
l as imageSvg
|
|
8
|
-
};
|
package/dist/index-7toZMdtG.js
DELETED
|
@@ -1,573 +0,0 @@
|
|
|
1
|
-
import { cY as g, cX as v, d5 as A, d6 as N, d7 as l, cT as V, cU as j, cJ as S, cZ as f, d8 as D, d0 as x, d1 as F, d9 as Q, da as R, db as $, dc as H, dd as Y, cV as K, cW as J, cE as X, cH as Z, cI as ee, cF as te, cG as M } from "./index-BJ7cbG3N.js";
|
|
2
|
-
import { n as q, c as ne } from "./if-defined-CNte9B3N.js";
|
|
3
|
-
import "./index-CmWdvIFT.js";
|
|
4
|
-
import "./index-CKikVKe2.js";
|
|
5
|
-
const W = {
|
|
6
|
-
async getTokenList() {
|
|
7
|
-
var a;
|
|
8
|
-
const t = g.state.activeCaipNetwork, n = await A.fetchSwapTokens({
|
|
9
|
-
chainId: t == null ? void 0 : t.caipNetworkId
|
|
10
|
-
});
|
|
11
|
-
return ((a = n == null ? void 0 : n.tokens) == null ? void 0 : a.map((s) => ({
|
|
12
|
-
...s,
|
|
13
|
-
eip2612: !1,
|
|
14
|
-
quantity: {
|
|
15
|
-
decimals: "0",
|
|
16
|
-
numeric: "0"
|
|
17
|
-
},
|
|
18
|
-
price: 0,
|
|
19
|
-
value: 0
|
|
20
|
-
}))) || [];
|
|
21
|
-
},
|
|
22
|
-
async fetchGasPrice() {
|
|
23
|
-
var n, o;
|
|
24
|
-
const t = g.state.activeCaipNetwork;
|
|
25
|
-
if (!t)
|
|
26
|
-
return null;
|
|
27
|
-
try {
|
|
28
|
-
switch (t.chainNamespace) {
|
|
29
|
-
case "solana":
|
|
30
|
-
const a = (o = await ((n = N) == null ? void 0 : n.estimateGas({ chainNamespace: "solana" }))) == null ? void 0 : o.toString();
|
|
31
|
-
return {
|
|
32
|
-
standard: a,
|
|
33
|
-
fast: a,
|
|
34
|
-
instant: a
|
|
35
|
-
};
|
|
36
|
-
case "eip155":
|
|
37
|
-
default:
|
|
38
|
-
return await A.fetchGasPrice({
|
|
39
|
-
chainId: t.caipNetworkId
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
async fetchSwapAllowance({ tokenAddress: t, userAddress: n, sourceTokenAmount: o, sourceTokenDecimals: a }) {
|
|
47
|
-
const s = await A.fetchSwapAllowance({
|
|
48
|
-
tokenAddress: t,
|
|
49
|
-
userAddress: n
|
|
50
|
-
});
|
|
51
|
-
if (s != null && s.allowance && o && a) {
|
|
52
|
-
const i = N.parseUnits(o, a) || 0;
|
|
53
|
-
return BigInt(s.allowance) >= i;
|
|
54
|
-
}
|
|
55
|
-
return !1;
|
|
56
|
-
},
|
|
57
|
-
async getMyTokensWithBalance(t) {
|
|
58
|
-
const n = v.state.address, o = g.state.activeCaipNetwork;
|
|
59
|
-
if (!n || !o)
|
|
60
|
-
return [];
|
|
61
|
-
const s = (await A.getBalance(n, o.caipNetworkId, t)).balances.filter((i) => i.quantity.decimals !== "0");
|
|
62
|
-
return v.setTokenBalance(s, g.state.activeChain), this.mapBalancesToSwapTokens(s);
|
|
63
|
-
},
|
|
64
|
-
mapBalancesToSwapTokens(t) {
|
|
65
|
-
return (t == null ? void 0 : t.map((n) => ({
|
|
66
|
-
...n,
|
|
67
|
-
address: n != null && n.address ? n.address : g.getActiveNetworkTokenAddress(),
|
|
68
|
-
decimals: parseInt(n.quantity.decimals, 10),
|
|
69
|
-
logoUri: n.iconUrl,
|
|
70
|
-
eip2612: !1
|
|
71
|
-
}))) || [];
|
|
72
|
-
}
|
|
73
|
-
}, h = {
|
|
74
|
-
getGasPriceInEther(t, n) {
|
|
75
|
-
const o = n * t;
|
|
76
|
-
return Number(o) / 1e18;
|
|
77
|
-
},
|
|
78
|
-
getGasPriceInUSD(t, n, o) {
|
|
79
|
-
const a = h.getGasPriceInEther(n, o);
|
|
80
|
-
return l.bigNumber(t).times(a).toNumber();
|
|
81
|
-
},
|
|
82
|
-
getPriceImpact({ sourceTokenAmount: t, sourceTokenPriceInUSD: n, toTokenPriceInUSD: o, toTokenAmount: a }) {
|
|
83
|
-
const s = l.bigNumber(t).times(n), i = l.bigNumber(a).times(o);
|
|
84
|
-
return s.minus(i).div(s).times(100).toNumber();
|
|
85
|
-
},
|
|
86
|
-
getMaxSlippage(t, n) {
|
|
87
|
-
const o = l.bigNumber(t).div(100);
|
|
88
|
-
return l.multiply(n, o).toNumber();
|
|
89
|
-
},
|
|
90
|
-
getProviderFee(t, n = 85e-4) {
|
|
91
|
-
return l.bigNumber(t).times(n).toString();
|
|
92
|
-
},
|
|
93
|
-
isInsufficientNetworkTokenForGas(t, n) {
|
|
94
|
-
const o = n || "0";
|
|
95
|
-
return l.bigNumber(t).eq(0) ? !0 : l.bigNumber(l.bigNumber(o)).gt(t);
|
|
96
|
-
},
|
|
97
|
-
isInsufficientSourceTokenForSwap(t, n, o) {
|
|
98
|
-
var i, u;
|
|
99
|
-
const a = (u = (i = o == null ? void 0 : o.find((c) => c.address === n)) == null ? void 0 : i.quantity) == null ? void 0 : u.numeric;
|
|
100
|
-
return l.bigNumber(a || "0").lt(t);
|
|
101
|
-
},
|
|
102
|
-
getToTokenAmount({ sourceToken: t, toToken: n, sourceTokenPrice: o, toTokenPrice: a, sourceTokenAmount: s }) {
|
|
103
|
-
if (s === "0" || !t || !n)
|
|
104
|
-
return "0";
|
|
105
|
-
const i = t.decimals, u = o, c = n.decimals, T = a;
|
|
106
|
-
if (T <= 0)
|
|
107
|
-
return "0";
|
|
108
|
-
const d = l.bigNumber(s).times(85e-4), w = l.bigNumber(s).minus(d).times(l.bigNumber(10).pow(i)), P = l.bigNumber(u).div(T), b = i - c;
|
|
109
|
-
return w.times(P).div(l.bigNumber(10).pow(b)).div(l.bigNumber(10).pow(c)).toFixed(c).toString();
|
|
110
|
-
}
|
|
111
|
-
}, z = 15e4, oe = 6, k = {
|
|
112
|
-
// Loading states
|
|
113
|
-
initializing: !1,
|
|
114
|
-
initialized: !1,
|
|
115
|
-
loadingPrices: !1,
|
|
116
|
-
loadingQuote: !1,
|
|
117
|
-
loadingApprovalTransaction: !1,
|
|
118
|
-
loadingBuildTransaction: !1,
|
|
119
|
-
loadingTransaction: !1,
|
|
120
|
-
// Error states
|
|
121
|
-
fetchError: !1,
|
|
122
|
-
// Approval & Swap transaction states
|
|
123
|
-
approvalTransaction: void 0,
|
|
124
|
-
swapTransaction: void 0,
|
|
125
|
-
transactionError: void 0,
|
|
126
|
-
// Input values
|
|
127
|
-
sourceToken: void 0,
|
|
128
|
-
sourceTokenAmount: "",
|
|
129
|
-
sourceTokenPriceInUSD: 0,
|
|
130
|
-
toToken: void 0,
|
|
131
|
-
toTokenAmount: "",
|
|
132
|
-
toTokenPriceInUSD: 0,
|
|
133
|
-
networkPrice: "0",
|
|
134
|
-
networkBalanceInUSD: "0",
|
|
135
|
-
networkTokenSymbol: "",
|
|
136
|
-
inputError: void 0,
|
|
137
|
-
// Request values
|
|
138
|
-
slippage: $.CONVERT_SLIPPAGE_TOLERANCE,
|
|
139
|
-
// Tokens
|
|
140
|
-
tokens: void 0,
|
|
141
|
-
popularTokens: void 0,
|
|
142
|
-
suggestedTokens: void 0,
|
|
143
|
-
foundTokens: void 0,
|
|
144
|
-
myTokensWithBalance: void 0,
|
|
145
|
-
tokensPriceMap: {},
|
|
146
|
-
// Calculations
|
|
147
|
-
gasFee: "0",
|
|
148
|
-
gasPriceInUSD: 0,
|
|
149
|
-
priceImpact: void 0,
|
|
150
|
-
maxSlippage: void 0,
|
|
151
|
-
providerFee: void 0
|
|
152
|
-
}, e = j(k), U = {
|
|
153
|
-
state: e,
|
|
154
|
-
subscribe(t) {
|
|
155
|
-
return J(e, () => t(e));
|
|
156
|
-
},
|
|
157
|
-
subscribeKey(t, n) {
|
|
158
|
-
return K(e, t, n);
|
|
159
|
-
},
|
|
160
|
-
getParams() {
|
|
161
|
-
var T, d, p, w, P, b, I, y;
|
|
162
|
-
const t = g.state.activeCaipAddress, n = g.state.activeChain, o = F.getPlainAddress(t), a = g.getActiveNetworkTokenAddress(), s = H.getConnectorId(n);
|
|
163
|
-
if (!o)
|
|
164
|
-
throw new Error("No address found to swap the tokens from.");
|
|
165
|
-
const i = !((T = e.toToken) != null && T.address) || !((d = e.toToken) != null && d.decimals), u = !((p = e.sourceToken) != null && p.address) || !((w = e.sourceToken) != null && w.decimals) || !l.bigNumber(e.sourceTokenAmount).gt(0), c = !e.sourceTokenAmount;
|
|
166
|
-
return {
|
|
167
|
-
networkAddress: a,
|
|
168
|
-
fromAddress: o,
|
|
169
|
-
fromCaipAddress: t,
|
|
170
|
-
sourceTokenAddress: (P = e.sourceToken) == null ? void 0 : P.address,
|
|
171
|
-
toTokenAddress: (b = e.toToken) == null ? void 0 : b.address,
|
|
172
|
-
toTokenAmount: e.toTokenAmount,
|
|
173
|
-
toTokenDecimals: (I = e.toToken) == null ? void 0 : I.decimals,
|
|
174
|
-
sourceTokenAmount: e.sourceTokenAmount,
|
|
175
|
-
sourceTokenDecimals: (y = e.sourceToken) == null ? void 0 : y.decimals,
|
|
176
|
-
invalidToToken: i,
|
|
177
|
-
invalidSourceToken: u,
|
|
178
|
-
invalidSourceTokenAmount: c,
|
|
179
|
-
availableToSwap: t && !i && !u && !c,
|
|
180
|
-
isAuthConnector: s === Y.CONNECTOR_ID.AUTH
|
|
181
|
-
};
|
|
182
|
-
},
|
|
183
|
-
setSourceToken(t) {
|
|
184
|
-
if (!t) {
|
|
185
|
-
e.sourceToken = t, e.sourceTokenAmount = "", e.sourceTokenPriceInUSD = 0;
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
e.sourceToken = t, r.setTokenPrice(t.address, "sourceToken");
|
|
189
|
-
},
|
|
190
|
-
setSourceTokenAmount(t) {
|
|
191
|
-
e.sourceTokenAmount = t;
|
|
192
|
-
},
|
|
193
|
-
setToToken(t) {
|
|
194
|
-
if (!t) {
|
|
195
|
-
e.toToken = t, e.toTokenAmount = "", e.toTokenPriceInUSD = 0;
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
e.toToken = t, r.setTokenPrice(t.address, "toToken");
|
|
199
|
-
},
|
|
200
|
-
setToTokenAmount(t) {
|
|
201
|
-
e.toTokenAmount = t ? l.formatNumberToLocalString(t, oe) : "";
|
|
202
|
-
},
|
|
203
|
-
async setTokenPrice(t, n) {
|
|
204
|
-
let o = e.tokensPriceMap[t] || 0;
|
|
205
|
-
o || (e.loadingPrices = !0, o = await r.getAddressPrice(t)), n === "sourceToken" ? e.sourceTokenPriceInUSD = o : n === "toToken" && (e.toTokenPriceInUSD = o), e.loadingPrices && (e.loadingPrices = !1), r.getParams().availableToSwap && r.swapTokens();
|
|
206
|
-
},
|
|
207
|
-
switchTokens() {
|
|
208
|
-
if (e.initializing || !e.initialized)
|
|
209
|
-
return;
|
|
210
|
-
const t = e.toToken ? { ...e.toToken } : void 0, n = e.sourceToken ? { ...e.sourceToken } : void 0, o = t && e.toTokenAmount === "" ? "1" : e.toTokenAmount;
|
|
211
|
-
r.setSourceToken(t), r.setToToken(n), r.setSourceTokenAmount(o), r.setToTokenAmount(""), r.swapTokens();
|
|
212
|
-
},
|
|
213
|
-
resetState() {
|
|
214
|
-
e.myTokensWithBalance = k.myTokensWithBalance, e.tokensPriceMap = k.tokensPriceMap, e.initialized = k.initialized, e.sourceToken = k.sourceToken, e.sourceTokenAmount = k.sourceTokenAmount, e.sourceTokenPriceInUSD = k.sourceTokenPriceInUSD, e.toToken = k.toToken, e.toTokenAmount = k.toTokenAmount, e.toTokenPriceInUSD = k.toTokenPriceInUSD, e.networkPrice = k.networkPrice, e.networkTokenSymbol = k.networkTokenSymbol, e.networkBalanceInUSD = k.networkBalanceInUSD, e.inputError = k.inputError, e.myTokensWithBalance = k.myTokensWithBalance;
|
|
215
|
-
},
|
|
216
|
-
resetValues() {
|
|
217
|
-
var o;
|
|
218
|
-
const { networkAddress: t } = r.getParams(), n = (o = e.tokens) == null ? void 0 : o.find((a) => a.address === t);
|
|
219
|
-
r.setSourceToken(n), r.setToToken(void 0);
|
|
220
|
-
},
|
|
221
|
-
getApprovalLoadingState() {
|
|
222
|
-
return e.loadingApprovalTransaction;
|
|
223
|
-
},
|
|
224
|
-
clearError() {
|
|
225
|
-
e.transactionError = void 0;
|
|
226
|
-
},
|
|
227
|
-
async initializeState() {
|
|
228
|
-
if (!e.initializing) {
|
|
229
|
-
if (e.initializing = !0, !e.initialized)
|
|
230
|
-
try {
|
|
231
|
-
await r.fetchTokens(), e.initialized = !0;
|
|
232
|
-
} catch {
|
|
233
|
-
e.initialized = !1, f.showError("Failed to initialize swap"), S.goBack();
|
|
234
|
-
}
|
|
235
|
-
e.initializing = !1;
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
async fetchTokens() {
|
|
239
|
-
var o;
|
|
240
|
-
const { networkAddress: t } = r.getParams();
|
|
241
|
-
await r.getTokenList(), await r.getNetworkTokenPrice(), await r.getMyTokensWithBalance();
|
|
242
|
-
const n = (o = e.tokens) == null ? void 0 : o.find((a) => a.address === t);
|
|
243
|
-
n && (e.networkTokenSymbol = n.symbol, r.setSourceToken(n), r.setSourceTokenAmount("1"));
|
|
244
|
-
},
|
|
245
|
-
async getTokenList() {
|
|
246
|
-
const t = await W.getTokenList();
|
|
247
|
-
e.tokens = t, e.popularTokens = t.sort((n, o) => n.symbol < o.symbol ? -1 : n.symbol > o.symbol ? 1 : 0), e.suggestedTokens = t.filter((n) => !!$.SWAP_SUGGESTED_TOKENS.includes(n.symbol), {});
|
|
248
|
-
},
|
|
249
|
-
async getAddressPrice(t) {
|
|
250
|
-
var T, d;
|
|
251
|
-
const n = e.tokensPriceMap[t];
|
|
252
|
-
if (n)
|
|
253
|
-
return n;
|
|
254
|
-
const o = await A.fetchTokenPrice({
|
|
255
|
-
addresses: [t]
|
|
256
|
-
}), a = (o == null ? void 0 : o.fungibles) || [], s = [...e.tokens || [], ...e.myTokensWithBalance || []], i = (T = s == null ? void 0 : s.find((p) => p.address === t)) == null ? void 0 : T.symbol, u = ((d = a.find((p) => p.symbol.toLowerCase() === (i == null ? void 0 : i.toLowerCase()))) == null ? void 0 : d.price) || 0, c = parseFloat(u.toString());
|
|
257
|
-
return e.tokensPriceMap[t] = c, c;
|
|
258
|
-
},
|
|
259
|
-
async getNetworkTokenPrice() {
|
|
260
|
-
var s;
|
|
261
|
-
const { networkAddress: t } = r.getParams(), o = (s = (await A.fetchTokenPrice({
|
|
262
|
-
addresses: [t]
|
|
263
|
-
}).catch(() => (f.showError("Failed to fetch network token price"), { fungibles: [] }))).fungibles) == null ? void 0 : s[0], a = (o == null ? void 0 : o.price.toString()) || "0";
|
|
264
|
-
e.tokensPriceMap[t] = parseFloat(a), e.networkTokenSymbol = (o == null ? void 0 : o.symbol) || "", e.networkPrice = a;
|
|
265
|
-
},
|
|
266
|
-
async getMyTokensWithBalance(t) {
|
|
267
|
-
const n = await R.getMyTokensWithBalance(t), o = R.mapBalancesToSwapTokens(n);
|
|
268
|
-
o && (await r.getInitialGasPrice(), r.setBalances(o));
|
|
269
|
-
},
|
|
270
|
-
setBalances(t) {
|
|
271
|
-
const { networkAddress: n } = r.getParams(), o = g.state.activeCaipNetwork;
|
|
272
|
-
if (!o)
|
|
273
|
-
return;
|
|
274
|
-
const a = t.find((s) => s.address === n);
|
|
275
|
-
t.forEach((s) => {
|
|
276
|
-
e.tokensPriceMap[s.address] = s.price || 0;
|
|
277
|
-
}), e.myTokensWithBalance = t.filter((s) => s.address.startsWith(o.caipNetworkId)), e.networkBalanceInUSD = a ? l.multiply(a.quantity.numeric, a.price).toString() : "0";
|
|
278
|
-
},
|
|
279
|
-
async getInitialGasPrice() {
|
|
280
|
-
var n, o;
|
|
281
|
-
const t = await W.fetchGasPrice();
|
|
282
|
-
if (!t)
|
|
283
|
-
return { gasPrice: null, gasPriceInUSD: null };
|
|
284
|
-
switch ((o = (n = g.state) == null ? void 0 : n.activeCaipNetwork) == null ? void 0 : o.chainNamespace) {
|
|
285
|
-
case "solana":
|
|
286
|
-
return e.gasFee = t.standard ?? "0", e.gasPriceInUSD = l.multiply(t.standard, e.networkPrice).div(1e9).toNumber(), {
|
|
287
|
-
gasPrice: BigInt(e.gasFee),
|
|
288
|
-
gasPriceInUSD: Number(e.gasPriceInUSD)
|
|
289
|
-
};
|
|
290
|
-
case "eip155":
|
|
291
|
-
default:
|
|
292
|
-
const a = t.standard ?? "0", s = BigInt(a), i = BigInt(z), u = h.getGasPriceInUSD(e.networkPrice, i, s);
|
|
293
|
-
return e.gasFee = a, e.gasPriceInUSD = u, { gasPrice: s, gasPriceInUSD: u };
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
// -- Swap -------------------------------------- //
|
|
297
|
-
async swapTokens() {
|
|
298
|
-
var i, u;
|
|
299
|
-
const t = v.state.address, n = e.sourceToken, o = e.toToken, a = l.bigNumber(e.sourceTokenAmount).gt(0);
|
|
300
|
-
if (a || r.setToTokenAmount(""), !o || !n || e.loadingPrices || !a)
|
|
301
|
-
return;
|
|
302
|
-
e.loadingQuote = !0;
|
|
303
|
-
const s = l.bigNumber(e.sourceTokenAmount).times(10 ** n.decimals).round(0);
|
|
304
|
-
try {
|
|
305
|
-
const c = await A.fetchSwapQuote({
|
|
306
|
-
userAddress: t,
|
|
307
|
-
from: n.address,
|
|
308
|
-
to: o.address,
|
|
309
|
-
gasPrice: e.gasFee,
|
|
310
|
-
amount: s.toString()
|
|
311
|
-
});
|
|
312
|
-
e.loadingQuote = !1;
|
|
313
|
-
const T = (u = (i = c == null ? void 0 : c.quotes) == null ? void 0 : i[0]) == null ? void 0 : u.toAmount;
|
|
314
|
-
if (!T) {
|
|
315
|
-
Q.open({
|
|
316
|
-
shortMessage: "Incorrect amount",
|
|
317
|
-
longMessage: "Please enter a valid amount"
|
|
318
|
-
}, "error");
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const d = l.bigNumber(T).div(10 ** o.decimals).toString();
|
|
322
|
-
r.setToTokenAmount(d), r.hasInsufficientToken(e.sourceTokenAmount, n.address) ? e.inputError = "Insufficient balance" : (e.inputError = void 0, r.setTransactionDetails());
|
|
323
|
-
} catch {
|
|
324
|
-
e.loadingQuote = !1, e.inputError = "Insufficient balance";
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
// -- Create Transactions -------------------------------------- //
|
|
328
|
-
async getTransaction() {
|
|
329
|
-
const { fromCaipAddress: t, availableToSwap: n } = r.getParams(), o = e.sourceToken, a = e.toToken;
|
|
330
|
-
if (!(!t || !n || !o || !a || e.loadingQuote))
|
|
331
|
-
try {
|
|
332
|
-
e.loadingBuildTransaction = !0;
|
|
333
|
-
const s = await W.fetchSwapAllowance({
|
|
334
|
-
userAddress: t,
|
|
335
|
-
tokenAddress: o.address,
|
|
336
|
-
sourceTokenAmount: e.sourceTokenAmount,
|
|
337
|
-
sourceTokenDecimals: o.decimals
|
|
338
|
-
});
|
|
339
|
-
let i;
|
|
340
|
-
return s ? i = await r.createSwapTransaction() : i = await r.createAllowanceTransaction(), e.loadingBuildTransaction = !1, e.fetchError = !1, i;
|
|
341
|
-
} catch {
|
|
342
|
-
S.goBack(), f.showError("Failed to check allowance"), e.loadingBuildTransaction = !1, e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
async createAllowanceTransaction() {
|
|
347
|
-
const { fromCaipAddress: t, sourceTokenAddress: n, toTokenAddress: o } = r.getParams();
|
|
348
|
-
if (!(!t || !o)) {
|
|
349
|
-
if (!n)
|
|
350
|
-
throw new Error("createAllowanceTransaction - No source token address found.");
|
|
351
|
-
try {
|
|
352
|
-
const a = await A.generateApproveCalldata({
|
|
353
|
-
from: n,
|
|
354
|
-
to: o,
|
|
355
|
-
userAddress: t
|
|
356
|
-
}), s = {
|
|
357
|
-
data: a.tx.data,
|
|
358
|
-
to: F.getPlainAddress(a.tx.from),
|
|
359
|
-
gasPrice: BigInt(a.tx.eip155.gasPrice),
|
|
360
|
-
value: BigInt(a.tx.value),
|
|
361
|
-
toAmount: e.toTokenAmount
|
|
362
|
-
};
|
|
363
|
-
return e.swapTransaction = void 0, e.approvalTransaction = {
|
|
364
|
-
data: s.data,
|
|
365
|
-
to: s.to,
|
|
366
|
-
gasPrice: s.gasPrice,
|
|
367
|
-
value: s.value,
|
|
368
|
-
toAmount: s.toAmount
|
|
369
|
-
}, {
|
|
370
|
-
data: s.data,
|
|
371
|
-
to: s.to,
|
|
372
|
-
gasPrice: s.gasPrice,
|
|
373
|
-
value: s.value,
|
|
374
|
-
toAmount: s.toAmount
|
|
375
|
-
};
|
|
376
|
-
} catch {
|
|
377
|
-
S.goBack(), f.showError("Failed to create approval transaction"), e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
async createSwapTransaction() {
|
|
383
|
-
var u;
|
|
384
|
-
const { networkAddress: t, fromCaipAddress: n, sourceTokenAmount: o } = r.getParams(), a = e.sourceToken, s = e.toToken;
|
|
385
|
-
if (!n || !o || !a || !s)
|
|
386
|
-
return;
|
|
387
|
-
const i = (u = N.parseUnits(o, a.decimals)) == null ? void 0 : u.toString();
|
|
388
|
-
try {
|
|
389
|
-
const c = await A.generateSwapCalldata({
|
|
390
|
-
userAddress: n,
|
|
391
|
-
from: a.address,
|
|
392
|
-
to: s.address,
|
|
393
|
-
amount: i,
|
|
394
|
-
disableEstimate: !0
|
|
395
|
-
}), T = a.address === t, d = BigInt(c.tx.eip155.gas), p = BigInt(c.tx.eip155.gasPrice), w = {
|
|
396
|
-
data: c.tx.data,
|
|
397
|
-
to: F.getPlainAddress(c.tx.to),
|
|
398
|
-
gas: d,
|
|
399
|
-
gasPrice: p,
|
|
400
|
-
value: BigInt(T ? i ?? "0" : "0"),
|
|
401
|
-
toAmount: e.toTokenAmount
|
|
402
|
-
};
|
|
403
|
-
return e.gasPriceInUSD = h.getGasPriceInUSD(e.networkPrice, d, p), e.approvalTransaction = void 0, e.swapTransaction = w, w;
|
|
404
|
-
} catch {
|
|
405
|
-
S.goBack(), f.showError("Failed to create transaction"), e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
// -- Send Transactions --------------------------------- //
|
|
410
|
-
async sendTransactionForApproval(t) {
|
|
411
|
-
var s, i, u, c;
|
|
412
|
-
const { fromAddress: n, isAuthConnector: o } = r.getParams();
|
|
413
|
-
e.loadingApprovalTransaction = !0;
|
|
414
|
-
const a = "Approve limit increase in your wallet";
|
|
415
|
-
o ? S.pushTransactionStack({
|
|
416
|
-
onSuccess() {
|
|
417
|
-
f.showLoading(a);
|
|
418
|
-
}
|
|
419
|
-
}) : f.showLoading(a);
|
|
420
|
-
try {
|
|
421
|
-
await N.sendTransaction({
|
|
422
|
-
address: n,
|
|
423
|
-
to: t.to,
|
|
424
|
-
data: t.data,
|
|
425
|
-
value: t.value,
|
|
426
|
-
chainNamespace: "eip155"
|
|
427
|
-
}), await r.swapTokens(), await r.getTransaction(), e.approvalTransaction = void 0, e.loadingApprovalTransaction = !1;
|
|
428
|
-
} catch (T) {
|
|
429
|
-
const d = T;
|
|
430
|
-
e.transactionError = d == null ? void 0 : d.shortMessage, e.loadingApprovalTransaction = !1, f.showError((d == null ? void 0 : d.shortMessage) || "Transaction error"), D.sendEvent({
|
|
431
|
-
type: "track",
|
|
432
|
-
event: "SWAP_APPROVAL_ERROR",
|
|
433
|
-
properties: {
|
|
434
|
-
message: (d == null ? void 0 : d.shortMessage) || (d == null ? void 0 : d.message) || "Unknown",
|
|
435
|
-
network: ((s = g.state.activeCaipNetwork) == null ? void 0 : s.caipNetworkId) || "",
|
|
436
|
-
swapFromToken: ((i = r.state.sourceToken) == null ? void 0 : i.symbol) || "",
|
|
437
|
-
swapToToken: ((u = r.state.toToken) == null ? void 0 : u.symbol) || "",
|
|
438
|
-
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
439
|
-
swapToAmount: r.state.toTokenAmount || "",
|
|
440
|
-
isSmartAccount: ((c = v.state.preferredAccountTypes) == null ? void 0 : c.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
async sendTransactionForSwap(t) {
|
|
446
|
-
var u, c, T, d, p, w, P, b, I, y, E, G, L, O;
|
|
447
|
-
if (!t)
|
|
448
|
-
return;
|
|
449
|
-
const { fromAddress: n, toTokenAmount: o, isAuthConnector: a } = r.getParams();
|
|
450
|
-
e.loadingTransaction = !0;
|
|
451
|
-
const s = `Swapping ${(u = e.sourceToken) == null ? void 0 : u.symbol} to ${l.formatNumberToLocalString(o, 3)} ${(c = e.toToken) == null ? void 0 : c.symbol}`, i = `Swapped ${(T = e.sourceToken) == null ? void 0 : T.symbol} to ${l.formatNumberToLocalString(o, 3)} ${(d = e.toToken) == null ? void 0 : d.symbol}`;
|
|
452
|
-
a ? S.pushTransactionStack({
|
|
453
|
-
onSuccess() {
|
|
454
|
-
S.replace("Account"), f.showLoading(s), U.resetState();
|
|
455
|
-
}
|
|
456
|
-
}) : f.showLoading("Confirm transaction in your wallet");
|
|
457
|
-
try {
|
|
458
|
-
const B = [(p = e.sourceToken) == null ? void 0 : p.address, (w = e.toToken) == null ? void 0 : w.address].join(","), m = await N.sendTransaction({
|
|
459
|
-
address: n,
|
|
460
|
-
to: t.to,
|
|
461
|
-
data: t.data,
|
|
462
|
-
value: t.value,
|
|
463
|
-
chainNamespace: "eip155"
|
|
464
|
-
});
|
|
465
|
-
return e.loadingTransaction = !1, f.showSuccess(i), D.sendEvent({
|
|
466
|
-
type: "track",
|
|
467
|
-
event: "SWAP_SUCCESS",
|
|
468
|
-
properties: {
|
|
469
|
-
network: ((P = g.state.activeCaipNetwork) == null ? void 0 : P.caipNetworkId) || "",
|
|
470
|
-
swapFromToken: ((b = r.state.sourceToken) == null ? void 0 : b.symbol) || "",
|
|
471
|
-
swapToToken: ((I = r.state.toToken) == null ? void 0 : I.symbol) || "",
|
|
472
|
-
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
473
|
-
swapToAmount: r.state.toTokenAmount || "",
|
|
474
|
-
isSmartAccount: ((y = v.state.preferredAccountTypes) == null ? void 0 : y.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
475
|
-
}
|
|
476
|
-
}), U.resetState(), a || S.replace("Account"), U.getMyTokensWithBalance(B), m;
|
|
477
|
-
} catch (B) {
|
|
478
|
-
const m = B;
|
|
479
|
-
e.transactionError = m == null ? void 0 : m.shortMessage, e.loadingTransaction = !1, f.showError((m == null ? void 0 : m.shortMessage) || "Transaction error"), D.sendEvent({
|
|
480
|
-
type: "track",
|
|
481
|
-
event: "SWAP_ERROR",
|
|
482
|
-
properties: {
|
|
483
|
-
message: (m == null ? void 0 : m.shortMessage) || (m == null ? void 0 : m.message) || "Unknown",
|
|
484
|
-
network: ((E = g.state.activeCaipNetwork) == null ? void 0 : E.caipNetworkId) || "",
|
|
485
|
-
swapFromToken: ((G = r.state.sourceToken) == null ? void 0 : G.symbol) || "",
|
|
486
|
-
swapToToken: ((L = r.state.toToken) == null ? void 0 : L.symbol) || "",
|
|
487
|
-
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
488
|
-
swapToAmount: r.state.toTokenAmount || "",
|
|
489
|
-
isSmartAccount: ((O = v.state.preferredAccountTypes) == null ? void 0 : O.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
// -- Checks -------------------------------------------- //
|
|
496
|
-
hasInsufficientToken(t, n) {
|
|
497
|
-
return h.isInsufficientSourceTokenForSwap(t, n, e.myTokensWithBalance);
|
|
498
|
-
},
|
|
499
|
-
// -- Calculations -------------------------------------- //
|
|
500
|
-
setTransactionDetails() {
|
|
501
|
-
const { toTokenAddress: t, toTokenDecimals: n } = r.getParams();
|
|
502
|
-
!t || !n || (e.gasPriceInUSD = h.getGasPriceInUSD(e.networkPrice, BigInt(e.gasFee), BigInt(z)), e.priceImpact = h.getPriceImpact({
|
|
503
|
-
sourceTokenAmount: e.sourceTokenAmount,
|
|
504
|
-
sourceTokenPriceInUSD: e.sourceTokenPriceInUSD,
|
|
505
|
-
toTokenPriceInUSD: e.toTokenPriceInUSD,
|
|
506
|
-
toTokenAmount: e.toTokenAmount
|
|
507
|
-
}), e.maxSlippage = h.getMaxSlippage(e.slippage, e.toTokenAmount), e.providerFee = h.getProviderFee(e.sourceTokenAmount));
|
|
508
|
-
}
|
|
509
|
-
}, r = V(U), se = X`
|
|
510
|
-
:host {
|
|
511
|
-
display: block;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
:host > button {
|
|
515
|
-
gap: var(--wui-spacing-xxs);
|
|
516
|
-
padding: var(--wui-spacing-xs);
|
|
517
|
-
padding-right: var(--wui-spacing-1xs);
|
|
518
|
-
height: 40px;
|
|
519
|
-
border-radius: var(--wui-border-radius-l);
|
|
520
|
-
background: var(--wui-color-gray-glass-002);
|
|
521
|
-
border-width: 0px;
|
|
522
|
-
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
:host > button wui-image {
|
|
526
|
-
width: 24px;
|
|
527
|
-
height: 24px;
|
|
528
|
-
border-radius: var(--wui-border-radius-s);
|
|
529
|
-
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
|
|
530
|
-
}
|
|
531
|
-
`;
|
|
532
|
-
var _ = function(t, n, o, a) {
|
|
533
|
-
var s = arguments.length, i = s < 3 ? n : a === null ? a = Object.getOwnPropertyDescriptor(n, o) : a, u;
|
|
534
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, n, o, a);
|
|
535
|
-
else for (var c = t.length - 1; c >= 0; c--) (u = t[c]) && (i = (s < 3 ? u(i) : s > 3 ? u(n, o, i) : u(n, o)) || i);
|
|
536
|
-
return s > 3 && i && Object.defineProperty(n, o, i), i;
|
|
537
|
-
};
|
|
538
|
-
let C = class extends te {
|
|
539
|
-
constructor() {
|
|
540
|
-
super(...arguments), this.text = "";
|
|
541
|
-
}
|
|
542
|
-
render() {
|
|
543
|
-
return M`
|
|
544
|
-
<button>
|
|
545
|
-
${this.tokenTemplate()}
|
|
546
|
-
<wui-text variant="paragraph-600" color="fg-100">${this.text}</wui-text>
|
|
547
|
-
</button>
|
|
548
|
-
`;
|
|
549
|
-
}
|
|
550
|
-
tokenTemplate() {
|
|
551
|
-
return this.imageSrc ? M`<wui-image src=${this.imageSrc}></wui-image>` : M`
|
|
552
|
-
<wui-icon-box
|
|
553
|
-
size="sm"
|
|
554
|
-
iconColor="fg-200"
|
|
555
|
-
backgroundColor="fg-300"
|
|
556
|
-
icon="networkPlaceholder"
|
|
557
|
-
></wui-icon-box>
|
|
558
|
-
`;
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
C.styles = [Z, ee, se];
|
|
562
|
-
_([
|
|
563
|
-
q()
|
|
564
|
-
], C.prototype, "imageSrc", void 0);
|
|
565
|
-
_([
|
|
566
|
-
q()
|
|
567
|
-
], C.prototype, "text", void 0);
|
|
568
|
-
C = _([
|
|
569
|
-
ne("wui-token-button")
|
|
570
|
-
], C);
|
|
571
|
-
export {
|
|
572
|
-
r as S
|
|
573
|
-
};
|