Skip to content
This repository was archived by the owner on Oct 8, 2019. It is now read-only.

Commit 6ffdf0c

Browse files
authored
Merge pull request #39 from wownmedia/fix-arkjs-error-handling
Added error handling for arkjs methods
2 parents 1fb0a8f + a7343d3 commit 6ffdf0c

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

index.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,11 @@ vorpal
645645
}, function(result){
646646
if (result.continue) {
647647
if (currentVote) {
648-
var unvoteTransaction = arkjs.vote.createVote(passphrase, ['-'+currentVote.publicKey]);
648+
try {
649+
var unvoteTransaction = arkjs.vote.createVote(passphrase, ['-'+currentVote.publicKey]);
650+
} catch (error) {
651+
return seriesCb('Failed: ' + error);
652+
}
649653
ledgerSignTransaction(seriesCb, unvoteTransaction, account, function(unvoteTransaction) {
650654
if (!unvoteTransaction) {
651655
return seriesCb('Failed to sign unvote transaction with ledger');
@@ -666,7 +670,11 @@ vorpal
666670
return seriesCb('Failed to fetch unconfirmed transaction: ' + body.error);
667671
} else if (body.transaction) {
668672
clearInterval(checkTransactionTimerId);
669-
var transaction = arkjs.vote.createVote(passphrase, ['+'+newDelegate.publicKey]);
673+
try {
674+
var transaction = arkjs.vote.createVote(passphrase, ['+'+newDelegate.publicKey]);
675+
} catch (error) {
676+
return seriesCb('Failed: ' + error);
677+
}
670678
ledgerSignTransaction(seriesCb, transaction, account, function(transaction) {
671679
if (!transaction) {
672680
return seriesCb('Failed to sign vote transaction with ledger');
@@ -679,7 +687,11 @@ vorpal
679687
});
680688
});
681689
} else {
682-
var transaction = arkjs.vote.createVote(passphrase, ['+'+newDelegate.publicKey]);
690+
try {
691+
var transaction = arkjs.vote.createVote(passphrase, ['+'+newDelegate.publicKey]);
692+
} catch (error) {
693+
return seriesCb('Failed: ' + error);
694+
}
683695
ledgerSignTransaction(seriesCb, transaction, account, function(transaction) {
684696
if (!transaction) {
685697
return seriesCb('Failed to sign transaction with ledger');
@@ -762,7 +774,11 @@ vorpal
762774
message: 'Removing last vote for ' + lastDelegate.username,
763775
}, function(result){
764776
if (result.continue) {
765-
var transaction = arkjs.vote.createVote(passphrase, delegates);
777+
try {
778+
var transaction = arkjs.vote.createVote(passphrase, delegates);
779+
} catch (error) {
780+
return seriesCb('Failed: ' + error);
781+
}
766782
ledgerSignTransaction(seriesCb, transaction, account, function(transaction) {
767783
if (!transaction) {
768784
return seriesCb('Failed to sign transaction with ledger');
@@ -872,7 +888,11 @@ vorpal
872888
message: 'Sending ' + arkAmountString + ' ' + network.config.token+' '+(currency?'('+currency+args.amount+') ':'')+'to '+args.address+' now',
873889
}, function(result){
874890
if (result.continue) {
875-
var transaction = arkjs.transaction.createTransaction(args.address, arkamount, null, passphrase);
891+
try {
892+
var transaction = arkjs.transaction.createTransaction(args.address, arkamount, null, passphrase);
893+
} catch (error) {
894+
return seriesCb('Failed: ' + error);
895+
}
876896
ledgerSignTransaction(seriesCb, transaction, account, function(transaction) {
877897
if (!transaction) {
878898
return seriesCb('Failed to sign transaction with ledger');
@@ -936,7 +956,11 @@ vorpal
936956
} else {
937957
return seriesCb('No public key for account');
938958
}
939-
var transaction = arkjs.delegate.createDelegate(passphrase, args.username);
959+
try {
960+
var transaction = arkjs.delegate.createDelegate(passphrase, args.username);
961+
} catch (error) {
962+
return seriesCb('Failed: ' + error);
963+
}
940964
ledgerSignTransaction(seriesCb, transaction, account, function(transaction) {
941965
if (!transaction) {
942966
return seriesCb('Failed to sign transaction with ledger');

0 commit comments

Comments
 (0)