@dcl/governance-site 1.14.1-19766186141.commit-f68c9c1 → 1.14.1-19868047872.commit-71d0841

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.
@@ -1,4 +1,4 @@
1
- import{Q as it,U as rt,s as q,r as w,i as b,x as h,q as ot,m as d,K as p,V as at,d as x,h as Z}from"./core-1eadecee.js";import{_ as c}from"./index-76a72ce6.js";const W=".",S={getSpacingStyles(t,e){if(Array.isArray(t))return t[e]?`var(--apkt-spacing-${t[e]})`:void 0;if(typeof t=="string")return`var(--apkt-spacing-${t})`},getFormattedDate(t){return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(t)},formatCurrency(t=0,e={}){const r=Number(t);return isNaN(r)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2,...e}).format(r)},getHostName(t){try{return new URL(t).hostname}catch{return""}},getTruncateString({string:t,charsStart:e,charsEnd:r,truncate:o}){return t.length<=e+r?t:o==="end"?`${t.substring(0,e)}...`:o==="start"?`...${t.substring(t.length-r)}`:`${t.substring(0,Math.floor(e))}...${t.substring(t.length-Math.floor(r))}`},generateAvatarColors(t){const r=t.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),o=this.hexToRgb(r),a=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),n=100-3*Number(a==null?void 0:a.replace("px","")),s=`${n}% ${n}% at 65% 40%`,u=[];for(let v=0;v<5;v+=1){const E=this.tintColor(o,.15*v);u.push(`rgb(${E[0]}, ${E[1]}, ${E[2]})`)}return`
1
+ import{Q as it,U as rt,s as q,r as w,i as b,x as h,q as ot,m as d,K as p,V as at,d as x,h as Z}from"./core-5cc0ace3.js";import{_ as c}from"./index-29108636.js";const W=".",S={getSpacingStyles(t,e){if(Array.isArray(t))return t[e]?`var(--apkt-spacing-${t[e]})`:void 0;if(typeof t=="string")return`var(--apkt-spacing-${t})`},getFormattedDate(t){return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(t)},formatCurrency(t=0,e={}){const r=Number(t);return isNaN(r)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2,...e}).format(r)},getHostName(t){try{return new URL(t).hostname}catch{return""}},getTruncateString({string:t,charsStart:e,charsEnd:r,truncate:o}){return t.length<=e+r?t:o==="end"?`${t.substring(0,e)}...`:o==="start"?`...${t.substring(t.length-r)}`:`${t.substring(0,Math.floor(e))}...${t.substring(t.length-Math.floor(r))}`},generateAvatarColors(t){const r=t.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),o=this.hexToRgb(r),a=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),n=100-3*Number(a==null?void 0:a.replace("px","")),s=`${n}% ${n}% at 65% 40%`,u=[];for(let v=0;v<5;v+=1){const E=this.tintColor(o,.15*v);u.push(`rgb(${E[0]}, ${E[1]}, ${E[2]})`)}return`
2
2
  --local-color-1: ${u[0]};
3
3
  --local-color-2: ${u[1]};
4
4
  --local-color-3: ${u[2]};
