mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
JS: Improve error handling.
This commit is contained in:
committed by
Stefan Thomas
parent
d7dffc2041
commit
5e083eb32f
@@ -136,8 +136,8 @@ UInt160.json_rewrite = function (j) {
|
|||||||
// Return a new UInt160 from j.
|
// Return a new UInt160 from j.
|
||||||
UInt160.from_json = function (j) {
|
UInt160.from_json = function (j) {
|
||||||
return 'string' === typeof j
|
return 'string' === typeof j
|
||||||
? (new UInt160()).parse_json(j)
|
? (new UInt160()).parse_json(j)
|
||||||
: j.clone();
|
: j.clone();
|
||||||
};
|
};
|
||||||
|
|
||||||
UInt160.prototype.clone = function() {
|
UInt160.prototype.clone = function() {
|
||||||
@@ -238,7 +238,9 @@ Currency.json_rewrite = function(j) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Currency.from_json = function (j) {
|
Currency.from_json = function (j) {
|
||||||
return (new Currency()).parse_json(j);
|
return 'string' === typeof j
|
||||||
|
? (new Currency()).parse_json(j)
|
||||||
|
: j.clone();
|
||||||
};
|
};
|
||||||
|
|
||||||
Currency.prototype.clone = function() {
|
Currency.prototype.clone = function() {
|
||||||
|
|||||||
13
js/remote.js
13
js/remote.js
@@ -914,6 +914,17 @@ Transaction.prototype.submit = function () {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var transaction = this.transaction;
|
var transaction = this.transaction;
|
||||||
|
|
||||||
|
if ('string' !== typeof transaction.Account)
|
||||||
|
{
|
||||||
|
this.emit('error', {
|
||||||
|
'error' : 'invalidAccount',
|
||||||
|
'error_message' : 'Bad account.'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// YYY Might check paths for invalid accounts.
|
||||||
|
|
||||||
if (undefined === transaction.Fee) {
|
if (undefined === transaction.Fee) {
|
||||||
if ('Payment' === transaction.TransactionType
|
if ('Payment' === transaction.TransactionType
|
||||||
&& transaction.Flags & Remote.flags.Payment.CreateAccount) {
|
&& transaction.Flags & Remote.flags.Payment.CreateAccount) {
|
||||||
@@ -989,8 +1000,10 @@ Transaction._path_rewrite = function (path) {
|
|||||||
|
|
||||||
if ('account' in node)
|
if ('account' in node)
|
||||||
node_new.account = UInt160.json_rewrite(node.account);
|
node_new.account = UInt160.json_rewrite(node.account);
|
||||||
|
|
||||||
if ('issuer' in node)
|
if ('issuer' in node)
|
||||||
node_new.issuer = UInt160.json_rewrite(node.issuer);
|
node_new.issuer = UInt160.json_rewrite(node.issuer);
|
||||||
|
|
||||||
if ('currency' in node)
|
if ('currency' in node)
|
||||||
node_new.currency = Currency.json_rewrite(node.currency);
|
node_new.currency = Currency.json_rewrite(node.currency);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user