-
Notifications
You must be signed in to change notification settings - Fork 13
/
813.b2fe51fea65bedef5adb.js
1 lines (1 loc) · 11.5 KB
/
813.b2fe51fea65bedef5adb.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[813],{37554:(e,t,a)=>{a.d(t,{Rq:()=>C,a2:()=>O,et:()=>x,tB:()=>D});var s=a(96540),r=a(96366),i=a(12569),n=a(72342),o=a(60819),l=a(87040),d=a(9476),c=a(58586),f=a(80849),_=a.n(f),p=a(10658),u=a.n(p),g=a(47729),m=a(88587),h=a(46128),y=a(5556),A=a.n(y),w=a(72090);function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},b.apply(this,arguments)}const O=function(e,t,a,s=null,r=null,i=null){try{return m.A.convertValue(e,t,a,i||c.A.getState().allMarketStats,r||w.ChainStore.getAsset("1.3.0"),s||!0)}catch(e){console.log(e)}};class B extends g.A{static defaultProps={fullPrecision:!0,noDecimals:!1,fullDecimals:!1,hide_asset:!1};constructor(e){super(e)}shouldComponentUpdate(e){return super.shouldComponentUpdate(e)||!l.A.are_equal_shallow(e.pulsate,this.props.pulsate)||e.toAsset!==this.props.toAsset||e.fromAsset!==this.props.fromAsset||e.amount!==this.props.amount}render(){let{amount:e,toAsset:t,fromAsset:a,fullPrecision:i,coreAsset:n,...o}=this.props,l=t.get("id"),d=t.get("symbol"),c=O(e,t,a,i,n);return c||0===c?s.createElement(r.A,b({noPrefix:!0,amount:c,asset:l,decimalOffset:-1!==d.indexOf("BTC")?4:this.props.fullDecimals?0:this.props.noDecimals?t.get("precision"):t.get("precision")-2},o)):s.createElement(h.Tooltip,{placement:"bottom",title:u().translate("tooltip.no_price")},s.createElement("div",{className:"tooltip inline-block",style:{fontSize:"0.9rem"}},s.createElement(_(),{content:"account.no_price"})))}}B=(0,o.A)(B,{propNames:["toAsset","fromAsset","coreAsset"],defaultProps:{toAsset:"1.3.0",coreAsset:"1.3.0"}});class C extends s.Component{render(){let{refCallback:e,...t}=this.props;return s.createElement(B,b({},t,{ref:e}))}}C=(0,d.N)(C,{listenTo:()=>[c.A],getProps:()=>({allMarketStats:c.A.getState().allMarketStats})});const x=function(e){const t=e.getIn(["balance","amount"]);return t||0===t?{asset_id:e.getIn(["balance","asset_id"]),amount:Number(e.getIn(["balance","amount"]))}:{asset_id:e.get("asset_type"),amount:Number(e.get("balance"))}};class D extends s.Component{static propTypes={balance:i.A.ChainObject.isRequired,satoshis:A().number};static defaultProps={satoshis:null};render(){const{balance:e,...t}=this.props,a=x(e);let r=a.amount;this.props.satoshis&&(r=this.props.satoshis);let i=a.asset_id;return isNaN(r)?s.createElement("span",null,"--"):s.createElement(C,b({amount:r,fromAsset:i,noDecimals:!0,fullPrecision:!this.props.satoshis&&this.props.fullPrecision},t))}}D=(0,n.A)(D,{keep_updating:!0})},41643:(e,t,a)=>{a.d(t,{Ay:()=>g,EA:()=>u,Vt:()=>p,g_:()=>_});var s=a(49074),r=a(2999),i=a(95093),n=a.n(i),o=a(24609),l=a(46863),d=a(62716),c=a(76123),f=a.n(c);const _=1e6,p=[43200,86400,259200,604800,2592e3,7776e3,31536e3,63072e3,15768e4],u=(e,t)=>("zh"===t&&(t="zh_CN"),f()(1e3*parseInt(e),{language:t,delimiter:" ",units:["d","h","m"]})),g=s.A.createActions(class{create({owner_account:e,asset_type:t,balance:a,fee_rate:s,max_duration_seconds:i,min_deal_amount:d,auto_disable_time:c,acceptable_collateral:f,acceptable_borrowers:_=[],enabled:p=!0,fee_asset:u="1.3.0"}){u instanceof o.Vd?u=u.asset_id:"string"!=typeof u&&(u=u.get("id")),"string"!=typeof t&&(t=t.get("id")),c instanceof n()&&(c=c.toDate());const g=r.A.new_transaction();return g.add_type_operation("credit_offer_create",{fee:{amount:0,asset_id:u},owner_account:e,asset_type:t,balance:a,fee_rate:s,max_duration_seconds:i,min_deal_amount:d,enabled:p,auto_disable_time:c,acceptable_collateral:f,acceptable_borrowers:_}),e=>l.A.process_transaction(g,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions create -----\x3e",t),e({transaction:null})}))}update({owner_account:e,offer_id:t,delta_amount:a,fee_rate:s,max_duration_seconds:i,min_deal_amount:d,enabled:c=!0,auto_disable_time:f,acceptable_collateral:_,acceptable_borrowers:p=[],fee_asset:u="1.3.0"}){u instanceof o.Vd?u=u.asset_id:"string"!=typeof u&&(u=u.get("id")),f instanceof n()&&(f=f.toDate());const g=r.A.new_transaction();return g.add_type_operation("credit_offer_update",{fee:{amount:0,asset_id:u},owner_account:e,offer_id:t,delta_amount:a,fee_rate:s,max_duration_seconds:i,min_deal_amount:d,enabled:c,auto_disable_time:f,acceptable_collateral:_,acceptable_borrowers:p}),e=>l.A.process_transaction(g,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions update -----\x3e",t),e({transaction:null})}))}disabled({owner_account:e,offer_id:t,enabled:a=!1,fee_asset:s="1.3.0"}){"string"!=typeof e&&(e=e.get("id"));const i=r.A.new_transaction();return i.add_type_operation("credit_offer_update",{fee:{amount:0,asset_id:s},owner_account:e,offer_id:t,enabled:a}),e=>l.A.process_transaction(i,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions disabled -----\x3e",t),e({transaction:null})}))}delete({owner_account:e,offer_id:t,fee_asset:a="1.3.0"}){"string"!=typeof e&&(e=e.get("id")),a instanceof o.Vd?a=a.asset_id:"string"!=typeof a&&(a=a.get("id"));const s=r.A.new_transaction();return s.add_type_operation("credit_offer_delete",{fee:{amount:0,asset_id:a},owner_account:e,offer_id:t}),e=>l.A.process_transaction(s,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions delete -----\x3e",t),e({transaction:null})}))}accept({borrower:e,offer_id:t,borrow_amount:a,collateral:s,max_fee_rate:i,min_duration_seconds:n,fee_asset:d="1.3.0"}){"string"!=typeof e&&(e=e.get("id")),d instanceof o.Vd?d=d.asset_id:"string"!=typeof d&&(d=d.get("id"));const c=r.A.new_transaction();return c.add_type_operation("credit_offer_accept",{fee:{amount:0,asset_id:d},borrower:e,offer_id:t,borrow_amount:a,collateral:s,max_fee_rate:i,min_duration_seconds:n}),e=>l.A.process_transaction(c,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions delete -----\x3e",t),e({transaction:null})}))}repay({account:e,deal_id:t,repay_amount:a,credit_fee:s,fee_asset:i="1.3.0"}){"string"!=typeof e&&(e=e.get("id")),i instanceof o.Vd?i=i.asset_id:"string"!=typeof i&&(i=i.get("id"));const n=r.A.new_transaction();return n.add_type_operation("credit_deal_repay",{fee:{amount:0,asset_id:i},account:e,deal_id:t,repay_amount:a.toObject(),credit_fee:s.toObject()}),e=>l.A.process_transaction(n,null,!0).then((t=>{e({transaction:t})})).catch((t=>{console.log("CreditOfferActions create -----\x3e",t),e({transaction:null})}))}getCreditOffersByOwner({name_or_id:e,limit:t=100,start_id:a=null,flag:s=!1}){let r=[e,t,a];return i=>{d.Apis.instance().db_api().exec("get_credit_offers_by_owner",r).then((r=>{r&&r.length==t?i({list:r,end:!1!==s&&"first"!==s,flag:s,pars:{name_or_id:e,limit:t,start_id:a}}):i({list:r,end:!0,flag:s})})).catch((e=>{console.error(e),i({list:[],end:!0,flag:s})}))}}getCreditDealsByBorrower({name_or_id:e,limit:t=100,start_id:a=null,flag:s=!1}){let r=[e,t,a];return i=>{d.Apis.instance().db_api().exec("get_credit_deals_by_borrower",r).then((r=>{r&&r.length==t?i({list:r,end:!1!==s&&"first"!==s,flag:s,pars:{name_or_id:e,limit:t,start_id:a}}):i({list:r,end:!0,flag:s,pars:{name_or_id:e,limit:t,start_id:a}})})).catch((e=>{console.error(e),i({list:[],end:!0,flag:s})}))}}getCreditDealsByOfferOwner({name_or_id:e,limit:t=100,start_id:a=null,flag:s=!1}){let r=[e,t,a];return i=>{d.Apis.instance().db_api().exec("get_credit_deals_by_offer_owner",r).then((r=>{r&&r.length==t?i({list:r,end:!1!==s&&"first"!==s,flag:s,pars:{name_or_id:e,limit:t,start_id:a}}):i({list:r,end:!0,flag:s})})).catch((e=>{console.error(e),i({list:[],end:!0,flag:s})}))}}getAll({limit:e=100,start_id:t=null,flag:a=!1}){let s=[e,t];return r=>{d.Apis.instance().db_api().exec("list_credit_offers",s).then((s=>{s&&s.length==e?r({list:s,end:!1!==a&&"first"!==a,flag:a,pars:{limit:e,start_id:t}}):r({list:s,end:!0,flag:a})})).catch((e=>{console.error(e),r({list:[],end:!0,flag:a})}))}}})},96218:(e,t,a)=>{a.d(t,{A:()=>i});var s=a(49074),r=a(41643);const i=s.A.createStore(class{constructor(){this.allList=[],this.listByOwner=[],this.dealsByBorrower=[],this.dealsByOfferOwner=[],this.bindListeners({onGetCreditOffersByOwner:r.Ay.getCreditOffersByOwner,onGetCreditDealsByBorrower:r.Ay.getCreditDealsByBorrower,onGetCreditDealsByOfferOwner:r.Ay.getCreditDealsByOfferOwner,onGetAll:r.Ay.getAll,onCreate:r.Ay.create,onDelete:r.Ay.delete,onUpdate:r.Ay.update,onDisabled:r.Ay.disabled,onAccept:r.Ay.accept,onRepay:r.Ay.repay})}onCreate({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operation_results[0][1],a=e[0].trx.operations[0][1].owner_account;r.Ay.getCreditOffersByOwner({name_or_id:a,limit:1,start_id:t,flag:"create"})}}onDisabled({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operations[0][1].offer_id,a=e[0].trx.operations[0][1].owner_account;r.Ay.getCreditOffersByOwner({name_or_id:a,limit:1,start_id:t,flag:"update"})}}onUpdate({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operations[0][1];r.Ay.getCreditOffersByOwner({name_or_id:t.owner_account,limit:1,start_id:t.offer_id,flag:"update"})}}onDelete({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operations[0][1].offer_id;if(t){let e=this.listByOwner.findIndex((e=>e.id==t));e>-1&&this.listByOwner.splice(e,1)}}}onAccept({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operations[0][1].offer_id;r.Ay.getAll({limit:1,start_id:t,flag:"update"})}}onRepay({transaction:e}){if(e&&e.length>0){let t=e[0].trx.operations[0][1].deal_id,a=e[0].trx.operations[0][1].account;r.Ay.getCreditDealsByBorrower({name_or_id:a,limit:1,start_id:t,flag:"update"})}}onGetCreditOffersByOwner(e){if(e.list.length>0){switch(e.flag){case"first":this.listByOwner=e.list;break;case"update":let t=this.listByOwner.findIndex((t=>t.id==e.list[0].id));t>-1&&this.listByOwner.splice(t,1,JSON.parse(JSON.stringify(e.list[0])));break;default:this.listByOwner=this.listByOwner.concat(e.list)}if(!1===e.end){let t=e.list[e.list.length-1].id.split(".");r.Ay.getCreditOffersByOwner({name_or_id:e.pars.name_or_id,limit:e.pars.limit,start_id:`${t[0]}.${t[1]}.${parseInt(t[2])+1}`})}}}onGetCreditDealsByBorrower(e){if(e.list.length>0){switch(e.flag){case"first":this.dealsByBorrower=e.list;break;case"update":let t=this.dealsByBorrower.findIndex((t=>t.id==e.list[0].id));t>-1&&this.dealsByBorrower.splice(t,1,JSON.parse(JSON.stringify(e.list[0])));break;default:this.dealsByBorrower=this.dealsByBorrower.concat(e.list)}if(!1===e.end){let t=e.list[e.list.length-1].id.split(".");r.Ay.getCreditDealsByBorrower({name_or_id:e.pars.name_or_id,limit:e.pars.limit,start_id:`${t[0]}.${t[1]}.${parseInt(t[2])+1}`})}}else if("update"===e.flag){let t=this.dealsByBorrower.findIndex((t=>t.id==e.pars.start_id));t>-1&&this.dealsByBorrower.splice(t,1)}}onGetCreditDealsByOfferOwner(e){if(e.list.length>0){switch(e.flag){case"first":this.dealsByOfferOwner=e.list;break;case"update":let t=this.dealsByOfferOwner.findIndex((t=>t.id==e.list[0].id));t>-1&&this.dealsByOfferOwner.splice(t,1,JSON.parse(JSON.stringify(e.list[0])));break;default:this.dealsByOfferOwner=this.dealsByOfferOwner.concat(e.list)}if(!1===e.end){let t=e.list[e.list.length-1].id.split(".");r.Ay.getCreditDealsByOfferOwner({name_or_id:e.pars.name_or_id,limit:e.pars.limit,start_id:`${t[0]}.${t[1]}.${parseInt(t[2])+1}`})}}}onGetAll(e){if(e.list.length>0){switch(e.flag){case"first":this.allList=e.list.filter((e=>e.enabled));break;case"update":let t=this.allList.findIndex((t=>t.id==e.list[0].id));t>-1&&(e.list[0].enabled?this.allList.splice(t,1,e.list[0]):this.allList.splice(t,1));break;default:this.allList=this.allList.concat(e.list.filter((e=>e.enabled)))}if(!1===e.end){let t=e.list[e.list.length-1].id.split(".");r.Ay.getAll({limit:e.pars.limit,start_id:`${t[0]}.${t[1]}.${parseInt(t[2])+1}`})}}}},"CreditOfferStore")}}]);