-
Notifications
You must be signed in to change notification settings - Fork 6
/
529.63029519ce9c6d9b8af1.js
1 lines (1 loc) · 18.8 KB
/
529.63029519ce9c6d9b8af1.js
1
"use strict";(this.webpackChunkRuDEX3_light=this.webpackChunkRuDEX3_light||[]).push([[529],{23951:(t,e,n)=>{n.d(e,{Z:()=>P});var s=n(69864),a=n(67294),o=n(42329),i=n(58074),r=n.n(i),l=n(32793),c=n(89449),p=n(30806),d=n(98485),h=n(13973),u=n(50379),m=n(82050),g=n(23037),b=n(82267),y=n(112),f=n.n(y),C=n(91684),E=n(36345),v=n(94184),A=n.n(v),_=n(45697),w=n.n(_),T=n(76660);n(108);class x extends a.Component{static propTypes={label:w().string,error:w().element,placeholder:w().string,onChange:w().func,onAccountChanged:w().func,onAction:w().func,accountName:w().string,account:g.Z.ChainAccount,tabIndex:w().number,disableActionButton:w().bool,allowUppercase:w().bool,typeahead:w().bool,excludeAccounts:w().array,focus:w().bool,disabled:w().bool,editable:w().bool,locked:w().bool,requireActiveSelect:w().bool,noForm:w().bool};static defaultProps={autosubscribe:!1,excludeAccounts:[],disabled:null,editable:null,locked:!1,requireActiveSelect:!0,noForm:!1};constructor(t){super(t),this.state={accountIndex:[],locked:null},this.timer=null}componentDidMount(){let{account:t,accountName:e}=this.props;e&&this._addThisToIndex(e),this.props.myActiveAccounts.map((t=>{this._addThisToIndex(t)})),this.props.contacts.map((t=>{this._addThisToIndex(t)})),this._fetchAccounts(),this.props.onAccountChanged&&t&&this.props.onAccountChanged(t),!this.props.typeahead&&e&&this.onInputChanged(e)}componentDidUpdate(t){this.props.focus&&this.props.editable&&!this.props.disabled&&this.refs.user_input.focus(),t.account&&t.account!==this.props.account&&this.props.onAccountChanged&&this.props.onAccountChanged(this.props.account)}_addToIndex(t,e=!1){e?(this._addThisToIndex(t),this._fetchAccounts()):(clearTimeout(this.timer),this.timer=setTimeout((()=>{this._addToIndex(t,!0)}),500))}_addThisToIndex(t){let{accountIndex:e}=this.state;if(!t)return;let n=e.find((e=>e.name===t));t&&!n&&e.push({name:t,data:null,attempts:0})}_getIndex(t,e){return e.findIndex((e=>e.name===t))}_getSearchArray(){let{accountIndex:t}=this.state;return t.filter((t=>!t.data&&t.attempts<5?t.name:null)).map((t=>t.name))}_fetchAccounts(){let{accountIndex:t}=this.state,e=this._getSearchArray();e.length>0&&(0,p.FetchChainObjects)(p.ChainStore.getAccount,e,3e3,{}).then((n=>{n.forEach((n=>{if(n){let s=this._getIndex(n.get("name"),t),a=this._populateAccountIndex(n);a&&(t[s]=a,e.splice(n.get("name")))}})),e.forEach((e=>{let n=this._getIndex(e,t);t[n].attempts++})),this.setState({accountIndex:t}),this.state.accountIndex.find((t=>!t.data&&t.attempts<5))&&setTimeout((()=>{this._fetchAccounts()}),500)}))}_populateAccountIndex(t){let{myActiveAccounts:e,contacts:n}=this.props;if(!t)return null;let s=t.get("name"),a=p.ChainStore.getAccountMemberStatus(t),o=this.getInputType(s),i=E.Z.isKnownScammer(s)?f().translate("account.member.suspected_scammer"):f().translate("account.member."+a),r="name"===o?"#"+t.get("id").substring(4):"id"===o?t.get("name"):"pubkey"==o&&this.props.allowPubKey?"Public Key":null;return{name:s,attempts:0,data:{id:t.get("id"),name:s,type:o,status:a,isOwnAccount:e.has(s),isContact:n.has(s),isKnownScammer:E.Z.isKnownScammer(s),statusLabel:i,rightLabel:r,className:E.Z.isKnownScammer(s)||!t?"negative":null}}}getAccount(){return this.props.account}getError(){let{account:t,accountName:e,error:n,typeahead:s}=this.props,a=e?this.getInputType(e):null;return s||!t&&e&&"pubkey"!==a&&(n=f().translate("account.errors.unknown")),n||!t||a||(n=f().translate("account.errors.invalid")),n}getInputType(t){return t?"#"===t[0]&&h.Z.is_object_id("1.2."+t.substring(1))?"id":p.ChainValidation.is_account_name(t,!0)?"name":this.props.allowPubKey&&p.PublicKey.fromPublicKeyString(t)?"pubkey":null:null}getVerifiedAccountName(t){let{allowUppercase:e}=this.props,n=null;n="string"==typeof t?t:t&&t.target?t.target.value.trim():"",e||(n=n.toLowerCase());let s=n.replace("#","").match(/(?:\/account\/)(.*)/);return s&&(n=s[1]),n}_notifyOnChange(t,e){let{props:n}=this;"input"==e&&this.props.typeahead&&this.props.requireActiveSelect&&(n.onAccountChanged&&n.onAccountChanged(null),n.onChange&&n.onChange(null));let s=this.getVerifiedAccountName(t);n.onChange&&(s||""===s)&&n.onChange(s),n.onAccountChanged&&(0,p.FetchChain)("getAccount",s,void 0,{[s]:!1}).then((t=>{t&&(this.props.requireActiveSelect&&"select"==e||!this.props.requireActiveSelect)&&n.onAccountChanged(t)})).catch((t=>{console.log(t)}))}onSelect(t){this._notifyOnChange(t,"select")}onInputChanged(t){this._addToIndex(this.getVerifiedAccountName(t)),this._notifyOnChange(t,"input")}onKeyDown(t){13!==t.keyCode&&9!==t.keyCode||this.onAction(t)}_onAddContact(){m.Z.addAccountContact(this.props.accountName)}_onRemoveContact(){m.Z.removeAccountContact(this.props.accountName)}onAction(t){let{onAction:e,disableActionButton:n,account:s,accountName:a}=this.props;t.preventDefault(),this.getError()||!e||n||(s?e(s):"pubkey"===this.getInputType(a)&&e(a))}render(){let{accountIndex:t}=this.state,{account:e,accountName:n,disableActionButton:s}=this.props,o=this.state.accountIndex.find((t=>!t.data&&t.attempts<5));const i=null!==this.state.locked?this.state.locked:this.props.locked;let l,c,p,d,h,m,g=this.getError();if(h=!i&&(null!=this.props.editable?this.props.editable:void 0),d=!!i||(null!=this.props.disabled?this.props.disabled:void 0),e){let n=this._getIndex(e.get("name"),t);c=t&&t[n]?t[n].data:null}if(p=!(e||c&&"pubkey"===c.type)||g||s,c&&c.isOwnAccount?m=a.createElement(T.Tooltip,{placement:"top",title:f().translate("tooltip.own_account")},a.createElement("span",{className:"tooltip green"},a.createElement(T.Icon,{type:"user"}))):c&&c.isKnownScammer?m=a.createElement(T.Tooltip,{placement:"top",title:f().translate("tooltip.scam_account")},a.createElement("span",{className:"tooltip red"},a.createElement(T.Icon,{type:"warning",theme:"filled"}))):c&&c.isContact?m=a.createElement(T.Tooltip,{placement:"top",title:f().translate("tooltip.follow_user"),onClick:this._onRemoveContact.bind(this)},a.createElement("span",{className:"tooltip green"},a.createElement(T.Icon,{type:"star",theme:"filled"}))):c&&(m=a.createElement(T.Tooltip,{placement:"top",title:f().translate("tooltip.follow_user_add"),onClick:this._onAddContact.bind(this)},a.createElement("span",{className:"tooltip"},a.createElement(T.Icon,{type:"star"})))),this.props.typeahead){let e=t.filter((t=>t.data?-1!==this.props.excludeAccounts.indexOf(t.id)?null:t.data.isOwnAccount||!this.props.locked&&t.data.isContact||n&&t.data.name===n?t:void 0:null)).sort(((t,e)=>t.data.isOwnAccount<e.data.isOwnAccount&&t.data.name>e.data.name?1:-1)).map((t=>a.createElement(T.Select.Option,{key:t.data.id,value:t.data.name,disabled:!!t.data.disabled||void 0},t.data.isOwnAccount?a.createElement(T.Icon,{type:"user"}):null,t.data.isContact?a.createElement(T.Icon,{type:"star"}):null,t.data.isKnownScammer?a.createElement(T.Icon,{type:"warning"}):null," ",t.data.name,a.createElement("span",{style:{float:"right"}},t.data.statusLabel))));l=a.createElement(T.Select,{showSearch:!0,optionLabelProp:"value",onSelect:this.onSelect.bind(this),onSearch:this.onInputChanged.bind(this),placeholder:f().translate("account.search"),notFoundContent:f().translate("global.not_found"),value:c?c.name:null,disabled:!!d||void 0},e)}else l=a.createElement(T.Input,{style:{textTransform:c&&"pubkey"===c.type?null:"lowercase",fontVariant:"initial"},name:"username",id:"username",autoComplete:this.props.editable?"username":void 0,type:"text",value:this.props.accountName||"",placeholder:this.props.placeholder||f().translate("account.name"),disabled:!!this.props.disabled||void 0,ref:"user_input",onChange:this.onInputChanged.bind(this),onKeyDown:this.onKeyDown.bind(this),tabIndex:!this.props.editable||this.props.disabled?-1:this.props.tabIndex,editable:h?h.toString():void 0,readOnly:h?(!h).toString():void 0});let b=this.props.hideImage?null:c&&"pubkey"===c.accountType?a.createElement("div",{className:"account-image"},a.createElement(C.Z,{name:"key",title:"icons.key",size:"4x"})):a.createElement(u.Z,{size:{height:this.props.size||33,width:this.props.size||33},account:c?c.name:null,custom_image:null}),y=i?"":null,E=this.props.label&&c?a.createElement("div",{className:"header-area"+(this.props.hideImage?" no-margin":"")},a.createElement("label",{className:A()("right-label",c.isContact||c.isOwnAccount?"positive":null,c.isKnownScammer?"negative":null),style:{marginTop:-30}},a.createElement("span",{style:{paddingRight:"0.5rem"}},c.rightLabel," ",c.displayText),m)):null;const v=this.props.noForm?a.Fragment:T.Form,_=this.props.noForm?{}:{className:"full-width",layout:"vertical",style:this.props.style};return a.createElement(T.Tooltip,{className:"input-area",title:this.props.tooltip,mouseEnterDelay:.5},a.createElement(v,_,a.createElement(T.Form.Item,{label:this.props.label?f().translate(this.props.label):"",validateStatus:g?"error":null,help:g||null},E,this.props.useHR&&a.createElement("hr",null),a.createElement("div",{className:"inline-label input-wrapper"},b,l,o?a.createElement(T.Icon,{type:"loading",style:{padding:10}}):null,y,this.props.children,this.props.onAction?a.createElement(T.Tooltip,{title:f().translate("tooltip.required_input",{type:f().translate("global.field_type.account")})},a.createElement(T.Button,{type:"primary",disabled:p,onClick:this.onAction.bind(this)},a.createElement(r(),{content:this.props.action_label}))):null))))}}x=(0,b.Z)(x);const N=x=(0,c.$)(x,{listenTo:()=>[l.Z],getProps:()=>({myActiveAccounts:l.Z.getState().myActiveAccounts,contacts:l.Z.getState().accountContacts})});var I=n(73556),S=n(44015),k=n(60567);function O(){return O=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},O.apply(this,arguments)}n(74366);class Z extends o.b{constructor(t){super(t)}UNSAFE_componentWillReceiveProps(t){t.to_name!==this.state.to_name&&this.setState({to_name:t.to_name?t.to_name:"",to_account:t.to_name?p.ChainStore.getAccount(t.to_name):null})}render(){let{propose:t,from_account:e,to_account:n,asset:o,asset_id:i,propose_account:c,feeAmount:h,amount:u,to_name:m,from_name:g,memo:b,balanceError:y,hidden:C}=this.state,E=l.Z.isMyAccount(e)||g===this.props.passwordAccount,v=!(!e||E||t),{asset_types:A}=this._getAvailableAssets(),_=null;if(e&&e.get("balances")&&!v){let t=e.get("balances").toJS(),n=this.state.balanceError?"has-error":"";if(1===A.length&&(o=p.ChainStore.getAsset(A[0])),A.length>0){let e=o?o.get("id"):A[0];_=a.createElement("span",null,a.createElement(r(),{component:"span",content:"transfer.available"}),":"," ",a.createElement("span",{className:n,style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"},onClick:this._setTotal.bind(this,e,t[e],h.getAmount({real:!0}),h.asset_id)},a.createElement(S.Z,{balance:t[e]})))}else _=a.createElement("span",null,a.createElement("span",{className:n},a.createElement(r(),{content:"transfer.errors.noFunds"})))}let w=t&&!c;const x=parseFloat(String.prototype.replace.call(u,/,/g,"")),O=x&&!(0,s.Z)(x),Z=!e||!n||!O||!o||v||w||y||e.get("id")==n.get("id");let L=this.props.tabIndex;return this.state.open?a.createElement("div",{id:"send_modal_wrapper",className:C||!this.state.open?"hide":""},a.createElement(T.Modal,{visible:this.state.isModalVisible,id:this.props.id,overlay:!0,onCancel:this.hideModal,footer:[a.createElement(T.Button,{key:"send",disabled:Z,onClick:Z?null:this.onSubmit.bind(this)},t?f().translate("propose"):f().translate("transfer.send")),a.createElement(T.Button,{key:"Cancel",tabIndex:L++,onClick:this.onClose},a.createElement(r(),{component:"span",content:"transfer.cancel"}))]},a.createElement("div",{className:"grid-block vertical no-overflow"},a.createElement("div",{className:"content-block",style:{textAlign:"center",fontSize:"18px"}},a.createElement(r(),{content:this.props.header,wallet_name:(0,k.w)()}),this.props.ticker),this.state.open?a.createElement(T.Form,{className:"full-width-wrapper",layout:"vertical"},a.createElement(N,{label:"transfer.from",accountName:g,account:e,onChange:this.fromChanged.bind(this),onAccountChanged:this.onFromAccountChanged.bind(this),typeahead:!0,tabIndex:L++,locked:!0,noForm:!0}),a.createElement(N,{label:"transfer.to",accountName:m,account:n,onChange:this.toChanged.bind(this),onAccountChanged:this.onToAccountChanged.bind(this),typeahead:!0,tabIndex:L++,locked:!0,noForm:!0}),a.createElement(d.Z,{label:"transfer.amount",amount:u,onChange:this.onAmountChanged.bind(this),asset:A.length>0&&o?o.get("id"):i||A[0],display_balance:_,tabIndex:L++,allowNaN:!0,locked:!0}),a.createElement(I.Z,{account:e,transaction:{type:"transfer",options:["price_per_kbyte"],data:{type:"memo",content:b}},onChange:this.onFeeChanged.bind(this),tabIndex:L++})):null))):null}}class L extends a.Component{render(){return a.createElement(Z,O({},this.props,{ref:this.props.refCallback}))}}const P=L=(0,c.$)(L,{listenTo:()=>[l.Z],getProps:t=>({currentAccount:l.Z.getState().currentAccount,passwordAccount:l.Z.getState().passwordAccount,tabIndex:t.tabIndex||0})})},3894:(t,e,n)=>{n.d(e,{Z:()=>m});var s=n(67294),a=n(13863),o=n(23037),i=n(82267),r=n(43393);class l extends s.Component{static propTypes={dos:o.Z.ChainObjectsList};static defaultProps={dos:(0,r.List)()};constructor(){super(),this.getDynamicObject=this.getDynamicObject.bind(this)}getDynamicObject(t){return this.props.dos.find((e=>e&&e.get("id")===t))}render(){return s.cloneElement(s.Children.only(this.props.children),{...this.props,getDynamicObject:this.getDynamicObject})}}l=(0,i.Z)(l);var c=n(45697),p=n.n(c),d=n(60567);function h(){return h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},h.apply(this,arguments)}class u extends s.Component{static propTypes={replaceNoneToBts:p().bool,maxWidth:p().number};static defaultProps={replaceNoneToBts:!0,maxWidth:20};constructor(t){super(t),this.state={imgError:!1}}shouldComponentUpdate(t,e){return this.props.asset!==t.asset||this.props.maxWidth!==t.maxWidth||this.props.whiteList!==t.whiteList||this.state.imgError!==e.imgError}_onError(t){this.state.imgError||(this.props.replaceNoneToBts?this.refs[t.toLowerCase()].src="asset-symbols/unknown.png":this.refs[t.toLowerCase()].remove(),this.setState({imgError:!0}))}render(){let{asset:t}=this.props;const e=function(t){if(null===t)return"unknown";let e=t.get("symbol");return(0,d.sA)(e)}(t);return s.createElement("img",{ref:e.toLowerCase(),className:"column-hide-small",onError:this._onError.bind(this,e),style:{maxWidth:this.props.maxWidth,marginRight:5,marginTop:"-3px"},src:`asset-symbols/${e.toLowerCase()}.png`})}}u=function(t,e={}){e.propNames=e.propNames||[e.asList?"assets":"asset"];const n=e.propNames.reduce(((t,n)=>(t[n]=e.asList?o.Z.ChainAssetsList:o.Z.ChainAsset.isRequired,t)),{});let c=Object.keys(n).reduce(((t,n)=>{let s=e.defaultProps&&e.defaultProps[n];return t[n]=e.asList?(0,r.List)(s||[]):s||"1.3.0",t}),{});e.defaultProps&&e.defaultProps.tempComponent&&(c.tempComponent=e.defaultProps.tempComponent);class p extends s.Component{static propTypes=n;static defaultProps=c;render(){let t={},n={},a=(0,r.List)();Object.keys(this.props).forEach((s=>{this.props[s]&&-1!==e.propNames.indexOf(s)?(e.withDynamic&&(e.asList?this.props[s].forEach((t=>{t&&(a=a.push(t.get("dynamic_asset_data_id")))})):a=a.push(this.props[s].get("dynamic_asset_data_id"))),t[s]=e.asList?this.props[s].filter((t=>!!t)):this.props[s]):n[s]=this.props[s]}));let o=s.cloneElement(s.Children.only(this.props.children),{...n,...t});return e.withDynamic?s.createElement(l,{dos:a},o):o}}p=(0,i.Z)(p);class d extends s.Component{render(){return s.createElement(p,this.props,s.createElement(t,{ref:"bound_component"}))}}return d.displayName=`Wrapper(${(0,a.G)(t)})`,d}(u);class m extends s.Component{render(){return s.createElement(u,h({},this.props,{asset:this.props.name}))}}},34091:(t,e,n)=>{n.d(e,{m:()=>g,O:()=>m});var s=n(67294),a=n(45697),o=n.n(a),i=n(94184),r=n.n(i),l=n(89449),c=n(55294),p=n(39014),d=n(112),h=n.n(d),u=n(5977);class m extends s.Component{static propTypes={changeTab:o().func,isActive:o().bool.isRequired,index:o().number.isRequired,className:o().string,isLinkTo:o().string,subText:o().oneOfType([o().object,o().string])};static defaultProps={isActive:!1,index:0,className:"",isLinkTo:"",subText:null};render(){let{isActive:t,index:e,changeTab:n,title:a,className:o,updatedTab:i,disabled:l,subText:c}=this.props,p=r()({"is-active":t},o);return"string"==typeof a&&a.indexOf(".")>0&&(a=h().translate(a)),this.props.collapsed?("string"==typeof c&&(c=c.trim()),"span"===a.type&&(a=a.props.children[2]),s.createElement("option",{value:e,"data-is-link-to":this.props.isLinkTo},a,i?"*":"",c&&" (",c&&c,c&&")")):s.createElement("li",{className:p,onClick:l?null:n.bind(this,e,this.props.isLinkTo)},s.createElement("a",null,s.createElement("span",{className:"tab-title"},a,i?"*":""),c&&s.createElement("div",{className:"tab-subtext"},c)))}}class g extends s.Component{static propTypes={setting:o().string,defaultActiveTab:o().number,segmented:o().bool};static defaultProps={active:0,defaultActiveTab:0,segmented:!0,contentClass:"",style:{}};constructor(t){super(),this.state={activeTab:t.setting?t.viewSettings.get(t.setting,t.defaultActiveTab):t.defaultActiveTab,width:window.innerWidth},this._setDimensions=this._setDimensions.bind(this)}componentDidMount(){this._setDimensions(),window.addEventListener("resize",this._setDimensions,{capture:!1,passive:!0})}UNSAFE_componentWillReceiveProps(t){let e=t.viewSettings.get(t.setting);e!==this.props.viewSettings.get(this.props.setting)&&this.setState({activeTab:e})}componentWillUnmount(){window.removeEventListener("resize",this._setDimensions)}_setDimensions(){let t=window.innerWidth;t!==this.state.width&&this.setState({width:t})}_changeTab(t,e){t!==this.state.activeTab&&(""!==e&&this.props.history.push(e),this.props.setting&&c.Z.changeViewSetting({[this.props.setting]:t}),this.setState({activeTab:t}),this.props.onChangeTab&&this.props.onChangeTab(t))}render(){let{children:t,contentClass:e,tabsClass:n,style:a,segmented:o}=this.props;const i=this.state.width<900&&s.Children.count(t)>2;let l=null,c=s.Children.map(t,((t,e)=>{if(!t)return null;if(i&&t.props.disabled)return null;let n=e===this.state.activeTab;return n&&(l=t.props.children),s.cloneElement(t,{collapsed:i,isActive:n,changeTab:this._changeTab.bind(this),index:e})})).filter((t=>null!==t));return l||(l=c[0].props.children),s.createElement("div",{className:r()(this.props.actionButtons?"with-buttons":"",this.props.className)},s.createElement("div",{className:"service-selector"},s.createElement("ul",{style:a,className:r()("button-group no-margin",n,{segmented:o})},i?s.createElement("li",{style:{paddingLeft:10,paddingRight:10,minWidth:"15rem"}},s.createElement("select",{value:this.state.activeTab,style:{marginTop:10,marginBottom:10},className:"bts-select",onChange:t=>{let e=parseInt(t.target.value,10);this._changeTab(e,t.target[e].attributes["data-is-link-to"].value)}},c)):c,this.props.actionButtons?s.createElement("li",{className:"tabs-action-buttons"},this.props.actionButtons):null)),s.createElement("div",{className:r()("tab-content",e)},l))}}g=(0,l.$)(g,{listenTo:()=>[p.Z],getProps:()=>({viewSettings:p.Z.getState().viewSettings})}),g=(0,u.EN)(g)}}]);