JS: Add support for config accounts to UInt160.parseJson().

This commit is contained in:
Arthur Britto
2012-10-17 23:27:19 -07:00
committed by Stefan Thomas
parent 8792871e48
commit 9f9ad852a1

View File

@@ -14,7 +14,7 @@ var UInt160 = function () {
};
UInt160.from_json = function (j) {
return (new UInt160()).parse_json(j);
return (new UInt160()).parse_json(j in accounts ? accounts[j].account : j);
};
UInt160.prototype.clone = function() {
@@ -140,6 +140,12 @@ Currency.prototype.to_human = function() {
return this.value ? this.value : "XNS";
};
var accounts = {};
var setAccounts = function (accounts_new) {
accounts = accounts_new;
};
var Amount = function () {
// Json format:
// integer : XNS
@@ -394,6 +400,7 @@ Amount.prototype.parse_json = function(j) {
return this;
};
exports.setAccounts = setAccounts;
exports.Amount = Amount;
exports.Currency = Currency;
exports.UInt160 = UInt160;