UNPKG

@coinmeca/wallet-sdk

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