@ -3,6 +3,7 @@ import Config from '../../config';
import { translate } from '../../translate/translate' ;
import {
sendToAddress ,
sendFromAddress ,
sendNativeTx ,
getKMDOPID ,
resolveOpenAliasAddress ,
@ -26,22 +27,47 @@ class SendCoin extends React.Component {
amount : 0 ,
fee : 0.0001 ,
sendSig : false ,
sendApiType : false ,
addressSelectorOpen : false ,
} ;
this . updateInput = this . updateInput . bind ( this ) ;
this . handleSubmit = this . handleSubmit . bind ( this ) ;
this . handleBasiliskSend = this . handleBasiliskSend . bind ( this ) ;
this . openDropMenu = this . openDropMenu . bind ( this ) ;
this . toggleSendSig = this . toggleSendSig . bind ( this ) ;
this . getOAdress = this . getOAdress . bind ( this ) ;
this . toggleSendAPIType = this . toggleSendAPIType . bind ( this ) ;
}
renderAddressAmount ( address ) {
if ( this . props . ActiveCoin . addresses && this . props . ActiveCoin . addresses [ 'public' ] && this . props . ActiveCoin . addresses [ 'public' ] . length ) {
for ( let i = 0 ; i < this . props . ActiveCoin . addresses [ 'public' ] . length ; i ++ ) {
if ( this . props . ActiveCoin . addresses [ 'public' ] [ i ] . address === address ) {
return this . props . ActiveCoin . addresses [ 'public' ] [ i ] . amount ;
}
}
} else {
return 0 ;
}
}
renderAddressByType ( type ) {
if ( this . props . ActiveCoin . addresses && this . props . ActiveCoin . addresses [ type ] && this . props . ActiveCoin . addresses [ type ] . length ) {
return this . props . ActiveCoin . addresses [ type ] . map ( ( address ) =>
< li data - original - index = "2" key = { address . address } className = { address . amount <= 0 ? 'hide' : '' } >
< a tabIndex = "0" data - tokens = "null" onClick = { ( ) => this . updateAddressSelection ( address . address , type , address . amount ) } > < i className = { type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' } > < / i > < s p a n c l a s s N a m e = " t e x t " > [ { a d d r e s s . a m o u n t } { t h i s . p r o p s . A c t i v e C o i n . c o i n } ] { a d d r e s s . a d d r e s s } < / s p a n > < s p a n c l a s s N a m e = " g l y p h i c o n g l y p h i c o n - o k c h e c k - m a r k " > < / s p a n > < / a >
< / l i >
) ;
if ( this . state . sendApiType ) {
const mainAddress = this . props . Dashboard . activeHandle [ this . props . ActiveCoin . coin ] ;
const mainAddressAmount = this . renderAddressAmount ( mainAddress ) ;
return (
< li data - original - index = "2" key = { mainAddress } className = { mainAddressAmount <= 0 ? 'hide' : '' } >
< a tabIndex = "0" data - tokens = "null" onClick = { ( ) => this . updateAddressSelection ( mainAddress , type , mainAddressAmount ) } > < i className = { type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' } > < / i > < s p a n c l a s s N a m e = " t e x t " > [ { m a i n A d d r e s s A m o u n t } { t h i s . p r o p s . A c t i v e C o i n . c o i n } ] { m a i n A d d r e s s } < / s p a n > < s p a n c l a s s N a m e = " g l y p h i c o n g l y p h i c o n - o k c h e c k - m a r k " > < / s p a n > < / a >
< / l i >
) ;
} else {
return this . props . ActiveCoin . addresses [ type ] . map ( ( address ) =>
< li data - original - index = "2" key = { address . address } className = { address . amount <= 0 ? 'hide' : '' } >
< a tabIndex = "0" data - tokens = "null" onClick = { ( ) => this . updateAddressSelection ( address . address , type , address . amount ) } > < i className = { type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' } > < / i > < s p a n c l a s s N a m e = " t e x t " > [ { a d d r e s s . a m o u n t } { t h i s . p r o p s . A c t i v e C o i n . c o i n } ] { a d d r e s s . a d d r e s s } < / s p a n > < s p a n c l a s s N a m e = " g l y p h i c o n g l y p h i c o n - o k c h e c k - m a r k " > < / s p a n > < / a >
< / l i >
) ;
}
} else {
return null ;
}
@ -54,6 +80,16 @@ class SendCoin extends React.Component {
< i className = { this . state . addressType === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' } > < / i > < s p a n c l a s s N a m e = " t e x t " > [ { t h i s . s t a t e . s e n d F r o m A m o u n t } { t h i s . p r o p s . A c t i v e C o i n . c o i n } ] { t h i s . s t a t e . s e n d F r o m } < / s p a n >
< / s p a n >
) ;
} else if ( this . state . sendApiType ) {
const mainAddress = this . props . Dashboard . activeHandle [ this . props . ActiveCoin . coin ] ;
const mainAddressAmount = this . renderAddressAmount ( mainAddress ) ;
console . log ( 'sendApiType' , this . state . sendApiType ) ;
return (
< span >
< i className = { this . state . addressType === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' } > < / i > < s p a n c l a s s N a m e = " t e x t " > [ { m a i n A d d r e s s A m o u n t } { t h i s . p r o p s . A c t i v e C o i n . c o i n } ] { m a i n A d d r e s s } < / s p a n >
< / s p a n >
) ;
} else {
return (
< span > - Select Transparent or Private Address - < / s p a n >
@ -89,7 +125,7 @@ class SendCoin extends React.Component {
this . setState ( Object . assign ( { } , this . state , {
sendFrom : address ,
addressType : type ,
sendFromAmount : amount ,
sendFromAmount : amount ? amount : this . props . ActiveCoin . addresses [ type ] [ address ] . amount ,
addressSelectorOpen : ! this . state . addressSelectorOpen ,
} ) ) ;
}
@ -100,7 +136,12 @@ class SendCoin extends React.Component {
} ) ) ;
if ( step === 2 ) {
Store . dispatch ( sendToAddress ( this . props . ActiveCoin . coin , this . state ) ) ;
if ( ! this . state . sendApiType ) {
handleBasiliskSend ( ) ;
} else {
Store . dispatch ( sendToAddress ( this . props . ActiveCoin . coin , this . state ) ) ;
}
//Store.dispatch(sendFromAddress(this.props.ActiveCoin.coin, this.state));
}
}
@ -110,14 +151,19 @@ class SendCoin extends React.Component {
} ) ) ;
}
toggleSendAPIType ( ) {
this . setState ( Object . assign ( { } , this . state , {
sendApiType : ! this . state . sendApiType ,
} ) ) ;
}
updateInput ( e ) {
this . setState ( {
[ e . target . name ] : e . target . value ,
} ) ;
console . log ( this . state ) ;
}
handleSubmit ( ) {
handleBasiliskSend ( ) {
const utxoSet = this . props . ActiveCoin . cache [ this . props . ActiveCoin . coin ] [ this . state . sendFrom ] . refresh ;
const sendData = {
'coin' : this . props . ActiveCoin . coin ,
@ -130,6 +176,19 @@ class SendCoin extends React.Component {
} ;
iguanaUTXORawTX ( sendData )
. then ( function ( json ) {
console . log ( 'sendData' , sendData ) ;
console . log ( 'iguanaUTXORawTXJSON' , json ) ;
if ( json . result === 'success' && json . completed === true ) {
Store . dispatch ( triggerToaster ( true , translate ( 'TOASTR.SIGNED_TX_GENERATED' ) + '.' , translate ( 'TOASTR.WALLET_NOTIFICATION' ) ) ) ;
if ( sendData . sendsig === 1 ) {
Store . dispatch ( triggerToaster ( true , translate ( 'TOASTR.SENDING_TX' ) + '.' , translate ( 'TOASTR.WALLET_NOTIFICATION' ) ) ) ;
ajax_data_dexrawtx = {
'signedtx' : json . signedtx ,
'coin' : sendData . coin
} ;
}
}
console . log ( json ) ;
} ) ;
//Store.dispatch(sendNativeTx(this.props.ActiveCoin.coin, this.state));
@ -218,7 +277,7 @@ class SendCoin extends React.Component {
}
if ( this . state . sendTo === '' ) {
Store . dispatch ( triggerToaster ( true , 'Couldn\'t find any ' + this . props . ActiveCoin . coin + ' addresses' , 'OpenAlias' , 'error' ) ) ;
Store . dispatch ( triggerToaster ( true , 'Couldn\'t find any ' + this . props . ActiveCoin . coin + ' addresses' , 'OpenAlias' , 'error' ) ) ;
}
} else {
Store . dispatch ( triggerToaster ( true , 'Couldn\'t find any addresses' , 'OpenAlias' , 'error' ) ) ;
@ -231,7 +290,7 @@ class SendCoin extends React.Component {
return (
< div className = "row" >
< div className = "col-lg-6 form-group form-material" >
< label className = "control-label" data - extcoin = "COIN" htmlFor = "kmd_wallet_sendto" > { translate ( 'INDEX.SEND_TO' ) } via Openalias address < / l a b e l >
< label className = "control-label" data - extcoin = "COIN" htmlFor = "kmd_wallet_sendto" > Fetch OpenAlias recipient address < / l a b e l >
< input type = "text" className = "form-control" data - extcoin = "COIN" name = "sendToOA" onChange = { this . updateInput } id = "kmd_wallet_sendto" placeholder = "Enter an alias as address@site.com" autoComplete = "off" required / >
< / d i v >
< div className = "col-lg-6 form-group form-material" >
@ -246,6 +305,23 @@ class SendCoin extends React.Component {
}
}
renderSendApiTypeSelector ( ) {
if ( this . props . ActiveCoin . mode === 'basilisk' ) {
return (
< div className = "row" >
< div className = "col-lg-10 margin-bottom-10" >
< div className = "pull-left margin-right-10" >
< input type = "checkbox" id = "edexcoin_send_api_type" data - plugin = "switchery" data - size = "small" / >
< / d i v >
< label className = "padding-top-3" htmlFor = "edexcoin_send_api_type" onClick = { this . toggleSendAPIType } > Send via sendtoaddress API < / l a b e l >
< / d i v >
< / d i v >
) ;
} else {
return null ;
}
}
render ( ) {
if ( this . props . ActiveCoin && this . props . ActiveCoin . send && this . props . ActiveCoin . mode !== 'native' ) {
return (
@ -283,6 +359,7 @@ class SendCoin extends React.Component {
< / d i v >
< div className = "panel-body container-fluid" >
< form className = "edexcoin-send-form" data - edexcoin = "COIN" method = "post" role = "form" autoComplete = "off" >
{ this . renderSendApiTypeSelector ( ) }
< div className = "row" >
< div className = { this . props . ActiveCoin . mode === 'basilisk' ? 'col-xlg-12 form-group form-material' : 'hide' } >
< label className = "control-label" data - edexcoin = "COIN" htmlFor = "edexcoin_send_from" > { translate ( 'INDEX.SEND_FROM' ) } < / l a b e l >