@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.
Files changed (228) hide show
  1. package/dist/ExchangeController-CbO41bcH.js +217 -0
  2. package/dist/HelpersUtil-DHm6EVSE.js +120 -0
  3. package/dist/NavigationUtil-kj9LEOOd.js +8 -0
  4. package/dist/PhArrowCircleDown-lsK25DCk.js +73 -0
  5. package/dist/PhArrowClockwise-NeKHZ1co.js +73 -0
  6. package/dist/PhArrowDown-C9AkNvLs.js +73 -0
  7. package/dist/PhArrowLeft-RNfIQP1X.js +73 -0
  8. package/dist/PhArrowRight-DM1tna0G.js +73 -0
  9. package/dist/PhArrowSquareOut-S5XYbAZj.js +73 -0
  10. package/dist/PhArrowUp-DmktzOWy.js +73 -0
  11. package/dist/PhArrowUpRight-BkNeW_5i.js +73 -0
  12. package/dist/PhArrowsClockwise-CQ4pG76b.js +73 -0
  13. package/dist/PhArrowsDownUp-H6gxaNM6.js +73 -0
  14. package/dist/PhArrowsLeftRight-DZSsfMR6.js +73 -0
  15. package/dist/PhBank-4_9QzqIB.js +73 -0
  16. package/dist/PhBrowser-B-JSznId.js +73 -0
  17. package/dist/PhCaretDown-vV5oHMNi.js +73 -0
  18. package/dist/PhCaretLeft-BLo6Y_f4.js +73 -0
  19. package/dist/PhCaretRight-CqQN4TT3.js +73 -0
  20. package/dist/PhCaretUp-Df7UCAHy.js +73 -0
  21. package/dist/PhCheck-gtpfK4ed.js +73 -0
  22. package/dist/PhCircleHalf-Uq7dwDYw.js +73 -0
  23. package/dist/PhClock-SDCW-NmF.js +73 -0
  24. package/dist/PhCompass-B7hgtdx-.js +73 -0
  25. package/dist/PhCopy-BcnhyXCy.js +73 -0
  26. package/dist/PhCreditCard-BJjByVgu.js +73 -0
  27. package/dist/PhCurrencyDollar-B7ZXqXBy.js +73 -0
  28. package/dist/PhDesktop-B3VKPuJx.js +73 -0
  29. package/dist/PhDeviceMobile-Bnd0TYEH.js +73 -0
  30. package/dist/PhDotsThree-yyMWyZ-R.js +73 -0
  31. package/dist/PhEnvelope-67uzHbI9.js +73 -0
  32. package/dist/PhFunnelSimple-B-DCsloI.js +73 -0
  33. package/dist/PhGlobe-TMm_6qGk.js +73 -0
  34. package/dist/PhIdentificationCard-CePPD2xc.js +73 -0
  35. package/dist/PhImage-gY96WtHR.js +73 -0
  36. package/dist/PhInfo-DRQM_ZDP.js +73 -0
  37. package/dist/PhLightbulb-B0TxPfZ1.js +73 -0
  38. package/dist/PhMagnifyingGlass-B8si5_6W.js +73 -0
  39. package/dist/PhPaperPlaneRight-DVu5PLYd.js +73 -0
  40. package/dist/PhPlus-BfTsQnUz.js +73 -0
  41. package/dist/PhPower-CxYUGOWn.js +73 -0
  42. package/dist/PhPuzzlePiece-CQ4wh0gV.js +73 -0
  43. package/dist/PhQrCode-BuJ97NYJ.js +73 -0
  44. package/dist/PhQuestion-kJoP8Mja.js +73 -0
  45. package/dist/PhQuestionMark-C46ZkFpu.js +73 -0
  46. package/dist/PhSealCheck-Eh8jVqSN.js +73 -0
  47. package/dist/PhSignOut-jk97OSVt.js +73 -0
  48. package/dist/PhSpinner-CiYOhwMg.js +73 -0
  49. package/dist/PhTrash-pxerMqzd.js +73 -0
  50. package/dist/PhUser-BMg0VV4A.js +73 -0
  51. package/dist/PhVault-DYQvx5A-.js +73 -0
  52. package/dist/PhWarning-NLC5Mj87.js +73 -0
  53. package/dist/PhWarningCircle-Ch2jU9fA.js +73 -0
  54. package/dist/PhX-Bx4wpwm3.js +73 -0
  55. package/dist/SwapController-Ch0FFTEt.js +457 -0
  56. package/dist/{ccip-BIGqktC1.js → ccip-BrGhNXIM.js} +4 -4
  57. package/dist/data-capture-CpafmuCb.js +490 -0
  58. package/dist/dcp-sdk.umd.js +7400 -6589
  59. package/dist/email-Dcg4jlai.js +344 -0
  60. package/dist/embedded-wallet-DeoRdAPw.js +820 -0
  61. package/dist/features-B9Nde43h.js +274 -0
  62. package/dist/{hashTypedData-ZH9ZnWu3.js → hashTypedData-a7b8tdkO.js} +6 -6
  63. package/dist/if-defined-k21LutCn.js +10 -0
  64. package/dist/index-9vLw53Xl.js +228 -0
  65. package/dist/index-B5wUyynz.js +107 -0
  66. package/dist/index-B8LkUrww.js +86 -0
  67. package/dist/{index-CPTcEPbD.js → index-BA0VwKg0.js} +296 -298
  68. package/dist/index-BB9JJ24N.js +125 -0
  69. package/dist/index-BCkEvPQ6.js +172 -0
  70. package/dist/index-BDeO_csr.js +171 -0
  71. package/dist/index-Bb7babLF.js +1281 -0
  72. package/dist/index-BjOhprVS.js +199 -0
  73. package/dist/{index-Dy4NyE6l.js → index-BjyMgZsf.js} +7 -7
  74. package/dist/index-BkThIDLX.js +159 -0
  75. package/dist/index-BmFs6nb7.js +209 -0
  76. package/dist/{index-5mp7WkhV.js → index-C4qc4PdD.js} +2 -2
  77. package/dist/{index-BdSIrl-R.js → index-CAPvUh14.js} +578 -570
  78. package/dist/index-CBMU3PTE.js +65 -0
  79. package/dist/index-CGwPkJLF.js +355 -0
  80. package/dist/index-CNGEqX3D.js +153 -0
  81. package/dist/index-CRlCq6IB.js +7981 -0
  82. package/dist/index-Cg_o-i9X.js +118 -0
  83. package/dist/index-D1BvhCbI.js +62 -0
  84. package/dist/index-DFi8TiHc.js +128 -0
  85. package/dist/index-DLwuveL9.js +555 -0
  86. package/dist/index-DMn7ktUQ.js +56 -0
  87. package/dist/index-DOXwtuwa.js +117 -0
  88. package/dist/index-DPPOW_Tp.js +118 -0
  89. package/dist/{index-f3LXSfM5.js → index-DQpzHpW-.js} +56 -142
  90. package/dist/{index-D6h-qfpt.js → index-DXHg5C-W.js} +5 -5
  91. package/dist/index-DcYjZV4H.js +110 -0
  92. package/dist/{index-BJ7cbG3N.js → index-DeL88Lwc.js} +36769 -40177
  93. package/dist/index-DrWVlf8b.js +46 -0
  94. package/dist/index-Dsfuc4rB.js +123 -0
  95. package/dist/index-DuTny38n.js +1175 -0
  96. package/dist/{index-D5r0iSq4.js → index-Nfjb6bV0.js} +1 -1
  97. package/dist/index-WwwdQSN2.js +85 -0
  98. package/dist/index-Yha9Afch.js +174 -0
  99. package/dist/index-cbQHN7GC.js +100 -0
  100. package/dist/{index-DobBVPe4.js → index-hyG3cYsv.js} +481 -236
  101. package/dist/index-qLxmmPaL.js +257 -0
  102. package/dist/index.js +1 -1
  103. package/dist/{localBatchGatewayRequest-CjGcn5nM.js → localBatchGatewayRequest-vfcvRH0G.js} +1 -1
  104. package/dist/onramp-BSiyOX4L.js +855 -0
  105. package/dist/{parseSignature-S8VEpRHC.js → parseSignature-CdCMAPZN.js} +2312 -2313
  106. package/dist/pay-with-exchange-CduNoMEz.js +525 -0
  107. package/dist/property-Bd8U3_QP.js +618 -0
  108. package/dist/receive-CrmptJlq.js +232 -0
  109. package/dist/ref-SOwYtCZb.js +107 -0
  110. package/dist/send-oMcHMEr6.js +1166 -0
  111. package/dist/socials-C0A4-FbY.js +620 -0
  112. package/dist/swaps-CbJJ9Ciu.js +1760 -0
  113. package/dist/{transactions-DujFkB-M.js → transactions-BDfCoBS5.js} +10 -10
  114. package/dist/w3m-modal-BjsTkny7.js +1706 -0
  115. package/package.json +3 -3
  116. package/dist/ConstantsUtil-B-_-u8aQ.js +0 -6
  117. package/dist/add-sji6scSD.js +0 -19
  118. package/dist/all-wallets-B4H-890E.js +0 -10
  119. package/dist/app-store-Z433s97G.js +0 -21
  120. package/dist/apple-b8Lxj7nb.js +0 -22
  121. package/dist/arrow-bottom-M9oWWo_9.js +0 -12
  122. package/dist/arrow-bottom-circle-N9c4CXY1.js +0 -15
  123. package/dist/arrow-left-Dw8AKfwf.js +0 -12
  124. package/dist/arrow-right-DwLQZSC_.js +0 -12
  125. package/dist/arrow-top-zhUjkBe1.js +0 -12
  126. package/dist/bank-CbQdnILK.js +0 -18
  127. package/dist/browser-xAqNwt7z.js +0 -18
  128. package/dist/card-Dr1QBmWp.js +0 -18
  129. package/dist/checkmark-BhT1dTgG.js +0 -15
  130. package/dist/checkmark-bold-CPB29wqQ.js +0 -12
  131. package/dist/chevron-bottom-BhNyx2II.js +0 -12
  132. package/dist/chevron-left-CGuEjQlY.js +0 -12
  133. package/dist/chevron-right-CvIRRsqZ.js +0 -12
  134. package/dist/chevron-top-RSzCqjBd.js +0 -12
  135. package/dist/chrome-store-Cs8dAgs0.js +0 -65
  136. package/dist/clock-fhZO5otC.js +0 -12
  137. package/dist/close-BPuztrdR.js +0 -12
  138. package/dist/coinPlaceholder-C8X2i7Kh.js +0 -12
  139. package/dist/compass-WMc5huk0.js +0 -12
  140. package/dist/copy-DVAeT17y.js +0 -19
  141. package/dist/cursor-BJ4YLXfy.js +0 -7
  142. package/dist/cursor-transparent-DN2fLQN4.js +0 -16
  143. package/dist/desktop-6avxisBw.js +0 -13
  144. package/dist/disconnect-AReVI8Gk.js +0 -12
  145. package/dist/discord-CxrI30BZ.js +0 -21
  146. package/dist/email-B8dIIaay.js +0 -696
  147. package/dist/embedded-wallet-C_5hF7rM.js +0 -468
  148. package/dist/etherscan-BnAy8cIF.js +0 -10
  149. package/dist/exclamation-triangle-Bu7nHwx9.js +0 -8
  150. package/dist/extension-F0LIhvcf.js +0 -12
  151. package/dist/external-link-CP6phyaM.js +0 -12
  152. package/dist/facebook-BtQ-Io2y.js +0 -30
  153. package/dist/farcaster-BmaN1ugd.js +0 -16
  154. package/dist/filters-DpEwoOmy.js +0 -12
  155. package/dist/github-q7qO9V-b.js +0 -22
  156. package/dist/google-DH_ZE8bW.js +0 -22
  157. package/dist/help-circle-BAQVmKas.js +0 -16
  158. package/dist/id-Cj68Zwgo.js +0 -16
  159. package/dist/if-defined-CNte9B3N.js +0 -744
  160. package/dist/image-BKJDw6N-.js +0 -8
  161. package/dist/index-7toZMdtG.js +0 -573
  162. package/dist/index-B1uKzdvN.js +0 -170
  163. package/dist/index-BHFZVF-b.js +0 -257
  164. package/dist/index-BKwa5JSA.js +0 -559
  165. package/dist/index-BP4B9VUt.js +0 -54
  166. package/dist/index-BVdzXHpO.js +0 -181
  167. package/dist/index-BYND0GJ9.js +0 -146
  168. package/dist/index-BaJ0zEbh.js +0 -97
  169. package/dist/index-Bh0MPFwP.js +0 -58
  170. package/dist/index-Bsh7_qTp.js +0 -511
  171. package/dist/index-BwnXTNNg.js +0 -199
  172. package/dist/index-C0kPDbg_.js +0 -77
  173. package/dist/index-CKikVKe2.js +0 -75
  174. package/dist/index-ChVh0Hkp.js +0 -243
  175. package/dist/index-Cle_NnnS.js +0 -305
  176. package/dist/index-CmWdvIFT.js +0 -51
  177. package/dist/index-D2AMA8Bu.js +0 -65
  178. package/dist/index-DAUM8CO4.js +0 -65
  179. package/dist/index-DGjZW6uR.js +0 -78
  180. package/dist/index-DQe94z7X.js +0 -265
  181. package/dist/index-DTo6w99t.js +0 -7864
  182. package/dist/index-DYdXjap2.js +0 -320
  183. package/dist/index-DceCxNV5.js +0 -181
  184. package/dist/index-Uw9cSw0q.js +0 -294
  185. package/dist/index-qiuyrukh.js +0 -45
  186. package/dist/index-zddvaohA.js +0 -78
  187. package/dist/info-RfPsmroW.js +0 -7
  188. package/dist/info-circle-DFKHB_ZN.js +0 -16
  189. package/dist/lightbulb-B-Bykj9X.js +0 -7
  190. package/dist/mail-mBAgGuw5.js +0 -12
  191. package/dist/mobile-Dhh3ndkf.js +0 -13
  192. package/dist/more-D1h7UTvg.js +0 -15
  193. package/dist/network-placeholder-Dqynvc-t.js +0 -18
  194. package/dist/nftPlaceholder-Df7MW4MM.js +0 -12
  195. package/dist/off-BmG3cHTX.js +0 -12
  196. package/dist/onramp-C401Aenb.js +0 -1279
  197. package/dist/play-store-4q1fzL_P.js +0 -36
  198. package/dist/plus-603Gs3yG.js +0 -17
  199. package/dist/qr-code-Dgwhf6M1.js +0 -10
  200. package/dist/receive-CYXbbEUR.js +0 -186
  201. package/dist/recycle-horizontal-Bu8zZ563.js +0 -13
  202. package/dist/ref-DpmKRWBK.js +0 -41
  203. package/dist/refresh-BMZFu0mu.js +0 -12
  204. package/dist/reown-logo-BXph7ThY.js +0 -16
  205. package/dist/search-Cm_V42Y_.js +0 -12
  206. package/dist/secp256k1-C0iX1TUr.js +0 -1510
  207. package/dist/secp256k1-DOQBqE4Z.js +0 -1302
  208. package/dist/send-BSMYxDuP.js +0 -19
  209. package/dist/send-C8EeIzRB.js +0 -1038
  210. package/dist/socials-DQrHQajs.js +0 -574
  211. package/dist/swapHorizontal-98rnJewS.js +0 -12
  212. package/dist/swapHorizontalBold-C299FjEt.js +0 -12
  213. package/dist/swapHorizontalMedium-Cqm6i4WJ.js +0 -20
  214. package/dist/swapHorizontalRoundedBold-De7hFfqZ.js +0 -12
  215. package/dist/swapVertical-DSL75l8L.js +0 -12
  216. package/dist/swaps-BuTNp65Y.js +0 -1637
  217. package/dist/telegram-cJP7hgUb.js +0 -20
  218. package/dist/three-dots-DHnEh28O.js +0 -9
  219. package/dist/twitch-CR2iGcBo.js +0 -22
  220. package/dist/twitterIcon-E5TAQjOn.js +0 -10
  221. package/dist/verify-DEukUJp0.js +0 -12
  222. package/dist/verify-filled-BXsx1i_p.js +0 -12
  223. package/dist/w3m-modal-Bm7BqVng.js +0 -1037
  224. package/dist/wallet-CzyyvdrT.js +0 -12
  225. package/dist/wallet-placeholder-BrcmyGEe.js +0 -18
  226. package/dist/walletconnect-BSYogWiE.js +0 -36
  227. package/dist/warning-circle-Cgp2BW3m.js +0 -16
  228. package/dist/x-BJinLpTw.js +0 -16
