diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index cb05efae..09aea072 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -58,6 +58,10 @@ export interface TokenConfiguration { readonly erc20Tokens?: ReadonlyArray; } +function isDefined(value: X | undefined): value is X { + return value !== undefined; +} + export class CosmWasmConnection implements BlockchainConnection { // we must know prefix and tokens a priori to understand the chain public static async establish( @@ -288,17 +292,17 @@ export class CosmWasmConnection implements BlockchainConnection { signedBy, tags, }: TransactionQuery): Promise | FailedTransaction)[]> { - if ([signedBy, tags].some(component => component !== undefined)) { + if ([signedBy, tags].some(isDefined)) { throw new Error("Transaction query by signedBy or tags not yet supported"); } - if ([maxHeight, minHeight].some(component => component !== undefined)) { + if ([maxHeight, minHeight].some(isDefined)) { throw new Error( "Transaction query by minHeight/maxHeight not yet supported. This is due to missing flexibility of the Gaia REST API, see https://github.com/cosmos/gaia/issues/75", ); } - if ([id, height, sentFromOrTo].filter(component => component !== undefined).length !== 1) { + if ([id, height, sentFromOrTo].filter(isDefined).length !== 1) { throw new Error( "Transaction query by id, height and sentFromOrTo is mutually exclusive. Exactly one must be set.", );