UNPKG

@coinmeca/wallet-sdk

Version:
3 lines (2 loc) 19.3 kB
import{Common as t}from"@ethereumjs/common";import{Wallet as e}from"@ethereumjs/wallet";import{fetchFromProvider as s,ecsign as r,toRpcSig as n}from"@ethereumjs/util";import{TransactionFactory as i}from"@ethereumjs/tx";import{keccak256 as o}from"ethereum-cryptography/keccak";import{signTypedData as a,signTypedData_v4 as h}from"eth-sig-util";import c from"crypto-js";import{C as d}from"./core-C6VcTWK5.js";import{selectors as u}from"./selectors.js";import{encrypt as g,parse as f,decrypt as m,formatChainId as l,parseChainId as w,valid as p}from"./utils.js";import{getSecureStorage as y}from"./storage.js";import"eventemitter3";import"ethereum-cryptography/utils";const k=I;function I(t,e){const s=b();return(I=function(t,e){return s[t-=434]})(t,e)}function b(){const t=["number","account","Locked out. Try again after ","Chain base doesn't EVM based.","addEthereumChain","114460UQMowv","6315749ZNryoA","updateContacts","8583840ZhKsKV","category","The given tokenId(","custom","type","lock.count",") is something wrong","signTypedData","accountUpdated","length","ethereum","ready","7saYQmc","toLowerCase","signMessage",":seed","hex","undefined","cumulativeGasUsed","218dOpRks","randomUUID","12sZmEjF","toString","count","filter","object",":chainId","requestAccounts","Account ","hash","lock.time","data","contact","floor","tokens","apps","import","fungibles","Locked out. Please try again later ","2341025cokqTS","changeAccount","from","value","getAddressString","receipt","10jAOiwk","rpcUrls","some","There is no message to sign.","unlock","accounts","check","wait","5141008hmFBDQ","There is no signer information.","allowance","0x1","status","contractAddress","set","revokeApp","1868244JhpeWt","key","Too many failed attempts. Try after ","getTime",":chain","remove","then","userId","chain","switchEthereumChain","The account information for adding the asset could not be found.","utf-8","serialize","sign","updateReceipt","Cannot access to the information of accounts.","changeChain","reset","find","address","txUpdated","appUpdated","string","nonFungibles","exist","Chain not registered yet.","init","The account information for removing the asset could not be found.","get","coinmeca","coinmeca:wallet","fromTxData","chainId","Invalid app information.","slice","chainChanged","updateAccount","Telegram","removeNonFungibleAsset","No receipt found for transaction "," second(s).","secure","There is no any chain registered.","clear","The account data wasn't provided.","WebApp","lockTimeUpdated","93BFfjPz","getReceipt","map","Contract Interaction","now","isInitialized","Wallet already initialized.","remain","Given account data is something wrong.","fromPrivateKey","gasUsed","locked","startsWith","eth_getCode","substring","origin","warn","effectiveGasPrice","user","Not found account info"," minute(s)","common","updateChain","index","Invalid key entered.","evm","lock","Invalid chain parameters. `chainId` and at least one `rpcUrls` are required.","Couldn't found a current account information.","Provider URL was not setup yet.","chainUpdated","name","accountChanged","signTypedData_v4","The given address(","updateApp","Wallet is not setup yet.","removeFungibleAsset","disable","recent","isLocked","CloudStorage","4283DZBWky","eth_sendRawTransaction","blockNumber","eth_getTransactionReceipt","url","coinmeca-wallet","initDataUnsafe","target","addNonFungibleAsset","chains","hasOwnProperty","getReceipts","Too many failed attempts. The wallet has been reset.","emit"];return(b=function(){return t})()}!function(){const t=I,e=b();for(;;)try{if(490088===parseInt(t(596))/1*(-parseInt(t(465))/2)+parseInt(t(554))/3*(parseInt(t(443))/4)+-parseInt(t(485))/5*(-parseInt(t(467))/6)+-parseInt(t(458))/7*(parseInt(t(499))/8)+-parseInt(t(446))/9+parseInt(t(491))/10*(parseInt(t(444))/11)+parseInt(t(507))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const v=[1,3,5,10,15,30,60,30,120,240,360,480,720];class E extends d{#t=k(537);#e;#s;#r;constructor(t){const e=k;super();const s=this.#n?this.#i?.[e(595)]:localStorage;this.#s=y(s,g(this.#t,this.#t),{codename:this.#t,emit:(t,s)=>{const r=e,n=s?.[r(508)],i=s?.[r(488)];if(this[r(437)](t),i)switch(n){case this.#t+":address":return this[r(486)](f(i));case this.#t+r(511):return this[r(523)](f(i)?.chainId);case this.#t+r(472):return this[r(523)](f(i));default:return}}});const{key:r,address:n,chainId:i,sessionId:o}=t||{},a=this.#o();if(this.#e=r,this.#r=o,n)r?this[e(486)](n):a?.[e(505)]("address",n);else{const t=a?.[e(535)](e(526));t&&this[e(486)](t)}if(typeof window!==e(463)&&(window[e(456)]={...window?.[e(456)],chainId:this.chainId}),i&&a?.[e(535)](e(605))?.[e(525)]((t=>t?.[e(539)]===i)))this[e(523)](i);else{const t=a?.[e(535)]("chainId");t&&this[e(523)](t?.chainId)}window.addEventListener("message",(t=>{const s=e;t?.[s(477)]?.[s(603)]===s(601)&&t.origin===window.location[s(569)]&&this.#s[s(457)]()})),Object.freeze(this),Object.defineProperty(window,e(536),{value:{wallet:this},writable:!1,configurable:!1,enumerable:!1})}#a(t){const e=k;return this.#h?t(this.#h):this[e(559)]?void 0:new Error(e(522))}#o(t){const e=k;return this.#s?.[e(548)](t)}#c(t){const s=k;return e[s(563)](Buffer.from(t.toString().trim()[s(568)](0,64),s(462)))}#d(t){const e=k;return t=c.SHA256(this.#u+":"+t).toString(),this.#o(t)[e(535)](t)}#g(t){const e=k;return typeof t===e(529)&&(t=this.#f?.get(t?.[e(459)]())?.[e(577)]),this.#a((s=>{const r=e,n=this.#f?.[r(535)](s+r(461));if(n?.length){const e=n[t];if(e)return e;throw new Error(r(573))}throw new Error(r(590))}))}getPrivateKey(t){const e=k;if(!t||""===t)throw new Error(e(551));if(this[e(565)][e(561)])throw new Error(e(509)+this.locked.remain+" minute(s)");const{hash:s,index:r,address:n}=f(m(t,new Date(Math[e(479)](Date[e(558)]())).toString())),i=this.#d(s),o=this.#o(i)[e(535)](n?.[e(459)]());if(this.#e===i&&o[e(577)]===r&&o[e(526)]?.[e(459)]()===n?.[e(459)]())return this.#g(r);{const t=this[e(565)][e(469)]+1;if(this.#o().set(e(451),t),this[e(565)][e(469)]>3){if(t-4>v[e(455)])throw this[e(524)](),new Error(e(436));{const s=60*v[t-4]*1e3;throw this.#o()[e(505)](e(476),Date[e(558)]()+s),this[e(437)](e(553),s),new Error(e(484)+s+" second(s).")}}throw Error(e(562))}}get#u(){const t=k;return this.#o()?.get(t(514))}get#h(){return this.#e}get#f(){return this.#a((t=>this.#o(t)))}get#m(){}get#i(){const t=k;return typeof window!==t(463)?window[t(544)]?.[t(552)]:void 0}get#n(){const t=k;return!!this.#i?.[t(602)]?.[t(572)]?.id}async#l(t,e){const r=k,n=this.chain?.[r(492)]?.[0];return n?await s(n,{method:t,params:e}):new Error(r(583))}get[k(559)](){return!!this.#u}get[k(594)](){return!this.#h}get[k(526)](){const t=k;return this.#o()?.[t(535)](t(526))}[k(439)](t){const e=k;return this.#f?.[e(535)]?.((t||this[e(526)])?.[e(459)]())}[k(496)](t){const e=k;try{return((t&&""!==t?this[e(481)]?.find((s=>s?.url?.[e(459)]()===t?.toLowerCase()))?.[e(496)]:this.#a((t=>this.#f?.[e(535)](t+":seed")?.[e(556)]((t=>this.#c(t)?.getAddressString()))))?.[e(556)]((t=>this.#f?.[e(535)](t?.toLowerCase()))))||[])[e(470)]((t=>t))}catch(t){return[]}}[k(501)](t,e){const s=k;return e=e||this[s(526)],!!t&&""!==t&&!!e&&""!==e&&this[s(496)](t)?.[s(493)]((t=>t?.[s(459)]()===e?.[s(459)]()))}get[k(539)](){const t=k;return l(this.#o()?.[t(535)](t(539))||1)}get chain(){const t=k;return this[t(605)]?.[t(525)]((e=>e?.[t(539)]===w(this[t(539)]||t(502))))}get[k(605)](){const t=k;return this.#o()[t(535)]("chains")||[]}get apps(){const t=k;return this.#o()[t(535)](t(481))||[]}get[k(478)](){const t=k;return this.#o()[t(535)](t(478))||[]}[k(533)](t){const e=k;this.#u&&new Error(e(560));const s=this.#n?window?.Telegram?.[e(552)]?.[e(602)]?.[e(572)]:crypto[e(466)]();this.#o()?.[e(505)](e(514),s);const r=c.SHA256(s+":"+t)[e(468)]();this.#e=r,this.#f?.[e(505)](r,r),this[e(523)](1)}reset(){const t=k;this.#o()?.[t(550)]()}get[k(565)](){const t=k,e=this.#o()?.[t(535)]("lock.time")||0,s=Math[t(479)]((e-Date[t(558)]())/1e3);return{count:this.#o()?.get(t(451))||0,time:e,remain:s>0?s:0}}[k(580)](){const t=k;this.#o()?.[t(505)](t(526),this[t(439)]()?.[t(526)]),this.#e=void 0,this[t(437)](t(580))}[k(497)](t){const e=k;return!!this.#d(t)?.[e(459)]()}[k(495)](t){const e=k;if(this[e(565)][e(561)])throw new Error(e(440)+this.locked[e(561)]+e(574));const s=this.#d(t);if(this.check(t)){this.#e=s;const t=this[e(496)]();let r;if(t?.length){const s=this[e(526)]||this.#f?.get(e(526))||t?.[0]?.address;r=s&&this.#f?.[e(535)](s?.toLowerCase()),r&&this[e(486)](r?.[e(577)])}return this.#o()?.set(e(476),0),this.#o()?.[e(505)]("lock.count",0),this[e(437)](e(495),r||!0),!0}{const t=this[e(565)][e(469)]+1;if(this.#o()[e(505)](e(451),t),this[e(565)].count>3){if(t-4>v[e(455)])throw this[e(524)](),new Error(e(436));{const s=60*v[t-4]*1e3;throw this.#o()[e(505)](e(476),Date[e(558)]()+s),this[e(437)](e(553),s),new Error(e(484)+s+e(547))}}throw new Error(e(578))}}[k(531)](t){return this.#a((e=>{const s=I;if(t&&""!==t&&t?.startsWith("0x"))switch(t?.length){case 42:const r=t;return this.accounts()?.some((t=>t?.[s(526)]?.[s(459)]()===r?.[s(459)]()))??!1;case 64:const n=t,i=this.#f?.[s(535)](e+s(461))||[];return i?.[s(493)]((t=>t?.[s(459)]()===n?.[s(459)]()))??!1;default:return}}))}create(){return this.#a((t=>{const e=I,s=this.#f?.get(t+e(461))||[],r=s?.[e(455)],n=c.SHA256(t+":"+r)[e(468)](),i=this.#c(n)?.getAddressString();return!!i&&(s?.[e(493)]((t=>t?.[e(459)]()===n?.[e(459)]()))||this.#f?.set(t+e(461),[...s,n]),this.#o()?.[e(535)](i?.[e(459)]())||this.#f?.set(i?.toLowerCase(),{address:i,index:r,name:e(474)+(r+1)}),this[e(486)](r),!0)}))}[k(482)](t){return this.#a((e=>{const s=I,r=this.#f?.[s(535)](e+s(461))||[],n=this.#o()?.[s(535)](s(496))||[],i=this.#c(t)[s(489)]();let o=n?.length;return!!i&&(r?.[s(493)](((e,r)=>{const n=s,i=e?.[n(459)]()===t?.[n(459)]();if(i)return o=r,i}))||this.#f?.[s(505)](e+":seed",[...r,t]),this.#o()?.[s(535)](i?.[s(459)]())||this.#f?.set(i?.[s(459)](),{address:i,index:o,name:s(474)+(o+1)}),this[s(486)](o),!0)}))}change(t,e){const s=k,r=this.#d(t),n=c.SHA256(this.#u+":"+t).toString();this.#o(n)[s(512)](n);const i=c.SHA256(this.#u+":"+e)[s(468)]();this.#o(i)[s(505)](i,r)}[k(486)](t){const e=k;if(typeof t===e(463))return;if(typeof(t=typeof t===e(529)?this.#f?.[e(535)](t?.toLowerCase())?.[e(577)]:t)!==e(438))return;const s=this[e(496)]()?.[t];if(!s)throw new Error("There is no accounts that setup yet.");return this.#o()?.[e(505)](e(526),s?.[e(526)]),this[e(437)](e(586),s?.[e(526)]),s?.[e(526)]}[k(523)](t){const e=k;if(!t)return;t=typeof t===e(529)?t?.[e(566)]("0x")?w(t):parseInt(t):t;const s=this.chains;if(s?.[e(455)]&&s?.[e(525)]((s=>s?.[e(539)]===t)))return this.#o()?.[e(505)](e(539),t),this.emit(e(542),l(t)),t;throw new Error("There is no any chain registered.")}[k(543)](t){const e=k;this.#f?.[e(505)](t?.[e(526)]?.[e(459)](),{...this.#f?.[e(535)](t?.address?.[e(459)]()),name:t?.name,disable:t?.[e(592)]}),this.emit(e(454),t)}[k(576)](t){const e=k;this.#o()?.[e(505)]("chains",[t,...this[e(605)]?.[e(470)]((s=>s?.[e(539)]!==t?.[e(539)]))]),this[e(437)](e(584),t)}[k(589)](t){const e=k;return this.#o()?.[e(505)](e(481),[t,...this[e(481)]?.[e(470)]((s=>s?.url?.[e(459)]()!==t?.url?.[e(459)]()))]),this[e(437)](e(528))}[k(506)](t){const e=k;return this.#o()?.[e(505)](e(481),this[e(481)]?.filter((s=>s?.url?.[e(459)]()!==t?.[e(459)]()))),this[e(437)](e(528))}revokeAccount(t,e){const s=k;if(typeof(e="string"==typeof e?this.#f?.[s(535)](e?.toLowerCase())?.[s(577)]:e)!==s(438))return;const r=this[s(496)]()?.[e];return this.#o()?.set(s(481),this.apps?.[s(556)]((e=>e?.url?.[s(459)]()===t?.[s(459)]()?{...e,accounts:e?.[s(496)]?.[s(470)]((t=>t?.toLowerCase()!==r?.[s(526)]?.[s(459)]()))}:e))),this[s(437)]("appUpdated")}async[k(442)](t){const e=k,{chainId:s,rpcUrls:r,nativeCurrency:n,base:i}=t;if(i&&i!==e(579))throw new Error(e(441));if(!(s&&r&&r.length&&n.decimals))throw new Error(e(581));const o=this.#o()?.[e(535)](e(605))||[],a=o?.[e(525)]((s=>s?.[e(539)]===t[e(539)]));return this.#o()?.[e(505)](e(605),[{...a,...t},...o?.filter((t=>t?.[e(539)]!==s))]),this[e(437)](e(584)),!0}removeEthereumChain(t){const e=k;if(!t)return;let s=typeof t===e(471)?t?.[e(539)]:t;s="string"==typeof s?s?.[e(566)]("0x")?w(s):parseInt(s):s;let r=this.chains;if(s===this[e(515)][e(539)]&&this[e(523)](1),r?.length&&r?.find((t=>t?.[e(539)]===s)))return this.#o()?.set(e(605),r?.[e(470)]((t=>t?.chainId!==s))),this[e(437)]("chainUpdated"),s;throw new Error(e(549))}async[k(516)](t){const e=k;t=typeof t===e(529)?t?.[e(566)]("0x")?w(t):parseInt(t):t;const s=this.#o()?.[e(535)](e(605))||[],r=s?.[e(525)]((s=>s?.[e(539)]===t));if(r)return this.chain?.chainId!==r?.[e(539)]&&this.changeChain(t),r;throw new Error(e(532))}async[k(473)](t,e){const s=k;if(e=e||this[s(526)]){const r=this[s(481)];if(t?.[s(600)]){const n={...r?.[s(525)]((e=>e?.[s(600)]?.[s(459)]()===t?.[s(600)]?.[s(459)]())),...t},i=[e,...(n?.[s(496)]||[])?.[s(470)]((t=>t?.[s(459)]()!==e?.toLowerCase()))][s(470)]((t=>t));return t={...n,accounts:i},this.#o()[s(505)](s(481),[t,...r?.[s(470)]((e=>e?.[s(600)]?.toLowerCase()!==t?.[s(600)]?.[s(459)]()))]),this[s(437)](s(528)),i}throw new Error(s(540))}throw new Error(s(582))}async[k(520)](e,s){const r=k;s=typeof s===r(471)?s?.[r(577)]:this.#f?.[r(535)](s?.[r(459)]())?.[r(577)];const n=this.chains?.find((t=>t?.[r(539)]===w(e?.[r(539)])))||this[r(515)],o=i[r(538)](e,{common:t[r(449)]({chainId:n?.[r(539)]})})[r(520)](Buffer.from(this.#g(s),r(462)));return"0x"+Buffer[r(487)](o[r(519)]())[r(468)](r(462))}async[k(460)](t){const e=k,s=p.address(t[0]),i=p[e(526)](t[1]);let a,h;if(!s&&!i)throw new Error(e(500));if(i?(h=t[1],a=t[0]):(h=t[0],a=t[1]),!a||!a?.[e(455)])throw new Error(e(494));if(h[e(459)]()!==this[e(526)][e(459)]())throw new Error("Address does not match selected wallet address.");const{v:c,r:d,s:u}=r(o(Buffer.from("Ethereum Signed Message:\n"+a[e(455)]+a,e(518))),this.#g(h));return n(c,d,u)}async[k(453)](t,e){const s=k,{signer:r}=t;return e=e||r||this.address,a(Buffer[s(487)](this.#g(e),"hex"),{data:t})}async[k(587)](t,e){const s=k,{signer:r}=t;return e=e||r||this[s(526)],h(Buffer.from(this.#g(e),s(462)),{data:t})}async send(e,s){const r=k;s=typeof s===r(471)?s?.[r(577)]:this.#f?.get(s?.toLowerCase())?.[r(577)];const n=this[r(605)]?.find((t=>t?.[r(539)]===w(e?.[r(539)])))||this.chain,o=i[r(538)](e,{common:t[r(449)]({chainId:n?.[r(539)]})}).sign(Buffer.from(this.#g(s),r(462))),a=await this.#l(r(597),["0x"+Buffer[r(487)](o.serialize())[r(468)](r(462))]),h=o?.[r(575)]?.[r(539)]()?.[r(468)]();let c=this[r(439)](o.getSenderAddress()?.[r(468)]());return h&&c&&(this.#f?.[r(505)](c?.address?.toLowerCase(),{...c,tx:{...c?.tx,[h]:[{hash:a,status:"pending",category:u?.[("0x"+Buffer.from(o[r(477)]).toString(r(462)))[r(568)](0,10)],time:Math[r(479)]((new Date)[r(510)]()/1e3),no:c?.tx?.[h]?.length||0,to:e?.to},...(c?.tx?.[h]||[]).filter((t=>t?.[r(475)]?.[r(459)]()!==a?.toLowerCase()))]}}),this[r(437)](r(527)),e?.to&&this[r(445)](e?.to?.[r(468)](),{type:r(593)})),Promise.resolve()[r(513)]((()=>this[r(498)](a,{chainId:h}))),a}async[k(490)](t,e){const s=k;if(e&&w(e)!==this.chain?.[s(539)]&&!this[s(523)](e))return;const r=await this.#l(s(599),[t]);return r||void 0}async[k(498)](t,e){const s=k;for(;;){const r=await this.receipt(t);if(r){if(console.log(s(498),r),r?.[s(503)]){const n=this[s(555)](t,e);this.updateReceipt({...n,to:r?.to,category:r?.[s(504)]?"deploy":n?.[s(447)]||("0x"!==await this.#l(s(567),[n?.to,"latest"])?s(557):n?.category),contractAddress:r?.contractAddress,blockNumber:r?.blockNumber?Number(r?.[s(598)]):"-",gasUsed:r?.[s(564)]?Number(r?.gasUsed):"-",status:r?.[s(503)]?r?.[s(503)]===s(502)?"success":"failure":"pending",cumulativeGasUsed:r?.[s(464)]?Number(r?.cumulativeGasUsed):"-",effectiveGasPrice:r?.[s(571)]?Number(r?.[s(571)]):"-"},e);break}await new Promise((t=>setTimeout(t,1e3)))}else console[s(570)](s(546)+t+", retrying..."),await new Promise((t=>setTimeout(t,1e3)))}}[k(445)](t,e){const s=k,r=e?.[s(450)]||"recent",n=e?.[s(585)],i=this.#o()?.[s(535)](s(478));!i?.[r]?.some((e=>e?.[s(526)]?.toLowerCase()===t?.[s(459)]()))&&this[s(531)](t)&&(this.#o()?.[s(505)]("contact",{...i,[r]:[...i?.[r]?.[s(541)]?.(0,19)||[],{name:n,address:t}]}),this[s(437)]("contactUpdated"))}[k(555)](t,e){const s=k,r=e?.chainId?w(e?.[s(539)]):this[s(515)]?.[s(539)],n=this[s(439)](e?.[s(526)]);if(r)return this.#f?.[s(535)](n?.[s(526)]?.[s(459)]())?.tx?.[r]?.[s(525)]((e=>e?.[s(475)]?.[s(459)]()===t?.toLowerCase()))}[k(435)](t,e){const s=k;e=e?w(e):this[s(515)]?.[s(539)];const r=this.account(t);if(e)return this.#f?.[s(535)](r?.[s(526)]?.toLowerCase())?.tx?.[e]||[]}[k(521)](t,e){const s=k;if(!t||typeof t!==s(471)||!t?.[s(475)])return;const r=this[s(439)](e?.[s(526)]),n=e?.[s(539)]?w(e?.[s(539)]):this[s(515)]?.[s(539)];this.#f?.set(r?.[s(526)]?.[s(459)](),{...r,tx:{...r?.tx,[n]:[...(r?.tx?.[""+n]||[])?.map((e=>e?.hash?.toLowerCase()===t?.[s(475)]?.[s(459)]()?{...e,...t}:e))]}}),this.emit(s(527))}updateReceipts(t,e){const s=k,r=this[s(439)](e?.[s(526)]),n=e?.chainId?w(e?.[s(539)]):this[s(515)]?.[s(539)],i=r?.tx?.[n];t&&t.length&&t?.[s(455)]===i?.length&&(this.#f?.set(r?.[s(526)]?.[s(459)](),{...r,tx:{...r?.tx,[n]:t}}),this.emit(s(527)))}addFungibleAsset(t,e){if(t)return this.#a((()=>{const s=I;t=t?.[s(459)]();const r=this.chain?.chainId?.[s(468)]();let n=this[s(439)](e);if(r&&n)return n={...n,tokens:{...n?.[s(480)],fungibles:{...n?.[s(480)]?.[s(483)],[r]:[t,...(n?.[s(480)]?.fungibles?.[r]||[])?.[s(470)]((e=>e!==t))]}}},this.#f?.[s(505)](n?.address?.[s(459)](),n),this[s(437)]("tokenUpdated",n[s(480)]?.[s(483)]),!0;throw new Error(s(517))}))}[k(591)](t,e){if(t)return this.#a((()=>{const s=I;let r=this[s(439)](e);const n=this.chain?.chainId?.[s(468)]();if(n&&r)return r={...r,tokens:{...r?.[s(480)],fungibles:{...r?.tokens?.[s(483)],[n]:(r?.[s(480)]?.fungibles?.[n]||[])?.[s(470)]((e=>e!==t))}}},this.#f?.[s(505)](r?.[s(526)]?.[s(459)](),r),this[s(437)]("tokenUpdated",r[s(480)]?.[s(483)]),!0;throw new Error(s(534))}))}[k(604)](t,e,s){const r=k;if(!t||""===t)throw new Error(r(588)+t+r(452));if(!e||""===e)throw new Error(r(448)+e+r(452));return this.#a((()=>{const n=r;t=t?.[n(459)]();const i=this[n(515)]?.[n(539)]?.[n(468)]();let o=this.account(s);if(i&&o)return o={...o,tokens:{...o?.tokens,nonFungibles:{...o?.[n(480)]?.[n(530)],[i]:[...(o?.[n(480)]?.nonFungibles?.[i]||[])?.filter((e=>e&&!e?.[n(434)](t))),{[t]:[e,...(o?.[n(480)]?.[n(530)]?.[i]?.[n(525)]((e=>e?.[t]))?.[t]||[])?.[n(470)]((t=>t!==e))]}]}}},this.#f?.[n(505)](o?.address?.[n(459)](),o),this[n(437)]("nftUpdated",o.tokens?.[n(483)]),!0;throw new Error(n(517))}))}[k(545)](t,e,s){const r=k;if(!t||""===t)throw new Error(r(588)+t+") is something wrong");if(!e||isNaN(Number(e)))throw new Error(r(448)+e+r(452));return this.#a((()=>{const n=r;let i=this[n(439)](s);const o=this[n(515)]?.[n(539)]?.[n(468)]();if(i)return i={...i,tokens:{...i?.[n(480)],nonFungibles:{...i?.[n(480)]?.[n(530)],[o]:[...(i?.[n(480)]?.[n(530)]?.[o]||[])?.[n(470)]((e=>e&&!t?.[n(434)](t))),{[t]:(i?.[n(480)]?.nonFungibles?.[o]?.[n(525)]((e=>e?.[t]))?.[t]||[])?.[n(470)]((t=>t!==e))}]}}},this.#f?.[n(505)](i?.address?.[n(459)](),i),this[n(437)]("nftUpdated",i.tokens?.[n(483)]),!0;throw new Error("The account information for removing the asset could not be found.")}))}}export{E as CoinmecaWalletProvider,v as locktime}; //# sourceMappingURL=provider.js.map