mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
JS: Add is_valid() for UInt160 and Currency.
This commit is contained in:
committed by
Stefan Thomas
parent
85914f38ce
commit
51c0782369
@@ -217,6 +217,10 @@ UInt160.prototype.to_json = function () {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UInt160.prototype.is_valid = function () {
|
||||||
|
return !isNaN(this_value);
|
||||||
|
};
|
||||||
|
|
||||||
// XXX Internal form should be UInt160.
|
// XXX Internal form should be UInt160.
|
||||||
var Currency = function () {
|
var Currency = function () {
|
||||||
// Internal form: 0 = XRP. 3 letter-code.
|
// Internal form: 0 = XRP. 3 letter-code.
|
||||||
@@ -272,6 +276,10 @@ Currency.prototype.parse_json = function(j) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Currency.prototype.is_valid = function () {
|
||||||
|
return !isNaN(this_value);
|
||||||
|
};
|
||||||
|
|
||||||
Currency.prototype.to_json = function () {
|
Currency.prototype.to_json = function () {
|
||||||
return this._value ? this._value : "XRP";
|
return this._value ? this._value : "XRP";
|
||||||
};
|
};
|
||||||
@@ -484,9 +492,9 @@ Amount.prototype.parse_native = function(j) {
|
|||||||
if (m[1])
|
if (m[1])
|
||||||
this._value = this._value.negate();
|
this._value = this._value.negate();
|
||||||
|
|
||||||
this._is_native = true;
|
this._is_native = true;
|
||||||
this._offset = undefined;
|
this._offset = undefined;
|
||||||
this._is_negative = undefined;
|
this._is_negative = undefined;
|
||||||
|
|
||||||
if (this._value.compareTo(exports.consts.bi_xns_max) > 0 || this._value.compareTo(exports.consts.bi_xns_min) < 0)
|
if (this._value.compareTo(exports.consts.bi_xns_max) > 0 || this._value.compareTo(exports.consts.bi_xns_min) < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user