-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path101.0eb338b9dc4edb0e40f9.js
1 lines (1 loc) · 17.6 KB
/
101.0eb338b9dc4edb0e40f9.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[101],{15255:(e,t,s)=>{s.d(t,{A:()=>k});var a=s(96540),n=s(80849),i=s.n(n),o=s(87040),r=s(72342),l=s(12569),c=s(39744),p=s(10658),m=s.n(p),d=s(52550),u=s(16415),h=s(21561),g=s(40702),_=s(18450),b=s(9476),y=s(74248),E=s(84259),A=s(15286),v=s.n(A),f=s(46128);function C(){return C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},C.apply(this,arguments)}class w extends a.Component{static propTypes={sender:l.A.ChainAccount.isRequired,asset:l.A.ChainAsset.isRequired};constructor(e){super(),this.state={inputCoinType:e.inputCoinType||this.props.preferredBridge,outputCoinType:e.outputCoinType,receiveAmount:0,depositLimit:0,sendAmount:0,toAddress:d.fH.getLast(e.walletType),withdrawValue:"",amountError:null,inputAmount:0,receiveLoading:!1,limitLoading:!0,apiError:!1},this._validateAddress(this.state.toAddress,e),this.deposit_address_cache=new u.A}onClose(){this.props.hideModal()}UNSAFE_componentWillMount(){this._getDepositAddress(this.props)}componentDidMount(){this._getDepositLimit(this.props),this._estimateOutput(this.props)}UNSAFE_componentWillReceiveProps(e){e.inputCoinType===this.props.inputCoinType&&e.outputCoinType===this.props.outputCoinType||(this.setState({inputCoinType:e.inputCoinType,outputCoinType:e.outputCoinType}),this._getDepositLimit(e),this._estimateOutput(e),this._getDepositAddress(e))}componentDidUpdate(){c.A.rebuild()}shouldComponentUpdate(e,t){return this.state.inputCoinType===t.inputCoinType&&this.state.outputCoinType===t.outputCoinType||(this._getDepositLimit(t),this._estimateOutput(t),this._getDepositAddress(t)),e.inputCoinType!==this.props.inputCoinType||e.outputCoinType!==this.props.outputCoinType||e.sender!==this.props.sender||e.asset!==this.props.asset||e.isAvailable!==this.props.isAvailable||e.isDown!==this.props.isDown||!o.A.are_equal_shallow(t,this.state)}_getDepositAddress(e){this.setState({receive_address:null}),(0,d.e4)(this._getDepositObject(e))}_getDepositObject(e){let{inputCoinType:t,outputCoinType:s}=e;return{inputCoinType:t.toLowerCase(),outputCoinType:s.toLowerCase(),outputAddress:this.props.sender.get("name"),url:_.qi.BASE,stateCallback:e=>{this.addDepositAddress(t.toLowerCase(),s.toLowerCase(),this.props.sender.get("name"),e)}}}_getDepositLimit(e){let{inputCoinType:t,outputCoinType:s}=e;this.setState({limitLoading:!0}),(0,d.K5)(t.toLowerCase(),s.toLowerCase()).then((e=>{this.setState({depositLimit:e.depositLimit,limitLoading:!1})})).catch((e=>{console.log("deposit limit error:",e),this.setState({depositLimit:null,limitLoading:!1})}))}_onAmountChange(e,t){let s=t.target.value;switch(new RegExp(/[[:digit:]]/).test(s)||(s=s.replace(/[^0-9.]/g,"")),"."==s.charAt(0)&&(s="0."),s.charAt(s.length)!=s.search(".")&&s.substr(1),s=o.A.limitByPrecision(s,8),e){case"input":this.setState({inputAmount:s},this._estimateOutput.bind(this));break;case"output":this.setState({outputAmount:s},this._estimateInput.bind(this))}}_estimateOutput(){let{inputAmount:e,inputCoinType:t,outputCoinType:s}=this.state;this.setState({receiveAmount:0,sendAmount:e}),e&&(this.setState({receiveLoading:!0}),(0,d.uV)(e,t.toLowerCase(),s.toLowerCase()).then((e=>{this.setState({inputAmount:e.inputAmount,receiveAmount:e.outputAmount,receiveLoading:!1})})).catch((e=>{console.log("receive amount err:",e),this.setState({receiveLoading:!1,apiError:!0})})))}_estimateInput(){let{outputAmount:e,inputCoinType:t,outputCoinType:s}=this.state;this.setState({receiveAmount:e,sendAmount:0}),e&&(this.setState({receiveLoading:!0}),(0,d.PH)(e,t.toLowerCase(),s.toLowerCase()).then((e=>{console.log(e),this.setState({inputAmount:e.inputAmount,sendAmount:o.A.limitByPrecision(e.inputAmount,8),receiveLoading:!1})})).catch((e=>{console.log("send amount err:",e),this.setState({receiveLoading:!1,apiError:!0})})))}addDepositAddress(e,t,s,a){this.deposit_address_cache.cacheInputAddress("blocktrades",s,e,t,a.address,a.memo),this.setState({receive_address:a})}_validateAddress(e,t=this.props){(0,d.jl)({walletType:t.walletType,newAddress:e}).then((t=>{this.state.toAddress===e&&this.setState({withdraw_address_check_in_progress:!1,validAddress:t})})).catch((e=>{console.error("Error when validating address:",e)}))}_setDepositAsset(e){this.setState({inputCoinType:e}),E.A.changeViewSetting({preferredBridge:e})}_renderDeposit(){const{name:e,prefix:t}=o.A.replaceName(this.props.asset),{receive_address:s,apiError:n}=this.state,r=s&&"memo"in s&&s.memo,l=s&&s.address||"",c=a.createElement("div",{className:"QR",style:{textAlign:"center"}},a.createElement(v(),{size:140,value:l}));let p=Object.keys(this.props.bridges.toJS());const d=this.state.inputCoinType.toUpperCase(),u=(t||"")+e;let _=(this.state.receiveAmount/this.state.inputAmount).toFixed(4),b=u+"/"+d;const y=this.state.inputAmount>parseFloat(this.state.depositLimit)||this.state.sendAmount>parseFloat(this.state.depositLimit);return a.createElement("div",{className:"modal__body",style:{paddingTop:0}},a.createElement(f.Form,{className:"full-width",layout:"vertical"},a.createElement(f.Form.Item,{label:m().translate("modal.buy.asset")},a.createElement(f.Input,{disabled:!0,value:u})),a.createElement(f.Form.Item,{label:m().translate("modal.buy.bridge")},a.createElement(f.Tooltip,{title:m().translate("tooltip.bridge_TRADE")},a.createElement(f.Input,{disabled:!0,type:"text",defaultValue:"BLOCKTRADES"})))),n?a.createElement(i(),{content:"modal.deposit.address_generation_error"}):a.createElement("span",null,a.createElement("div",{className:"grid-block no-overflow wrap shrink"},a.createElement("div",{className:"small-12 medium-6",style:{paddingRight:5}},a.createElement(f.Form,{className:"full-width",layout:"vertical"},a.createElement(f.Form.Item,{label:m().translate("transfer.send"),validateStatus:y?"error":"",help:y?m().translate("gateway.over_limit"):""},a.createElement(f.Input,{value:this.state.sendAmount,onChange:this._onAmountChange.bind(this,"input"),addonAfter:a.createElement(f.Select,{defaultValue:this.state.inputCoinType.toUpperCase(),value:this.state.inputCoinType.toUpperCase(),style:{width:100},onChange:this._setDepositAsset.bind(this)},p.map((e=>a.createElement(f.Select.Option,{key:e.toUpperCase()},e.toUpperCase()))))})))),a.createElement("div",{className:"small-12 medium-6",style:{paddingRight:5}},a.createElement(f.Form,{className:"full-width",layout:"vertical"},a.createElement(f.Form.Item,{label:m().translate("gateway.deposit_limit")},a.createElement(f.Input,{value:this.state.depositLimit,disabled:!0,addonAfter:a.createElement(f.Select,{defaultValue:this.state.inputCoinType.toUpperCase(),value:this.state.inputCoinType.toUpperCase(),style:{width:100},disabled:!0,showArrow:!1},p.map((e=>a.createElement(f.Select.Option,{key:e.toUpperCase()},e.toUpperCase()))))}))))),a.createElement("div",{className:"grid-block no-overflow wrap shrink"},a.createElement("div",{className:"small-12 medium-6",style:{paddingRight:5}},a.createElement(f.Form,{className:"full-width",layout:"vertical"},a.createElement(f.Form.Item,{label:m().translate("exchange.receive")},a.createElement(f.Input,{value:this.state.receiveAmount,onChange:this._onAmountChange.bind(this,"output"),addonAfter:a.createElement(f.Select,{defaultValue:u,value:u,style:{width:100},disabled:!0,showArrow:!1},a.createElement(f.Select.Option,{key:u},u))})))),a.createElement("div",{className:"small-12 medium-6",style:{paddingRight:5}},a.createElement(f.Form,{className:"full-width",layout:"vertical"},a.createElement(f.Form.Item,{label:m().translate("exchange.price")},a.createElement(f.Input,{value:y||isNaN(_)?0:_,disabled:!0,addonAfter:a.createElement(f.Select,{defaultValue:b,value:b,style:{width:125},disabled:!0,showArrow:!1},a.createElement(f.Select.Option,{key:b},b))}))))),l?a.createElement("div",{className:"container-row"},r?null:c,a.createElement("div",{className:"grid-block"},a.createElement("div",{className:"copyIcon"},a.createElement(h.A,{text:l,className:"copyIcon"})),a.createElement("div",null,a.createElement(i(),{component:"div",style:{fontSize:"0.8rem",fontWeight:"bold",paddingBottom:"0.3rem"},content:"gateway.purchase_notice",inputAsset:d,outputAsset:u}),a.createElement("div",{className:"modal__highlight"},l))),r?a.createElement("div",{className:"grid-block",style:{marginTop:"10px"}},a.createElement("div",{className:"copyIcon"},a.createElement(h.A,{text:s.memo,className:"copyIcon"})),a.createElement("div",null,a.createElement(i(),{unsafe:!0,content:"gateway.purchase_notice_memo",component:"div",style:{fontSize:"0.8rem",fontWeight:"bold",paddingBottom:"0.3rem"}}),a.createElement("div",{className:"modal__highlight"},s.memo))):null):a.createElement("div",{style:{textAlign:"center"}},a.createElement(g.A,{type:"three-bounce"}))))}render(){let{asset:e}=this.props;return e?a.createElement("div",{className:"grid-block vertical no-overflow"},this.props.isDown?a.createElement("div",{style:{textAlign:"center"}},a.createElement(i(),{className:"txtlabel cancel",content:"gateway.unavailable_TRADE",component:"p"})):this.props.isAvailable?this._renderDeposit():a.createElement("div",{style:{textAlign:"center"}},a.createElement(i(),{className:"txtlabel cancel",content:"gateway.unavailable",component:"p"}))):null}}w=(0,r.A)(w);class S extends a.Component{render(){let{preferredBridge:e,...t}=this.props,s=this.props.bridges.get(this.props.preferredBridge);return s||(s=this.props.bridges.first(),e=s.inputCoinType),a.createElement(w,C({hideModal:this.props.hideModal},t,{preferredBridge:e},s.toJS()))}}S=(0,b.N)(S,{listenTo:()=>[y.A],getProps:()=>({preferredBridge:y.A.getState().viewSettings.get("preferredBridge","btc")})});class k extends a.Component{render(){return this.props.bridges?a.createElement(f.Modal,{title:m().translate("modal.buy.title"),visible:this.props.visible,onCancel:this.props.hideModal,footer:[a.createElement(f.Button,{key:"cancel",onClick:this.props.hideModal},m().translate("modal.close"))]},a.createElement(S,C({},this.props,{open:this.props.visible}))):null}}},85551:(e,t,s)=>{s.d(t,{A:()=>F});var a=s(96540),n=s(9404),i=s.n(n),o=s(5556),r=s.n(o),l=s(80849),c=s.n(l),p=s(91001),m=s(54625),d=(s(12569),s(60819)),u=s(36247);class h extends a.Component{render(){let{base:e,quote:t}=this.props;if(e.get("id")===t.get("id"))return null;let s=t.get("symbol")+"_"+e.get("symbol"),n=a.createElement("span",null,a.createElement(p.A,{name:t.get("symbol")})," /"," ",a.createElement(p.A,{name:e.get("symbol")}));return a.createElement(m.N_,{to:`/market/${s}`,onClick:()=>u.A.switchMarket()},n)}}const g=h=(0,d.A)(h,{propNames:["quote","base"],defaultProps:{base:"1.3.0"}});var _=s(89247),b=s(2999),y=s(46863),E=s(10658),A=s.n(E),v=s(72090),f=s(50548),C=s(62716),w=s(24609),S=s(64143);function k(){return k=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},k.apply(this,arguments)}var T=s(16e3),x=s(46128),N=s(87040);const L=(I=({worthLessSettlement:e,asset:t,shortBackingAsset:s,marketPrice:n,settlementPrice:i})=>{switch(n=N.A.format_number(n,t.get("precision")),i=N.A.format_number(i,t.get("precision")),e){case!0:return a.createElement("div",null,a.createElement(c(),{component:"h2",content:"exchange.settle_better_marketprice"}),a.createElement("span",null,a.createElement(T.A,{string:"exchange.worth_less_settlement_warning",keys:[{value:a.createElement(g,{base:t.get("id"),quote:s.get("id")}),arg:"market_link"}]}),a.createElement("br",null)," ",a.createElement(c(),{content:"exchange.price_market"}),": ",n,a.createElement("br",null)," ",a.createElement(c(),{content:"exchange.settle"}),": ",i));case void 0:return a.createElement(c(),{content:"exchange.checking_for_worth_less_settlement"});default:return a.createElement("div",null,a.createElement(c(),{component:"h2",content:"exchange.settle_better_settleprice"}),a.createElement("span",null,a.createElement(T.A,{string:"exchange.settlement_hint",keys:[{value:a.createElement(g,{base:t.get("id"),quote:s.get("id")}),arg:"market_link"},{value:a.createElement(p.A,{name:t.get("symbol")}),arg:"long"}]}),a.createElement("br",null)," ",a.createElement(c(),{content:"exchange.price_market"}),": ",n,a.createElement("br",null)," ",a.createElement(c(),{content:"exchange.settle"}),": ",i))}},(e=>{const t=(0,d.A)(e,{propNames:["shortBackingAsset"]});return(0,d.A)((e=>a.createElement(t,k({},e,{shortBackingAsset:e.asset.getIn(["bitasset","options","short_backing_asset"])}))))})(class extends a.PureComponent{state={worthLessSettlement:void 0};updateFlag(){const{asset:e,shortBackingAsset:t}=this.props,s=e.get("id"),a=t.get("id"),n=C.Apis.instance().db_api().exec("get_order_book",[a,s,1]).then((e=>0===e.bids.length?0:Number(e.bids[0].price)));let i=null,o=1,r=0;e.get("bitasset")&&e.get("bitasset").get("settlement_fund")>0?i=e.get("bitasset").get("settlement_price"):(i=S.A.extractRawFeedPrice(e),r=e.get("bitasset").get("options").get("force_settlement_offset_percent"),o=1-r/1e4);const l=new w.gm({base:new w.Vd({asset_id:a,amount:i.getIn(["quote","amount"]),preicision:t.get("precision")}),quote:new w.Vd({asset_id:s,amount:i.getIn(["base","amount"]),precision:e.get("precision")})}).toReal()*o;n.then((e=>this.setState({worthLessSettlement:e>l,marketPrice:e,settlementPrice:l})))}UNSAFE_componentWillMount(){this.updateFlag()}componentDidUpdate(){this.updateFlag()}render(){const{props:e,state:{worthLessSettlement:t,marketPrice:s,settlementPrice:n}}=this;return a.createElement(I,k({},e,{worthLessSettlement:t,marketPrice:s,settlementPrice:n}))}}));var I;class D extends a.Component{static propTypes={asset:r().instanceOf(i().Map),core:r().instanceOf(i().Map),account:r().instanceOf(i().Map)};static defaultProps={asset:i().Map(),core:i().Map(),account:i().Map()};constructor(){super(),this.state={amount:0},this.onSubmit=this.onSubmit.bind(this)}UNSAFE_componentWillReceiveProps(e){e.asset&&this.props.asset&&e.asset.get("id")!==this.props.asset.get("id")&&this.setState({amount:0})}getSettlementInfo(){const{getDynamicObject:e,asset:t,core:s}=this.props,a=e(t.get("dynamic_asset_data_id")),n=a&&a.size?a.get("current_supply"):0,i=s&&s.size?s.getIn(["parameters","maintenance_interval"]):0,o=t.get("bitasset").toJS(),r=o.force_settled_volume,l=n*(o.options.maximum_force_settlement_volume/1e4);return{maxSettlementVolume:l,remainingVolume:r?l-r:l,maintenanceInterval:i,settlementDelay:o.options.force_settlement_delay_sec}}onAmountChanged({amount:e,asset:t}){this.setState({amount:e})}onSubmit(e){let{amount:t}=this.state;e.preventDefault(),this.props.hideModal(),t=parseInt(t*Math.pow(10,this.props.asset.get("precision")));var s=b.A.new_transaction();return s.add_type_operation("asset_settle",{fee:{amount:0,asset_id:0},account:this.props.account.get("id"),amount:{amount:t,asset_id:this.props.asset.get("id")}}),y.A.process_transaction(s,null,!0).then((e=>!0)).catch((e=>(console.error("asset settle error: ",e),!1)))}_useMaxValue(e){this.setState({amount:e/Math.pow(10,this.props.asset.get("precision"))})}render(){let{asset:e,account:t}=this.props,{amount:s}=this.state;if(!e)return null;let n=e&&e.getIn(["bitasset","options"])?e.getIn(["bitasset","options"]).toJS():null,i=e.get("bitasset").get("settlement_fund")>0,o=0;i||(o=e.get("bitasset").get("options").get("force_settlement_offset_percent")/100);let r=e.get("id"),l=t.get("balances");const{name:p,prefix:m}=N.A.replaceName(e),d=(m||"")+p;let u=null,h=0;l&&l.forEach((e=>{let t=v.ChainStore.getObject(e);if(!t.get("balance"))return null;t.get("asset_type")===r&&(u=e,h=t.get("balance"))}));let g=a.createElement("span",null,a.createElement(c(),{content:"exchange.balance"}),": ",u?a.createElement("span",{className:"underline",onClick:this._useMaxValue.bind(this,h)},a.createElement(_.A,{balance:u})):"0 "+e.get("symbol")),b=!1;s>h/Math.pow(10,this.props.asset.get("precision"))&&(b=!0);const y=[a.createElement(x.Tooltip,{title:b?A().translate("tooltip.lack_funds"):null},a.createElement(x.Button,{key:"submit",type:"primary",onClick:this.onSubmit,disabled:b},A().translate("modal.settle.submit"))),a.createElement(x.Button,{key:"close",onClick:this.props.hideModal},A().translate("modal.close"))],{maxSettlementVolume:E,remainingVolume:C,settlementDelay:w,maintenanceInterval:S}=this.getSettlementInfo(),k=i?0:(w+Math.floor(s/E)*S)/3600,T=e.getIn(["bitasset","is_prediction_market"]);let I=T?a.createElement(x.Alert,{message:A().translate("tooltip.settle_market_prediction"),type:"info",showIcon:!0}):a.createElement(a.Fragment,null,i?a.createElement(x.Alert,{message:A().translate("exchange.settle_delay_globally_settled"),type:"warning",showIcon:!0}):a.createElement(x.Alert,{message:A().translate("exchange.settle_delay",{hours:n.force_settlement_delay_sec/3600}),description:k?A().translate("modal.settle.delay",{amount:k}):null,type:"info",showIcon:!0}),a.createElement(L,{asset:r}),a.createElement("br",null),i?null:a.createElement(c(),{component:"div",content:"exchange.settle_offset",offset:o}),a.createElement("br",null),a.createElement(x.Form,{className:"full-width",layout:"vertical"},a.createElement(f.A,{label:"modal.settle.amount",amount:s,onChange:this.onAmountChanged.bind(this),display_balance:g,asset:r,assets:[r],tabIndex:1,style:s>C?{"margin-bottom":"0"}:{}}),s>C?a.createElement(a.Fragment,null,a.createElement(c(),{className:"facolor-info",content:"modal.settle.max_volume",amount:E,asset:d}),a.createElement("br",null),a.createElement(c(),{className:"facolor-info",content:"modal.settle.remaining_volume",amount:C,asset:d})):null));return a.createElement(x.Modal,{title:A().translate("modal.settle.title",{asset:d}),visible:this.props.visible,id:this.props.modalId,footer:T?null:y,onCancel:this.props.hideModal,overlay:!0,ref:"settlement_modal"},I)}}D=(0,d.A)(D,{propNames:["asset","core"],withDynamic:!0,defaultProps:{core:"2.0.0"}});class M extends a.Component{render(){return a.createElement(D,this.props)}}const F=M}}]);