diff --git a/packages/ripple-binary-codec/package.json b/packages/ripple-binary-codec/package.json index 1bdc2e9d..bcda4e71 100644 --- a/packages/ripple-binary-codec/package.json +++ b/packages/ripple-binary-codec/package.json @@ -1,6 +1,6 @@ { "name": "ripple-binary-codec", - "version": "1.0.0-rc2", + "version": "1.0.0-rc3", "description": "XRP Ledger binary codec", "files": [ "dist/*", diff --git a/packages/ripple-binary-codec/src/types/amount.ts b/packages/ripple-binary-codec/src/types/amount.ts index 5176c43c..e3f89f7b 100644 --- a/packages/ripple-binary-codec/src/types/amount.ts +++ b/packages/ripple-binary-codec/src/types/amount.ts @@ -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`); } } } diff --git a/packages/ripple-binary-codec/src/types/path-set.ts b/packages/ripple-binary-codec/src/types/path-set.ts index 969b4ea4..1e9e737f 100644 --- a/packages/ripple-binary-codec/src/types/path-set.ts +++ b/packages/ripple-binary-codec/src/types/path-set.ts @@ -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, + }; } /**