mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
JS: Fix UInt160 to use config.
This commit is contained in:
committed by
Stefan Thomas
parent
b54bac5add
commit
8c3c33e638
12
js/amount.js
12
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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user