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:
Nathan Nichols
2020-08-19 13:44:53 -05:00
parent 0be93e7533
commit e9d5ae0d35
3 changed files with 15 additions and 11 deletions

View File

@@ -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`);
}
}
}

View File

@@ -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,
};
}
/**