-
Notifications
You must be signed in to change notification settings - Fork 13
/
322.781d0e3fc3479a8f2248.js
1 lines (1 loc) · 30.9 KB
/
322.781d0e3fc3479a8f2248.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[322],{62390:(e,t,n)=>{n.d(t,{A:()=>P});var a=n(96540),s=n(9476),l=n(9404),r=n.n(l),i=n(32485),c=n.n(i),o=n(10658),m=n.n(o),u=n(40702),h=n(20149),p=n(69146),d=n(55421),_=n(14954),g=n(96366),y=n(80849),b=n.n(y);class E extends a.Component{UNSAFE_componentWillReceiveProps(e){e.claim_account_name&&this.onClaimAccount(e.claim_account_name,e.checked)}render(){if(void 0===this.props.balances||!this.props.total_by_account_asset.size)return a.createElement("div",null);let e=-1;return a.createElement("div",null,a.createElement("table",{className:"table"},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null),a.createElement("th",{style:{textAlign:"center"}},a.createElement(b(),{content:"wallet.unclaimed"})),a.createElement("th",{style:{textAlign:"center"}},a.createElement(b(),{content:"wallet.unclaimed_vesting"})),a.createElement("th",{style:{textAlign:"center"}},a.createElement(b(),{content:"account.name"})))),a.createElement("tbody",null,this.props.total_by_account_asset.map(((t,n)=>a.createElement("tr",{key:++e},a.createElement("td",null,a.createElement("input",{type:"checkbox",checked:!!this.props.checked.get(e),onChange:this.onCheckbox.bind(this,e,t.balances)})),a.createElement("td",{style:{textAlign:"right"}},t.unclaimed?a.createElement(g.A,{color:"info",amount:t.unclaimed,asset:n.get(1)}):null),a.createElement("td",{style:{textAlign:"right"}},t.vesting.unclaimed?a.createElement("div",null,a.createElement(g.A,{color:"info",amount:t.vesting.unclaimed,hide_asset:!0,asset:n.get(1)}),a.createElement("span",null," of "),a.createElement(g.A,{color:"info",amount:t.vesting.total,asset:n.get(1)})):null),a.createElement("td",null," ",n.get(0)," ")))).toArray())))}onCheckbox(e,t){let n=this.props.checked;n=n.get(e)?n.delete(e):n.set(e,t),_.A.setSelectedBalanceClaims(n)}onClaimAccount(e,t){if(t.size)return;let n=-1;this.props.total_by_account_asset.forEach(((a,s)=>{n++,s.get(0)===e&&(a.unclaimed||a.vesting.unclaimed)&&(t=t.set(n,a.balances))})),t.size&&_.A.setSelectedBalanceClaims(t)}}const f=E=(0,s.N)(E,{listenTo:()=>[d.A],getProps(){let e=d.A.getState(),{balances:t,address_to_pubkey:n}=e,a=h.A.getState().keys,s=r().Map().asMutable();return t&&(e.total_by_account_asset=t.groupBy((e=>{let t="",l=n.get(e.owner),i=a.get(l);i&&i.import_account_names&&(t=i.import_account_names.join(", "));let c=Math.ceil(((e,t)=>{let n=s.get(e);return n||(n=r().Set().asMutable(),s.set(e,n)),n.add(t),n.size})(r().List([t,e.balance.asset_id]),e.owner)/60);return r().List([t,e.balance.asset_id,c])})).map((e=>e.reduce(((e,t)=>(t.public_key_string=n.get(t.owner),e.balances=e.balances.add(t),null!=t.vested_balance?(e.vesting.unclaimed+=Number(t.vested_balance.amount),e.vesting.total+=Number(t.balance.amount)):e.unclaimed+=Number(t.balance.amount),e)),{unclaimed:0,vesting:{unclaimed:0,total:0},balances:r().Set()}))).sortBy((e=>e))),e}});var k=n(32795),v=n(55840),w=n(12569),A=n(81088),C=n(72342),S=n(5556),x=n.n(S);class N extends a.Component{static propTypes={accounts:w.A.ChainAccountsList.isRequired,onChange:x().func.isRequired};render(){var e=this.props.accounts.filter((e=>!!e)).filter((e=>v.A.isMyAccount(e))).map((e=>e.get("name"))).sort();return a.createElement("span",null,a.createElement(A.A,{onChange:this.onAccountSelect.bind(this),account_names:e,center:!0}))}onAccountSelect(e){this.props.onChange(e)}}const B=(0,C.A)(N);var I=n(46128);class K extends a.Component{UNSAFE_componentWillMount(){let e=h.A.getState().keys.keySeq();_.A.setPubkeys(e),this.existing_keys=e}UNSAFE_componentWillReceiveProps(e){let t=h.A.getState().keys.keySeq();t.equals(this.existing_keys)||(this.existing_keys=t,_.A.setPubkeys(t))}render(){if(!this.props.account_refs.size)return a.createElement("div",null,a.createElement("h5",null,a.createElement(b(),{content:"wallet.no_balance"})));if(this.props.loading)return a.createElement("div",null,a.createElement("br",null),a.createElement("h5",null,a.createElement(b(),{content:"wallet.loading_balances"}),"…"),a.createElement("br",null),a.createElement(u.A,{type:"three-bounce"}));if(!this.props.balances||!this.props.balances.size)return a.createElement("div",null,a.createElement("br",null),a.createElement("h5",null,a.createElement(b(),{content:"wallet.no_balance"})));let e=this.props.selected_balances.size&&this.props.claim_account_name,t=e?` (${this.props.claim_account_name})`:null;return a.createElement("div",null,a.createElement("div",{className:"content-block center-content"},a.createElement("h3",{className:"no-border-bottom"},a.createElement(b(),{content:"wallet.claim_balances"}))),a.createElement("div",{className:"grid-block vertical"},a.createElement("div",{className:"grid-content",style:{overflowY:"hidden !important"}},a.createElement("div",{className:"full-width-content center-content"},a.createElement(B,{key:this.props.balances,accounts:r().List(this.props.account_refs),onChange:this.onClaimAccountChange.bind(this)})),a.createElement("br",null)),a.createElement("br",null),a.createElement(f,null)),a.createElement("br",null),a.createElement("br",null),a.createElement("div",{className:c()("button success",{disabled:!e}),onClick:this.onClaimBalance.bind(this)},a.createElement(b(),{content:"wallet.claim_balance"}),t),a.createElement("div",{className:"button cancel",onClick:this.onBack.bind(this)},a.createElement(b(),{content:"wallet.cancel"})))}onBack(e){e.preventDefault(),window.history.back()}onClaimAccountChange(e){_.A.claimAccountChange(e)}onClaimBalance(){k.A.importBalance(this.props.claim_account_name,this.props.selected_balances,!0).catch((e=>{console.error("claimBalance",e);let t=e;try{t=e.data.message}catch(e){}throw I.Notification.error({message:m().translate("notifications.balance_claim_error",{error_msg:t})}),e}))}}const P=K=(0,s.N)(K,{listenTo:()=>[d.A,p.A,h.A],getProps(){let e=d.A.getState();return e.account_refs=p.A.getAccountRefs(),e}})},25322:(e,t,n)=>{n.r(t),n.d(t,{ExistingAccountOptions:()=>H,default:()=>J});var a=n(96540),s=n(54625),l=n(9476),r=n(98933),i=n(62390),c=n(80849),o=n.n(c),m=n(24180),u=n(84123),h=n(9404),p=n.n(h),d=n(32485),_=n.n(d),g=n(49074);const y=g.A.createActions(class{setBrainkey(e){return e}});var b=n(72090),E=n(77736);class f{static instances=new Map;static getInstance(e){var t=f.instances.get(e);t||(t=g.A.createStore(k,"BrainkeyStore"),f.instances.set(e,t));var n=e+" subscribed_instance";if(!f.instances.get(n)){var a=t.chainStoreUpdate.bind(t);b.ChainStore.subscribe(a),f.instances.set(n,a)}return t}static closeInstance(e){var t=f.instances.get(e);if(!t)throw new Error("unknown instance "+e);var n=e+" subscribed_instance",a=f.instances.get(n);f.instances.delete(n),b.ChainStore.unsubscribe(a),t.clearCache()}}class k extends E.A{constructor(){super(),this.clearCache(),this.bindListeners({onSetBrainkey:y.setBrainkey}),this._export("inSync","chainStoreUpdate","clearCache")}clearCache(){this.state={brnkey:"",account_ids:p().Set()},this.derived_keys=new Array,this.account_ids_by_key=null}onSetBrainkey(e){this.clearCache(),this.setState({brnkey:e}),this.deriveKeys(e),this.chainStoreUpdate()}inSync(){return this.derived_keys.forEach((e=>{if(w(e))return!1})),!0}chainStoreUpdate(){this.derived_keys.length&&this.account_ids_by_key!==b.ChainStore.account_ids_by_key&&(this.account_ids_by_key=b.ChainStore.account_ids_by_key,this.updateAccountIds())}deriveKeys(e=this.state.brnkey){var t,n,a=this.derived_keys.length,s=(t=b.key.get_brainPrivateKey(e,a),n=t.toPublicKey().toPublicKeyString(),{private_key:t,public_string:n});this.derived_keys.push(s),this.derived_keys.length<10&&this.deriveKeys(e)}updateAccountIds(){var e=p().Set().withMutations((e=>{this.derived_keys.forEach((t=>{return n=t.public_string,void((a=b.ChainStore.getAccountRefsOfKey(n))&&a.forEach((t=>{e.add(t)})));var n,a}))}));e.equals(this.state.account_ids)||(this.state.account_ids=e,this.setState({account_ids:e}))}}var v,w=e=>void 0===b.ChainStore.getAccountRefsOfKey(e.public_string),A=n(72342),C=n(12569),S=n(5556),x=n.n(S);class N extends a.Component{static propTypes={onChange:x().func.isRequired};constructor(){super(),this.state={brnkey:"",loading:!0}}UNSAFE_componentWillMount(){fetch("dictionary.json").then((e=>e.json().then((e=>{v=new Set(e.en.split(",")),this.setState({loading:!1})})))).catch((e=>{console.log("fetch dictionary error:",e)}))}_checkBrainKey(){let e,t=this.state.brnkey.split(" "),n=[];t.forEach(((e,t)=>{if(""===e)return;let s=e.toLowerCase();s=s.match(/[a-z]+/),null===s||v.has(s[0])?n.push(a.createElement("span",{key:t,style:{padding:"1px",margin:"1px"}},e)):n.push(a.createElement(B,{key:t},e))}));let s=!0,l=!0;return n.length>0&&(this.state.brnkey.length<50?(e=this.state.brnkey.length+" characters (50 minimum)",l=!1):n.length<16?e=n.length+" words (16 recommended)":(e=n.length+" words",s=!1)),{warn:s,valid:l,word_count_label:e,checked_words:n}}render(){if(this.state.loading||!v)return a.createElement("div",{style:{padding:20}},"Fetching dictionary....");let{warn:e,word_count_label:t,checked_words:n}=this._checkBrainKey();return a.createElement("span",{className:""},a.createElement("div",null,a.createElement("textarea",{tabIndex:this.props.tabIndex||1,onChange:this.formChange.bind(this),value:this.state.brnkey,id:"brnkey",style:{height:100,minWidth:450}}),a.createElement("div",{style:{textAlign:"left"},className:"grid-content no-padding no-overflow"},n),this.state.check_digits&&!this.props.hideCheckDigits?a.createElement("div",null,a.createElement("br",null),a.createElement("pre",{className:"no-overflow"},this.state.check_digits," * Check Digits"),a.createElement("br",null)):null,a.createElement("p",null,a.createElement("i",{className:_()({error:e})},t))))}formChange(e){var{id:t,value:n}=e.target;let{valid:a}=this._checkBrainKey();var s={};if(s[t]=n,"brnkey"===t){var l=b.key.normalize_brainKey(n);this.props.onChange(l.length<50?null:l),s.check_digits=l.length<50?null:b.hash.sha1(l).toString("hex").substring(0,4)}this.setState(s),this.props.errorCallback&&this.props.errorCallback(a)}}class B extends a.Component{render(){return a.createElement("span",{style:{borderBottom:"1px dotted #ff0000",padding:"1px",margin:"1px"}},a.createElement("span",{style:{borderBottom:"1px dotted #ff0000"}},this.props.children))}}var I=n(89247),K=n(14670),P=n(55840);class T extends a.Component{static propTypes={account:C.A.ChainAccount.isRequired};onCardClick(e){e.preventDefault();let t=this.props.account.get("name");this.props.history.push(`/account/${t}`)}render(){let e=null,t=null,n=!1;if(this.props.account){e=this.props.account.get("name");let s=this.props.account.get("balances");s&&(t=s.map((e=>b.ChainStore.getObject(e).get("balance")?a.createElement("li",{key:e},a.createElement(I.A,{balance:e})):null)).toArray()),n=P.A.isMyAccount(this.props.account)}return a.createElement("div",{className:"grid-content account-card",onClick:this.onCardClick.bind(this)},a.createElement("div",{className:"card"+(n?" my-account":"")},a.createElement("h4",{className:"text-center"},e),a.createElement("div",{className:"card-content clearfix"},a.createElement("div",{className:"float-left"},a.createElement(K.A,{account:e,size:{height:64,width:64}})),a.createElement("ul",{className:"balances"},t))))}}T=(0,A.A)(T);const z=(0,m.y)(T),R={listenTo:()=>[f.getInstance("wmc")],getProps:()=>f.getInstance("wmc").getState()};class M extends a.Component{componentWillUnmount(){f.closeInstance("wmc")}render(){return a.createElement("span",null,a.createElement("h3",null,a.createElement(o(),{content:"wallet.brainkey"})),a.createElement(j,null,a.createElement(W,null)))}}const O=M=(0,l.N)(M,R);class W extends a.Component{render(){let e=this.props.brnkey.substring(0,10);return a.createElement("span",null,a.createElement("div",null,a.createElement("span",{className:""},e),"…"),a.createElement("p",null),this.props.account_ids.size?a.createElement(q,{accounts:p().List(this.props.account_ids.toArray())}):a.createElement("h5",null,a.createElement(o(),{content:"wallet.no_accounts"})))}}W=(0,l.N)(W,R);class q extends a.Component{static propTypes={accounts:C.A.ChainAccountsList.isRequired};render(){let e=(0,u.A)(this.props.accounts).filter((e=>!!e[1])).map((e=>e[1].get("name"))).sort().map((e=>a.createElement(z,{key:e,account:e})));return a.createElement("span",null,e)}}q=(0,A.A)(q);class j extends a.Component{constructor(){super(),this.state={brnkey:"",accept:!1}}render(){if(this.state.accept)return a.createElement("span",null,this.props.children);let e=this.state.brnkey&&""!==this.state.brnkey;return a.createElement("span",{className:"grid-container"},a.createElement("div",null,a.createElement(N,{onChange:this.onBrainkeyChange.bind(this)})),a.createElement("div",{className:_()("button success",{disabled:!e}),onClick:this.onAccept.bind(this)},a.createElement(o(),{content:"wallet.accept"})))}onBrainkeyChange(e){this.setState({brnkey:e})}onAccept(){this.setState({accept:!0}),y.setBrainkey(this.state.brnkey)}}var D=n(87133),F=n(99425),U=n(45964);const L={listenTo:()=>[r.A],getProps:()=>({wallet:r.A.getState()})};class G extends a.Component{render(){const e=0!=this.props.wallet.wallet_names.count();return a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"grid-content"},a.createElement("div",{className:"content-block center-content"},a.createElement("div",{className:"page-header"},a.createElement("h1",null,a.createElement(o(),{content:"account.welcome",wallet_name:(0,U.vj)()})),e?a.createElement("h3",null,a.createElement(o(),{content:"wallet.setup_wallet"})):a.createElement("h3",null,a.createElement(o(),{content:"wallet.create_wallet_backup"}))),a.createElement("div",{className:"content-block"},a.createElement(m.dO,null,a.createElement(m.qh,{exact:!0,path:"/existing-account",component:F.jY}),a.createElement(m.qh,{exact:!0,path:"/existing-account/import-backup",component:H}),a.createElement(m.qh,{exact:!0,path:"/existing-account/import-keys",component:D.A}),a.createElement(m.qh,{exact:!0,path:"/existing-account/brainkey",component:O}),a.createElement(m.qh,{exact:!0,path:"/existing-account/balance-claim",component:i.A})),this.props.children))))}}G=(0,l.N)(G,L);class H extends a.Component{render(){const e=0!=this.props.wallet.wallet_names.count();return a.createElement("span",null,e?null:a.createElement("div",null,a.createElement(s.N_,{to:"existing-account/import-backup"},a.createElement(o(),{content:"wallet.import_backup",wallet_name:(0,U.vj)()})),a.createElement("br",null),a.createElement("br",null),a.createElement(s.N_,{to:"existing-account/import-keys"},a.createElement(o(),{content:"wallet.import_bts1"})),a.createElement("br",null),a.createElement("br",null),a.createElement(s.N_,{to:"existing-account/import-keys"},a.createElement(o(),{content:"wallet.create_wallet"})),a.createElement("br",null),a.createElement("hr",null)),e?a.createElement(i.A,null):null,e?a.createElement("span",null,a.createElement(s.N_,{to:"dashboard"},a.createElement("div",{className:"button outline"},a.createElement(o(),{component:"span",content:"header.dashboard"}))),a.createElement(s.N_,{to:"wallet"},a.createElement("div",{className:"button outline"},a.createElement(o(),{content:"settings.wallets"})))):null)}}H=(0,l.N)(H,L);const J=G},87133:(t,n,a)=>{a.d(n,{A:()=>O});var s=a(96540),l=a(9476),r=a(32485),i=a.n(r),c=a(72090),o=a(65319),m=a(62716),u=a(20149),h=a(51579),p=a(11186),d=a(40702),_=a(80849),g=a.n(_),y=a(10658),b=a.n(y),E=a(62390),f=a(14954),k=a(55421),v=a(96366);class w extends s.Component{render(){if(void 0===this.props.balances)return s.createElement("div",null,s.createElement(g(),{content:"wallet.loading_balances"}),"…");var e=this.props.balances.groupBy((e=>e.balance.asset_id)).map((e=>e.reduce(((e,t)=>e+Number(t.balance.amount)),0)));return e.size?s.createElement("div",null,e.map(((e,t)=>s.createElement("div",{key:t},s.createElement(v.A,{color:"info",amount:e,asset:t})))).toArray()):s.createElement("div",null,"None")}}const A=w=(0,l.N)(w,{listenTo:()=>[k.A],getProps:()=>k.A.getState()});var C=a(46863),S=a(49074),x=a(77736);class N extends x.A{constructor(){super(),this.state=this._getInitialState(),this._export("importing")}_getInitialState(){return{importing:!1}}importing(e){this.setState({importing:e})}}const B=S.A.createStore(N,"ImportKeysStore");var I=a(46128),K=a(48287).Buffer,P=void 0;try{var T=a(41973).A;if(-1===T.indexOf("3cee441"))throw new Error("Incorrect hash: bts_genesiskeys_bloom.dat");P=T}catch(e){console.log("WARN: Will be unable to filter BTS 1.0 wallet imports, did not find assets/bts_genesiskeys_bloom.dat",e)}class z{constructor(e){e&&(this.bloom_buffer=e,this.bits_in_filter=8*e.length)}isAvailable(){return void 0!==P}init(t){if(this.bloom_buffer)t();else{if(!this.isAvailable())throw new Error("Genesis bloom file was not deployed");var n=new XMLHttpRequest;n.responseType="blob",n.onload=()=>{if(404!==n.status){var e=new FileReader;e.onload=e=>{var n=new K(e.target.result,"binary");if(1048576!==n.length)throw new Error("Wrong length");this.bits_in_filter=8*n.length,this.bloom_buffer=n,t()},e.readAsBinaryString(n.response)}},n.onerror=()=>{console.error("xhr.onerror",e)},n.open("GET",P),n.send()}}inGenesis(e){if(!this.bloom_buffer)throw new Error("Call init() first");for(var t=0;t<3;t++){var n=c.hash.sha256(t+":"+e),a=parseInt(n.slice(-3).toString("hex"),16)%this.bits_in_filter,s=a>>3,l=1<<(7&a);if(!(this.bloom_buffer[s]&l))return!1}return!0}filter(e,t){if(!this.isAvailable())return console.log("WARN: Missing bloom filter for BTS 0.9.x wallets"),void t({error:"missing_bloom"});var n=!0;t({initalizing:n}),this.init((()=>{try{t({initalizing:n=!1});for(var a=1,s=0;s<e.length;s++){var l=0,r=0,i=e[s],o=i.encrypted_private_keys.length;t({importing:!0,account_name:i.account_name,count:r,total:o});for(var m=i.encrypted_private_keys.length-1;m>=0;m--){if(++r%a==0&&(a=47,t({importing:!0,account_name:i.account_name,count:r,total:o})),!i.public_keys)return void t({error:"missing_public_keys"});var u=i.public_keys[m];if(/^GPH/.test(u)&&(u="BTS"+u.substring(3)),!this.inGenesis(u)){for(var h=c.key.addresses(u,"BTS"),p=!1,d=0;d<h.length;d++)if(this.inGenesis(h[d])){p=!0;break}p||(delete i.encrypted_private_keys[m],delete i.public_keys[m],l++)}}var _=[],g=[];for(m=i.encrypted_private_keys.length-1;m>=0;m--)i.encrypted_private_keys[m]&&(_.push(i.encrypted_private_keys[m]),g.push(i.public_keys[m]));i.encrypted_private_keys=_,t({importing:!1,account_name:i.account_name,count:r-l,total:o}),i.public_keys=g}t({success:!0})}finally{n&&t({initalizing:n=!1})}}))}}a(61073);const R=({key_count:e})=>e?s.createElement("span",null,"Found ",e," private keys"):s.createElement("span",null);class M extends s.Component{constructor(){super(),this.state=this._getInitialState(),this._renderBalanceClaims=this._renderBalanceClaims.bind(this)}static defaultProps={privateKey:!0};_getInitialState(e=!1){return{keys_to_account:{},no_file:!0,account_keys:[],reset_file_name:e?this.state.reset_file_name:Date.now(),reset_password:Date.now(),password_checksum:null,import_file_message:null,import_password_message:null,imported_keys_public:{},key_text_message:null,associatedAccount:null,errorTextMessage:null,genesis_filtering:!1,genesis_filter_status:[],genesis_filter_finished:void 0,importSuccess:!1}}reset(e,t){e&&e.preventDefault();let n=this._getInitialState(t);this.setState(n,(()=>this.updateOnChange()))}onWif(e){e.preventDefault();const t=this.refs.wifInput.state.value;this.addByPattern(t)}onCancel(e){e&&e.preventDefault(),this.setState(this._getInitialState())}updateOnChange(){f.A.setPubkeys(Object.keys(this.state.imported_keys_public))}getImportAccountKeyCount(e){let t={},n=!1;for(let a in e)for(let s of e[a].account_names)t[s]=(t[s]||0)+1,n=!0;return n?t:null}upload(e){this.reset(null,!0);let t=e.target.files[0],n=new FileReader;n.onload=e=>{let n=e.target.result;try{let e;try{e=JSON.parse(n),this._parseImportKeyUpload(e,t.name,(e=>{this.setState(e,(()=>{e.genesis_filter_finished&&this._passwordCheck()}))}))}catch(a){try{e||t.name,this._parseWalletJson(e)}catch(e){if(!this.addByPattern(n))throw e}this._passwordCheck()}}catch(e){console.error("... ImportKeys upload error",e),this.setState({import_file_message:e})}},n.readAsText(t)}_parseImportKeyUpload(e,t,n){let a,s;try{if(a=e.password_checksum,!a)throw t+" is an unrecognized format";if(!Array.isArray(e.account_keys))throw t+" is an unrecognized format";s=e.account_keys}catch(e){throw e.message||e}let l=new z;l.isAvailable()?this.setState({genesis_filter_initalizing:!0},(()=>l.init((()=>{let e=this.state.genesis_filter_status,t=s;l.filter(t,(l=>{if("missing_public_keys"===l.error)return console.error("un-released format, just for testing"),void n({password_checksum:a,account_keys:s,genesis_filter_finished:!0,genesis_filtering:!1});l.success?n({password_checksum:a,account_keys:t,genesis_filter_finished:!0,genesis_filtering:!1}):void 0===l.initalizing?void 0!==l.importing?(e.length&&e[e.length-1].account_name===l.account_name?e[e.length-1]=l:e.push(l),n({genesis_filter_status:e})):console.error("unknown status",l):n({genesis_filter_initalizing:l.initalizing,genesis_filtering:!0})}))})))):n({password_checksum:a,account_keys:s,genesis_filter_finished:!0,genesis_filtering:!1})}_parseWalletJson(e){let t,n,a={},s={},l=function(e,t){e=m.ChainConfig.address_prefix+e.substring(3);let n=c.PublicKey.fromPublicKeyString(e).toAddressString(),a=s[t]||[];n="BTS"+n.substring(3),a.push(n),s[t]=a};try{if(!Array.isArray(e))throw new Error("Invalid wallet format");for(let s of e)if("key_record_type"==s.type&&s.data.account_address&&s.data.encrypted_private_key){let e=s.data.account_address,t=a[e]||[];t.push(s.data.encrypted_private_key),a[e]=t}else if("account_record_type"!=s.type)if("property_record_type"!=s.type||"encrypted_brainkey"!=s.data.key){if("master_key_record_type"==s.type){if(!s.data)throw file.name+" invalid master_key_record record";if(!s.data.checksum)throw file.name+" is missing master_key_record checksum";t=s.data.checksum}}else n=s.data.value;else{let e=s.data.name;l(s.data.owner_key,e);for(let t of s.data.active_key_history)l(t[1],e)}if(!n)throw"Please use a BTS 1.0 wallet_export_keys file instead";if(!t)throw file.name+" is missing password_checksum";if(!enckeys.length)throw file.name+" does not contain any private keys"}catch(e){throw e.message||e}let r=[];for(let e in s){let t=[];for(let n of s[e]){let e=a[n];if(e)for(let n of e)t.push(n)}r.push({account_name:e,encrypted_private_keys:t})}this.setState({password_checksum:t,account_keys:r})}_passwordCheck(e){e&&"preventDefault"in e&&e.preventDefault();let t=this.refs.password,n=t?t.value:"";if(this.state.password_checksum!=c.hash.sha512(c.hash.sha512(n)).toString("hex"))return this.setState({no_file:!1,import_password_message:n.length?"Incorrect password":null});this.setState({no_file:!1,reset_password:Date.now(),import_password_message:b().translate("wallet.import_pass_match")},(()=>this._decryptPrivateKeys(n)))}_decryptPrivateKeys(e){let t=c.Aes.fromSeed(e),n=!0;for(let e of this.state.account_keys){if(!e.encrypted_private_keys){let t=`Account ${e.account_name} missing encrypted_private_keys`;console.error(t),n&&(I.Notification.error({message:t}),n=!1);continue}let a=e.account_name.trim(),s=new RegExp("^"+m.ChainConfig.address_prefix);for(let n=0;n<e.encrypted_private_keys.length;n++){let l=e.encrypted_private_keys[n],r=e.public_keys?e.public_keys[n]:null;try{let e=t.decryptHex(l);r?s.test(r)||(r=m.ChainConfig.address_prefix+r.substring(3)):r=c.PrivateKey.fromHex(e).toPublicKey().toPublicKeyString(),this.state.imported_keys_public[r]=!0;let{account_names:n}=this.state.keys_to_account[e]||{account_names:[]},i=!1;for(let e of n)e==a&&(i=!0);if(i)continue;n.push(a),this.state.keys_to_account[e]={account_names:n,public_key_string:r}}catch(e){console.log(e,e.stack);let t=e.message||e;I.Notification.error({message:b().translate("notifications.import_keys_error",{account_name:a,error_msg:t})})}}}this.setState({import_file_message:null,import_password_message:null,password_checksum:null},(()=>this.updateOnChange()))}_saveImport(e){e.preventDefault();let t=u.A.getState().keys,n={};for(let e in this.state.imported_keys_public)t.has(e)&&(delete this.state.imported_keys_public[e],n[e]=!0);if(0===Object.keys(this.state.imported_keys_public).length)return void I.Notification.error({message:b().translate("notifications.import_keys_already_imported")});let a=this.state.keys_to_account;for(let e of Object.keys(a)){let{account_names:t,public_key_string:s}=a[e];n[s]&&delete a[e]}h.A.unlock().then((()=>{B.importing(!0),setTimeout((()=>this.saveImport()),200)})).catch((()=>{}))}saveImport(){let e=this.state.keys_to_account,t=[];for(let n of Object.keys(e)){let{account_names:a,public_key_string:s}=e[n];t.push({private_plainhex:n,import_account_names:a,public_key_string:s})}this.reset(),C.A.importKeysWorker(t).then((e=>{B.importing(!1);let n=t.length;I.Notification.success({message:b().translate("wallet.import_key_success",{count:n})}),this.setState({importSuccess:!0})})).catch((e=>{console.log("error:",e),B.importing(!1);let t=e;try{t=e.target.error.message}catch(e){}I.Notification.error({message:b().translate("notifications.import_keys_error_unknown",{error_msg:t})})}))}addByPattern(e){if(!e)return this.setState({errorTextMessage:b().translate("wallet.wif_import_error")}),!1;if(51!==e.length)return this.setState({errorTextMessage:b().translate("wallet.wif_length_error")}),!1;let t=0,n=0,a=/5[HJK][1-9A-Za-z]{49}/g;for(let s of e.match(a)||[])try{let e=c.PrivateKey.fromWif(s),n=e.toBuffer().toString("hex"),a=e.toPublicKey().toPublicKeyString();this.state.imported_keys_public[a]=!0,this.state.keys_to_account[n]={account_names:[],public_key_string:a};let l=[];o.A.lookupAccountByPublicKey(a).then((async e=>{let t;t=e[0].map((e=>(0,c.FetchChain)("getAccount",e))),(await Promise.all(t)).map((e=>{let t=e.get("name");-1===l.indexOf(t)&&l.push(t)})),this.setState({associatedAccount:l})})),t++}catch(e){n++}return this.setState({key_text_message:"Found "+(t?t+" valid":"")+(n?" and "+n+" invalid":"")+" key"+(t>1||n>1?"s":"")+"."},(()=>this.updateOnChange())),this.setState({key_text_message:null,errorTextMessage:null}),t}_renderBalanceClaims(){return s.createElement("div",null,s.createElement(E.A,null),s.createElement("div",{style:{paddingTop:15}},s.createElement(I.Button,{type:"primary",onClick:this.onCancel.bind(this)},s.createElement(g(),{content:"wallet.done"}))))}render(){let{privateKey:e}=this.props,{keys_to_account:t}=this.state,n=Object.keys(t).length,a=this.getImportAccountKeyCount(t);if(!C.A.getWallet())return s.createElement(p.G,{importKeys:!0,hideTitle:!0});if(this.props.importing)return s.createElement("div",null,s.createElement("div",{className:"center-content"},s.createElement(d.A,{type:"circle"})));let l=this.state.genesis_filtering,r=(!!this.state.genesis_filter_status.length&&this.state.genesis_filter_finished,null);if(this.state.genesis_filter_status.length){r=[];for(let e of this.state.genesis_filter_status)e.count&&e.total&&r.push(s.createElement("tr",{key:e.account_name},s.createElement("td",null,e.account_name),s.createElement("td",null,l?s.createElement("span",null,"Filtering"," ",Math.round(e.count/e.total*100)," ","%"," "):s.createElement("span",null,e.count))))}let c=0!==n,o=b().translate("wallet.import_password");if(c&&(o=""),!r&&a){r=[];for(let e in a)r.push(s.createElement("tr",{key:e},s.createElement("td",null,e),s.createElement("td",null,a[e])))}let m=s.createElement(I.Button,{onClick:this.onCancel.bind(this)},s.createElement(g(),{content:"wallet.cancel"})),u=1;return this.state.importSuccess?this._renderBalanceClaims():s.createElement("div",null,s.createElement("div",{style:{padding:"10px 0"}},s.createElement("span",null,this.state.key_text_message?this.state.key_text_message:s.createElement(R,{key_count:n})),c?s.createElement("span",null," ","(",s.createElement("a",{onClick:this.reset.bind(this)},s.createElement(g(),{content:"wallet.reset"})),")"):null,s.createElement("span",null,s.createElement("br",null),this.state.associatedAccount&&s.createElement("div",null,s.createElement(g(),{content:"wallet.wif_associated_accounts"}),this.state.associatedAccount.map(((e,t)=>s.createElement("p",{key:t},e)))))),r?s.createElement("div",null,r.length?s.createElement("div",null,s.createElement("table",{className:"table"},s.createElement("thead",null,s.createElement("tr",null,s.createElement("th",null,s.createElement(g(),{content:"explorer.account.title"})),s.createElement("th",null,s.createElement(g(),{content:"settings.restore_key_count"})))),s.createElement("tbody",null,r)),s.createElement("br",null)):b().translate("wallet.no_accounts")):null,s.createElement("br",null),c||this.state.genesis_filter_initalizing?null:s.createElement("div",null,s.createElement("div",null,s.createElement("div",null,e?s.createElement("form",{onSubmit:this.onWif.bind(this)},s.createElement(g(),{component:"label",content:"wallet.paste_private"}),s.createElement(I.Input,{ref:"wifInput",type:"password",id:"wif",tabIndex:u++,style:{marginBottom:"16px"}}),s.createElement("div",{className:"importError"},s.createElement("span",{className:"red"},this.state.errorTextMessage)),s.createElement(I.Button,{type:"primary",htmlType:"submit",style:{marginRight:"16px"}},s.createElement(g(),{content:"wallet.submit"})),m):s.createElement("form",{onSubmit:this._passwordCheck.bind(this)},s.createElement("label",null,s.createElement(g(),{content:"wallet.bts_09_export"}),this.state.no_file?null:s.createElement("span",null," (",s.createElement("a",{onClick:this.reset.bind(this)},"Reset"),")")),s.createElement("input",{type:"file",id:"file_input",accept:".json",style:{border:"solid",marginBottom:15},key:this.state.reset_file_name,onChange:this.upload.bind(this)}),s.createElement("div",null,this.state.import_file_message),this.state.no_file?null:s.createElement("div",null,s.createElement(I.Input,{type:"password",ref:"password",key:this.state.reset_password,placeholder:o,onChange:()=>{this.state.import_password_message&&this.state.import_password_message.length&&this.setState({import_password_message:null})}}),s.createElement("p",{className:"facolor-error"},this.state.import_password_message)),s.createElement("div",{className:"button-group"},s.createElement(I.Button,{type:"primary",disabled:!!this.state.no_file,htmlType:"submit",style:{marginRight:"16px"}},s.createElement(g(),{content:"wallet.submit"})),m))),s.createElement("br",null),s.createElement("br",null))),this.state.genesis_filter_initalizing?s.createElement("div",null,s.createElement("div",{className:"center-content"},s.createElement(d.A,{type:"circle"}))):null,c?s.createElement("div",null,s.createElement("div",null,s.createElement("div",{className:"button-group"},s.createElement("div",{className:i()("button success",{disabled:!c}),onClick:this._saveImport.bind(this)},s.createElement(g(),{content:"wallet.import_keys"})),s.createElement("div",{className:"button secondary",onClick:this.reset.bind(this)},s.createElement(g(),{content:"wallet.cancel"})))),s.createElement("h4",null,s.createElement(g(),{content:"wallet.unclaimed"})),s.createElement(g(),{component:"p",content:"wallet.claim_later"}),s.createElement("div",{className:"grid-block"},s.createElement("div",{className:"grid-content no-overflow"},s.createElement(g(),{component:"label",content:"wallet.totals"}),s.createElement(A,null))),s.createElement("br",null)):null)}}const O=M=(0,l.N)(M,{listenTo:()=>[B],getProps:()=>({importing:B.getState().importing})})},41973:(e,t,n)=>{n.d(t,{A:()=>a});const a=n.p+"bts_genesiskeys_bloom_3cee441.dat"},61073:(e,t,n)=>{n.r(t)}}]);