@coinmeca/wallet-sdk
Version:
3 lines (2 loc) • 13 kB
JavaScript
import{C as e}from"./core-BP4HjhRb.js";import{fetchFromProvider as t}from"@ethereumjs/util";import{formatChainId as r,loadStorage as a,openWindow as s,getFaviconUri as n,getAppName as i,parseChainId as o,parse as c}from"./utils.js";import"eventemitter3";import"crypto-js";import"ethereum-cryptography/utils";const h=d;function d(e,t){const r=l();return(d=function(e,t){return r[e-=182]})(e,t)}function l(){const e=["appendChild","absolute","eth_syncing","'eth_sign' is depreacted request method. Please request again with 'personal_sign' or 'eth_signTypedData'.","No chainId provided","WebApp","No address or position provided","Telegram","center","No asset information provided","100vh","100%","contentWindow","eip6963:requestProvider","remove","1278417OcgZoM","Error rejecting '","100vw","assign","1750196GwdOVG","isCoinmecaWallet","bind","address","flex","length","clear","forEach","querySelectorAll","freeze","eth_hashrate","params","message","has","10rStUIs","eth_newFilter","' was rejected.","modal","target",":chainId",":address","Method '","state","chain","width","getAddress","50376073pIDEYW","rpc","decimals","src","chainId","tdesktop","13569BoRTNs","undefined","fixed","eth_signTypedData_v4","latest","personal_sign","coinmeca-wallet-proxy-","getElementById","host","strategy","balance","initial","6UVMStn","height","size","number","addEventListener","eth_unsubscribe"," is not supported. Subscription methods are not available in this wallet","erc20_approve","div","CoinmecaWallet","ethereum","eth_requestAccounts","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFT0lEQVR4AbVWBWxbVxQ975ND3+GkzBBORmVmZqYxB8bMvBXGaQdWmSHpmJkXLDMF1YBaq3O5Z35WubYbPNKR7E/vwrmAqsLeeF3okeavTSlvOsJW3CYxa39is7I9XcJP7xkaePrAjIDyg0/5Z9kXB3x0/F//ydxuhqGuUG5ujyryX23bYNxxaL3SnrMQwBRonCwUjhSCoxTBqarg/T6C74ULftdDcM+L6mH7j8b8438Y8agp/sJf1h2WrTN/UtMdr6E7RyKE7aAzCIIWgKqTylnK3/JaiADjFHCaLzg/HtzxmuJw5Bozy7bBRH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IUWfAPPc49l10xcgYqdVuXrTXmIn03orep0JQOEa8e8EY/wN217XhnKTLiDYS+OUlbklaDti3VohKAVzTgAj3OlsqN0u3E8Ct6glx+4QVmRW+qKhM+1bjRRdQoYtCKeHfEq31J3leTqJ25AVSBFqXyzOQ9DVxCBk89Wh1aNwzXXemeKsUxQVvAp36Lcr03peXVQts2UwnRVR1I6YU4i9GhCCTobFcVJcZbyt0GIINdmpTkPNtX3mOSf50gNqZy5JKTCiprCqCyI13/fNV+ZmX1YDMwgms0irMmEz0TCGEahS4538h4qljdoWDMZ3nTToWvbHrTd1M4ehbqCaS8OM7YWTdY/3feh/ta2LOcULdfvzD+tT99w2jJhS5nvmN1ZzvXO1mhq5ZQOM+yhqCL+B+AWe5nrKa3ZAAAAAElFTkSuQmCC","set","coinmeca-wallet-modal-","then","508900HONLew","' not supported","9HKXpKS","coinmeca","style","get","eth_getBalance","eth_signTransaction","popup","load","net.coinmeca.wallet","method","https://wallet.coinmeca.net","frame_id","-999999999","none","search","coinmeca-wallet-panel-","/request/","filter",":chain","createElement","eth_signTypedData","storage","resolve","eth_subscribe","coinmeca-wallet-","coinmeca:wallet","eth_filterChanges","eth_blockNumber","Provider URL was not setup yet.","2625940HfdryQ","hostname","eth_sendTransaction","data","newValue","error","eth_accounts","origin","request","RPC Error: ","black","randomUUID","proxy","location","platform","The given parameter is incorrect.","includes","postMessage","No filter ID provided","eth_getCode","body","1px solid rgba(255,255,255,.3)","7544888DDnyvK","iframe","eth_mining","result","hidden","510pdYDGU","0x1","wallet_switchEthereumChain","eth_protocolVersion","getTime","eth_chainId","No transaction parameters provided","isArray","object","coinmeca-wallet","wallet","panel","eth_gasPrice",'[id^="coinmeca-wallet-proxy-"]',"storageArea","dispatchEvent"];return(l=function(){return e})()}!function(){const e=d,t=l();for(;;)try{if(664946===-parseInt(e(311))/1+-parseInt(e(280))/2*(parseInt(e(194))/3)+parseInt(e(315))/4*(-parseInt(e(329))/5)+-parseInt(e(206))/6*(-parseInt(e(222))/7)+-parseInt(e(275))/8*(parseInt(e(224))/9)+parseInt(e(253))/10+parseInt(e(188))/11)break;t.push(t.shift())}catch(e){t.push(t.shift())}}();class w extends e{#e=h(249);#t;#r=new Map;constructor(e){const t=h;super();const{chainId:r,rpcUrls:a,nativeCurrency:s}=e?.chain||{};r&&a&&a[t(320)]&&s&&s?.[t(190)]&&this.#a(e?.[t(185)]);window[t(210)](t(245),(e=>{const r=t;if(e[r(294)]!==localStorage||!e[r(257)])return;const{key:a,newValue:s}=e,n=c(s);if(n)switch(a){case this.#e+r(182):this.#s(n);break;case this.#e+r(242):n?.[r(192)]&&this.#a(n[r(192)]);break;case this.#e+r(334):this.#a(n)}}));const n=new CustomEvent("eip6963:announceProvider",{detail:{info:{name:"Coinmeca Wallet",icon:t(218),uuid:crypto[t(264)](),rdns:t(232)},provider:this}});window[t(295)](n),window[t(210)](t(309),(()=>window[t(295)](n))),window[t(210)](t(327),this.#n[t(317)](this)),typeof window!==t(195)&&(window[t(216)]?(window[t(216)].providers=[...window.ethereum.providers?.[t(241)]((e=>e?.[t(316)]))||[],this],window[t(216)].providerMap=new Map([...window[t(216)].providerMap||[],["CoinmecaWallet",this]])):window[t(216)]={providers:[this],providerMap:new Map([[t(215),this]])}),Object[t(324)](this)}get#i(){const e=h;return"undefined"!=typeof window?window[e(303)]?.[e(301)]:void 0}get#o(){const e=h;return window?.[e(225)]?.[e(290)]}get[h(316)](){return!0}get[h(318)](){const e=h;return this.#o?.[e(318)]||this.#c({storage:sessionStorage})?.get(e(318))||this.#c()?.[e(227)](e(318))}get[h(185)](){const e=h;return this.#o?.[e(185)]||this.#c()?.[e(227)](e(185))}get[h(192)](){const e=h;return r(this.#o?.[e(185)]?.[e(192)]||this.chain?.[e(192)])||e(281)}async[h(187)](){return this[h(318)]}async[h(204)](){const e=h;return await this.#h.rpc(e(228),[this[e(318)],e(198)])}#c(e){const t=h,r=a(this.#e,e?.[t(245)]||localStorage,!1,e?.key);return Object[t(324)](r)}#s(e){const t=h;this.#c({storage:sessionStorage})?.[t(219)]("address",e),this.#c()?.[t(219)](t(318),e)}#a(e){const t=h;typeof e===t(288)&&(this.#c()?.set(t(185),e),e=e?.[t(192)]),typeof window!==t(195)&&(window[t(216)][t(192)]=r(e)),this.#c({storage:sessionStorage})?.[t(219)](t(192),e),this.#c()?.[t(219)](t(192),e)}#d(e,t="popup",r){const a=h;t="proxy"!==t&&this.#i?.[a(267)]===a(193)||window[a(266)][a(238)][a(269)](a(235))||window[a(266)][a(254)].endsWith("discordsays.com")?a(332):t;const n=crypto[a(264)](),i={target:a(289),id:n,strategy:t,request:e,time:Math.floor((new Date)[a(284)]()/1e3)};let o;switch(window[a(270)]({target:i[a(333)]},window[a(266)][a(260)]),t){case a(230):o=this.#t?this.#t:this.#t=s((a(234)||window[a(266)][a(260)])+"/request/"+e?.[a(233)],r);break;case a(265):const t=document[a(243)](a(276));Object[a(314)](t[a(226)],{position:a(297),display:a(237),bottom:"0",left:"0",width:"0",height:"0",margin:"0",padding:"0",opacity:"0",zIndex:a(236),border:a(237),pointerEvents:"none"}),t[a(191)]=(a(234)||window[a(266)][a(260)])+"/proxy/request/"+e?.[a(233)],t.id=a(200)+n,document[a(273)][a(296)](t),o=t[a(308)],o[a(210)](a(231),(()=>{o.coinmeca={isProxy:!0}}));break;case a(332):const i=document.createElement(a(214));i.id=a(239)+n,Object.assign(i[a(226)],{position:a(196),top:"0",left:"0",width:a(313),height:a(306),backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:"999999999",display:a(319),justifyContent:a(304),alignItems:a(304),overflow:a(279)});const c=document[a(243)](a(276));Object[a(314)](c.style,{background:a(263),width:a(307),height:a(307),maxWidth:(typeof r===a(209)?r:r?.[a(186)]||384)+"px",maxHeight:(typeof r===a(209)?r:r?.[a(207)]||640)+"px",border:a(274),pointerEvents:a(205)}),c.src=(a(234)||window[a(266)][a(260)])+a(240)+e?.[a(233)],c.id=a(220)+n,document[a(273)][a(296)](i),i[a(296)](c),o=c[a(308)],o[a(210)](a(231),(()=>{o[a(225)]={isModal:!0}}))}const c=e=>{const t=a;e?.data?.[t(333)]===t(289)&&"ready"===e?.[t(256)]?.[t(184)]&&(o[t(270)](i,"https://wallet.coinmeca.net"),window.removeEventListener(t(327),c))};return window[a(210)]("message",c),{id:n,portal:o,strategy:t}}async#l(e,t){const r=h,a={method:e,params:t?.[r(326)],chainId:this[r(185)]?.chainId,app:{url:window[r(266)][r(202)],name:i(),logo:await n()}},s=t?.size,o=t?.[r(203)]||"popup";return new Promise((async(e,t)=>{const n=r,{portal:i,id:c}=this.#d(a,o,s);if(this.#r[n(219)](c,{method:a[n(233)],resolve:e,reject:t}),i&&"popup"===o){const e=setInterval((()=>{const r=n;(!i||i?.closed)&&(this.#t=void 0,clearInterval(e),this.#r[r(208)]&&(this.#r[r(322)]((({method:e,reject:t},a)=>{const s=r;try{t(new Error("Request '"+e+s(331)))}catch(t){console[s(258)](s(312)+e+"':",t)}})),this.#r[r(321)](),t(new Error("User closed the window before approving the request."))))}),100)}this.#r[n(219)](c,{method:a[n(233)],resolve:e,reject:t})}))}#n(e){const t=h,{target:r,id:a,strategy:s,result:n,error:i,close:o}=e[t(256)],c=this.#r.get(a)?.[t(246)],d=this.#r.get(a)?.reject;r===t(289)&&(a&&this.#r[t(328)](a)?(typeof n!==t(195)&&c&&c(e[t(256)][t(278)]),typeof i!==t(195)&&d&&d(new Error(e.data.error)),o?(document?.[t(201)](t(248)+(s===t(265)?t(265):t(291))+"-"+a)?.[t(310)](),1===this.#r[t(208)]&&(this.#t=void 0)):new Error(e.data[t(258)]),this.#r.delete(a)):("proxy"===s||s===t(332))&&(document[t(323)]('[id^="coinmeca-wallet-panel-"]')[t(322)]((e=>e[t(310)]())),document.querySelectorAll(t(293))[t(322)]((e=>e.remove()))))}#h={wallet:async(e,t)=>{const r=h,a=t?.[r(326)]?.[r(256)];return a&&a?.startsWith("0x095ea7b3")?await this.#l(r(213),t):await this.#l(e,t)},rpc:async(e,r)=>{const a=h,s=this[a(185)]?.rpcUrls?.[0];if(!s)return new Error(a(252));const n=await t(s,{method:e,params:r});if(n[a(256)][a(258)])throw new Error(a(262)+n.data.error.message);return n[a(256)][a(278)]}};async[h(261)]({method:e,params:t}){const a=h;switch(e){case"eth_coinbase":return this[a(318)];case a(285):return this.chainId;case"net_version":return o(this[a(192)]);case"eth_estimateGas":if(Array[a(287)](t)?!t?.length:!t)throw new Error(a(286));return await this.#h[a(189)](e,t);case"eth_getTransactionCount":return await this.#h[a(189)](e,[this.address,"latest"]);case a(272):return await this.#h[a(189)](e,[(t?.[0]||t)?.[a(318)],a(198)]);case a(259):return await this.#h[a(290)](e,{strategy:"proxy"});case a(217):return await this.#h[a(290)](a(259),{strategy:a(265)})[a(221)]((async t=>{const r=a;return t?.[r(320)]?[t[0]]:await this.#h[r(290)](e)[r(221)]((e=>{if(e)return this.#s(e?.[0]),e}))}));case a(228):return await this[a(204)]();case"eth_sign":throw new Error(a(299));case a(199):if(!t||!t[a(320)])throw new Error(a(268));return await this.#h.wallet(e,{params:t}).then((e=>{if(e)return e}));case"eth_signTypedData":if(!t||!t?.[a(320)])throw new Error(a(268));return await this.#h[a(290)](a(244),{params:t}).then((e=>{if(e)return e}));case a(197):if(!t||!t?.length)throw new Error(a(268));return await this.#h[a(290)](a(197),{params:t})[a(221)]((e=>{if(e)return e}));case a(229):throw new Error("'eth_signTransaction' is depreacted request method.");case a(255):if(Array[a(287)](t)?!t?.[a(320)]:!t)throw new Error("No transaction parameters provided");return await this.#h[a(290)](e,{params:t?.[0]||t})[a(221)]((e=>{if(e)return e}));case"wallet_addEthereumChain":if(Array[a(287)](t)?!t?.[a(320)]:!t)throw new Error("No chain information provided");return await this.#h[a(290)](e,{params:t?.[0]||t}).then((e=>{if(e)return this.#a(e),e}));case a(282):if(Array[a(287)](t)?!t?.[a(320)]:!t)throw new Error(a(300));return this[a(192)]&&this[a(192)]===r((t?.[0]||t)?.[a(192)])?this[a(185)]:await this.#h.wallet(e,{params:t?.[0]||t})[a(221)]((e=>{if(e)return this.#a(e),e}));case"wallet_watchAsset":if(Array[a(287)](t)?!t?.[a(320)]:!t)throw new Error(a(305));return await this.#h[a(290)](e,{params:t?.[0]||t})[a(221)]((e=>{if(e)return e}));case a(330):return await this.#h[a(189)](e,t);case a(250):return await this.#h.rpc(e,t);case"eth_uninstallFilter":if(Array[a(287)](t)?!t?.[a(320)]:!t)throw new Error(a(271));return await this.#h.rpc(e,t);case"eth_getStorageAt":if(Array.isArray(t)?!t?.[a(320)]:!t)throw new Error(a(302));return await this.#h.rpc(e,t);case a(251):case a(292):case a(283):case a(298):case a(277):case a(325):return await this.#h[a(189)](e);case a(247):case a(211):throw new Error(e+a(212));default:throw new Error(a(183)+e+a(223))}}}export{w as CoinmecaWalletAdapter};
//# sourceMappingURL=adapter.js.map