Skip to content

Commit 3f6db24

Browse files
committed
convert use submit and verify process
1 parent e2a67bd commit 3f6db24

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

js/controller/convert.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

js/ripple/api.factory.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,10 @@ myApp.factory('XrpApi', ['$rootScope', 'AuthenticationFactory', 'ServerManager',
8989
maxLedgerVersion: maxLedger
9090
};
9191
_remote.getTransaction(hash, options).then(data => {
92-
console.log(data);
93-
console.log('Final Result: ', data.outcome.result);
94-
console.log('Validated in Ledger: ', data.outcome.ledgerVersion);
95-
console.log('Sequence: ', data.sequence);
9692
if (data.outcome.result === 'tesSUCCESS') {
9793
$rootScope.$broadcast('txSuccess', { hash: hash, options: options});
9894
} else {
95+
console.error(data);
9996
$rootScope.$broadcast('txFail', { hash: hash});
10097
}
10198
}).catch(err => {

pages/convert.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@
8585
<i class="fa fa-spinner fa-pulse"></i> {{ 'submitting' | translate}}
8686
</div>
8787
</div>
88-
<div class="row form-group block" ng-show="send_done">
89-
<div class="message">
90-
<h2 class="result-success" translate="submitted">Your transaction has been submitted.</h2>
88+
<div class="row form-group block" ng-show="tx_state">
89+
<div class="message" ng-show="tx_state == 'submitted'">
90+
<h2 translate="submitted">Your transaction has been submitted.</h2>
9191
<p translate="act_will_upd">Your account will update once the transaction has cleared.</p>
9292
</div>
93+
<div class="message" ng-show="tx_state == 'success'">
94+
<h2 class="result-success" translate="cleared">Transaction cleared!</h2>
95+
</div>
9396
<hr>
9497
<div class="actionLink"><a href="" ng-click="init()" translate="back_convert">Do another conversion</a></div>
9598
<div class="actionLink"><a href="" ng-click="goTo('balance')" translate="go_balance">Back to balance</a></div>

0 commit comments

Comments
 (0)