@@ -1 +1 @@
1
- import{i as e}from"./index-76a72ce6.js";function t(){if(typeof WebSocket<"u")return WebSocket;if(typeof e.WebSocket<"u")return e.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}const n=t();export{n as WebSocket};
1
+ import{i as e}from"./index-29108636.js";function t(){if(typeof WebSocket<"u")return WebSocket;if(typeof e.WebSocket<"u")return e.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}const n=t();export{n as WebSocket};
@@ -1,4 +1,4 @@
1
- import{bx as Nr,k as xr,bu as Cr,e as H,c as be,by as Ce,g as Lr,bF as Ur}from"./index-76a72ce6.js";var Be={exports:{}},Me={},xe={},Qe;function Or(){if(Qe)return xe;Qe=1,xe.byteLength=i,xe.toByteArray=v,xe.fromByteArray=g;for(var T=[],w=[],M=typeof Uint8Array<"u"?Uint8Array:Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,E=b.length;L<E;++L)T[L]=b[L],w[b.charCodeAt(L)]=L;w["-".charCodeAt(0)]=62,w["_".charCodeAt(0)]=63;function y(_){var S=_.length;if(S%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var F=_.indexOf("=");F===-1&&(F=S);var x=F===S?0:4-F%4;return[F,x]}function i(_){var S=y(_),F=S[0],x=S[1];return(F+x)*3/4-x}function l(_,S,F){return(S+F)*3/4-F}function v(_){var S,F=y(_),x=F[0],u=F[1],p=new M(l(_,x,u)),C=0,N=u>0?x-4:x,I;for(I=0;I<N;I+=4)S=w[_.charCodeAt(I)]<<18|w[_.charCodeAt(I+1)]<<12|w[_.charCodeAt(I+2)]<<6|w[_.charCodeAt(I+3)],p[C++]=S>>16&255,p[C++]=S>>8&255,p[C++]=S&255;return u===2&&(S=w[_.charCodeAt(I)]<<2|w[_.charCodeAt(I+1)]>>4,p[C++]=S&255),u===1&&(S=w[_.charCodeAt(I)]<<10|w[_.charCodeAt(I+1)]<<4|w[_.charCodeAt(I+2)]>>2,p[C++]=S>>8&255,p[C++]=S&255),p}function m(_){return T[_>>18&63]+T[_>>12&63]+T[_>>6&63]+T[_&63]}function s(_,S,F){for(var x,u=[],p=S;p<F;p+=3)x=(_[p]<<16&16711680)+(_[p+1]<<8&65280)+(_[p+2]&255),u.push(m(x));return u.join("")}function g(_){for(var S,F=_.length,x=F%3,u=[],p=16383,C=0,N=F-x;C<N;C+=p)u.push(s(_,C,C+p>N?N:C+p));return x===1?(S=_[F-1],u.push(T[S>>2]+T[S<<4&63]+"==")):x===2&&(S=(_[F-2]<<8)+_[F-1],u.push(T[S>>10]+T[S>>4&63]+T[S<<2&63]+"=")),u.join("")}return xe}var Fe={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var er;function Dr(){return er||(er=1,Fe.read=function(T,w,M,b,L){var E,y,i=L*8-b-1,l=(1<<i)-1,v=l>>1,m=-7,s=M?L-1:0,g=M?-1:1,_=T[w+s];for(s+=g,E=_&(1<<-m)-1,_>>=-m,m+=i;m>0;E=E*256+T[w+s],s+=g,m-=8);for(y=E&(1<<-m)-1,E>>=-m,m+=b;m>0;y=y*256+T[w+s],s+=g,m-=8);if(E===0)E=1-v;else{if(E===l)return y?NaN:(_?-1:1)*(1/0);y=y+Math.pow(2,b),E=E-v}return(_?-1:1)*y*Math.pow(2,E-b)},Fe.write=function(T,w,M,b,L,E){var y,i,l,v=E*8-L-1,m=(1<<v)-1,s=m>>1,g=L===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=b?0:E-1,S=b?1:-1,F=w<0||w===0&&1/w<0?1:0;for(w=Math.abs(w),isNaN(w)||w===1/0?(i=isNaN(w)?1:0,y=m):(y=Math.floor(Math.log(w)/Math.LN2),w*(l=Math.pow(2,-y))<1&&(y--,l*=2),y+s>=1?w+=g/l:w+=g*Math.pow(2,1-s),w*l>=2&&(y++,l/=2),y+s>=m?(i=0,y=m):y+s>=1?(i=(w*l-1)*Math.pow(2,L),y=y+s):(i=w*Math.pow(2,s-1)*Math.pow(2,L),y=0));L>=8;T[M+_]=i&255,_+=S,i/=256,L-=8);for(y=y<<L|i,v+=L;v>0;T[M+_]=y&255,_+=S,y/=256,v-=8);T[M+_-S]|=F*128}),Fe}/*!
1
+ import{bx as Nr,k as xr,bu as Cr,e as H,c as be,by as Ce,g as Lr,bF as Ur}from"./index-29108636.js";var Be={exports:{}},Me={},xe={},Qe;function Or(){if(Qe)return xe;Qe=1,xe.byteLength=i,xe.toByteArray=v,xe.fromByteArray=g;for(var T=[],w=[],M=typeof Uint8Array<"u"?Uint8Array:Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,E=b.length;L<E;++L)T[L]=b[L],w[b.charCodeAt(L)]=L;w["-".charCodeAt(0)]=62,w["_".charCodeAt(0)]=63;function y(_){var S=_.length;if(S%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var F=_.indexOf("=");F===-1&&(F=S);var x=F===S?0:4-F%4;return[F,x]}function i(_){var S=y(_),F=S[0],x=S[1];return(F+x)*3/4-x}function l(_,S,F){return(S+F)*3/4-F}function v(_){var S,F=y(_),x=F[0],u=F[1],p=new M(l(_,x,u)),C=0,N=u>0?x-4:x,I;for(I=0;I<N;I+=4)S=w[_.charCodeAt(I)]<<18|w[_.charCodeAt(I+1)]<<12|w[_.charCodeAt(I+2)]<<6|w[_.charCodeAt(I+3)],p[C++]=S>>16&255,p[C++]=S>>8&255,p[C++]=S&255;return u===2&&(S=w[_.charCodeAt(I)]<<2|w[_.charCodeAt(I+1)]>>4,p[C++]=S&255),u===1&&(S=w[_.charCodeAt(I)]<<10|w[_.charCodeAt(I+1)]<<4|w[_.charCodeAt(I+2)]>>2,p[C++]=S>>8&255,p[C++]=S&255),p}function m(_){return T[_>>18&63]+T[_>>12&63]+T[_>>6&63]+T[_&63]}function s(_,S,F){for(var x,u=[],p=S;p<F;p+=3)x=(_[p]<<16&16711680)+(_[p+1]<<8&65280)+(_[p+2]&255),u.push(m(x));return u.join("")}function g(_){for(var S,F=_.length,x=F%3,u=[],p=16383,C=0,N=F-x;C<N;C+=p)u.push(s(_,C,C+p>N?N:C+p));return x===1?(S=_[F-1],u.push(T[S>>2]+T[S<<4&63]+"==")):x===2&&(S=(_[F-2]<<8)+_[F-1],u.push(T[S>>10]+T[S>>4&63]+T[S<<2&63]+"=")),u.join("")}return xe}var Fe={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var er;function Dr(){return er||(er=1,Fe.read=function(T,w,M,b,L){var E,y,i=L*8-b-1,l=(1<<i)-1,v=l>>1,m=-7,s=M?L-1:0,g=M?-1:1,_=T[w+s];for(s+=g,E=_&(1<<-m)-1,_>>=-m,m+=i;m>0;E=E*256+T[w+s],s+=g,m-=8);for(y=E&(1<<-m)-1,E>>=-m,m+=b;m>0;y=y*256+T[w+s],s+=g,m-=8);if(E===0)E=1-v;else{if(E===l)return y?NaN:(_?-1:1)*(1/0);y=y+Math.pow(2,b),E=E-v}return(_?-1:1)*y*Math.pow(2,E-b)},Fe.write=function(T,w,M,b,L,E){var y,i,l,v=E*8-L-1,m=(1<<v)-1,s=m>>1,g=L===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=b?0:E-1,S=b?1:-1,F=w<0||w===0&&1/w<0?1:0;for(w=Math.abs(w),isNaN(w)||w===1/0?(i=isNaN(w)?1:0,y=m):(y=Math.floor(Math.log(w)/Math.LN2),w*(l=Math.pow(2,-y))<1&&(y--,l*=2),y+s>=1?w+=g/l:w+=g*Math.pow(2,1-s),w*l>=2&&(y++,l/=2),y+s>=m?(i=0,y=m):y+s>=1?(i=(w*l-1)*Math.pow(2,L),y=y+s):(i=w*Math.pow(2,s-1)*Math.pow(2,L),y=0));L>=8;T[M+_]=i&255,_+=S,i/=256,L-=8);for(y=y<<L|i,v+=L;v>0;T[M+_]=y&255,_+=S,y/=256,v-=8);T[M+_-S]|=F*128}),Fe}/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1,4 +1,4 @@
1
- import{N as b,t as _e,w as Be,l as Te,u as Ue,v as ze,n as f,a as ye,y as Ye,C as he,c as z,S as v,R as p,z as Z,B as J,D as Xe,F as te,b as de,E as M,G as ue,I as pe,M as R,J as Fe,d as A,r as se,i as x,x as l,h as Le,K as me,g as ke,e as qe,L as Y,O as y,s as He,A as le,T as Qe,P as Ze}from"./core-1eadecee.js";import{c as T,n as h,o as O,r as m,U as je}from"./index-5333eb0e.js";import"./index-76a72ce6.js";import"./index-55ab6459.js";const j={getGasPriceInEther(e,t){const o=t*e;return Number(o)/1e18},getGasPriceInUSD(e,t,o){const n=j.getGasPriceInEther(t,o);return b.bigNumber(e).times(n).toNumber()},getPriceImpact({sourceTokenAmount:e,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:n}){const a=b.bigNumber(e).times(t),i=b.bigNumber(n).times(o);return a.minus(i).div(a).times(100).toNumber()},getMaxSlippage(e,t){const o=b.bigNumber(e).div(100);return b.multiply(t,o).toNumber()},getProviderFee(e,t=.0085){return b.bigNumber(e).times(t).toString()},isInsufficientNetworkTokenForGas(e,t){const o=t||"0";return b.bigNumber(e).eq(0)?!0:b.bigNumber(b.bigNumber(o)).gt(e)},isInsufficientSourceTokenForSwap(e,t,o){var i,s;const n=(s=(i=o==null?void 0:o.find(c=>c.address===t))==null?void 0:i.quantity)==null?void 0:s.numeric;return b.bigNumber(n||"0").lt(e)}},We=15e4,Je=6,S={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:Te.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},r=_e({...S}),we={state:r,subscribe(e){return Ue(r,()=>e(r))},subscribeKey(e,t){return ze(r,e,t)},getParams(){var d,w,g,P,E,F,L,H,Q;const e=f.state.activeChain,t=((d=f.getAccountData(e))==null?void 0:d.caipAddress)??f.state.activeCaipAddress,o=ye.getPlainAddress(t),n=Ye(),a=he.getConnectorId(f.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const i=!((w=r.toToken)!=null&&w.address)||!((g=r.toToken)!=null&&g.decimals),s=!((P=r.sourceToken)!=null&&P.address)||!((E=r.sourceToken)!=null&&E.decimals)||!b.bigNumber(r.sourceTokenAmount).gt(0),c=!r.sourceTokenAmount;return{networkAddress:n,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(F=r.sourceToken)==null?void 0:F.address,toTokenAddress:(L=r.toToken)==null?void 0:L.address,toTokenAmount:r.toTokenAmount,toTokenDecimals:(H=r.toToken)==null?void 0:H.decimals,sourceTokenAmount:r.sourceTokenAmount,sourceTokenDecimals:(Q=r.sourceToken)==null?void 0:Q.decimals,invalidToToken:i,invalidSourceToken:s,invalidSourceTokenAmount:c,availableToSwap:t&&!i&&!s&&!c,isAuthConnector:a===z.CONNECTOR_ID.AUTH}},async setSourceToken(e){if(!e){r.sourceToken=e,r.sourceTokenAmount="",r.sourceTokenPriceInUSD=0;return}r.sourceToken=e,await u.setTokenPrice(e.address,"sourceToken")},setSourceTokenAmount(e){r.sourceTokenAmount=e},async setToToken(e){if(!e){r.toToken=e,r.toTokenAmount="",r.toTokenPriceInUSD=0;return}r.toToken=e,await u.setTokenPrice(e.address,"toToken")},setToTokenAmount(e){r.toTokenAmount=e?b.toFixed(e,Je):""},async setTokenPrice(e,t){let o=r.tokensPriceMap[e]||0;o||(r.loadingPrices=!0,o=await u.getAddressPrice(e)),t==="sourceToken"?r.sourceTokenPriceInUSD=o:t==="toToken"&&(r.toTokenPriceInUSD=o),r.loadingPrices&&(r.loadingPrices=!1),u.getParams().availableToSwap&&!r.switchingTokens&&u.swapTokens()},async switchTokens(){if(!(r.initializing||!r.initialized||r.switchingTokens)){r.switchingTokens=!0;try{const e=r.toToken?{...r.toToken}:void 0,t=r.sourceToken?{...r.sourceToken}:void 0,o=e&&r.toTokenAmount===""?"1":r.toTokenAmount;u.setSourceTokenAmount(o),u.setToTokenAmount(""),await u.setSourceToken(e),await u.setToToken(t),r.switchingTokens=!1,u.swapTokens()}catch(e){throw r.switchingTokens=!1,e}}},resetState(){r.myTokensWithBalance=S.myTokensWithBalance,r.tokensPriceMap=S.tokensPriceMap,r.initialized=S.initialized,r.initializing=S.initializing,r.switchingTokens=S.switchingTokens,r.sourceToken=S.sourceToken,r.sourceTokenAmount=S.sourceTokenAmount,r.sourceTokenPriceInUSD=S.sourceTokenPriceInUSD,r.toToken=S.toToken,r.toTokenAmount=S.toTokenAmount,r.toTokenPriceInUSD=S.toTokenPriceInUSD,r.networkPrice=S.networkPrice,r.networkTokenSymbol=S.networkTokenSymbol,r.networkBalanceInUSD=S.networkBalanceInUSD,r.inputError=S.inputError},resetValues(){var o;const{networkAddress:e}=u.getParams(),t=(o=r.tokens)==null?void 0:o.find(n=>n.address===e);u.setSourceToken(t),u.setToToken(void 0)},getApprovalLoadingState(){return r.loadingApprovalTransaction},clearError(){r.transactionError=void 0},async initializeState(){if(!r.initializing){if(r.initializing=!0,!r.initialized)try{await u.fetchTokens(),r.initialized=!0}catch{r.initialized=!1,v.showError("Failed to initialize swap"),p.goBack()}r.initializing=!1}},async fetchTokens(){var o;const{networkAddress:e}=u.getParams();await u.getNetworkTokenPrice(),await u.getMyTokensWithBalance();const t=(o=r.myTokensWithBalance)==null?void 0:o.find(n=>n.address===e);t&&(r.networkTokenSymbol=t.symbol,u.setSourceToken(t),u.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const e=(t=f.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(r.caipNetworkId===e&&r.tokens))try{r.tokensLoading=!0;const n=await Z.getTokenList(e);r.tokens=n,r.caipNetworkId=e,r.popularTokens=n.sort((d,w)=>d.symbol<w.symbol?-1:d.symbol>w.symbol?1:0);const i=(e&&((o=Te.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[e])||[]).map(d=>n.find(w=>w.symbol===d)).filter(d=>!!d),c=(Te.SWAP_SUGGESTED_TOKENS||[]).map(d=>n.find(w=>w.symbol===d)).filter(d=>!!d).filter(d=>!i.some(w=>w.address===d.address));r.suggestedTokens=[...i,...c]}catch{r.tokens=[],r.popularTokens=[],r.suggestedTokens=[]}finally{r.tokensLoading=!1}},async getAddressPrice(e){var d,w;const t=r.tokensPriceMap[e];if(t)return t;const o=await J.fetchTokenPrice({addresses:[e]}),n=(o==null?void 0:o.fungibles)||[],a=[...r.tokens||[],...r.myTokensWithBalance||[]],i=(d=a==null?void 0:a.find(g=>g.address===e))==null?void 0:d.symbol,s=((w=n.find(g=>g.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:w.price)||0,c=parseFloat(s.toString());return r.tokensPriceMap[e]=c,c},async getNetworkTokenPrice(){var a;const{networkAddress:e}=u.getParams(),o=(a=(await J.fetchTokenPrice({addresses:[e]}).catch(()=>(v.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:a[0],n=(o==null?void 0:o.price.toString())||"0";r.tokensPriceMap[e]=parseFloat(n),r.networkTokenSymbol=(o==null?void 0:o.symbol)||"",r.networkPrice=n},async getMyTokensWithBalance(e){const t=await Xe.getMyTokensWithBalance(e),o=Z.mapBalancesToSwapTokens(t);o&&(await u.getInitialGasPrice(),u.setBalances(o))},setBalances(e){const{networkAddress:t}=u.getParams(),o=f.state.activeCaipNetwork;if(!o)return;const n=e.find(a=>a.address===t);e.forEach(a=>{r.tokensPriceMap[a.address]=a.price||0}),r.myTokensWithBalance=e.filter(a=>a.address.startsWith(o.caipNetworkId)),r.networkBalanceInUSD=n?b.multiply(n.quantity.numeric,n.price).toString():"0"},async getInitialGasPrice(){var t,o;const e=await Z.fetchGasPrice();if(!e)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=f.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case z.CHAIN.SOLANA:return r.gasFee=e.standard??"0",r.gasPriceInUSD=b.multiply(e.standard,r.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(r.gasFee),gasPriceInUSD:Number(r.gasPriceInUSD)};case z.CHAIN.EVM:default:const n=e.standard??"0",a=BigInt(n),i=BigInt(We),s=j.getGasPriceInUSD(r.networkPrice,i,a);return r.gasFee=n,r.gasPriceInUSD=s,{gasPrice:a,gasPriceInUSD:s}}},async swapTokens(){var i,s,c;const e=(i=f.getAccountData())==null?void 0:i.address,t=r.sourceToken,o=r.toToken,n=b.bigNumber(r.sourceTokenAmount).gt(0);if(n||u.setToTokenAmount(""),!o||!t||r.loadingPrices||!n||!e)return;r.loadingQuote=!0;const a=b.bigNumber(r.sourceTokenAmount).times(10**t.decimals).round(0);try{const d=await J.fetchSwapQuote({userAddress:e,from:t.address,to:o.address,gasPrice:r.gasFee,amount:a.toString()});r.loadingQuote=!1;const w=(c=(s=d==null?void 0:d.quotes)==null?void 0:s[0])==null?void 0:c.toAmount;if(!w){te.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const g=b.bigNumber(w).div(10**o.decimals).toString();u.setToTokenAmount(g),u.hasInsufficientToken(r.sourceTokenAmount,t.address)?r.inputError="Insufficient balance":(r.inputError=void 0,u.setTransactionDetails())}catch(d){const w=await Z.handleSwapError(d);r.loadingQuote=!1,r.inputError=w||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:e,availableToSwap:t}=u.getParams(),o=r.sourceToken,n=r.toToken;if(!(!e||!t||!o||!n||r.loadingQuote))try{r.loadingBuildTransaction=!0;const a=await Z.fetchSwapAllowance({userAddress:e,tokenAddress:o.address,sourceTokenAmount:r.sourceTokenAmount,sourceTokenDecimals:o.decimals});let i;return a?i=await u.createSwapTransaction():i=await u.createAllowanceTransaction(),r.loadingBuildTransaction=!1,r.fetchError=!1,i}catch{p.goBack(),v.showError("Failed to check allowance"),r.loadingBuildTransaction=!1,r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:e,sourceTokenAddress:t,toTokenAddress:o}=u.getParams();if(!(!e||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const n=await J.generateApproveCalldata({from:t,to:o,userAddress:e}),a=ye.getPlainAddress(n.tx.from);if(!a)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:n.tx.data,to:a,gasPrice:BigInt(n.tx.eip155.gasPrice),value:BigInt(n.tx.value),toAmount:r.toTokenAmount};return r.swapTransaction=void 0,r.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{p.goBack(),v.showError("Failed to create approval transaction"),r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}}},async createSwapTransaction(){var s;const{networkAddress:e,fromCaipAddress:t,sourceTokenAmount:o}=u.getParams(),n=r.sourceToken,a=r.toToken;if(!t||!o||!n||!a)return;const i=(s=de.parseUnits(o,n.decimals))==null?void 0:s.toString();try{const c=await J.generateSwapCalldata({userAddress:t,from:n.address,to:a.address,amount:i,disableEstimate:!0}),d=n.address===e,w=BigInt(c.tx.eip155.gas),g=BigInt(c.tx.eip155.gasPrice),P=ye.getPlainAddress(c.tx.to);if(!P)throw new Error("SwapController:createSwapTransaction - address is required");const E={data:c.tx.data,to:P,gas:w,gasPrice:g,value:BigInt(d?i??"0":"0"),toAmount:r.toTokenAmount};return r.gasPriceInUSD=j.getGasPriceInUSD(r.networkPrice,w,g),r.approvalTransaction=void 0,r.swapTransaction=E,E}catch{p.goBack(),v.showError("Failed to create transaction"),r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){v.showLoading("Approve limit increase in your wallet"),p.replace("SwapPreview")},async sendTransactionForApproval(e){var a,i,s;const{fromAddress:t,isAuthConnector:o}=u.getParams();r.loadingApprovalTransaction=!0;const n="Approve limit increase in your wallet";o?p.pushTransactionStack({onSuccess:u.onEmbeddedWalletApprovalSuccess}):v.showLoading(n);try{await de.sendTransaction({address:t,to:e.to,data:e.data,value:e.value,chainNamespace:z.CHAIN.EVM}),await u.swapTokens(),await u.getTransaction(),r.approvalTransaction=void 0,r.loadingApprovalTransaction=!1}catch(c){const d=c;r.transactionError=d==null?void 0:d.displayMessage,r.loadingApprovalTransaction=!1,v.showError((d==null?void 0:d.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(d==null?void 0:d.displayMessage)||(d==null?void 0:d.message)||"Unknown",network:((a=f.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||"",swapFromToken:((i=u.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((s=u.state.toToken)==null?void 0:s.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(e){var s,c,d,w,g,P,E,F,L,H,Q,Ee;if(!e)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:n}=u.getParams();r.loadingTransaction=!0;const a=`Swapping ${(s=r.sourceToken)==null?void 0:s.symbol} to ${b.formatNumberToLocalString(o,3)} ${(c=r.toToken)==null?void 0:c.symbol}`,i=`Swapped ${(d=r.sourceToken)==null?void 0:d.symbol} to ${b.formatNumberToLocalString(o,3)} ${(w=r.toToken)==null?void 0:w.symbol}`;n?p.pushTransactionStack({onSuccess(){p.replace("Account"),v.showLoading(a),we.resetState()}}):v.showLoading("Confirm transaction in your wallet");try{const ve=[(g=r.sourceToken)==null?void 0:g.address,(P=r.toToken)==null?void 0:P.address].join(","),$=await de.sendTransaction({address:t,to:e.to,data:e.data,value:e.value,chainNamespace:z.CHAIN.EVM});return r.loadingTransaction=!1,v.showSuccess(i),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((E=f.state.activeCaipNetwork)==null?void 0:E.caipNetworkId)||"",swapFromToken:((F=u.state.sourceToken)==null?void 0:F.symbol)||"",swapToToken:((L=u.state.toToken)==null?void 0:L.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}}),we.resetState(),n||p.replace("Account"),we.getMyTokensWithBalance(ve),$}catch(ve){const $=ve;r.transactionError=$==null?void 0:$.displayMessage,r.loadingTransaction=!1,v.showError(($==null?void 0:$.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:($==null?void 0:$.displayMessage)||($==null?void 0:$.message)||"Unknown",network:((H=f.state.activeCaipNetwork)==null?void 0:H.caipNetworkId)||"",swapFromToken:((Q=u.state.sourceToken)==null?void 0:Q.symbol)||"",swapToToken:((Ee=u.state.toToken)==null?void 0:Ee.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(e,t){return j.isInsufficientSourceTokenForSwap(e,t,r.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:e,toTokenDecimals:t}=u.getParams();!e||!t||(r.gasPriceInUSD=j.getGasPriceInUSD(r.networkPrice,BigInt(r.gasFee),BigInt(We)),r.priceImpact=j.getPriceImpact({sourceTokenAmount:r.sourceTokenAmount,sourceTokenPriceInUSD:r.sourceTokenPriceInUSD,toTokenPriceInUSD:r.toTokenPriceInUSD,toTokenAmount:r.toTokenAmount}),r.maxSlippage=j.getMaxSlippage(r.slippage,r.toTokenAmount),r.providerFee=j.getProviderFee(r.sourceTokenAmount))}},u=Be(we),W=_e({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),et={state:W,subscribe(e){return Ue(W,()=>e(W))},subscribeKey(e,t){return ze(W,e,t)},showTooltip({message:e,triggerRect:t,variant:o}){W.open=!0,W.message=e,W.triggerRect=t,W.variant=o},hide(){W.open=!1,W.message="",W.triggerRect={width:0,height:0,top:0,left:0}}},ee=Be(et),Me={isUnsupportedChainView(){return p.state.view==="UnsupportedChain"||p.state.view==="SwitchNetwork"&&p.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){R.shake();return}if(await Fe.isSIWXCloseDisabled()){R.shake();return}(p.state.view==="DataCapture"||p.state.view==="DataCaptureOtpConfirm")&&de.disconnect(),R.close()}},tt=A`
1
+ import{N as b,t as _e,w as Be,l as Te,u as Ue,v as ze,n as f,a as ye,y as Ye,C as he,c as z,S as v,R as p,z as Z,B as J,D as Xe,F as te,b as de,E as M,G as ue,I as pe,M as R,J as Fe,d as A,r as se,i as x,x as l,h as Le,K as me,g as ke,e as qe,L as Y,O as y,s as He,A as le,T as Qe,P as Ze}from"./core-5cc0ace3.js";import{c as T,n as h,o as O,r as m,U as je}from"./index-dc54623c.js";import"./index-29108636.js";import"./index-a4cb946c.js";const j={getGasPriceInEther(e,t){const o=t*e;return Number(o)/1e18},getGasPriceInUSD(e,t,o){const n=j.getGasPriceInEther(t,o);return b.bigNumber(e).times(n).toNumber()},getPriceImpact({sourceTokenAmount:e,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:n}){const a=b.bigNumber(e).times(t),i=b.bigNumber(n).times(o);return a.minus(i).div(a).times(100).toNumber()},getMaxSlippage(e,t){const o=b.bigNumber(e).div(100);return b.multiply(t,o).toNumber()},getProviderFee(e,t=.0085){return b.bigNumber(e).times(t).toString()},isInsufficientNetworkTokenForGas(e,t){const o=t||"0";return b.bigNumber(e).eq(0)?!0:b.bigNumber(b.bigNumber(o)).gt(e)},isInsufficientSourceTokenForSwap(e,t,o){var i,s;const n=(s=(i=o==null?void 0:o.find(c=>c.address===t))==null?void 0:i.quantity)==null?void 0:s.numeric;return b.bigNumber(n||"0").lt(e)}},We=15e4,Je=6,S={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:Te.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},r=_e({...S}),we={state:r,subscribe(e){return Ue(r,()=>e(r))},subscribeKey(e,t){return ze(r,e,t)},getParams(){var d,w,g,P,E,F,L,H,Q;const e=f.state.activeChain,t=((d=f.getAccountData(e))==null?void 0:d.caipAddress)??f.state.activeCaipAddress,o=ye.getPlainAddress(t),n=Ye(),a=he.getConnectorId(f.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const i=!((w=r.toToken)!=null&&w.address)||!((g=r.toToken)!=null&&g.decimals),s=!((P=r.sourceToken)!=null&&P.address)||!((E=r.sourceToken)!=null&&E.decimals)||!b.bigNumber(r.sourceTokenAmount).gt(0),c=!r.sourceTokenAmount;return{networkAddress:n,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(F=r.sourceToken)==null?void 0:F.address,toTokenAddress:(L=r.toToken)==null?void 0:L.address,toTokenAmount:r.toTokenAmount,toTokenDecimals:(H=r.toToken)==null?void 0:H.decimals,sourceTokenAmount:r.sourceTokenAmount,sourceTokenDecimals:(Q=r.sourceToken)==null?void 0:Q.decimals,invalidToToken:i,invalidSourceToken:s,invalidSourceTokenAmount:c,availableToSwap:t&&!i&&!s&&!c,isAuthConnector:a===z.CONNECTOR_ID.AUTH}},async setSourceToken(e){if(!e){r.sourceToken=e,r.sourceTokenAmount="",r.sourceTokenPriceInUSD=0;return}r.sourceToken=e,await u.setTokenPrice(e.address,"sourceToken")},setSourceTokenAmount(e){r.sourceTokenAmount=e},async setToToken(e){if(!e){r.toToken=e,r.toTokenAmount="",r.toTokenPriceInUSD=0;return}r.toToken=e,await u.setTokenPrice(e.address,"toToken")},setToTokenAmount(e){r.toTokenAmount=e?b.toFixed(e,Je):""},async setTokenPrice(e,t){let o=r.tokensPriceMap[e]||0;o||(r.loadingPrices=!0,o=await u.getAddressPrice(e)),t==="sourceToken"?r.sourceTokenPriceInUSD=o:t==="toToken"&&(r.toTokenPriceInUSD=o),r.loadingPrices&&(r.loadingPrices=!1),u.getParams().availableToSwap&&!r.switchingTokens&&u.swapTokens()},async switchTokens(){if(!(r.initializing||!r.initialized||r.switchingTokens)){r.switchingTokens=!0;try{const e=r.toToken?{...r.toToken}:void 0,t=r.sourceToken?{...r.sourceToken}:void 0,o=e&&r.toTokenAmount===""?"1":r.toTokenAmount;u.setSourceTokenAmount(o),u.setToTokenAmount(""),await u.setSourceToken(e),await u.setToToken(t),r.switchingTokens=!1,u.swapTokens()}catch(e){throw r.switchingTokens=!1,e}}},resetState(){r.myTokensWithBalance=S.myTokensWithBalance,r.tokensPriceMap=S.tokensPriceMap,r.initialized=S.initialized,r.initializing=S.initializing,r.switchingTokens=S.switchingTokens,r.sourceToken=S.sourceToken,r.sourceTokenAmount=S.sourceTokenAmount,r.sourceTokenPriceInUSD=S.sourceTokenPriceInUSD,r.toToken=S.toToken,r.toTokenAmount=S.toTokenAmount,r.toTokenPriceInUSD=S.toTokenPriceInUSD,r.networkPrice=S.networkPrice,r.networkTokenSymbol=S.networkTokenSymbol,r.networkBalanceInUSD=S.networkBalanceInUSD,r.inputError=S.inputError},resetValues(){var o;const{networkAddress:e}=u.getParams(),t=(o=r.tokens)==null?void 0:o.find(n=>n.address===e);u.setSourceToken(t),u.setToToken(void 0)},getApprovalLoadingState(){return r.loadingApprovalTransaction},clearError(){r.transactionError=void 0},async initializeState(){if(!r.initializing){if(r.initializing=!0,!r.initialized)try{await u.fetchTokens(),r.initialized=!0}catch{r.initialized=!1,v.showError("Failed to initialize swap"),p.goBack()}r.initializing=!1}},async fetchTokens(){var o;const{networkAddress:e}=u.getParams();await u.getNetworkTokenPrice(),await u.getMyTokensWithBalance();const t=(o=r.myTokensWithBalance)==null?void 0:o.find(n=>n.address===e);t&&(r.networkTokenSymbol=t.symbol,u.setSourceToken(t),u.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const e=(t=f.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(r.caipNetworkId===e&&r.tokens))try{r.tokensLoading=!0;const n=await Z.getTokenList(e);r.tokens=n,r.caipNetworkId=e,r.popularTokens=n.sort((d,w)=>d.symbol<w.symbol?-1:d.symbol>w.symbol?1:0);const i=(e&&((o=Te.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[e])||[]).map(d=>n.find(w=>w.symbol===d)).filter(d=>!!d),c=(Te.SWAP_SUGGESTED_TOKENS||[]).map(d=>n.find(w=>w.symbol===d)).filter(d=>!!d).filter(d=>!i.some(w=>w.address===d.address));r.suggestedTokens=[...i,...c]}catch{r.tokens=[],r.popularTokens=[],r.suggestedTokens=[]}finally{r.tokensLoading=!1}},async getAddressPrice(e){var d,w;const t=r.tokensPriceMap[e];if(t)return t;const o=await J.fetchTokenPrice({addresses:[e]}),n=(o==null?void 0:o.fungibles)||[],a=[...r.tokens||[],...r.myTokensWithBalance||[]],i=(d=a==null?void 0:a.find(g=>g.address===e))==null?void 0:d.symbol,s=((w=n.find(g=>g.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:w.price)||0,c=parseFloat(s.toString());return r.tokensPriceMap[e]=c,c},async getNetworkTokenPrice(){var a;const{networkAddress:e}=u.getParams(),o=(a=(await J.fetchTokenPrice({addresses:[e]}).catch(()=>(v.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:a[0],n=(o==null?void 0:o.price.toString())||"0";r.tokensPriceMap[e]=parseFloat(n),r.networkTokenSymbol=(o==null?void 0:o.symbol)||"",r.networkPrice=n},async getMyTokensWithBalance(e){const t=await Xe.getMyTokensWithBalance(e),o=Z.mapBalancesToSwapTokens(t);o&&(await u.getInitialGasPrice(),u.setBalances(o))},setBalances(e){const{networkAddress:t}=u.getParams(),o=f.state.activeCaipNetwork;if(!o)return;const n=e.find(a=>a.address===t);e.forEach(a=>{r.tokensPriceMap[a.address]=a.price||0}),r.myTokensWithBalance=e.filter(a=>a.address.startsWith(o.caipNetworkId)),r.networkBalanceInUSD=n?b.multiply(n.quantity.numeric,n.price).toString():"0"},async getInitialGasPrice(){var t,o;const e=await Z.fetchGasPrice();if(!e)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=f.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case z.CHAIN.SOLANA:return r.gasFee=e.standard??"0",r.gasPriceInUSD=b.multiply(e.standard,r.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(r.gasFee),gasPriceInUSD:Number(r.gasPriceInUSD)};case z.CHAIN.EVM:default:const n=e.standard??"0",a=BigInt(n),i=BigInt(We),s=j.getGasPriceInUSD(r.networkPrice,i,a);return r.gasFee=n,r.gasPriceInUSD=s,{gasPrice:a,gasPriceInUSD:s}}},async swapTokens(){var i,s,c;const e=(i=f.getAccountData())==null?void 0:i.address,t=r.sourceToken,o=r.toToken,n=b.bigNumber(r.sourceTokenAmount).gt(0);if(n||u.setToTokenAmount(""),!o||!t||r.loadingPrices||!n||!e)return;r.loadingQuote=!0;const a=b.bigNumber(r.sourceTokenAmount).times(10**t.decimals).round(0);try{const d=await J.fetchSwapQuote({userAddress:e,from:t.address,to:o.address,gasPrice:r.gasFee,amount:a.toString()});r.loadingQuote=!1;const w=(c=(s=d==null?void 0:d.quotes)==null?void 0:s[0])==null?void 0:c.toAmount;if(!w){te.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const g=b.bigNumber(w).div(10**o.decimals).toString();u.setToTokenAmount(g),u.hasInsufficientToken(r.sourceTokenAmount,t.address)?r.inputError="Insufficient balance":(r.inputError=void 0,u.setTransactionDetails())}catch(d){const w=await Z.handleSwapError(d);r.loadingQuote=!1,r.inputError=w||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:e,availableToSwap:t}=u.getParams(),o=r.sourceToken,n=r.toToken;if(!(!e||!t||!o||!n||r.loadingQuote))try{r.loadingBuildTransaction=!0;const a=await Z.fetchSwapAllowance({userAddress:e,tokenAddress:o.address,sourceTokenAmount:r.sourceTokenAmount,sourceTokenDecimals:o.decimals});let i;return a?i=await u.createSwapTransaction():i=await u.createAllowanceTransaction(),r.loadingBuildTransaction=!1,r.fetchError=!1,i}catch{p.goBack(),v.showError("Failed to check allowance"),r.loadingBuildTransaction=!1,r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:e,sourceTokenAddress:t,toTokenAddress:o}=u.getParams();if(!(!e||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const n=await J.generateApproveCalldata({from:t,to:o,userAddress:e}),a=ye.getPlainAddress(n.tx.from);if(!a)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:n.tx.data,to:a,gasPrice:BigInt(n.tx.eip155.gasPrice),value:BigInt(n.tx.value),toAmount:r.toTokenAmount};return r.swapTransaction=void 0,r.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{p.goBack(),v.showError("Failed to create approval transaction"),r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}}},async createSwapTransaction(){var s;const{networkAddress:e,fromCaipAddress:t,sourceTokenAmount:o}=u.getParams(),n=r.sourceToken,a=r.toToken;if(!t||!o||!n||!a)return;const i=(s=de.parseUnits(o,n.decimals))==null?void 0:s.toString();try{const c=await J.generateSwapCalldata({userAddress:t,from:n.address,to:a.address,amount:i,disableEstimate:!0}),d=n.address===e,w=BigInt(c.tx.eip155.gas),g=BigInt(c.tx.eip155.gasPrice),P=ye.getPlainAddress(c.tx.to);if(!P)throw new Error("SwapController:createSwapTransaction - address is required");const E={data:c.tx.data,to:P,gas:w,gasPrice:g,value:BigInt(d?i??"0":"0"),toAmount:r.toTokenAmount};return r.gasPriceInUSD=j.getGasPriceInUSD(r.networkPrice,w,g),r.approvalTransaction=void 0,r.swapTransaction=E,E}catch{p.goBack(),v.showError("Failed to create transaction"),r.approvalTransaction=void 0,r.swapTransaction=void 0,r.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){v.showLoading("Approve limit increase in your wallet"),p.replace("SwapPreview")},async sendTransactionForApproval(e){var a,i,s;const{fromAddress:t,isAuthConnector:o}=u.getParams();r.loadingApprovalTransaction=!0;const n="Approve limit increase in your wallet";o?p.pushTransactionStack({onSuccess:u.onEmbeddedWalletApprovalSuccess}):v.showLoading(n);try{await de.sendTransaction({address:t,to:e.to,data:e.data,value:e.value,chainNamespace:z.CHAIN.EVM}),await u.swapTokens(),await u.getTransaction(),r.approvalTransaction=void 0,r.loadingApprovalTransaction=!1}catch(c){const d=c;r.transactionError=d==null?void 0:d.displayMessage,r.loadingApprovalTransaction=!1,v.showError((d==null?void 0:d.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(d==null?void 0:d.displayMessage)||(d==null?void 0:d.message)||"Unknown",network:((a=f.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||"",swapFromToken:((i=u.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((s=u.state.toToken)==null?void 0:s.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(e){var s,c,d,w,g,P,E,F,L,H,Q,Ee;if(!e)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:n}=u.getParams();r.loadingTransaction=!0;const a=`Swapping ${(s=r.sourceToken)==null?void 0:s.symbol} to ${b.formatNumberToLocalString(o,3)} ${(c=r.toToken)==null?void 0:c.symbol}`,i=`Swapped ${(d=r.sourceToken)==null?void 0:d.symbol} to ${b.formatNumberToLocalString(o,3)} ${(w=r.toToken)==null?void 0:w.symbol}`;n?p.pushTransactionStack({onSuccess(){p.replace("Account"),v.showLoading(a),we.resetState()}}):v.showLoading("Confirm transaction in your wallet");try{const ve=[(g=r.sourceToken)==null?void 0:g.address,(P=r.toToken)==null?void 0:P.address].join(","),$=await de.sendTransaction({address:t,to:e.to,data:e.data,value:e.value,chainNamespace:z.CHAIN.EVM});return r.loadingTransaction=!1,v.showSuccess(i),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((E=f.state.activeCaipNetwork)==null?void 0:E.caipNetworkId)||"",swapFromToken:((F=u.state.sourceToken)==null?void 0:F.symbol)||"",swapToToken:((L=u.state.toToken)==null?void 0:L.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}}),we.resetState(),n||p.replace("Account"),we.getMyTokensWithBalance(ve),$}catch(ve){const $=ve;r.transactionError=$==null?void 0:$.displayMessage,r.loadingTransaction=!1,v.showError(($==null?void 0:$.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:($==null?void 0:$.displayMessage)||($==null?void 0:$.message)||"Unknown",network:((H=f.state.activeCaipNetwork)==null?void 0:H.caipNetworkId)||"",swapFromToken:((Q=u.state.sourceToken)==null?void 0:Q.symbol)||"",swapToToken:((Ee=u.state.toToken)==null?void 0:Ee.symbol)||"",swapFromAmount:u.state.sourceTokenAmount||"",swapToAmount:u.state.toTokenAmount||"",isSmartAccount:ue(z.CHAIN.EVM)===pe.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(e,t){return j.isInsufficientSourceTokenForSwap(e,t,r.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:e,toTokenDecimals:t}=u.getParams();!e||!t||(r.gasPriceInUSD=j.getGasPriceInUSD(r.networkPrice,BigInt(r.gasFee),BigInt(We)),r.priceImpact=j.getPriceImpact({sourceTokenAmount:r.sourceTokenAmount,sourceTokenPriceInUSD:r.sourceTokenPriceInUSD,toTokenPriceInUSD:r.toTokenPriceInUSD,toTokenAmount:r.toTokenAmount}),r.maxSlippage=j.getMaxSlippage(r.slippage,r.toTokenAmount),r.providerFee=j.getProviderFee(r.sourceTokenAmount))}},u=Be(we),W=_e({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),et={state:W,subscribe(e){return Ue(W,()=>e(W))},subscribeKey(e,t){return ze(W,e,t)},showTooltip({message:e,triggerRect:t,variant:o}){W.open=!0,W.message=e,W.triggerRect=t,W.variant=o},hide(){W.open=!1,W.message="",W.triggerRect={width:0,height:0,top:0,left:0}}},ee=Be(et),Me={isUnsupportedChainView(){return p.state.view==="UnsupportedChain"||p.state.view==="SwitchNetwork"&&p.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){R.shake();return}if(await Fe.isSIWXCloseDisabled()){R.shake();return}(p.state.view==="DataCapture"||p.state.view==="DataCaptureOtpConfirm")&&de.disconnect(),R.close()}},tt=A`
2
2
  :host {
3
3
  display: block;
4
4
  border-radius: clamp(0px, ${({borderRadius:e})=>e[8]}, 44px);
package/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" type="image/x-icon" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19766186141.commit-f68c9c1/favicon.ico" />
5
+ <link rel="icon" type="image/x-icon" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19868047872.commit-71d0841/favicon.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <link
8
8
  href="https://fonts.googleapis.com/css?family=Inconsolata&display=swap"
@@ -14,7 +14,7 @@
14
14
  title="Sitemap"
15
15
  href="/sitemap.xml"
16
16
  />
17
- <link rel="manifest" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19766186141.commit-f68c9c1/manifest.json" />
17
+ <link rel="manifest" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19868047872.commit-71d0841/manifest.json" />
18
18
  <meta name="theme-color" content="#000000" />
19
19
  <title>Decentraland DAO</title>
20
20
  <meta name="description" content="The governance hub for Decentraland. Create and vote on proposals that help shape the future of the metaverse." />
@@ -25,8 +25,8 @@
25
25
  <meta property="twitter:description" content="The governance hub for Decentraland. Create and vote on proposals that help shape the future of the metaverse." >
26
26
  <meta property="twitter:image" content="https://decentraland.org/images/decentraland.png" >
27
27
  <meta property="twitter:card" content="summary" >
28
- <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19766186141.commit-f68c9c1/assets/index-76a72ce6.js"></script>
29
- <link rel="stylesheet" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19766186141.commit-f68c9c1/assets/index-471effde.css">
28
+ <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19868047872.commit-71d0841/assets/index-29108636.js"></script>
29
+ <link rel="stylesheet" href="https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19868047872.commit-71d0841/assets/index-80e7a0a9.css">
30
30
  </head>
31
31
  <body>
32
32
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/governance-site",
3
- "version": "1.14.1-19766186141.commit-f68c9c1",
3
+ "version": "1.14.1-19868047872.commit-71d0841",
4
4
  "description": "Governance website",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,6 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/decentraland/governance-ui.git"
19
19
  },
20
- "homepage": "https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19766186141.commit-f68c9c1",
21
- "commit": "f68c9c136da3b4ef530c41222ac04d04f9d827e7"
20
+ "homepage": "https://cdn.decentraland.org/@dcl/governance-site/1.14.1-19868047872.commit-71d0841",
21
+ "commit": "71d08415f9440aa6fa376e397fe386c000dafe77"
22
22
  }