Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
fix(path-set): do not return undefined values in toJSON function (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadejgolobic authored Jan 28, 2021
1 parent 8b96de7 commit fd601fd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/types/path-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit fd601fd

Please sign in to comment.