From 5d9fdae5cf3c37415eca8b2b4e1c279bbd256a79 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 19 Oct 2012 21:15:22 -0700 Subject: [PATCH] JS: Fix UInt160 to use config. --- js/amount.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/amount.js b/js/amount.js index faac4e3de5..36d57889b5 100644 --- a/js/amount.js +++ b/js/amount.js @@ -19,10 +19,14 @@ var UInt160 = function () { this.value = NaN; }; +UInt160.json_rewrite = function (j) { + return UInt160.from_json(j).to_json(); +}; + // Return a new UInt160 from j. UInt160.from_json = function (j) { return 'string' === typeof j - ? (new UInt160()).parse_json(j in accounts ? accounts[j].account : j) + ? (new UInt160()).parse_json(j) : j.clone(); }; @@ -40,6 +44,8 @@ UInt160.prototype.copyTo = function(d) { // value = NaN on error. UInt160.prototype.parse_json = function (j) { // Canonicalize and validate + if (j in accounts) + j = accounts[j].account; switch (j) { case undefined: @@ -163,6 +169,10 @@ var Amount = function () { this.issuer = new UInt160(); }; +Amount.json_rewrite = function(j) { + return Amount.from_json(j).to_json(); +}; + Amount.from_json = function(j) { return (new Amount()).parse_json(j); };