Allow any type of asset fields for the isERC20Asset type guard (#322)

This commit is contained in:
Matthew Russell 2022-04-27 10:35:30 -07:00 committed by GitHub
parent 448e0ec78f
commit 8ebb2ee81c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,8 +7,10 @@ export interface ERC20Asset extends AssetFields {
};
}
type UnknownAssset = Pick<AssetFields, '__typename' | 'source'>;
// Type guard to ensure an asset is an ERC20 token
export const isERC20Asset = (asset: AssetFields): asset is ERC20Asset => {
export const isERC20Asset = (asset: UnknownAssset): asset is ERC20Asset => {
if (asset.source.__typename === 'ERC20') {
return true;
}