@shapeshiftoss/swap-widget 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +233 -0
- package/dist/index.js +63612 -0
- package/dist/style.css +1 -0
- package/package.json +69 -18
- package/Dockerfile +0 -87
- package/dist/assets/PhArrowCircleDown-B305t-Sh.js +0 -14
- package/dist/assets/PhArrowClockwise-CJPxQhr_.js +0 -14
- package/dist/assets/PhArrowDown-C4hT9BVu.js +0 -14
- package/dist/assets/PhArrowLeft-Way4Cu-r.js +0 -14
- package/dist/assets/PhArrowRight-Cp5ZME0F.js +0 -14
- package/dist/assets/PhArrowSquareOut-NnrK69c5.js +0 -14
- package/dist/assets/PhArrowUp-Dph6j8rm.js +0 -14
- package/dist/assets/PhArrowUpRight-BpJjRRRh.js +0 -14
- package/dist/assets/PhArrowsClockwise-CFUT8X7R.js +0 -14
- package/dist/assets/PhArrowsDownUp-BjBI4ckC.js +0 -14
- package/dist/assets/PhArrowsLeftRight-CuLpbKRk.js +0 -14
- package/dist/assets/PhBank-Dchr4XQJ.js +0 -14
- package/dist/assets/PhBrowser-dUu2TrC1.js +0 -14
- package/dist/assets/PhCaretDown-78IuKU3V.js +0 -14
- package/dist/assets/PhCaretLeft-_aiyH7n1.js +0 -14
- package/dist/assets/PhCaretRight-8zJQEuDX.js +0 -14
- package/dist/assets/PhCaretUp-CiCxKWwN.js +0 -14
- package/dist/assets/PhCheck-CcADx8br.js +0 -14
- package/dist/assets/PhCircleHalf-BYzSzd2h.js +0 -14
- package/dist/assets/PhClock-UItiXeJq.js +0 -14
- package/dist/assets/PhCompass-CUy3uA7t.js +0 -14
- package/dist/assets/PhCopy-C-PDgSlZ.js +0 -14
- package/dist/assets/PhCreditCard-CWRaUT6F.js +0 -14
- package/dist/assets/PhCurrencyDollar-Cqla3AXT.js +0 -14
- package/dist/assets/PhDesktop-BBIPrYLl.js +0 -14
- package/dist/assets/PhDeviceMobile-BdsPaATg.js +0 -14
- package/dist/assets/PhDotsThree-BMXCQl-0.js +0 -14
- package/dist/assets/PhEnvelope-yUsis6yU.js +0 -14
- package/dist/assets/PhFunnelSimple-Ba7BbWTp.js +0 -14
- package/dist/assets/PhGlobe-DgLxBk5U.js +0 -14
- package/dist/assets/PhIdentificationCard-Czjmq9Z3.js +0 -14
- package/dist/assets/PhImage-BAJ_erz6.js +0 -14
- package/dist/assets/PhInfo-Cr4DhVUE.js +0 -14
- package/dist/assets/PhLightbulb-BX_7duTr.js +0 -14
- package/dist/assets/PhMagnifyingGlass-Mygfryvz.js +0 -14
- package/dist/assets/PhPaperPlaneRight-BeuCA660.js +0 -14
- package/dist/assets/PhPlus-BMjcHjsT.js +0 -14
- package/dist/assets/PhPower-CGffGmdb.js +0 -14
- package/dist/assets/PhPuzzlePiece-wm_GpVSi.js +0 -14
- package/dist/assets/PhQrCode-DRwRzXCH.js +0 -14
- package/dist/assets/PhQuestion-M09j2U0T.js +0 -14
- package/dist/assets/PhQuestionMark-BP9EMB6h.js +0 -14
- package/dist/assets/PhSealCheck-BfG80yKn.js +0 -14
- package/dist/assets/PhSignOut-C5YOWlPT.js +0 -14
- package/dist/assets/PhSpinner-BXooDYzU.js +0 -14
- package/dist/assets/PhTrash-Biq6rmmL.js +0 -14
- package/dist/assets/PhUser-CAgZSpGe.js +0 -14
- package/dist/assets/PhVault-l2PHF38a.js +0 -14
- package/dist/assets/PhWallet-w25D16It.js +0 -14
- package/dist/assets/PhWarning-DPEydIPw.js +0 -14
- package/dist/assets/PhWarningCircle-BqjT745H.js +0 -14
- package/dist/assets/PhX-s-SmVExa.js +0 -14
- package/dist/assets/SwapController-If0bFrNc.js +0 -1
- package/dist/assets/ccip-BBB7uCdL.js +0 -1
- package/dist/assets/ccip-CkkdfKKI.js +0 -1
- package/dist/assets/data-capture-D4gAy-Yc.js +0 -242
- package/dist/assets/email-B1AJehis.js +0 -90
- package/dist/assets/embedded-wallet-Q6DQopDk.js +0 -410
- package/dist/assets/features-B6JAPAFb.js +0 -5
- package/dist/assets/index-5jd8RPN9.js +0 -7428
- package/dist/assets/index-B4kNtSTk.js +0 -1080
- package/dist/assets/index-B753eAob.js +0 -1
- package/dist/assets/index-BZoLTv77.js +0 -3
- package/dist/assets/index-Bcw9UURX.js +0 -3
- package/dist/assets/index-BkrV-ahK.js +0 -2
- package/dist/assets/index-CRQzQ_up.js +0 -9
- package/dist/assets/index-CSW0Gt5y.js +0 -132
- package/dist/assets/index-CZ4jTIsk.js +0 -138
- package/dist/assets/index-Cwa8SB3h.js +0 -61
- package/dist/assets/index-DEwQgT4r.js +0 -78
- package/dist/assets/index-DVfQiQ1d.js +0 -1
- package/dist/assets/index-cV3UdaMs.css +0 -1
- package/dist/assets/index-hAmu622O.js +0 -43
- package/dist/assets/onramp-XcPNCLRU.js +0 -422
- package/dist/assets/pay-with-exchange-BeHt4OF4.js +0 -280
- package/dist/assets/property-C9JG5tag.js +0 -27
- package/dist/assets/receive-7ff4he2S.js +0 -131
- package/dist/assets/send-CkMBIRXT.js +0 -554
- package/dist/assets/socials-DmmxuLrP.js +0 -250
- package/dist/assets/swaps-IHAYRQ0x.js +0 -1050
- package/dist/assets/transactions-9Cxdk7o9.js +0 -16
- package/dist/assets/v4-BOvFkHkt.js +0 -1
- package/dist/assets/w3m-modal-kJzFnBfB.js +0 -891
- package/dist/assets/wallet-standard-Dv8LMoUB.js +0 -1
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +0 -11
- package/dist/icon-192x192.png +0 -0
- package/dist/icon-512x512.png +0 -0
- package/dist/index.html +0 -33
- package/index.html +0 -32
- package/public/favicon.png +0 -0
- package/public/favicon.svg +0 -11
- package/public/icon-192x192.png +0 -0
- package/public/icon-512x512.png +0 -0
- package/railway.toml +0 -10
- package/src/api/client.ts +0 -95
- package/src/components/AddressInputModal.css +0 -173
- package/src/components/AddressInputModal.tsx +0 -250
- package/src/components/ApprovalStep.tsx +0 -92
- package/src/components/ExecutionStep.tsx +0 -27
- package/src/components/InputStep.tsx +0 -431
- package/src/components/QuoteSelector.css +0 -146
- package/src/components/QuoteSelector.tsx +0 -137
- package/src/components/QuotesModal.css +0 -250
- package/src/components/QuotesModal.tsx +0 -182
- package/src/components/SettingsModal.css +0 -145
- package/src/components/SettingsModal.tsx +0 -180
- package/src/components/StatusStep.tsx +0 -139
- package/src/components/SwapWidget.css +0 -713
- package/src/components/SwapWidget.tsx +0 -607
- package/src/components/TokenSelectModal.css +0 -438
- package/src/components/TokenSelectModal.tsx +0 -487
- package/src/components/WalletProvider.tsx +0 -92
- package/src/config/appkit.ts +0 -104
- package/src/config/wagmi.ts +0 -27
- package/src/constants/chains.ts +0 -72
- package/src/constants/defaults.ts +0 -28
- package/src/constants/swappers.ts +0 -48
- package/src/constants/viemChains.ts +0 -69
- package/src/contexts/SwapWalletContext.tsx +0 -25
- package/src/demo/App.css +0 -458
- package/src/demo/App.tsx +0 -481
- package/src/demo/main.tsx +0 -25
- package/src/hooks/useAssets.ts +0 -180
- package/src/hooks/useBalances.ts +0 -822
- package/src/hooks/useBitcoinSigning.ts +0 -276
- package/src/hooks/useMarketData.ts +0 -169
- package/src/hooks/useSolanaSigning.ts +0 -275
- package/src/hooks/useStatusPolling.ts +0 -137
- package/src/hooks/useSwapApproval.ts +0 -106
- package/src/hooks/useSwapDisplayValues.ts +0 -157
- package/src/hooks/useSwapExecution.ts +0 -199
- package/src/hooks/useSwapHandlers.ts +0 -119
- package/src/hooks/useSwapQuote.ts +0 -71
- package/src/hooks/useSwapQuoting.ts +0 -102
- package/src/hooks/useSwapRates.ts +0 -61
- package/src/index.ts +0 -43
- package/src/machines/SwapMachineContext.ts +0 -5
- package/src/machines/__tests__/guards.test.ts +0 -228
- package/src/machines/__tests__/setup.test.ts +0 -7
- package/src/machines/__tests__/swapMachine.test.ts +0 -544
- package/src/machines/__tests__/types.test.ts +0 -124
- package/src/machines/guards.ts +0 -33
- package/src/machines/swapMachine.ts +0 -288
- package/src/machines/types.ts +0 -54
- package/src/services/transactionStatus.ts +0 -322
- package/src/types/index.ts +0 -361
- package/src/utils/addressValidation.ts +0 -201
- package/src/utils/redirect.ts +0 -45
- package/src/vite-env.d.ts +0 -10
- package/tsconfig.json +0 -23
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -101
- package/vitest.config.ts +0 -18
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
import{y as x,F as d,a4 as u,G as b,I as v,at as F,n as D,k as g,C as j,aF as l,J as c,au as z,R as h,N as H,U as R,as as q,S as y,r as Q,q as X,a1 as K,z as Y,D as J,a3 as Z,aN as L,aO as M,E as ee}from"./index-5jd8RPN9.js";import"./index-DEwQgT4r.js";import"./index-CZ4jTIsk.js";import{S as G}from"./SwapController-If0bFrNc.js";const te=x`
|
|
2
|
-
:host {
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100px;
|
|
5
|
-
border-radius: ${({borderRadius:e})=>e[5]};
|
|
6
|
-
border: 1px solid ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
7
|
-
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
8
|
-
transition: background-color ${({durations:e})=>e.lg}
|
|
9
|
-
${({easings:e})=>e["ease-out-power-1"]};
|
|
10
|
-
will-change: background-color;
|
|
11
|
-
position: relative;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:host(:hover) {
|
|
15
|
-
background-color: ${({tokens:e})=>e.theme.foregroundSecondary};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
wui-flex {
|
|
19
|
-
width: 100%;
|
|
20
|
-
height: fit-content;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
wui-button {
|
|
24
|
-
display: ruby;
|
|
25
|
-
color: ${({tokens:e})=>e.theme.textPrimary};
|
|
26
|
-
margin: 0 ${({spacing:e})=>e[2]};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.instruction {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 50%;
|
|
32
|
-
transform: translateY(-50%);
|
|
33
|
-
z-index: 2;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.paste {
|
|
37
|
-
display: inline-flex;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
textarea {
|
|
41
|
-
background: transparent;
|
|
42
|
-
width: 100%;
|
|
43
|
-
font-family: ${({fontFamily:e})=>e.regular};
|
|
44
|
-
font-style: normal;
|
|
45
|
-
font-size: ${({textSize:e})=>e.large};
|
|
46
|
-
font-weight: ${({fontWeight:e})=>e.regular};
|
|
47
|
-
line-height: ${({typography:e})=>e["lg-regular"].lineHeight};
|
|
48
|
-
letter-spacing: ${({typography:e})=>e["lg-regular"].letterSpacing};
|
|
49
|
-
color: ${({tokens:e})=>e.theme.textPrimary};
|
|
50
|
-
caret-color: ${({tokens:e})=>e.core.backgroundAccentPrimary};
|
|
51
|
-
box-sizing: border-box;
|
|
52
|
-
-webkit-appearance: none;
|
|
53
|
-
-moz-appearance: textfield;
|
|
54
|
-
padding: 0px;
|
|
55
|
-
border: none;
|
|
56
|
-
outline: none;
|
|
57
|
-
appearance: none;
|
|
58
|
-
resize: none;
|
|
59
|
-
overflow: hidden;
|
|
60
|
-
}
|
|
61
|
-
`;var E=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let $=class extends v{constructor(){super(...arguments),this.inputElementRef=F(),this.instructionElementRef=F(),this.readOnly=!1,this.instructionHidden=!!this.value,this.pasting=!1,this.onDebouncedSearch=D.debounce(async t=>{if(!t.length){this.setReceiverAddress("");return}const i=g.state.activeChain;if(D.isAddress(t,i)){this.setReceiverAddress(t);return}try{const o=await j.getEnsAddress(t);if(o){l.setReceiverProfileName(t),l.setReceiverAddress(o);const n=await j.getEnsAvatar(t);l.setReceiverProfileImageUrl(n||void 0)}}catch{this.setReceiverAddress(t)}finally{l.setLoading(!1)}})}firstUpdated(){this.value&&(this.instructionHidden=!0),this.checkHidden()}render(){return this.readOnly?c` <wui-flex
|
|
62
|
-
flexDirection="column"
|
|
63
|
-
justifyContent="center"
|
|
64
|
-
gap="01"
|
|
65
|
-
.padding=${["8","4","5","4"]}
|
|
66
|
-
>
|
|
67
|
-
<textarea
|
|
68
|
-
spellcheck="false"
|
|
69
|
-
?disabled=${!0}
|
|
70
|
-
autocomplete="off"
|
|
71
|
-
.value=${this.value??""}
|
|
72
|
-
>
|
|
73
|
-
${this.value??""}</textarea
|
|
74
|
-
>
|
|
75
|
-
</wui-flex>`:c` <wui-flex
|
|
76
|
-
@click=${this.onBoxClick.bind(this)}
|
|
77
|
-
flexDirection="column"
|
|
78
|
-
justifyContent="center"
|
|
79
|
-
gap="01"
|
|
80
|
-
.padding=${["8","4","5","4"]}
|
|
81
|
-
>
|
|
82
|
-
<wui-text
|
|
83
|
-
${z(this.instructionElementRef)}
|
|
84
|
-
class="instruction"
|
|
85
|
-
color="secondary"
|
|
86
|
-
variant="md-medium"
|
|
87
|
-
>
|
|
88
|
-
Type or
|
|
89
|
-
<wui-button
|
|
90
|
-
class="paste"
|
|
91
|
-
size="md"
|
|
92
|
-
variant="neutral-secondary"
|
|
93
|
-
iconLeft="copy"
|
|
94
|
-
@click=${this.onPasteClick.bind(this)}
|
|
95
|
-
>
|
|
96
|
-
<wui-icon size="sm" color="inherit" slot="iconLeft" name="copy"></wui-icon>
|
|
97
|
-
Paste
|
|
98
|
-
</wui-button>
|
|
99
|
-
address
|
|
100
|
-
</wui-text>
|
|
101
|
-
<textarea
|
|
102
|
-
spellcheck="false"
|
|
103
|
-
?disabled=${!this.instructionHidden}
|
|
104
|
-
${z(this.inputElementRef)}
|
|
105
|
-
@input=${this.onInputChange.bind(this)}
|
|
106
|
-
@blur=${this.onBlur.bind(this)}
|
|
107
|
-
.value=${this.value??""}
|
|
108
|
-
autocomplete="off"
|
|
109
|
-
>
|
|
110
|
-
${this.value??""}</textarea
|
|
111
|
-
>
|
|
112
|
-
</wui-flex>`}async focusInput(){var t;this.instructionElementRef.value&&(this.instructionHidden=!0,await this.toggleInstructionFocus(!1),this.instructionElementRef.value.style.pointerEvents="none",(t=this.inputElementRef.value)==null||t.focus(),this.inputElementRef.value&&(this.inputElementRef.value.selectionStart=this.inputElementRef.value.selectionEnd=this.inputElementRef.value.value.length))}async focusInstruction(){var t;this.instructionElementRef.value&&(this.instructionHidden=!1,await this.toggleInstructionFocus(!0),this.instructionElementRef.value.style.pointerEvents="auto",(t=this.inputElementRef.value)==null||t.blur())}async toggleInstructionFocus(t){this.instructionElementRef.value&&await this.instructionElementRef.value.animate([{opacity:t?0:1},{opacity:t?1:0}],{duration:100,easing:"ease",fill:"forwards"}).finished}onBoxClick(){!this.value&&!this.instructionHidden&&this.focusInput()}onBlur(){!this.value&&this.instructionHidden&&!this.pasting&&this.focusInstruction()}checkHidden(){this.instructionHidden&&this.focusInput()}async onPasteClick(){this.pasting=!0;const t=await navigator.clipboard.readText();l.setReceiverAddress(t),this.focusInput()}onInputChange(t){var r;const i=t.target;this.pasting=!1,this.value=(r=t.target)==null?void 0:r.value,i.value&&!this.instructionHidden&&this.focusInput(),l.setLoading(!0),this.onDebouncedSearch(i.value)}setReceiverAddress(t){l.setReceiverAddress(t),l.setReceiverProfileName(void 0),l.setReceiverProfileImageUrl(void 0),l.setLoading(!1)}};$.styles=te;E([d()],$.prototype,"value",void 0);E([d({type:Boolean})],$.prototype,"readOnly",void 0);E([u()],$.prototype,"instructionHidden",void 0);E([u()],$.prototype,"pasting",void 0);$=E([b("w3m-input-address")],$);const ie=x`
|
|
113
|
-
:host {
|
|
114
|
-
width: 100%;
|
|
115
|
-
height: 100px;
|
|
116
|
-
border-radius: ${({borderRadius:e})=>e[5]};
|
|
117
|
-
border: 1px solid ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
118
|
-
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
119
|
-
transition: background-color ${({durations:e})=>e.lg}
|
|
120
|
-
${({easings:e})=>e["ease-out-power-1"]};
|
|
121
|
-
will-change: background-color;
|
|
122
|
-
transition: all ${({easings:e})=>e["ease-out-power-1"]}
|
|
123
|
-
${({durations:e})=>e.lg};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
:host(:hover) {
|
|
127
|
-
background-color: ${({tokens:e})=>e.theme.foregroundSecondary};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
wui-flex {
|
|
131
|
-
width: 100%;
|
|
132
|
-
height: fit-content;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
wui-button {
|
|
136
|
-
width: 100%;
|
|
137
|
-
display: flex;
|
|
138
|
-
justify-content: flex-end;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
wui-input-amount {
|
|
142
|
-
mask-image: linear-gradient(
|
|
143
|
-
270deg,
|
|
144
|
-
transparent 0px,
|
|
145
|
-
transparent 8px,
|
|
146
|
-
black 24px,
|
|
147
|
-
black 25px,
|
|
148
|
-
black 32px,
|
|
149
|
-
black 100%
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.totalValue {
|
|
154
|
-
width: 100%;
|
|
155
|
-
}
|
|
156
|
-
`;var P=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let A=class extends v{constructor(){super(...arguments),this.readOnly=!1,this.isInsufficientBalance=!1}render(){const t=this.readOnly||!this.token;return c` <wui-flex
|
|
157
|
-
flexDirection="column"
|
|
158
|
-
gap="01"
|
|
159
|
-
.padding=${["5","3","4","3"]}
|
|
160
|
-
>
|
|
161
|
-
<wui-flex alignItems="center">
|
|
162
|
-
<wui-input-amount
|
|
163
|
-
@inputChange=${this.onInputChange.bind(this)}
|
|
164
|
-
?disabled=${t}
|
|
165
|
-
.value=${this.sendTokenAmount?String(this.sendTokenAmount):""}
|
|
166
|
-
?error=${!!this.isInsufficientBalance}
|
|
167
|
-
></wui-input-amount>
|
|
168
|
-
${this.buttonTemplate()}
|
|
169
|
-
</wui-flex>
|
|
170
|
-
${this.bottomTemplate()}
|
|
171
|
-
</wui-flex>`}buttonTemplate(){return this.token?c`<wui-token-button
|
|
172
|
-
text=${this.token.symbol}
|
|
173
|
-
imageSrc=${this.token.iconUrl}
|
|
174
|
-
@click=${this.handleSelectButtonClick.bind(this)}
|
|
175
|
-
>
|
|
176
|
-
</wui-token-button>`:c`<wui-button
|
|
177
|
-
size="md"
|
|
178
|
-
variant="neutral-secondary"
|
|
179
|
-
@click=${this.handleSelectButtonClick.bind(this)}
|
|
180
|
-
>Select token</wui-button
|
|
181
|
-
>`}handleSelectButtonClick(){this.readOnly||h.push("WalletSendSelectToken")}sendValueTemplate(){if(!this.readOnly&&this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return c`<wui-text class="totalValue" variant="sm-regular" color="secondary"
|
|
182
|
-
>${i?`$${H.formatNumberToLocalString(i,2)}`:"Incorrect value"}</wui-text
|
|
183
|
-
>`}return null}maxAmountTemplate(){return this.token?c` <wui-text variant="sm-regular" color="secondary">
|
|
184
|
-
${R.roundNumber(Number(this.token.quantity.numeric),6,5)}
|
|
185
|
-
</wui-text>`:null}actionTemplate(){return this.token?c`<wui-link @click=${this.onMaxClick.bind(this)}>Max</wui-link>`:null}bottomTemplate(){return this.readOnly?null:c`<wui-flex alignItems="center" justifyContent="space-between">
|
|
186
|
-
${this.sendValueTemplate()}
|
|
187
|
-
<wui-flex alignItems="center" gap="01" justifyContent="flex-end">
|
|
188
|
-
${this.maxAmountTemplate()} ${this.actionTemplate()}
|
|
189
|
-
</wui-flex>
|
|
190
|
-
</wui-flex>`}onInputChange(t){l.setTokenAmount(t.detail)}onMaxClick(){if(this.token){const t=H.bigNumber(this.token.quantity.numeric);l.setTokenAmount(Number(t.toFixed(20)))}}};A.styles=ie;P([d({type:Object})],A.prototype,"token",void 0);P([d({type:Boolean})],A.prototype,"readOnly",void 0);P([d({type:Number})],A.prototype,"sendTokenAmount",void 0);P([d({type:Boolean})],A.prototype,"isInsufficientBalance",void 0);A=P([b("w3m-input-token")],A);const ne=x`
|
|
191
|
-
:host {
|
|
192
|
-
display: block;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
wui-flex {
|
|
196
|
-
position: relative;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
wui-icon-box {
|
|
200
|
-
width: 32px;
|
|
201
|
-
height: 32px;
|
|
202
|
-
border-radius: ${({borderRadius:e})=>e[10]} !important;
|
|
203
|
-
border: 4px solid ${({tokens:e})=>e.theme.backgroundPrimary};
|
|
204
|
-
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
205
|
-
position: absolute;
|
|
206
|
-
top: 50%;
|
|
207
|
-
left: 50%;
|
|
208
|
-
transform: translate(-50%, -50%);
|
|
209
|
-
z-index: 3;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
wui-button {
|
|
213
|
-
--local-border-radius: ${({borderRadius:e})=>e[4]} !important;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.inputContainer {
|
|
217
|
-
height: fit-content;
|
|
218
|
-
}
|
|
219
|
-
`;var w=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};const p={INSUFFICIENT_FUNDS:"Insufficient Funds",INCORRECT_VALUE:"Incorrect Value",INVALID_ADDRESS:"Invalid Address",ADD_ADDRESS:"Add Address",ADD_AMOUNT:"Add Amount",SELECT_TOKEN:"Select Token",PREVIEW_SEND:"Preview Send"};let f=class extends v{constructor(){var i,r;super(),this.unsubscribe=[],this.isTryingToChooseDifferentWallet=!1,this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.loading=l.state.loading,this.params=(i=h.state.data)==null?void 0:i.send,this.caipAddress=(r=g.getAccountData())==null?void 0:r.caipAddress,this.message=p.PREVIEW_SEND,this.disconnecting=!1,this.token&&!this.params&&(this.fetchBalances(),this.fetchNetworkPrice());const t=g.subscribeKey("activeCaipAddress",o=>{!o&&this.isTryingToChooseDifferentWallet&&(this.isTryingToChooseDifferentWallet=!1,q.open({view:"Connect",data:{redirectView:"WalletSend"}}).catch(()=>null),t())});this.unsubscribe.push(g.subscribeAccountStateProp("caipAddress",o=>{this.caipAddress=o}),l.subscribe(o=>{this.token=o.token,this.sendTokenAmount=o.sendTokenAmount,this.receiverAddress=o.receiverAddress,this.receiverProfileName=o.receiverProfileName,this.loading=o.loading}))}disconnectedCallback(){this.unsubscribe.forEach(t=>t())}async firstUpdated(){await this.handleSendParameters()}render(){this.getMessage();const t=!!this.params;return c` <wui-flex flexDirection="column" .padding=${["0","4","4","4"]}>
|
|
220
|
-
<wui-flex class="inputContainer" gap="2" flexDirection="column">
|
|
221
|
-
<w3m-input-token
|
|
222
|
-
.token=${this.token}
|
|
223
|
-
.sendTokenAmount=${this.sendTokenAmount}
|
|
224
|
-
?readOnly=${t}
|
|
225
|
-
?isInsufficientBalance=${this.message===p.INSUFFICIENT_FUNDS}
|
|
226
|
-
></w3m-input-token>
|
|
227
|
-
<wui-icon-box size="md" variant="secondary" icon="arrowBottom"></wui-icon-box>
|
|
228
|
-
<w3m-input-address
|
|
229
|
-
?readOnly=${t}
|
|
230
|
-
.value=${this.receiverProfileName?this.receiverProfileName:this.receiverAddress}
|
|
231
|
-
></w3m-input-address>
|
|
232
|
-
</wui-flex>
|
|
233
|
-
${this.buttonTemplate()}
|
|
234
|
-
</wui-flex>`}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await G.getNetworkTokenPrice()}onButtonClick(){h.push("WalletSendPreview",{send:this.params})}onFundWalletClick(){h.push("FundWallet",{redirectView:"WalletSend"})}async onConnectDifferentWalletClick(){try{this.isTryingToChooseDifferentWallet=!0,this.disconnecting=!0,await j.disconnect()}finally{this.disconnecting=!1}}getMessage(){var t;this.message=p.PREVIEW_SEND,this.receiverAddress&&!D.isAddress(this.receiverAddress,g.state.activeChain)&&(this.message=p.INVALID_ADDRESS),this.receiverAddress||(this.message=p.ADD_ADDRESS),this.sendTokenAmount&&this.token&&this.sendTokenAmount>Number(this.token.quantity.numeric)&&(this.message=p.INSUFFICIENT_FUNDS),this.sendTokenAmount||(this.message=p.ADD_AMOUNT),this.sendTokenAmount&&((t=this.token)!=null&&t.price)&&(this.sendTokenAmount*this.token.price||(this.message=p.INCORRECT_VALUE)),this.token||(this.message=p.SELECT_TOKEN)}buttonTemplate(){const t=!this.message.startsWith(p.PREVIEW_SEND),i=this.message===p.INSUFFICIENT_FUNDS,r=!!this.params;return i&&!r?c`
|
|
235
|
-
<wui-flex .margin=${["4","0","0","0"]} flexDirection="column" gap="4">
|
|
236
|
-
<wui-button
|
|
237
|
-
@click=${this.onFundWalletClick.bind(this)}
|
|
238
|
-
size="lg"
|
|
239
|
-
variant="accent-secondary"
|
|
240
|
-
fullWidth
|
|
241
|
-
>
|
|
242
|
-
Fund Wallet
|
|
243
|
-
</wui-button>
|
|
244
|
-
|
|
245
|
-
<wui-separator data-testid="wui-separator" text="or"></wui-separator>
|
|
246
|
-
|
|
247
|
-
<wui-button
|
|
248
|
-
@click=${this.onConnectDifferentWalletClick.bind(this)}
|
|
249
|
-
size="lg"
|
|
250
|
-
variant="neutral-secondary"
|
|
251
|
-
fullWidth
|
|
252
|
-
?loading=${this.disconnecting}
|
|
253
|
-
>
|
|
254
|
-
Connect a different wallet
|
|
255
|
-
</wui-button>
|
|
256
|
-
</wui-flex>
|
|
257
|
-
`:c`<wui-flex .margin=${["4","0","0","0"]}>
|
|
258
|
-
<wui-button
|
|
259
|
-
@click=${this.onButtonClick.bind(this)}
|
|
260
|
-
?disabled=${t}
|
|
261
|
-
size="lg"
|
|
262
|
-
variant="accent-primary"
|
|
263
|
-
?loading=${this.loading}
|
|
264
|
-
fullWidth
|
|
265
|
-
>
|
|
266
|
-
${this.message}
|
|
267
|
-
</wui-button>
|
|
268
|
-
</wui-flex>`}async handleSendParameters(){if(this.loading=!0,!this.params){this.loading=!1;return}const t=Number(this.params.amount);if(isNaN(t)){y.showError("Invalid amount"),this.loading=!1;return}const{namespace:i,chainId:r,assetAddress:o}=this.params;if(!Q.SEND_PARAMS_SUPPORTED_CHAINS.includes(i)){y.showError(`Chain "${i}" is not supported for send parameters`),this.loading=!1;return}const n=g.getCaipNetworkById(r,i);if(!n){y.showError(`Network with id "${r}" not found`),this.loading=!1;return}try{const{balance:s,name:a,symbol:W,decimals:V}=await X.fetchERC20Balance({caipAddress:this.caipAddress,assetAddress:o,caipNetwork:n});if(!a||!W||!V||!s){y.showError("Token not found");return}l.setToken({name:a,symbol:W,chainId:n.id.toString(),address:`${n.chainNamespace}:${n.id}:${o}`,value:0,price:0,quantity:{decimals:V.toString(),numeric:s.toString()},iconUrl:K.getTokenImage(W)??""}),l.setTokenAmount(t),l.setReceiverAddress(this.params.to)}catch(s){console.error("Failed to load token information:",s),y.showError("Failed to load token information")}finally{this.loading=!1}}};f.styles=ne;w([u()],f.prototype,"token",void 0);w([u()],f.prototype,"sendTokenAmount",void 0);w([u()],f.prototype,"receiverAddress",void 0);w([u()],f.prototype,"receiverProfileName",void 0);w([u()],f.prototype,"loading",void 0);w([u()],f.prototype,"params",void 0);w([u()],f.prototype,"caipAddress",void 0);w([u()],f.prototype,"message",void 0);w([u()],f.prototype,"disconnecting",void 0);f=w([b("w3m-wallet-send-view")],f);const re=x`
|
|
269
|
-
.contentContainer {
|
|
270
|
-
height: 440px;
|
|
271
|
-
overflow: scroll;
|
|
272
|
-
scrollbar-width: none;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.contentContainer::-webkit-scrollbar {
|
|
276
|
-
display: none;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
wui-icon-box {
|
|
280
|
-
width: 40px;
|
|
281
|
-
height: 40px;
|
|
282
|
-
border-radius: ${({borderRadius:e})=>e[3]};
|
|
283
|
-
}
|
|
284
|
-
`;var I=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let C=class extends v{constructor(){super(),this.unsubscribe=[],this.tokenBalances=l.state.tokenBalances,this.search="",this.onDebouncedSearch=D.debounce(t=>{this.search=t}),this.fetchBalancesAndNetworkPrice(),this.unsubscribe.push(l.subscribe(t=>{this.tokenBalances=t.tokenBalances}))}disconnectedCallback(){this.unsubscribe.forEach(t=>t())}render(){return c`
|
|
285
|
-
<wui-flex flexDirection="column">
|
|
286
|
-
${this.templateSearchInput()} <wui-separator></wui-separator> ${this.templateTokens()}
|
|
287
|
-
</wui-flex>
|
|
288
|
-
`}async fetchBalancesAndNetworkPrice(){var t;(!this.tokenBalances||((t=this.tokenBalances)==null?void 0:t.length)===0)&&(await this.fetchBalances(),await this.fetchNetworkPrice())}async fetchBalances(){await l.fetchTokenBalance(),l.fetchNetworkBalance()}async fetchNetworkPrice(){await G.getNetworkTokenPrice()}templateSearchInput(){return c`
|
|
289
|
-
<wui-flex gap="2" padding="3">
|
|
290
|
-
<wui-input-text
|
|
291
|
-
@inputChange=${this.onInputChange.bind(this)}
|
|
292
|
-
class="network-search-input"
|
|
293
|
-
size="sm"
|
|
294
|
-
placeholder="Search token"
|
|
295
|
-
icon="search"
|
|
296
|
-
></wui-input-text>
|
|
297
|
-
</wui-flex>
|
|
298
|
-
`}templateTokens(){var t,i;return this.tokens=(t=this.tokenBalances)==null?void 0:t.filter(r=>{var o;return r.chainId===((o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)}),this.search?this.filteredTokens=(i=this.tokenBalances)==null?void 0:i.filter(r=>r.name.toLowerCase().includes(this.search.toLowerCase())):this.filteredTokens=this.tokens,c`
|
|
299
|
-
<wui-flex
|
|
300
|
-
class="contentContainer"
|
|
301
|
-
flexDirection="column"
|
|
302
|
-
.padding=${["0","3","0","3"]}
|
|
303
|
-
>
|
|
304
|
-
<wui-flex justifyContent="flex-start" .padding=${["4","3","3","3"]}>
|
|
305
|
-
<wui-text variant="md-medium" color="secondary">Your tokens</wui-text>
|
|
306
|
-
</wui-flex>
|
|
307
|
-
<wui-flex flexDirection="column" gap="2">
|
|
308
|
-
${this.filteredTokens&&this.filteredTokens.length>0?this.filteredTokens.map(r=>c`<wui-list-token
|
|
309
|
-
@click=${this.handleTokenClick.bind(this,r)}
|
|
310
|
-
?clickable=${!0}
|
|
311
|
-
tokenName=${r.name}
|
|
312
|
-
tokenImageUrl=${r.iconUrl}
|
|
313
|
-
tokenAmount=${r.quantity.numeric}
|
|
314
|
-
tokenValue=${r.value}
|
|
315
|
-
tokenCurrency=${r.symbol}
|
|
316
|
-
></wui-list-token>`):c`<wui-flex
|
|
317
|
-
.padding=${["20","0","0","0"]}
|
|
318
|
-
alignItems="center"
|
|
319
|
-
flexDirection="column"
|
|
320
|
-
gap="4"
|
|
321
|
-
>
|
|
322
|
-
<wui-icon-box icon="coinPlaceholder" color="default" size="lg"></wui-icon-box>
|
|
323
|
-
<wui-flex
|
|
324
|
-
class="textContent"
|
|
325
|
-
gap="2"
|
|
326
|
-
flexDirection="column"
|
|
327
|
-
justifyContent="center"
|
|
328
|
-
flexDirection="column"
|
|
329
|
-
>
|
|
330
|
-
<wui-text variant="lg-medium" align="center" color="primary">
|
|
331
|
-
No tokens found
|
|
332
|
-
</wui-text>
|
|
333
|
-
<wui-text variant="lg-regular" align="center" color="secondary">
|
|
334
|
-
Your tokens will appear here
|
|
335
|
-
</wui-text>
|
|
336
|
-
</wui-flex>
|
|
337
|
-
<wui-link @click=${this.onBuyClick.bind(this)}>Buy</wui-link>
|
|
338
|
-
</wui-flex>`}
|
|
339
|
-
</wui-flex>
|
|
340
|
-
</wui-flex>
|
|
341
|
-
`}onBuyClick(){h.push("OnRampProviders")}onInputChange(t){this.onDebouncedSearch(t.detail)}handleTokenClick(t){l.setToken(t),l.setTokenAmount(void 0),h.goBack()}};C.styles=re;I([u()],C.prototype,"tokenBalances",void 0);I([u()],C.prototype,"tokens",void 0);I([u()],C.prototype,"filteredTokens",void 0);I([u()],C.prototype,"search",void 0);C=I([b("w3m-wallet-send-select-token-view")],C);const oe=x`
|
|
342
|
-
:host {
|
|
343
|
-
height: 32px;
|
|
344
|
-
display: flex;
|
|
345
|
-
align-items: center;
|
|
346
|
-
gap: ${({spacing:e})=>e[1]};
|
|
347
|
-
border-radius: ${({borderRadius:e})=>e[32]};
|
|
348
|
-
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
349
|
-
padding: ${({spacing:e})=>e[1]};
|
|
350
|
-
padding-left: ${({spacing:e})=>e[2]};
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
wui-avatar,
|
|
354
|
-
wui-image {
|
|
355
|
-
width: 24px;
|
|
356
|
-
height: 24px;
|
|
357
|
-
border-radius: ${({borderRadius:e})=>e[16]};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
wui-icon {
|
|
361
|
-
border-radius: ${({borderRadius:e})=>e[16]};
|
|
362
|
-
}
|
|
363
|
-
`;var _=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let T=class extends v{constructor(){super(...arguments),this.text=""}render(){return c`<wui-text variant="lg-regular" color="primary">${this.text}</wui-text>
|
|
364
|
-
${this.imageTemplate()}`}imageTemplate(){return this.address?c`<wui-avatar address=${this.address} .imageSrc=${this.imageSrc}></wui-avatar>`:this.imageSrc?c`<wui-image src=${this.imageSrc}></wui-image>`:c`<wui-icon size="lg" color="inverse" name="networkPlaceholder"></wui-icon>`}};T.styles=[Y,J,oe];_([d({type:String})],T.prototype,"text",void 0);_([d({type:String})],T.prototype,"address",void 0);_([d({type:String})],T.prototype,"imageSrc",void 0);T=_([b("wui-preview-item")],T);const se=x`
|
|
365
|
-
:host {
|
|
366
|
-
display: flex;
|
|
367
|
-
padding: ${({spacing:e})=>e[4]} ${({spacing:e})=>e[3]};
|
|
368
|
-
width: 100%;
|
|
369
|
-
background-color: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
370
|
-
border-radius: ${({borderRadius:e})=>e[4]};
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
wui-image {
|
|
374
|
-
width: 20px;
|
|
375
|
-
height: 20px;
|
|
376
|
-
border-radius: ${({borderRadius:e})=>e[16]};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
wui-icon {
|
|
380
|
-
width: 20px;
|
|
381
|
-
height: 20px;
|
|
382
|
-
}
|
|
383
|
-
`;var O=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let S=class extends v{constructor(){super(...arguments),this.imageSrc=void 0,this.textTitle="",this.textValue=void 0}render(){return c`
|
|
384
|
-
<wui-flex justifyContent="space-between" alignItems="center">
|
|
385
|
-
<wui-text variant="lg-regular" color="primary"> ${this.textTitle} </wui-text>
|
|
386
|
-
${this.templateContent()}
|
|
387
|
-
</wui-flex>
|
|
388
|
-
`}templateContent(){return this.imageSrc?c`<wui-image src=${this.imageSrc} alt=${this.textTitle}></wui-image>`:this.textValue?c` <wui-text variant="md-regular" color="secondary"> ${this.textValue} </wui-text>`:c`<wui-icon size="inherit" color="default" name="networkPlaceholder"></wui-icon>`}};S.styles=[Y,J,se];O([d()],S.prototype,"imageSrc",void 0);O([d()],S.prototype,"textTitle",void 0);O([d()],S.prototype,"textValue",void 0);S=O([b("wui-list-content")],S);const ae=x`
|
|
389
|
-
:host {
|
|
390
|
-
display: flex;
|
|
391
|
-
width: auto;
|
|
392
|
-
flex-direction: column;
|
|
393
|
-
gap: ${({spacing:e})=>e[1]};
|
|
394
|
-
border-radius: ${({borderRadius:e})=>e[5]};
|
|
395
|
-
background: ${({tokens:e})=>e.theme.foregroundPrimary};
|
|
396
|
-
padding: ${({spacing:e})=>e[3]} ${({spacing:e})=>e[2]}
|
|
397
|
-
${({spacing:e})=>e[2]} ${({spacing:e})=>e[2]};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
wui-list-content {
|
|
401
|
-
width: -webkit-fill-available !important;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
wui-text {
|
|
405
|
-
padding: 0 ${({spacing:e})=>e[2]};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
wui-flex {
|
|
409
|
-
margin-top: ${({spacing:e})=>e[2]};
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
.network {
|
|
413
|
-
cursor: pointer;
|
|
414
|
-
transition: background-color ${({durations:e})=>e.lg}
|
|
415
|
-
${({easings:e})=>e["ease-out-power-1"]};
|
|
416
|
-
will-change: background-color;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
.network:focus-visible {
|
|
420
|
-
border: 1px solid ${({tokens:e})=>e.core.textAccentPrimary};
|
|
421
|
-
background-color: ${({tokens:e})=>e.core.glass010};
|
|
422
|
-
-webkit-box-shadow: 0px 0px 0px 4px ${({tokens:e})=>e.core.foregroundAccent010};
|
|
423
|
-
-moz-box-shadow: 0px 0px 0px 4px ${({tokens:e})=>e.core.foregroundAccent010};
|
|
424
|
-
box-shadow: 0px 0px 0px 4px ${({tokens:e})=>e.core.foregroundAccent010};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.network:hover {
|
|
428
|
-
background-color: ${({tokens:e})=>e.core.glass010};
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.network:active {
|
|
432
|
-
background-color: ${({tokens:e})=>e.core.glass010};
|
|
433
|
-
}
|
|
434
|
-
`;var B=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let N=class extends v{constructor(){var t;super(...arguments),this.params=(t=h.state.data)==null?void 0:t.send}render(){return c` <wui-text variant="sm-regular" color="secondary">Details</wui-text>
|
|
435
|
-
<wui-flex flexDirection="column" gap="1">
|
|
436
|
-
<wui-list-content
|
|
437
|
-
textTitle="Address"
|
|
438
|
-
textValue=${R.getTruncateString({string:this.receiverAddress??"",charsStart:4,charsEnd:4,truncate:"middle"})}
|
|
439
|
-
>
|
|
440
|
-
</wui-list-content>
|
|
441
|
-
${this.networkTemplate()}
|
|
442
|
-
</wui-flex>`}networkTemplate(){var t;return(t=this.caipNetwork)!=null&&t.name?c` <wui-list-content
|
|
443
|
-
@click=${()=>this.onNetworkClick(this.caipNetwork)}
|
|
444
|
-
class="network"
|
|
445
|
-
textTitle="Network"
|
|
446
|
-
imageSrc=${Z(K.getNetworkImage(this.caipNetwork))}
|
|
447
|
-
></wui-list-content>`:null}onNetworkClick(t){t&&!this.params&&h.push("Networks",{network:t})}};N.styles=ae;B([d()],N.prototype,"receiverAddress",void 0);B([d({type:Object})],N.prototype,"caipNetwork",void 0);B([u()],N.prototype,"params",void 0);N=B([b("w3m-wallet-send-details")],N);const le=x`
|
|
448
|
-
wui-avatar,
|
|
449
|
-
wui-image {
|
|
450
|
-
display: ruby;
|
|
451
|
-
width: 32px;
|
|
452
|
-
height: 32px;
|
|
453
|
-
border-radius: ${({borderRadius:e})=>e[20]};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
.sendButton {
|
|
457
|
-
width: 70%;
|
|
458
|
-
--local-width: 100% !important;
|
|
459
|
-
--local-border-radius: ${({borderRadius:e})=>e[4]} !important;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
.cancelButton {
|
|
463
|
-
width: 30%;
|
|
464
|
-
--local-width: 100% !important;
|
|
465
|
-
--local-border-radius: ${({borderRadius:e})=>e[4]} !important;
|
|
466
|
-
}
|
|
467
|
-
`;var k=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let m=class extends v{constructor(){var t;super(),this.unsubscribe=[],this.token=l.state.token,this.sendTokenAmount=l.state.sendTokenAmount,this.receiverAddress=l.state.receiverAddress,this.receiverProfileName=l.state.receiverProfileName,this.receiverProfileImageUrl=l.state.receiverProfileImageUrl,this.caipNetwork=g.state.activeCaipNetwork,this.loading=l.state.loading,this.params=(t=h.state.data)==null?void 0:t.send,this.unsubscribe.push(l.subscribe(i=>{this.token=i.token,this.sendTokenAmount=i.sendTokenAmount,this.receiverAddress=i.receiverAddress,this.receiverProfileName=i.receiverProfileName,this.receiverProfileImageUrl=i.receiverProfileImageUrl,this.loading=i.loading}),g.subscribeKey("activeCaipNetwork",i=>this.caipNetwork=i))}disconnectedCallback(){this.unsubscribe.forEach(t=>t())}render(){var t,i;return c` <wui-flex flexDirection="column" .padding=${["0","4","4","4"]}>
|
|
468
|
-
<wui-flex gap="2" flexDirection="column" .padding=${["0","2","0","2"]}>
|
|
469
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
470
|
-
<wui-flex flexDirection="column" gap="01">
|
|
471
|
-
<wui-text variant="sm-regular" color="secondary">Send</wui-text>
|
|
472
|
-
${this.sendValueTemplate()}
|
|
473
|
-
</wui-flex>
|
|
474
|
-
<wui-preview-item
|
|
475
|
-
text="${this.sendTokenAmount?R.roundNumber(this.sendTokenAmount,6,5):"unknown"} ${(t=this.token)==null?void 0:t.symbol}"
|
|
476
|
-
.imageSrc=${(i=this.token)==null?void 0:i.iconUrl}
|
|
477
|
-
></wui-preview-item>
|
|
478
|
-
</wui-flex>
|
|
479
|
-
<wui-flex>
|
|
480
|
-
<wui-icon color="default" size="md" name="arrowBottom"></wui-icon>
|
|
481
|
-
</wui-flex>
|
|
482
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
483
|
-
<wui-text variant="sm-regular" color="secondary">To</wui-text>
|
|
484
|
-
<wui-preview-item
|
|
485
|
-
text="${this.receiverProfileName?R.getTruncateString({string:this.receiverProfileName,charsStart:20,charsEnd:0,truncate:"end"}):R.getTruncateString({string:this.receiverAddress?this.receiverAddress:"",charsStart:4,charsEnd:4,truncate:"middle"})}"
|
|
486
|
-
address=${this.receiverAddress??""}
|
|
487
|
-
.imageSrc=${this.receiverProfileImageUrl??void 0}
|
|
488
|
-
.isAddress=${!0}
|
|
489
|
-
></wui-preview-item>
|
|
490
|
-
</wui-flex>
|
|
491
|
-
</wui-flex>
|
|
492
|
-
<wui-flex flexDirection="column" .padding=${["6","0","0","0"]}>
|
|
493
|
-
<w3m-wallet-send-details
|
|
494
|
-
.caipNetwork=${this.caipNetwork}
|
|
495
|
-
.receiverAddress=${this.receiverAddress}
|
|
496
|
-
></w3m-wallet-send-details>
|
|
497
|
-
<wui-flex justifyContent="center" gap="1" .padding=${["3","0","0","0"]}>
|
|
498
|
-
<wui-icon size="sm" color="default" name="warningCircle"></wui-icon>
|
|
499
|
-
<wui-text variant="sm-regular" color="secondary">Review transaction carefully</wui-text>
|
|
500
|
-
</wui-flex>
|
|
501
|
-
<wui-flex justifyContent="center" gap="3" .padding=${["4","0","0","0"]}>
|
|
502
|
-
<wui-button
|
|
503
|
-
class="cancelButton"
|
|
504
|
-
@click=${this.onCancelClick.bind(this)}
|
|
505
|
-
size="lg"
|
|
506
|
-
variant="neutral-secondary"
|
|
507
|
-
>
|
|
508
|
-
Cancel
|
|
509
|
-
</wui-button>
|
|
510
|
-
<wui-button
|
|
511
|
-
class="sendButton"
|
|
512
|
-
@click=${this.onSendClick.bind(this)}
|
|
513
|
-
size="lg"
|
|
514
|
-
variant="accent-primary"
|
|
515
|
-
.loading=${this.loading}
|
|
516
|
-
>
|
|
517
|
-
Send
|
|
518
|
-
</wui-button>
|
|
519
|
-
</wui-flex>
|
|
520
|
-
</wui-flex></wui-flex
|
|
521
|
-
>`}sendValueTemplate(){if(!this.params&&this.token&&this.sendTokenAmount){const i=this.token.price*this.sendTokenAmount;return c`<wui-text variant="md-regular" color="primary"
|
|
522
|
-
>$${i.toFixed(2)}</wui-text
|
|
523
|
-
>`}return null}async onSendClick(){if(!this.sendTokenAmount||!this.receiverAddress){y.showError("Please enter a valid amount and receiver address");return}try{await l.sendToken(),this.params?h.reset("WalletSendConfirmed"):(y.showSuccess("Transaction started"),h.replace("Account"))}catch(t){let i="Failed to send transaction";const r=t instanceof L&&t.originalName===M.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST,o=t instanceof L&&t.originalName===M.PROVIDER_RPC_ERROR_NAME.SEND_TRANSACTION_ERROR;(r||o)&&(i=t.message),ee.sendEvent({type:"track",event:r?"SEND_REJECTED":"SEND_ERROR",properties:l.getSdkEventProperties(t)}),y.showError(i)}}onCancelClick(){h.goBack()}};m.styles=le;k([u()],m.prototype,"token",void 0);k([u()],m.prototype,"sendTokenAmount",void 0);k([u()],m.prototype,"receiverAddress",void 0);k([u()],m.prototype,"receiverProfileName",void 0);k([u()],m.prototype,"receiverProfileImageUrl",void 0);k([u()],m.prototype,"caipNetwork",void 0);k([u()],m.prototype,"loading",void 0);k([u()],m.prototype,"params",void 0);m=k([b("w3m-wallet-send-preview-view")],m);const ce=x`
|
|
524
|
-
.icon-box {
|
|
525
|
-
width: 64px;
|
|
526
|
-
height: 64px;
|
|
527
|
-
border-radius: 16px;
|
|
528
|
-
background-color: ${({spacing:e})=>e[16]};
|
|
529
|
-
border: 8px solid ${({tokens:e})=>e.theme.borderPrimary};
|
|
530
|
-
border-radius: ${({borderRadius:e})=>e.round};
|
|
531
|
-
}
|
|
532
|
-
`;var ue=function(e,t,i,r){var o=arguments.length,n=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,i):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let U=class extends v{constructor(){super(),this.unsubscribe=[],this.unsubscribe.push()}render(){return c`
|
|
533
|
-
<wui-flex
|
|
534
|
-
flexDirection="column"
|
|
535
|
-
alignItems="center"
|
|
536
|
-
gap="4"
|
|
537
|
-
.padding="${["1","3","4","3"]}"
|
|
538
|
-
>
|
|
539
|
-
<wui-flex justifyContent="center" alignItems="center" class="icon-box">
|
|
540
|
-
<wui-icon size="xxl" color="success" name="checkmark"></wui-icon>
|
|
541
|
-
</wui-flex>
|
|
542
|
-
|
|
543
|
-
<wui-text variant="h6-medium" color="primary">You successfully sent asset</wui-text>
|
|
544
|
-
|
|
545
|
-
<wui-button
|
|
546
|
-
fullWidth
|
|
547
|
-
@click=${this.onCloseClick.bind(this)}
|
|
548
|
-
size="lg"
|
|
549
|
-
variant="neutral-secondary"
|
|
550
|
-
>
|
|
551
|
-
Close
|
|
552
|
-
</wui-button>
|
|
553
|
-
</wui-flex>
|
|
554
|
-
`}onCloseClick(){q.close()}};U.styles=ce;U=ue([b("w3m-send-confirmed-view")],U);export{U as W3mSendConfirmedView,C as W3mSendSelectTokenView,m as W3mWalletSendPreviewView,f as W3mWalletSendView};
|