@shapeshiftoss/swap-widget 0.0.2 → 0.2.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/LICENSE.md +21 -0
- package/README.md +18 -11
- package/package.json +77 -28
- 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,1080 +0,0 @@
|
|
|
1
|
-
import{y as G,z as ot,D as wt,F as P,G as F,I as W,aG as At,J as d,h as $,aB as We,k as w,u as R,aS as xt,C as q,aT as bt,a6 as I,n as z,aU as Et,af as Le,N as S,aV as je,a1 as D,E as oe,S as H,q as It,as as ue,R as ce,a4 as f,L as _t,U as Nt,O as vt,aM as He}from"./index-5jd8RPN9.js";/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const le=globalThis,fe=le.trustedTypes,ze=fe?fe.createPolicy("lit-html",{createHTML:t=>t}):void 0,at="$lit$",Q=`lit$${Math.random().toFixed(9).slice(2)}$`,ct="?"+Q,Tt=`<${ct}>`,ee=document,ge=()=>ee.createComment(""),de=t=>t===null||typeof t!="object"&&typeof t!="function",De=Array.isArray,$t=t=>De(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ne=`[
|
|
6
|
-
\f\r]`,ae=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ge=/-->/g,Ve=/>/g,J=RegExp(`>|${Ne}(?:([^\\s"'>=/]+)(${Ne}*=${Ne}*(?:[^
|
|
7
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Qe=/'/g,Ye=/"/g,lt=/^(?:script|style|textarea|title)$/i,ne=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Ke=new WeakMap,Z=ee.createTreeWalker(ee,129);function ut(t,e){if(!De(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return ze!==void 0?ze.createHTML(e):e}const Pt=(t,e)=>{const n=t.length-1,s=[];let i,r=e===2?"<svg>":e===3?"<math>":"",o=ae;for(let c=0;c<n;c++){const l=t[c];let m,y,g=-1,v=0;for(;v<l.length&&(o.lastIndex=v,y=o.exec(l),y!==null);)v=o.lastIndex,o===ae?y[1]==="!--"?o=Ge:y[1]!==void 0?o=Ve:y[2]!==void 0?(lt.test(y[2])&&(i=RegExp("</"+y[2],"g")),o=J):y[3]!==void 0&&(o=J):o===J?y[0]===">"?(o=i??ae,g=-1):y[1]===void 0?g=-2:(g=o.lastIndex-y[2].length,m=y[1],o=y[3]===void 0?J:y[3]==='"'?Ye:Qe):o===Ye||o===Qe?o=J:o===Ge||o===Ve?o=ae:(o=J,i=void 0);const C=o===J&&t[c+1].startsWith("/>")?" ":"";r+=o===ae?l+Tt:g>=0?(s.push(m),l.slice(0,g)+at+l.slice(g)+Q+C):l+Q+(g===-2?c:C)}return[ut(t,r+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};class pe{constructor({strings:e,_$litType$:n},s){let i;this.parts=[];let r=0,o=0;const c=e.length-1,l=this.parts,[m,y]=Pt(e,n);if(this.el=pe.createElement(m,s),Z.currentNode=this.el.content,n===2||n===3){const g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(i=Z.nextNode())!==null&&l.length<c;){if(i.nodeType===1){if(i.hasAttributes())for(const g of i.getAttributeNames())if(g.endsWith(at)){const v=y[o++],C=i.getAttribute(g).split(Q),k=/([.?@])?(.*)/.exec(v);l.push({type:1,index:r,name:k[2],strings:C,ctor:k[1]==="."?Ct:k[1]==="?"?kt:k[1]==="@"?Rt:Ie}),i.removeAttribute(g)}else g.startsWith(Q)&&(l.push({type:6,index:r}),i.removeAttribute(g));if(lt.test(i.tagName)){const g=i.textContent.split(Q),v=g.length-1;if(v>0){i.textContent=fe?fe.emptyScript:"";for(let C=0;C<v;C++)i.append(g[C],ge()),Z.nextNode(),l.push({type:2,index:++r});i.append(g[v],ge())}}}else if(i.nodeType===8)if(i.data===ct)l.push({type:2,index:r});else{let g=-1;for(;(g=i.data.indexOf(Q,g+1))!==-1;)l.push({type:7,index:r}),g+=Q.length-1}r++}}static createElement(e,n){const s=ee.createElement("template");return s.innerHTML=e,s}}function se(t,e,n=t,s){var o,c;if(e===ne)return e;let i=s!==void 0?(o=n._$Co)==null?void 0:o[s]:n._$Cl;const r=de(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((c=i==null?void 0:i._$AO)==null||c.call(i,!1),r===void 0?i=void 0:(i=new r(t),i._$AT(t,n,s)),s!==void 0?(n._$Co??(n._$Co=[]))[s]=i:n._$Cl=i),i!==void 0&&(e=se(t,i._$AS(t,e.values),i,s)),e}class St{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:s}=this._$AD,i=((e==null?void 0:e.creationScope)??ee).importNode(n,!0);Z.currentNode=i;let r=Z.nextNode(),o=0,c=0,l=s[0];for(;l!==void 0;){if(o===l.index){let m;l.type===2?m=new Ee(r,r.nextSibling,this,e):l.type===1?m=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(m=new Ot(r,this,e)),this._$AV.push(m),l=s[++c]}o!==(l==null?void 0:l.index)&&(r=Z.nextNode(),o++)}return Z.currentNode=ee,i}p(e){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,n),n+=s.strings.length-2):s._$AI(e[n])),n++}}class Ee{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,s,i){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=se(this,e,n),de(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==ne&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):$t(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&de(this._$AH)?this._$AA.nextSibling.data=e:this.T(ee.createTextNode(e)),this._$AH=e}$(e){var r;const{values:n,_$litType$:s}=e,i=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=pe.createElement(ut(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(n);else{const o=new St(i,this),c=o.u(this.options);o.p(n),this.T(c),this._$AH=o}}_$AC(e){let n=Ke.get(e.strings);return n===void 0&&Ke.set(e.strings,n=new pe(e)),n}k(e){De(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const r of e)i===n.length?n.push(s=new Ee(this.O(ge()),this.O(ge()),this,this.options)):s=n[i],s._$AI(r),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,n);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}}class Ie{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,s,i,r){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=_}_$AI(e,n=this,s,i){const r=this.strings;let o=!1;if(r===void 0)e=se(this,e,n,0),o=!de(e)||e!==this._$AH&&e!==ne,o&&(this._$AH=e);else{const c=e;let l,m;for(e=r[0],l=0;l<r.length-1;l++)m=se(this,c[s+l],n,l),m===ne&&(m=this._$AH[l]),o||(o=!de(m)||m!==this._$AH[l]),m===_?e=_:e!==_&&(e+=(m??"")+r[l+1]),this._$AH[l]=m}o&&!i&&this.j(e)}j(e){e===_?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Ct extends Ie{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_?void 0:e}}class kt extends Ie{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_)}}class Rt extends Ie{constructor(e,n,s,i,r){super(e,n,s,i,r),this.type=5}_$AI(e,n=this){if((e=se(this,e,n,0)??_)===ne)return;const s=this._$AH,i=e===_&&s!==_||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==_&&(s===_||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}}class Ot{constructor(e,n,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){se(this,e)}}const ve=le.litHtmlPolyfillSupport;ve==null||ve(pe,Ee),(le.litHtmlVersions??(le.litHtmlVersions=[])).push("3.3.0");/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2018 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/const b=t=>t??_,Ut=G`
|
|
12
|
-
:host {
|
|
13
|
-
position: relative;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
button {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
align-items: center;
|
|
20
|
-
background-color: transparent;
|
|
21
|
-
padding: ${({spacing:t})=>t[1]};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* -- Colors --------------------------------------------------- */
|
|
25
|
-
button[data-type='accent'] wui-icon {
|
|
26
|
-
color: ${({tokens:t})=>t.core.iconAccentPrimary};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
button[data-type='neutral'][data-variant='primary'] wui-icon {
|
|
30
|
-
color: ${({tokens:t})=>t.theme.iconInverse};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
button[data-type='neutral'][data-variant='secondary'] wui-icon {
|
|
34
|
-
color: ${({tokens:t})=>t.theme.iconDefault};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
button[data-type='success'] wui-icon {
|
|
38
|
-
color: ${({tokens:t})=>t.core.iconSuccess};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
button[data-type='error'] wui-icon {
|
|
42
|
-
color: ${({tokens:t})=>t.core.iconError};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* -- Sizes --------------------------------------------------- */
|
|
46
|
-
button[data-size='xs'] {
|
|
47
|
-
width: 16px;
|
|
48
|
-
height: 16px;
|
|
49
|
-
|
|
50
|
-
border-radius: ${({borderRadius:t})=>t[1]};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
button[data-size='sm'] {
|
|
54
|
-
width: 20px;
|
|
55
|
-
height: 20px;
|
|
56
|
-
border-radius: ${({borderRadius:t})=>t[1]};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
button[data-size='md'] {
|
|
60
|
-
width: 24px;
|
|
61
|
-
height: 24px;
|
|
62
|
-
border-radius: ${({borderRadius:t})=>t[2]};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
button[data-size='lg'] {
|
|
66
|
-
width: 28px;
|
|
67
|
-
height: 28px;
|
|
68
|
-
border-radius: ${({borderRadius:t})=>t[2]};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
button[data-size='xs'] wui-icon {
|
|
72
|
-
width: 8px;
|
|
73
|
-
height: 8px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
button[data-size='sm'] wui-icon {
|
|
77
|
-
width: 12px;
|
|
78
|
-
height: 12px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
button[data-size='md'] wui-icon {
|
|
82
|
-
width: 16px;
|
|
83
|
-
height: 16px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
button[data-size='lg'] wui-icon {
|
|
87
|
-
width: 20px;
|
|
88
|
-
height: 20px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/* -- Hover --------------------------------------------------- */
|
|
92
|
-
@media (hover: hover) {
|
|
93
|
-
button[data-type='accent']:hover:enabled {
|
|
94
|
-
background-color: ${({tokens:t})=>t.core.foregroundAccent010};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
button[data-variant='primary'][data-type='neutral']:hover:enabled {
|
|
98
|
-
background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
button[data-variant='secondary'][data-type='neutral']:hover:enabled {
|
|
102
|
-
background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
button[data-type='success']:hover:enabled {
|
|
106
|
-
background-color: ${({tokens:t})=>t.core.backgroundSuccess};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
button[data-type='error']:hover:enabled {
|
|
110
|
-
background-color: ${({tokens:t})=>t.core.backgroundError};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* -- Focus --------------------------------------------------- */
|
|
115
|
-
button:focus-visible {
|
|
116
|
-
box-shadow: 0 0 0 4px ${({tokens:t})=>t.core.foregroundAccent020};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* -- Properties --------------------------------------------------- */
|
|
120
|
-
button[data-full-width='true'] {
|
|
121
|
-
width: 100%;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
:host([fullWidth]) {
|
|
125
|
-
width: 100%;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
button[disabled] {
|
|
129
|
-
opacity: 0.5;
|
|
130
|
-
cursor: not-allowed;
|
|
131
|
-
}
|
|
132
|
-
`;var K=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let M=class extends W{constructor(){super(...arguments),this.icon="card",this.variant="primary",this.type="accent",this.size="md",this.iconSize=void 0,this.fullWidth=!1,this.disabled=!1}render(){return d`<button
|
|
133
|
-
data-variant=${this.variant}
|
|
134
|
-
data-type=${this.type}
|
|
135
|
-
data-size=${this.size}
|
|
136
|
-
data-full-width=${this.fullWidth}
|
|
137
|
-
?disabled=${this.disabled}
|
|
138
|
-
>
|
|
139
|
-
<wui-icon color="inherit" name=${this.icon} size=${At(this.iconSize)}></wui-icon>
|
|
140
|
-
</button>`}};M.styles=[ot,wt,Ut];K([P()],M.prototype,"icon",void 0);K([P()],M.prototype,"variant",void 0);K([P()],M.prototype,"type",void 0);K([P()],M.prototype,"size",void 0);K([P()],M.prototype,"iconSize",void 0);K([P({type:Boolean})],M.prototype,"fullWidth",void 0);K([P({type:Boolean})],M.prototype,"disabled",void 0);M=K([F("wui-icon-button")],M);const Lt=Symbol(),Xe=Object.getPrototypeOf,Je=new WeakMap,Dt=t=>t&&(Je.has(t)?Je.get(t):Xe(t)===Object.prototype||Xe(t)===Array.prototype),qt=t=>Dt(t)&&t[Lt]||null,Ce={},qe=t=>typeof t=="object"&&t!==null,Mt=t=>qe(t)&&!dt.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),Bt=(t,e,n,s)=>({deleteProperty(i,r){const o=Reflect.get(i,r);n(r);const c=Reflect.deleteProperty(i,r);return c&&s(["delete",[r],o]),c},set(i,r,o,c){const l=!t()&&Reflect.has(i,r),m=Reflect.get(i,r,c);if(l&&(Ze(m,o)||we.has(o)&&Ze(m,we.get(o))))return!0;n(r),qe(o)&&(o=qt(o)||o);const y=!ye.has(o)&&Wt(o)?pt(o):o;return e(r,y),Reflect.set(i,r,y,c),s(["set",[r],o,m]),!0}}),ye=new WeakMap,dt=new WeakSet,Te=[1],we=new WeakMap;let Ze=Object.is,Ft=(t,e)=>new Proxy(t,e),Wt=Mt,jt=Bt;function pt(t={}){if(!qe(t))throw new Error("object required");const e=we.get(t);if(e)return e;let n=Te[0];const s=new Set,i=(A,T=++Te[0])=>{n!==T&&(r=n=T,s.forEach(x=>x(A,T)))};let r=n;const o=(A=Te[0])=>(r!==A&&(r=A,l.forEach(([T])=>{const x=T[1](A);x>n&&(n=x)})),n),c=A=>(T,x)=>{const L=[...T];L[1]=[A,...L[1]],i(L,x)},l=new Map,m=(A,T)=>{const x=!dt.has(T)&&ye.get(T);if(x){if((Ce?"production":void 0)!=="production"&&l.has(A))throw new Error("prop listener already exists");if(s.size){const L=x[2](c(A));l.set(A,[x,L])}else l.set(A,[x])}},y=A=>{var T;const x=l.get(A);x&&(l.delete(A),(T=x[1])==null||T.call(x))},g=A=>(s.add(A),s.size===1&&l.forEach(([x,L],he)=>{if((Ce?"production":void 0)!=="production"&&L)throw new Error("remove already exists");const yt=x[2](c(he));l.set(he,[x,yt])}),()=>{s.delete(A),s.size===0&&l.forEach(([x,L],he)=>{L&&(L(),l.set(he,[x]))})});let v=!0;const C=jt(()=>v,m,y,i),k=Ft(t,C);we.set(t,k);const te=[t,o,g];return ye.set(k,te),Reflect.ownKeys(t).forEach(A=>{const T=Object.getOwnPropertyDescriptor(t,A);"value"in T&&T.writable&&(k[A]=t[A])}),v=!1,k}function ht(t,e,n){const s=ye.get(t);(Ce?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");let i;const r=[],o=s[2];let c=!1;const m=o(y=>{r.push(y),i||(i=Promise.resolve().then(()=>{i=void 0,c&&e(r.splice(0))}))});return c=!0,()=>{c=!1,m()}}function Ht(t,e,n,s){let i=t[e];return ht(t,()=>{const r=t[e];Object.is(i,r)||n(i=r)})}const zt={EIP155:$.CHAIN.EVM},O={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([n,s])=>{e[`${zt.EIP155}:${n}`]=s}),e},isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())},getActiveNamespaceConnectedToAuth(){const t=w.state.activeChain;return $.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>R.getConnectorId(e)===$.CONNECTOR_ID.AUTH&&e===t)},withRetry({conditionFn:t,intervalMs:e,maxRetries:n}){let s=0;return new Promise(i=>{async function r(){return s+=1,await t()?i(!0):s>=n?i(!1):(setTimeout(r,e),null)}r()})},userChainIdToChainNamespace(t){if(typeof t=="number")return $.CHAIN.EVM;const[e]=t.split(":");return e},getOtherAuthNamespaces(t){return t?$.AUTH_CONNECTOR_SUPPORTED_CHAINS.filter(s=>s!==t):[]},getConnectorStorageInfo(t,e){const s=We.getConnections()[e]??[];return{hasDisconnected:We.isConnectorDisconnected(t,e),hasConnected:s.some(i=>O.isLowerCaseMatch(i.connectorId,t))}}},p={INVALID_PAYMENT_CONFIG:"INVALID_PAYMENT_CONFIG",INVALID_RECIPIENT:"INVALID_RECIPIENT",INVALID_ASSET:"INVALID_ASSET",INVALID_AMOUNT:"INVALID_AMOUNT",UNKNOWN_ERROR:"UNKNOWN_ERROR",UNABLE_TO_INITIATE_PAYMENT:"UNABLE_TO_INITIATE_PAYMENT",INVALID_CHAIN_NAMESPACE:"INVALID_CHAIN_NAMESPACE",GENERIC_PAYMENT_ERROR:"GENERIC_PAYMENT_ERROR",UNABLE_TO_GET_EXCHANGES:"UNABLE_TO_GET_EXCHANGES",ASSET_NOT_SUPPORTED:"ASSET_NOT_SUPPORTED",UNABLE_TO_GET_PAY_URL:"UNABLE_TO_GET_PAY_URL",UNABLE_TO_GET_BUY_STATUS:"UNABLE_TO_GET_BUY_STATUS",UNABLE_TO_GET_TOKEN_BALANCES:"UNABLE_TO_GET_TOKEN_BALANCES",UNABLE_TO_GET_QUOTE:"UNABLE_TO_GET_QUOTE",UNABLE_TO_GET_QUOTE_STATUS:"UNABLE_TO_GET_QUOTE_STATUS",INVALID_RECIPIENT_ADDRESS_FOR_ASSET:"INVALID_RECIPIENT_ADDRESS_FOR_ASSET"},V={[p.INVALID_PAYMENT_CONFIG]:"Invalid payment configuration",[p.INVALID_RECIPIENT]:"Invalid recipient address",[p.INVALID_ASSET]:"Invalid asset specified",[p.INVALID_AMOUNT]:"Invalid payment amount",[p.INVALID_RECIPIENT_ADDRESS_FOR_ASSET]:"Invalid recipient address for the asset selected",[p.UNKNOWN_ERROR]:"Unknown payment error occurred",[p.UNABLE_TO_INITIATE_PAYMENT]:"Unable to initiate payment",[p.INVALID_CHAIN_NAMESPACE]:"Invalid chain namespace",[p.GENERIC_PAYMENT_ERROR]:"Unable to process payment",[p.UNABLE_TO_GET_EXCHANGES]:"Unable to get exchanges",[p.ASSET_NOT_SUPPORTED]:"Asset not supported by the selected exchange",[p.UNABLE_TO_GET_PAY_URL]:"Unable to get payment URL",[p.UNABLE_TO_GET_BUY_STATUS]:"Unable to get buy status",[p.UNABLE_TO_GET_TOKEN_BALANCES]:"Unable to get token balances",[p.UNABLE_TO_GET_QUOTE]:"Unable to get quote. Please choose a different token",[p.UNABLE_TO_GET_QUOTE_STATUS]:"Unable to get quote status"};class h extends Error{get message(){return V[this.code]}constructor(e,n){super(V[e]),this.name="AppKitPayError",this.code=e,this.details=n,Error.captureStackTrace&&Error.captureStackTrace(this,h)}}const Gt="https://rpc.walletconnect.org/v1/json-rpc",et="reown_test";function Vt(){const{chainNamespace:t}=I.parseCaipNetworkId(u.state.paymentAsset.network);if(!z.isAddress(u.state.recipient,t))throw new h(p.INVALID_RECIPIENT_ADDRESS_FOR_ASSET,`Provide valid recipient address for namespace "${t}"`)}async function Qt(t,e,n){var c;if(e!==$.CHAIN.EVM)throw new h(p.INVALID_CHAIN_NAMESPACE);if(!n.fromAddress)throw new h(p.INVALID_PAYMENT_CONFIG,"fromAddress is required for native EVM payments.");const s=typeof n.amount=="string"?parseFloat(n.amount):n.amount;if(isNaN(s))throw new h(p.INVALID_PAYMENT_CONFIG);const i=((c=t.metadata)==null?void 0:c.decimals)??18,r=q.parseUnits(s.toString(),i);if(typeof r!="bigint")throw new h(p.GENERIC_PAYMENT_ERROR);return await q.sendTransaction({chainNamespace:e,to:n.recipient,address:n.fromAddress,value:r,data:"0x"})??void 0}async function Yt(t,e){if(!e.fromAddress)throw new h(p.INVALID_PAYMENT_CONFIG,"fromAddress is required for ERC20 EVM payments.");const n=t.asset,s=e.recipient,i=Number(t.metadata.decimals),r=q.parseUnits(e.amount.toString(),i);if(r===void 0)throw new h(p.GENERIC_PAYMENT_ERROR);return await q.writeContract({fromAddress:e.fromAddress,tokenAddress:n,args:[s,r],method:"transfer",abi:bt.getERC20Abi(n),chainNamespace:$.CHAIN.EVM})??void 0}async function Kt(t,e){if(t!==$.CHAIN.SOLANA)throw new h(p.INVALID_CHAIN_NAMESPACE);if(!e.fromAddress)throw new h(p.INVALID_PAYMENT_CONFIG,"fromAddress is required for Solana payments.");const n=typeof e.amount=="string"?parseFloat(e.amount):e.amount;if(isNaN(n)||n<=0)throw new h(p.INVALID_PAYMENT_CONFIG,"Invalid payment amount.");try{if(!xt.getProvider(t))throw new h(p.GENERIC_PAYMENT_ERROR,"No Solana provider available.");const i=await q.sendTransaction({chainNamespace:$.CHAIN.SOLANA,to:e.recipient,value:n,tokenMint:e.tokenMint});if(!i)throw new h(p.GENERIC_PAYMENT_ERROR,"Transaction failed.");return i}catch(s){throw s instanceof h?s:new h(p.GENERIC_PAYMENT_ERROR,`Solana payment failed: ${s}`)}}async function Xt({sourceToken:t,toToken:e,amount:n,recipient:s}){const i=q.parseUnits(n,t.metadata.decimals),r=q.parseUnits(n,e.metadata.decimals);return Promise.resolve({type:Re,origin:{amount:(i==null?void 0:i.toString())??"0",currency:t},destination:{amount:(r==null?void 0:r.toString())??"0",currency:e},fees:[{id:"service",label:"Service Fee",amount:"0",currency:e}],steps:[{requestId:Re,type:"deposit",deposit:{amount:(i==null?void 0:i.toString())??"0",currency:t.asset,receiver:s}}],timeInSeconds:6})}function ke(t){if(!t)return null;const e=t.steps[0];return!e||e.type!==pn?null:e}function $e(t,e=0){if(!t)return[];const n=t.steps.filter(i=>i.type===hn),s=n.filter((i,r)=>r+1>e);return n.length>0&&n.length<3?s:[]}const Me=new Et({baseUrl:z.getApiUrl(),clientId:null});class Jt extends Error{}function Zt(){const t=Le.getSnapshot().projectId;return`${Gt}?projectId=${t}`}function Be(){const{projectId:t,sdkType:e,sdkVersion:n}=Le.state;return{projectId:t,st:e||"appkit",sv:n||"html-wagmi-4.2.2"}}async function Fe(t,e){const n=Zt(),{sdkType:s,sdkVersion:i,projectId:r}=Le.getSnapshot(),o={jsonrpc:"2.0",id:1,method:t,params:{...e||{},st:s,sv:i,projectId:r}},l=await(await fetch(n,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})).json();if(l.error)throw new Jt(l.error.message);return l}async function tt(t){return(await Fe("reown_getExchanges",t)).result}async function nt(t){return(await Fe("reown_getExchangePayUrl",t)).result}async function en(t){return(await Fe("reown_getExchangeBuyStatus",t)).result}async function tn(t){const e=S.bigNumber(t.amount).times(10**t.toToken.metadata.decimals).toString(),{chainId:n,chainNamespace:s}=I.parseCaipNetworkId(t.sourceToken.network),{chainId:i,chainNamespace:r}=I.parseCaipNetworkId(t.toToken.network),o=t.sourceToken.asset==="native"?je(s):t.sourceToken.asset,c=t.toToken.asset==="native"?je(r):t.toToken.asset;return await Me.post({path:"/appkit/v1/transfers/quote",body:{user:t.address,originChainId:n.toString(),originCurrency:o,destinationChainId:i.toString(),destinationCurrency:c,recipient:t.recipient,amount:e},params:Be()})}async function nn(t){const e=O.isLowerCaseMatch(t.sourceToken.network,t.toToken.network),n=O.isLowerCaseMatch(t.sourceToken.asset,t.toToken.asset);return e&&n?Xt(t):tn(t)}async function sn(t){return await Me.get({path:"/appkit/v1/transfers/status",params:{requestId:t.requestId,...Be()}})}async function rn(t){return await Me.get({path:`/appkit/v1/transfers/assets/exchanges/${t}`,params:Be()})}const on=["eip155","solana"],an={eip155:{native:{assetNamespace:"slip44",assetReference:"60"},defaultTokenNamespace:"erc20"},solana:{native:{assetNamespace:"slip44",assetReference:"501"},defaultTokenNamespace:"token"}};function Pe(t,e){const{chainNamespace:n,chainId:s}=I.parseCaipNetworkId(t),i=an[n];if(!i)throw new Error(`Unsupported chain namespace for CAIP-19 formatting: ${n}`);let r=i.native.assetNamespace,o=i.native.assetReference;return e!=="native"&&(r=i.defaultTokenNamespace,o=e),`${`${n}:${s}`}/${r}:${o}`}function cn(t){const{chainNamespace:e}=I.parseCaipNetworkId(t);return on.includes(e)}function ln(t){const n=w.getAllRequestedCaipNetworks().find(i=>i.caipNetworkId===t.chainId);let s=t.address;if(!n)throw new Error(`Target network not found for balance chainId "${t.chainId}"`);if(O.isLowerCaseMatch(t.symbol,n.nativeCurrency.symbol))s="native";else if(z.isCaipAddress(s)){const{address:i}=I.parseCaipAddress(s);s=i}else if(!s)throw new Error(`Balance address not found for balance symbol "${t.symbol}"`);return{network:n.caipNetworkId,asset:s,metadata:{name:t.name,symbol:t.symbol,decimals:Number(t.quantity.decimals),logoURI:t.iconUrl},amount:t.quantity.numeric}}function un(t){return{chainId:t.network,address:`${t.network}:${t.asset}`,symbol:t.metadata.symbol,name:t.metadata.name,iconUrl:t.metadata.logoURI||"",price:0,quantity:{numeric:"0",decimals:t.metadata.decimals.toString()}}}function Ae(t){const e=S.bigNumber(t,{safe:!0});return e.lt(.001)?"<0.001":e.round(4).toString()}function dn(t){const n=w.getAllRequestedCaipNetworks().find(s=>s.caipNetworkId===t.network);return n?!!n.testnet:!1}const st=0,Se="unknown",Re="direct-transfer",pn="deposit",hn="transaction",a=pt({paymentAsset:{network:"eip155:1",asset:"0x0",metadata:{name:"0x0",symbol:"0x0",decimals:0}},recipient:"0x0",amount:0,isConfigured:!1,error:null,isPaymentInProgress:!1,exchanges:[],isLoading:!1,openInNewTab:!0,redirectUrl:void 0,payWithExchange:void 0,currentPayment:void 0,analyticsSet:!1,paymentId:void 0,choice:"pay",tokenBalances:{[$.CHAIN.EVM]:[],[$.CHAIN.SOLANA]:[]},isFetchingTokenBalances:!1,selectedPaymentAsset:null,quote:void 0,quoteStatus:"waiting",quoteError:null,isFetchingQuote:!1,selectedExchange:void 0,exchangeUrlForQuote:void 0,requestId:void 0}),u={state:a,subscribe(t){return ht(a,()=>t(a))},subscribeKey(t,e){return Ht(a,t,e)},async handleOpenPay(t){this.resetState(),this.setPaymentConfig(t),this.initializeAnalytics(),Vt(),await this.prepareTokenLogo(),a.isConfigured=!0,oe.sendEvent({type:"track",event:"PAY_MODAL_OPEN",properties:{exchanges:a.exchanges,configuration:{network:a.paymentAsset.network,asset:a.paymentAsset.asset,recipient:a.recipient,amount:a.amount}}}),await ue.open({view:"Pay"})},resetState(){a.paymentAsset={network:"eip155:1",asset:"0x0",metadata:{name:"0x0",symbol:"0x0",decimals:0}},a.recipient="0x0",a.amount=0,a.isConfigured=!1,a.error=null,a.isPaymentInProgress=!1,a.isLoading=!1,a.currentPayment=void 0,a.selectedExchange=void 0,a.exchangeUrlForQuote=void 0,a.requestId=void 0},resetQuoteState(){a.quote=void 0,a.quoteStatus="waiting",a.quoteError=null,a.isFetchingQuote=!1,a.requestId=void 0},setPaymentConfig(t){if(!t.paymentAsset)throw new h(p.INVALID_PAYMENT_CONFIG);try{a.choice=t.choice??"pay",a.paymentAsset=t.paymentAsset,a.recipient=t.recipient,a.amount=t.amount,a.openInNewTab=t.openInNewTab??!0,a.redirectUrl=t.redirectUrl,a.payWithExchange=t.payWithExchange,a.error=null}catch(e){throw new h(p.INVALID_PAYMENT_CONFIG,e.message)}},setSelectedPaymentAsset(t){a.selectedPaymentAsset=t},setSelectedExchange(t){a.selectedExchange=t},setRequestId(t){a.requestId=t},setPaymentInProgress(t){a.isPaymentInProgress=t},getPaymentAsset(){return a.paymentAsset},getExchanges(){return a.exchanges},async fetchExchanges(){try{a.isLoading=!0;const t=await tt({page:st});a.exchanges=t.exchanges.slice(0,2)}catch{throw H.showError(V.UNABLE_TO_GET_EXCHANGES),new h(p.UNABLE_TO_GET_EXCHANGES)}finally{a.isLoading=!1}},async getAvailableExchanges(t){var e;try{const n=t!=null&&t.asset&&(t!=null&&t.network)?Pe(t.network,t.asset):void 0;return await tt({page:(t==null?void 0:t.page)??st,asset:n,amount:(e=t==null?void 0:t.amount)==null?void 0:e.toString()})}catch{throw new h(p.UNABLE_TO_GET_EXCHANGES)}},async getPayUrl(t,e,n=!1){try{const s=Number(e.amount),i=await nt({exchangeId:t,asset:Pe(e.network,e.asset),amount:s.toString(),recipient:`${e.network}:${e.recipient}`});return oe.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{source:"pay",exchange:{id:t},configuration:{network:e.network,asset:e.asset,recipient:e.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},headless:n}}),n&&(this.initiatePayment(),oe.sendEvent({type:"track",event:"PAY_INITIATED",properties:{source:"pay",paymentId:a.paymentId||Se,configuration:{network:e.network,asset:e.asset,recipient:e.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t}}})),i}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new h(p.ASSET_NOT_SUPPORTED):new Error(s.message)}},async generateExchangeUrlForQuote({exchangeId:t,paymentAsset:e,amount:n,recipient:s}){const i=await nt({exchangeId:t,asset:Pe(e.network,e.asset),amount:n.toString(),recipient:s});a.exchangeSessionId=i.sessionId,a.exchangeUrlForQuote=i.url},async openPayUrl(t,e,n=!1){try{const s=await this.getPayUrl(t.exchangeId,e,n);if(!s)throw new h(p.UNABLE_TO_GET_PAY_URL);const r=t.openInNewTab??!0?"_blank":"_self";return z.openHref(s.url,r),s}catch(s){throw s instanceof h?a.error=s.message:a.error=V.GENERIC_PAYMENT_ERROR,new h(p.UNABLE_TO_GET_PAY_URL)}},async onTransfer({chainNamespace:t,fromAddress:e,toAddress:n,amount:s,paymentAsset:i}){if(a.currentPayment={type:"wallet",status:"IN_PROGRESS"},!a.isPaymentInProgress)try{this.initiatePayment();const o=w.getAllRequestedCaipNetworks().find(l=>l.caipNetworkId===i.network);if(!o)throw new Error("Target network not found");const c=w.state.activeCaipNetwork;switch(O.isLowerCaseMatch(c==null?void 0:c.caipNetworkId,o.caipNetworkId)||await w.switchActiveNetwork(o),t){case $.CHAIN.EVM:i.asset==="native"&&(a.currentPayment.result=await Qt(i,t,{recipient:n,amount:s,fromAddress:e})),i.asset.startsWith("0x")&&(a.currentPayment.result=await Yt(i,{recipient:n,amount:s,fromAddress:e})),a.currentPayment.status="SUCCESS";break;case $.CHAIN.SOLANA:a.currentPayment.result=await Kt(t,{recipient:n,amount:s,fromAddress:e,tokenMint:i.asset==="native"?void 0:i.asset}),a.currentPayment.status="SUCCESS";break;default:throw new h(p.INVALID_CHAIN_NAMESPACE)}}catch(r){throw r instanceof h?a.error=r.message:a.error=V.GENERIC_PAYMENT_ERROR,a.currentPayment.status="FAILED",H.showError(a.error),r}finally{a.isPaymentInProgress=!1}},async onSendTransaction(t){try{const{namespace:e,transactionStep:n}=t;u.initiatePayment();const i=w.getAllRequestedCaipNetworks().find(o=>{var c;return o.caipNetworkId===((c=a.paymentAsset)==null?void 0:c.network)});if(!i)throw new Error("Target network not found");const r=w.state.activeCaipNetwork;if(O.isLowerCaseMatch(r==null?void 0:r.caipNetworkId,i.caipNetworkId)||await w.switchActiveNetwork(i),e===$.CHAIN.EVM){const{from:o,to:c,data:l,value:m}=n.transaction;await q.sendTransaction({address:o,to:c,data:l,value:BigInt(m),chainNamespace:e})}else if(e===$.CHAIN.SOLANA){const{instructions:o}=n.transaction;await q.writeSolanaTransaction({instructions:o})}}catch(e){throw e instanceof h?a.error=e.message:a.error=V.GENERIC_PAYMENT_ERROR,H.showError(a.error),e}finally{a.isPaymentInProgress=!1}},getExchangeById(t){return a.exchanges.find(e=>e.id===t)},validatePayConfig(t){const{paymentAsset:e,recipient:n,amount:s}=t;if(!e)throw new h(p.INVALID_PAYMENT_CONFIG);if(!n)throw new h(p.INVALID_RECIPIENT);if(!e.asset)throw new h(p.INVALID_ASSET);if(s==null||s<=0)throw new h(p.INVALID_AMOUNT)},async handlePayWithExchange(t){try{a.currentPayment={type:"exchange",exchangeId:t};const{network:e,asset:n}=a.paymentAsset,s={network:e,asset:n,amount:a.amount,recipient:a.recipient},i=await this.getPayUrl(t,s);if(!i)throw new h(p.UNABLE_TO_INITIATE_PAYMENT);return a.currentPayment.sessionId=i.sessionId,a.currentPayment.status="IN_PROGRESS",a.currentPayment.exchangeId=t,this.initiatePayment(),{url:i.url,openInNewTab:a.openInNewTab}}catch(e){return e instanceof h?a.error=e.message:a.error=V.GENERIC_PAYMENT_ERROR,a.isPaymentInProgress=!1,H.showError(a.error),null}},async getBuyStatus(t,e){var n,s;try{const i=await en({sessionId:e,exchangeId:t});return(i.status==="SUCCESS"||i.status==="FAILED")&&oe.sendEvent({type:"track",event:i.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:i.status==="FAILED"?z.parseError(a.error):void 0,source:"pay",paymentId:a.paymentId||Se,configuration:{network:a.paymentAsset.network,asset:a.paymentAsset.asset,recipient:a.recipient,amount:a.amount},currentPayment:{type:"exchange",exchangeId:(n=a.currentPayment)==null?void 0:n.exchangeId,sessionId:(s=a.currentPayment)==null?void 0:s.sessionId,result:i.txHash}}}),i}catch{throw new h(p.UNABLE_TO_GET_BUY_STATUS)}},async fetchTokensFromEOA({caipAddress:t,caipNetwork:e,namespace:n}){if(!t)return[];const{address:s}=I.parseCaipAddress(t);let i=e;return n===$.CHAIN.EVM&&(i=void 0),await It.getMyTokensWithBalance({address:s,caipNetwork:i})},async fetchTokensFromExchange(){if(!a.selectedExchange)return[];const t=await rn(a.selectedExchange.id),e=Object.values(t.assets).flat();return await Promise.all(e.map(async s=>{const i=un(s),{chainNamespace:r}=I.parseCaipNetworkId(i.chainId);let o=i.address;if(z.isCaipAddress(o)){const{address:l}=I.parseCaipAddress(o);o=l}const c=await D.getImageByToken(o??"",r).catch(()=>{});return i.iconUrl=c??"",i}))},async fetchTokens({caipAddress:t,caipNetwork:e,namespace:n}){try{a.isFetchingTokenBalances=!0;const r=await(!!a.selectedExchange?this.fetchTokensFromExchange():this.fetchTokensFromEOA({caipAddress:t,caipNetwork:e,namespace:n}));a.tokenBalances={...a.tokenBalances,[n]:r}}catch(s){const i=s instanceof Error?s.message:"Unable to get token balances";H.showError(i)}finally{a.isFetchingTokenBalances=!1}},async fetchQuote({amount:t,address:e,sourceToken:n,toToken:s,recipient:i}){try{u.resetQuoteState(),a.isFetchingQuote=!0;const r=await nn({amount:t,address:a.selectedExchange?void 0:e,sourceToken:n,toToken:s,recipient:i});if(a.selectedExchange){const o=ke(r);if(o){const c=`${n.network}:${o.deposit.receiver}`,l=S.formatNumber(o.deposit.amount,{decimals:n.metadata.decimals??0,round:8});await u.generateExchangeUrlForQuote({exchangeId:a.selectedExchange.id,paymentAsset:n,amount:l.toString(),recipient:c})}}a.quote=r}catch(r){let o=V.UNABLE_TO_GET_QUOTE;if(r instanceof Error&&r.cause&&r.cause instanceof Response)try{const c=await r.cause.json();c.error&&typeof c.error=="string"&&(o=c.error)}catch{}throw a.quoteError=o,H.showError(o),new h(p.UNABLE_TO_GET_QUOTE)}finally{a.isFetchingQuote=!1}},async fetchQuoteStatus({requestId:t}){try{if(t===Re){const n=a.selectedExchange,s=a.exchangeSessionId;if(n&&s){switch((await this.getBuyStatus(n.id,s)).status){case"IN_PROGRESS":a.quoteStatus="waiting";break;case"SUCCESS":a.quoteStatus="success",a.isPaymentInProgress=!1;break;case"FAILED":a.quoteStatus="failure",a.isPaymentInProgress=!1;break;case"UNKNOWN":a.quoteStatus="waiting";break;default:a.quoteStatus="waiting";break}return}a.quoteStatus="success";return}const{status:e}=await sn({requestId:t});a.quoteStatus=e}catch{throw a.quoteStatus="failure",new h(p.UNABLE_TO_GET_QUOTE_STATUS)}},initiatePayment(){a.isPaymentInProgress=!0,a.paymentId=crypto.randomUUID()},initializeAnalytics(){a.analyticsSet||(a.analyticsSet=!0,this.subscribeKey("isPaymentInProgress",t=>{var e;if((e=a.currentPayment)!=null&&e.status&&a.currentPayment.status!=="UNKNOWN"){const n={IN_PROGRESS:"PAY_INITIATED",SUCCESS:"PAY_SUCCESS",FAILED:"PAY_ERROR"}[a.currentPayment.status];oe.sendEvent({type:"track",event:n,properties:{message:a.currentPayment.status==="FAILED"?z.parseError(a.error):void 0,source:"pay",paymentId:a.paymentId||Se,configuration:{network:a.paymentAsset.network,asset:a.paymentAsset.asset,recipient:a.recipient,amount:a.amount},currentPayment:{type:a.currentPayment.type,exchangeId:a.currentPayment.exchangeId,sessionId:a.currentPayment.sessionId,result:a.currentPayment.result}}})}}))},async prepareTokenLogo(){if(!a.paymentAsset.metadata.logoURI)try{const{chainNamespace:t}=I.parseCaipNetworkId(a.paymentAsset.network),e=await D.getImageByToken(a.paymentAsset.asset,t);a.paymentAsset.metadata.logoURI=e}catch{}}},mn=G`
|
|
141
|
-
wui-separator {
|
|
142
|
-
margin: var(--apkt-spacing-3) calc(var(--apkt-spacing-3) * -1) var(--apkt-spacing-2)
|
|
143
|
-
calc(var(--apkt-spacing-3) * -1);
|
|
144
|
-
width: calc(100% + var(--apkt-spacing-3) * 2);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.token-display {
|
|
148
|
-
padding: var(--apkt-spacing-3) var(--apkt-spacing-3);
|
|
149
|
-
border-radius: var(--apkt-borderRadius-5);
|
|
150
|
-
background-color: var(--apkt-tokens-theme-backgroundPrimary);
|
|
151
|
-
margin-top: var(--apkt-spacing-3);
|
|
152
|
-
margin-bottom: var(--apkt-spacing-3);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.token-display wui-text {
|
|
156
|
-
text-transform: none;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
wui-loading-spinner {
|
|
160
|
-
padding: var(--apkt-spacing-2);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.left-image-container {
|
|
164
|
-
position: relative;
|
|
165
|
-
justify-content: center;
|
|
166
|
-
align-items: center;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.token-image {
|
|
170
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
171
|
-
width: 40px;
|
|
172
|
-
height: 40px;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.chain-image {
|
|
176
|
-
position: absolute;
|
|
177
|
-
width: 20px;
|
|
178
|
-
height: 20px;
|
|
179
|
-
bottom: -3px;
|
|
180
|
-
right: -5px;
|
|
181
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
182
|
-
border: 2px solid ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.payment-methods-container {
|
|
186
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
187
|
-
border-top-right-radius: ${({borderRadius:t})=>t[8]};
|
|
188
|
-
border-top-left-radius: ${({borderRadius:t})=>t[8]};
|
|
189
|
-
}
|
|
190
|
-
`;var X=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let B=class extends W{constructor(){super(),this.unsubscribe=[],this.amount=u.state.amount,this.namespace=void 0,this.paymentAsset=u.state.paymentAsset,this.activeConnectorIds=R.state.activeConnectorIds,this.caipAddress=void 0,this.exchanges=u.state.exchanges,this.isLoading=u.state.isLoading,this.initializeNamespace(),this.unsubscribe.push(u.subscribeKey("amount",e=>this.amount=e)),this.unsubscribe.push(R.subscribeKey("activeConnectorIds",e=>this.activeConnectorIds=e)),this.unsubscribe.push(u.subscribeKey("exchanges",e=>this.exchanges=e)),this.unsubscribe.push(u.subscribeKey("isLoading",e=>this.isLoading=e)),u.fetchExchanges(),u.setSelectedExchange(void 0)}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){return d`
|
|
191
|
-
<wui-flex flexDirection="column">
|
|
192
|
-
${this.paymentDetailsTemplate()} ${this.paymentMethodsTemplate()}
|
|
193
|
-
</wui-flex>
|
|
194
|
-
`}paymentMethodsTemplate(){return d`
|
|
195
|
-
<wui-flex flexDirection="column" padding="3" gap="2" class="payment-methods-container">
|
|
196
|
-
${this.payWithWalletTemplate()} ${this.templateSeparator()}
|
|
197
|
-
${this.templateExchangeOptions()}
|
|
198
|
-
</wui-flex>
|
|
199
|
-
`}initializeNamespace(){var n;const e=w.state.activeChain;this.namespace=e,this.caipAddress=(n=w.getAccountData(e))==null?void 0:n.caipAddress,this.unsubscribe.push(w.subscribeChainProp("accountState",s=>{this.caipAddress=s==null?void 0:s.caipAddress},e))}paymentDetailsTemplate(){const n=w.getAllRequestedCaipNetworks().find(s=>s.caipNetworkId===this.paymentAsset.network);return d`
|
|
200
|
-
<wui-flex
|
|
201
|
-
alignItems="center"
|
|
202
|
-
justifyContent="space-between"
|
|
203
|
-
.padding=${["6","8","6","8"]}
|
|
204
|
-
gap="2"
|
|
205
|
-
>
|
|
206
|
-
<wui-flex alignItems="center" gap="1">
|
|
207
|
-
<wui-text variant="h1-regular" color="primary">
|
|
208
|
-
${Ae(this.amount||"0")}
|
|
209
|
-
</wui-text>
|
|
210
|
-
|
|
211
|
-
<wui-flex flexDirection="column">
|
|
212
|
-
<wui-text variant="h6-regular" color="secondary">
|
|
213
|
-
${this.paymentAsset.metadata.symbol||"Unknown"}
|
|
214
|
-
</wui-text>
|
|
215
|
-
<wui-text variant="md-medium" color="secondary"
|
|
216
|
-
>on ${(n==null?void 0:n.name)||"Unknown"}</wui-text
|
|
217
|
-
>
|
|
218
|
-
</wui-flex>
|
|
219
|
-
</wui-flex>
|
|
220
|
-
|
|
221
|
-
<wui-flex class="left-image-container">
|
|
222
|
-
<wui-image
|
|
223
|
-
src=${b(this.paymentAsset.metadata.logoURI)}
|
|
224
|
-
class="token-image"
|
|
225
|
-
></wui-image>
|
|
226
|
-
<wui-image
|
|
227
|
-
src=${b(D.getNetworkImage(n))}
|
|
228
|
-
class="chain-image"
|
|
229
|
-
></wui-image>
|
|
230
|
-
</wui-flex>
|
|
231
|
-
</wui-flex>
|
|
232
|
-
`}payWithWalletTemplate(){return cn(this.paymentAsset.network)?this.caipAddress?this.connectedWalletTemplate():this.disconnectedWalletTemplate():d``}connectedWalletTemplate(){const{name:e,image:n}=this.getWalletProperties({namespace:this.namespace});return d`
|
|
233
|
-
<wui-flex flexDirection="column" gap="3">
|
|
234
|
-
<wui-list-item
|
|
235
|
-
type="secondary"
|
|
236
|
-
boxColor="foregroundSecondary"
|
|
237
|
-
@click=${this.onWalletPayment}
|
|
238
|
-
.boxed=${!1}
|
|
239
|
-
?chevron=${!0}
|
|
240
|
-
?fullSize=${!1}
|
|
241
|
-
?rounded=${!0}
|
|
242
|
-
data-testid="wallet-payment-option"
|
|
243
|
-
imageSrc=${b(n)}
|
|
244
|
-
imageSize="3xl"
|
|
245
|
-
>
|
|
246
|
-
<wui-text variant="lg-regular" color="primary">Pay with ${e}</wui-text>
|
|
247
|
-
</wui-list-item>
|
|
248
|
-
|
|
249
|
-
<wui-list-item
|
|
250
|
-
type="secondary"
|
|
251
|
-
icon="power"
|
|
252
|
-
iconColor="error"
|
|
253
|
-
@click=${this.onDisconnect}
|
|
254
|
-
data-testid="disconnect-button"
|
|
255
|
-
?chevron=${!1}
|
|
256
|
-
boxColor="foregroundSecondary"
|
|
257
|
-
>
|
|
258
|
-
<wui-text variant="lg-regular" color="secondary">Disconnect</wui-text>
|
|
259
|
-
</wui-list-item>
|
|
260
|
-
</wui-flex>
|
|
261
|
-
`}disconnectedWalletTemplate(){return d`<wui-list-item
|
|
262
|
-
type="secondary"
|
|
263
|
-
boxColor="foregroundSecondary"
|
|
264
|
-
variant="icon"
|
|
265
|
-
iconColor="default"
|
|
266
|
-
iconVariant="overlay"
|
|
267
|
-
icon="wallet"
|
|
268
|
-
@click=${this.onWalletPayment}
|
|
269
|
-
?chevron=${!0}
|
|
270
|
-
data-testid="wallet-payment-option"
|
|
271
|
-
>
|
|
272
|
-
<wui-text variant="lg-regular" color="primary">Pay with wallet</wui-text>
|
|
273
|
-
</wui-list-item>`}templateExchangeOptions(){if(this.isLoading)return d`<wui-flex justifyContent="center" alignItems="center">
|
|
274
|
-
<wui-loading-spinner size="md"></wui-loading-spinner>
|
|
275
|
-
</wui-flex>`;const e=this.exchanges.filter(n=>dn(this.paymentAsset)?n.id===et:n.id!==et);return e.length===0?d`<wui-flex justifyContent="center" alignItems="center">
|
|
276
|
-
<wui-text variant="md-medium" color="primary">No exchanges available</wui-text>
|
|
277
|
-
</wui-flex>`:e.map(n=>d`
|
|
278
|
-
<wui-list-item
|
|
279
|
-
type="secondary"
|
|
280
|
-
boxColor="foregroundSecondary"
|
|
281
|
-
@click=${()=>this.onExchangePayment(n)}
|
|
282
|
-
data-testid="exchange-option-${n.id}"
|
|
283
|
-
?chevron=${!0}
|
|
284
|
-
imageSrc=${b(n.imageUrl)}
|
|
285
|
-
>
|
|
286
|
-
<wui-text flexGrow="1" variant="lg-regular" color="primary">
|
|
287
|
-
Pay with ${n.name}
|
|
288
|
-
</wui-text>
|
|
289
|
-
</wui-list-item>
|
|
290
|
-
`)}templateSeparator(){return d`<wui-separator text="or" bgColor="secondary"></wui-separator>`}async onWalletPayment(){if(!this.namespace)throw new Error("Namespace not found");this.caipAddress?ce.push("PayQuote"):(await R.connect(),await ue.open({view:"PayQuote"}))}onExchangePayment(e){u.setSelectedExchange(e),ce.push("PayQuote")}async onDisconnect(){try{await q.disconnect(),await ue.open({view:"Pay"})}catch{console.error("Failed to disconnect"),H.showError("Failed to disconnect")}}getWalletProperties({namespace:e}){if(!e)return{name:void 0,image:void 0};const n=this.activeConnectorIds[e];if(!n)return{name:void 0,image:void 0};const s=R.getConnector({id:n,namespace:e});if(!s)return{name:void 0,image:void 0};const i=D.getConnectorImage(s);return{name:s.name,image:i}}};B.styles=mn;X([f()],B.prototype,"amount",void 0);X([f()],B.prototype,"namespace",void 0);X([f()],B.prototype,"paymentAsset",void 0);X([f()],B.prototype,"activeConnectorIds",void 0);X([f()],B.prototype,"caipAddress",void 0);X([f()],B.prototype,"exchanges",void 0);X([f()],B.prototype,"isLoading",void 0);B=X([F("w3m-pay-view")],B);/**
|
|
291
|
-
* @license
|
|
292
|
-
* Copyright 2017 Google LLC
|
|
293
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
294
|
-
*/const fn={ATTRIBUTE:1},gn=t=>(...e)=>({_$litDirective$:t,values:e});class yn{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,s){this._$Ct=e,this._$AM=n,this._$Ci=s}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/**
|
|
295
|
-
* @license
|
|
296
|
-
* Copyright 2018 Google LLC
|
|
297
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
298
|
-
*/const mt=gn(class extends yn{constructor(t){var e;if(super(t),t.type!==fn.ATTRIBUTE||t.name!=="class"||((e=t.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var s,i;if(this.st===void 0){this.st=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in e)e[r]&&!((s=this.nt)!=null&&s.has(r))&&this.st.add(r);return this.render(e)}const n=t.element.classList;for(const r of this.st)r in e||(n.remove(r),this.st.delete(r));for(const r in e){const o=!!e[r];o===this.st.has(r)||(i=this.nt)!=null&&i.has(r)||(o?(n.add(r),this.st.add(r)):(n.remove(r),this.st.delete(r)))}return ne}}),wn=G`
|
|
299
|
-
:host {
|
|
300
|
-
display: inline-flex;
|
|
301
|
-
align-items: center;
|
|
302
|
-
justify-content: center;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.pulse-container {
|
|
306
|
-
position: relative;
|
|
307
|
-
width: var(--pulse-size);
|
|
308
|
-
height: var(--pulse-size);
|
|
309
|
-
display: flex;
|
|
310
|
-
align-items: center;
|
|
311
|
-
justify-content: center;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.pulse-rings {
|
|
315
|
-
position: absolute;
|
|
316
|
-
inset: 0;
|
|
317
|
-
pointer-events: none;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.pulse-ring {
|
|
321
|
-
position: absolute;
|
|
322
|
-
inset: 0;
|
|
323
|
-
border-radius: 50%;
|
|
324
|
-
border: 2px solid var(--pulse-color);
|
|
325
|
-
opacity: 0;
|
|
326
|
-
animation: pulse var(--pulse-duration, 2s) ease-out infinite;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.pulse-content {
|
|
330
|
-
position: relative;
|
|
331
|
-
z-index: 1;
|
|
332
|
-
display: flex;
|
|
333
|
-
align-items: center;
|
|
334
|
-
justify-content: center;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@keyframes pulse {
|
|
338
|
-
0% {
|
|
339
|
-
transform: scale(0.5);
|
|
340
|
-
opacity: var(--pulse-opacity, 0.3);
|
|
341
|
-
}
|
|
342
|
-
50% {
|
|
343
|
-
opacity: calc(var(--pulse-opacity, 0.3) * 0.5);
|
|
344
|
-
}
|
|
345
|
-
100% {
|
|
346
|
-
transform: scale(1.2);
|
|
347
|
-
opacity: 0;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
`;var re=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};const An=3,xn=2,bn=.3,En="200px",In={"accent-primary":_t.tokens.core.backgroundAccentPrimary};let Y=class extends W{constructor(){super(...arguments),this.rings=An,this.duration=xn,this.opacity=bn,this.size=En,this.variant="accent-primary"}render(){const e=In[this.variant];this.style.cssText=`
|
|
351
|
-
--pulse-size: ${this.size};
|
|
352
|
-
--pulse-duration: ${this.duration}s;
|
|
353
|
-
--pulse-color: ${e};
|
|
354
|
-
--pulse-opacity: ${this.opacity};
|
|
355
|
-
`;const n=Array.from({length:this.rings},(s,i)=>this.renderRing(i,this.rings));return d`
|
|
356
|
-
<div class="pulse-container">
|
|
357
|
-
<div class="pulse-rings">${n}</div>
|
|
358
|
-
<div class="pulse-content">
|
|
359
|
-
<slot></slot>
|
|
360
|
-
</div>
|
|
361
|
-
</div>
|
|
362
|
-
`}renderRing(e,n){const i=`animation-delay: ${e/n*this.duration}s;`;return d`<div class="pulse-ring" style=${i}></div>`}};Y.styles=[ot,wn];re([P({type:Number})],Y.prototype,"rings",void 0);re([P({type:Number})],Y.prototype,"duration",void 0);re([P({type:Number})],Y.prototype,"opacity",void 0);re([P()],Y.prototype,"size",void 0);re([P()],Y.prototype,"variant",void 0);Y=re([F("wui-pulse")],Y);const it=[{id:"received",title:"Receiving funds",icon:"dollar"},{id:"processing",title:"Swapping asset",icon:"recycleHorizontal"},{id:"sending",title:"Sending asset to the recipient address",icon:"send"}],rt=["success","submitted","failure","timeout","refund"],_n=G`
|
|
363
|
-
:host {
|
|
364
|
-
display: block;
|
|
365
|
-
height: 100%;
|
|
366
|
-
width: 100%;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
wui-image {
|
|
370
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
.token-badge-container {
|
|
374
|
-
position: absolute;
|
|
375
|
-
bottom: 6px;
|
|
376
|
-
left: 50%;
|
|
377
|
-
transform: translateX(-50%);
|
|
378
|
-
border-radius: ${({borderRadius:t})=>t[4]};
|
|
379
|
-
z-index: 3;
|
|
380
|
-
min-width: 105px;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.token-badge-container.loading {
|
|
384
|
-
background-color: ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
385
|
-
border: 3px solid ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
.token-badge-container.success {
|
|
389
|
-
background-color: ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
390
|
-
border: 3px solid ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
.token-image-container {
|
|
394
|
-
position: relative;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
.token-image {
|
|
398
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
399
|
-
width: 64px;
|
|
400
|
-
height: 64px;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
.token-image.success {
|
|
404
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.token-image.error {
|
|
408
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.token-image.loading {
|
|
412
|
-
background: ${({colors:t})=>t.accent010};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
.token-image wui-icon {
|
|
416
|
-
width: 32px;
|
|
417
|
-
height: 32px;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
.token-badge {
|
|
421
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
422
|
-
border: 1px solid ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
423
|
-
border-radius: ${({borderRadius:t})=>t[4]};
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
.token-badge wui-text {
|
|
427
|
-
white-space: nowrap;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
.payment-lifecycle-container {
|
|
431
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
432
|
-
border-top-right-radius: ${({borderRadius:t})=>t[6]};
|
|
433
|
-
border-top-left-radius: ${({borderRadius:t})=>t[6]};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.payment-step-badge {
|
|
437
|
-
padding: ${({spacing:t})=>t[1]} ${({spacing:t})=>t[2]};
|
|
438
|
-
border-radius: ${({borderRadius:t})=>t[1]};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
.payment-step-badge.loading {
|
|
442
|
-
background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
.payment-step-badge.error {
|
|
446
|
-
background-color: ${({tokens:t})=>t.core.backgroundError};
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
.payment-step-badge.success {
|
|
450
|
-
background-color: ${({tokens:t})=>t.core.backgroundSuccess};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.step-icon-container {
|
|
454
|
-
position: relative;
|
|
455
|
-
height: 40px;
|
|
456
|
-
width: 40px;
|
|
457
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
458
|
-
background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
.step-icon-box {
|
|
462
|
-
position: absolute;
|
|
463
|
-
right: -4px;
|
|
464
|
-
bottom: -1px;
|
|
465
|
-
padding: 2px;
|
|
466
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
467
|
-
border: 2px solid ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
468
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
.step-icon-box.success {
|
|
472
|
-
background-color: ${({tokens:t})=>t.core.backgroundSuccess};
|
|
473
|
-
}
|
|
474
|
-
`;var j=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};const Nn={received:["pending","success","submitted"],processing:["success","submitted"],sending:["success","submitted"]},vn=3e3;let U=class extends W{constructor(){super(),this.unsubscribe=[],this.pollingInterval=null,this.paymentAsset=u.state.paymentAsset,this.quoteStatus=u.state.quoteStatus,this.quote=u.state.quote,this.amount=u.state.amount,this.namespace=void 0,this.caipAddress=void 0,this.profileName=null,this.activeConnectorIds=R.state.activeConnectorIds,this.selectedExchange=u.state.selectedExchange,this.initializeNamespace(),this.unsubscribe.push(u.subscribeKey("quoteStatus",e=>this.quoteStatus=e),u.subscribeKey("quote",e=>this.quote=e),R.subscribeKey("activeConnectorIds",e=>this.activeConnectorIds=e),u.subscribeKey("selectedExchange",e=>this.selectedExchange=e))}connectedCallback(){super.connectedCallback(),this.startPolling()}disconnectedCallback(){super.disconnectedCallback(),this.stopPolling(),this.unsubscribe.forEach(e=>e())}render(){return d`
|
|
475
|
-
<wui-flex flexDirection="column" .padding=${["3","0","0","0"]} gap="2">
|
|
476
|
-
${this.tokenTemplate()} ${this.paymentTemplate()} ${this.paymentLifecycleTemplate()}
|
|
477
|
-
</wui-flex>
|
|
478
|
-
`}tokenTemplate(){const e=Ae(this.amount||"0"),n=this.paymentAsset.metadata.symbol??"Unknown",i=w.getAllRequestedCaipNetworks().find(c=>c.caipNetworkId===this.paymentAsset.network),r=this.quoteStatus==="failure"||this.quoteStatus==="timeout"||this.quoteStatus==="refund";return this.quoteStatus==="success"||this.quoteStatus==="submitted"?d`<wui-flex alignItems="center" justifyContent="center">
|
|
479
|
-
<wui-flex justifyContent="center" alignItems="center" class="token-image success">
|
|
480
|
-
<wui-icon name="checkmark" color="success" size="inherit"></wui-icon>
|
|
481
|
-
</wui-flex>
|
|
482
|
-
</wui-flex>`:r?d`<wui-flex alignItems="center" justifyContent="center">
|
|
483
|
-
<wui-flex justifyContent="center" alignItems="center" class="token-image error">
|
|
484
|
-
<wui-icon name="close" color="error" size="inherit"></wui-icon>
|
|
485
|
-
</wui-flex>
|
|
486
|
-
</wui-flex>`:d`
|
|
487
|
-
<wui-flex alignItems="center" justifyContent="center">
|
|
488
|
-
<wui-flex class="token-image-container">
|
|
489
|
-
<wui-pulse size="125px" rings="3" duration="4" opacity="0.5" variant="accent-primary">
|
|
490
|
-
<wui-flex justifyContent="center" alignItems="center" class="token-image loading">
|
|
491
|
-
<wui-icon name="paperPlaneTitle" color="accent-primary" size="inherit"></wui-icon>
|
|
492
|
-
</wui-flex>
|
|
493
|
-
</wui-pulse>
|
|
494
|
-
|
|
495
|
-
<wui-flex
|
|
496
|
-
justifyContent="center"
|
|
497
|
-
alignItems="center"
|
|
498
|
-
class="token-badge-container loading"
|
|
499
|
-
>
|
|
500
|
-
<wui-flex
|
|
501
|
-
alignItems="center"
|
|
502
|
-
justifyContent="center"
|
|
503
|
-
gap="01"
|
|
504
|
-
padding="1"
|
|
505
|
-
class="token-badge"
|
|
506
|
-
>
|
|
507
|
-
<wui-image
|
|
508
|
-
src=${b(D.getNetworkImage(i))}
|
|
509
|
-
class="chain-image"
|
|
510
|
-
size="mdl"
|
|
511
|
-
></wui-image>
|
|
512
|
-
|
|
513
|
-
<wui-text variant="lg-regular" color="primary">${e} ${n}</wui-text>
|
|
514
|
-
</wui-flex>
|
|
515
|
-
</wui-flex>
|
|
516
|
-
</wui-flex>
|
|
517
|
-
</wui-flex>
|
|
518
|
-
`}paymentTemplate(){return d`
|
|
519
|
-
<wui-flex flexDirection="column" gap="2" .padding=${["0","6","0","6"]}>
|
|
520
|
-
${this.renderPayment()}
|
|
521
|
-
<wui-separator></wui-separator>
|
|
522
|
-
${this.renderWallet()}
|
|
523
|
-
</wui-flex>
|
|
524
|
-
`}paymentLifecycleTemplate(){const e=this.getStepsWithStatus();return d`
|
|
525
|
-
<wui-flex flexDirection="column" padding="4" gap="2" class="payment-lifecycle-container">
|
|
526
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
527
|
-
<wui-text variant="md-regular" color="secondary">PAYMENT CYCLE</wui-text>
|
|
528
|
-
|
|
529
|
-
${this.renderPaymentCycleBadge()}
|
|
530
|
-
</wui-flex>
|
|
531
|
-
|
|
532
|
-
<wui-flex flexDirection="column" gap="5" .padding=${["2","0","2","0"]}>
|
|
533
|
-
${e.map(n=>this.renderStep(n))}
|
|
534
|
-
</wui-flex>
|
|
535
|
-
</wui-flex>
|
|
536
|
-
`}renderPaymentCycleBadge(){var i;const e=this.quoteStatus==="failure"||this.quoteStatus==="timeout"||this.quoteStatus==="refund",n=this.quoteStatus==="success"||this.quoteStatus==="submitted";if(e)return d`
|
|
537
|
-
<wui-flex
|
|
538
|
-
justifyContent="center"
|
|
539
|
-
alignItems="center"
|
|
540
|
-
class="payment-step-badge error"
|
|
541
|
-
gap="1"
|
|
542
|
-
>
|
|
543
|
-
<wui-icon name="close" color="error" size="xs"></wui-icon>
|
|
544
|
-
<wui-text variant="sm-regular" color="error">Failed</wui-text>
|
|
545
|
-
</wui-flex>
|
|
546
|
-
`;if(n)return d`
|
|
547
|
-
<wui-flex
|
|
548
|
-
justifyContent="center"
|
|
549
|
-
alignItems="center"
|
|
550
|
-
class="payment-step-badge success"
|
|
551
|
-
gap="1"
|
|
552
|
-
>
|
|
553
|
-
<wui-icon name="checkmark" color="success" size="xs"></wui-icon>
|
|
554
|
-
<wui-text variant="sm-regular" color="success">Completed</wui-text>
|
|
555
|
-
</wui-flex>
|
|
556
|
-
`;const s=((i=this.quote)==null?void 0:i.timeInSeconds)??0;return d`
|
|
557
|
-
<wui-flex alignItems="center" justifyContent="space-between" gap="3">
|
|
558
|
-
<wui-flex
|
|
559
|
-
justifyContent="center"
|
|
560
|
-
alignItems="center"
|
|
561
|
-
class="payment-step-badge loading"
|
|
562
|
-
gap="1"
|
|
563
|
-
>
|
|
564
|
-
<wui-icon name="clock" color="default" size="xs"></wui-icon>
|
|
565
|
-
<wui-text variant="sm-regular" color="primary">Est. ${s} sec</wui-text>
|
|
566
|
-
</wui-flex>
|
|
567
|
-
|
|
568
|
-
<wui-icon name="chevronBottom" color="default" size="xxs"></wui-icon>
|
|
569
|
-
</wui-flex>
|
|
570
|
-
`}renderPayment(){var o,c,l;const n=w.getAllRequestedCaipNetworks().find(m=>{var v;const y=(v=this.quote)==null?void 0:v.origin.currency.network;if(!y)return!1;const{chainId:g}=I.parseCaipNetworkId(y);return O.isLowerCaseMatch(m.id.toString(),g.toString())}),s=S.formatNumber(((o=this.quote)==null?void 0:o.origin.amount)||"0",{decimals:((c=this.quote)==null?void 0:c.origin.currency.metadata.decimals)??0}).toString(),i=Ae(s),r=((l=this.quote)==null?void 0:l.origin.currency.metadata.symbol)??"Unknown";return d`
|
|
571
|
-
<wui-flex
|
|
572
|
-
alignItems="flex-start"
|
|
573
|
-
justifyContent="space-between"
|
|
574
|
-
.padding=${["3","0","3","0"]}
|
|
575
|
-
>
|
|
576
|
-
<wui-text variant="lg-regular" color="secondary">Payment Method</wui-text>
|
|
577
|
-
|
|
578
|
-
<wui-flex flexDirection="column" alignItems="flex-end" gap="1">
|
|
579
|
-
<wui-flex alignItems="center" gap="01">
|
|
580
|
-
<wui-text variant="lg-regular" color="primary">${i}</wui-text>
|
|
581
|
-
<wui-text variant="lg-regular" color="secondary">${r}</wui-text>
|
|
582
|
-
</wui-flex>
|
|
583
|
-
|
|
584
|
-
<wui-flex alignItems="center" gap="1">
|
|
585
|
-
<wui-text variant="md-regular" color="secondary">on</wui-text>
|
|
586
|
-
<wui-image
|
|
587
|
-
src=${b(D.getNetworkImage(n))}
|
|
588
|
-
size="xs"
|
|
589
|
-
></wui-image>
|
|
590
|
-
<wui-text variant="md-regular" color="secondary">${n==null?void 0:n.name}</wui-text>
|
|
591
|
-
</wui-flex>
|
|
592
|
-
</wui-flex>
|
|
593
|
-
</wui-flex>
|
|
594
|
-
`}renderWallet(){return d`
|
|
595
|
-
<wui-flex
|
|
596
|
-
alignItems="flex-start"
|
|
597
|
-
justifyContent="space-between"
|
|
598
|
-
.padding=${["3","0","3","0"]}
|
|
599
|
-
>
|
|
600
|
-
<wui-text variant="lg-regular" color="secondary">Wallet</wui-text>
|
|
601
|
-
|
|
602
|
-
${this.renderWalletText()}
|
|
603
|
-
</wui-flex>
|
|
604
|
-
`}renderWalletText(){var i;const{image:e}=this.getWalletProperties({namespace:this.namespace}),{address:n}=this.caipAddress?I.parseCaipAddress(this.caipAddress):{},s=(i=this.selectedExchange)==null?void 0:i.name;return this.selectedExchange?d`
|
|
605
|
-
<wui-flex alignItems="center" justifyContent="flex-end" gap="1">
|
|
606
|
-
<wui-text variant="lg-regular" color="primary">${s}</wui-text>
|
|
607
|
-
<wui-image src=${b(this.selectedExchange.imageUrl)} size="mdl"></wui-image>
|
|
608
|
-
</wui-flex>
|
|
609
|
-
`:d`
|
|
610
|
-
<wui-flex alignItems="center" justifyContent="flex-end" gap="1">
|
|
611
|
-
<wui-text variant="lg-regular" color="primary">
|
|
612
|
-
${Nt.getTruncateString({string:this.profileName||n||s||"",charsStart:this.profileName?16:4,charsEnd:this.profileName?0:6,truncate:this.profileName?"end":"middle"})}
|
|
613
|
-
</wui-text>
|
|
614
|
-
|
|
615
|
-
<wui-image src=${b(e)} size="mdl"></wui-image>
|
|
616
|
-
</wui-flex>
|
|
617
|
-
`}getStepsWithStatus(){return this.quoteStatus==="failure"||this.quoteStatus==="timeout"||this.quoteStatus==="refund"?it.map(n=>({...n,status:"failed"})):it.map(n=>{const i=(Nn[n.id]??[]).includes(this.quoteStatus)?"completed":"pending";return{...n,status:i}})}renderStep({title:e,icon:n,status:s}){return d`
|
|
618
|
-
<wui-flex alignItems="center" gap="3">
|
|
619
|
-
<wui-flex justifyContent="center" alignItems="center" class="step-icon-container">
|
|
620
|
-
<wui-icon name=${n} color="default" size="mdl"></wui-icon>
|
|
621
|
-
|
|
622
|
-
<wui-flex alignItems="center" justifyContent="center" class=${mt({"step-icon-box":!0,success:s==="completed"})}>
|
|
623
|
-
${this.renderStatusIndicator(s)}
|
|
624
|
-
</wui-flex>
|
|
625
|
-
</wui-flex>
|
|
626
|
-
|
|
627
|
-
<wui-text variant="md-regular" color="primary">${e}</wui-text>
|
|
628
|
-
</wui-flex>
|
|
629
|
-
`}renderStatusIndicator(e){return e==="completed"?d`<wui-icon size="sm" color="success" name="checkmark"></wui-icon>`:e==="failed"?d`<wui-icon size="sm" color="error" name="close"></wui-icon>`:e==="pending"?d`<wui-loading-spinner color="accent-primary" size="sm"></wui-loading-spinner>`:null}startPolling(){this.pollingInterval||(this.fetchQuoteStatus(),this.pollingInterval=setInterval(()=>{this.fetchQuoteStatus()},vn))}stopPolling(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=null)}async fetchQuoteStatus(){const e=u.state.requestId;if(!e||rt.includes(this.quoteStatus))this.stopPolling();else try{await u.fetchQuoteStatus({requestId:e}),rt.includes(this.quoteStatus)&&this.stopPolling()}catch{this.stopPolling()}}initializeNamespace(){var n,s;const e=w.state.activeChain;this.namespace=e,this.caipAddress=(n=w.getAccountData(e))==null?void 0:n.caipAddress,this.profileName=((s=w.getAccountData(e))==null?void 0:s.profileName)??null,this.unsubscribe.push(w.subscribeChainProp("accountState",i=>{this.caipAddress=i==null?void 0:i.caipAddress,this.profileName=(i==null?void 0:i.profileName)??null},e))}getWalletProperties({namespace:e}){if(!e)return{name:void 0,image:void 0};const n=this.activeConnectorIds[e];if(!n)return{name:void 0,image:void 0};const s=R.getConnector({id:n,namespace:e});if(!s)return{name:void 0,image:void 0};const i=D.getConnectorImage(s);return{name:s.name,image:i}}};U.styles=_n;j([f()],U.prototype,"paymentAsset",void 0);j([f()],U.prototype,"quoteStatus",void 0);j([f()],U.prototype,"quote",void 0);j([f()],U.prototype,"amount",void 0);j([f()],U.prototype,"namespace",void 0);j([f()],U.prototype,"caipAddress",void 0);j([f()],U.prototype,"profileName",void 0);j([f()],U.prototype,"activeConnectorIds",void 0);j([f()],U.prototype,"selectedExchange",void 0);U=j([F("w3m-pay-loading-view")],U);const Tn=vt`
|
|
630
|
-
:host {
|
|
631
|
-
display: block;
|
|
632
|
-
}
|
|
633
|
-
`;var $n=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let Oe=class extends W{render(){return d`
|
|
634
|
-
<wui-flex flexDirection="column" gap="4">
|
|
635
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
636
|
-
<wui-text variant="md-regular" color="secondary">Pay</wui-text>
|
|
637
|
-
<wui-shimmer width="60px" height="16px" borderRadius="4xs" variant="light"></wui-shimmer>
|
|
638
|
-
</wui-flex>
|
|
639
|
-
|
|
640
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
641
|
-
<wui-text variant="md-regular" color="secondary">Network Fee</wui-text>
|
|
642
|
-
|
|
643
|
-
<wui-flex flexDirection="column" alignItems="flex-end" gap="2">
|
|
644
|
-
<wui-shimmer
|
|
645
|
-
width="75px"
|
|
646
|
-
height="16px"
|
|
647
|
-
borderRadius="4xs"
|
|
648
|
-
variant="light"
|
|
649
|
-
></wui-shimmer>
|
|
650
|
-
|
|
651
|
-
<wui-flex alignItems="center" gap="01">
|
|
652
|
-
<wui-shimmer width="14px" height="14px" rounded variant="light"></wui-shimmer>
|
|
653
|
-
<wui-shimmer
|
|
654
|
-
width="49px"
|
|
655
|
-
height="14px"
|
|
656
|
-
borderRadius="4xs"
|
|
657
|
-
variant="light"
|
|
658
|
-
></wui-shimmer>
|
|
659
|
-
</wui-flex>
|
|
660
|
-
</wui-flex>
|
|
661
|
-
</wui-flex>
|
|
662
|
-
|
|
663
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
664
|
-
<wui-text variant="md-regular" color="secondary">Service Fee</wui-text>
|
|
665
|
-
<wui-shimmer width="75px" height="16px" borderRadius="4xs" variant="light"></wui-shimmer>
|
|
666
|
-
</wui-flex>
|
|
667
|
-
</wui-flex>
|
|
668
|
-
`}};Oe.styles=[Tn];Oe=$n([F("w3m-pay-fees-skeleton")],Oe);const Pn=G`
|
|
669
|
-
:host {
|
|
670
|
-
display: block;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
wui-image {
|
|
674
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
675
|
-
}
|
|
676
|
-
`;var ft=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let xe=class extends W{constructor(){super(),this.unsubscribe=[],this.quote=u.state.quote,this.unsubscribe.push(u.subscribeKey("quote",e=>this.quote=e))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){var n,s,i;const e=S.formatNumber(((n=this.quote)==null?void 0:n.origin.amount)||"0",{decimals:((s=this.quote)==null?void 0:s.origin.currency.metadata.decimals)??0,round:6}).toString();return d`
|
|
677
|
-
<wui-flex flexDirection="column" gap="4">
|
|
678
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
679
|
-
<wui-text variant="md-regular" color="secondary">Pay</wui-text>
|
|
680
|
-
<wui-text variant="md-regular" color="primary">
|
|
681
|
-
${e} ${((i=this.quote)==null?void 0:i.origin.currency.metadata.symbol)||"Unknown"}
|
|
682
|
-
</wui-text>
|
|
683
|
-
</wui-flex>
|
|
684
|
-
|
|
685
|
-
${this.quote&&this.quote.fees.length>0?this.quote.fees.map(r=>this.renderFee(r)):null}
|
|
686
|
-
</wui-flex>
|
|
687
|
-
`}renderFee(e){const n=e.id==="network",s=S.formatNumber(e.amount||"0",{decimals:e.currency.metadata.decimals??0,round:6}).toString();if(n){const r=w.getAllRequestedCaipNetworks().find(o=>O.isLowerCaseMatch(o.caipNetworkId,e.currency.network));return d`
|
|
688
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
689
|
-
<wui-text variant="md-regular" color="secondary">${e.label}</wui-text>
|
|
690
|
-
|
|
691
|
-
<wui-flex flexDirection="column" alignItems="flex-end" gap="2">
|
|
692
|
-
<wui-text variant="md-regular" color="primary">
|
|
693
|
-
${s} ${e.currency.metadata.symbol||"Unknown"}
|
|
694
|
-
</wui-text>
|
|
695
|
-
|
|
696
|
-
<wui-flex alignItems="center" gap="01">
|
|
697
|
-
<wui-image
|
|
698
|
-
src=${b(D.getNetworkImage(r))}
|
|
699
|
-
size="xs"
|
|
700
|
-
></wui-image>
|
|
701
|
-
<wui-text variant="sm-regular" color="secondary">
|
|
702
|
-
${(r==null?void 0:r.name)||"Unknown"}
|
|
703
|
-
</wui-text>
|
|
704
|
-
</wui-flex>
|
|
705
|
-
</wui-flex>
|
|
706
|
-
</wui-flex>
|
|
707
|
-
`}return d`
|
|
708
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
709
|
-
<wui-text variant="md-regular" color="secondary">${e.label}</wui-text>
|
|
710
|
-
<wui-text variant="md-regular" color="primary">
|
|
711
|
-
${s} ${e.currency.metadata.symbol||"Unknown"}
|
|
712
|
-
</wui-text>
|
|
713
|
-
</wui-flex>
|
|
714
|
-
`}};xe.styles=[Pn];ft([f()],xe.prototype,"quote",void 0);xe=ft([F("w3m-pay-fees")],xe);const Sn=G`
|
|
715
|
-
:host {
|
|
716
|
-
display: block;
|
|
717
|
-
width: 100%;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
.disabled-container {
|
|
721
|
-
padding: ${({spacing:t})=>t[2]};
|
|
722
|
-
min-height: 168px;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
wui-icon {
|
|
726
|
-
width: ${({spacing:t})=>t[8]};
|
|
727
|
-
height: ${({spacing:t})=>t[8]};
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
wui-flex > wui-text {
|
|
731
|
-
max-width: 273px;
|
|
732
|
-
}
|
|
733
|
-
`;var gt=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let be=class extends W{constructor(){super(),this.unsubscribe=[],this.selectedExchange=u.state.selectedExchange,this.unsubscribe.push(u.subscribeKey("selectedExchange",e=>this.selectedExchange=e))}disconnectedCallback(){this.unsubscribe.forEach(e=>e())}render(){const e=!!this.selectedExchange;return d`
|
|
734
|
-
<wui-flex
|
|
735
|
-
flexDirection="column"
|
|
736
|
-
alignItems="center"
|
|
737
|
-
justifyContent="center"
|
|
738
|
-
gap="3"
|
|
739
|
-
class="disabled-container"
|
|
740
|
-
>
|
|
741
|
-
<wui-icon name="coins" color="default" size="inherit"></wui-icon>
|
|
742
|
-
|
|
743
|
-
<wui-text variant="md-regular" color="primary" align="center">
|
|
744
|
-
You don't have enough funds to complete this transaction
|
|
745
|
-
</wui-text>
|
|
746
|
-
|
|
747
|
-
${e?null:d`<wui-button
|
|
748
|
-
size="md"
|
|
749
|
-
variant="neutral-secondary"
|
|
750
|
-
@click=${this.dispatchConnectOtherWalletEvent.bind(this)}
|
|
751
|
-
>Connect other wallet</wui-button
|
|
752
|
-
>`}
|
|
753
|
-
</wui-flex>
|
|
754
|
-
`}dispatchConnectOtherWalletEvent(){this.dispatchEvent(new CustomEvent("connectOtherWallet",{detail:!0,bubbles:!0,composed:!0}))}};be.styles=[Sn];gt([P({type:Array})],be.prototype,"selectedExchange",void 0);be=gt([F("w3m-pay-options-empty")],be);const Cn=G`
|
|
755
|
-
:host {
|
|
756
|
-
display: block;
|
|
757
|
-
width: 100%;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
.pay-options-container {
|
|
761
|
-
max-height: 196px;
|
|
762
|
-
overflow-y: auto;
|
|
763
|
-
overflow-x: hidden;
|
|
764
|
-
scrollbar-width: none;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
.pay-options-container::-webkit-scrollbar {
|
|
768
|
-
display: none;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
.pay-option-container {
|
|
772
|
-
border-radius: ${({borderRadius:t})=>t[4]};
|
|
773
|
-
padding: ${({spacing:t})=>t[3]};
|
|
774
|
-
min-height: 60px;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
.token-images-container {
|
|
778
|
-
position: relative;
|
|
779
|
-
justify-content: center;
|
|
780
|
-
align-items: center;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
.chain-image {
|
|
784
|
-
position: absolute;
|
|
785
|
-
bottom: -3px;
|
|
786
|
-
right: -5px;
|
|
787
|
-
border: 2px solid ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
788
|
-
}
|
|
789
|
-
`;var kn=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};let Ue=class extends W{render(){return d`
|
|
790
|
-
<wui-flex flexDirection="column" gap="2" class="pay-options-container">
|
|
791
|
-
${this.renderOptionEntry()} ${this.renderOptionEntry()} ${this.renderOptionEntry()}
|
|
792
|
-
</wui-flex>
|
|
793
|
-
`}renderOptionEntry(){return d`
|
|
794
|
-
<wui-flex
|
|
795
|
-
alignItems="center"
|
|
796
|
-
justifyContent="space-between"
|
|
797
|
-
gap="2"
|
|
798
|
-
class="pay-option-container"
|
|
799
|
-
>
|
|
800
|
-
<wui-flex alignItems="center" gap="2">
|
|
801
|
-
<wui-flex class="token-images-container">
|
|
802
|
-
<wui-shimmer
|
|
803
|
-
width="32px"
|
|
804
|
-
height="32px"
|
|
805
|
-
rounded
|
|
806
|
-
variant="light"
|
|
807
|
-
class="token-image"
|
|
808
|
-
></wui-shimmer>
|
|
809
|
-
<wui-shimmer
|
|
810
|
-
width="16px"
|
|
811
|
-
height="16px"
|
|
812
|
-
rounded
|
|
813
|
-
variant="light"
|
|
814
|
-
class="chain-image"
|
|
815
|
-
></wui-shimmer>
|
|
816
|
-
</wui-flex>
|
|
817
|
-
|
|
818
|
-
<wui-flex flexDirection="column" gap="1">
|
|
819
|
-
<wui-shimmer
|
|
820
|
-
width="74px"
|
|
821
|
-
height="16px"
|
|
822
|
-
borderRadius="4xs"
|
|
823
|
-
variant="light"
|
|
824
|
-
></wui-shimmer>
|
|
825
|
-
<wui-shimmer
|
|
826
|
-
width="46px"
|
|
827
|
-
height="14px"
|
|
828
|
-
borderRadius="4xs"
|
|
829
|
-
variant="light"
|
|
830
|
-
></wui-shimmer>
|
|
831
|
-
</wui-flex>
|
|
832
|
-
</wui-flex>
|
|
833
|
-
</wui-flex>
|
|
834
|
-
`}};Ue.styles=[Cn];Ue=kn([F("w3m-pay-options-skeleton")],Ue);const Rn=G`
|
|
835
|
-
:host {
|
|
836
|
-
display: block;
|
|
837
|
-
width: 100%;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
.pay-options-container {
|
|
841
|
-
max-height: 196px;
|
|
842
|
-
overflow-y: auto;
|
|
843
|
-
overflow-x: hidden;
|
|
844
|
-
scrollbar-width: none;
|
|
845
|
-
mask-image: var(--options-mask-image);
|
|
846
|
-
-webkit-mask-image: var(--options-mask-image);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
.pay-options-container::-webkit-scrollbar {
|
|
850
|
-
display: none;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
.pay-option-container {
|
|
854
|
-
cursor: pointer;
|
|
855
|
-
border-radius: ${({borderRadius:t})=>t[4]};
|
|
856
|
-
padding: ${({spacing:t})=>t[3]};
|
|
857
|
-
transition: background-color ${({durations:t})=>t.lg}
|
|
858
|
-
${({easings:t})=>t["ease-out-power-1"]};
|
|
859
|
-
will-change: background-color;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
.token-images-container {
|
|
863
|
-
position: relative;
|
|
864
|
-
justify-content: center;
|
|
865
|
-
align-items: center;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
.token-image {
|
|
869
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
870
|
-
width: 32px;
|
|
871
|
-
height: 32px;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
.chain-image {
|
|
875
|
-
position: absolute;
|
|
876
|
-
width: 16px;
|
|
877
|
-
height: 16px;
|
|
878
|
-
bottom: -3px;
|
|
879
|
-
right: -5px;
|
|
880
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
881
|
-
border: 2px solid ${({tokens:t})=>t.theme.backgroundPrimary};
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
@media (hover: hover) and (pointer: fine) {
|
|
885
|
-
.pay-option-container:hover {
|
|
886
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
`;var _e=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};const On=300;let ie=class extends W{constructor(){super(),this.unsubscribe=[],this.options=[],this.selectedPaymentAsset=null}disconnectedCallback(){var n,s;this.unsubscribe.forEach(i=>i()),(n=this.resizeObserver)==null||n.disconnect();const e=(s=this.shadowRoot)==null?void 0:s.querySelector(".pay-options-container");e==null||e.removeEventListener("scroll",this.handleOptionsListScroll.bind(this))}firstUpdated(){var n,s;const e=(n=this.shadowRoot)==null?void 0:n.querySelector(".pay-options-container");e&&(requestAnimationFrame(this.handleOptionsListScroll.bind(this)),e==null||e.addEventListener("scroll",this.handleOptionsListScroll.bind(this)),this.resizeObserver=new ResizeObserver(()=>{this.handleOptionsListScroll()}),(s=this.resizeObserver)==null||s.observe(e),this.handleOptionsListScroll())}render(){return d`
|
|
890
|
-
<wui-flex flexDirection="column" gap="2" class="pay-options-container">
|
|
891
|
-
${this.options.map(e=>this.payOptionTemplate(e))}
|
|
892
|
-
</wui-flex>
|
|
893
|
-
`}payOptionTemplate(e){var C,k;const{network:n,metadata:s,asset:i,amount:r="0"}=e,c=w.getAllRequestedCaipNetworks().find(te=>te.caipNetworkId===n),l=`${n}:${i}`,m=`${(C=this.selectedPaymentAsset)==null?void 0:C.network}:${(k=this.selectedPaymentAsset)==null?void 0:k.asset}`,y=l===m,g=S.bigNumber(r,{safe:!0}),v=g.gt(0);return d`
|
|
894
|
-
<wui-flex
|
|
895
|
-
alignItems="center"
|
|
896
|
-
justifyContent="space-between"
|
|
897
|
-
gap="2"
|
|
898
|
-
@click=${()=>{var te;return(te=this.onSelect)==null?void 0:te.call(this,e)}}
|
|
899
|
-
class="pay-option-container"
|
|
900
|
-
>
|
|
901
|
-
<wui-flex alignItems="center" gap="2">
|
|
902
|
-
<wui-flex class="token-images-container">
|
|
903
|
-
<wui-image
|
|
904
|
-
src=${b(s.logoURI)}
|
|
905
|
-
class="token-image"
|
|
906
|
-
size="3xl"
|
|
907
|
-
></wui-image>
|
|
908
|
-
<wui-image
|
|
909
|
-
src=${b(D.getNetworkImage(c))}
|
|
910
|
-
class="chain-image"
|
|
911
|
-
size="md"
|
|
912
|
-
></wui-image>
|
|
913
|
-
</wui-flex>
|
|
914
|
-
|
|
915
|
-
<wui-flex flexDirection="column" gap="1">
|
|
916
|
-
<wui-text variant="lg-regular" color="primary">${s.symbol}</wui-text>
|
|
917
|
-
${v?d`<wui-text variant="sm-regular" color="secondary">
|
|
918
|
-
${g.round(6).toString()} ${s.symbol}
|
|
919
|
-
</wui-text>`:null}
|
|
920
|
-
</wui-flex>
|
|
921
|
-
</wui-flex>
|
|
922
|
-
|
|
923
|
-
${y?d`<wui-icon name="checkmark" size="md" color="success"></wui-icon>`:null}
|
|
924
|
-
</wui-flex>
|
|
925
|
-
`}handleOptionsListScroll(){var s;const e=(s=this.shadowRoot)==null?void 0:s.querySelector(".pay-options-container");if(!e)return;e.scrollHeight>On?(e.style.setProperty("--options-mask-image",`linear-gradient(
|
|
926
|
-
to bottom,
|
|
927
|
-
rgba(0, 0, 0, calc(1 - var(--options-scroll--top-opacity))) 0px,
|
|
928
|
-
rgba(200, 200, 200, calc(1 - var(--options-scroll--top-opacity))) 1px,
|
|
929
|
-
black 50px,
|
|
930
|
-
black calc(100% - 50px),
|
|
931
|
-
rgba(155, 155, 155, calc(1 - var(--options-scroll--bottom-opacity))) calc(100% - 1px),
|
|
932
|
-
rgba(0, 0, 0, calc(1 - var(--options-scroll--bottom-opacity))) 100%
|
|
933
|
-
)`),e.style.setProperty("--options-scroll--top-opacity",He.interpolate([0,50],[0,1],e.scrollTop).toString()),e.style.setProperty("--options-scroll--bottom-opacity",He.interpolate([0,50],[0,1],e.scrollHeight-e.scrollTop-e.offsetHeight).toString())):(e.style.setProperty("--options-mask-image","none"),e.style.setProperty("--options-scroll--top-opacity","0"),e.style.setProperty("--options-scroll--bottom-opacity","0"))}};ie.styles=[Rn];_e([P({type:Array})],ie.prototype,"options",void 0);_e([P()],ie.prototype,"selectedPaymentAsset",void 0);_e([P()],ie.prototype,"onSelect",void 0);ie=_e([F("w3m-pay-options")],ie);const Un=G`
|
|
934
|
-
.payment-methods-container {
|
|
935
|
-
background-color: ${({tokens:t})=>t.theme.foregroundPrimary};
|
|
936
|
-
border-top-right-radius: ${({borderRadius:t})=>t[5]};
|
|
937
|
-
border-top-left-radius: ${({borderRadius:t})=>t[5]};
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
.pay-options-container {
|
|
941
|
-
background-color: ${({tokens:t})=>t.theme.foregroundSecondary};
|
|
942
|
-
border-radius: ${({borderRadius:t})=>t[5]};
|
|
943
|
-
padding: ${({spacing:t})=>t[1]};
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
w3m-tooltip-trigger {
|
|
947
|
-
display: flex;
|
|
948
|
-
align-items: center;
|
|
949
|
-
justify-content: center;
|
|
950
|
-
max-width: fit-content;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
wui-image {
|
|
954
|
-
border-radius: ${({borderRadius:t})=>t.round};
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
w3m-pay-options.disabled {
|
|
958
|
-
opacity: 0.5;
|
|
959
|
-
pointer-events: none;
|
|
960
|
-
}
|
|
961
|
-
`;var N=function(t,e,n,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,s);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);return i>3&&r&&Object.defineProperty(e,n,r),r};const me={eip155:"ethereum",solana:"solana",bip122:"bitcoin",ton:"ton"},Ln={eip155:{icon:me.eip155,label:"EVM"},solana:{icon:me.solana,label:"Solana"},bip122:{icon:me.bip122,label:"Bitcoin"},ton:{icon:me.ton,label:"Ton"}};let E=class extends W{constructor(){super(),this.unsubscribe=[],this.profileName=null,this.paymentAsset=u.state.paymentAsset,this.namespace=void 0,this.caipAddress=void 0,this.amount=u.state.amount,this.recipient=u.state.recipient,this.activeConnectorIds=R.state.activeConnectorIds,this.selectedPaymentAsset=u.state.selectedPaymentAsset,this.selectedExchange=u.state.selectedExchange,this.isFetchingQuote=u.state.isFetchingQuote,this.quoteError=u.state.quoteError,this.quote=u.state.quote,this.isFetchingTokenBalances=u.state.isFetchingTokenBalances,this.tokenBalances=u.state.tokenBalances,this.isPaymentInProgress=u.state.isPaymentInProgress,this.exchangeUrlForQuote=u.state.exchangeUrlForQuote,this.completedTransactionsCount=0,this.unsubscribe.push(u.subscribeKey("paymentAsset",e=>this.paymentAsset=e)),this.unsubscribe.push(u.subscribeKey("tokenBalances",e=>this.onTokenBalancesChanged(e))),this.unsubscribe.push(u.subscribeKey("isFetchingTokenBalances",e=>this.isFetchingTokenBalances=e)),this.unsubscribe.push(R.subscribeKey("activeConnectorIds",e=>this.activeConnectorIds=e)),this.unsubscribe.push(u.subscribeKey("selectedPaymentAsset",e=>this.selectedPaymentAsset=e)),this.unsubscribe.push(u.subscribeKey("isFetchingQuote",e=>this.isFetchingQuote=e)),this.unsubscribe.push(u.subscribeKey("quoteError",e=>this.quoteError=e)),this.unsubscribe.push(u.subscribeKey("quote",e=>this.quote=e)),this.unsubscribe.push(u.subscribeKey("amount",e=>this.amount=e)),this.unsubscribe.push(u.subscribeKey("recipient",e=>this.recipient=e)),this.unsubscribe.push(u.subscribeKey("isPaymentInProgress",e=>this.isPaymentInProgress=e)),this.unsubscribe.push(u.subscribeKey("selectedExchange",e=>this.selectedExchange=e)),this.unsubscribe.push(u.subscribeKey("exchangeUrlForQuote",e=>this.exchangeUrlForQuote=e)),this.resetQuoteState(),this.initializeNamespace(),this.fetchTokens()}disconnectedCallback(){super.disconnectedCallback(),this.resetAssetsState(),this.unsubscribe.forEach(e=>e())}updated(e){super.updated(e),e.has("selectedPaymentAsset")&&this.fetchQuote()}render(){return d`
|
|
962
|
-
<wui-flex flexDirection="column">
|
|
963
|
-
${this.profileTemplate()}
|
|
964
|
-
|
|
965
|
-
<wui-flex
|
|
966
|
-
flexDirection="column"
|
|
967
|
-
gap="4"
|
|
968
|
-
class="payment-methods-container"
|
|
969
|
-
.padding=${["4","4","5","4"]}
|
|
970
|
-
>
|
|
971
|
-
${this.paymentOptionsViewTemplate()} ${this.amountWithFeeTemplate()}
|
|
972
|
-
|
|
973
|
-
<wui-flex
|
|
974
|
-
alignItems="center"
|
|
975
|
-
justifyContent="space-between"
|
|
976
|
-
.padding=${["1","0","1","0"]}
|
|
977
|
-
>
|
|
978
|
-
<wui-separator></wui-separator>
|
|
979
|
-
</wui-flex>
|
|
980
|
-
|
|
981
|
-
${this.paymentActionsTemplate()}
|
|
982
|
-
</wui-flex>
|
|
983
|
-
</wui-flex>
|
|
984
|
-
`}profileTemplate(){var o,c;if(this.selectedExchange){const l=S.formatNumber((o=this.quote)==null?void 0:o.origin.amount,{decimals:((c=this.quote)==null?void 0:c.origin.currency.metadata.decimals)??0}).toString();return d`
|
|
985
|
-
<wui-flex
|
|
986
|
-
.padding=${["4","3","4","3"]}
|
|
987
|
-
alignItems="center"
|
|
988
|
-
justifyContent="space-between"
|
|
989
|
-
gap="2"
|
|
990
|
-
>
|
|
991
|
-
<wui-text variant="lg-regular" color="secondary">Paying with</wui-text>
|
|
992
|
-
|
|
993
|
-
${this.quote?d`<wui-text variant="lg-regular" color="primary">
|
|
994
|
-
${S.bigNumber(l,{safe:!0}).round(6).toString()}
|
|
995
|
-
${this.quote.origin.currency.metadata.symbol}
|
|
996
|
-
</wui-text>`:d`<wui-shimmer width="80px" height="18px" variant="light"></wui-shimmer>`}
|
|
997
|
-
</wui-flex>
|
|
998
|
-
`}const e=z.getPlainAddress(this.caipAddress)??"",{name:n,image:s}=this.getWalletProperties({namespace:this.namespace}),{icon:i,label:r}=Ln[this.namespace]??{};return d`
|
|
999
|
-
<wui-flex
|
|
1000
|
-
.padding=${["4","3","4","3"]}
|
|
1001
|
-
alignItems="center"
|
|
1002
|
-
justifyContent="space-between"
|
|
1003
|
-
gap="2"
|
|
1004
|
-
>
|
|
1005
|
-
<wui-wallet-switch
|
|
1006
|
-
profileName=${b(this.profileName)}
|
|
1007
|
-
address=${b(e)}
|
|
1008
|
-
imageSrc=${b(s)}
|
|
1009
|
-
alt=${b(n)}
|
|
1010
|
-
@click=${this.onConnectOtherWallet.bind(this)}
|
|
1011
|
-
data-testid="wui-wallet-switch"
|
|
1012
|
-
></wui-wallet-switch>
|
|
1013
|
-
|
|
1014
|
-
<wui-wallet-switch
|
|
1015
|
-
profileName=${b(r)}
|
|
1016
|
-
address=${b(e)}
|
|
1017
|
-
icon=${b(i)}
|
|
1018
|
-
iconSize="xs"
|
|
1019
|
-
.enableGreenCircle=${!1}
|
|
1020
|
-
alt=${b(r)}
|
|
1021
|
-
@click=${this.onConnectOtherWallet.bind(this)}
|
|
1022
|
-
data-testid="wui-wallet-switch"
|
|
1023
|
-
></wui-wallet-switch>
|
|
1024
|
-
</wui-flex>
|
|
1025
|
-
`}initializeNamespace(){var n,s;const e=w.state.activeChain;this.namespace=e,this.caipAddress=(n=w.getAccountData(e))==null?void 0:n.caipAddress,this.profileName=((s=w.getAccountData(e))==null?void 0:s.profileName)??null,this.unsubscribe.push(w.subscribeChainProp("accountState",i=>this.onAccountStateChanged(i),e))}async fetchTokens(){if(this.namespace){let e;if(this.caipAddress){const{chainId:n,chainNamespace:s}=I.parseCaipAddress(this.caipAddress),i=`${s}:${n}`;e=w.getAllRequestedCaipNetworks().find(o=>o.caipNetworkId===i)}await u.fetchTokens({caipAddress:this.caipAddress,caipNetwork:e,namespace:this.namespace})}}fetchQuote(){if(this.amount&&this.recipient&&this.selectedPaymentAsset&&this.paymentAsset){const{address:e}=this.caipAddress?I.parseCaipAddress(this.caipAddress):{};u.fetchQuote({amount:this.amount.toString(),address:e,sourceToken:this.selectedPaymentAsset,toToken:this.paymentAsset,recipient:this.recipient})}}getWalletProperties({namespace:e}){if(!e)return{name:void 0,image:void 0};const n=this.activeConnectorIds[e];if(!n)return{name:void 0,image:void 0};const s=R.getConnector({id:n,namespace:e});if(!s)return{name:void 0,image:void 0};const i=D.getConnectorImage(s);return{name:s.name,image:i}}paymentOptionsViewTemplate(){return d`
|
|
1026
|
-
<wui-flex flexDirection="column" gap="2">
|
|
1027
|
-
<wui-text variant="sm-regular" color="secondary">CHOOSE PAYMENT OPTION</wui-text>
|
|
1028
|
-
<wui-flex class="pay-options-container">${this.paymentOptionsTemplate()}</wui-flex>
|
|
1029
|
-
</wui-flex>
|
|
1030
|
-
`}paymentOptionsTemplate(){const e=this.getPaymentAssetFromTokenBalances();if(this.isFetchingTokenBalances)return d`<w3m-pay-options-skeleton></w3m-pay-options-skeleton>`;if(e.length===0)return d`<w3m-pay-options-empty
|
|
1031
|
-
@connectOtherWallet=${this.onConnectOtherWallet.bind(this)}
|
|
1032
|
-
></w3m-pay-options-empty>`;const n={disabled:this.isFetchingQuote};return d`<w3m-pay-options
|
|
1033
|
-
class=${mt(n)}
|
|
1034
|
-
.options=${e}
|
|
1035
|
-
.selectedPaymentAsset=${b(this.selectedPaymentAsset)}
|
|
1036
|
-
.onSelect=${this.onSelectedPaymentAssetChanged.bind(this)}
|
|
1037
|
-
></w3m-pay-options>`}amountWithFeeTemplate(){return this.isFetchingQuote||!this.selectedPaymentAsset||this.quoteError?d`<w3m-pay-fees-skeleton></w3m-pay-fees-skeleton>`:d`<w3m-pay-fees></w3m-pay-fees>`}paymentActionsTemplate(){var i,r,o;const e=this.isFetchingQuote||this.isFetchingTokenBalances,n=this.isFetchingQuote||this.isFetchingTokenBalances||!this.selectedPaymentAsset||!!this.quoteError,s=S.formatNumber(((i=this.quote)==null?void 0:i.origin.amount)??0,{decimals:((r=this.quote)==null?void 0:r.origin.currency.metadata.decimals)??0}).toString();return this.selectedExchange?e||n?d`
|
|
1038
|
-
<wui-shimmer width="100%" height="48px" variant="light" ?rounded=${!0}></wui-shimmer>
|
|
1039
|
-
`:d`<wui-button
|
|
1040
|
-
size="lg"
|
|
1041
|
-
fullWidth
|
|
1042
|
-
variant="accent-secondary"
|
|
1043
|
-
@click=${this.onPayWithExchange.bind(this)}
|
|
1044
|
-
>
|
|
1045
|
-
${`Continue in ${this.selectedExchange.name}`}
|
|
1046
|
-
|
|
1047
|
-
<wui-icon name="arrowRight" color="inherit" size="sm" slot="iconRight"></wui-icon>
|
|
1048
|
-
</wui-button>`:d`
|
|
1049
|
-
<wui-flex alignItems="center" justifyContent="space-between">
|
|
1050
|
-
<wui-flex flexDirection="column" gap="1">
|
|
1051
|
-
<wui-text variant="md-regular" color="secondary">Order Total</wui-text>
|
|
1052
|
-
|
|
1053
|
-
${e||n?d`<wui-shimmer width="58px" height="32px" variant="light"></wui-shimmer>`:d`<wui-flex alignItems="center" gap="01">
|
|
1054
|
-
<wui-text variant="h4-regular" color="primary">${Ae(s)}</wui-text>
|
|
1055
|
-
|
|
1056
|
-
<wui-text variant="lg-regular" color="secondary">
|
|
1057
|
-
${((o=this.quote)==null?void 0:o.origin.currency.metadata.symbol)||"Unknown"}
|
|
1058
|
-
</wui-text>
|
|
1059
|
-
</wui-flex>`}
|
|
1060
|
-
</wui-flex>
|
|
1061
|
-
|
|
1062
|
-
${this.actionButtonTemplate({isLoading:e,isDisabled:n})}
|
|
1063
|
-
</wui-flex>
|
|
1064
|
-
`}actionButtonTemplate(e){const n=$e(this.quote),{isLoading:s,isDisabled:i}=e;let r="Pay";return n.length>1&&this.completedTransactionsCount===0&&(r="Approve"),d`
|
|
1065
|
-
<wui-button
|
|
1066
|
-
size="lg"
|
|
1067
|
-
variant="accent-primary"
|
|
1068
|
-
?loading=${s||this.isPaymentInProgress}
|
|
1069
|
-
?disabled=${i||this.isPaymentInProgress}
|
|
1070
|
-
@click=${()=>{n.length>0?this.onSendTransactions():this.onTransfer()}}
|
|
1071
|
-
>
|
|
1072
|
-
${r}
|
|
1073
|
-
${s?null:d`<wui-icon
|
|
1074
|
-
name="arrowRight"
|
|
1075
|
-
color="inherit"
|
|
1076
|
-
size="sm"
|
|
1077
|
-
slot="iconRight"
|
|
1078
|
-
></wui-icon>`}
|
|
1079
|
-
</wui-button>
|
|
1080
|
-
`}getPaymentAssetFromTokenBalances(){return this.namespace?(this.tokenBalances[this.namespace]??[]).map(i=>{try{return ln(i)}catch{return null}}).filter(i=>!!i).filter(i=>{const{chainId:r}=I.parseCaipNetworkId(i.network),{chainId:o}=I.parseCaipNetworkId(this.paymentAsset.network);return O.isLowerCaseMatch(i.asset,this.paymentAsset.asset)?!0:this.selectedExchange?!O.isLowerCaseMatch(r.toString(),o.toString()):!0}):[]}onTokenBalancesChanged(e){this.tokenBalances=e;const[n]=this.getPaymentAssetFromTokenBalances();n&&u.setSelectedPaymentAsset(n)}async onConnectOtherWallet(){await R.connect(),await ue.open({view:"PayQuote"})}onAccountStateChanged(e){const{address:n}=this.caipAddress?I.parseCaipAddress(this.caipAddress):{};if(this.caipAddress=e==null?void 0:e.caipAddress,this.profileName=(e==null?void 0:e.profileName)??null,n){const{address:s}=this.caipAddress?I.parseCaipAddress(this.caipAddress):{};s?O.isLowerCaseMatch(s,n)||(this.resetAssetsState(),this.resetQuoteState(),this.fetchTokens()):ue.close()}}onSelectedPaymentAssetChanged(e){this.isFetchingQuote||u.setSelectedPaymentAsset(e)}async onTransfer(){var n,s,i;const e=ke(this.quote);if(e){if(!O.isLowerCaseMatch((n=this.selectedPaymentAsset)==null?void 0:n.asset,e.deposit.currency))throw new Error("Quote asset is not the same as the selected payment asset");const o=((s=this.selectedPaymentAsset)==null?void 0:s.amount)??"0",c=S.formatNumber(e.deposit.amount,{decimals:((i=this.selectedPaymentAsset)==null?void 0:i.metadata.decimals)??0}).toString();if(!S.bigNumber(o).gte(c)){H.showError("Insufficient funds");return}if(this.quote&&this.selectedPaymentAsset&&this.caipAddress&&this.namespace){const{address:m}=I.parseCaipAddress(this.caipAddress);await u.onTransfer({chainNamespace:this.namespace,fromAddress:m,toAddress:e.deposit.receiver,amount:c,paymentAsset:this.selectedPaymentAsset}),u.setRequestId(e.requestId),ce.push("PayLoading")}}}async onSendTransactions(){var o,c,l;const e=((o=this.selectedPaymentAsset)==null?void 0:o.amount)??"0",n=S.formatNumber(((c=this.quote)==null?void 0:c.origin.amount)??0,{decimals:((l=this.selectedPaymentAsset)==null?void 0:l.metadata.decimals)??0}).toString();if(!S.bigNumber(e).gte(n)){H.showError("Insufficient funds");return}const i=$e(this.quote),[r]=$e(this.quote,this.completedTransactionsCount);r&&this.namespace&&(await u.onSendTransaction({namespace:this.namespace,transactionStep:r}),this.completedTransactionsCount+=1,this.completedTransactionsCount===i.length&&(u.setRequestId(r.requestId),ce.push("PayLoading")))}onPayWithExchange(){if(this.exchangeUrlForQuote){const e=z.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!e)throw new Error("Could not create popup window");e.location.href=this.exchangeUrlForQuote;const n=ke(this.quote);n&&u.setRequestId(n.requestId),u.initiatePayment(),ce.push("PayLoading")}}resetAssetsState(){u.setSelectedPaymentAsset(null)}resetQuoteState(){u.resetQuoteState()}};E.styles=Un;N([f()],E.prototype,"profileName",void 0);N([f()],E.prototype,"paymentAsset",void 0);N([f()],E.prototype,"namespace",void 0);N([f()],E.prototype,"caipAddress",void 0);N([f()],E.prototype,"amount",void 0);N([f()],E.prototype,"recipient",void 0);N([f()],E.prototype,"activeConnectorIds",void 0);N([f()],E.prototype,"selectedPaymentAsset",void 0);N([f()],E.prototype,"selectedExchange",void 0);N([f()],E.prototype,"isFetchingQuote",void 0);N([f()],E.prototype,"quoteError",void 0);N([f()],E.prototype,"quote",void 0);N([f()],E.prototype,"isFetchingTokenBalances",void 0);N([f()],E.prototype,"tokenBalances",void 0);N([f()],E.prototype,"isPaymentInProgress",void 0);N([f()],E.prototype,"exchangeUrlForQuote",void 0);N([f()],E.prototype,"completedTransactionsCount",void 0);E=N([F("w3m-pay-quote-view")],E);export{h as A,u as P,B as W,p as a,U as b,E as c};
|