@@ -44,7 +44,8 @@ myApp.controller("ConvertCtrl", ['$scope', '$rootScope', 'XrpApi', 'XrpPath', 'S
4444 $scope . found = false ;
4545 $scope . asset = { } ;
4646 $scope . finding = true ;
47- $scope . send_done = false ;
47+ $scope . hash = "" ;
48+ $scope . tx_state = "" ;
4849 $scope . send_error = '' ;
4950 $scope . lastUpdate = 0 ;
5051
@@ -94,13 +95,26 @@ myApp.controller("ConvertCtrl", ['$scope', '$rootScope', 'XrpApi', 'XrpPath', 'S
9495 }
9596
9697 $scope . sending ;
97- $scope . send_done = false ;
9898 $scope . send_error = '' ;
99+
100+ $scope . hash = "" ;
101+ $scope . tx_state = "" ;
102+ $scope . $on ( "txSuccess" , function ( e , tx ) {
103+ console . debug ( 'txSuccess event' , tx ) ;
104+ if ( tx . hash == $scope . hash ) $scope . tx_state = "success" ;
105+ $scope . $apply ( ) ;
106+ } ) ;
107+ $scope . $on ( "txFail" , function ( e , tx ) {
108+ console . debug ( 'txFail event' , tx ) ;
109+ if ( tx . hash == $scope . hash ) $scope . tx_state = "fail" ;
110+ $scope . $apply ( ) ;
111+ } ) ;
99112
100113 $scope . convert_confirmed = function ( ) {
101114 $scope . mode = 'submit' ;
102115 $scope . sending = true ;
103- $scope . send_done = false ;
116+ $scope . hash = "" ;
117+ $scope . tx_state = "" ;
104118 $scope . send_error = '' ;
105119
106120 var alt = $scope . asset . origin ;
@@ -129,9 +143,10 @@ myApp.controller("ConvertCtrl", ['$scope', '$rootScope', 'XrpApi', 'XrpPath', 'S
129143 value : $scope . dst_amount . toString ( )
130144 }
131145 }
132- XrpApi . convert ( srcAmount , dstAmount , alt . paths_computed ) . then ( result => {
146+ XrpApi . convert ( srcAmount , dstAmount , alt . paths_computed ) . then ( hash => {
133147 $scope . sending = false ;
134- $scope . send_done = true ;
148+ $scope . hash = hash ;
149+ $scope . tx_state = "submitted" ;
135150 $rootScope . $apply ( ) ;
136151 } ) . catch ( err => {
137152 $scope . sending = false ;
0 commit comments