@dcl/governance-site 2.0.0 → 2.0.1-20995780683.commit-d6baf5e
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/assets/BlockOverrides-9837a6f9.js +5 -0
- package/assets/ConstantsUtil-298f7898.js +1 -0
- package/assets/ExchangeController-d2354ec6.js +1 -0
- package/assets/HelpersUtil-8cddb046.js +62 -0
- package/assets/MathUtil-b514a570.js +1 -0
- package/assets/NavigationUtil-a0d0ce87.js +1 -0
- package/assets/NetworkUtil-220ea128.js +1 -0
- package/assets/PhWallet-fd2006d2.js +14 -0
- package/assets/{features-b72c9430.js → ReownAuthentication-468828df.js} +4 -4
- package/assets/SwapController-7bfd6ce7.js +1 -0
- package/assets/{UserAvatar-78751cb5.js → UserAvatar-456716f1.js} +1 -1
- package/assets/ccip-ddcec720.js +1 -0
- package/assets/data-capture-3e424a2c.js +242 -0
- package/assets/email-ea617f9c.js +90 -0
- package/assets/embedded-wallet-814bf005.js +410 -0
- package/assets/features-fd521597.js +1 -0
- package/assets/fortmatic-f3cb4aa6.js +13 -0
- package/assets/if-defined-0a35f675.js +5 -0
- package/assets/index-034d22a0.js +138 -0
- package/assets/{index-a8255d1c.css → index-05771666.css} +4 -4
- package/assets/index-07a61b45.js +51 -0
- package/assets/index-1039ded0.js +132 -0
- package/assets/index-123c1362.js +224 -0
- package/assets/index-15bbaaa0.js +7 -0
- package/assets/{index-073512a1.js → index-206e3e77.js} +1 -1
- package/assets/index-27a991e4.js +53 -0
- package/assets/index-2d0efdd2.js +210 -0
- package/assets/index-32d53c87.js +189 -0
- package/assets/index-3b861a37.js +102 -0
- package/assets/index-4207595b.js +100 -0
- package/assets/index-4243d275.js +43 -0
- package/assets/index-42ce7246.js +63 -0
- package/assets/index-47e87339.js +152 -0
- package/assets/index-48bd3fca.js +277 -0
- package/assets/index-49cc5044.js +46 -0
- package/assets/index-5788a0d6.js +468 -0
- package/assets/index-5824c226.js +81 -0
- package/assets/index-5da565ce.js +78 -0
- package/assets/index-685e7949.js +425 -0
- package/assets/index-84e8ecf6.js +647 -0
- package/assets/index-965fdf98.js +3425 -0
- package/assets/index-9d970383.js +152 -0
- package/assets/index-a59b6662.js +68 -0
- package/assets/index-b457d047.js +1062 -0
- package/assets/index-b65e06cc.js +27 -0
- package/assets/{index-2ef9f1d1.js → index-d70e4ab8.js} +66 -66
- package/assets/index-d7a6ceea.js +30 -0
- package/assets/index-d9c55c27.js +77 -0
- package/assets/index-db5b7889.js +77 -0
- package/assets/index-e3222791.js +78 -0
- package/assets/index-eb060c20.js +1 -0
- package/assets/index-f3f03959.js +90 -0
- package/assets/index-fcda68c9.js +19 -0
- package/assets/index-ff4dea43.js +85 -0
- package/assets/networks-14f3c0d2.js +1 -0
- package/assets/onramp-dcdb1a34.js +422 -0
- package/assets/pay-with-exchange-a64f18a3.js +280 -0
- package/assets/receive-ca7bc867.js +131 -0
- package/assets/ref-88e1be05.js +13 -0
- package/assets/send-8739c9fb.js +554 -0
- package/assets/socials-ccc593f5.js +250 -0
- package/assets/swaps-0a90eb06.js +1050 -0
- package/assets/transactions-bb8cb277.js +16 -0
- package/assets/{tslib.es6-82b9ba96.js → tslib.es6-db2ec995.js} +2 -2
- package/assets/w3m-modal-869dafbc.js +891 -0
- package/assets/zoraTestnet-adc7b76b.js +36 -0
- package/index.html +4 -4
- package/package.json +3 -3
- package/assets/basic-ca749c4c.js +0 -1435
- package/assets/core-806d78ea.js +0 -249
- package/assets/fortmatic-12e0f2e5.js +0 -13
- package/assets/index-372705ba.js +0 -1321
- package/assets/index-4be588a0.js +0 -94
- package/assets/index-74e34dfb.js +0 -39
- package/assets/index-bbb36593.js +0 -7
- package/assets/index-c1c8440f.js +0 -47
- package/assets/w3m-modal-26eff9d9.js +0 -1209
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
import{j as A,l as D,C as $,N as h,m as u,c as V,E as N,R as S,h as M,M as K,y as F,W as Q,r as W,k as q}from"./index-48bd3fca.js";import{r as l,n as w,c as C}from"./index-84e8ecf6.js";import"./index-47e87339.js";import"./index-ff4dea43.js";import"./index-4207595b.js";import{S as s}from"./SwapController-7bfd6ce7.js";import"./index-d7a6ceea.js";import"./index-034d22a0.js";import{M as _}from"./MathUtil-b514a570.js";import"./index-9d970383.js";import"./index-42ce7246.js";import"./index-d70e4ab8.js";import"./NetworkUtil-220ea128.js";import"./BlockOverrides-9837a6f9.js";import"./index-4243d275.js";import"./index-07a61b45.js";import"./if-defined-0a35f675.js";import"./ref-88e1be05.js";const H={numericInputKeyDown(e,t,o){const i=["Backspace","Meta","Ctrl","a","A","c","C","x","X","v","V","ArrowLeft","ArrowRight","Tab"],r=e.metaKey||e.ctrlKey,n=e.key,a=n.toLocaleLowerCase(),c=a==="a",x=a==="c",I=a==="v",U=a==="x",L=n===",",R=n===".",B=n>="0"&&n<="9";!r&&(c||x||I||U)&&e.preventDefault(),t==="0"&&!L&&!R&&n==="0"&&e.preventDefault(),t==="0"&&B&&(o(n),e.preventDefault()),(L||R)&&(t||(o("0."),e.preventDefault()),(t!=null&&t.includes(".")||t!=null&&t.includes(","))&&e.preventDefault()),!B&&!i.includes(n)&&!R&&!L&&e.preventDefault()}},G=A`
|
|
2
|
+
:host {
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.details-container > wui-flex {
|
|
7
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
8
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.details-container > wui-flex > button {
|
|
13
|
+
border: none;
|
|
14
|
+
background: none;
|
|
15
|
+
padding: ${({spacing:e})=>e[3]};
|
|
16
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.details-content-container {
|
|
21
|
+
padding: ${({spacing:e})=>e[2]};
|
|
22
|
+
padding-top: 0px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.details-content-container > wui-flex {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.details-row {
|
|
33
|
+
width: 100%;
|
|
34
|
+
padding: ${({spacing:e})=>e[3]};
|
|
35
|
+
padding-left: ${({spacing:e})=>e[3]};
|
|
36
|
+
padding-right: ${({spacing:e})=>e[2]};
|
|
37
|
+
border-radius: calc(
|
|
38
|
+
${({borderRadius:e})=>e[1]} + ${({borderRadius:e})=>e[1]}
|
|
39
|
+
);
|
|
40
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.details-row-title {
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.details-row.provider-free-row {
|
|
48
|
+
padding-right: ${({spacing:e})=>e[2]};
|
|
49
|
+
}
|
|
50
|
+
`;var T=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};const X=V.CONVERT_SLIPPAGE_TOLERANCE;let f=class extends D{constructor(){var t;super(),this.unsubscribe=[],this.networkName=(t=$.state.activeCaipNetwork)==null?void 0:t.name,this.detailsOpen=!1,this.sourceToken=s.state.sourceToken,this.toToken=s.state.toToken,this.toTokenAmount=s.state.toTokenAmount,this.sourceTokenPriceInUSD=s.state.sourceTokenPriceInUSD,this.toTokenPriceInUSD=s.state.toTokenPriceInUSD,this.priceImpact=s.state.priceImpact,this.maxSlippage=s.state.maxSlippage,this.networkTokenSymbol=s.state.networkTokenSymbol,this.inputError=s.state.inputError,this.unsubscribe.push(s.subscribe(o=>{this.sourceToken=o.sourceToken,this.toToken=o.toToken,this.toTokenAmount=o.toTokenAmount,this.priceImpact=o.priceImpact,this.maxSlippage=o.maxSlippage,this.sourceTokenPriceInUSD=o.sourceTokenPriceInUSD,this.toTokenPriceInUSD=o.toTokenPriceInUSD,this.inputError=o.inputError}))}render(){const t=this.toTokenAmount&&this.maxSlippage?h.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString():null;if(!this.sourceToken||!this.toToken||this.inputError)return null;const o=this.sourceTokenPriceInUSD&&this.toTokenPriceInUSD?1/this.toTokenPriceInUSD*this.sourceTokenPriceInUSD:0;return u`
|
|
51
|
+
<wui-flex flexDirection="column" alignItems="center" gap="01" class="details-container">
|
|
52
|
+
<wui-flex flexDirection="column">
|
|
53
|
+
<button @click=${this.toggleDetails.bind(this)}>
|
|
54
|
+
<wui-flex justifyContent="space-between" .padding=${["0","2","0","2"]}>
|
|
55
|
+
<wui-flex justifyContent="flex-start" flexGrow="1" gap="2">
|
|
56
|
+
<wui-text variant="sm-regular" color="primary">
|
|
57
|
+
1 ${this.sourceToken.symbol} =
|
|
58
|
+
${h.formatNumberToLocalString(o,3)}
|
|
59
|
+
${this.toToken.symbol}
|
|
60
|
+
</wui-text>
|
|
61
|
+
<wui-text variant="sm-regular" color="secondary">
|
|
62
|
+
$${h.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
|
|
63
|
+
</wui-text>
|
|
64
|
+
</wui-flex>
|
|
65
|
+
<wui-icon name="chevronBottom"></wui-icon>
|
|
66
|
+
</wui-flex>
|
|
67
|
+
</button>
|
|
68
|
+
${this.detailsOpen?u`
|
|
69
|
+
<wui-flex flexDirection="column" gap="2" class="details-content-container">
|
|
70
|
+
${this.priceImpact?u` <wui-flex flexDirection="column" gap="2">
|
|
71
|
+
<wui-flex
|
|
72
|
+
justifyContent="space-between"
|
|
73
|
+
alignItems="center"
|
|
74
|
+
class="details-row"
|
|
75
|
+
>
|
|
76
|
+
<wui-flex alignItems="center" gap="2">
|
|
77
|
+
<wui-text
|
|
78
|
+
class="details-row-title"
|
|
79
|
+
variant="sm-regular"
|
|
80
|
+
color="secondary"
|
|
81
|
+
>
|
|
82
|
+
Price impact
|
|
83
|
+
</wui-text>
|
|
84
|
+
<w3m-tooltip-trigger
|
|
85
|
+
text="Price impact reflects the change in market price due to your trade"
|
|
86
|
+
>
|
|
87
|
+
<wui-icon size="sm" color="default" name="info"></wui-icon>
|
|
88
|
+
</w3m-tooltip-trigger>
|
|
89
|
+
</wui-flex>
|
|
90
|
+
<wui-flex>
|
|
91
|
+
<wui-text variant="sm-regular" color="secondary">
|
|
92
|
+
${h.formatNumberToLocalString(this.priceImpact,3)}%
|
|
93
|
+
</wui-text>
|
|
94
|
+
</wui-flex>
|
|
95
|
+
</wui-flex>
|
|
96
|
+
</wui-flex>`:null}
|
|
97
|
+
${this.maxSlippage&&this.sourceToken.symbol?u`<wui-flex flexDirection="column" gap="2">
|
|
98
|
+
<wui-flex
|
|
99
|
+
justifyContent="space-between"
|
|
100
|
+
alignItems="center"
|
|
101
|
+
class="details-row"
|
|
102
|
+
>
|
|
103
|
+
<wui-flex alignItems="center" gap="2">
|
|
104
|
+
<wui-text
|
|
105
|
+
class="details-row-title"
|
|
106
|
+
variant="sm-regular"
|
|
107
|
+
color="secondary"
|
|
108
|
+
>
|
|
109
|
+
Max. slippage
|
|
110
|
+
</wui-text>
|
|
111
|
+
<w3m-tooltip-trigger
|
|
112
|
+
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 ${h.formatNumberToLocalString(t,6)} ${this.toToken.symbol} due to price changes.`:""}`}
|
|
113
|
+
>
|
|
114
|
+
<wui-icon size="sm" color="default" name="info"></wui-icon>
|
|
115
|
+
</w3m-tooltip-trigger>
|
|
116
|
+
</wui-flex>
|
|
117
|
+
<wui-flex>
|
|
118
|
+
<wui-text variant="sm-regular" color="secondary">
|
|
119
|
+
${h.formatNumberToLocalString(this.maxSlippage,6)}
|
|
120
|
+
${this.toToken.symbol} ${X}%
|
|
121
|
+
</wui-text>
|
|
122
|
+
</wui-flex>
|
|
123
|
+
</wui-flex>
|
|
124
|
+
</wui-flex>`:null}
|
|
125
|
+
<wui-flex flexDirection="column" gap="2">
|
|
126
|
+
<wui-flex
|
|
127
|
+
justifyContent="space-between"
|
|
128
|
+
alignItems="center"
|
|
129
|
+
class="details-row provider-free-row"
|
|
130
|
+
>
|
|
131
|
+
<wui-flex alignItems="center" gap="2">
|
|
132
|
+
<wui-text class="details-row-title" variant="sm-regular" color="secondary">
|
|
133
|
+
Provider fee
|
|
134
|
+
</wui-text>
|
|
135
|
+
</wui-flex>
|
|
136
|
+
<wui-flex>
|
|
137
|
+
<wui-text variant="sm-regular" color="secondary">0.85%</wui-text>
|
|
138
|
+
</wui-flex>
|
|
139
|
+
</wui-flex>
|
|
140
|
+
</wui-flex>
|
|
141
|
+
</wui-flex>
|
|
142
|
+
`:null}
|
|
143
|
+
</wui-flex>
|
|
144
|
+
</wui-flex>
|
|
145
|
+
`}toggleDetails(){this.detailsOpen=!this.detailsOpen}};f.styles=[G];T([l()],f.prototype,"networkName",void 0);T([w()],f.prototype,"detailsOpen",void 0);T([l()],f.prototype,"sourceToken",void 0);T([l()],f.prototype,"toToken",void 0);T([l()],f.prototype,"toTokenAmount",void 0);T([l()],f.prototype,"sourceTokenPriceInUSD",void 0);T([l()],f.prototype,"toTokenPriceInUSD",void 0);T([l()],f.prototype,"priceImpact",void 0);T([l()],f.prototype,"maxSlippage",void 0);T([l()],f.prototype,"networkTokenSymbol",void 0);T([l()],f.prototype,"inputError",void 0);f=T([C("w3m-swap-details")],f);const Y=A`
|
|
146
|
+
:host {
|
|
147
|
+
width: 100%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:host > wui-flex {
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: row;
|
|
153
|
+
justify-content: space-between;
|
|
154
|
+
align-items: center;
|
|
155
|
+
border-radius: ${({borderRadius:e})=>e[5]};
|
|
156
|
+
padding: ${({spacing:e})=>e[5]};
|
|
157
|
+
padding-right: ${({spacing:e})=>e[3]};
|
|
158
|
+
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
159
|
+
box-shadow: inset 0px 0px 0px 1px ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
160
|
+
width: 100%;
|
|
161
|
+
height: 100px;
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
position: relative;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
wui-shimmer.market-value {
|
|
167
|
+
opacity: 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
:host > wui-flex > svg.input_mask {
|
|
171
|
+
position: absolute;
|
|
172
|
+
inset: 0;
|
|
173
|
+
z-index: 5;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:host wui-flex .input_mask__border,
|
|
177
|
+
:host wui-flex .input_mask__background {
|
|
178
|
+
transition: fill ${({durations:e})=>e.md}
|
|
179
|
+
${({easings:e})=>e["ease-out-power-1"]};
|
|
180
|
+
will-change: fill;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host wui-flex .input_mask__border {
|
|
184
|
+
fill: ${({tokens:e})=>e.core.glass010};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:host wui-flex .input_mask__background {
|
|
188
|
+
fill: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
189
|
+
}
|
|
190
|
+
`;var z=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let j=class extends D{constructor(){super(...arguments),this.target="sourceToken"}render(){return u`
|
|
191
|
+
<wui-flex class justifyContent="space-between">
|
|
192
|
+
<wui-flex
|
|
193
|
+
flex="1"
|
|
194
|
+
flexDirection="column"
|
|
195
|
+
alignItems="flex-start"
|
|
196
|
+
justifyContent="center"
|
|
197
|
+
class="swap-input"
|
|
198
|
+
gap="1"
|
|
199
|
+
>
|
|
200
|
+
<wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
|
|
201
|
+
</wui-flex>
|
|
202
|
+
${this.templateTokenSelectButton()}
|
|
203
|
+
</wui-flex>
|
|
204
|
+
`}templateTokenSelectButton(){return u`
|
|
205
|
+
<wui-flex
|
|
206
|
+
class="swap-token-button"
|
|
207
|
+
flexDirection="column"
|
|
208
|
+
alignItems="flex-end"
|
|
209
|
+
justifyContent="center"
|
|
210
|
+
gap="1"
|
|
211
|
+
>
|
|
212
|
+
<wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
|
|
213
|
+
</wui-flex>
|
|
214
|
+
`}};j.styles=[Y];z([w()],j.prototype,"target",void 0);j=z([C("w3m-swap-input-skeleton")],j);const Z=A`
|
|
215
|
+
:host > wui-flex {
|
|
216
|
+
display: flex;
|
|
217
|
+
flex-direction: row;
|
|
218
|
+
justify-content: space-between;
|
|
219
|
+
align-items: center;
|
|
220
|
+
border-radius: ${({borderRadius:e})=>e[5]};
|
|
221
|
+
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
222
|
+
padding: ${({spacing:e})=>e[5]};
|
|
223
|
+
padding-right: ${({spacing:e})=>e[3]};
|
|
224
|
+
width: 100%;
|
|
225
|
+
height: 100px;
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
box-shadow: inset 0px 0px 0px 1px ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
228
|
+
position: relative;
|
|
229
|
+
transition: box-shadow ${({easings:e})=>e["ease-out-power-1"]}
|
|
230
|
+
${({durations:e})=>e.lg};
|
|
231
|
+
will-change: background-color;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
:host wui-flex.focus {
|
|
235
|
+
box-shadow: inset 0px 0px 0px 1px ${({tokens:e})=>e.core.glass010};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
:host > wui-flex .swap-input,
|
|
239
|
+
:host > wui-flex .swap-token-button {
|
|
240
|
+
z-index: 10;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
:host > wui-flex .swap-input {
|
|
244
|
+
-webkit-mask-image: linear-gradient(
|
|
245
|
+
270deg,
|
|
246
|
+
transparent 0px,
|
|
247
|
+
transparent 8px,
|
|
248
|
+
black 24px,
|
|
249
|
+
black 25px,
|
|
250
|
+
black 32px,
|
|
251
|
+
black 100%
|
|
252
|
+
);
|
|
253
|
+
mask-image: linear-gradient(
|
|
254
|
+
270deg,
|
|
255
|
+
transparent 0px,
|
|
256
|
+
transparent 8px,
|
|
257
|
+
black 24px,
|
|
258
|
+
black 25px,
|
|
259
|
+
black 32px,
|
|
260
|
+
black 100%
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
:host > wui-flex .swap-input input {
|
|
265
|
+
background: none;
|
|
266
|
+
border: none;
|
|
267
|
+
height: 42px;
|
|
268
|
+
width: 100%;
|
|
269
|
+
font-size: 32px;
|
|
270
|
+
font-style: normal;
|
|
271
|
+
font-weight: 400;
|
|
272
|
+
line-height: 130%;
|
|
273
|
+
letter-spacing: -1.28px;
|
|
274
|
+
outline: none;
|
|
275
|
+
caret-color: ${({tokens:e})=>e.core.textAccentPrimary};
|
|
276
|
+
color: ${({tokens:e})=>e.theme.textPrimary};
|
|
277
|
+
padding: 0px;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
:host > wui-flex .swap-input input:focus-visible {
|
|
281
|
+
outline: none;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
:host > wui-flex .swap-input input::-webkit-outer-spin-button,
|
|
285
|
+
:host > wui-flex .swap-input input::-webkit-inner-spin-button {
|
|
286
|
+
-webkit-appearance: none;
|
|
287
|
+
margin: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.max-value-button {
|
|
291
|
+
background-color: transparent;
|
|
292
|
+
border: none;
|
|
293
|
+
cursor: pointer;
|
|
294
|
+
color: ${({tokens:e})=>e.core.glass010};
|
|
295
|
+
padding-left: 0px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.market-value {
|
|
299
|
+
min-height: 18px;
|
|
300
|
+
}
|
|
301
|
+
`;var y=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};const J=5e-5;let k=class extends D{constructor(){super(...arguments),this.focused=!1,this.price=0,this.target="sourceToken",this.onSetAmount=null,this.onSetMaxValue=null}render(){const t=this.marketValue||"0",o=h.bigNumber(t).gt("0");return u`
|
|
302
|
+
<wui-flex
|
|
303
|
+
class="${this.focused?"focus":""}"
|
|
304
|
+
justifyContent="space-between"
|
|
305
|
+
alignItems="center"
|
|
306
|
+
>
|
|
307
|
+
<wui-flex
|
|
308
|
+
flex="1"
|
|
309
|
+
flexDirection="column"
|
|
310
|
+
alignItems="flex-start"
|
|
311
|
+
justifyContent="center"
|
|
312
|
+
class="swap-input"
|
|
313
|
+
>
|
|
314
|
+
<input
|
|
315
|
+
data-testid="swap-input-${this.target}"
|
|
316
|
+
@focusin=${()=>this.onFocusChange(!0)}
|
|
317
|
+
@focusout=${()=>this.onFocusChange(!1)}
|
|
318
|
+
?disabled=${this.disabled}
|
|
319
|
+
value=${this.value||""}
|
|
320
|
+
@input=${this.dispatchInputChangeEvent}
|
|
321
|
+
@keydown=${this.handleKeydown}
|
|
322
|
+
placeholder="0"
|
|
323
|
+
type="text"
|
|
324
|
+
inputmode="decimal"
|
|
325
|
+
pattern="[0-9,.]*"
|
|
326
|
+
/>
|
|
327
|
+
<wui-text class="market-value" variant="sm-regular" color="secondary">
|
|
328
|
+
${o?`$${h.formatNumberToLocalString(this.marketValue,2)}`:null}
|
|
329
|
+
</wui-text>
|
|
330
|
+
</wui-flex>
|
|
331
|
+
${this.templateTokenSelectButton()}
|
|
332
|
+
</wui-flex>
|
|
333
|
+
`}handleKeydown(t){return H.numericInputKeyDown(t,this.value,o=>{var i;return(i=this.onSetAmount)==null?void 0:i.call(this,this.target,o)})}dispatchInputChangeEvent(t){if(!this.onSetAmount)return;const o=t.target.value.replace(/[^0-9.]/gu,"");o===","||o==="."?this.onSetAmount(this.target,"0."):o.endsWith(",")?this.onSetAmount(this.target,o.replace(",",".")):this.onSetAmount(this.target,o)}setMaxValueToInput(){var t;(t=this.onSetMaxValue)==null||t.call(this,this.target,this.balance)}templateTokenSelectButton(){return this.token?u`
|
|
334
|
+
<wui-flex
|
|
335
|
+
class="swap-token-button"
|
|
336
|
+
flexDirection="column"
|
|
337
|
+
alignItems="flex-end"
|
|
338
|
+
justifyContent="center"
|
|
339
|
+
gap="1"
|
|
340
|
+
>
|
|
341
|
+
<wui-token-button
|
|
342
|
+
data-testid="swap-input-token-${this.target}"
|
|
343
|
+
text=${this.token.symbol}
|
|
344
|
+
imageSrc=${this.token.logoUri}
|
|
345
|
+
@click=${this.onSelectToken.bind(this)}
|
|
346
|
+
>
|
|
347
|
+
</wui-token-button>
|
|
348
|
+
<wui-flex alignItems="center" gap="1"> ${this.tokenBalanceTemplate()} </wui-flex>
|
|
349
|
+
</wui-flex>
|
|
350
|
+
`:u` <wui-button
|
|
351
|
+
data-testid="swap-select-token-button-${this.target}"
|
|
352
|
+
class="swap-token-button"
|
|
353
|
+
size="md"
|
|
354
|
+
variant="neutral-secondary"
|
|
355
|
+
@click=${this.onSelectToken.bind(this)}
|
|
356
|
+
>
|
|
357
|
+
Select token
|
|
358
|
+
</wui-button>`}tokenBalanceTemplate(){const t=h.multiply(this.balance,this.price),o=t?t==null?void 0:t.gt(J):!1;return u`
|
|
359
|
+
${o?u`<wui-text variant="sm-regular" color="secondary">
|
|
360
|
+
${h.formatNumberToLocalString(this.balance,2)}
|
|
361
|
+
</wui-text>`:null}
|
|
362
|
+
${this.target==="sourceToken"?this.tokenActionButtonTemplate(o):null}
|
|
363
|
+
`}tokenActionButtonTemplate(t){return t?u` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
|
|
364
|
+
<wui-text color="accent-primary" variant="sm-medium">Max</wui-text>
|
|
365
|
+
</button>`:u` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
|
|
366
|
+
<wui-text color="accent-primary" variant="sm-medium">Buy</wui-text>
|
|
367
|
+
</button>`}onFocusChange(t){this.focused=t}onSelectToken(){N.sendEvent({type:"track",event:"CLICK_SELECT_TOKEN_TO_SWAP"}),S.push("SwapSelectToken",{target:this.target})}onBuyToken(){S.push("OnRampProviders")}};k.styles=[Z];y([w()],k.prototype,"focused",void 0);y([w()],k.prototype,"balance",void 0);y([w()],k.prototype,"value",void 0);y([w()],k.prototype,"price",void 0);y([w()],k.prototype,"marketValue",void 0);y([w()],k.prototype,"disabled",void 0);y([w()],k.prototype,"target",void 0);y([w()],k.prototype,"token",void 0);y([w()],k.prototype,"onSetAmount",void 0);y([w()],k.prototype,"onSetMaxValue",void 0);k=y([C("w3m-swap-input")],k);const ee=A`
|
|
368
|
+
:host > wui-flex:first-child {
|
|
369
|
+
overflow-y: auto;
|
|
370
|
+
overflow-x: hidden;
|
|
371
|
+
scrollbar-width: none;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
375
|
+
display: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
wui-loading-hexagon {
|
|
379
|
+
position: absolute;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.action-button {
|
|
383
|
+
width: 100%;
|
|
384
|
+
border-radius: ${({borderRadius:e})=>e[4]};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.action-button:disabled {
|
|
388
|
+
border-color: 1px solid ${({tokens:e})=>e.core.glass010};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.swap-inputs-container {
|
|
392
|
+
position: relative;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
wui-icon-box {
|
|
396
|
+
width: 32px;
|
|
397
|
+
height: 32px;
|
|
398
|
+
border-radius: ${({borderRadius:e})=>e[10]} !important;
|
|
399
|
+
border: 4px solid ${({tokens:e})=>e.theme.backgroundPrimary};
|
|
400
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
401
|
+
position: absolute;
|
|
402
|
+
top: 50%;
|
|
403
|
+
left: 50%;
|
|
404
|
+
transform: translate(-50%, -50%);
|
|
405
|
+
z-index: 3;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.replace-tokens-button-container {
|
|
409
|
+
display: flex;
|
|
410
|
+
justify-content: center;
|
|
411
|
+
align-items: center;
|
|
412
|
+
position: absolute;
|
|
413
|
+
top: 50%;
|
|
414
|
+
left: 50%;
|
|
415
|
+
transform: translate(-50%, -50%);
|
|
416
|
+
gap: ${({spacing:e})=>e[2]};
|
|
417
|
+
border-radius: ${({borderRadius:e})=>e[4]};
|
|
418
|
+
background-color: ${({tokens:e})=>e.theme.backgroundPrimary};
|
|
419
|
+
padding: ${({spacing:e})=>e[2]};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.details-container > wui-flex {
|
|
423
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
424
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
425
|
+
width: 100%;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.details-container > wui-flex > button {
|
|
429
|
+
border: none;
|
|
430
|
+
background: none;
|
|
431
|
+
padding: ${({spacing:e})=>e[3]};
|
|
432
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
433
|
+
transition: background ${({durations:e})=>e.lg}
|
|
434
|
+
${({easings:e})=>e["ease-out-power-2"]};
|
|
435
|
+
will-change: background;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.details-container > wui-flex > button:hover {
|
|
439
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.details-content-container {
|
|
443
|
+
padding: ${({spacing:e})=>e[2]};
|
|
444
|
+
display: flex;
|
|
445
|
+
align-items: center;
|
|
446
|
+
justify-content: center;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.details-content-container > wui-flex {
|
|
450
|
+
width: 100%;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
.details-row {
|
|
454
|
+
width: 100%;
|
|
455
|
+
padding: ${({spacing:e})=>e[3]} ${({spacing:e})=>e[5]};
|
|
456
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
457
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
458
|
+
}
|
|
459
|
+
`;var m=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let p=class extends D{subscribe({resetSwapState:t,initializeSwapState:o}){return()=>{$.subscribeKey("activeCaipNetwork",i=>this.onCaipNetworkChange({newCaipNetwork:i,resetSwapState:t,initializeSwapState:o})),$.subscribeChainProp("accountState",i=>{this.onCaipAddressChange({newCaipAddress:i==null?void 0:i.caipAddress,resetSwapState:t,initializeSwapState:o})})}}constructor(){var t,o,i;super(),this.unsubscribe=[],this.initialParams=(t=S.state.data)==null?void 0:t.swap,this.detailsOpen=!1,this.caipAddress=(o=$.getAccountData())==null?void 0:o.caipAddress,this.caipNetworkId=(i=$.state.activeCaipNetwork)==null?void 0:i.caipNetworkId,this.initialized=s.state.initialized,this.loadingQuote=s.state.loadingQuote,this.loadingPrices=s.state.loadingPrices,this.loadingTransaction=s.state.loadingTransaction,this.sourceToken=s.state.sourceToken,this.sourceTokenAmount=s.state.sourceTokenAmount,this.sourceTokenPriceInUSD=s.state.sourceTokenPriceInUSD,this.toToken=s.state.toToken,this.toTokenAmount=s.state.toTokenAmount,this.toTokenPriceInUSD=s.state.toTokenPriceInUSD,this.inputError=s.state.inputError,this.fetchError=s.state.fetchError,this.lastTokenPriceUpdate=0,this.minTokenPriceUpdateInterval=1e4,this.visibilityChangeHandler=()=>{document!=null&&document.hidden?(clearInterval(this.interval),this.interval=void 0):this.startTokenPriceInterval()},this.startTokenPriceInterval=()=>{this.interval&&Date.now()-this.lastTokenPriceUpdate<this.minTokenPriceUpdateInterval||(this.lastTokenPriceUpdate&&Date.now()-this.lastTokenPriceUpdate>this.minTokenPriceUpdateInterval&&this.fetchTokensAndValues(),clearInterval(this.interval),this.interval=setInterval(()=>{this.fetchTokensAndValues()},this.minTokenPriceUpdateInterval))},this.watchTokensAndValues=()=>{!this.sourceToken||!this.toToken||(this.subscribeToVisibilityChange(),this.startTokenPriceInterval())},this.onDebouncedGetSwapCalldata=M.debounce(async()=>{await s.swapTokens()},200),this.subscribe({resetSwapState:!0,initializeSwapState:!1})(),this.unsubscribe.push(this.subscribe({resetSwapState:!1,initializeSwapState:!0}),K.subscribeKey("open",r=>{r||s.resetState()}),S.subscribeKey("view",r=>{r.includes("Swap")||s.resetValues()}),s.subscribe(r=>{this.initialized=r.initialized,this.loadingQuote=r.loadingQuote,this.loadingPrices=r.loadingPrices,this.loadingTransaction=r.loadingTransaction,this.sourceToken=r.sourceToken,this.sourceTokenAmount=r.sourceTokenAmount,this.sourceTokenPriceInUSD=r.sourceTokenPriceInUSD,this.toToken=r.toToken,this.toTokenAmount=r.toTokenAmount,this.toTokenPriceInUSD=r.toTokenPriceInUSD,this.inputError=r.inputError,this.fetchError=r.fetchError,r.sourceToken&&r.toToken&&this.watchTokensAndValues()}))}async firstUpdated(){s.initializeState(),this.watchTokensAndValues(),await this.handleSwapParameters()}disconnectedCallback(){this.unsubscribe.forEach(t=>t==null?void 0:t()),clearInterval(this.interval),document==null||document.removeEventListener("visibilitychange",this.visibilityChangeHandler)}render(){return u`
|
|
460
|
+
<wui-flex flexDirection="column" .padding=${["0","4","4","4"]} gap="3">
|
|
461
|
+
${this.initialized?this.templateSwap():this.templateLoading()}
|
|
462
|
+
</wui-flex>
|
|
463
|
+
`}subscribeToVisibilityChange(){document==null||document.removeEventListener("visibilitychange",this.visibilityChangeHandler),document==null||document.addEventListener("visibilitychange",this.visibilityChangeHandler)}fetchTokensAndValues(){s.getNetworkTokenPrice(),s.getMyTokensWithBalance(),s.swapTokens(),this.lastTokenPriceUpdate=Date.now()}templateSwap(){return u`
|
|
464
|
+
<wui-flex flexDirection="column" gap="3">
|
|
465
|
+
<wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
|
|
466
|
+
${this.templateTokenInput("sourceToken",this.sourceToken)}
|
|
467
|
+
${this.templateTokenInput("toToken",this.toToken)} ${this.templateReplaceTokensButton()}
|
|
468
|
+
</wui-flex>
|
|
469
|
+
${this.templateDetails()} ${this.templateActionButton()}
|
|
470
|
+
</wui-flex>
|
|
471
|
+
`}actionButtonLabel(){const t=!this.sourceTokenAmount||this.sourceTokenAmount==="0";return this.fetchError?"Swap":!this.sourceToken||!this.toToken?"Select token":t?"Enter amount":this.inputError?this.inputError:"Review swap"}templateReplaceTokensButton(){return u`
|
|
472
|
+
<wui-flex class="replace-tokens-button-container">
|
|
473
|
+
<wui-icon-box
|
|
474
|
+
@click=${this.onSwitchTokens.bind(this)}
|
|
475
|
+
icon="recycleHorizontal"
|
|
476
|
+
size="md"
|
|
477
|
+
variant="default"
|
|
478
|
+
></wui-icon-box>
|
|
479
|
+
</wui-flex>
|
|
480
|
+
`}templateLoading(){return u`
|
|
481
|
+
<wui-flex flexDirection="column" gap="4">
|
|
482
|
+
<wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
|
|
483
|
+
<w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
|
|
484
|
+
<w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
|
|
485
|
+
${this.templateReplaceTokensButton()}
|
|
486
|
+
</wui-flex>
|
|
487
|
+
${this.templateActionButton()}
|
|
488
|
+
</wui-flex>
|
|
489
|
+
`}templateTokenInput(t,o){var c,x;const i=(c=s.state.myTokensWithBalance)==null?void 0:c.find(I=>(I==null?void 0:I.address)===(o==null?void 0:o.address)),r=t==="toToken"?this.toTokenAmount:this.sourceTokenAmount,n=t==="toToken"?this.toTokenPriceInUSD:this.sourceTokenPriceInUSD,a=h.parseLocalStringToNumber(r)*n;return u`<w3m-swap-input
|
|
490
|
+
.value=${t==="toToken"?this.toTokenAmount:this.sourceTokenAmount}
|
|
491
|
+
.disabled=${t==="toToken"}
|
|
492
|
+
.onSetAmount=${this.handleChangeAmount.bind(this)}
|
|
493
|
+
target=${t}
|
|
494
|
+
.token=${o}
|
|
495
|
+
.balance=${(x=i==null?void 0:i.quantity)==null?void 0:x.numeric}
|
|
496
|
+
.price=${i==null?void 0:i.price}
|
|
497
|
+
.marketValue=${a}
|
|
498
|
+
.onSetMaxValue=${this.onSetMaxValue.bind(this)}
|
|
499
|
+
></w3m-swap-input>`}onSetMaxValue(t,o){const i=h.bigNumber(o||"0");this.handleChangeAmount(t,i.gt(0)?i.toFixed(20):"0")}templateDetails(){return!this.sourceToken||!this.toToken||this.inputError?null:u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`}handleChangeAmount(t,o){s.clearError(),t==="sourceToken"?s.setSourceTokenAmount(o):s.setToTokenAmount(o),this.onDebouncedGetSwapCalldata()}templateActionButton(){const t=!this.toToken||!this.sourceToken,o=!this.sourceTokenAmount||this.sourceTokenAmount==="0",i=this.loadingQuote||this.loadingPrices||this.loadingTransaction,r=i||t||o||this.inputError;return u` <wui-flex gap="2">
|
|
500
|
+
<wui-button
|
|
501
|
+
data-testid="swap-action-button"
|
|
502
|
+
class="action-button"
|
|
503
|
+
fullWidth
|
|
504
|
+
size="lg"
|
|
505
|
+
borderRadius="xs"
|
|
506
|
+
variant="accent-primary"
|
|
507
|
+
?loading=${!!i}
|
|
508
|
+
?disabled=${!!r}
|
|
509
|
+
@click=${this.onSwapPreview.bind(this)}
|
|
510
|
+
>
|
|
511
|
+
${this.actionButtonLabel()}
|
|
512
|
+
</wui-button>
|
|
513
|
+
</wui-flex>`}async onSwitchTokens(){await s.switchTokens()}async onSwapPreview(){var t,o;this.fetchError&&await s.swapTokens(),N.sendEvent({type:"track",event:"INITIATE_SWAP",properties:{network:this.caipNetworkId||"",swapFromToken:((t=this.sourceToken)==null?void 0:t.symbol)||"",swapToToken:((o=this.toToken)==null?void 0:o.symbol)||"",swapFromAmount:this.sourceTokenAmount||"",swapToAmount:this.toTokenAmount||"",isSmartAccount:F($.state.activeChain)===Q.ACCOUNT_TYPES.SMART_ACCOUNT}}),S.push("SwapPreview")}async handleSwapParameters(){this.initialParams&&(s.state.initialized||await new Promise(o=>{const i=s.subscribeKey("initialized",r=>{r&&(i==null||i(),o())})}),await this.setSwapParameters(this.initialParams))}async setSwapParameters({amount:t,fromToken:o,toToken:i}){(!s.state.tokens||!s.state.myTokensWithBalance)&&await new Promise(a=>{const c=s.subscribeKey("myTokensWithBalance",x=>{x&&x.length>0&&(c==null||c(),a())});setTimeout(()=>{c==null||c(),a()},5e3)});const r=[...s.state.tokens||[],...s.state.myTokensWithBalance||[]];if(o){const n=r.find(a=>a.symbol.toLowerCase()===o.toLowerCase());n&&s.setSourceToken(n)}if(i){const n=r.find(a=>a.symbol.toLowerCase()===i.toLowerCase());n&&s.setToToken(n)}t&&!isNaN(Number(t))&&s.setSourceTokenAmount(t)}onCaipAddressChange({newCaipAddress:t,resetSwapState:o,initializeSwapState:i}){this.caipAddress!==t&&(this.caipAddress=t,o&&s.resetState(),i&&s.initializeState())}onCaipNetworkChange({newCaipNetwork:t,resetSwapState:o,initializeSwapState:i}){this.caipNetworkId!==(t==null?void 0:t.caipNetworkId)&&(this.caipNetworkId=t==null?void 0:t.caipNetworkId,o&&s.resetState(),i&&s.initializeState())}};p.styles=ee;m([w({type:Object})],p.prototype,"initialParams",void 0);m([l()],p.prototype,"interval",void 0);m([l()],p.prototype,"detailsOpen",void 0);m([l()],p.prototype,"caipAddress",void 0);m([l()],p.prototype,"caipNetworkId",void 0);m([l()],p.prototype,"initialized",void 0);m([l()],p.prototype,"loadingQuote",void 0);m([l()],p.prototype,"loadingPrices",void 0);m([l()],p.prototype,"loadingTransaction",void 0);m([l()],p.prototype,"sourceToken",void 0);m([l()],p.prototype,"sourceTokenAmount",void 0);m([l()],p.prototype,"sourceTokenPriceInUSD",void 0);m([l()],p.prototype,"toToken",void 0);m([l()],p.prototype,"toTokenAmount",void 0);m([l()],p.prototype,"toTokenPriceInUSD",void 0);m([l()],p.prototype,"inputError",void 0);m([l()],p.prototype,"fetchError",void 0);m([l()],p.prototype,"lastTokenPriceUpdate",void 0);p=m([C("w3m-swap-view")],p);const te=A`
|
|
514
|
+
:host > wui-flex:first-child {
|
|
515
|
+
overflow-y: auto;
|
|
516
|
+
overflow-x: hidden;
|
|
517
|
+
scrollbar-width: none;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
521
|
+
display: none;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.preview-container,
|
|
525
|
+
.details-container {
|
|
526
|
+
width: 100%;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.token-image {
|
|
530
|
+
width: 24px;
|
|
531
|
+
height: 24px;
|
|
532
|
+
box-shadow: 0 0 0 2px ${({tokens:e})=>e.core.glass010};
|
|
533
|
+
border-radius: 12px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
wui-loading-hexagon {
|
|
537
|
+
position: absolute;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.token-item {
|
|
541
|
+
display: flex;
|
|
542
|
+
align-items: center;
|
|
543
|
+
justify-content: center;
|
|
544
|
+
gap: ${({spacing:e})=>e[2]};
|
|
545
|
+
padding: ${({spacing:e})=>e[2]};
|
|
546
|
+
height: 40px;
|
|
547
|
+
border: none;
|
|
548
|
+
border-radius: 80px;
|
|
549
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
550
|
+
box-shadow: inset 0 0 0 1px ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
551
|
+
cursor: pointer;
|
|
552
|
+
transition: background ${({durations:e})=>e.lg}
|
|
553
|
+
${({easings:e})=>e["ease-out-power-2"]};
|
|
554
|
+
will-change: background;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.token-item:hover {
|
|
558
|
+
background: ${({tokens:e})=>e.core.glass010};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.preview-token-details-container {
|
|
562
|
+
width: 100%;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.details-row {
|
|
566
|
+
width: 100%;
|
|
567
|
+
padding: ${({spacing:e})=>e[3]} ${({spacing:e})=>e[5]};
|
|
568
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
569
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.action-buttons-container {
|
|
573
|
+
width: 100%;
|
|
574
|
+
gap: ${({spacing:e})=>e[2]};
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.action-buttons-container > button {
|
|
578
|
+
display: flex;
|
|
579
|
+
align-items: center;
|
|
580
|
+
justify-content: center;
|
|
581
|
+
background: transparent;
|
|
582
|
+
height: 48px;
|
|
583
|
+
border-radius: ${({borderRadius:e})=>e[4]};
|
|
584
|
+
border: none;
|
|
585
|
+
box-shadow: inset 0 0 0 1px ${({tokens:e})=>e.core.glass010};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.action-buttons-container > button:disabled {
|
|
589
|
+
opacity: 0.8;
|
|
590
|
+
cursor: not-allowed;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.action-button > wui-loading-spinner {
|
|
594
|
+
display: inline-block;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.cancel-button:hover,
|
|
598
|
+
.action-button:hover {
|
|
599
|
+
cursor: pointer;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.action-buttons-container > wui-button.cancel-button {
|
|
603
|
+
flex: 2;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.action-buttons-container > wui-button.action-button {
|
|
607
|
+
flex: 4;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.action-buttons-container > button.action-button > wui-text {
|
|
611
|
+
color: white;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.details-container > wui-flex {
|
|
615
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
616
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
617
|
+
width: 100%;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
.details-container > wui-flex > button {
|
|
621
|
+
border: none;
|
|
622
|
+
background: none;
|
|
623
|
+
padding: ${({spacing:e})=>e[3]};
|
|
624
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
625
|
+
transition: background ${({durations:e})=>e.lg}
|
|
626
|
+
${({easings:e})=>e["ease-out-power-2"]};
|
|
627
|
+
will-change: background;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.details-container > wui-flex > button:hover {
|
|
631
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.details-content-container {
|
|
635
|
+
padding: ${({spacing:e})=>e[2]};
|
|
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: ${({spacing:e})=>e[3]} ${({spacing:e})=>e[5]};
|
|
648
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
649
|
+
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
650
|
+
}
|
|
651
|
+
`;var g=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let d=class extends D{constructor(){var t;super(),this.unsubscribe=[],this.detailsOpen=!0,this.approvalTransaction=s.state.approvalTransaction,this.swapTransaction=s.state.swapTransaction,this.sourceToken=s.state.sourceToken,this.sourceTokenAmount=s.state.sourceTokenAmount??"",this.sourceTokenPriceInUSD=s.state.sourceTokenPriceInUSD,this.balanceSymbol=(t=$.getAccountData())==null?void 0:t.balanceSymbol,this.toToken=s.state.toToken,this.toTokenAmount=s.state.toTokenAmount??"",this.toTokenPriceInUSD=s.state.toTokenPriceInUSD,this.caipNetwork=$.state.activeCaipNetwork,this.inputError=s.state.inputError,this.loadingQuote=s.state.loadingQuote,this.loadingApprovalTransaction=s.state.loadingApprovalTransaction,this.loadingBuildTransaction=s.state.loadingBuildTransaction,this.loadingTransaction=s.state.loadingTransaction,this.unsubscribe.push($.subscribeChainProp("accountState",o=>{(o==null?void 0:o.balanceSymbol)!==this.balanceSymbol&&S.goBack()}),$.subscribeKey("activeCaipNetwork",o=>{this.caipNetwork!==o&&(this.caipNetwork=o)}),s.subscribe(o=>{this.approvalTransaction=o.approvalTransaction,this.swapTransaction=o.swapTransaction,this.sourceToken=o.sourceToken,this.toToken=o.toToken,this.toTokenPriceInUSD=o.toTokenPriceInUSD,this.sourceTokenAmount=o.sourceTokenAmount??"",this.toTokenAmount=o.toTokenAmount??"",this.inputError=o.inputError,o.inputError&&S.goBack(),this.loadingQuote=o.loadingQuote,this.loadingApprovalTransaction=o.loadingApprovalTransaction,this.loadingBuildTransaction=o.loadingBuildTransaction,this.loadingTransaction=o.loadingTransaction}))}firstUpdated(){s.getTransaction(),this.refreshTransaction()}disconnectedCallback(){this.unsubscribe.forEach(t=>t==null?void 0:t()),clearInterval(this.interval)}render(){return u`
|
|
652
|
+
<wui-flex flexDirection="column" .padding=${["0","4","4","4"]} gap="3">
|
|
653
|
+
${this.templateSwap()}
|
|
654
|
+
</wui-flex>
|
|
655
|
+
`}refreshTransaction(){this.interval=setInterval(()=>{s.getApprovalLoadingState()||s.getTransaction()},1e4)}templateSwap(){var x,I,U,L;const t=`${h.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(x=this.sourceToken)==null?void 0:x.symbol}`,o=`${h.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(I=this.toToken)==null?void 0:I.symbol}`,i=parseFloat(this.sourceTokenAmount)*this.sourceTokenPriceInUSD,r=parseFloat(this.toTokenAmount)*this.toTokenPriceInUSD,n=h.formatNumberToLocalString(i),a=h.formatNumberToLocalString(r),c=this.loadingQuote||this.loadingBuildTransaction||this.loadingTransaction||this.loadingApprovalTransaction;return u`
|
|
656
|
+
<wui-flex flexDirection="column" alignItems="center" gap="4">
|
|
657
|
+
<wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="4">
|
|
658
|
+
<wui-flex
|
|
659
|
+
class="preview-token-details-container"
|
|
660
|
+
alignItems="center"
|
|
661
|
+
justifyContent="space-between"
|
|
662
|
+
gap="4"
|
|
663
|
+
>
|
|
664
|
+
<wui-flex flexDirection="column" alignItems="flex-start" gap="01">
|
|
665
|
+
<wui-text variant="sm-regular" color="secondary">Send</wui-text>
|
|
666
|
+
<wui-text variant="md-regular" color="primary">$${n}</wui-text>
|
|
667
|
+
</wui-flex>
|
|
668
|
+
<wui-token-button
|
|
669
|
+
flexDirection="row-reverse"
|
|
670
|
+
text=${t}
|
|
671
|
+
imageSrc=${(U=this.sourceToken)==null?void 0:U.logoUri}
|
|
672
|
+
>
|
|
673
|
+
</wui-token-button>
|
|
674
|
+
</wui-flex>
|
|
675
|
+
<wui-icon name="recycleHorizontal" color="default" size="md"></wui-icon>
|
|
676
|
+
<wui-flex
|
|
677
|
+
class="preview-token-details-container"
|
|
678
|
+
alignItems="center"
|
|
679
|
+
justifyContent="space-between"
|
|
680
|
+
gap="4"
|
|
681
|
+
>
|
|
682
|
+
<wui-flex flexDirection="column" alignItems="flex-start" gap="01">
|
|
683
|
+
<wui-text variant="sm-regular" color="secondary">Receive</wui-text>
|
|
684
|
+
<wui-text variant="md-regular" color="primary">$${a}</wui-text>
|
|
685
|
+
</wui-flex>
|
|
686
|
+
<wui-token-button
|
|
687
|
+
flexDirection="row-reverse"
|
|
688
|
+
text=${o}
|
|
689
|
+
imageSrc=${(L=this.toToken)==null?void 0:L.logoUri}
|
|
690
|
+
>
|
|
691
|
+
</wui-token-button>
|
|
692
|
+
</wui-flex>
|
|
693
|
+
</wui-flex>
|
|
694
|
+
|
|
695
|
+
${this.templateDetails()}
|
|
696
|
+
|
|
697
|
+
<wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="2">
|
|
698
|
+
<wui-icon size="sm" color="default" name="info"></wui-icon>
|
|
699
|
+
<wui-text variant="sm-regular" color="secondary">Review transaction carefully</wui-text>
|
|
700
|
+
</wui-flex>
|
|
701
|
+
|
|
702
|
+
<wui-flex
|
|
703
|
+
class="action-buttons-container"
|
|
704
|
+
flexDirection="row"
|
|
705
|
+
alignItems="center"
|
|
706
|
+
justifyContent="space-between"
|
|
707
|
+
gap="2"
|
|
708
|
+
>
|
|
709
|
+
<wui-button
|
|
710
|
+
class="cancel-button"
|
|
711
|
+
fullWidth
|
|
712
|
+
size="lg"
|
|
713
|
+
borderRadius="xs"
|
|
714
|
+
variant="neutral-secondary"
|
|
715
|
+
@click=${this.onCancelTransaction.bind(this)}
|
|
716
|
+
>
|
|
717
|
+
<wui-text variant="md-medium" color="secondary">Cancel</wui-text>
|
|
718
|
+
</wui-button>
|
|
719
|
+
<wui-button
|
|
720
|
+
class="action-button"
|
|
721
|
+
fullWidth
|
|
722
|
+
size="lg"
|
|
723
|
+
borderRadius="xs"
|
|
724
|
+
variant="accent-primary"
|
|
725
|
+
?loading=${c}
|
|
726
|
+
?disabled=${c}
|
|
727
|
+
@click=${this.onSendTransaction.bind(this)}
|
|
728
|
+
>
|
|
729
|
+
<wui-text variant="md-medium" color="invert"> ${this.actionButtonLabel()} </wui-text>
|
|
730
|
+
</wui-button>
|
|
731
|
+
</wui-flex>
|
|
732
|
+
</wui-flex>
|
|
733
|
+
`}templateDetails(){return!this.sourceToken||!this.toToken||this.inputError?null:u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`}actionButtonLabel(){return this.loadingApprovalTransaction?"Approving...":this.approvalTransaction?"Approve":"Swap"}onCancelTransaction(){S.goBack()}onSendTransaction(){this.approvalTransaction?s.sendTransactionForApproval(this.approvalTransaction):s.sendTransactionForSwap(this.swapTransaction)}};d.styles=te;g([l()],d.prototype,"interval",void 0);g([l()],d.prototype,"detailsOpen",void 0);g([l()],d.prototype,"approvalTransaction",void 0);g([l()],d.prototype,"swapTransaction",void 0);g([l()],d.prototype,"sourceToken",void 0);g([l()],d.prototype,"sourceTokenAmount",void 0);g([l()],d.prototype,"sourceTokenPriceInUSD",void 0);g([l()],d.prototype,"balanceSymbol",void 0);g([l()],d.prototype,"toToken",void 0);g([l()],d.prototype,"toTokenAmount",void 0);g([l()],d.prototype,"toTokenPriceInUSD",void 0);g([l()],d.prototype,"caipNetwork",void 0);g([l()],d.prototype,"inputError",void 0);g([l()],d.prototype,"loadingQuote",void 0);g([l()],d.prototype,"loadingApprovalTransaction",void 0);g([l()],d.prototype,"loadingBuildTransaction",void 0);g([l()],d.prototype,"loadingTransaction",void 0);d=g([C("w3m-swap-preview-view")],d);const oe=A`
|
|
734
|
+
:host {
|
|
735
|
+
width: 100%;
|
|
736
|
+
height: 60px;
|
|
737
|
+
min-height: 60px;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
:host > wui-flex {
|
|
741
|
+
cursor: pointer;
|
|
742
|
+
height: 100%;
|
|
743
|
+
display: flex;
|
|
744
|
+
column-gap: ${({spacing:e})=>e[3]};
|
|
745
|
+
padding: ${({spacing:e})=>e[2]};
|
|
746
|
+
padding-right: ${({spacing:e})=>e[4]};
|
|
747
|
+
width: 100%;
|
|
748
|
+
background-color: transparent;
|
|
749
|
+
border-radius: ${({borderRadius:e})=>e[4]};
|
|
750
|
+
color: ${({tokens:e})=>e.theme.foregroundSecondary};
|
|
751
|
+
transition:
|
|
752
|
+
background-color ${({durations:e})=>e.lg}
|
|
753
|
+
${({easings:e})=>e["ease-out-power-2"]},
|
|
754
|
+
opacity ${({durations:e})=>e.lg} ${({easings:e})=>e["ease-out-power-2"]};
|
|
755
|
+
will-change: background-color, opacity;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
@media (hover: hover) and (pointer: fine) {
|
|
759
|
+
:host > wui-flex:hover {
|
|
760
|
+
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
:host > wui-flex:active {
|
|
764
|
+
background-color: ${({tokens:e})=>e.core.glass010};
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
:host([disabled]) > wui-flex {
|
|
769
|
+
opacity: 0.6;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
:host([disabled]) > wui-flex:hover {
|
|
773
|
+
background-color: transparent;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
:host > wui-flex > wui-flex {
|
|
777
|
+
flex: 1;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
:host > wui-flex > wui-image,
|
|
781
|
+
:host > wui-flex > .token-item-image-placeholder {
|
|
782
|
+
width: 40px;
|
|
783
|
+
max-width: 40px;
|
|
784
|
+
height: 40px;
|
|
785
|
+
border-radius: ${({borderRadius:e})=>e[20]};
|
|
786
|
+
position: relative;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
:host > wui-flex > .token-item-image-placeholder {
|
|
790
|
+
display: flex;
|
|
791
|
+
align-items: center;
|
|
792
|
+
justify-content: center;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
:host > wui-flex > wui-image::after,
|
|
796
|
+
:host > wui-flex > .token-item-image-placeholder::after {
|
|
797
|
+
position: absolute;
|
|
798
|
+
content: '';
|
|
799
|
+
inset: 0;
|
|
800
|
+
box-shadow: inset 0 0 0 1px ${({tokens:e})=>e.core.glass010};
|
|
801
|
+
border-radius: ${({borderRadius:e})=>e[8]};
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
button > wui-icon-box[data-variant='square-blue'] {
|
|
805
|
+
border-radius: ${({borderRadius:e})=>e[2]};
|
|
806
|
+
position: relative;
|
|
807
|
+
border: none;
|
|
808
|
+
width: 36px;
|
|
809
|
+
height: 36px;
|
|
810
|
+
}
|
|
811
|
+
`;var E=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let P=class extends D{constructor(){super(),this.observer=new IntersectionObserver(()=>{}),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=>{t.forEach(o=>{o.isIntersecting?this.visible=!0:this.visible=!1})},{threshold:.1})}firstUpdated(){this.observer.observe(this)}disconnectedCallback(){this.observer.disconnect()}render(){var o;if(!this.visible)return null;const t=this.amount&&this.price?(o=h.multiply(this.price,this.amount))==null?void 0:o.toFixed(3):null;return u`
|
|
812
|
+
<wui-flex alignItems="center">
|
|
813
|
+
${this.visualTemplate()}
|
|
814
|
+
<wui-flex flexDirection="column" gap="1">
|
|
815
|
+
<wui-flex justifyContent="space-between">
|
|
816
|
+
<wui-text variant="md-medium" color="primary" lineClamp="1">${this.name}</wui-text>
|
|
817
|
+
${t?u`
|
|
818
|
+
<wui-text variant="md-medium" color="primary">
|
|
819
|
+
$${h.formatNumberToLocalString(t,3)}
|
|
820
|
+
</wui-text>
|
|
821
|
+
`:null}
|
|
822
|
+
</wui-flex>
|
|
823
|
+
<wui-flex justifyContent="space-between">
|
|
824
|
+
<wui-text variant="sm-regular" color="secondary" lineClamp="1">${this.symbol}</wui-text>
|
|
825
|
+
${this.amount?u`<wui-text variant="sm-regular" color="secondary">
|
|
826
|
+
${h.formatNumberToLocalString(this.amount,5)}
|
|
827
|
+
</wui-text>`:null}
|
|
828
|
+
</wui-flex>
|
|
829
|
+
</wui-flex>
|
|
830
|
+
</wui-flex>
|
|
831
|
+
`}visualTemplate(){return this.imageError?u`<wui-flex class="token-item-image-placeholder">
|
|
832
|
+
<wui-icon name="image" color="inherit"></wui-icon>
|
|
833
|
+
</wui-flex>`:this.imageSrc?u`<wui-image
|
|
834
|
+
width="40"
|
|
835
|
+
height="40"
|
|
836
|
+
src=${this.imageSrc}
|
|
837
|
+
@onLoadError=${this.imageLoadError}
|
|
838
|
+
></wui-image>`:null}imageLoadError(){this.imageError=!0}};P.styles=[W,q,oe];E([w()],P.prototype,"imageSrc",void 0);E([w()],P.prototype,"name",void 0);E([w()],P.prototype,"symbol",void 0);E([w()],P.prototype,"price",void 0);E([w()],P.prototype,"amount",void 0);E([l()],P.prototype,"visible",void 0);E([l()],P.prototype,"imageError",void 0);P=E([C("wui-token-list-item")],P);const ie=A`
|
|
839
|
+
:host {
|
|
840
|
+
width: 100%;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
:host > wui-flex {
|
|
844
|
+
cursor: pointer;
|
|
845
|
+
height: 100%;
|
|
846
|
+
width: 100%;
|
|
847
|
+
display: flex;
|
|
848
|
+
column-gap: ${({spacing:e})=>e[3]};
|
|
849
|
+
padding: ${({spacing:e})=>e[2]};
|
|
850
|
+
padding-right: ${({spacing:e})=>e[4]};
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
wui-flex {
|
|
854
|
+
display: flex;
|
|
855
|
+
flex: 1;
|
|
856
|
+
}
|
|
857
|
+
`;var ne=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let O=class extends D{render(){return u`
|
|
858
|
+
<wui-flex alignItems="center">
|
|
859
|
+
<wui-shimmer width="40px" height="40px"></wui-shimmer>
|
|
860
|
+
<wui-flex flexDirection="column" gap="1">
|
|
861
|
+
<wui-shimmer width="72px" height="16px" borderRadius="4xs"></wui-shimmer>
|
|
862
|
+
<wui-shimmer width="148px" height="14px" borderRadius="4xs"></wui-shimmer>
|
|
863
|
+
</wui-flex>
|
|
864
|
+
<wui-flex flexDirection="column" gap="1" alignItems="flex-end">
|
|
865
|
+
<wui-shimmer width="24px" height="12px" borderRadius="4xs"></wui-shimmer>
|
|
866
|
+
<wui-shimmer width="32px" height="12px" borderRadius="4xs"></wui-shimmer>
|
|
867
|
+
</wui-flex>
|
|
868
|
+
</wui-flex>
|
|
869
|
+
`}};O.styles=[W,ie];O=ne([C("wui-token-list-item-loader")],O);const re=A`
|
|
870
|
+
:host {
|
|
871
|
+
--tokens-scroll--top-opacity: 0;
|
|
872
|
+
--tokens-scroll--bottom-opacity: 1;
|
|
873
|
+
--suggested-tokens-scroll--left-opacity: 0;
|
|
874
|
+
--suggested-tokens-scroll--right-opacity: 1;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
:host > wui-flex:first-child {
|
|
878
|
+
overflow-y: hidden;
|
|
879
|
+
overflow-x: hidden;
|
|
880
|
+
scrollbar-width: none;
|
|
881
|
+
scrollbar-height: none;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
:host > wui-flex:first-child::-webkit-scrollbar {
|
|
885
|
+
display: none;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
wui-loading-hexagon {
|
|
889
|
+
position: absolute;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.suggested-tokens-container {
|
|
893
|
+
overflow-x: auto;
|
|
894
|
+
mask-image: linear-gradient(
|
|
895
|
+
to right,
|
|
896
|
+
rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
|
|
897
|
+
rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
|
|
898
|
+
black 50px,
|
|
899
|
+
black 90px,
|
|
900
|
+
black calc(100% - 90px),
|
|
901
|
+
black calc(100% - 50px),
|
|
902
|
+
rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
|
|
903
|
+
rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
.suggested-tokens-container::-webkit-scrollbar {
|
|
908
|
+
display: none;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
.tokens-container {
|
|
912
|
+
border-top: 1px solid ${({tokens:e})=>e.core.glass010};
|
|
913
|
+
height: 100%;
|
|
914
|
+
max-height: 390px;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
.tokens {
|
|
918
|
+
width: 100%;
|
|
919
|
+
overflow-y: auto;
|
|
920
|
+
mask-image: linear-gradient(
|
|
921
|
+
to bottom,
|
|
922
|
+
rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
|
|
923
|
+
rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
|
|
924
|
+
black 50px,
|
|
925
|
+
black 90px,
|
|
926
|
+
black calc(100% - 90px),
|
|
927
|
+
black calc(100% - 50px),
|
|
928
|
+
rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
|
|
929
|
+
rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
.network-search-input,
|
|
934
|
+
.select-network-button {
|
|
935
|
+
height: 40px;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
.select-network-button {
|
|
939
|
+
border: none;
|
|
940
|
+
display: flex;
|
|
941
|
+
flex-direction: row;
|
|
942
|
+
align-items: center;
|
|
943
|
+
justify-content: center;
|
|
944
|
+
gap: ${({spacing:e})=>e[2]};
|
|
945
|
+
box-shadow: inset 0 0 0 1px ${({tokens:e})=>e.core.glass010};
|
|
946
|
+
background-color: transparent;
|
|
947
|
+
border-radius: ${({borderRadius:e})=>e[3]};
|
|
948
|
+
padding: ${({spacing:e})=>e[2]};
|
|
949
|
+
align-items: center;
|
|
950
|
+
transition: background-color ${({durations:e})=>e.lg}
|
|
951
|
+
${({easings:e})=>e["ease-out-power-2"]};
|
|
952
|
+
will-change: background-color;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
.select-network-button:hover {
|
|
956
|
+
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.select-network-button > wui-image {
|
|
960
|
+
width: 26px;
|
|
961
|
+
height: 26px;
|
|
962
|
+
border-radius: ${({borderRadius:e})=>e[4]};
|
|
963
|
+
box-shadow: inset 0 0 0 1px ${({tokens:e})=>e.core.glass010};
|
|
964
|
+
}
|
|
965
|
+
`;var v=globalThis&&globalThis.__decorate||function(e,t,o,i){var r=arguments.length,n=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(n=(r<3?a(n):r>3?a(t,o,n):a(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};let b=class extends D{constructor(){var t;super(),this.unsubscribe=[],this.targetToken=(t=S.state.data)==null?void 0:t.target,this.sourceToken=s.state.sourceToken,this.sourceTokenAmount=s.state.sourceTokenAmount,this.toToken=s.state.toToken,this.myTokensWithBalance=s.state.myTokensWithBalance,this.popularTokens=s.state.popularTokens,this.suggestedTokens=s.state.suggestedTokens,this.tokensLoading=s.state.tokensLoading,this.searchValue="",this.unsubscribe.push(s.subscribe(o=>{this.sourceToken=o.sourceToken,this.toToken=o.toToken,this.myTokensWithBalance=o.myTokensWithBalance,this.popularTokens=o.popularTokens,this.suggestedTokens=o.suggestedTokens,this.tokensLoading=o.tokensLoading}))}async firstUpdated(){await s.getTokenList()}updated(){var i,r;const t=(i=this.renderRoot)==null?void 0:i.querySelector(".suggested-tokens-container");t==null||t.addEventListener("scroll",this.handleSuggestedTokensScroll.bind(this));const o=(r=this.renderRoot)==null?void 0:r.querySelector(".tokens");o==null||o.addEventListener("scroll",this.handleTokenListScroll.bind(this))}disconnectedCallback(){var i,r;super.disconnectedCallback();const t=(i=this.renderRoot)==null?void 0:i.querySelector(".suggested-tokens-container"),o=(r=this.renderRoot)==null?void 0:r.querySelector(".tokens");t==null||t.removeEventListener("scroll",this.handleSuggestedTokensScroll.bind(this)),o==null||o.removeEventListener("scroll",this.handleTokenListScroll.bind(this)),clearInterval(this.interval)}render(){return u`
|
|
966
|
+
<wui-flex flexDirection="column" gap="3">
|
|
967
|
+
${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
|
|
968
|
+
</wui-flex>
|
|
969
|
+
`}onSelectToken(t){this.targetToken==="sourceToken"?s.setSourceToken(t):(s.setToToken(t),this.sourceToken&&this.sourceTokenAmount&&s.swapTokens()),S.goBack()}templateSearchInput(){return u`
|
|
970
|
+
<wui-flex .padding=${["1","3","0","3"]} gap="2">
|
|
971
|
+
<wui-input-text
|
|
972
|
+
data-testid="swap-select-token-search-input"
|
|
973
|
+
class="network-search-input"
|
|
974
|
+
size="sm"
|
|
975
|
+
placeholder="Search token"
|
|
976
|
+
icon="search"
|
|
977
|
+
.value=${this.searchValue}
|
|
978
|
+
@inputChange=${this.onSearchInputChange.bind(this)}
|
|
979
|
+
></wui-input-text>
|
|
980
|
+
</wui-flex>
|
|
981
|
+
`}templateMyTokens(){const t=this.myTokensWithBalance?Object.values(this.myTokensWithBalance):[],o=this.filterTokensWithText(t,this.searchValue);return(o==null?void 0:o.length)>0?u`<wui-flex justifyContent="flex-start" padding="2">
|
|
982
|
+
<wui-text variant="md-medium" color="secondary">Your tokens</wui-text>
|
|
983
|
+
</wui-flex>
|
|
984
|
+
${o.map(i=>{var n,a,c;const r=i.symbol===((n=this.sourceToken)==null?void 0:n.symbol)||i.symbol===((a=this.toToken)==null?void 0:a.symbol);return u`
|
|
985
|
+
<wui-token-list-item
|
|
986
|
+
data-testid="swap-select-token-item-${i.symbol}"
|
|
987
|
+
name=${i.name}
|
|
988
|
+
?disabled=${r}
|
|
989
|
+
symbol=${i.symbol}
|
|
990
|
+
price=${i==null?void 0:i.price}
|
|
991
|
+
amount=${(c=i==null?void 0:i.quantity)==null?void 0:c.numeric}
|
|
992
|
+
imageSrc=${i.logoUri}
|
|
993
|
+
@click=${()=>{r||this.onSelectToken(i)}}
|
|
994
|
+
>
|
|
995
|
+
</wui-token-list-item>
|
|
996
|
+
`})}`:null}templateAllTokens(){const t=this.popularTokens?this.popularTokens:[],o=this.filterTokensWithText(t,this.searchValue);return this.tokensLoading?u`
|
|
997
|
+
<wui-token-list-item-loader></wui-token-list-item-loader>
|
|
998
|
+
<wui-token-list-item-loader></wui-token-list-item-loader>
|
|
999
|
+
<wui-token-list-item-loader></wui-token-list-item-loader>
|
|
1000
|
+
<wui-token-list-item-loader></wui-token-list-item-loader>
|
|
1001
|
+
<wui-token-list-item-loader></wui-token-list-item-loader>
|
|
1002
|
+
`:(o==null?void 0:o.length)>0?u`
|
|
1003
|
+
${o.map(i=>u`
|
|
1004
|
+
<wui-token-list-item
|
|
1005
|
+
data-testid="swap-select-token-item-${i.symbol}"
|
|
1006
|
+
name=${i.name}
|
|
1007
|
+
symbol=${i.symbol}
|
|
1008
|
+
imageSrc=${i.logoUri}
|
|
1009
|
+
@click=${()=>this.onSelectToken(i)}
|
|
1010
|
+
>
|
|
1011
|
+
</wui-token-list-item>
|
|
1012
|
+
`)}
|
|
1013
|
+
`:null}templateTokens(){return u`
|
|
1014
|
+
<wui-flex class="tokens-container">
|
|
1015
|
+
<wui-flex class="tokens" .padding=${["0","2","2","2"]} flexDirection="column">
|
|
1016
|
+
${this.templateMyTokens()}
|
|
1017
|
+
<wui-flex justifyContent="flex-start" padding="3">
|
|
1018
|
+
<wui-text variant="md-medium" color="secondary">Tokens</wui-text>
|
|
1019
|
+
</wui-flex>
|
|
1020
|
+
${this.templateAllTokens()}
|
|
1021
|
+
</wui-flex>
|
|
1022
|
+
</wui-flex>
|
|
1023
|
+
`}templateSuggestedTokens(){const t=this.suggestedTokens?this.suggestedTokens.slice(0,8):null;return this.tokensLoading?u`
|
|
1024
|
+
<wui-flex
|
|
1025
|
+
class="suggested-tokens-container"
|
|
1026
|
+
.padding=${["0","3","0","3"]}
|
|
1027
|
+
gap="2"
|
|
1028
|
+
>
|
|
1029
|
+
<wui-token-button loading></wui-token-button>
|
|
1030
|
+
<wui-token-button loading></wui-token-button>
|
|
1031
|
+
<wui-token-button loading></wui-token-button>
|
|
1032
|
+
<wui-token-button loading></wui-token-button>
|
|
1033
|
+
<wui-token-button loading></wui-token-button>
|
|
1034
|
+
</wui-flex>
|
|
1035
|
+
`:t?u`
|
|
1036
|
+
<wui-flex
|
|
1037
|
+
class="suggested-tokens-container"
|
|
1038
|
+
.padding=${["0","3","0","3"]}
|
|
1039
|
+
gap="2"
|
|
1040
|
+
>
|
|
1041
|
+
${t.map(o=>u`
|
|
1042
|
+
<wui-token-button
|
|
1043
|
+
text=${o.symbol}
|
|
1044
|
+
imageSrc=${o.logoUri}
|
|
1045
|
+
@click=${()=>this.onSelectToken(o)}
|
|
1046
|
+
>
|
|
1047
|
+
</wui-token-button>
|
|
1048
|
+
`)}
|
|
1049
|
+
</wui-flex>
|
|
1050
|
+
`:null}onSearchInputChange(t){this.searchValue=t.detail}handleSuggestedTokensScroll(){var o;const t=(o=this.renderRoot)==null?void 0:o.querySelector(".suggested-tokens-container");t&&(t.style.setProperty("--suggested-tokens-scroll--left-opacity",_.interpolate([0,100],[0,1],t.scrollLeft).toString()),t.style.setProperty("--suggested-tokens-scroll--right-opacity",_.interpolate([0,100],[0,1],t.scrollWidth-t.scrollLeft-t.offsetWidth).toString()))}handleTokenListScroll(){var o;const t=(o=this.renderRoot)==null?void 0:o.querySelector(".tokens");t&&(t.style.setProperty("--tokens-scroll--top-opacity",_.interpolate([0,100],[0,1],t.scrollTop).toString()),t.style.setProperty("--tokens-scroll--bottom-opacity",_.interpolate([0,100],[0,1],t.scrollHeight-t.scrollTop-t.offsetHeight).toString()))}filterTokensWithText(t,o){return t.filter(i=>`${i.symbol} ${i.name} ${i.address}`.toLowerCase().includes(o.toLowerCase())).sort((i,r)=>{const n=`${i.symbol} ${i.name} ${i.address}`.toLowerCase(),a=`${r.symbol} ${r.name} ${r.address}`.toLowerCase(),c=n.indexOf(o.toLowerCase()),x=a.indexOf(o.toLowerCase());return c-x})}};b.styles=re;v([l()],b.prototype,"interval",void 0);v([l()],b.prototype,"targetToken",void 0);v([l()],b.prototype,"sourceToken",void 0);v([l()],b.prototype,"sourceTokenAmount",void 0);v([l()],b.prototype,"toToken",void 0);v([l()],b.prototype,"myTokensWithBalance",void 0);v([l()],b.prototype,"popularTokens",void 0);v([l()],b.prototype,"suggestedTokens",void 0);v([l()],b.prototype,"tokensLoading",void 0);v([l()],b.prototype,"searchValue",void 0);b=v([C("w3m-swap-select-token-view")],b);export{d as W3mSwapPreviewView,b as W3mSwapSelectTokenView,p as W3mSwapView};
|