Skip to content

Commit

Permalink
Replace instanceof check with ducktyping approach
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-snake committed Dec 9, 2024
1 parent 40d6b9a commit 35f9ca0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/agent/src/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function isSignedReadStateRequestWithExpiry(
hasProperty(value.body.content, 'request_type') &&
value.body.content.request_type === ReadRequestType.ReadState &&
hasProperty(value.body.content, 'ingress_expiry') &&
value.body.content.ingress_expiry instanceof Expiry
typeof value.body.content.ingress_expiry === 'object' &&
value.body.content.ingress_expiry !== null &&
hasProperty(value.body.content.ingress_expiry, 'toCBOR') &&
typeof value.body.content.ingress_expiry.toCBOR === 'function' &&
hasProperty(value.body.content.ingress_expiry, 'toHash') &&
typeof value.body.content.ingress_expiry.toHash === 'function'
);
}

Expand Down

0 comments on commit 35f9ca0

Please sign in to comment.