@@ -1,1637 +0,0 @@
1
- import { cE as P, cF as C, cY as D, d7 as j, cG as u, db as K, d8 as W, cJ as S, cX as _, d1 as V, cS as M, d0 as F, cH as Q, cI as q } from "./index-BJ7cbG3N.js";
2
- import { r as s, n as h, c as E, U as m } from "./if-defined-CNte9B3N.js";
3
- import "./index-Uw9cSw0q.js";
4
- import { M as L } from "./index-zddvaohA.js";
5
- import "./index-BYND0GJ9.js";
6
- import { S as n } from "./index-7toZMdtG.js";
7
- import "./index-C0kPDbg_.js";
8
- import "./index-DQe94z7X.js";
9
- import "./index-CmWdvIFT.js";
10
- const H = {
11
- numericInputKeyDown(c, t, e) {
12
- const o = [
13
- "Backspace",
14
- "Meta",
15
- "Ctrl",
16
- "a",
17
- "A",
18
- "c",
19
- "C",
20
- "x",
21
- "X",
22
- "v",
23
- "V",
24
- "ArrowLeft",
25
- "ArrowRight",
26
- "Tab"
27
- ], a = c.metaKey || c.ctrlKey, i = c.key, r = i.toLocaleLowerCase(), l = r === "a", x = r === "c", v = r === "v", R = r === "x", U = i === ",", O = i === ".", B = i >= "0" && i <= "9";
28
- !a && (l || x || v || R) && c.preventDefault(), t === "0" && !U && !O && i === "0" && c.preventDefault(), t === "0" && B && (e(i), c.preventDefault()), (U || O) && (t || (e("0."), c.preventDefault()), (t != null && t.includes(".") || t != null && t.includes(",")) && c.preventDefault()), !B && !o.includes(i) && !O && !U && c.preventDefault();
29
- }
30
- }, G = P`
31
- :host {
32
- width: 100%;
33
- }
34
-
35
- .details-container > wui-flex {
36
- background: var(--wui-color-gray-glass-002);
37
- border-radius: var(--wui-border-radius-xxs);
38
- width: 100%;
39
- }
40
-
41
- .details-container > wui-flex > button {
42
- border: none;
43
- background: none;
44
- padding: var(--wui-spacing-s);
45
- border-radius: var(--wui-border-radius-xxs);
46
- cursor: pointer;
47
- }
48
-
49
- .details-content-container {
50
- padding: var(--wui-spacing-1xs);
51
- padding-top: 0px;
52
- display: flex;
53
- align-items: center;
54
- justify-content: center;
55
- }
56
-
57
- .details-content-container > wui-flex {
58
- width: 100%;
59
- }
60
-
61
- .details-row {
62
- width: 100%;
63
- padding: var(--wui-spacing-s);
64
- padding-left: var(--wui-spacing-s);
65
- padding-right: var(--wui-spacing-1xs);
66
- border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs));
67
- background: var(--wui-color-gray-glass-002);
68
- }
69
-
70
- .details-row-title {
71
- white-space: nowrap;
72
- }
73
-
74
- .details-row.provider-free-row {
75
- padding-right: var(--wui-spacing-xs);
76
- }
77
- `;
78
- var k = function(c, t, e, o) {
79
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
80
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
81
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
82
- return a > 3 && i && Object.defineProperty(t, e, i), i;
83
- };
84
- const X = K.CONVERT_SLIPPAGE_TOLERANCE;
85
- let f = class extends C {
86
- constructor() {
87
- var t;
88
- super(), this.unsubscribe = [], this.networkName = (t = D.state.activeCaipNetwork) == null ? void 0 : t.name, this.detailsOpen = !1, this.sourceToken = n.state.sourceToken, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount, this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.priceImpact = n.state.priceImpact, this.maxSlippage = n.state.maxSlippage, this.networkTokenSymbol = n.state.networkTokenSymbol, this.inputError = n.state.inputError, this.unsubscribe.push(n.subscribe((e) => {
89
- this.sourceToken = e.sourceToken, this.toToken = e.toToken, this.toTokenAmount = e.toTokenAmount, this.priceImpact = e.priceImpact, this.maxSlippage = e.maxSlippage, this.sourceTokenPriceInUSD = e.sourceTokenPriceInUSD, this.toTokenPriceInUSD = e.toTokenPriceInUSD, this.inputError = e.inputError;
90
- }));
91
- }
92
- render() {
93
- const t = this.toTokenAmount && this.maxSlippage ? j.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString() : null;
94
- if (!this.sourceToken || !this.toToken || this.inputError)
95
- return null;
96
- const e = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD ? 1 / this.toTokenPriceInUSD * this.sourceTokenPriceInUSD : 0;
97
- return u`
98
- <wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container">
99
- <wui-flex flexDirection="column">
100
- <button @click=${this.toggleDetails.bind(this)}>
101
- <wui-flex justifyContent="space-between" .padding=${["0", "xs", "0", "xs"]}>
102
- <wui-flex justifyContent="flex-start" flexGrow="1" gap="xs">
103
- <wui-text variant="small-400" color="fg-100">
104
- 1 ${this.sourceToken.symbol} =
105
- ${m.formatNumberToLocalString(e, 3)}
106
- ${this.toToken.symbol}
107
- </wui-text>
108
- <wui-text variant="small-400" color="fg-200">
109
- $${m.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
110
- </wui-text>
111
- </wui-flex>
112
- <wui-icon name="chevronBottom"></wui-icon>
113
- </wui-flex>
114
- </button>
115
- ${this.detailsOpen ? u`
116
- <wui-flex flexDirection="column" gap="xs" class="details-content-container">
117
- ${this.priceImpact ? u` <wui-flex flexDirection="column" gap="xs">
118
- <wui-flex
119
- justifyContent="space-between"
120
- alignItems="center"
121
- class="details-row"
122
- >
123
- <wui-flex alignItems="center" gap="xs">
124
- <wui-text class="details-row-title" variant="small-400" color="fg-150">
125
- Price impact
126
- </wui-text>
127
- <w3m-tooltip-trigger
128
- text="Price impact reflects the change in market price due to your trade"
129
- >
130
- <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
131
- </w3m-tooltip-trigger>
132
- </wui-flex>
133
- <wui-flex>
134
- <wui-text variant="small-400" color="fg-200">
135
- ${m.formatNumberToLocalString(this.priceImpact, 3)}%
136
- </wui-text>
137
- </wui-flex>
138
- </wui-flex>
139
- </wui-flex>` : null}
140
- ${this.maxSlippage && this.sourceToken.symbol ? u`<wui-flex flexDirection="column" gap="xs">
141
- <wui-flex
142
- justifyContent="space-between"
143
- alignItems="center"
144
- class="details-row"
145
- >
146
- <wui-flex alignItems="center" gap="xs">
147
- <wui-text class="details-row-title" variant="small-400" color="fg-150">
148
- Max. slippage
149
- </wui-text>
150
- <w3m-tooltip-trigger
151
- text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${t ? `Transaction will be reversed if you receive less than ${m.formatNumberToLocalString(t, 6)} ${this.toToken.symbol} due to price changes.` : ""}`}
152
- >
153
- <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
154
- </w3m-tooltip-trigger>
155
- </wui-flex>
156
- <wui-flex>
157
- <wui-text variant="small-400" color="fg-200">
158
- ${m.formatNumberToLocalString(this.maxSlippage, 6)}
159
- ${this.toToken.symbol} ${X}%
160
- </wui-text>
161
- </wui-flex>
162
- </wui-flex>
163
- </wui-flex>` : null}
164
- <wui-flex flexDirection="column" gap="xs">
165
- <wui-flex
166
- justifyContent="space-between"
167
- alignItems="center"
168
- class="details-row provider-free-row"
169
- >
170
- <wui-flex alignItems="center" gap="xs">
171
- <wui-text class="details-row-title" variant="small-400" color="fg-150">
172
- Provider fee
173
- </wui-text>
174
- </wui-flex>
175
- <wui-flex>
176
- <wui-text variant="small-400" color="fg-200">0.85%</wui-text>
177
- </wui-flex>
178
- </wui-flex>
179
- </wui-flex>
180
- </wui-flex>
181
- ` : null}
182
- </wui-flex>
183
- </wui-flex>
184
- `;
185
- }
186
- toggleDetails() {
187
- this.detailsOpen = !this.detailsOpen;
188
- }
189
- };
190
- f.styles = [G];
191
- k([
192
- s()
193
- ], f.prototype, "networkName", void 0);
194
- k([
195
- h()
196
- ], f.prototype, "detailsOpen", void 0);
197
- k([
198
- s()
199
- ], f.prototype, "sourceToken", void 0);
200
- k([
201
- s()
202
- ], f.prototype, "toToken", void 0);
203
- k([
204
- s()
205
- ], f.prototype, "toTokenAmount", void 0);
206
- k([
207
- s()
208
- ], f.prototype, "sourceTokenPriceInUSD", void 0);
209
- k([
210
- s()
211
- ], f.prototype, "toTokenPriceInUSD", void 0);
212
- k([
213
- s()
214
- ], f.prototype, "priceImpact", void 0);
215
- k([
216
- s()
217
- ], f.prototype, "maxSlippage", void 0);
218
- k([
219
- s()
220
- ], f.prototype, "networkTokenSymbol", void 0);
221
- k([
222
- s()
223
- ], f.prototype, "inputError", void 0);
224
- f = k([
225
- E("w3m-swap-details")
226
- ], f);
227
- const Y = P`
228
- :host {
229
- width: 100%;
230
- }
231
-
232
- :host > wui-flex {
233
- display: flex;
234
- flex-direction: row;
235
- justify-content: space-between;
236
- align-items: center;
237
- border-radius: var(--wui-border-radius-s);
238
- padding: var(--wui-spacing-xl);
239
- padding-right: var(--wui-spacing-s);
240
- background-color: var(--wui-color-gray-glass-002);
241
- box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
242
- width: 100%;
243
- height: 100px;
244
- box-sizing: border-box;
245
- position: relative;
246
- }
247
-
248
- wui-shimmer.market-value {
249
- opacity: 0;
250
- }
251
-
252
- :host > wui-flex > svg.input_mask {
253
- position: absolute;
254
- inset: 0;
255
- z-index: 5;
256
- }
257
-
258
- :host wui-flex .input_mask__border,
259
- :host wui-flex .input_mask__background {
260
- transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1);
261
- will-change: fill;
262
- }
263
-
264
- :host wui-flex .input_mask__border {
265
- fill: var(--wui-color-gray-glass-020);
266
- }
267
-
268
- :host wui-flex .input_mask__background {
269
- fill: var(--wui-color-gray-glass-002);
270
- }
271
- `;
272
- var z = function(c, t, e, o) {
273
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
274
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
275
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
276
- return a > 3 && i && Object.defineProperty(t, e, i), i;
277
- };
278
- let N = class extends C {
279
- constructor() {
280
- super(...arguments), this.target = "sourceToken";
281
- }
282
- render() {
283
- return u`
284
- <wui-flex class justifyContent="space-between">
285
- <wui-flex
286
- flex="1"
287
- flexDirection="column"
288
- alignItems="flex-start"
289
- justifyContent="center"
290
- class="swap-input"
291
- gap="xxs"
292
- >
293
- <wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer>
294
- </wui-flex>
295
- ${this.templateTokenSelectButton()}
296
- </wui-flex>
297
- `;
298
- }
299
- templateTokenSelectButton() {
300
- return u`
301
- <wui-flex
302
- class="swap-token-button"
303
- flexDirection="column"
304
- alignItems="flex-end"
305
- justifyContent="center"
306
- gap="xxs"
307
- >
308
- <wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer>
309
- </wui-flex>
310
- `;
311
- }
312
- };
313
- N.styles = [Y];
314
- z([
315
- h()
316
- ], N.prototype, "target", void 0);
317
- N = z([
318
- E("w3m-swap-input-skeleton")
319
- ], N);
320
- const J = P`
321
- :host > wui-flex {
322
- display: flex;
323
- flex-direction: row;
324
- justify-content: space-between;
325
- align-items: center;
326
- border-radius: var(--wui-border-radius-s);
327
- background-color: var(--wui-color-gray-glass-002);
328
- padding: var(--wui-spacing-xl);
329
- padding-right: var(--wui-spacing-s);
330
- width: 100%;
331
- height: 100px;
332
- box-sizing: border-box;
333
- box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
334
- position: relative;
335
- transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg);
336
- will-change: background-color;
337
- }
338
-
339
- :host wui-flex.focus {
340
- box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005);
341
- }
342
-
343
- :host > wui-flex .swap-input,
344
- :host > wui-flex .swap-token-button {
345
- z-index: 10;
346
- }
347
-
348
- :host > wui-flex .swap-input {
349
- -webkit-mask-image: linear-gradient(
350
- 270deg,
351
- transparent 0px,
352
- transparent 8px,
353
- black 24px,
354
- black 25px,
355
- black 32px,
356
- black 100%
357
- );
358
- mask-image: linear-gradient(
359
- 270deg,
360
- transparent 0px,
361
- transparent 8px,
362
- black 24px,
363
- black 25px,
364
- black 32px,
365
- black 100%
366
- );
367
- }
368
-
369
- :host > wui-flex .swap-input input {
370
- background: none;
371
- border: none;
372
- height: 42px;
373
- width: 100%;
374
- font-size: 32px;
375
- font-style: normal;
376
- font-weight: 400;
377
- line-height: 130%;
378
- letter-spacing: -1.28px;
379
- outline: none;
380
- caret-color: var(--wui-color-accent-100);
381
- color: var(--wui-color-fg-100);
382
- padding: 0px;
383
- }
384
-
385
- :host > wui-flex .swap-input input:focus-visible {
386
- outline: none;
387
- }
388
-
389
- :host > wui-flex .swap-input input::-webkit-outer-spin-button,
390
- :host > wui-flex .swap-input input::-webkit-inner-spin-button {
391
- -webkit-appearance: none;
392
- margin: 0;
393
- }
394
-
395
- .max-value-button {
396
- background-color: transparent;
397
- border: none;
398
- cursor: pointer;
399
- color: var(--wui-color-gray-glass-020);
400
- padding-left: 0px;
401
- }
402
-
403
- .market-value {
404
- min-height: 18px;
405
- }
406
- `;
407
- var y = function(c, t, e, o) {
408
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
409
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
410
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
411
- return a > 3 && i && Object.defineProperty(t, e, i), i;
412
- };
413
- const Z = 5e-5;
414
- let b = class extends C {
415
- constructor() {
416
- super(...arguments), this.focused = !1, this.price = 0, this.target = "sourceToken", this.onSetAmount = null, this.onSetMaxValue = null;
417
- }
418
- render() {
419
- const t = this.marketValue || "0", e = j.bigNumber(t).gt("0");
420
- return u`
421
- <wui-flex class="${this.focused ? "focus" : ""}" justifyContent="space-between">
422
- <wui-flex
423
- flex="1"
424
- flexDirection="column"
425
- alignItems="flex-start"
426
- justifyContent="center"
427
- class="swap-input"
428
- >
429
- <input
430
- data-testid="swap-input-${this.target}"
431
- @focusin=${() => this.onFocusChange(!0)}
432
- @focusout=${() => this.onFocusChange(!1)}
433
- ?disabled=${this.disabled}
434
- .value=${this.value}
435
- @input=${this.dispatchInputChangeEvent}
436
- @keydown=${this.handleKeydown}
437
- placeholder="0"
438
- type="text"
439
- inputmode="decimal"
440
- />
441
- <wui-text class="market-value" variant="small-400" color="fg-200">
442
- ${e ? `$${m.formatNumberToLocalString(this.marketValue, 2)}` : null}
443
- </wui-text>
444
- </wui-flex>
445
- ${this.templateTokenSelectButton()}
446
- </wui-flex>
447
- `;
448
- }
449
- handleKeydown(t) {
450
- return H.numericInputKeyDown(t, this.value, (e) => {
451
- var o;
452
- return (o = this.onSetAmount) == null ? void 0 : o.call(this, this.target, e);
453
- });
454
- }
455
- dispatchInputChangeEvent(t) {
456
- if (!this.onSetAmount)
457
- return;
458
- const e = t.target.value.replace(/[^0-9.]/gu, "");
459
- e === "," || e === "." ? this.onSetAmount(this.target, "0.") : e.endsWith(",") ? this.onSetAmount(this.target, e.replace(",", ".")) : this.onSetAmount(this.target, e);
460
- }
461
- setMaxValueToInput() {
462
- var t;
463
- (t = this.onSetMaxValue) == null || t.call(this, this.target, this.balance);
464
- }
465
- templateTokenSelectButton() {
466
- return this.token ? u`
467
- <wui-flex
468
- class="swap-token-button"
469
- flexDirection="column"
470
- alignItems="flex-end"
471
- justifyContent="center"
472
- gap="xxs"
473
- >
474
- <wui-token-button
475
- data-testid="swap-input-token-${this.target}"
476
- text=${this.token.symbol}
477
- imageSrc=${this.token.logoUri}
478
- @click=${this.onSelectToken.bind(this)}
479
- >
480
- </wui-token-button>
481
- <wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex>
482
- </wui-flex>
483
- ` : u` <wui-button
484
- data-testid="swap-select-token-button-${this.target}"
485
- class="swap-token-button"
486
- size="md"
487
- variant="accent"
488
- @click=${this.onSelectToken.bind(this)}
489
- >
490
- Select token
491
- </wui-button>`;
492
- }
493
- tokenBalanceTemplate() {
494
- const t = j.multiply(this.balance, this.price), e = t ? t == null ? void 0 : t.gt(Z) : !1;
495
- return u`
496
- ${e ? u`<wui-text variant="small-400" color="fg-200">
497
- ${m.formatNumberToLocalString(this.balance, 2)}
498
- </wui-text>` : null}
499
- ${this.target === "sourceToken" ? this.tokenActionButtonTemplate(e) : null}
500
- `;
501
- }
502
- tokenActionButtonTemplate(t) {
503
- return t ? u` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
504
- <wui-text color="accent-100" variant="small-600">Max</wui-text>
505
- </button>` : u` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
506
- <wui-text color="accent-100" variant="small-600">Buy</wui-text>
507
- </button>`;
508
- }
509
- onFocusChange(t) {
510
- this.focused = t;
511
- }
512
- onSelectToken() {
513
- W.sendEvent({ type: "track", event: "CLICK_SELECT_TOKEN_TO_SWAP" }), S.push("SwapSelectToken", {
514
- target: this.target
515
- });
516
- }
517
- onBuyToken() {
518
- S.push("OnRampProviders");
519
- }
520
- };
521
- b.styles = [J];
522
- y([
523
- h()
524
- ], b.prototype, "focused", void 0);
525
- y([
526
- h()
527
- ], b.prototype, "balance", void 0);
528
- y([
529
- h()
530
- ], b.prototype, "value", void 0);
531
- y([
532
- h()
533
- ], b.prototype, "price", void 0);
534
- y([
535
- h()
536
- ], b.prototype, "marketValue", void 0);
537
- y([
538
- h()
539
- ], b.prototype, "disabled", void 0);
540
- y([
541
- h()
542
- ], b.prototype, "target", void 0);
543
- y([
544
- h()
545
- ], b.prototype, "token", void 0);
546
- y([
547
- h()
548
- ], b.prototype, "onSetAmount", void 0);
549
- y([
550
- h()
551
- ], b.prototype, "onSetMaxValue", void 0);
552
- b = y([
553
- E("w3m-swap-input")
554
- ], b);
555
- const tt = P`
556
- :host > wui-flex:first-child {
557
- overflow-y: auto;
558
- overflow-x: hidden;
559
- scrollbar-width: none;
560
- }
561
-
562
- :host > wui-flex:first-child::-webkit-scrollbar {
563
- display: none;
564
- }
565
-
566
- wui-loading-hexagon {
567
- position: absolute;
568
- }
569
-
570
- .action-button {
571
- width: 100%;
572
- border-radius: var(--wui-border-radius-xs);
573
- }
574
-
575
- .action-button:disabled {
576
- border-color: 1px solid var(--wui-color-gray-glass-005);
577
- }
578
-
579
- .swap-inputs-container {
580
- position: relative;
581
- }
582
-
583
- .replace-tokens-button-container {
584
- display: flex;
585
- justify-content: center;
586
- align-items: center;
587
- position: absolute;
588
- top: 50%;
589
- left: 50%;
590
- transform: translate(-50%, -50%);
591
- gap: var(--wui-spacing-1xs);
592
- border-radius: var(--wui-border-radius-xs);
593
- background-color: var(--wui-color-modal-bg-base);
594
- padding: var(--wui-spacing-xxs);
595
- }
596
-
597
- .replace-tokens-button-container > button {
598
- display: flex;
599
- justify-content: center;
600
- align-items: center;
601
- height: 40px;
602
- width: 40px;
603
- padding: var(--wui-spacing-xs);
604
- border: none;
605
- border-radius: var(--wui-border-radius-xxs);
606
- background: var(--wui-color-gray-glass-002);
607
- transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1);
608
- will-change: background-color;
609
- z-index: 20;
610
- }
611
-
612
- .replace-tokens-button-container > button:hover {
613
- background: var(--wui-color-gray-glass-005);
614
- }
615
-
616
- .details-container > wui-flex {
617
- background: var(--wui-color-gray-glass-002);
618
- border-radius: var(--wui-border-radius-xxs);
619
- width: 100%;
620
- }
621
-
622
- .details-container > wui-flex > button {
623
- border: none;
624
- background: none;
625
- padding: var(--wui-spacing-s);
626
- border-radius: var(--wui-border-radius-xxs);
627
- transition: background 0.2s linear;
628
- }
629
-
630
- .details-container > wui-flex > button:hover {
631
- background: var(--wui-color-gray-glass-002);
632
- }
633
-
634
- .details-content-container {
635
- padding: var(--wui-spacing-1xs);
636
- display: flex;
637
- align-items: center;
638
- justify-content: center;
639
- }
640
-
641
- .details-content-container > wui-flex {
642
- width: 100%;
643
- }
644
-
645
- .details-row {
646
- width: 100%;
647
- padding: var(--wui-spacing-s) var(--wui-spacing-xl);
648
- border-radius: var(--wui-border-radius-xxs);
649
- background: var(--wui-color-gray-glass-002);
650
- }
651
- `;
652
- var w = function(c, t, e, o) {
653
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
654
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
655
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
656
- return a > 3 && i && Object.defineProperty(t, e, i), i;
657
- };
658
- let p = class extends C {
659
- constructor() {
660
- var t, e;
661
- super(), this.unsubscribe = [], this.initialParams = (t = S.state.data) == null ? void 0 : t.swap, this.detailsOpen = !1, this.caipAddress = _.state.caipAddress, this.caipNetworkId = (e = D.state.activeCaipNetwork) == null ? void 0 : e.caipNetworkId, this.initialized = n.state.initialized, this.loadingQuote = n.state.loadingQuote, this.loadingPrices = n.state.loadingPrices, this.loadingTransaction = n.state.loadingTransaction, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount, this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount, this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.inputError = n.state.inputError, this.fetchError = n.state.fetchError, this.onDebouncedGetSwapCalldata = V.debounce(async () => {
662
- await n.swapTokens();
663
- }, 200), D.subscribeKey("activeCaipNetwork", (o) => this.onCaipNetworkChange({
664
- newCaipNetwork: o,
665
- resetSwapState: !0,
666
- initializeSwapState: !1
667
- })), _.subscribeKey("caipAddress", (o) => this.onCaipAddressChange({
668
- newCaipAddress: o,
669
- resetSwapState: !0,
670
- initializeSwapState: !1
671
- })), this.unsubscribe.push(D.subscribeKey("activeCaipNetwork", (o) => this.onCaipNetworkChange({
672
- newCaipNetwork: o,
673
- resetSwapState: !1,
674
- initializeSwapState: !0
675
- })), _.subscribeKey("caipAddress", (o) => this.onCaipAddressChange({
676
- newCaipAddress: o,
677
- resetSwapState: !1,
678
- initializeSwapState: !0
679
- })), M.subscribeKey("open", (o) => {
680
- o || n.resetState();
681
- }), S.subscribeKey("view", (o) => {
682
- o.includes("Swap") || n.resetValues();
683
- }), n.subscribe((o) => {
684
- this.initialized = o.initialized, this.loadingQuote = o.loadingQuote, this.loadingPrices = o.loadingPrices, this.loadingTransaction = o.loadingTransaction, this.sourceToken = o.sourceToken, this.sourceTokenAmount = o.sourceTokenAmount, this.sourceTokenPriceInUSD = o.sourceTokenPriceInUSD, this.toToken = o.toToken, this.toTokenAmount = o.toTokenAmount, this.toTokenPriceInUSD = o.toTokenPriceInUSD, this.inputError = o.inputError, this.fetchError = o.fetchError;
685
- }));
686
- }
687
- async firstUpdated() {
688
- n.initializeState(), this.watchTokensAndValues(), await this.handleSwapParameters();
689
- }
690
- disconnectedCallback() {
691
- this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval);
692
- }
693
- render() {
694
- return u`
695
- <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
696
- ${this.initialized ? this.templateSwap() : this.templateLoading()}
697
- </wui-flex>
698
- `;
699
- }
700
- watchTokensAndValues() {
701
- this.interval = setInterval(() => {
702
- n.getNetworkTokenPrice(), n.getMyTokensWithBalance(), n.swapTokens();
703
- }, 1e4);
704
- }
705
- templateSwap() {
706
- return u`
707
- <wui-flex flexDirection="column" gap="s">
708
- <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
709
- ${this.templateTokenInput("sourceToken", this.sourceToken)}
710
- ${this.templateTokenInput("toToken", this.toToken)} ${this.templateReplaceTokensButton()}
711
- </wui-flex>
712
- ${this.templateDetails()} ${this.templateActionButton()}
713
- </wui-flex>
714
- `;
715
- }
716
- actionButtonLabel() {
717
- return this.fetchError ? "Swap" : !this.sourceToken || !this.toToken ? "Select token" : this.sourceTokenAmount ? this.inputError ? this.inputError : "Review swap" : "Enter amount";
718
- }
719
- templateReplaceTokensButton() {
720
- return u`
721
- <wui-flex class="replace-tokens-button-container">
722
- <button @click=${this.onSwitchTokens.bind(this)}>
723
- <wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon>
724
- </button>
725
- </wui-flex>
726
- `;
727
- }
728
- templateLoading() {
729
- return u`
730
- <wui-flex flexDirection="column" gap="l">
731
- <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
732
- <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
733
- <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
734
- ${this.templateReplaceTokensButton()}
735
- </wui-flex>
736
- ${this.templateActionButton()}
737
- </wui-flex>
738
- `;
739
- }
740
- templateTokenInput(t, e) {
741
- var l, x;
742
- const o = (l = n.state.myTokensWithBalance) == null ? void 0 : l.find((v) => (v == null ? void 0 : v.address) === (e == null ? void 0 : e.address)), a = t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount, i = t === "toToken" ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD, r = j.parseLocalStringToNumber(a) * i;
743
- return u`<w3m-swap-input
744
- .value=${t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount}
745
- .disabled=${t === "toToken"}
746
- .onSetAmount=${this.handleChangeAmount.bind(this)}
747
- target=${t}
748
- .token=${e}
749
- .balance=${(x = o == null ? void 0 : o.quantity) == null ? void 0 : x.numeric}
750
- .price=${o == null ? void 0 : o.price}
751
- .marketValue=${r}
752
- .onSetMaxValue=${this.onSetMaxValue.bind(this)}
753
- ></w3m-swap-input>`;
754
- }
755
- onSetMaxValue(t, e) {
756
- const o = j.bigNumber(e || "0");
757
- this.handleChangeAmount(t, o.gt(0) ? o.toFixed(20) : "0");
758
- }
759
- templateDetails() {
760
- return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
761
- }
762
- handleChangeAmount(t, e) {
763
- n.clearError(), t === "sourceToken" ? n.setSourceTokenAmount(e) : n.setToTokenAmount(e), this.onDebouncedGetSwapCalldata();
764
- }
765
- templateActionButton() {
766
- const t = !this.toToken || !this.sourceToken, e = !this.sourceTokenAmount, o = this.loadingQuote || this.loadingPrices || this.loadingTransaction, a = o || t || e || this.inputError;
767
- return u` <wui-flex gap="xs">
768
- <wui-button
769
- data-testid="swap-action-button"
770
- class="action-button"
771
- fullWidth
772
- size="lg"
773
- borderRadius="xs"
774
- variant=${t ? "neutral" : "main"}
775
- .loading=${o}
776
- .disabled=${a}
777
- @click=${this.onSwapPreview.bind(this)}
778
- >
779
- ${this.actionButtonLabel()}
780
- </wui-button>
781
- </wui-flex>`;
782
- }
783
- onSwitchTokens() {
784
- n.switchTokens();
785
- }
786
- async onSwapPreview() {
787
- var e, o, a;
788
- const t = D.state.activeChain;
789
- this.fetchError && await n.swapTokens(), W.sendEvent({
790
- type: "track",
791
- event: "INITIATE_SWAP",
792
- properties: {
793
- network: this.caipNetworkId || "",
794
- swapFromToken: ((e = this.sourceToken) == null ? void 0 : e.symbol) || "",
795
- swapToToken: ((o = this.toToken) == null ? void 0 : o.symbol) || "",
796
- swapFromAmount: this.sourceTokenAmount || "",
797
- swapToAmount: this.toTokenAmount || "",
798
- isSmartAccount: ((a = _.state.preferredAccountTypes) == null ? void 0 : a[t]) === F.ACCOUNT_TYPES.SMART_ACCOUNT
799
- }
800
- }), S.push("SwapPreview");
801
- }
802
- async handleSwapParameters() {
803
- this.initialParams && (n.state.initialized || await new Promise((e) => {
804
- const o = n.subscribeKey("initialized", (a) => {
805
- a && (o == null || o(), e());
806
- });
807
- }), await this.setSwapParameters(this.initialParams));
808
- }
809
- async setSwapParameters({ amount: t, fromToken: e, toToken: o }) {
810
- (!n.state.tokens || !n.state.myTokensWithBalance) && await new Promise((r) => {
811
- const l = n.subscribeKey("myTokensWithBalance", (x) => {
812
- x && x.length > 0 && (l == null || l(), r());
813
- });
814
- setTimeout(() => {
815
- l == null || l(), r();
816
- }, 5e3);
817
- });
818
- const a = [
819
- ...n.state.tokens || [],
820
- ...n.state.myTokensWithBalance || []
821
- ];
822
- if (e) {
823
- const i = a.find((r) => r.symbol.toLowerCase() === e.toLowerCase());
824
- i && n.setSourceToken(i);
825
- }
826
- if (o) {
827
- const i = a.find((r) => r.symbol.toLowerCase() === o.toLowerCase());
828
- i && n.setToToken(i);
829
- }
830
- t && !isNaN(Number(t)) && n.setSourceTokenAmount(t);
831
- }
832
- onCaipAddressChange({ newCaipAddress: t, resetSwapState: e, initializeSwapState: o }) {
833
- this.caipAddress !== t && (this.caipAddress = t, e && n.resetState(), o && n.initializeState());
834
- }
835
- onCaipNetworkChange({ newCaipNetwork: t, resetSwapState: e, initializeSwapState: o }) {
836
- this.caipNetworkId !== (t == null ? void 0 : t.caipNetworkId) && (this.caipNetworkId = t == null ? void 0 : t.caipNetworkId, e && n.resetState(), o && n.initializeState());
837
- }
838
- };
839
- p.styles = tt;
840
- w([
841
- h({ type: Object })
842
- ], p.prototype, "initialParams", void 0);
843
- w([
844
- s()
845
- ], p.prototype, "interval", void 0);
846
- w([
847
- s()
848
- ], p.prototype, "detailsOpen", void 0);
849
- w([
850
- s()
851
- ], p.prototype, "caipAddress", void 0);
852
- w([
853
- s()
854
- ], p.prototype, "caipNetworkId", void 0);
855
- w([
856
- s()
857
- ], p.prototype, "initialized", void 0);
858
- w([
859
- s()
860
- ], p.prototype, "loadingQuote", void 0);
861
- w([
862
- s()
863
- ], p.prototype, "loadingPrices", void 0);
864
- w([
865
- s()
866
- ], p.prototype, "loadingTransaction", void 0);
867
- w([
868
- s()
869
- ], p.prototype, "sourceToken", void 0);
870
- w([
871
- s()
872
- ], p.prototype, "sourceTokenAmount", void 0);
873
- w([
874
- s()
875
- ], p.prototype, "sourceTokenPriceInUSD", void 0);
876
- w([
877
- s()
878
- ], p.prototype, "toToken", void 0);
879
- w([
880
- s()
881
- ], p.prototype, "toTokenAmount", void 0);
882
- w([
883
- s()
884
- ], p.prototype, "toTokenPriceInUSD", void 0);
885
- w([
886
- s()
887
- ], p.prototype, "inputError", void 0);
888
- w([
889
- s()
890
- ], p.prototype, "fetchError", void 0);
891
- p = w([
892
- E("w3m-swap-view")
893
- ], p);
894
- const et = P`
895
- :host > wui-flex:first-child {
896
- overflow-y: auto;
897
- overflow-x: hidden;
898
- scrollbar-width: none;
899
- }
900
-
901
- :host > wui-flex:first-child::-webkit-scrollbar {
902
- display: none;
903
- }
904
-
905
- .preview-container,
906
- .details-container {
907
- width: 100%;
908
- }
909
-
910
- .token-image {
911
- width: 24px;
912
- height: 24px;
913
- box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005);
914
- border-radius: 12px;
915
- }
916
-
917
- wui-loading-hexagon {
918
- position: absolute;
919
- }
920
-
921
- .token-item {
922
- display: flex;
923
- align-items: center;
924
- justify-content: center;
925
- gap: var(--wui-spacing-xxs);
926
- padding: var(--wui-spacing-xs);
927
- height: 40px;
928
- border: none;
929
- border-radius: 80px;
930
- background: var(--wui-color-gray-glass-002);
931
- box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
932
- cursor: pointer;
933
- transition: background 0.2s linear;
934
- }
935
-
936
- .token-item:hover {
937
- background: var(--wui-color-gray-glass-005);
938
- }
939
-
940
- .preview-token-details-container {
941
- width: 100%;
942
- }
943
-
944
- .details-row {
945
- width: 100%;
946
- padding: var(--wui-spacing-s) var(--wui-spacing-xl);
947
- border-radius: var(--wui-border-radius-xxs);
948
- background: var(--wui-color-gray-glass-002);
949
- }
950
-
951
- .action-buttons-container {
952
- width: 100%;
953
- gap: var(--wui-spacing-xs);
954
- }
955
-
956
- .action-buttons-container > button {
957
- display: flex;
958
- align-items: center;
959
- justify-content: center;
960
- background: transparent;
961
- height: 48px;
962
- border-radius: var(--wui-border-radius-xs);
963
- border: none;
964
- box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
965
- }
966
-
967
- .action-buttons-container > button:disabled {
968
- opacity: 0.8;
969
- cursor: not-allowed;
970
- }
971
-
972
- .action-button > wui-loading-spinner {
973
- display: inline-block;
974
- }
975
-
976
- .cancel-button:hover,
977
- .action-button:hover {
978
- cursor: pointer;
979
- }
980
-
981
- .action-buttons-container > wui-button.cancel-button {
982
- flex: 2;
983
- }
984
-
985
- .action-buttons-container > wui-button.action-button {
986
- flex: 4;
987
- }
988
-
989
- .action-buttons-container > button.action-button > wui-text {
990
- color: white;
991
- }
992
-
993
- .details-container > wui-flex {
994
- background: var(--wui-color-gray-glass-002);
995
- border-radius: var(--wui-border-radius-xxs);
996
- width: 100%;
997
- }
998
-
999
- .details-container > wui-flex > button {
1000
- border: none;
1001
- background: none;
1002
- padding: var(--wui-spacing-s);
1003
- border-radius: var(--wui-border-radius-xxs);
1004
- transition: background 0.2s linear;
1005
- }
1006
-
1007
- .details-container > wui-flex > button:hover {
1008
- background: var(--wui-color-gray-glass-002);
1009
- }
1010
-
1011
- .details-content-container {
1012
- padding: var(--wui-spacing-1xs);
1013
- display: flex;
1014
- align-items: center;
1015
- justify-content: center;
1016
- }
1017
-
1018
- .details-content-container > wui-flex {
1019
- width: 100%;
1020
- }
1021
-
1022
- .details-row {
1023
- width: 100%;
1024
- padding: var(--wui-spacing-s) var(--wui-spacing-xl);
1025
- border-radius: var(--wui-border-radius-xxs);
1026
- background: var(--wui-color-gray-glass-002);
1027
- }
1028
- `;
1029
- var g = function(c, t, e, o) {
1030
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1031
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1032
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1033
- return a > 3 && i && Object.defineProperty(t, e, i), i;
1034
- };
1035
- let d = class extends C {
1036
- constructor() {
1037
- super(), this.unsubscribe = [], this.detailsOpen = !0, this.approvalTransaction = n.state.approvalTransaction, this.swapTransaction = n.state.swapTransaction, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount ?? "", this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount ?? "", this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.caipNetwork = D.state.activeCaipNetwork, this.balanceSymbol = _.state.balanceSymbol, this.inputError = n.state.inputError, this.loadingQuote = n.state.loadingQuote, this.loadingApprovalTransaction = n.state.loadingApprovalTransaction, this.loadingBuildTransaction = n.state.loadingBuildTransaction, this.loadingTransaction = n.state.loadingTransaction, this.unsubscribe.push(_.subscribeKey("balanceSymbol", (t) => {
1038
- this.balanceSymbol !== t && S.goBack();
1039
- }), D.subscribeKey("activeCaipNetwork", (t) => {
1040
- this.caipNetwork !== t && (this.caipNetwork = t);
1041
- }), n.subscribe((t) => {
1042
- this.approvalTransaction = t.approvalTransaction, this.swapTransaction = t.swapTransaction, this.sourceToken = t.sourceToken, this.toToken = t.toToken, this.toTokenPriceInUSD = t.toTokenPriceInUSD, this.sourceTokenAmount = t.sourceTokenAmount ?? "", this.toTokenAmount = t.toTokenAmount ?? "", this.inputError = t.inputError, t.inputError && S.goBack(), this.loadingQuote = t.loadingQuote, this.loadingApprovalTransaction = t.loadingApprovalTransaction, this.loadingBuildTransaction = t.loadingBuildTransaction, this.loadingTransaction = t.loadingTransaction;
1043
- }));
1044
- }
1045
- firstUpdated() {
1046
- n.getTransaction(), this.refreshTransaction();
1047
- }
1048
- disconnectedCallback() {
1049
- this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval);
1050
- }
1051
- render() {
1052
- return u`
1053
- <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
1054
- ${this.templateSwap()}
1055
- </wui-flex>
1056
- `;
1057
- }
1058
- refreshTransaction() {
1059
- this.interval = setInterval(() => {
1060
- n.getApprovalLoadingState() || n.getTransaction();
1061
- }, 1e4);
1062
- }
1063
- templateSwap() {
1064
- var x, v, R, U;
1065
- const t = `${m.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(x = this.sourceToken) == null ? void 0 : x.symbol}`, e = `${m.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(v = this.toToken) == null ? void 0 : v.symbol}`, o = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD, a = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD, i = m.formatNumberToLocalString(o), r = m.formatNumberToLocalString(a), l = this.loadingQuote || this.loadingBuildTransaction || this.loadingTransaction || this.loadingApprovalTransaction;
1066
- return u`
1067
- <wui-flex flexDirection="column" alignItems="center" gap="l">
1068
- <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l">
1069
- <wui-flex
1070
- class="preview-token-details-container"
1071
- alignItems="center"
1072
- justifyContent="space-between"
1073
- gap="l"
1074
- >
1075
- <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1076
- <wui-text variant="small-400" color="fg-150">Send</wui-text>
1077
- <wui-text variant="paragraph-400" color="fg-100">$${i}</wui-text>
1078
- </wui-flex>
1079
- <wui-token-button
1080
- flexDirection="row-reverse"
1081
- text=${t}
1082
- imageSrc=${(R = this.sourceToken) == null ? void 0 : R.logoUri}
1083
- >
1084
- </wui-token-button>
1085
- </wui-flex>
1086
- <wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon>
1087
- <wui-flex
1088
- class="preview-token-details-container"
1089
- alignItems="center"
1090
- justifyContent="space-between"
1091
- gap="l"
1092
- >
1093
- <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1094
- <wui-text variant="small-400" color="fg-150">Receive</wui-text>
1095
- <wui-text variant="paragraph-400" color="fg-100">$${r}</wui-text>
1096
- </wui-flex>
1097
- <wui-token-button
1098
- flexDirection="row-reverse"
1099
- text=${e}
1100
- imageSrc=${(U = this.toToken) == null ? void 0 : U.logoUri}
1101
- >
1102
- </wui-token-button>
1103
- </wui-flex>
1104
- </wui-flex>
1105
-
1106
- ${this.templateDetails()}
1107
-
1108
- <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs">
1109
- <wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon>
1110
- <wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text>
1111
- </wui-flex>
1112
-
1113
- <wui-flex
1114
- class="action-buttons-container"
1115
- flexDirection="row"
1116
- alignItems="center"
1117
- justifyContent="space-between"
1118
- gap="xs"
1119
- >
1120
- <wui-button
1121
- class="cancel-button"
1122
- fullWidth
1123
- size="lg"
1124
- borderRadius="xs"
1125
- variant="neutral"
1126
- @click=${this.onCancelTransaction.bind(this)}
1127
- >
1128
- <wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text>
1129
- </wui-button>
1130
- <wui-button
1131
- class="action-button"
1132
- fullWidth
1133
- size="lg"
1134
- borderRadius="xs"
1135
- variant="main"
1136
- ?loading=${l}
1137
- ?disabled=${l}
1138
- @click=${this.onSendTransaction.bind(this)}
1139
- >
1140
- <wui-text variant="paragraph-600" color="inverse-100">
1141
- ${this.actionButtonLabel()}
1142
- </wui-text>
1143
- </wui-button>
1144
- </wui-flex>
1145
- </wui-flex>
1146
- `;
1147
- }
1148
- templateDetails() {
1149
- return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
1150
- }
1151
- actionButtonLabel() {
1152
- return this.loadingApprovalTransaction ? "Approving..." : this.approvalTransaction ? "Approve" : "Swap";
1153
- }
1154
- onCancelTransaction() {
1155
- S.goBack();
1156
- }
1157
- onSendTransaction() {
1158
- this.approvalTransaction ? n.sendTransactionForApproval(this.approvalTransaction) : n.sendTransactionForSwap(this.swapTransaction);
1159
- }
1160
- };
1161
- d.styles = et;
1162
- g([
1163
- s()
1164
- ], d.prototype, "interval", void 0);
1165
- g([
1166
- s()
1167
- ], d.prototype, "detailsOpen", void 0);
1168
- g([
1169
- s()
1170
- ], d.prototype, "approvalTransaction", void 0);
1171
- g([
1172
- s()
1173
- ], d.prototype, "swapTransaction", void 0);
1174
- g([
1175
- s()
1176
- ], d.prototype, "sourceToken", void 0);
1177
- g([
1178
- s()
1179
- ], d.prototype, "sourceTokenAmount", void 0);
1180
- g([
1181
- s()
1182
- ], d.prototype, "sourceTokenPriceInUSD", void 0);
1183
- g([
1184
- s()
1185
- ], d.prototype, "toToken", void 0);
1186
- g([
1187
- s()
1188
- ], d.prototype, "toTokenAmount", void 0);
1189
- g([
1190
- s()
1191
- ], d.prototype, "toTokenPriceInUSD", void 0);
1192
- g([
1193
- s()
1194
- ], d.prototype, "caipNetwork", void 0);
1195
- g([
1196
- s()
1197
- ], d.prototype, "balanceSymbol", void 0);
1198
- g([
1199
- s()
1200
- ], d.prototype, "inputError", void 0);
1201
- g([
1202
- s()
1203
- ], d.prototype, "loadingQuote", void 0);
1204
- g([
1205
- s()
1206
- ], d.prototype, "loadingApprovalTransaction", void 0);
1207
- g([
1208
- s()
1209
- ], d.prototype, "loadingBuildTransaction", void 0);
1210
- g([
1211
- s()
1212
- ], d.prototype, "loadingTransaction", void 0);
1213
- d = g([
1214
- E("w3m-swap-preview-view")
1215
- ], d);
1216
- const ot = P`
1217
- :host {
1218
- height: 60px;
1219
- min-height: 60px;
1220
- }
1221
-
1222
- :host > wui-flex {
1223
- cursor: pointer;
1224
- height: 100%;
1225
- display: flex;
1226
- column-gap: var(--wui-spacing-s);
1227
- padding: var(--wui-spacing-xs);
1228
- padding-right: var(--wui-spacing-l);
1229
- width: 100%;
1230
- background-color: transparent;
1231
- border-radius: var(--wui-border-radius-xs);
1232
- color: var(--wui-color-fg-250);
1233
- transition:
1234
- background-color var(--wui-ease-out-power-1) var(--wui-duration-lg),
1235
- opacity var(--wui-ease-out-power-1) var(--wui-duration-lg);
1236
- will-change: background-color, opacity;
1237
- }
1238
-
1239
- @media (hover: hover) and (pointer: fine) {
1240
- :host > wui-flex:hover {
1241
- background-color: var(--wui-color-gray-glass-002);
1242
- }
1243
-
1244
- :host > wui-flex:active {
1245
- background-color: var(--wui-color-gray-glass-005);
1246
- }
1247
- }
1248
-
1249
- :host([disabled]) > wui-flex {
1250
- opacity: 0.6;
1251
- }
1252
-
1253
- :host([disabled]) > wui-flex:hover {
1254
- background-color: transparent;
1255
- }
1256
-
1257
- :host > wui-flex > wui-flex {
1258
- flex: 1;
1259
- }
1260
-
1261
- :host > wui-flex > wui-image,
1262
- :host > wui-flex > .token-item-image-placeholder {
1263
- width: 40px;
1264
- max-width: 40px;
1265
- height: 40px;
1266
- border-radius: var(--wui-border-radius-3xl);
1267
- position: relative;
1268
- }
1269
-
1270
- :host > wui-flex > .token-item-image-placeholder {
1271
- display: flex;
1272
- align-items: center;
1273
- justify-content: center;
1274
- }
1275
-
1276
- :host > wui-flex > wui-image::after,
1277
- :host > wui-flex > .token-item-image-placeholder::after {
1278
- position: absolute;
1279
- content: '';
1280
- inset: 0;
1281
- box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1282
- border-radius: var(--wui-border-radius-l);
1283
- }
1284
-
1285
- button > wui-icon-box[data-variant='square-blue'] {
1286
- border-radius: var(--wui-border-radius-3xs);
1287
- position: relative;
1288
- border: none;
1289
- width: 36px;
1290
- height: 36px;
1291
- }
1292
- `;
1293
- var A = function(c, t, e, o) {
1294
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1295
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1296
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1297
- return a > 3 && i && Object.defineProperty(t, e, i), i;
1298
- };
1299
- let $ = class extends C {
1300
- constructor() {
1301
- super(), this.observer = new IntersectionObserver(() => {
1302
- }), this.imageSrc = void 0, this.name = void 0, this.symbol = void 0, this.price = void 0, this.amount = void 0, this.visible = !1, this.imageError = !1, this.observer = new IntersectionObserver((t) => {
1303
- t.forEach((e) => {
1304
- e.isIntersecting ? this.visible = !0 : this.visible = !1;
1305
- });
1306
- }, { threshold: 0.1 });
1307
- }
1308
- firstUpdated() {
1309
- this.observer.observe(this);
1310
- }
1311
- disconnectedCallback() {
1312
- this.observer.disconnect();
1313
- }
1314
- render() {
1315
- var e;
1316
- if (!this.visible)
1317
- return null;
1318
- const t = this.amount && this.price ? (e = j.multiply(this.price, this.amount)) == null ? void 0 : e.toFixed(3) : null;
1319
- return u`
1320
- <wui-flex alignItems="center">
1321
- ${this.visualTemplate()}
1322
- <wui-flex flexDirection="column" gap="3xs">
1323
- <wui-flex justifyContent="space-between">
1324
- <wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text>
1325
- ${t ? u`
1326
- <wui-text variant="paragraph-500" color="fg-100">
1327
- $${m.formatNumberToLocalString(t, 3)}
1328
- </wui-text>
1329
- ` : null}
1330
- </wui-flex>
1331
- <wui-flex justifyContent="space-between">
1332
- <wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text>
1333
- ${this.amount ? u`<wui-text variant="small-400" color="fg-200">
1334
- ${m.formatNumberToLocalString(this.amount, 4)}
1335
- </wui-text>` : null}
1336
- </wui-flex>
1337
- </wui-flex>
1338
- </wui-flex>
1339
- `;
1340
- }
1341
- visualTemplate() {
1342
- return this.imageError ? u`<wui-flex class="token-item-image-placeholder">
1343
- <wui-icon name="image" color="inherit"></wui-icon>
1344
- </wui-flex>` : this.imageSrc ? u`<wui-image
1345
- width="40"
1346
- height="40"
1347
- src=${this.imageSrc}
1348
- @onLoadError=${this.imageLoadError}
1349
- ></wui-image>` : null;
1350
- }
1351
- imageLoadError() {
1352
- this.imageError = !0;
1353
- }
1354
- };
1355
- $.styles = [Q, q, ot];
1356
- A([
1357
- h()
1358
- ], $.prototype, "imageSrc", void 0);
1359
- A([
1360
- h()
1361
- ], $.prototype, "name", void 0);
1362
- A([
1363
- h()
1364
- ], $.prototype, "symbol", void 0);
1365
- A([
1366
- h()
1367
- ], $.prototype, "price", void 0);
1368
- A([
1369
- h()
1370
- ], $.prototype, "amount", void 0);
1371
- A([
1372
- s()
1373
- ], $.prototype, "visible", void 0);
1374
- A([
1375
- s()
1376
- ], $.prototype, "imageError", void 0);
1377
- $ = A([
1378
- E("wui-token-list-item")
1379
- ], $);
1380
- const it = P`
1381
- :host {
1382
- --tokens-scroll--top-opacity: 0;
1383
- --tokens-scroll--bottom-opacity: 1;
1384
- --suggested-tokens-scroll--left-opacity: 0;
1385
- --suggested-tokens-scroll--right-opacity: 1;
1386
- }
1387
-
1388
- :host > wui-flex:first-child {
1389
- overflow-y: hidden;
1390
- overflow-x: hidden;
1391
- scrollbar-width: none;
1392
- scrollbar-height: none;
1393
- }
1394
-
1395
- :host > wui-flex:first-child::-webkit-scrollbar {
1396
- display: none;
1397
- }
1398
-
1399
- wui-loading-hexagon {
1400
- position: absolute;
1401
- }
1402
-
1403
- .suggested-tokens-container {
1404
- overflow-x: auto;
1405
- mask-image: linear-gradient(
1406
- to right,
1407
- rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
1408
- rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
1409
- black 50px,
1410
- black 90px,
1411
- black calc(100% - 90px),
1412
- black calc(100% - 50px),
1413
- rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
1414
- rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
1415
- );
1416
- }
1417
-
1418
- .suggested-tokens-container::-webkit-scrollbar {
1419
- display: none;
1420
- }
1421
-
1422
- .tokens-container {
1423
- border-top: 1px solid var(--wui-color-gray-glass-005);
1424
- height: 100%;
1425
- max-height: 390px;
1426
- }
1427
-
1428
- .tokens {
1429
- width: 100%;
1430
- overflow-y: auto;
1431
- mask-image: linear-gradient(
1432
- to bottom,
1433
- rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
1434
- rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
1435
- black 50px,
1436
- black 90px,
1437
- black calc(100% - 90px),
1438
- black calc(100% - 50px),
1439
- rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
1440
- rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
1441
- );
1442
- }
1443
-
1444
- .network-search-input,
1445
- .select-network-button {
1446
- height: 40px;
1447
- }
1448
-
1449
- .select-network-button {
1450
- border: none;
1451
- display: flex;
1452
- flex-direction: row;
1453
- align-items: center;
1454
- justify-content: center;
1455
- gap: var(--wui-spacing-xs);
1456
- box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005);
1457
- background-color: transparent;
1458
- border-radius: var(--wui-border-radius-xxs);
1459
- padding: var(--wui-spacing-xs);
1460
- align-items: center;
1461
- transition: background-color 0.2s linear;
1462
- }
1463
-
1464
- .select-network-button:hover {
1465
- background-color: var(--wui-color-gray-glass-002);
1466
- }
1467
-
1468
- .select-network-button > wui-image {
1469
- width: 26px;
1470
- height: 26px;
1471
- border-radius: var(--wui-border-radius-xs);
1472
- box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1473
- }
1474
- `;
1475
- var I = function(c, t, e, o) {
1476
- var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1477
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1478
- else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1479
- return a > 3 && i && Object.defineProperty(t, e, i), i;
1480
- };
1481
- let T = class extends C {
1482
- constructor() {
1483
- var t;
1484
- super(), this.unsubscribe = [], this.targetToken = (t = S.state.data) == null ? void 0 : t.target, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount, this.toToken = n.state.toToken, this.myTokensWithBalance = n.state.myTokensWithBalance, this.popularTokens = n.state.popularTokens, this.searchValue = "", this.unsubscribe.push(n.subscribe((e) => {
1485
- this.sourceToken = e.sourceToken, this.toToken = e.toToken, this.myTokensWithBalance = e.myTokensWithBalance;
1486
- }));
1487
- }
1488
- updated() {
1489
- var o, a;
1490
- const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".suggested-tokens-container");
1491
- t == null || t.addEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
1492
- const e = (a = this.renderRoot) == null ? void 0 : a.querySelector(".tokens");
1493
- e == null || e.addEventListener("scroll", this.handleTokenListScroll.bind(this));
1494
- }
1495
- disconnectedCallback() {
1496
- var o, a;
1497
- super.disconnectedCallback();
1498
- const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".suggested-tokens-container"), e = (a = this.renderRoot) == null ? void 0 : a.querySelector(".tokens");
1499
- t == null || t.removeEventListener("scroll", this.handleSuggestedTokensScroll.bind(this)), e == null || e.removeEventListener("scroll", this.handleTokenListScroll.bind(this)), clearInterval(this.interval);
1500
- }
1501
- render() {
1502
- return u`
1503
- <wui-flex flexDirection="column" gap="s">
1504
- ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
1505
- </wui-flex>
1506
- `;
1507
- }
1508
- onSelectToken(t) {
1509
- this.targetToken === "sourceToken" ? n.setSourceToken(t) : (n.setToToken(t), this.sourceToken && this.sourceTokenAmount && n.swapTokens()), S.goBack();
1510
- }
1511
- templateSearchInput() {
1512
- return u`
1513
- <wui-flex .padding=${["3xs", "s", "0", "s"]} gap="xs">
1514
- <wui-input-text
1515
- data-testid="swap-select-token-search-input"
1516
- class="network-search-input"
1517
- size="sm"
1518
- placeholder="Search token"
1519
- icon="search"
1520
- .value=${this.searchValue}
1521
- @inputChange=${this.onSearchInputChange.bind(this)}
1522
- ></wui-input-text>
1523
- </wui-flex>
1524
- `;
1525
- }
1526
- templateTokens() {
1527
- const t = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [], e = this.popularTokens ? this.popularTokens : [], o = this.filterTokensWithText(t, this.searchValue), a = this.filterTokensWithText(e, this.searchValue);
1528
- return u`
1529
- <wui-flex class="tokens-container">
1530
- <wui-flex class="tokens" .padding=${["0", "s", "s", "s"]} flexDirection="column">
1531
- ${(o == null ? void 0 : o.length) > 0 ? u`
1532
- <wui-flex justifyContent="flex-start" padding="s">
1533
- <wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text>
1534
- </wui-flex>
1535
- ${o.map((i) => {
1536
- var l, x, v;
1537
- const r = i.symbol === ((l = this.sourceToken) == null ? void 0 : l.symbol) || i.symbol === ((x = this.toToken) == null ? void 0 : x.symbol);
1538
- return u`
1539
- <wui-token-list-item
1540
- data-testid="swap-select-token-item-${i.symbol}"
1541
- name=${i.name}
1542
- ?disabled=${r}
1543
- symbol=${i.symbol}
1544
- price=${i == null ? void 0 : i.price}
1545
- amount=${(v = i == null ? void 0 : i.quantity) == null ? void 0 : v.numeric}
1546
- imageSrc=${i.logoUri}
1547
- @click=${() => {
1548
- r || this.onSelectToken(i);
1549
- }}
1550
- >
1551
- </wui-token-list-item>
1552
- `;
1553
- })}
1554
- ` : null}
1555
-
1556
- <wui-flex justifyContent="flex-start" padding="s">
1557
- <wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text>
1558
- </wui-flex>
1559
- ${(a == null ? void 0 : a.length) > 0 ? a.map((i) => u`
1560
- <wui-token-list-item
1561
- data-testid="swap-select-token-item-${i.symbol}"
1562
- name=${i.name}
1563
- symbol=${i.symbol}
1564
- imageSrc=${i.logoUri}
1565
- @click=${() => this.onSelectToken(i)}
1566
- >
1567
- </wui-token-list-item>
1568
- `) : null}
1569
- </wui-flex>
1570
- </wui-flex>
1571
- `;
1572
- }
1573
- templateSuggestedTokens() {
1574
- const t = n.state.suggestedTokens ? n.state.suggestedTokens.slice(0, 8) : null;
1575
- return t ? u`
1576
- <wui-flex class="suggested-tokens-container" .padding=${["0", "s", "0", "s"]} gap="xs">
1577
- ${t.map((e) => u`
1578
- <wui-token-button
1579
- text=${e.symbol}
1580
- imageSrc=${e.logoUri}
1581
- @click=${() => this.onSelectToken(e)}
1582
- >
1583
- </wui-token-button>
1584
- `)}
1585
- </wui-flex>
1586
- ` : null;
1587
- }
1588
- onSearchInputChange(t) {
1589
- this.searchValue = t.detail;
1590
- }
1591
- handleSuggestedTokensScroll() {
1592
- var e;
1593
- const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".suggested-tokens-container");
1594
- t && (t.style.setProperty("--suggested-tokens-scroll--left-opacity", L.interpolate([0, 100], [0, 1], t.scrollLeft).toString()), t.style.setProperty("--suggested-tokens-scroll--right-opacity", L.interpolate([0, 100], [0, 1], t.scrollWidth - t.scrollLeft - t.offsetWidth).toString()));
1595
- }
1596
- handleTokenListScroll() {
1597
- var e;
1598
- const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".tokens");
1599
- t && (t.style.setProperty("--tokens-scroll--top-opacity", L.interpolate([0, 100], [0, 1], t.scrollTop).toString()), t.style.setProperty("--tokens-scroll--bottom-opacity", L.interpolate([0, 100], [0, 1], t.scrollHeight - t.scrollTop - t.offsetHeight).toString()));
1600
- }
1601
- filterTokensWithText(t, e) {
1602
- return t.filter((o) => `${o.symbol} ${o.name} ${o.address}`.toLowerCase().includes(e.toLowerCase()));
1603
- }
1604
- };
1605
- T.styles = it;
1606
- I([
1607
- s()
1608
- ], T.prototype, "interval", void 0);
1609
- I([
1610
- s()
1611
- ], T.prototype, "targetToken", void 0);
1612
- I([
1613
- s()
1614
- ], T.prototype, "sourceToken", void 0);
1615
- I([
1616
- s()
1617
- ], T.prototype, "sourceTokenAmount", void 0);
1618
- I([
1619
- s()
1620
- ], T.prototype, "toToken", void 0);
1621
- I([
1622
- s()
1623
- ], T.prototype, "myTokensWithBalance", void 0);
1624
- I([
1625
- s()
1626
- ], T.prototype, "popularTokens", void 0);
1627
- I([
1628
- s()
1629
- ], T.prototype, "searchValue", void 0);
1630
- T = I([
1631
- E("w3m-swap-select-token-view")
1632
- ], T);
1633
- export {
1634
- d as W3mSwapPreviewView,
1635
- T as W3mSwapSelectTokenView,
1636
- p as W3mSwapView
1637
- };