@@ -237,18 +237,32 @@ myApp.controller("TradeCtrl", [ '$scope', '$rootScope', 'XrpApi', 'XrpOrderbook'
237237 $scope . refreshOffer ( ) ;
238238 $scope . refreshBook ( ) ;
239239 } ) ;
240- $scope . $on ( "txSuccess" , function ( e , tx ) {
241- console . debug ( 'txSuccess event' , tx ) ;
242- $scope . refreshOffer ( ) ;
243- $scope . refreshBook ( ) ;
244- } ) ;
245240
246241 $scope . buying = false ;
247- $scope . buy_ok ;
248242 $scope . buy_fail ;
249243 $scope . selling = false ;
250- $scope . sell_ok ;
251244 $scope . sell_fail ;
245+
246+ $scope . buy_hash = "" ;
247+ $scope . buy_state = "" ;
248+ $scope . sell_hash = "" ;
249+ $scope . sell_state = "" ;
250+ $scope . $on ( "txSuccess" , function ( e , tx ) {
251+ console . debug ( 'txSuccess event' , tx ) ;
252+ if ( tx . hash == $scope . buy_hash ) $scope . buy_state = "success" ;
253+ if ( tx . hash == $scope . sell_hash ) $scope . sell_state = "success" ;
254+ $scope . refreshOffer ( ) ;
255+ $scope . refreshBook ( ) ;
256+ $scope . $apply ( ) ;
257+ } ) ;
258+ $scope . $on ( "txFail" , function ( e , tx ) {
259+ console . debug ( 'txFail event' , tx ) ;
260+ if ( tx . hash == $scope . buy_hash ) $scope . buy_state = "fail" ;
261+ if ( tx . hash == $scope . sell_hash ) $scope . sell_state = "fail" ;
262+ $scope . refreshOffer ( ) ;
263+ $scope . refreshBook ( ) ;
264+ $scope . $apply ( ) ;
265+ } ) ;
252266
253267 $scope . buy_price ;
254268 $scope . buy_amount ;
@@ -308,7 +322,8 @@ myApp.controller("TradeCtrl", [ '$scope', '$rootScope', 'XrpApi', 'XrpOrderbook'
308322 $scope . offer = function ( type ) {
309323 $scope [ 'fatfinger' + type ] = false ; // hide the fatfinger warning
310324 $scope [ type + 'ing' ] = true ;
311- $scope [ type + '_ok' ] = false ;
325+ $scope [ type + '_hash' ] = "" ;
326+ $scope [ type + '_state' ] = "" ;
312327 $scope [ type + '_fail' ] = "" ;
313328 var option = {
314329 type : type ,
@@ -324,9 +339,10 @@ myApp.controller("TradeCtrl", [ '$scope', '$rootScope', 'XrpApi', 'XrpOrderbook'
324339 option . amount = $scope . sell_amount ;
325340 option . price = $scope . sell_price ;
326341 }
327- XrpApi . offer ( option ) . then ( result => {
342+ XrpApi . offer ( option ) . then ( hash => {
328343 $scope [ type + 'ing' ] = false ;
329- $scope [ type + '_ok' ] = true ;
344+ $scope [ type + '_hash' ] = hash ;
345+ $scope [ type + '_state' ] = "submitted" ;
330346 $scope [ type + '_amount' ] = "" ;
331347 $scope [ type + '_price' ] = "" ;
332348 $scope [ type + '_volume' ] = "" ;
0 commit comments