From 9f9ad852a1ac438ae89e161eceb6a717f410f6c0 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Wed, 17 Oct 2012 23:27:19 -0700 Subject: [PATCH] JS: Add support for config accounts to UInt160.parseJson(). --- js/amount.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/amount.js b/js/amount.js index 652e8438..09991347 100644 --- a/js/amount.js +++ b/js/amount.js @@ -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,9 +400,10 @@ Amount.prototype.parse_json = function(j) { return this; }; -exports.Amount = Amount; -exports.Currency = Currency; -exports.UInt160 = UInt160; +exports.setAccounts = setAccounts; +exports.Amount = Amount; +exports.Currency = Currency; +exports.UInt160 = UInt160; exports.consts = { 'address_xns' : "rrrrrrrrrrrrrrrrrrrrrhoLvTp",