wative 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("fs"),require("path"),require("figlet"),require("inquirer"),require("web3"),require("@solana/web3.js"),require("@solana/spl-token"),require("@metaplex-foundation/js"),require("bignumber.js")):"function"==typeof define&&define.amd?define(["fs","path","figlet","inquirer","web3","@solana/web3.js","@solana/spl-token","@metaplex-foundation/js","bignumber.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.figlet,e.inquirer,e.Web3,e.web3_js,e.splToken,e.js,e.bignumber_js)}(this,(function(e,t,n,r,a,s,o,c,u){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var d=l(e),p=l(t),m=l(n),f=i(r),h=i(a);function g(e,t,n,r){return new(n||(n=Promise))((function(a,s){function o(e){try{u(r.next(e))}catch(e){s(e)}}function c(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,c)}u((r=r.apply(e,t||[])).next())}))}function v(e,t){var n,r,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var b=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new h.default(e),[4,ae(t.eth.getChainId,[])];case 1:return[2,n.sent()]}}))}))},w=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=new h.default(t),[4,ae(n.eth.getBalance,[e])];case 1:return[2,r.sent()]}}))}))},y=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=new s.Connection(t),[4,ae(n.getBalance.bind(n),[new s.PublicKey(e)])];case 1:return[2,r.sent()]}}))}))},k=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o;return v(this,(function(c){switch(c.label){case 0:return n=new h.default(t),r=new n.eth.Contract([{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],e),[4,ae(r.methods.symbol().call.bind(r),[])];case 1:return a=c.sent(),[4,ae(r.methods.name().call.bind(r),[])];case 2:return s=c.sent(),[4,ae(r.methods.decimals().call.bind(r),[])];case 3:return o=c.sent(),a.status&&s.status&&o.status?[2,{status:!0,output:{symbol:a.output,name:s.output,decimals:o.output}}]:[2,{status:!1,output:"Failed to get token info"}]}}))}))},S=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,u,i,l,d;return v(this,(function(p){switch(p.label){case 0:return n=new s.Connection(t),r=c.Metaplex.make(n),a=new s.PublicKey(e),[4,ae(o.getMint,[n,a])];case 1:if(u=p.sent(),i={status:!0,output:{symbol:"",name:"",decimals:""}},!u.status)return[2,{status:!1,output:"Failed to get token decimals"}];i.output.decimals=u.output.decimals,p.label=2;case 2:return p.trys.push([2,6,,7]),l=r.nfts().pdas().metadata({mint:a}),[4,n.getAccountInfo(l)];case 3:return p.sent()?[4,r.nfts().findByMint({mintAddress:a})]:[3,5];case 4:d=p.sent(),i.output.name=d.name,i.output.symbol=d.symbol,p.label=5;case 5:return[3,7];case 6:return p.sent(),[2,{status:!1,output:"Failed to get token name"}];case 7:return[2,i]}}))}))},N=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s;return v(this,(function(o){switch(o.label){case 0:return r=new h.default(n),a=new r.eth.Contract([{constant:!0,inputs:[{name:"who",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],t),[4,ae(a.methods.balanceOf(e).call.bind(a),[])];case 1:return(s=o.sent()).status?[2,{status:!0,output:s.output}]:[2,{status:!1,output:"Failed to get token balance"}]}}))}))},x=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,c;return v(this,(function(u){switch(u.label){case 0:return r=new s.Connection(n),a=o.getAssociatedTokenAddressSync(new s.PublicKey(t),new s.PublicKey(e)),[4,ae(r.getTokenAccountBalance.bind(r),[a])];case 1:return(c=u.sent()).status?[2,{status:!0,output:c.output.value.amount}]:c.output.includes("could not find account")?[2,{status:!0,output:"0"}]:[2,{status:!1,output:"Failed to get token balance"}]}}))}))},B=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r;return v(this,(function(a){return r=new h.default(n),[2,r.eth.abi.encodeFunctionCall({constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},[e,t])]}))}))},P=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a;return v(this,(function(o){switch(o.label){case 0:return t=new s.Connection(e),[4,ae(t.getRecentPrioritizationFees.bind(t),[])];case 1:return(n=o.sent()).status?(r=n.output,a=r.map((function(e){return e.prioritizationFee})).sort(),[2,{status:!0,output:a.length>0?Math.ceil(a.reduce((function(e,t){return e+t}))/a.length):1e3}]):[2,{status:!1,output:"Failed to get recent prioritization fees"}]}}))}))},O=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=new s.Connection(t),[4,ae(n.getAccountInfo.bind(n),[new s.PublicKey(e.toString())])];case 1:return(r=a.sent()).status?[2,{status:!0,output:r.output}]:[2,{status:!1,output:"Failed to get account info"}]}}))}))},A=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"],_=[{name:"Ethereum Mainnet",chainId:1,rpcUrl:"https://eth.llamarpc.com",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},multicallAddress:"0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441"},{name:"Solana Mainnet",chainId:901,rpcUrl:"https://api.mainnet-beta.solana.com",nativeCurrency:{name:"SOL",symbol:"SOL",decimals:9}}],C=["901","902","903"],j=function(e){return C.includes(e)?9:18},F=function(e){return C.includes(e)?"solana":"evm"},T=require("chalk"),L=process.env.HOME||process.env.USERPROFILE,I="".concat(L,"/.wative"),q=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=[{name:"inputText",type:"input",message:"".concat(e,":"),validate:t}],[4,f.default.prompt(n)];case 1:return[2,r.sent().inputText.trim().toString()]}}))}))},z=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=0,a.label=1;case 1:return t<5?[4,R(e,"Input start address or index")]:[3,5];case 2:return(n=a.sent())?[4,R(e,"Input end address or index")]:(console.log(T.red("Invalid start account index")),[2,null]);case 3:return(r=a.sent())?n>r?(console.log(T.red("Invalid address range")),[3,4]):[2,{from:n,to:r}]:(console.log(T.red("Invalid end account index")),[2,null]);case 4:return t++,[3,1];case 5:return[2,null]}}))}))},R=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i;return v(this,(function(l){switch(l.label){case 0:if(n=e.data,0===(r=n.length))return[2,null];for(a=[],s=[],c=0;c<r;c++)a.push(n[c].ciphertexts.evm.address.toLocaleLowerCase()),s.push(n[c].ciphertexts.solana.address.toLocaleLowerCase());o=r-1,c=0,l.label=1;case 1:return c<5?[4,q(t,D)]:[3,4];case 2:if(u=l.sent(),"unknown"===(i=se(u)))return Number(u)>o?(console.log(T.red("Invalid account index")),[3,3]):[2,Number(u)];if("evm"===i&&-1!==a.indexOf(u.toLocaleLowerCase()))return[2,a.indexOf(u.toLocaleLowerCase())];if("solana"===i&&-1!==s.indexOf(u.toLocaleLowerCase()))return[2,s.indexOf(u.toLocaleLowerCase())];l.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))},U=function(e){return""===e||((e=e.replace(/\s+/g," ").trim()).length>10?"Tag length should be less than 10":!1!==/^[0-9a-zA-Z\s]*$/g.test(e)||"Tag should be alphanumeric")},M=function(e){return!isNaN(Number(e))||"Value should be a number"},K=function(e){var t=(e=e.replace(/\s+/g," ")).split(/\s+/g);if(12!==t.length)return"Passphrase should be equal to 12 words";for(var n=0;n<t.length;n++)if(!1===A.includes(t[n]))return"Passphrase word should be valid";return!0},E=function(e){var t=Number(e);return isNaN(t)?"Amount should be a number":!(t>2e3)||"Amount should be less than 2000"},J=function(e){var t=Number(e);return!isNaN(t)||"Last account no should be a number"},D=function(e){return!1===isNaN(Number(e))||G(e)},G=function(e){return"unknown"!=se(e)||"Address should be valid"},$=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r;return v(this,(function(a){switch(a.label){case 0:return r=[{type:"list",name:"inputText",message:t||"Choose an option",default:n,choices:e,pageSize:30,filter:function(e){return e}}],[4,f.default.prompt(r)];case 1:return[2,a.sent().inputText.toString()]}}))}))},H=function(e,t){return void 0===t&&(t=!1),g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent())&&t)return[2,null];if(/^[0-9]*$/g.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},W=function(e,t,n){return void 0===n&&(n=!1),g(void 0,void 0,void 0,(function(){var r,a,s,o;return v(this,(function(c){switch(c.label){case 0:r=0,c.label=1;case 1:return r<5?[4,q(t)]:[3,7];case 2:a=c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),""===a&&n?[2,null]:"solana"===F(e)?[2,a]:[4,b(a)];case 4:return(s=c.sent()).status?s.output.toString()===e.toString()?[2,a]:(console.log(T.red("Rpc url not match chain id")),[3,6]):(console.log(T.red(s.output)),[3,6]);case 5:return o=c.sent(),console.log(T.red(o.message)),[3,6];case 6:return r++,[3,1];case 7:return[2,null]}}))}))},Z=function(e){return g(void 0,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:t=0,r.label=1;case 1:return t<5?[4,q(e)]:[3,4];case 2:if(""===(n=r.sent()))return[2,null];if(""!==n&&42!==n.length)return console.log(T.red("Multicall address length must be 42")),[3,3];r.label=3;case 3:return t++,[3,1];case 4:return[2,null]}}))}))},X=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=/^[A-Za-z][0-9a-zA-Z]*$/g,n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent()))return[2,null];if(t.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},V=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=/^#[0-9A_F]{6}$/g,n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent()))return[2,null];if(t.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},Q=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){switch(s.label){case 0:n=/^[a-zA-Z0-9]{2,20}$/g,r=0,s.label=1;case 1:return r<5?[4,q(e)]:[3,4];case 2:if(a=(a=s.sent()).trim(),n.test(a))return t.includes(a)?(console.log(T.red("Account label already exists")),[3,3]):[2,a.toLocaleLowerCase()];s.label=3;case 3:return r++,[3,1];case 4:return[2,null]}}))}))},Y=function(e){var t="Password must contain at least: \n",n=!0,r=" ",a=T.green("✔"),s=T.red("✖");return e.length>=8?t+=r+a+" 8 characters\n":(t+=r+s+" 8 characters\n",n=!1),/[0-9]/.test(e)?t+=r+a+" One numerical character\n":(t+=r+s+" One numerical character\n",n=!1),/[A-Z]/.test(e)?t+=r+a+" One uppercase letter\n":(t+=r+s+" One uppercase letter\n",n=!1),/[!@#$%]/.test(e)?t+=r+a+" One sepcial character (i.e. !@#$%)\n":(t+=r+s+" One sepcial character (i.e. !@#$%)\n",n=!1),!!n||t},ee=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=[{name:"password",type:"password",mask:"#",message:"".concat(e,":"),validate:Y}],[4,f.default.prompt(t)];case 1:return[2,n.sent().password]}}))}))},te=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=[{name:"confirm",type:"confirm",message:"".concat(e)}],[4,f.default.prompt(t)];case 1:return[2,n.sent().confirm]}}))}))},ne=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=[{name:"editor",type:"editor",message:"".concat(e),validate:t}],[4,f.default.prompt(n)];case 1:return[2,r.sent().editor.trim().toString()]}}))}))},re=function(e){return!!/^0x[0-9a-fA-F]*$/g.test(e)},ae=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,e.apply(void 0,t)];case 1:return r=s.sent(),n={status:!0,output:r},[3,3];case 2:return a=s.sent(),n={status:!1,output:a.toString()},[3,3];case 3:return[2,n]}}))}))},se=function(e){return e.startsWith("0x")&&42===e.length?"evm":/^[A-HJ-NP-Za-km-z1-9]*$/.test(e)&&e.length<=44&&e.length>=32?"solana":"unknown"},oe=function(e){return e=e.trim(),d.existsSync(e)},ce=require("chalk"),ue=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){return n=p.join(e,"assets.json"),oe(n)?(r=d.readFileSync(n).toString(),a=JSON.parse(r),t in a?[2,a[t]]:[2,[]]):[2,[]]}))}))},ie=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s;return v(this,(function(o){switch(o.label){case 0:return[4,ue(e,t)];case 1:for(r=o.sent(),a=[],s=0;s<r.length;s++)r[s].symbol===n&&a.push(r[s]);return[2,a]}}))}))},le=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return r=ot(e,t),a=ct(e,t),[4,ue(e,a.chainId.toString())];case 1:return(s=i.sent())?[4,fe(n,s,a.rpcUrl,r)]:(console.log(ce.red("No asset found")),[2]);case 2:for(o=i.sent(),c=1,u=0;u<o.length;u++)"0"!==o[u].balance&&"0.0000"!==o[u].balance&&(console.log(ce.green("".concat(c,". ").concat(o[u].symbol," Balance: ").concat(o[u].balance))),c+=1);return 1===c&&console.log(ce.red("No asset found")),[2]}}))}))},de=function(e,t,n,r,a,s){return g(void 0,void 0,void 0,(function(){var o,c,u;return v(this,(function(i){return o=p.join(e,"assets.json"),c={},oe(o)&&(u=d.readFileSync(o).toString(),c=JSON.parse(u)),void 0===c[t]&&(c[t]=[]),c[t].push({address:n,symbol:r,name:a,decimals:s}),d.writeFileSync(o,JSON.stringify(c,null,4)),[2]}))}))},pe=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,q("Please input Token address",G)];case 1:return n=u.sent(),r=ot(e,t),a=ct(e,t),"evm"!==r?[3,3]:(i=n).startsWith("0x")&&42===i.length?[4,k(n,a.rpcUrl)]:(console.log(ce.red("evm address format error")),[2]);case 2:return s=u.sent(),[3,5];case 3:return function(e){return/^[A-HJ-NP-Za-km-z1-9]*$/.test(e)}(n)?[4,S(n,a.rpcUrl)]:(console.log(ce.red("solana address format error")),[2]);case 4:s=u.sent(),u.label=5;case 5:return s.status?s.output.name?[3,7]:(o=s.output,[4,q("Please input token name")]):(console.log(ce.red(s.output)),[2]);case 6:o.name=u.sent(),u.label=7;case 7:return s.output.symbol?[3,9]:(c=s.output,[4,q("Please input token symbol")]);case 8:c.symbol=u.sent(),u.label=9;case 9:return[4,de(e,a.chainId.toString(),n,s.output.symbol,s.output.name,s.output.decimals)];case 10:return u.sent(),console.log(ce.green("Asset added successfully")),[2]}var i}))}))},me=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r;return v(this,(function(a){switch(a.label){case 0:return[4,$(["> Show Assets","> Add Asset","> Back"])];case 1:switch(r=a.sent(),r){case"> Show Assets":return[3,2];case"> Add Asset":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,le(e,n,t)];case 3:case 5:return a.sent(),[3,7];case 4:return[4,pe(e,n)];case 6:return[2];case 7:return[4,me(e,t,n)];case 8:return a.sent(),[2]}}))}))},fe=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,i,l,d,p,m;return v(this,(function(f){switch(f.label){case 0:for(a=t.length,s=[],i=0;i<a;i++)l=t[i],"evm"===r?s.push(N(e,l.address,n)):"solana"===r&&s.push(x(e,l.address,n));return[4,Promise.all(s)];case 1:for(o=f.sent(),c=[],i=0;i<a;i++){if(l=t[i],d=l.decimals,!o[i].status)return console.log(ce.red(o[i].output)),[2,null];p=new u.BigNumber(o[i].output),m=p.dividedBy(Math.pow(10,d)).toFixed(4,u.BigNumber.ROUND_FLOOR),c.push({address:l.address,symbol:l.symbol,balance:m})}return[2,c]}}))}))},he=require("bn.js").BN,ge=require("ethereumjs-util").stripHexPrefix,ve=require("bignumber.js").BigNumber;function be(e){return new he(ge(e.toString("hex")),16)}var we=function(e){return e.match(/^-?0x/u)?e:e.match(/^-?0X/u)?e.replace("0X","0x"):e.startsWith("-")?e.replace("-","-0x"):"0x".concat(e)};function ye(e){return we(e.toString(16))}var ke=function(){function e(e){this.query=new h.default(h.default.givenProvider||e).eth}return e.prototype.analyzeGasUsage=function(e){return g(this,void 0,void 0,(function(){var t,n,r,a,s,o;return v(this,(function(c){switch(c.label){case 0:return[4,this.query.getBlock("latest",!1)];case 1:t=c.sent(),n=be(t.gasLimit),u=n,i=20,l=new he(19),d=new he(i),r=u.mul(l).div(d),a=ye(r),c.label=2;case 2:return c.trys.push([2,4,,5]),[4,this.estimateTxGas(e)];case 3:return a=c.sent(),[3,5];case 4:return o=c.sent(),s={reason:o.message,errorKey:o.errorKey,debug:{blockNumber:t.number,blockGasLimit:t.gasLimit}},[3,5];case 5:return[2,{blockGasLimit:t.gasLimit,estimatedGasHex:a,simulationFails:s}]}var u,i,l,d}))}))},e.prototype.estimateTxGas=function(e){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this.query.estimateGas(e)];case 1:return t=n.sent(),[2,t=new ve(t.toString()).multipliedBy(1.3).toFixed(0)]}}))}))},e.prototype.addGasBuffer=function(e,t,n){void 0===n&&(n=1.3);var r=be(e),a=be(t).muln(.9),s=r.muln(n);return r.gt(a)?ye(r):s.lt(a)?ye(s):ye(a)},e.prototype.getBufferedGasLimit=function(e,t){return g(this,void 0,void 0,(function(){var n,r,a,s;return v(this,(function(o){switch(o.label){case 0:return[4,this.analyzeGasUsage(e)];case 1:return n=o.sent(),r=n.blockGasLimit,a=n.estimatedGasHex,s=n.simulationFails,[2,{gasLimit:this.addGasBuffer(we(a),r,t),simulationFails:s}]}}))}))},e.prototype.getGasPrice=function(){return g(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this.query.getGasPrice()];case 1:return[2,e.sent()]}}))}))},e.prototype.getTransactionCount=function(e){return g(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this.query.getTransactionCount(e)];case 1:return[2,t.sent()]}}))}))},e}(),Se=require("chalk");require("wative-core").WativeCore;var Ne=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l;return v(this,(function(d){switch(d.label){case 0:return t=[new f.default.Separator("————Tx Detail—————-"),"from: ".concat(e.from),"to: ".concat(e.to),"nonce: ".concat(e.nonce),"gasPrice: ".concat(e.gasPrice),"data: ".concat(e.data),"value: ".concat(e.value),"gas: ".concat(e.gas),new f.default.Separator("——————————————-"),"Send it now"],[4,$(t)];case 1:return n=d.sent(),1!==(r=t.indexOf(n))?[3,3]:(a=e,[4,q("from",G)]);case 2:a.from=d.sent(),d.label=3;case 3:return 2!==r?[3,5]:(s=e,[4,q("to",G)]);case 4:s.to=d.sent(),d.label=5;case 5:return 3!==r?[3,7]:(o=e,[4,q("nonce")]);case 6:o.nonce=d.sent(),d.label=7;case 7:return 4!==r?[3,9]:(c=e,[4,q("gasPrice")]);case 8:c.gasPrice=d.sent(),d.label=9;case 9:return 5!==r?[3,11]:(u=e,[4,ne("data")]);case 10:u.data=d.sent(),d.label=11;case 11:return 6!==r?[3,13]:(i=e,[4,q("value")]);case 12:i.value=d.sent(),d.label=13;case 13:return 7!==r?[3,15]:(l=e,[4,q("gas")]);case 14:l.gas=d.sent(),d.label=15;case 15:return 9===r?[2,e]:[4,Ne(e)];case 16:return d.sent(),[2]}}))}))},xe=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,i,l,d,p,m,f,b,y,k,S,N,x,B,P,O,A,_,C,j,F,T,L,I,z,R;return v(this,(function(U){switch(U.label){case 0:return[4,q("to",G)];case 1:return a=U.sent(),[4,(s=new ke(e)).getGasPrice()];case 2:return o=U.sent(),c=new u.BigNumber(o.toString()).dividedBy(1e9),i=c.toFixed(4,u.BigNumber.ROUND_FLOOR),[4,q("Gas price (".concat(i,"), agree or enter"))];case 3:return l=U.sent(),d=l||i,d=new u.BigNumber(d).multipliedBy(1e9).toFixed(0),[4,(K=a,E=e,g(void 0,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return e=new h.default(E),[4,ae(e.eth.getCode.bind(e),[K])];case 1:return(t=n.sent()).status?[2,{status:!0,output:t.output}]:[2,{status:!1,output:"Failed to get code"}]}}))})))];case 4:return(p=U.sent()).status?"0x"!==p.output?[3,10]:(m="0x",[4,w(n,e)]):(console.log(Se.red(p.output)),[2]);case 5:return(b=U.sent()).status?(y=new u.BigNumber(b.output),k=new u.BigNumber(d),S=y.minus(k.multipliedBy(21e3)).toFixed(0,u.BigNumber.ROUND_FLOOR),N=new u.BigNumber(S).dividedBy(1e18).toFixed(4,u.BigNumber.ROUND_FLOOR),new u.BigNumber(N)<new u.BigNumber(0)?(console.log(Se.red("Not enough balance")),[2]):(x=["> Input value","> Total Balance (".concat(N," ").concat(t,")")],[4,$(x)])):(console.log(Se.red(b.output)),[2]);case 6:return B=U.sent(),0!==(P=x.indexOf(B))?[3,8]:[4,q("value",M)];case 7:return O=U.sent(),f=new u.BigNumber(O).multipliedBy(1e18).toFixed(0,u.BigNumber.ROUND_FLOOR),[3,9];case 8:1===P&&(f=S),U.label=9;case 9:return new u.BigNumber(f).isGreaterThan(new u.BigNumber(S))?(console.log(Se.red("Not enough balance")),[2]):[3,13];case 10:return[4,ne("data",re)];case 11:return m=U.sent(),[4,q("value",M)];case 12:f=U.sent(),U.label=13;case 13:return[4,s.getTransactionCount(n)];case 14:return A=U.sent(),[4,q("Nonce (".concat(A,"), agree or enter"))];case 15:return _=U.sent(),C=_||A.toString(),j={from:n,to:a,nonce:C,gasPrice:d,data:m,value:f},"0x"!==m?[3,16]:(j.gas="21000",[3,21]);case 16:F=j.gasPrice,delete j.gasPrice,U.label=17;case 17:return U.trys.push([17,19,,20]),T=j,L="gas",[4,s.estimateTxGas(j)];case 18:return T[L]=U.sent().toString(),[3,20];case 19:return I=U.sent(),console.log(Se.red("Error: "+I)),[2];case 20:j.gasPrice=F,U.label=21;case 21:return[4,Ne(j)];case 22:return j=U.sent(),[4,r.account.signTransaction(n,j,e)];case 23:return(z=U.sent()).status?[4,r.account.sendSignedTransaction(n,z.output.rawTransaction,e)]:(console.log(Se.red(z.output)),[2]);case 24:return(R=U.sent()).status?(console.log(Se.green("Transaction hash: ".concat(R.output.transactionHash))),[2]):(console.log(Se.red(R.output)),[2])}var K,E}))}))},Be=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,o,c,i,l,d,p,m,f,h,g,b,w,k,S,N,x,B,O,A;return v(this,(function(v){switch(v.label){case 0:return[4,q("to",G)];case 1:return a=v.sent(),(o=(new s.Transaction).add(s.SystemProgram.transfer({fromPubkey:new s.PublicKey(n),toPubkey:new s.PublicKey(a),lamports:1}))).add(s.ComputeBudgetProgram.setComputeUnitLimit({units:2e5})),o.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:1e3})),[4,r.account.simulateTransaction(n,e,o)];case 2:return(c=v.sent()).status?c.output&&c.output.value&&0!==c.output.value.unitsConsumed&&!c.output.value.err?(i=new u.BigNumber(c.output.value.unitsConsumed.toString()).multipliedBy(1.2).toFixed(0,u.BigNumber.ROUND_CEIL),l=new u.BigNumber(i),[4,P(e)]):(console.log(Se.red("Simulate error")),[2]):(console.log(Se.red(c.output)),[2]);case 3:return(d=v.sent()).status?(p=new u.BigNumber(d.output.toString()),m=l.multipliedBy(p).dividedBy(1e6).toFixed(0,u.BigNumber.ROUND_CEIL),[4,y(n,e)]):(console.log(Se.red(d.output)),[2]);case 4:return(f=v.sent()).status?(h=new u.BigNumber(f.output),g=h.minus(5e3).minus(m),b=new u.BigNumber(g).dividedBy(1e9).toFixed(4,u.BigNumber.ROUND_FLOOR),new u.BigNumber(b)<new u.BigNumber(0)?(console.log(Se.red("Not enough balance")),[2]):(w=["> Input value","> Total Balance (".concat(b," ").concat(t,")")],[4,$(w)])):(console.log(Se.red(f.output)),[2]);case 5:return k=v.sent(),S=w.indexOf(k),N="0",0!==S?[3,7]:[4,q("value",M)];case 6:return x=v.sent(),N=new u.BigNumber(x).multipliedBy(1e9).toFixed(0,u.BigNumber.ROUND_FLOOR),new u.BigNumber(N).isGreaterThan(new u.BigNumber(g))?(console.log(Se.red("Not enough balance")),[2]):[3,8];case 7:1===S&&(N=g.toString()),v.label=8;case 8:return(B=new s.Transaction).add(s.ComputeBudgetProgram.setComputeUnitLimit({units:Number(l)})),B.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:Number(p)})),B.add(s.SystemProgram.transfer({fromPubkey:new s.PublicKey(n),toPubkey:new s.PublicKey(a),lamports:Number(N)})),[4,r.account.signTransaction(n,B,e)];case 9:return(O=v.sent()).status?[4,r.account.sendSignedTransaction(n,O.output,e)]:(console.log(Se.red(O.output)),[2]);case 10:return(A=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(A.output))),[2]):(console.log(Se.red(A.output)),[2])}}))}))},Pe=function(e,t,n,r,a){return g(void 0,void 0,void 0,(function(){var s,o,c,i,l,d,p,m,f,h,g,b,w,y,S,x,P,O,A,_,C,j,F,T,L,I,z,R,U,K,E,J,D;return v(this,(function(v){switch(v.label){case 0:return[4,$(["> Input token ticker","> Input token contract address"])];case 1:switch(s=v.sent(),s){case"> Input token ticker":return[3,2];case"> Input token contract address":return[3,10]}return[3,13];case 2:return[4,q("token ticker")];case 3:return i=v.sent(),[4,ie(e,n,i)];case 4:if(0===(l=v.sent()).length)return console.log(Se.red("Token not found")),[2];d=[],p=0,v.label=5;case 5:return p<l.length?[4,N(r,l[p].address,t)]:[3,8];case 6:if(!(m=v.sent()).status)return console.log(Se.red(m.output)),[2];if(f=new u.BigNumber(m.output),h=f.dividedBy(Math.pow(10,Number(l[p].decimals))).toFixed(4,u.BigNumber.ROUND_FLOOR),1===l.length)return d.push("> 1. ".concat(i," Balance: ").concat(h)),[3,8];d.push("> ".concat(p+1,". ").concat(i," Balance: ").concat(h,"(").concat(l[p].address,")")),d.push(l[p].address),v.label=7;case 7:return p++,[3,5];case 8:return[4,$(d)];case 9:return g=v.sent(),b=l[d.indexOf(g)],o=b.address,c=Number(b.decimals),[3,13];case 10:return[4,q("token contract address",G)];case 11:return o=v.sent(),[4,k(o,t)];case 12:return(w=v.sent()).status?(c=Number(w.output.decimals),[3,13]):(console.log(Se.red(w.output)),[2]);case 13:return[4,q("Receipt",G)];case 14:return y=v.sent(),[4,q("Amount",M)];case 15:return S=v.sent(),[4,(x=new ke(t)).getGasPrice()];case 16:return P=v.sent(),O=new u.BigNumber(P.toString()).dividedBy(1e9),A=O.toFixed(4,u.BigNumber.ROUND_FLOOR),[4,q("Gas price (".concat(A,"), agree or enter"))];case 17:return _=v.sent(),C=_||A,C=new u.BigNumber(C).multipliedBy(1e9).toFixed(0),j=new u.BigNumber(S).multipliedBy(Math.pow(10,c)).toFixed(0),[4,B(y,j,t)];case 18:return F=v.sent(),[4,x.getTransactionCount(r)];case 19:return T=v.sent(),[4,q("Nonce (".concat(T,"), agree or enter"))];case 20:return L=v.sent(),I=L||T.toString(),z={from:r,to:o,nonce:I,gasPrice:C,data:F,value:"0"},"0x"!==F?[3,21]:(z.gas="21000",[3,26]);case 21:R=z.gasPrice,delete z.gasPrice,v.label=22;case 22:return v.trys.push([22,24,,25]),U=z,K="gas",[4,x.estimateTxGas(z)];case 23:return U[K]=v.sent().toString(),[3,25];case 24:return E=v.sent(),console.log(Se.red("Failed to estimate gas, "+E.message)),[2];case 25:z.gasPrice=R,v.label=26;case 26:return[4,Ne(z)];case 27:return z=v.sent(),[4,a.account.signTransaction(r,z,t)];case 28:return(J=v.sent()).status?[4,a.account.sendSignedTransaction(r,J.output.rawTransaction,t)]:(console.log(Se.red(J.output)),[2]);case 29:return(D=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(D.output.transactionHash))),[2]):(console.log(Se.red(D.output)),[2])}}))}))},Oe=function(e,t,n,r,a){return g(void 0,void 0,void 0,(function(){var c,i,l,d,p,m,f,h,g,b,w,y,k,N,B,A,_,C,j,F,T,L,I,z,R,U,K,E;return v(this,(function(v){switch(v.label){case 0:return[4,$(["> Input token ticker","> Input token contract address"])];case 1:switch(c=v.sent(),c){case"> Input token ticker":return[3,2];case"> Input token contract address":return[3,10]}return[3,13];case 2:return[4,q("token ticker")];case 3:return d=v.sent(),[4,ie(e,n,d)];case 4:if(0===(p=v.sent()).length)return console.log(Se.red("Token not found")),[2];m=[],f=0,v.label=5;case 5:return f<p.length?[4,x(r,p[f].address,t)]:[3,8];case 6:if(!(h=v.sent()).status)return console.log(Se.red(h.output)),[2];if(g=new u.BigNumber(h.output),b=g.dividedBy(Math.pow(10,Number(p[f].decimals))).toFixed(4,u.BigNumber.ROUND_FLOOR),1===p.length)return m.push("> 1. ".concat(d," Balance: ").concat(b)),[3,8];m.push("> ".concat(f+1,". ").concat(d," Balance: ").concat(b,"(").concat(p[f].address,")")),m.push(p[f].address),v.label=7;case 7:return f++,[3,5];case 8:return[4,$(m)];case 9:return w=v.sent(),y=p[m.indexOf(w)],i=y.address,l=Number(y.decimals),[3,13];case 10:return[4,q("token contract address",G)];case 11:return i=v.sent(),[4,S(i,t)];case 12:return(k=v.sent()).status?(l=Number(k.output.decimals),[3,13]):(console.log(Se.red(k.output)),[2]);case 13:return[4,q("Receipt",G)];case 14:return N=v.sent(),[4,q("Amount",M)];case 15:return B=v.sent(),A=new u.BigNumber(B).multipliedBy(Math.pow(10,l)).toFixed(0),_=o.getAssociatedTokenAddressSync(new s.PublicKey(i),new s.PublicKey(r),!0),[4,O(_.toString(),t)];case 16:return(C=v.sent()).status?C.output&&C.output.owner.toString()!==s.PublicKey.default?(j=o.getAssociatedTokenAddressSync(new s.PublicKey(i),new s.PublicKey(N),!1),[4,O(j.toString(),t)]):(console.log(Se.red("From token account not found")),[2]):(console.log(Se.red(C.output)),[2]);case 17:return(F=v.sent()).status?(T=new s.Transaction,L=new s.Transaction,F.output&&F.output.owner.toString()!==s.PublicKey.default||(T.add(o.createAssociatedTokenAccountInstruction(new s.PublicKey(r),new s.PublicKey(j),new s.PublicKey(N),new s.PublicKey(i))),L.add(o.createAssociatedTokenAccountInstruction(new s.PublicKey(r),new s.PublicKey(j),new s.PublicKey(N),new s.PublicKey(i)))),T.add(o.createTransferInstruction(_,j,new s.PublicKey(r),Number(A))),T.add(s.ComputeBudgetProgram.setComputeUnitLimit({units:2e5})),T.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:1e3})),[4,a.account.simulateTransaction(r,t,T)]):(console.log(Se.red(F.output)),[2]);case 18:return(I=v.sent()).status?I.output&&I.output.value&&0!==I.output.value.unitsConsumed&&!I.output.value.err?(z=new u.BigNumber(I.output.value.unitsConsumed.toString()),z=new u.BigNumber(Math.ceil(1.2*Number(z))),[4,P(t)]):(console.log(Se.red("Simulate error")),[2]):(console.log(Se.red(I.output)),[2]);case 19:return(R=v.sent()).status?(U=new u.BigNumber(R.output.toString()),L.add(o.createTransferInstruction(_,j,new s.PublicKey(r),Number(A))),L.add(s.ComputeBudgetProgram.setComputeUnitLimit({units:Number(z)})),L.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:Number(U)})),[4,a.account.signTransaction(r,L,t)]):(console.log(Se.red(R.output)),[2]);case 20:return(K=v.sent()).status?[4,a.account.sendSignedTransaction(r,K.output,t)]:(console.log(Se.red(K.output)),[2]);case 21:return(E=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(E.output))),[2]):(console.log(Se.red(E.output)),[2])}}))}))},Ae=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u,i,l,d;return v(this,(function(p){switch(p.label){case 0:return a=mt(e,t,n),s=ot(e,a),o=se(n),s!==o&&("evm"===o&&(a="Ethereum Mainnet"),"solana"===o&&(a="Solana Mainnet"),s=ot(e,a)),"evm"!==s?[3,3]:[4,te("Network (".concat(a,"), want a change?"))];case 1:return p.sent()?(c=ft(e),[4,$(c,"Select a network")]):[3,3];case 2:u=p.sent(),a=u,p.label=3;case 3:return[4,pt(n,e,a)];case 4:return(i=p.sent()).status?(l=ct(e,a),console.log(Se.green(" ".concat(l.nativeCurrency.symbol," Balance: ").concat(i.output))),[4,$(["> Send Raw Tx","> Send Token","> Back"])]):(console.log(Se.red(i.output)),[2]);case 5:switch(d=p.sent(),d){case"> Send Raw Tx":return[3,6];case"> Send Token":return[3,11];case"> Back":return[3,16]}return[3,17];case 6:return"evm"!==o?[3,8]:[4,xe(l.rpcUrl,l.nativeCurrency.symbol,n,r)];case 7:p.sent(),p.label=8;case 8:return"solana"!==o?[3,10]:[4,Be(l.rpcUrl,l.nativeCurrency.symbol,n,r)];case 9:p.sent(),p.label=10;case 10:return[3,17];case 11:return"evm"!==o?[3,13]:[4,Pe(e,l.rpcUrl,l.chainId.toString(),n,r)];case 12:p.sent(),p.label=13;case 13:return"solana"!==o?[3,15]:[4,Oe(e,l.rpcUrl,l.chainId.toString(),n,r)];case 14:p.sent(),p.label=15;case 15:return[3,17];case 16:case 17:return[2]}}))}))},_e=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o;return v(this,(function(c){switch(c.label){case 0:return[4,$(["> SendTx","> SignMessage","> Back"])];case 1:switch(a=c.sent(),a){case"> SendTx":return[3,2];case"> SignMessage":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Ae(e,t,n,r)];case 3:return c.sent(),[3,7];case 4:return[4,ne("Input the message to sign")];case 5:return s=c.sent(),(o=r.account.signMessage(n,s)).status?(console.log(Se.green("Signature: "+o.output)),[3,7]):(console.log(Se.red(o.output)),[3,7]);case 6:return[2];case 7:return[4,_e(e,t,n,r)];case 8:return c.sent(),[2]}}))}))},Ce=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return[4,q("Input the address to send tx",G)];case 1:return n=a.sent(),null!==(r=t.account.getAccountLabel(n))?[3,3]:(console.log(Se.red("Account not found")),[4,Ce(e,t)]);case 2:case 5:case 8:return a.sent(),[2];case 3:return[4,Me(r,t)];case 4:return a.sent()?[3,6]:[4,Ce(e,t)];case 6:return[4,_e(e,r,n,t)];case 7:return a.sent(),[4,Ce(e,t)]}}))}))},je=require("chalk"),Fe=require("cli-progress");require("wative-core").WativeCore;var Te=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s;return v(this,(function(o){switch(o.label){case 0:return t=ze(e),n=[],t.accounts&&(n=t.accounts),[4,Q("Account Label",n)];case 1:return null===(r=o.sent())?[2,null]:[4,ee("Please set a password for Account [".concat(r,"]"))];case 2:return a=o.sent(),[4,st(e)];case 3:return s=o.sent(),[2,{account_label:r,password:a,selected_default_network:s}]}}))}))},Le=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,Te(e)];case 1:return(n=u.sent())?[4,q("Please enter a mnemonic [split by space]",K)]:[2];case 2:return r=(r=u.sent()).replace(/\s+/g," "),(a=t.account.generatePPAccount(n.account_label,r,n.password)).status?(s=p.join(e,"accounts/".concat(n.account_label,".json")),a.output.default_network=n.selected_default_network,d.writeFileSync(s,JSON.stringify(a.output,null,4)),o=p.resolve(e,"network.json"),(c=JSON.parse(d.readFileSync(o,"utf8"))).accounts.push(n.account_label),d.writeFileSync(o,JSON.stringify(c,null,4)),[2]):(console.log(je.red(a.output)),[2])}}))}))},Ie=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return[4,Te(e)];case 1:return(n=i.sent())?[4,q("Please enter a private key")]:[2];case 2:return r=i.sent(),[4,ct(e,n.selected_default_network)];case 3:return a=i.sent(),[4,t.account.generatePKAccount(n.account_label,r,n.password,a.chainId)];case 4:return(s=i.sent()).status?(o=p.join(e,"accounts/".concat(n.account_label,".json")),s.output.default_network=n.selected_default_network,d.writeFileSync(o,JSON.stringify(s.output,null,4)),c=p.resolve(e,"network.json"),(u=JSON.parse(d.readFileSync(c,"utf8"))).accounts.push(n.account_label),d.writeFileSync(c,JSON.stringify(u,null,4)),[2]):(console.log(je.red(s.output)),[2])}}))}))},qe=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return[4,$(["> Import Passphrase","> Import Private Key","> Back"])];case 1:switch(n=r.sent(),n){case"> Import Passphrase":return[3,2];case"> Import Private Key":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Le(e,t)];case 3:case 5:return r.sent(),[3,7];case 4:return[4,Ie(e,t)];case 6:case 7:return[2]}}))}))},ze=function(e){var t=p.resolve(e,"network.json");return JSON.parse(d.readFileSync(t,"utf8"))},Re=function(e,t){var n=p.join(e,"accounts/".concat(t,".json"));return JSON.parse(d.readFileSync(n,"utf8"))},Ue=function(e,t,n){var r=p.join(e,"accounts/".concat(t,".json"));d.writeFileSync(r,JSON.stringify(n,null,4))},Me=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return t.account.isLogin(e)?[2,!0]:[4,ee("Please input the password for Account [".concat(e,"]"))];case 1:return n=a.sent(),[4,t.account.login(e,n)];case 2:return(r=a.sent()).status?[2,!0]:(console.log(je.red(r.output)),[2,!1])}}))}))},Ke=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l;return v(this,(function(d){switch(d.label){case 0:if(n=ze(e),r=n.accounts,a=["> Back"],0===(s=r.length))return console.log(je.red("No address here yet")),[2];for(o=0;o<s;o++)c=r[o],"PP"===(u=Re(e,c)).account_type?a.push("".concat(o+1,") ").concat(c," [").concat(u.account_type,":").concat(u.data.length,"]")):a.push("".concat(o+1,") ").concat(c," [").concat(u.account_type,":1]"));return[4,$(a,"Select an account")];case 1:return"> Back"===(i=d.sent())?[2]:(l=r[a.indexOf(i)-1],[4,Me(l,t)]);case 2:return d.sent()?[4,Je(e,l,t)]:[3,4];case 3:d.sent(),d.label=4;case 4:return[4,Ke(e,t)];case 5:return d.sent(),[2]}}))}))},Ee=function(e,t,n){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l,d,p,m,f,h,g,b,w,y,k;return v(this,(function(v){switch(v.label){case 0:return[4,Re(e,t)];case 1:return n=v.sent(),[4,$(["> Back","1.Disabled Slots","2.Add Single","3.Add Range"])];case 2:switch(r=v.sent(),r){case"> Back":return[3,3];case"1.Disabled Slots":return[3,4];case"2.Add Single":return[3,7];case"3.Add Range":return[3,9]}return[3,11];case 3:return[2];case 4:if(!(a=n.disabled_slots)||0===a.length)return console.log(je.red("No disabled slots here yet")),[3,11];for(s=n.data,o=["> Back"],c=n.default_network,u=0;u<a.length;u++){if(i=a[u].from,l=a[u].to,d=c,p=c,"default_network"in s[i]&&(d=s[i].default_network),"default_network"in s[l]&&(p=s[l].default_network),m=ot(e,d),f=ot(e,p),"evm"!==m&&"solana"!==m)throw new Error("Invalid network type: ".concat(m));if("evm"!==f&&"solana"!==f)throw new Error("Invalid network type: ".concat(f));h=void 0,g=void 0,h="evm"===m?s[i].ciphertexts.evm.address:s[l].ciphertexts.solana.address,g="evm"===f?s[l].ciphertexts.evm.address:s[l].ciphertexts.solana.address,i===l?o.push("".concat(u+1,". ").concat(h,"[").concat(i,"]")):o.push("".concat(u+1,". ").concat(h,"[").concat(i,"]-").concat(g,"[").concat(l,"]"))}return[4,$(o)];case 5:return"> Back"===(b=v.sent())?[3,11]:[4,te("Are you sure to delete the ".concat(b,"?"))];case 6:return v.sent()?(w=o.indexOf(b)-1,n.disabled_slots.splice(w,1),Ue(e,t,n),[3,11]):[3,11];case 7:return[4,R(n,"Input address or index")];case 8:return null===(y=v.sent())?(console.log(je.red("Invalid account index")),[3,11]):(n.disabled_slots?n.disabled_slots.push({from:y,to:y}):n.disabled_slots=[{from:y,to:y}],Ue(e,t,n),[3,11]);case 9:return[4,z(n)];case 10:return(k=v.sent())?(n.disabled_slots?n.disabled_slots.push(k):n.disabled_slots=[k],Ue(e,t,n),[3,11]):(console.log(je.red("Invalid account range")),[3,11]);case 11:return[4,Ee(e,t)];case 12:return v.sent(),[2]}}))}))},Je=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i;return v(this,(function(l){switch(l.label){case 0:return[4,Re(e,t)];case 1:return r=l.sent(),a="PP"===r.account_type?["1.Address List","2.Expand Address","3.Slice Address","4.Disable Address","5.Reset Account Password","6.Switch Networks [".concat(r.default_network,"]"),"> Back"]:["1.Address List","2.Reset Account Password","3.Switch Networks [".concat(r.default_network,"]"),"> Back"],[4,$(a)];case 2:switch(s=l.sent(),s){case"1.Address List":return[3,3];case"2.Expand Address":return[3,8];case"3.Slice Address":return[3,11];case"4.Disable Address":return[3,14];case"5.Reset Account Password":return[3,16];case"3.Switch Networks [".concat(r.default_network,"]"):return[3,20];case"6.Switch Networks [".concat(r.default_network,"]"):return[3,22];case"2.Reset Account Password":return[3,24];case"> Back":return[3,28]}return[3,29];case 3:return"PP"!==r.account_type?[3,5]:[4,De(e,t,n)];case 4:return l.sent(),[3,7];case 5:return[4,$e(e,t,n)];case 6:l.sent(),l.label=7;case 7:return[3,29];case 8:return[4,q("Expand accounts count",E)];case 9:return o=l.sent(),Number(o)>2e3?(console.log(je.red("Too many accounts, please input less than 2000")),[3,29]):[4,We(e,t,Number(o),n)];case 10:return l.sent(),[3,29];case 11:return[4,q("Please input last account number",J)];case 12:return c=l.sent(),[4,Ze(e,t,Number(c),n)];case 13:return l.sent(),[3,29];case 14:return[4,Ee(e,t)];case 15:return l.sent(),[3,29];case 16:return[4,ee("Please input new password for Account [".concat(t,"]"))];case 17:return u=l.sent(),[4,ee("Please confirm new password for Account [".concat(t,"]"))];case 18:return i=l.sent(),u!==i?(console.log(je.red("Passwords do not match")),[3,29]):[4,n.account.resetPassword(t,u)];case 19:return l.sent(),[2];case 20:return[4,dt(e,t,!0)];case 21:return l.sent(),[3,29];case 22:return[4,dt(e,t,!0)];case 23:return l.sent(),[3,29];case 24:return[4,ee("Please input new password for Account [".concat(t,"]"))];case 25:return u=l.sent(),[4,ee("Please confirm new password for Account [".concat(t,"]"))];case 26:return i=l.sent(),u!==i?(console.log(je.red("Passwords do not match")),[3,29]):[4,n.account.resetPassword(t,u)];case 27:return l.sent(),[2];case 28:return[2];case 29:return[4,Je(e,t,n)];case 30:return l.sent(),[2]}}))}))},De=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,d,p;return v(this,(function(m){switch(m.label){case 0:return[4,Re(e,t)];case 1:for(r=m.sent(),a=["> Back"],s=r.disabled_slots,o=0;o<r.data.length;o++)c=r.default_network,"default_network"in r.data[o]&&(c=r.data[o].default_network),u=ot(e,c),i="","tag"in r.data[o]&&(i="(".concat(r.data[o].tag,")")),l=n.account.checkIsDisableAddress(s,o),"evm"===u?l?a.push(new f.default.Separator(je.yellow("#".concat(o," ").concat(r.data[o].ciphertexts.evm.address," ").concat(i," [").concat(c,"]")))):a.push("#".concat(o," ").concat(r.data[o].ciphertexts.evm.address," ").concat(i," [").concat(c,"]")):"solana"===u&&(l?a.push(new f.default.Separator(je.yellow("#".concat(o," ").concat(r.data[o].ciphertexts.solana.address," ").concat(i," [").concat(c,"]")))):a.push("#".concat(o," ").concat(r.data[o].ciphertexts.solana.address," ").concat(i," [").concat(c,"]")));return[4,$(a,"Select an account")];case 2:return"> Back"===(d=m.sent())?[2]:(p=a.indexOf(d)-1,[4,Ge(e,t,p,n)]);case 3:return m.sent(),[4,De(e,t,n)];case 4:return m.sent(),[2]}}))}))},Ge=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u,i,l,d,p,m,f;return v(this,(function(h){switch(h.label){case 0:return[4,Re(e,t)];case 1:return a=h.sent(),s=a.default_network,"default_network"in a.data[n]&&(s=a.data[n].default_network),[4,ct(e,s)];case 2:return o=h.sent(),c=ut(e,t,n),[4,pt(c,e,s)];case 3:return(u=h.sent()).status?console.log(je.green(" Address No: #".concat(n,"\n Network: ").concat(s,"\n ").concat(o.nativeCurrency.symbol," Balance: ").concat(u.output))):console.log(je.green(" Address No: #".concat(n,"\n Network: ").concat(s,"\n ").concat(o.nativeCurrency.symbol))),i="> Tag()","tag"in a.data[n]&&""!==a.data[n].tag&&(i="> Tag(".concat(a.data[n].tag,")")),[4,$([i,"> Switch network","> Assets","> Tools","> Dump private key","> Back"])];case 4:switch(l=h.sent(),l){case i:return[3,5];case"> Switch network":return[3,7];case"> Assets":return[3,9];case"> Tools":return[3,11];case"> Dump private key":return[3,13];case"> Back":return[3,15]}return[3,16];case 5:return d="Current tag ()","tag"in a.data[n]&&""!==a.data[n].tag&&(d="Current tag (".concat(a.data[n].tag,")")),[4,q(d,U)];case 6:return p=(p=h.sent()).replace(/\s+/g," ").trim(),a.data[n].tag=p.toLocaleLowerCase(),Ue(e,t,a),[3,16];case 7:return[4,lt(e,t,n)];case 8:case 10:case 12:return h.sent(),[3,16];case 9:return[4,me(e,c,s)];case 11:return[4,_e(e,t,c,r)];case 13:return m=ut(e,t,n),[4,r.account.showPrivateKey(m)];case 14:return f=h.sent(),console.log("account: ",m),console.log("private key: ",f),[3,16];case 15:case 16:return[2]}}))}))},$e=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,Re(e,t)];case 1:return r=u.sent(),a=["> Back"],s="","tag"in r&&""!==r.tag&&(s="(".concat(r.tag,")")),a.push("#0 ".concat(r.ciphertexts.address," ").concat(s," [").concat(r.default_network,"]")),[4,$(a,"Select an account")];case 2:return"> Back"===u.sent()?[2]:(o=r.default_network,[4,ct(e,o)]);case 3:return c=u.sent(),console.log(je.green(" Address No: #0\n Network: ".concat(o,"\n ").concat(c.nativeCurrency.symbol," Balance: 0"))),[4,He(e,t,n)];case 4:return u.sent(),[4,$e(e,t,n)];case 5:return u.sent(),[2]}}))}))},He=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i;return v(this,(function(l){switch(l.label){case 0:return[4,Re(e,t)];case 1:return r=l.sent(),a="> Tag()","tag"in r&&""!==r.tag&&(a="> Tag(".concat(r.tag,")")),[4,$([a,"> Switch network","> Assets","> Tools","> Dump private key","> Back"])];case 2:switch(s=l.sent(),s){case a:return[3,3];case"> Switch network":return[3,5];case"> Assets":return[3,7];case"> Tools":return[3,9];case"> Dump private key":return[3,11];case"> Back":return[3,13]}return[3,14];case 3:return o="Current tag ()","tag"in r&&""!==r.tag&&(o="Current tag (".concat(r.tag,")")),[4,q(o,U)];case 4:return c=l.sent(),r.tag=c.replace(/\s+/g," ").trim().toLocaleLowerCase(),Ue(e,t,r),[3,14];case 5:return[4,dt(e,t,!1)];case 6:case 8:case 10:return l.sent(),[3,14];case 7:return u=it(e,t),[4,me(e,u,r.default_network)];case 9:return u=it(e,t),[4,_e(e,t,u,n)];case 11:return u=it(e,t),[4,n.account.showPrivateKey(u)];case 12:return i=l.sent(),console.log("account: ",u),console.log("private key: ",i),[3,14];case 13:return[2];case 14:return[4,He(e,t,n)];case 15:return l.sent(),[2]}}))}))},We=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return[4,Re(e,t)];case 1:a=i.sent(),s=a.data.length,(o=new Fe.SingleBar({},Fe.Presets.legacy)).start(n,0),c=s,i.label=2;case 2:return c<s+n?[4,r.account.generateSubAccount(t,c)]:[3,5];case 3:if(!(u=i.sent()).status)return console.log(je.red(u.output)),[2];a.data.push({ciphertexts:u.output}),o.increment(),i.label=4;case 4:return c++,[3,2];case 5:return o.stop(),Ue(e,t,a),[2]}}))}))},Ze=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a;return v(this,(function(s){switch(s.label){case 0:return[4,Re(e,t)];case 1:return(a=s.sent()).data=a.data.slice(0,n+1),Ue(e,t,a),r.account.reloadAccount(),[2]}}))}))},Xe=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=p.resolve(e,"accounts"),d.existsSync(n)||d.mkdirSync(n),[4,$(["> Select an account","> Create a new account","> Back"])];case 1:switch(r=a.sent(),r){case"> Select an account":return[3,2];case"> Create a new account":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Ke(e,t)];case 3:case 5:return a.sent(),[3,7];case 4:return[4,qe(e,t)];case 6:return[2];case 7:return[4,Xe(e,t)];case 8:return a.sent(),[2]}}))}))},Ve=require("chalk"),Qe=function(e){return g(void 0,void 0,void 0,(function(){var t,n;return v(this,(function(r){return t=p.resolve(e,"network.json"),d.existsSync(t)||(n={networks:_,currentNetwork:"Ethereum Mainnet",accounts:[]},d.writeFileSync(t,JSON.stringify(n,null,2))),[2]}))}))},Ye=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=["> Edit"],"Ethereum Mainnet"!==t.name&&"Solana Mainnet"!==t.name&&n.push("> Remove"),n.push("> Back"),[4,$(n)];case 1:switch(r=a.sent(),r){case"> Edit":return[3,2];case"> Remove":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,et(e,t)];case 3:case 5:return a.sent(),[3,7];case 4:return[4,tt(e,t)];case 6:return[3,7];case 7:return[2]}}))}))},et=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l,m,f,h,g;return v(this,(function(v){switch(v.label){case 0:for(n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=[],g=0;g<r.networks.length;g++)s=r.networks[g],a.push(s.name);return o=t.rpcUrl,c=t.chainId.toString(),u=t.nativeCurrency.symbol,i=t.name,l=t.multicallAddress,m=t.color,"Ethereum Mainnet"!==t.name&&"Solana Mainnet"!==t.name?[3,2]:[4,W(t.chainId.toString(),"Rpc Url (default: ".concat(t.rpcUrl,")"),!0)];case 1:return o=v.sent(),[3,9];case 2:return[4,q("Chain Name (default: ".concat(t.name,")"))];case 3:return(i=v.sent())&&i!==t.name&&a.includes(i)?(console.log(Ve.red("Chain Name already exists")),[2]):[4,H("Chain Id (default: ".concat(t.chainId,")"),!0)];case 4:return c=v.sent(),[4,W(c||t.chainId,"RPC Url (default: ".concat(t.rpcUrl,")"),!0)];case 5:return o=v.sent(),[4,X("Symbol (default: ".concat(t.nativeCurrency.symbol,")"))];case 6:return u=v.sent(),[4,Z(t.multicallAddress?"Multicall Address (Optional) (default: ".concat(t.multicallAddress,")"):"Multicall Address (Optional)")];case 7:return l=v.sent(),[4,V(t.color?"Color (Optional): (default: ".concat(t.color,")"):"Color (Optional)")];case 8:m=v.sent(),v.label=9;case 9:for(f=j(c),h={name:i||t.name,chainId:Number(c)||t.chainId,rpcUrl:o||t.rpcUrl,nativeCurrency:{name:u||t.nativeCurrency.symbol,symbol:u||t.nativeCurrency.symbol,decimals:f||t.nativeCurrency.decimals}},(l||t.multicallAddress)&&(h.multicallAddress=l||t.multicallAddress),(m||t.color)&&(h.color=m||t.color),g=0;g<r.networks.length;g++)if(r.networks[g].name===t.name){r.networks[g]=h;break}return d.writeFileSync(n,JSON.stringify(r,null,2)),[2]}}))}))},tt=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){for(n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++)if(r.networks[a].name===t.name){r.networks.splice(a,1);break}return t.name===r.currentNetwork&&(r.currentNetwork="Ethereum Mainnet"),d.writeFileSync(n,JSON.stringify(r,null,2)),[2]}))}))},nt=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l,m,f,h;return v(this,(function(g){switch(g.label){case 0:for(t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=[],a=0;a<n.networks.length;a++)s=n.networks[a],r.push(s.name);return console.log(Ve.green("Please input someting about network")),[4,q("Chain Name")];case 1:return o=g.sent(),r.includes(o)?(console.log(Ve.red("Chain Name already exists")),[2]):[4,H("Chain Id")];case 2:return(c=g.sent())?[4,W(c,"RPC Url")]:[2];case 3:return(u=g.sent())?[4,X("Symbol")]:[2];case 4:return(i=g.sent())?[4,Z("Multicall Address (Optional)")]:[2];case 5:return l=g.sent(),[4,V("Color (Optional)")];case 6:return m=g.sent(),f=j(c),h={name:o,chainId:Number(c),rpcUrl:u,nativeCurrency:{name:i,symbol:i,decimals:f}},l&&(h.multicallAddress=l),m&&(h.color=m),n.networks.push(h),d.writeFileSync(t,JSON.stringify(n,null,2)),[2]}}))}))},rt=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l,m,h,g;return v(this,(function(v){switch(v.label){case 0:for(t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=[],a=[],c=0;c<n.networks.length;c++)i=n.networks[c],"solana"===F(i.chainId.toString())?a.push(c):r.push(c);for(s=["> Back",new f.default.Separator("----Networks(evm)----")],c=0;c<r.length;c++)o=r[c],i=n.networks[o],l="".concat(c+1,".").concat(i.name),0===c&&(l+=" 🔒"),s.push(l);for(s.push(new f.default.Separator("----Networks(solana)----")),c=0;c<a.length;c++)u=a[c],i=n.networks[u],l="".concat(c+1,".").concat(i.name),0===c&&(l+=" 🔒"),s.push(l);return[4,$(s)];case 1:return"> Back"===(m=v.sent())?[2]:(h=s.indexOf(m),g=h<r.length+2?n.networks[r[h-2]]:n.networks[a[h-r.length-3]],[4,Ye(e,g)]);case 2:return v.sent(),[4,rt(e)];case 3:return v.sent(),[2]}}))}))},at=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,$(["> Available Networks","> Add Network","> Back"])];case 1:switch(t=n.sent(),t){case"> Available Networks":return[3,2];case"> Add Network":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,rt(e)];case 3:case 5:return n.sent(),[3,7];case 4:return[4,nt(e)];case 6:return[2];case 7:return[4,at(e)];case 8:return n.sent(),[2]}}))}))},st=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:return t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=n.networks.map((function(e){return"> ".concat(e.name)})),[4,$(r,"Please select a default network")];case 1:return[2,a.sent().slice(2)]}}))}))},ot=function(e,t){for(var n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++){var s=r.networks[a];if(s.name===t)return F(s.chainId.toString())}return"unknown"},ct=function(e,t){for(var n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++){var s=r.networks[a];if(s.name===t)return s}return null},ut=function(e,t,n){var r=Re(e,t),a=r.default_network;r.data[n].default_network&&""!==r.data[n].default_network&&(a=r.data[n].default_network);var s=ot(e,a);return"solana"===s?r.data[n].ciphertexts.solana.address:"evm"===s?r.data[n].ciphertexts.evm.address:null},it=function(e,t){return Re(e,t).ciphertexts.address},lt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,m,f,h,g,b,w;return v(this,(function(v){switch(v.label){case 0:for(r=p.resolve(e,"network.json"),a=JSON.parse(d.readFileSync(r,"utf8")),s=a.networks,o=s.length,c=Re(e,t),u=["> Back"],(i=c.data[n].default_network)&&""!==i?u.push("○ Same as the account setting"):u.push("● Same as the account setting"),l=0;l<o;l++)m=s[l],f=void 0,f=F(m.chainId.toString())?c.data[n].ciphertexts.solana.address:c.data[n].ciphertexts.evm.address,m.name===i?u.push("● ".concat(f," [").concat(m.name,"]")):u.push("○ ".concat(f," [").concat(m.name,"]"));return[4,$(u)];case 1:return"> Back"===(h=v.sent())||(1===(g=u.indexOf(h))?delete c.data[n].default_network:c.data[n].default_network=s[g-2].name,Ue(e,t,c),b=c.default_network,"default_network"in c.data[n]&&""!==c.data[n].default_network&&(b=c.data[n].default_network),w=ct(e,b),console.log(Ve.green(" Address No: #".concat(n,"\n Network: ").concat(b,"\n ").concat(w.nativeCurrency.symbol," Balance: 0")))),[2]}}))}))},dt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,m,f,h,g,b,w,y,k,S;return v(this,(function(v){switch(v.label){case 0:for(r=p.resolve(e,"network.json"),a=JSON.parse(d.readFileSync(r,"utf8")),s=a.networks,o=s.length,c=Re(e,t),u=["> Back"],i=c.default_network,l="",n||(l=c.ciphertexts.address),m=[],f=ot(e,i),h=0;h<o;h++)g=s[h],b=ot(e,g.name),"PK"===c.account_type&&f!==b||(g.name===i?n?u.push("● ".concat(g.name)):u.push("● ".concat(l," [").concat(g.name,"]")):n?u.push("○ ".concat(g.name)):u.push("○ ".concat(l," [").concat(g.name,"]")),m.push(g.name));return[4,$(u)];case 1:return"> Back"===(w=v.sent())||(y=u.indexOf(w),c.default_network=m[y-1],Ue(e,t,c),n||(k=c.default_network,S=ct(e,k),console.log(Ve.green(" Address No: #0\n Network: ".concat(k,"\n ").concat(S.nativeCurrency.symbol," Balance: 0"))))),[2]}}))}))},pt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c;return v(this,(function(i){switch(i.label){case 0:return r=ct(t,n),a=r.rpcUrl,s=r.nativeCurrency.decimals,"solana"!==F(r.chainId.toString())?[3,2]:[4,y(e,a)];case 1:return o=i.sent(),[3,4];case 2:return[4,w(e,a)];case 3:o=i.sent(),i.label=4;case 4:return o.status&&(c=new u.BigNumber(o.output.toString()),o.output=c.dividedBy(Math.pow(10,s)).toFixed(4,u.BigNumber.ROUND_FLOOR)),[2,o]}}))}))},mt=function(e,t,n){var r=Re(e,t);if("PK"===r.account_type)return r.default_network;for(var a=0;a<r.data.length;a++)if(r.data[a].ciphertexts.solana.address===n||r.data[a].ciphertexts.evm.address===n)return"default_network"in r.data[a]?r.data[a].default_network:r.default_network;return null},ft=function(e){for(var t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")).networks,r=n.length,a=[],s=0;s<r;s++)"evm"===F(n[s].chainId.toString())&&a.push(n[s].name);return a};require("wative-core").WativeCore;var ht=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return[4,$(["> System & Settings","> Accounts","> Tools","> Exit"])];case 1:switch(n=r.sent(),n){case"> System & Settings":return[3,2];case"> Accounts":return[3,4];case"> Tools":return[3,6];case"> Exit":return[3,8]}return[3,9];case 2:return[4,at(e)];case 3:case 5:case 7:return r.sent(),[3,9];case 4:return[4,Xe(e,t)];case 6:return[4,Ce(e,t)];case 8:return[2];case 9:return[4,ht(e,t)];case 10:return r.sent(),[2]}}))}))},gt=require("wative-core").WativeCore,vt=require("../package.json");require("events").EventEmitter.defaultMaxListeners=0;process.on("unhandledRejection",(function(e,t){console.log("Unhandled Rejection at:",t,"reason:",e)})),g(void 0,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(a){switch(a.label){case 0:return console.log("version:",vt.version),console.log(T.green(m.textSync("Wative",{font:"Ghost",horizontalLayout:"default",verticalLayout:"default"}))),[4,g(void 0,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,q("Keystore storage located in (default: ".concat(I,")"))];case 1:return(e=t.sent())||(e=I),e=(e=e.trim()).replace("~",L),d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),[2,e]}}))}))];case 1:return e=a.sent(),[4,Qe(e)];case 2:return a.sent(),t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=new gt(e,n.accounts,null,!0),[4,ht(e,r)];case 3:return a.sent(),[2]}}))})).then((function(){return process.exit(0)})).catch((function(e){console.log(e.message),process.exit(1)}))}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("fs"),require("path"),require("figlet"),require("inquirer"),require("web3"),require("@solana/web3.js"),require("@solana/spl-token"),require("@metaplex-foundation/js"),require("bignumber.js")):"function"==typeof define&&define.amd?define(["fs","path","figlet","inquirer","web3","@solana/web3.js","@solana/spl-token","@metaplex-foundation/js","bignumber.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.figlet,e.inquirer,e.Web3,e.web3_js,e.splToken,e.js,e.bignumber_js)}(this,(function(e,t,n,r,a,s,o,c,u){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var d=l(e),p=l(t),f=l(n),m=i(r),h=i(a);function g(e,t,n,r){return new(n||(n=Promise))((function(a,s){function o(e){try{u(r.next(e))}catch(e){s(e)}}function c(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,c)}u((r=r.apply(e,t||[])).next())}))}function v(e,t){var n,r,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var b=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new h.default(e),[4,ae(t.eth.getChainId,[])];case 1:return[2,n.sent()]}}))}))},w=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=new h.default(t),[4,ae(n.eth.getBalance,[e])];case 1:return[2,r.sent()]}}))}))},y=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=new s.Connection(t),[4,ae(n.getBalance.bind(n),[new s.PublicKey(e)])];case 1:return[2,r.sent()]}}))}))},k=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o;return v(this,(function(c){switch(c.label){case 0:return n=new h.default(t),r=new n.eth.Contract([{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],e),[4,ae(r.methods.symbol().call.bind(r),[])];case 1:return a=c.sent(),[4,ae(r.methods.name().call.bind(r),[])];case 2:return s=c.sent(),[4,ae(r.methods.decimals().call.bind(r),[])];case 3:return o=c.sent(),a.status&&s.status&&o.status?[2,{status:!0,output:{symbol:a.output,name:s.output,decimals:o.output}}]:[2,{status:!1,output:"Failed to get token info"}]}}))}))},S=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,u,i,l,d;return v(this,(function(p){switch(p.label){case 0:return n=new s.Connection(t),r=c.Metaplex.make(n),a=new s.PublicKey(e),[4,ae(o.getMint,[n,a])];case 1:if(u=p.sent(),i={status:!0,output:{symbol:"",name:"",decimals:""}},!u.status)return[2,{status:!1,output:"Failed to get token decimals"}];i.output.decimals=u.output.decimals,p.label=2;case 2:return p.trys.push([2,6,,7]),l=r.nfts().pdas().metadata({mint:a}),[4,n.getAccountInfo(l)];case 3:return p.sent()?[4,r.nfts().findByMint({mintAddress:a})]:[3,5];case 4:d=p.sent(),i.output.name=d.name,i.output.symbol=d.symbol,p.label=5;case 5:return[3,7];case 6:return p.sent(),[2,{status:!1,output:"Failed to get token name"}];case 7:return[2,i]}}))}))},N=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s;return v(this,(function(o){switch(o.label){case 0:return r=new h.default(n),a=new r.eth.Contract([{constant:!0,inputs:[{name:"who",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],t),[4,ae(a.methods.balanceOf(e).call.bind(a),[])];case 1:return(s=o.sent()).status?[2,{status:!0,output:s.output}]:[2,{status:!1,output:"Failed to get token balance"}]}}))}))},x=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,c;return v(this,(function(u){switch(u.label){case 0:return r=new s.Connection(n),a=o.getAssociatedTokenAddressSync(new s.PublicKey(t),new s.PublicKey(e)),[4,ae(r.getTokenAccountBalance.bind(r),[a])];case 1:return(c=u.sent()).status?[2,{status:!0,output:c.output.value.amount}]:c.output.includes("could not find account")?[2,{status:!0,output:"0"}]:[2,{status:!1,output:"Failed to get token balance"}]}}))}))},B=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r;return v(this,(function(a){return r=new h.default(n),[2,r.eth.abi.encodeFunctionCall({constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},[e,t])]}))}))},P=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a;return v(this,(function(o){switch(o.label){case 0:return t=new s.Connection(e),[4,ae(t.getRecentPrioritizationFees.bind(t),[])];case 1:return(n=o.sent()).status?(r=n.output,a=r.map((function(e){return e.prioritizationFee})).sort(),[2,{status:!0,output:a.length>0?Math.ceil(a.reduce((function(e,t){return e+t}))/a.length):1e3}]):[2,{status:!1,output:"Failed to get recent prioritization fees"}]}}))}))},O=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=new s.Connection(t),[4,ae(n.getAccountInfo.bind(n),[new s.PublicKey(e.toString())])];case 1:return(r=a.sent()).status?[2,{status:!0,output:r.output}]:[2,{status:!1,output:"Failed to get account info"}]}}))}))},A=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"],_=[{name:"Ethereum Mainnet",chainId:1,rpcUrl:"https://eth.llamarpc.com",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},multicallAddress:"0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441"},{name:"Solana Mainnet",chainId:901,rpcUrl:"https://api.mainnet-beta.solana.com",nativeCurrency:{name:"SOL",symbol:"SOL",decimals:9}}],C=["901","902","903"],j=function(e){return C.includes(e)?9:18},F=function(e){return C.includes(e)?"solana":"evm"},T=require("chalk"),L=process.env.HOME||process.env.USERPROFILE,I="".concat(L,"/.wative"),q=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=[{name:"inputText",type:"input",message:"".concat(e,":"),validate:t}],[4,m.default.prompt(n)];case 1:return[2,r.sent().inputText.trim().toString()]}}))}))},z=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=0,a.label=1;case 1:return t<5?[4,R(e,"Input start address or index")]:[3,5];case 2:return(n=a.sent())?[4,R(e,"Input end address or index")]:(console.log(T.red("Invalid start account index")),[2,null]);case 3:return(r=a.sent())?n>r?(console.log(T.red("Invalid address range")),[3,4]):[2,{from:n,to:r}]:(console.log(T.red("Invalid end account index")),[2,null]);case 4:return t++,[3,1];case 5:return[2,null]}}))}))},R=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i;return v(this,(function(l){switch(l.label){case 0:if(n=e.data,0===(r=n.length))return[2,null];for(a=[],s=[],c=0;c<r;c++)a.push(n[c].ciphertexts.evm.address.toLocaleLowerCase()),s.push(n[c].ciphertexts.solana.address.toLocaleLowerCase());o=r-1,c=0,l.label=1;case 1:return c<5?[4,q(t,D)]:[3,4];case 2:if(u=l.sent(),"unknown"===(i=se(u)))return Number(u)>o?(console.log(T.red("Invalid account index")),[3,3]):[2,Number(u)];if("evm"===i&&-1!==a.indexOf(u.toLocaleLowerCase()))return[2,a.indexOf(u.toLocaleLowerCase())];if("solana"===i&&-1!==s.indexOf(u.toLocaleLowerCase()))return[2,s.indexOf(u.toLocaleLowerCase())];l.label=3;case 3:return c++,[3,1];case 4:return[2,null]}}))}))},U=function(e){return""===e||((e=e.replace(/\s+/g," ").trim()).length>10?"Tag length should be less than 10":!1!==/^[0-9a-zA-Z\s]*$/g.test(e)||"Tag should be alphanumeric")},M=function(e){return!isNaN(Number(e))||"Value should be a number"},K=function(e){var t=(e=e.replace(/\s+/g," ")).split(/\s+/g);if(12!==t.length)return"Passphrase should be equal to 12 words";for(var n=0;n<t.length;n++)if(!1===A.includes(t[n]))return"Passphrase word should be valid";return!0},E=function(e){var t=Number(e);return isNaN(t)?"Amount should be a number":!(t>2e3)||"Amount should be less than 2000"},J=function(e){var t=Number(e);return!isNaN(t)||"Last account no should be a number"},D=function(e){return!1===isNaN(Number(e))||G(e)},G=function(e){return"unknown"!=se(e)||"Address should be valid"},$=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r;return v(this,(function(a){switch(a.label){case 0:return r=[{type:"list",name:"inputText",message:t||"Choose an option",default:n,choices:e,pageSize:30,filter:function(e){return e}}],[4,m.default.prompt(r)];case 1:return[2,a.sent().inputText.toString()]}}))}))},H=function(e,t){return void 0===t&&(t=!1),g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent())&&t)return[2,null];if(/^[0-9]*$/g.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},W=function(e,t,n){return void 0===n&&(n=!1),g(void 0,void 0,void 0,(function(){var r,a,s,o;return v(this,(function(c){switch(c.label){case 0:r=0,c.label=1;case 1:return r<5?[4,q(t)]:[3,7];case 2:a=c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),""===a&&n?[2,null]:"solana"===F(e)?[2,a]:[4,b(a)];case 4:return(s=c.sent()).status?s.output.toString()===e.toString()?[2,a]:(console.log(T.red("Rpc url not match chain id")),[3,6]):(console.log(T.red(s.output)),[3,6]);case 5:return o=c.sent(),console.log(T.red(o.message)),[3,6];case 6:return r++,[3,1];case 7:return[2,null]}}))}))},Z=function(e){return g(void 0,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:t=0,r.label=1;case 1:return t<5?[4,q(e)]:[3,4];case 2:if(""===(n=r.sent()))return[2,null];if(""!==n&&42!==n.length)return console.log(T.red("Multicall address length must be 42")),[3,3];r.label=3;case 3:return t++,[3,1];case 4:return[2,null]}}))}))},X=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=/^[A-Za-z][0-9a-zA-Z]*$/g,n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent()))return[2,null];if(t.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},V=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:t=/^#[0-9A_F]{6}$/g,n=0,a.label=1;case 1:return n<5?[4,q(e)]:[3,4];case 2:if(""===(r=a.sent()))return[2,null];if(t.test(r))return[2,r];a.label=3;case 3:return n++,[3,1];case 4:return[2,null]}}))}))},Q=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){switch(s.label){case 0:n=/^[a-zA-Z0-9]{2,20}$/g,r=0,s.label=1;case 1:return r<5?[4,q(e)]:[3,4];case 2:if(a=(a=s.sent()).trim(),n.test(a))return t.includes(a)?(console.log(T.red("Account label already exists")),[3,3]):[2,a.toLocaleLowerCase()];s.label=3;case 3:return r++,[3,1];case 4:return[2,null]}}))}))},Y=function(e){var t="Password must contain at least: \n",n=!0,r=" ",a=T.green("✔"),s=T.red("✖");return e.length>=8?t+=r+a+" 8 characters\n":(t+=r+s+" 8 characters\n",n=!1),/[0-9]/.test(e)?t+=r+a+" One numerical character\n":(t+=r+s+" One numerical character\n",n=!1),/[A-Z]/.test(e)?t+=r+a+" One uppercase letter\n":(t+=r+s+" One uppercase letter\n",n=!1),/[!@#$%]/.test(e)?t+=r+a+" One sepcial character (i.e. !@#$%)\n":(t+=r+s+" One sepcial character (i.e. !@#$%)\n",n=!1),!!n||t},ee=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=[{name:"password",type:"password",mask:"#",message:"".concat(e,":"),validate:Y}],[4,m.default.prompt(t)];case 1:return[2,n.sent().password]}}))}))},te=function(e){return g(void 0,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=[{name:"confirm",type:"confirm",message:"".concat(e)}],[4,m.default.prompt(t)];case 1:return[2,n.sent().confirm]}}))}))},ne=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return n=[{name:"editor",type:"editor",message:"".concat(e),validate:t}],[4,m.default.prompt(n)];case 1:return[2,r.sent().editor.trim().toString()]}}))}))},re=function(e){return!!/^0x[0-9a-fA-F]*$/g.test(e.trim())},ae=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,e.apply(void 0,t)];case 1:return r=s.sent(),n={status:!0,output:r},[3,3];case 2:return a=s.sent(),n={status:!1,output:a.toString()},[3,3];case 3:return[2,n]}}))}))},se=function(e){return e.startsWith("0x")&&42===e.length?"evm":/^[A-HJ-NP-Za-km-z1-9]*$/.test(e)&&e.length<=44&&e.length>=32?"solana":"unknown"},oe=function(e){return e=e.trim(),d.existsSync(e)},ce=require("chalk"),ue=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){return n=p.join(e,"assets.json"),oe(n)?(r=d.readFileSync(n).toString(),a=JSON.parse(r),t in a?[2,a[t]]:[2,[]]):[2,[]]}))}))},ie=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s;return v(this,(function(o){switch(o.label){case 0:return[4,ue(e,t)];case 1:for(r=o.sent(),a=[],s=0;s<r.length;s++)r[s].symbol===n&&a.push(r[s]);return[2,a]}}))}))},le=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return r=ot(e,t),a=ct(e,t),[4,ue(e,a.chainId.toString())];case 1:return(s=i.sent())?[4,me(n,s,a.rpcUrl,r)]:(console.log(ce.red("No asset found")),[2]);case 2:for(o=i.sent(),c=1,u=0;u<o.length;u++)"0"!==o[u].balance&&"0.0000"!==o[u].balance&&(console.log(ce.green("".concat(c,". ").concat(o[u].symbol," Balance: ").concat(o[u].balance))),c+=1);return 1===c&&console.log(ce.red("No asset found")),[2]}}))}))},de=function(e,t,n,r,a,s){return g(void 0,void 0,void 0,(function(){var o,c,u;return v(this,(function(i){return o=p.join(e,"assets.json"),c={},oe(o)&&(u=d.readFileSync(o).toString(),c=JSON.parse(u)),void 0===c[t]&&(c[t]=[]),c[t].push({address:n,symbol:r,name:a,decimals:s}),d.writeFileSync(o,JSON.stringify(c,null,4)),[2]}))}))},pe=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,q("Please input Token address",G)];case 1:return n=u.sent(),r=ot(e,t),a=ct(e,t),"evm"!==r?[3,3]:(i=n).startsWith("0x")&&42===i.length?[4,k(n,a.rpcUrl)]:(console.log(ce.red("evm address format error")),[2]);case 2:return s=u.sent(),[3,5];case 3:return function(e){return/^[A-HJ-NP-Za-km-z1-9]*$/.test(e)}(n)?[4,S(n,a.rpcUrl)]:(console.log(ce.red("solana address format error")),[2]);case 4:s=u.sent(),u.label=5;case 5:return s.status?s.output.name?[3,7]:(o=s.output,[4,q("Please input token name")]):(console.log(ce.red(s.output)),[2]);case 6:o.name=u.sent(),u.label=7;case 7:return s.output.symbol?[3,9]:(c=s.output,[4,q("Please input token symbol")]);case 8:c.symbol=u.sent(),u.label=9;case 9:return[4,de(e,a.chainId.toString(),n,s.output.symbol,s.output.name,s.output.decimals)];case 10:return u.sent(),console.log(ce.green("Asset added successfully")),[2]}var i}))}))},fe=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a;return v(this,(function(s){switch(s.label){case 0:return r=["> Back",new m.default.Separator("----------------------------------"),"> Show Assets","> Add Asset"],[4,$(r)];case 1:switch(a=s.sent(),a){case"> Show Assets":return[3,2];case"> Add Asset":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,le(e,n,t)];case 3:case 5:return s.sent(),[3,7];case 4:return[4,pe(e,n)];case 6:return[2];case 7:return[4,fe(e,t,n)];case 8:return s.sent(),[2]}}))}))},me=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,i,l,d,p,f;return v(this,(function(m){switch(m.label){case 0:for(a=t.length,s=[],i=0;i<a;i++)l=t[i],"evm"===r?s.push(N(e,l.address,n)):"solana"===r&&s.push(x(e,l.address,n));return[4,Promise.all(s)];case 1:for(o=m.sent(),c=[],i=0;i<a;i++){if(l=t[i],d=l.decimals,!o[i].status)return console.log(ce.red(o[i].output)),[2,null];p=new u.BigNumber(o[i].output),f=p.dividedBy(Math.pow(10,d)).toFixed(4,u.BigNumber.ROUND_FLOOR),c.push({address:l.address,symbol:l.symbol,balance:f})}return[2,c]}}))}))},he=require("bn.js").BN,ge=require("ethereumjs-util").stripHexPrefix,ve=require("bignumber.js").BigNumber;function be(e){return new he(ge(e.toString("hex")),16)}var we=function(e){return e.match(/^-?0x/u)?e:e.match(/^-?0X/u)?e.replace("0X","0x"):e.startsWith("-")?e.replace("-","-0x"):"0x".concat(e)};function ye(e){return we(e.toString(16))}var ke=function(){function e(e){this.query=new h.default(h.default.givenProvider||e).eth}return e.prototype.analyzeGasUsage=function(e){return g(this,void 0,void 0,(function(){var t,n,r,a,s,o;return v(this,(function(c){switch(c.label){case 0:return[4,this.query.getBlock("latest",!1)];case 1:t=c.sent(),n=be(t.gasLimit),u=n,i=20,l=new he(19),d=new he(i),r=u.mul(l).div(d),a=ye(r),c.label=2;case 2:return c.trys.push([2,4,,5]),[4,this.estimateTxGas(e)];case 3:return a=c.sent(),[3,5];case 4:return o=c.sent(),s={reason:o.message,errorKey:o.errorKey,debug:{blockNumber:t.number,blockGasLimit:t.gasLimit}},[3,5];case 5:return[2,{blockGasLimit:t.gasLimit,estimatedGasHex:a,simulationFails:s}]}var u,i,l,d}))}))},e.prototype.estimateTxGas=function(e){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this.query.estimateGas(e)];case 1:return t=n.sent(),[2,t=new ve(t.toString()).multipliedBy(1.3).toFixed(0)]}}))}))},e.prototype.addGasBuffer=function(e,t,n){void 0===n&&(n=1.3);var r=be(e),a=be(t).muln(.9),s=r.muln(n);return r.gt(a)?ye(r):s.lt(a)?ye(s):ye(a)},e.prototype.getBufferedGasLimit=function(e,t){return g(this,void 0,void 0,(function(){var n,r,a,s;return v(this,(function(o){switch(o.label){case 0:return[4,this.analyzeGasUsage(e)];case 1:return n=o.sent(),r=n.blockGasLimit,a=n.estimatedGasHex,s=n.simulationFails,[2,{gasLimit:this.addGasBuffer(we(a),r,t),simulationFails:s}]}}))}))},e.prototype.getGasPrice=function(){return g(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this.query.getGasPrice()];case 1:return[2,e.sent()]}}))}))},e.prototype.getTransactionCount=function(e){return g(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this.query.getTransactionCount(e)];case 1:return[2,t.sent()]}}))}))},e}(),Se=require("chalk");require("wative-core").WativeCore;var Ne=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l;return v(this,(function(d){switch(d.label){case 0:return t=[new m.default.Separator("————Tx Detail—————-"),"from: ".concat(e.from),"to: ".concat(e.to),"nonce: ".concat(e.nonce),"gasPrice: ".concat(e.gasPrice),"data: ".concat(e.data),"value: ".concat(e.value),"gas: ".concat(e.gas),new m.default.Separator("——————————————-"),"Send it now"],[4,$(t)];case 1:return n=d.sent(),1!==(r=t.indexOf(n))?[3,3]:(a=e,[4,q("from",G)]);case 2:a.from=d.sent(),d.label=3;case 3:return 2!==r?[3,5]:(s=e,[4,q("to",G)]);case 4:s.to=d.sent(),d.label=5;case 5:return 3!==r?[3,7]:(o=e,[4,q("nonce")]);case 6:o.nonce=d.sent(),d.label=7;case 7:return 4!==r?[3,9]:(c=e,[4,q("gasPrice")]);case 8:c.gasPrice=d.sent(),d.label=9;case 9:return 5!==r?[3,11]:(u=e,[4,ne("data")]);case 10:u.data=d.sent(),d.label=11;case 11:return 6!==r?[3,13]:(i=e,[4,q("value")]);case 12:i.value=d.sent(),d.label=13;case 13:return 7!==r?[3,15]:(l=e,[4,q("gas")]);case 14:l.gas=d.sent(),d.label=15;case 15:return 9===r?[2,e]:[4,Ne(e)];case 16:return[2,d.sent()]}}))}))},xe=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,i,l,d,p,f,m,b,y,k,S,N,x,B,P,O,A,_,C,j,F,T,L,I,z,R;return v(this,(function(U){switch(U.label){case 0:return[4,q("to",G)];case 1:return a=U.sent(),[4,(s=new ke(e)).getGasPrice()];case 2:return o=U.sent(),c=new u.BigNumber(o.toString()).dividedBy(1e9),i=c.toFixed(4,u.BigNumber.ROUND_FLOOR),[4,q("Gas price (".concat(i,"), agree or enter"))];case 3:return l=U.sent(),d=l||i,d=new u.BigNumber(d).multipliedBy(1e9).toFixed(0),[4,(K=a,E=e,g(void 0,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return e=new h.default(E),[4,ae(e.eth.getCode.bind(e),[K])];case 1:return(t=n.sent()).status?[2,{status:!0,output:t.output}]:[2,{status:!1,output:"Failed to get code"}]}}))})))];case 4:return(p=U.sent()).status?"0x"!==p.output?[3,10]:(f="0x",[4,w(n,e)]):(console.log(Se.red(p.output)),[2]);case 5:return(b=U.sent()).status?(y=new u.BigNumber(b.output),k=new u.BigNumber(d),S=y.minus(k.multipliedBy(21e3)).toFixed(0,u.BigNumber.ROUND_FLOOR),N=new u.BigNumber(S).dividedBy(1e18).toFixed(4,u.BigNumber.ROUND_FLOOR),new u.BigNumber(N)<new u.BigNumber(0)?(console.log(Se.red("Not enough balance")),[2]):(x=["> Input value","> Total Balance (".concat(N," ").concat(t,")")],[4,$(x)])):(console.log(Se.red(b.output)),[2]);case 6:return B=U.sent(),0!==(P=x.indexOf(B))?[3,8]:[4,q("value",M)];case 7:return O=U.sent(),m=new u.BigNumber(O).multipliedBy(1e18).toFixed(0,u.BigNumber.ROUND_FLOOR),[3,9];case 8:1===P&&(m=S),U.label=9;case 9:return new u.BigNumber(m).isGreaterThan(new u.BigNumber(S))?(console.log(Se.red("Not enough balance")),[2]):[3,13];case 10:return[4,ne("data",re)];case 11:return f=U.sent(),[4,q("value",M)];case 12:m=U.sent(),U.label=13;case 13:return[4,s.getTransactionCount(n)];case 14:return A=U.sent(),[4,q("Nonce (".concat(A,"), agree or enter"))];case 15:return _=U.sent(),C=_||A.toString(),j={from:n,to:a,nonce:C,gasPrice:d,data:f,value:m},"0x"!==f?[3,16]:(j.gas="21000",[3,21]);case 16:F=j.gasPrice,delete j.gasPrice,U.label=17;case 17:return U.trys.push([17,19,,20]),T=j,L="gas",[4,s.estimateTxGas(j)];case 18:return T[L]=U.sent().toString(),[3,20];case 19:return I=U.sent(),console.log(Se.red("Error: "+I)),[2];case 20:j.gasPrice=F,U.label=21;case 21:return[4,Ne(j)];case 22:return j=U.sent(),[4,r.account.signTransaction(n,j,e)];case 23:return(z=U.sent()).status?[4,r.account.sendSignedTransaction(n,z.output.rawTransaction,e)]:(console.log(Se.red(z.output)),[2]);case 24:return(R=U.sent()).status?(console.log(Se.green("Transaction hash: ".concat(R.output.transactionHash))),[2]):(console.log(Se.red(R.output)),[2])}var K,E}))}))},Be=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,o,c,i,l,d,p,f,m,h,g,b,w,k,S,N,x,B,O,A;return v(this,(function(v){switch(v.label){case 0:return[4,q("to",G)];case 1:return a=v.sent(),(o=(new s.Transaction).add(s.SystemProgram.transfer({fromPubkey:new s.PublicKey(n),toPubkey:new s.PublicKey(a),lamports:1}))).add(s.ComputeBudgetProgram.setComputeUnitLimit({units:2e5})),o.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:1e3})),[4,r.account.simulateTransaction(n,e,o)];case 2:return(c=v.sent()).status?c.output&&c.output.value&&0!==c.output.value.unitsConsumed&&!c.output.value.err?(i=new u.BigNumber(c.output.value.unitsConsumed.toString()).multipliedBy(1.2).toFixed(0,u.BigNumber.ROUND_CEIL),l=new u.BigNumber(i),[4,P(e)]):(console.log(Se.red("Simulate error")),[2]):(console.log(Se.red(c.output)),[2]);case 3:return(d=v.sent()).status?(p=new u.BigNumber(d.output.toString()),f=l.multipliedBy(p).dividedBy(1e6).toFixed(0,u.BigNumber.ROUND_CEIL),[4,y(n,e)]):(console.log(Se.red(d.output)),[2]);case 4:return(m=v.sent()).status?(h=new u.BigNumber(m.output),g=h.minus(5e3).minus(f),b=new u.BigNumber(g).dividedBy(1e9).toFixed(4,u.BigNumber.ROUND_FLOOR),new u.BigNumber(b)<new u.BigNumber(0)?(console.log(Se.red("Not enough balance")),[2]):(w=["> Input value","> Total Balance (".concat(b," ").concat(t,")")],[4,$(w)])):(console.log(Se.red(m.output)),[2]);case 5:return k=v.sent(),S=w.indexOf(k),N="0",0!==S?[3,7]:[4,q("value",M)];case 6:return x=v.sent(),N=new u.BigNumber(x).multipliedBy(1e9).toFixed(0,u.BigNumber.ROUND_FLOOR),new u.BigNumber(N).isGreaterThan(new u.BigNumber(g))?(console.log(Se.red("Not enough balance")),[2]):[3,8];case 7:1===S&&(N=g.toString()),v.label=8;case 8:return(B=new s.Transaction).add(s.ComputeBudgetProgram.setComputeUnitLimit({units:Number(l)})),B.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:Number(p)})),B.add(s.SystemProgram.transfer({fromPubkey:new s.PublicKey(n),toPubkey:new s.PublicKey(a),lamports:Number(N)})),[4,r.account.signTransaction(n,B,e)];case 9:return(O=v.sent()).status?[4,r.account.sendSignedTransaction(n,O.output,e)]:(console.log(Se.red(O.output)),[2]);case 10:return(A=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(A.output))),[2]):(console.log(Se.red(A.output)),[2])}}))}))},Pe=function(e,t,n,r,a){return g(void 0,void 0,void 0,(function(){var s,o,c,i,l,d,p,f,m,h,g,b,w,y,S,x,P,O,A,_,C,j,F,T,L,I,z,R,U,K,E,J,D;return v(this,(function(v){switch(v.label){case 0:return[4,$(["> Input token ticker","> Input token contract address"])];case 1:switch(s=v.sent(),s){case"> Input token ticker":return[3,2];case"> Input token contract address":return[3,10]}return[3,13];case 2:return[4,q("token ticker")];case 3:return i=v.sent(),[4,ie(e,n,i)];case 4:if(0===(l=v.sent()).length)return console.log(Se.red("Token not found")),[2];d=[],p=0,v.label=5;case 5:return p<l.length?[4,N(r,l[p].address,t)]:[3,8];case 6:if(!(f=v.sent()).status)return console.log(Se.red(f.output)),[2];if(m=new u.BigNumber(f.output),h=m.dividedBy(Math.pow(10,Number(l[p].decimals))).toFixed(4,u.BigNumber.ROUND_FLOOR),1===l.length)return d.push("> 1. ".concat(i," Balance: ").concat(h)),[3,8];d.push("> ".concat(p+1,". ").concat(i," Balance: ").concat(h,"(").concat(l[p].address,")")),d.push(l[p].address),v.label=7;case 7:return p++,[3,5];case 8:return[4,$(d)];case 9:return g=v.sent(),b=l[d.indexOf(g)],o=b.address,c=Number(b.decimals),[3,13];case 10:return[4,q("token contract address",G)];case 11:return o=v.sent(),[4,k(o,t)];case 12:return(w=v.sent()).status?(c=Number(w.output.decimals),[3,13]):(console.log(Se.red(w.output)),[2]);case 13:return[4,q("Receipt",G)];case 14:return y=v.sent(),[4,q("Amount",M)];case 15:return S=v.sent(),[4,(x=new ke(t)).getGasPrice()];case 16:return P=v.sent(),O=new u.BigNumber(P.toString()).dividedBy(1e9),A=O.toFixed(4,u.BigNumber.ROUND_FLOOR),[4,q("Gas price (".concat(A,"), agree or enter"))];case 17:return _=v.sent(),C=_||A,C=new u.BigNumber(C).multipliedBy(1e9).toFixed(0),j=new u.BigNumber(S).multipliedBy(Math.pow(10,c)).toFixed(0),[4,B(y,j,t)];case 18:return F=v.sent(),[4,x.getTransactionCount(r)];case 19:return T=v.sent(),[4,q("Nonce (".concat(T,"), agree or enter"))];case 20:return L=v.sent(),I=L||T.toString(),z={from:r,to:o,nonce:I,gasPrice:C,data:F,value:"0"},"0x"!==F?[3,21]:(z.gas="21000",[3,26]);case 21:R=z.gasPrice,delete z.gasPrice,v.label=22;case 22:return v.trys.push([22,24,,25]),U=z,K="gas",[4,x.estimateTxGas(z)];case 23:return U[K]=v.sent().toString(),[3,25];case 24:return E=v.sent(),console.log(Se.red("Failed to estimate gas, "+E.message)),[2];case 25:z.gasPrice=R,v.label=26;case 26:return[4,Ne(z)];case 27:return z=v.sent(),[4,a.account.signTransaction(r,z,t)];case 28:return(J=v.sent()).status?[4,a.account.sendSignedTransaction(r,J.output.rawTransaction,t)]:(console.log(Se.red(J.output)),[2]);case 29:return(D=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(D.output.transactionHash))),[2]):(console.log(Se.red(D.output)),[2])}}))}))},Oe=function(e,t,n,r,a){return g(void 0,void 0,void 0,(function(){var c,i,l,d,p,f,m,h,g,b,w,y,k,N,B,A,_,C,j,F,T,L,I,z,R,U,K,E;return v(this,(function(v){switch(v.label){case 0:return[4,$(["> Input token ticker","> Input token contract address"])];case 1:switch(c=v.sent(),c){case"> Input token ticker":return[3,2];case"> Input token contract address":return[3,10]}return[3,13];case 2:return[4,q("token ticker")];case 3:return d=v.sent(),[4,ie(e,n,d)];case 4:if(0===(p=v.sent()).length)return console.log(Se.red("Token not found")),[2];f=[],m=0,v.label=5;case 5:return m<p.length?[4,x(r,p[m].address,t)]:[3,8];case 6:if(!(h=v.sent()).status)return console.log(Se.red(h.output)),[2];if(g=new u.BigNumber(h.output),b=g.dividedBy(Math.pow(10,Number(p[m].decimals))).toFixed(4,u.BigNumber.ROUND_FLOOR),1===p.length)return f.push("> 1. ".concat(d," Balance: ").concat(b)),[3,8];f.push("> ".concat(m+1,". ").concat(d," Balance: ").concat(b,"(").concat(p[m].address,")")),f.push(p[m].address),v.label=7;case 7:return m++,[3,5];case 8:return[4,$(f)];case 9:return w=v.sent(),y=p[f.indexOf(w)],i=y.address,l=Number(y.decimals),[3,13];case 10:return[4,q("token contract address",G)];case 11:return i=v.sent(),[4,S(i,t)];case 12:return(k=v.sent()).status?(l=Number(k.output.decimals),[3,13]):(console.log(Se.red(k.output)),[2]);case 13:return[4,q("Receipt",G)];case 14:return N=v.sent(),[4,q("Amount",M)];case 15:return B=v.sent(),A=new u.BigNumber(B).multipliedBy(Math.pow(10,l)).toFixed(0),_=o.getAssociatedTokenAddressSync(new s.PublicKey(i),new s.PublicKey(r),!0),[4,O(_.toString(),t)];case 16:return(C=v.sent()).status?C.output&&C.output.owner.toString()!==s.PublicKey.default?(j=o.getAssociatedTokenAddressSync(new s.PublicKey(i),new s.PublicKey(N),!1),[4,O(j.toString(),t)]):(console.log(Se.red("From token account not found")),[2]):(console.log(Se.red(C.output)),[2]);case 17:return(F=v.sent()).status?(T=new s.Transaction,L=new s.Transaction,F.output&&F.output.owner.toString()!==s.PublicKey.default||(T.add(o.createAssociatedTokenAccountInstruction(new s.PublicKey(r),new s.PublicKey(j),new s.PublicKey(N),new s.PublicKey(i))),L.add(o.createAssociatedTokenAccountInstruction(new s.PublicKey(r),new s.PublicKey(j),new s.PublicKey(N),new s.PublicKey(i)))),T.add(o.createTransferInstruction(_,j,new s.PublicKey(r),Number(A))),T.add(s.ComputeBudgetProgram.setComputeUnitLimit({units:2e5})),T.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:1e3})),[4,a.account.simulateTransaction(r,t,T)]):(console.log(Se.red(F.output)),[2]);case 18:return(I=v.sent()).status?I.output&&I.output.value&&0!==I.output.value.unitsConsumed&&!I.output.value.err?(z=new u.BigNumber(I.output.value.unitsConsumed.toString()),z=new u.BigNumber(Math.ceil(1.2*Number(z))),[4,P(t)]):(console.log(Se.red("Simulate error")),[2]):(console.log(Se.red(I.output)),[2]);case 19:return(R=v.sent()).status?(U=new u.BigNumber(R.output.toString()),L.add(o.createTransferInstruction(_,j,new s.PublicKey(r),Number(A))),L.add(s.ComputeBudgetProgram.setComputeUnitLimit({units:Number(z)})),L.add(s.ComputeBudgetProgram.setComputeUnitPrice({microLamports:Number(U)})),[4,a.account.signTransaction(r,L,t)]):(console.log(Se.red(R.output)),[2]);case 20:return(K=v.sent()).status?[4,a.account.sendSignedTransaction(r,K.output,t)]:(console.log(Se.red(K.output)),[2]);case 21:return(E=v.sent()).status?(console.log(Se.green("Transaction hash: ".concat(E.output))),[2]):(console.log(Se.red(E.output)),[2])}}))}))},Ae=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u,i,l,d,p;return v(this,(function(f){switch(f.label){case 0:return a=ft(e,t,n),s=ot(e,a),o=se(n),s!==o&&("evm"===o&&(a="Ethereum Mainnet"),"solana"===o&&(a="Solana Mainnet"),s=ot(e,a)),"evm"!==s?[3,3]:[4,te("Network (".concat(a,"), want a change?"))];case 1:return f.sent()?(c=mt(e),[4,$(c,"Select a network")]):[3,3];case 2:u=f.sent(),a=u,f.label=3;case 3:return[4,pt(n,e,a)];case 4:return(i=f.sent()).status?(l=ct(e,a),console.log(Se.green(" ".concat(l.nativeCurrency.symbol," Balance: ").concat(i.output))),d=["> Back",new m.default.Separator("----------------------------------"),"> Send Raw Tx","> Send Token"],[4,$(d)]):(console.log(Se.red(i.output)),[2]);case 5:switch(p=f.sent(),p){case"> Send Raw Tx":return[3,6];case"> Send Token":return[3,11];case"> Back":return[3,16]}return[3,17];case 6:return"evm"!==o?[3,8]:[4,xe(l.rpcUrl,l.nativeCurrency.symbol,n,r)];case 7:f.sent(),f.label=8;case 8:return"solana"!==o?[3,10]:[4,Be(l.rpcUrl,l.nativeCurrency.symbol,n,r)];case 9:f.sent(),f.label=10;case 10:return[3,17];case 11:return"evm"!==o?[3,13]:[4,Pe(e,l.rpcUrl,l.chainId.toString(),n,r)];case 12:f.sent(),f.label=13;case 13:return"solana"!==o?[3,15]:[4,Oe(e,l.rpcUrl,l.chainId.toString(),n,r)];case 14:f.sent(),f.label=15;case 15:return[3,17];case 16:case 17:return[2]}}))}))},_e=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return a=["> Back",new m.default.Separator("----------------------------------"),"> SendTx","> SignMessage"],[4,$(a)];case 1:switch(s=u.sent(),s){case"> SendTx":return[3,2];case"> SignMessage":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Ae(e,t,n,r)];case 3:return u.sent(),[3,7];case 4:return[4,ne("Input the message to sign")];case 5:return o=u.sent(),(c=r.account.signMessage(n,o)).status?(console.log(Se.green("Signature: "+c.output)),[3,7]):(console.log(Se.red(c.output)),[3,7]);case 6:return[2];case 7:return[4,_e(e,t,n,r)];case 8:return u.sent(),[2]}}))}))},Ce=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return[4,q("Input the address to send tx",G)];case 1:return n=a.sent(),null!==(r=t.account.getAccountLabel(n))?[3,3]:(console.log(Se.red("Account not found")),[4,Ce(e,t)]);case 2:case 5:case 8:return a.sent(),[2];case 3:return[4,Me(r,t)];case 4:return a.sent()?[3,6]:[4,Ce(e,t)];case 6:return[4,_e(e,r,n,t)];case 7:return a.sent(),[4,Ce(e,t)]}}))}))},je=require("chalk"),Fe=require("cli-progress");require("wative-core").WativeCore;var Te=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s;return v(this,(function(o){switch(o.label){case 0:return t=ze(e),n=[],t.accounts&&(n=t.accounts),[4,Q("Account Label",n)];case 1:return null===(r=o.sent())?[2,null]:[4,ee("Please set a password for Account [".concat(r,"]"))];case 2:return a=o.sent(),[4,st(e)];case 3:return s=o.sent(),[2,{account_label:r,password:a,selected_default_network:s}]}}))}))},Le=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,Te(e)];case 1:return(n=u.sent())?[4,q("Please enter a mnemonic [split by space]",K)]:[2];case 2:return r=(r=u.sent()).replace(/\s+/g," "),(a=t.account.generatePPAccount(n.account_label,r,n.password)).status?(s=p.join(e,"accounts/".concat(n.account_label,".json")),a.output.default_network=n.selected_default_network,d.writeFileSync(s,JSON.stringify(a.output,null,4)),o=p.resolve(e,"network.json"),(c=JSON.parse(d.readFileSync(o,"utf8"))).accounts.push(n.account_label),d.writeFileSync(o,JSON.stringify(c,null,4)),[2]):(console.log(je.red(a.output)),[2])}}))}))},Ie=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return[4,Te(e)];case 1:return(n=i.sent())?[4,q("Please enter a private key")]:[2];case 2:return r=i.sent(),[4,ct(e,n.selected_default_network)];case 3:return a=i.sent(),[4,t.account.generatePKAccount(n.account_label,r,n.password,a.chainId)];case 4:return(s=i.sent()).status?(o=p.join(e,"accounts/".concat(n.account_label,".json")),s.output.default_network=n.selected_default_network,d.writeFileSync(o,JSON.stringify(s.output,null,4)),c=p.resolve(e,"network.json"),(u=JSON.parse(d.readFileSync(c,"utf8"))).accounts.push(n.account_label),d.writeFileSync(c,JSON.stringify(u,null,4)),[2]):(console.log(je.red(s.output)),[2])}}))}))},qe=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=["> Back",new m.default.Separator("----------------------------------"),"> Import Passphrase","> Import Private Key"],[4,$(n)];case 1:switch(r=a.sent(),r){case"> Import Passphrase":return[3,2];case"> Import Private Key":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Le(e,t)];case 3:case 5:return a.sent(),[3,7];case 4:return[4,Ie(e,t)];case 6:case 7:return[2]}}))}))},ze=function(e){var t=p.resolve(e,"network.json");return JSON.parse(d.readFileSync(t,"utf8"))},Re=function(e,t){var n=p.join(e,"accounts/".concat(t,".json"));return JSON.parse(d.readFileSync(n,"utf8"))},Ue=function(e,t,n){var r=p.join(e,"accounts/".concat(t,".json"));d.writeFileSync(r,JSON.stringify(n,null,4))},Me=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){switch(s.label){case 0:if(t.account.isLogin(e))return[2,!0];n=0,s.label=1;case 1:return n<3?[4,ee("Please input the password for Account [".concat(e,"]"))]:[3,5];case 2:return r=s.sent(),[4,t.account.login(e,r)];case 3:if((a=s.sent()).status)return[2,!0];console.log(je.red(a.output)),s.label=4;case 4:return n++,[3,1];case 5:return[2,!1]}}))}))},Ke=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l;return v(this,(function(d){switch(d.label){case 0:if(n=ze(e),r=n.accounts,a=["> Back",new m.default.Separator("----------------------------------")],0===(s=r.length))return console.log(je.red("No address here yet")),[2];for(o=0;o<s;o++)c=r[o],"PP"===(u=Re(e,c)).account_type?a.push("".concat(o+1,") ").concat(c," [").concat(u.account_type,":").concat(u.data.length,"]")):a.push("".concat(o+1,") ").concat(c," [").concat(u.account_type,":1]"));return[4,$(a,"Select an account")];case 1:return"> Back"===(i=d.sent())?[2]:(l=r[a.indexOf(i)-2],[4,Me(l,t)]);case 2:return d.sent()?[4,Je(e,l,t)]:[3,4];case 3:d.sent(),d.label=4;case 4:return[4,Ke(e,t)];case 5:return d.sent(),[2]}}))}))},Ee=function(e,t,n){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l,d,p,f,h,g,b,w,y,k,S,N;return v(this,(function(v){switch(v.label){case 0:return[4,Re(e,t)];case 1:return n=v.sent(),r=["> Back",new m.default.Separator("----------------------------------"),"1.Disabled Slots","2.Add Single","3.Add Range"],[4,$(r)];case 2:switch(a=v.sent(),a){case"> Back":return[3,3];case"1.Disabled Slots":return[3,4];case"2.Add Single":return[3,7];case"3.Add Range":return[3,9]}return[3,11];case 3:return[2];case 4:if(!(s=n.disabled_slots)||0===s.length)return console.log(je.red("No disabled slots here yet")),[3,11];for(o=n.data,c=["> Back",new m.default.Separator("----------------------------------")],u=n.default_network,i=0;i<s.length;i++){if(l=s[i].from,d=s[i].to,p=u,f=u,"default_network"in o[l]&&(p=o[l].default_network),"default_network"in o[d]&&(f=o[d].default_network),h=ot(e,p),g=ot(e,f),"evm"!==h&&"solana"!==h)throw new Error("Invalid network type: ".concat(h));if("evm"!==g&&"solana"!==g)throw new Error("Invalid network type: ".concat(g));b=void 0,w=void 0,b="evm"===h?o[l].ciphertexts.evm.address:o[d].ciphertexts.solana.address,w="evm"===g?o[d].ciphertexts.evm.address:o[d].ciphertexts.solana.address,l===d?c.push("".concat(i+1,". ").concat(b,"[").concat(l,"]")):c.push("".concat(i+1,". ").concat(b,"[").concat(l,"]-").concat(w,"[").concat(d,"]"))}return[4,$(c)];case 5:return"> Back"===(y=v.sent())?[3,11]:[4,te("Are you sure to delete the ".concat(y,"?"))];case 6:return v.sent()?(k=c.indexOf(y)-2,n.disabled_slots.splice(k,1),Ue(e,t,n),[3,11]):[3,11];case 7:return[4,R(n,"Input address or index")];case 8:return null===(S=v.sent())?(console.log(je.red("Invalid account index")),[3,11]):(n.disabled_slots?n.disabled_slots.push({from:S,to:S}):n.disabled_slots=[{from:S,to:S}],Ue(e,t,n),[3,11]);case 9:return[4,z(n)];case 10:return(N=v.sent())?(n.disabled_slots?n.disabled_slots.push(N):n.disabled_slots=[N],Ue(e,t,n),[3,11]):(console.log(je.red("Invalid account range")),[3,11]);case 11:return[4,Ee(e,t)];case 12:return v.sent(),[2]}}))}))},Je=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i;return v(this,(function(l){switch(l.label){case 0:return[4,Re(e,t)];case 1:return r=l.sent(),a="PP"===r.account_type?["> Back",new m.default.Separator("----------------------------------"),"1.Address List","2.Expand Address","3.Slice Address","4.Disable Address","5.Reset Account Password","6.Switch Networks [".concat(r.default_network,"]")]:["> Back",new m.default.Separator("----------------------------------"),"1.Address List","2.Reset Account Password","3.Switch Networks [".concat(r.default_network,"]")],[4,$(a)];case 2:switch(s=l.sent(),s){case"1.Address List":return[3,3];case"2.Expand Address":return[3,8];case"3.Slice Address":return[3,11];case"4.Disable Address":return[3,14];case"5.Reset Account Password":return[3,16];case"3.Switch Networks [".concat(r.default_network,"]"):return[3,20];case"6.Switch Networks [".concat(r.default_network,"]"):return[3,22];case"2.Reset Account Password":return[3,24];case"> Back":return[3,28]}return[3,29];case 3:return"PP"!==r.account_type?[3,5]:[4,De(e,t,n)];case 4:return l.sent(),[3,7];case 5:return[4,$e(e,t,n)];case 6:l.sent(),l.label=7;case 7:return[3,29];case 8:return[4,q("Expand accounts count",E)];case 9:return o=l.sent(),Number(o)>2e3?(console.log(je.red("Too many accounts, please input less than 2000")),[3,29]):[4,We(e,t,Number(o),n)];case 10:return l.sent(),[3,29];case 11:return[4,q("Please input last account number",J)];case 12:return c=l.sent(),[4,Ze(e,t,Number(c),n)];case 13:return l.sent(),[3,29];case 14:return[4,Ee(e,t)];case 15:return l.sent(),[3,29];case 16:return[4,ee("Please input new password for Account [".concat(t,"]"))];case 17:return u=l.sent(),[4,ee("Please confirm new password for Account [".concat(t,"]"))];case 18:return i=l.sent(),u!==i?(console.log(je.red("Passwords do not match")),[3,29]):[4,n.account.resetPassword(t,u)];case 19:return l.sent(),[2];case 20:return[4,dt(e,t,!0)];case 21:return l.sent(),[3,29];case 22:return[4,dt(e,t,!0)];case 23:return l.sent(),[3,29];case 24:return[4,ee("Please input new password for Account [".concat(t,"]"))];case 25:return u=l.sent(),[4,ee("Please confirm new password for Account [".concat(t,"]"))];case 26:return i=l.sent(),u!==i?(console.log(je.red("Passwords do not match")),[3,29]):[4,n.account.resetPassword(t,u)];case 27:return l.sent(),[2];case 28:return[2];case 29:return[4,Je(e,t,n)];case 30:return l.sent(),[2]}}))}))},De=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,d,p;return v(this,(function(f){switch(f.label){case 0:return[4,Re(e,t)];case 1:for(r=f.sent(),a=["> Back",new m.default.Separator("----------------------------------")],s=r.disabled_slots,o=0;o<r.data.length;o++)c=r.default_network,"default_network"in r.data[o]&&(c=r.data[o].default_network),u=ot(e,c),i="","tag"in r.data[o]&&(i="(".concat(r.data[o].tag,")")),l=n.account.checkIsDisableAddress(s,o),"evm"===u?l?a.push(new m.default.Separator(je.yellow("#".concat(o," ").concat(r.data[o].ciphertexts.evm.address," ").concat(i," [").concat(c,"]")))):a.push("#".concat(o," ").concat(r.data[o].ciphertexts.evm.address," ").concat(i," [").concat(c,"]")):"solana"===u&&(l?a.push(new m.default.Separator(je.yellow("#".concat(o," ").concat(r.data[o].ciphertexts.solana.address," ").concat(i," [").concat(c,"]")))):a.push("#".concat(o," ").concat(r.data[o].ciphertexts.solana.address," ").concat(i," [").concat(c,"]")));return[4,$(a,"Select an account")];case 2:return"> Back"===(d=f.sent())?[2]:(p=a.indexOf(d)-2,[4,Ge(e,t,p,n)]);case 3:return f.sent(),[4,De(e,t,n)];case 4:return f.sent(),[2]}}))}))},Ge=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u,i,l,d,p,f,h,g;return v(this,(function(v){switch(v.label){case 0:return[4,Re(e,t)];case 1:return a=v.sent(),s=a.default_network,"default_network"in a.data[n]&&(s=a.data[n].default_network),[4,ct(e,s)];case 2:return o=v.sent(),c=ut(e,t,n),[4,pt(c,e,s)];case 3:return(u=v.sent()).status?console.log(je.green(" Address No: #".concat(n,"\n Network: ").concat(s,"\n ").concat(o.nativeCurrency.symbol," Balance: ").concat(u.output))):console.log(je.green(" Address No: #".concat(n,"\n Network: ").concat(s,"\n ").concat(o.nativeCurrency.symbol))),i="> Tag()","tag"in a.data[n]&&""!==a.data[n].tag&&(i="> Tag(".concat(a.data[n].tag,")")),l=["> Back",new m.default.Separator("----------------------------------"),i,"> Switch network","> Assets","> Tools","> Dump private key"],[4,$(l)];case 4:switch(d=v.sent(),d){case i:return[3,5];case"> Switch network":return[3,7];case"> Assets":return[3,9];case"> Tools":return[3,11];case"> Dump private key":return[3,13];case"> Back":return[3,15]}return[3,16];case 5:return p="Current tag ()","tag"in a.data[n]&&""!==a.data[n].tag&&(p="Current tag (".concat(a.data[n].tag,")")),[4,q(p,U)];case 6:return f=(f=v.sent()).replace(/\s+/g," ").trim(),a.data[n].tag=f.toLocaleLowerCase(),Ue(e,t,a),[3,16];case 7:return[4,lt(e,t,n)];case 8:case 10:case 12:return v.sent(),[3,16];case 9:return[4,fe(e,c,s)];case 11:return[4,_e(e,t,c,r)];case 13:return h=ut(e,t,n),[4,r.account.showPrivateKey(h)];case 14:return g=v.sent(),console.log("account: ",h),console.log("private key: ",g),[3,16];case 15:case 16:return[2]}}))}))},$e=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c;return v(this,(function(u){switch(u.label){case 0:return[4,Re(e,t)];case 1:return r=u.sent(),a=["> Back",new m.default.Separator("----------------------------------")],s="","tag"in r&&""!==r.tag&&(s="(".concat(r.tag,")")),a.push("#0 ".concat(r.ciphertexts.address," ").concat(s," [").concat(r.default_network,"]")),[4,$(a,"Select an account")];case 2:return"> Back"===u.sent()?[2]:(o=r.default_network,[4,ct(e,o)]);case 3:return c=u.sent(),console.log(je.green(" Address No: #0\n Network: ".concat(o,"\n ").concat(c.nativeCurrency.symbol," Balance: 0"))),[4,He(e,t,n)];case 4:return u.sent(),[4,$e(e,t,n)];case 5:return u.sent(),[2]}}))}))},He=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l;return v(this,(function(d){switch(d.label){case 0:return[4,Re(e,t)];case 1:return r=d.sent(),a="> Tag()","tag"in r&&""!==r.tag&&(a="> Tag(".concat(r.tag,")")),s=["> Back",new m.default.Separator("----------------------------------"),a,"> Switch network","> Assets","> Tools","> Dump private key"],[4,$(s)];case 2:switch(o=d.sent(),o){case a:return[3,3];case"> Switch network":return[3,5];case"> Assets":return[3,7];case"> Tools":return[3,9];case"> Dump private key":return[3,11];case"> Back":return[3,13]}return[3,14];case 3:return c="Current tag ()","tag"in r&&""!==r.tag&&(c="Current tag (".concat(r.tag,")")),[4,q(c,U)];case 4:return u=d.sent(),r.tag=u.replace(/\s+/g," ").trim().toLocaleLowerCase(),Ue(e,t,r),[3,14];case 5:return[4,dt(e,t,!1)];case 6:case 8:case 10:return d.sent(),[3,14];case 7:return i=it(e,t),[4,fe(e,i,r.default_network)];case 9:return i=it(e,t),[4,_e(e,t,i,n)];case 11:return i=it(e,t),[4,n.account.showPrivateKey(i)];case 12:return l=d.sent(),console.log("account: ",i),console.log("private key: ",l),[3,14];case 13:return[2];case 14:return[4,He(e,t,n)];case 15:return d.sent(),[2]}}))}))},We=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a,s,o,c,u;return v(this,(function(i){switch(i.label){case 0:return[4,Re(e,t)];case 1:a=i.sent(),s=a.data.length,(o=new Fe.SingleBar({},Fe.Presets.legacy)).start(n,0),c=s,i.label=2;case 2:return c<s+n?[4,r.account.generateSubAccount(t,c)]:[3,5];case 3:if(!(u=i.sent()).status)return console.log(je.red(u.output)),[2];a.data.push({ciphertexts:u.output}),o.increment(),i.label=4;case 4:return c++,[3,2];case 5:return o.stop(),Ue(e,t,a),[2]}}))}))},Ze=function(e,t,n,r){return g(void 0,void 0,void 0,(function(){var a;return v(this,(function(s){switch(s.label){case 0:return[4,Re(e,t)];case 1:return(a=s.sent()).data=a.data.slice(0,n+1),Ue(e,t,a),r.account.reloadAccount(),[2]}}))}))},Xe=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o;return v(this,(function(c){switch(c.label){case 0:return n=p.resolve(e,"accounts"),d.existsSync(n)||d.mkdirSync(n),r=ze(e),a=r.accounts,s=0===a.length?["> Back",new m.default.Separator("----------------------------------"),"> Create a new account"]:["> Back",new m.default.Separator("----------------------------------"),"> Select an account","> Create a new account"],[4,$(s)];case 1:switch(o=c.sent(),o){case"> Select an account":return[3,2];case"> Create a new account":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,Ke(e,t)];case 3:case 5:return c.sent(),[3,7];case 4:return[4,qe(e,t)];case 6:return[2];case 7:return[4,Xe(e,t)];case 8:return c.sent(),[2]}}))}))},Ve=require("chalk"),Qe=function(e){return g(void 0,void 0,void 0,(function(){var t,n;return v(this,(function(r){return t=p.resolve(e,"network.json"),d.existsSync(t)||(n={networks:_,currentNetwork:"Ethereum Mainnet",accounts:[]},d.writeFileSync(t,JSON.stringify(n,null,2))),[2]}))}))},Ye=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r;return v(this,(function(a){switch(a.label){case 0:return n=["> Back",new m.default.Separator("----------------------------------"),"> Edit"],"Ethereum Mainnet"!==t.name&&"Solana Mainnet"!==t.name&&n.push("> Remove"),[4,$(n)];case 1:switch(r=a.sent(),r){case"> Edit":return[3,2];case"> Remove":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,et(e,t)];case 3:case 5:return a.sent(),[3,7];case 4:return[4,tt(e,t)];case 6:return[3,7];case 7:return[2]}}))}))},et=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a,s,o,c,u,i,l,f,m,h,g;return v(this,(function(v){switch(v.label){case 0:for(n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=[],g=0;g<r.networks.length;g++)s=r.networks[g],a.push(s.name);return o=t.rpcUrl,c=t.chainId.toString(),u=t.nativeCurrency.symbol,i=t.name,l=t.multicallAddress,f=t.color,"Ethereum Mainnet"!==t.name&&"Solana Mainnet"!==t.name?[3,2]:[4,W(t.chainId.toString(),"Rpc Url (default: ".concat(t.rpcUrl,")"),!0)];case 1:return o=v.sent(),[3,9];case 2:return[4,q("Chain Name (default: ".concat(t.name,")"))];case 3:return(i=v.sent())&&i!==t.name&&a.includes(i)?(console.log(Ve.red("Chain Name already exists")),[2]):[4,H("Chain Id (default: ".concat(t.chainId,")"),!0)];case 4:return c=v.sent(),[4,W(c||t.chainId,"RPC Url (default: ".concat(t.rpcUrl,")"),!0)];case 5:return o=v.sent(),[4,X("Symbol (default: ".concat(t.nativeCurrency.symbol,")"))];case 6:return u=v.sent(),[4,Z(t.multicallAddress?"Multicall Address (Optional) (default: ".concat(t.multicallAddress,")"):"Multicall Address (Optional)")];case 7:return l=v.sent(),[4,V(t.color?"Color (Optional): (default: ".concat(t.color,")"):"Color (Optional)")];case 8:f=v.sent(),v.label=9;case 9:for(m=j(c),h={name:i||t.name,chainId:Number(c)||t.chainId,rpcUrl:o||t.rpcUrl,nativeCurrency:{name:u||t.nativeCurrency.symbol,symbol:u||t.nativeCurrency.symbol,decimals:m||t.nativeCurrency.decimals}},(l||t.multicallAddress)&&(h.multicallAddress=l||t.multicallAddress),(f||t.color)&&(h.color=f||t.color),g=0;g<r.networks.length;g++)if(r.networks[g].name===t.name){r.networks[g]=h;break}return d.writeFileSync(n,JSON.stringify(r,null,2)),[2]}}))}))},tt=function(e,t){return g(void 0,void 0,void 0,(function(){var n,r,a;return v(this,(function(s){for(n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++)if(r.networks[a].name===t.name){r.networks.splice(a,1);break}return t.name===r.currentNetwork&&(r.currentNetwork="Ethereum Mainnet"),d.writeFileSync(n,JSON.stringify(r,null,2)),[2]}))}))},nt=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l,f,m,h;return v(this,(function(g){switch(g.label){case 0:for(t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=[],a=0;a<n.networks.length;a++)s=n.networks[a],r.push(s.name);return console.log(Ve.green("Please input someting about network")),[4,q("Chain Name")];case 1:return o=g.sent(),r.includes(o)?(console.log(Ve.red("Chain Name already exists")),[2]):[4,H("Chain Id")];case 2:return(c=g.sent())?[4,W(c,"RPC Url")]:[2];case 3:return(u=g.sent())?[4,X("Symbol")]:[2];case 4:return(i=g.sent())?[4,Z("Multicall Address (Optional)")]:[2];case 5:return l=g.sent(),[4,V("Color (Optional)")];case 6:return f=g.sent(),m=j(c),h={name:o,chainId:Number(c),rpcUrl:u,nativeCurrency:{name:i,symbol:i,decimals:m}},l&&(h.multicallAddress=l),f&&(h.color=f),n.networks.push(h),d.writeFileSync(t,JSON.stringify(n,null,2)),[2]}}))}))},rt=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,i,l,f,h,g;return v(this,(function(v){switch(v.label){case 0:for(t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=[],a=[],c=0;c<n.networks.length;c++)i=n.networks[c],"solana"===F(i.chainId.toString())?a.push(c):r.push(c);for(s=["> Back",new m.default.Separator("----Networks(evm)----")],c=0;c<r.length;c++)o=r[c],i=n.networks[o],l="".concat(c+1,".").concat(i.name),0===c&&(l+=" 🔒"),s.push(l);for(s.push(new m.default.Separator("----Networks(solana)----")),c=0;c<a.length;c++)u=a[c],i=n.networks[u],l="".concat(c+1,".").concat(i.name),0===c&&(l+=" 🔒"),s.push(l);return[4,$(s)];case 1:return"> Back"===(f=v.sent())?[2]:(h=s.indexOf(f),g=h<r.length+2?n.networks[r[h-2]]:n.networks[a[h-r.length-3]],[4,Ye(e,g)]);case 2:return v.sent(),[4,rt(e)];case 3:return v.sent(),[2]}}))}))},at=function(e){return g(void 0,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return t=["> Back",new m.default.Separator("----------------------------------"),"> Available Networks","> Add Network"],[4,$(t)];case 1:switch(n=r.sent(),n){case"> Available Networks":return[3,2];case"> Add Network":return[3,4];case"> Back":return[3,6]}return[3,7];case 2:return[4,rt(e)];case 3:case 5:return r.sent(),[3,7];case 4:return[4,nt(e)];case 6:return[2];case 7:return[4,at(e)];case 8:return r.sent(),[2]}}))}))},st=function(e){return g(void 0,void 0,void 0,(function(){var t,n,r;return v(this,(function(a){switch(a.label){case 0:return t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=n.networks.map((function(e){return"> ".concat(e.name)})),[4,$(r,"Please select a default network")];case 1:return[2,a.sent().slice(2)]}}))}))},ot=function(e,t){for(var n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++){var s=r.networks[a];if(s.name===t)return F(s.chainId.toString())}return"unknown"},ct=function(e,t){for(var n=p.resolve(e,"network.json"),r=JSON.parse(d.readFileSync(n,"utf8")),a=0;a<r.networks.length;a++){var s=r.networks[a];if(s.name===t)return s}return null},ut=function(e,t,n){var r=Re(e,t),a=r.default_network;r.data[n].default_network&&""!==r.data[n].default_network&&(a=r.data[n].default_network);var s=ot(e,a);return"solana"===s?r.data[n].ciphertexts.solana.address:"evm"===s?r.data[n].ciphertexts.evm.address:null},it=function(e,t){return Re(e,t).ciphertexts.address},lt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,f,h,g,b,w,y;return v(this,(function(v){switch(v.label){case 0:for(r=p.resolve(e,"network.json"),a=JSON.parse(d.readFileSync(r,"utf8")),s=a.networks,o=s.length,c=Re(e,t),u=["> Back",new m.default.Separator("----------------------------------")],(i=c.data[n].default_network)&&""!==i?u.push("○ Same as the account setting"):u.push("● Same as the account setting"),l=0;l<o;l++)f=s[l],h=void 0,h=F(f.chainId.toString())?c.data[n].ciphertexts.solana.address:c.data[n].ciphertexts.evm.address,f.name===i?u.push("● ".concat(h," [").concat(f.name,"]")):u.push("○ ".concat(h," [").concat(f.name,"]"));return[4,$(u)];case 1:return"> Back"===(g=v.sent())||(2===(b=u.indexOf(g))?delete c.data[n].default_network:c.data[n].default_network=s[b-3].name,Ue(e,t,c),w=c.default_network,"default_network"in c.data[n]&&""!==c.data[n].default_network&&(w=c.data[n].default_network),y=ct(e,w),console.log(Ve.green(" Address No: #".concat(n,"\n Network: ").concat(w,"\n ").concat(y.nativeCurrency.symbol," Balance: 0")))),[2]}}))}))},dt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c,u,i,l,f,h,g,b,w,y,k,S,N;return v(this,(function(v){switch(v.label){case 0:for(r=p.resolve(e,"network.json"),a=JSON.parse(d.readFileSync(r,"utf8")),s=a.networks,o=s.length,c=Re(e,t),u=["> Back",new m.default.Separator("----------------------------------")],i=c.default_network,l="",n||(l=c.ciphertexts.address),f=[],h=ot(e,i),g=0;g<o;g++)b=s[g],w=ot(e,b.name),"PK"===c.account_type&&h!==w||(b.name===i?n?u.push("● ".concat(b.name)):u.push("● ".concat(l," [").concat(b.name,"]")):n?u.push("○ ".concat(b.name)):u.push("○ ".concat(l," [").concat(b.name,"]")),f.push(b.name));return[4,$(u)];case 1:return"> Back"===(y=v.sent())||(k=u.indexOf(y),c.default_network=f[k-2],Ue(e,t,c),n||(S=c.default_network,N=ct(e,S),console.log(Ve.green(" Address No: #0\n Network: ".concat(S,"\n ").concat(N.nativeCurrency.symbol," Balance: 0"))))),[2]}}))}))},pt=function(e,t,n){return g(void 0,void 0,void 0,(function(){var r,a,s,o,c;return v(this,(function(i){switch(i.label){case 0:return r=ct(t,n),a=r.rpcUrl,s=r.nativeCurrency.decimals,"solana"!==F(r.chainId.toString())?[3,2]:[4,y(e,a)];case 1:return o=i.sent(),[3,4];case 2:return[4,w(e,a)];case 3:o=i.sent(),i.label=4;case 4:return o.status&&(c=new u.BigNumber(o.output.toString()),o.output=c.dividedBy(Math.pow(10,s)).toFixed(4,u.BigNumber.ROUND_FLOOR)),[2,o]}}))}))},ft=function(e,t,n){var r=Re(e,t);if("PK"===r.account_type)return r.default_network;for(var a=0;a<r.data.length;a++)if(r.data[a].ciphertexts.solana.address===n||r.data[a].ciphertexts.evm.address===n)return"default_network"in r.data[a]?r.data[a].default_network:r.default_network;return null},mt=function(e){for(var t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")).networks,r=n.length,a=[],s=0;s<r;s++)"evm"===F(n[s].chainId.toString())&&a.push(n[s].name);return a};require("wative-core").WativeCore;var ht=function(e,t){return g(void 0,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return[4,$(["> System & Settings","> Accounts","> Tools","> Exit"])];case 1:switch(n=r.sent(),n){case"> System & Settings":return[3,2];case"> Accounts":return[3,4];case"> Tools":return[3,6];case"> Exit":return[3,8]}return[3,9];case 2:return[4,at(e)];case 3:case 5:case 7:return r.sent(),[3,9];case 4:return[4,Xe(e,t)];case 6:return[4,Ce(e,t)];case 8:return[2];case 9:return[4,ht(e,t)];case 10:return r.sent(),[2]}}))}))},gt=require("wative-core").WativeCore,vt=require("../package.json");require("events").EventEmitter.defaultMaxListeners=0;process.on("unhandledRejection",(function(e,t){console.log("Unhandled Rejection at:",t,"reason:",e)})),g(void 0,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(a){switch(a.label){case 0:return console.log("version:",vt.version),console.log(T.green(f.textSync("Wative",{font:"Ghost",horizontalLayout:"default",verticalLayout:"default"}))),[4,g(void 0,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,q("Keystore storage located in (default: ".concat(I,")"))];case 1:return(e=t.sent())||(e=I),e=(e=e.trim()).replace("~",L),d.existsSync(e)||d.mkdirSync(e,{recursive:!0}),[2,e]}}))}))];case 1:return e=a.sent(),[4,Qe(e)];case 2:return a.sent(),t=p.resolve(e,"network.json"),n=JSON.parse(d.readFileSync(t,"utf8")),r=new gt(e,n.accounts,null,!0),[4,ht(e,r)];case 3:return a.sent(),[2]}}))})).then((function(){return process.exit(0)})).catch((function(e){console.log(e.message),process.exit(1)}))}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wative",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "An agile keystore management toolkit",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -48,7 +48,7 @@
48
48
  "rollup-plugin-terser": "^7.0.2",
49
49
  "rollup-plugin-typescript2": "^0.31.1",
50
50
  "uuid": "^9.0.0",
51
- "wative-core": "1.0.4",
51
+ "wative-core": "1.0.6",
52
52
  "web3": "1.7.3"
53
53
  },
54
54
  "directories": {