mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Order objects consistent with 0.2.6 (#96)
Changed object order so 1.0.0 is consistent with 0.2.6.
This commit is contained in:
@@ -160,9 +160,9 @@ class Amount extends SerializedType {
|
||||
Amount.assertIouIsValid(value);
|
||||
|
||||
return {
|
||||
issuer: issuer.toJSON(),
|
||||
currency: currency.toJSON(),
|
||||
value: value.toString(),
|
||||
currency: currency.toJSON(),
|
||||
issuer: issuer.toJSON(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -175,13 +175,13 @@ class Amount extends SerializedType {
|
||||
*/
|
||||
private static assertXrpIsValid(amount: string): void {
|
||||
if (amount.indexOf(".") !== -1) {
|
||||
throw new Error("XRP amounts must be integer");
|
||||
throw new Error(`${amount.toString()} is an illegal amount`);
|
||||
}
|
||||
|
||||
const decimal = new Decimal(amount);
|
||||
if (!decimal.isZero()) {
|
||||
if (decimal.lt(MIN_XRP) || decimal.gt(MAX_DROPS)) {
|
||||
throw new Error("Invalid XRP amount");
|
||||
throw new Error(`${amount.toString()} is an illegal amount`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,20 +116,24 @@ class Hop extends SerializedType {
|
||||
const hopParser = new BinaryParser(this.bytes.toString("hex"));
|
||||
const type = hopParser.readUInt8();
|
||||
|
||||
const result: HopObject = {};
|
||||
let account, currency, issuer: string | undefined = undefined
|
||||
if (type & TYPE_ACCOUNT) {
|
||||
result.account = (AccountID.fromParser(hopParser) as AccountID).toJSON();
|
||||
account = (AccountID.fromParser(hopParser) as AccountID).toJSON();
|
||||
}
|
||||
|
||||
if (type & TYPE_CURRENCY) {
|
||||
result.currency = (Currency.fromParser(hopParser) as Currency).toJSON();
|
||||
currency = (Currency.fromParser(hopParser) as Currency).toJSON();
|
||||
}
|
||||
|
||||
if (type & TYPE_ISSUER) {
|
||||
result.issuer = (AccountID.fromParser(hopParser) as AccountID).toJSON();
|
||||
issuer = (AccountID.fromParser(hopParser) as AccountID).toJSON();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
return {
|
||||
account: account,
|
||||
issuer: issuer,
|
||||
currency: currency,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user