mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
JS: Add negate() and parse_issuer() to Amount.
This commit is contained in:
committed by
Stefan Thomas
parent
84d0057c91
commit
a033980b66
15
js/amount.js
15
js/amount.js
@@ -258,6 +258,15 @@ Amount.prototype.canonicalize = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Amount.prototype.negate = function () {
|
||||||
|
if (this.is_native) {
|
||||||
|
this.value.negate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.is_negative = !this.is_negative;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Amount.prototype.to_json = function() {
|
Amount.prototype.to_json = function() {
|
||||||
if (this.is_native) {
|
if (this.is_native) {
|
||||||
return this.to_text();
|
return this.to_text();
|
||||||
@@ -400,6 +409,12 @@ Amount.prototype.parse_json = function(j) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Amount.prototype.parse_issuer = function (issuer) {
|
||||||
|
this.issuer.parse_json(issuer);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
exports.setAccounts = setAccounts;
|
exports.setAccounts = setAccounts;
|
||||||
exports.Amount = Amount;
|
exports.Amount = Amount;
|
||||||
exports.Currency = Currency;
|
exports.Currency = Currency;
|
||||||
|
|||||||
Reference in New Issue
Block a user