fix(path-set): do not return undefined values in toJSON function (#118)

This commit is contained in:
golobitch
2021-01-28 18:41:23 +01:00
parent b59c5002ed
commit b1f78b7bea

View File

@@ -117,26 +117,20 @@ class Hop extends SerializedType {
const hopParser = new BinaryParser(this.bytes.toString("hex"));
const type = hopParser.readUInt8();
let account,
currency,
issuer: string | undefined = undefined;
const result: HopObject = {};
if (type & TYPE_ACCOUNT) {
account = (AccountID.fromParser(hopParser) as AccountID).toJSON();
result.account = (AccountID.fromParser(hopParser) as AccountID).toJSON();
}
if (type & TYPE_CURRENCY) {
currency = (Currency.fromParser(hopParser) as Currency).toJSON();
result.currency = (Currency.fromParser(hopParser) as Currency).toJSON();
}
if (type & TYPE_ISSUER) {
issuer = (AccountID.fromParser(hopParser) as AccountID).toJSON();
result.issuer = (AccountID.fromParser(hopParser) as AccountID).toJSON();
}
return {
account: account,
issuer: issuer,
currency: currency,
};
return result;
}
/**