From f5fc5179cd975045c214bb8fda4b2e45a1480c0d Mon Sep 17 00:00:00 2001 From: Adam A Date: Fri, 27 Sep 2024 08:37:32 +0300 Subject: [PATCH] fix(namada): patch up type errors --- packages/namada/NamadaBlock.ts | 2 +- packages/namada/NamadaChain.ts | 2 +- packages/namada/NamadaConnection.ts | 2 +- packages/namada/NamadaDecode.ts | 8 ++++---- packages/namada/NamadaPoS.ts | 7 ++++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/namada/NamadaBlock.ts b/packages/namada/NamadaBlock.ts index 7bcf0b9a69..f5d3a77af0 100644 --- a/packages/namada/NamadaBlock.ts +++ b/packages/namada/NamadaBlock.ts @@ -54,7 +54,7 @@ export async function fetchBlockResultsByHeight ( } const returned: Partial = {} for (const [key, value] of Object.entries(result)) { - returned[Case.camel(key) as keyof BlockResults] = value + returned[Case.camel(key) as keyof BlockResults] = value as any } return returned as BlockResults } diff --git a/packages/namada/NamadaChain.ts b/packages/namada/NamadaChain.ts index 82b53eca58..963d00967c 100644 --- a/packages/namada/NamadaChain.ts +++ b/packages/namada/NamadaChain.ts @@ -4,7 +4,7 @@ import NamadaConnection from './NamadaConnection' import type { Validator } from './NamadaPoS' import { Decode, initDecoder } from './NamadaDecode' import type { NamadaDecoder } from './NamadaDecode' -import type { Epoch } from './Namada' +import type { Epoch } from './NamadaEpoch' export default class NamadaChain extends CW.Chain { decode: NamadaDecoder = Decode as unknown as NamadaDecoder diff --git a/packages/namada/NamadaConnection.ts b/packages/namada/NamadaConnection.ts index 55c0de6b5e..1cce9be440 100644 --- a/packages/namada/NamadaConnection.ts +++ b/packages/namada/NamadaConnection.ts @@ -4,7 +4,7 @@ import * as PoS from './NamadaPoS' import * as PGF from './NamadaPGF' import * as Gov from './NamadaGov' import * as Epoch from './NamadaEpoch' -import type { Chain as Namada, Epoch } from './Namada' +import type { Chain as Namada } from './Namada' import { decode, u256 } from '@hackbg/borshest' export default class NamadaConnection extends CW.Connection { diff --git a/packages/namada/NamadaDecode.ts b/packages/namada/NamadaDecode.ts index b0e6a8e298..5ce293d1d1 100644 --- a/packages/namada/NamadaDecode.ts +++ b/packages/namada/NamadaDecode.ts @@ -1,7 +1,7 @@ import type { Address, Uint128 } from '@hackbg/fadroma' import init, { Decode } from './pkg/fadroma_namada.js' -import type NamadaBlock from './NamadaBlock' -import type { Transaction as NamadaTransaction } from './NamadaBlock' +import type { Block, Transaction } from './NamadaBlock' +import type { } from './NamadaBlock' import type * as PGF from './NamadaPGF' import type * as PoS from './NamadaPoS' import type * as Gov from './NamadaGov' @@ -145,8 +145,8 @@ export interface NamadaDecoder { block (blockResponse: unknown, resultsResponse: unknown): { hash: string, - header: NamadaBlock["header"] - transactions: Array & {id: string}> + header: Block["header"] + transactions: Array & {id: string}> } tx (): { diff --git a/packages/namada/NamadaPoS.ts b/packages/namada/NamadaPoS.ts index 5182807715..dfbceab997 100644 --- a/packages/namada/NamadaPoS.ts +++ b/packages/namada/NamadaPoS.ts @@ -2,7 +2,8 @@ import type { Address } from '@hackbg/fadroma' import { Console, assign, base16, optionallyParallel} from '@hackbg/fadroma' import { Staking } from '@fadroma/cw' import { decode, u8, u64, u256, array, set } from '@hackbg/borshest' -import type { Chain as Namada, Connection as NamadaConnection, Epoch } from './Namada' +import type { Chain as Namada, Connection as NamadaConnection } from './Namada' +import type { Epoch } from './NamadaEpoch' export type Params = Awaited> @@ -377,7 +378,7 @@ const getRequests = ( /** Generates a warning handler for each request. */ const getWarnings = (connection: NamadaConnection, address: Address, epoch?: Epoch) => { const warn = (msg: string) => (_: Error) => { - if (!isNaN(epoch)) msg += ` for epoch ${epoch}` + if (!isNaN(epoch as number)) msg += ` for epoch ${epoch}` connection.log.warn(`${address}:`, msg) return null } @@ -395,7 +396,7 @@ const getAbciQueryPaths = (address: Address, epoch?: Epoch) => { let commissionPath = `/vp/pos/validator/commission/${address}` let statePath = `/vp/pos/validator/state/${address}` let stakePath = `/vp/pos/validator/stake/${address}` - if (!isNaN(epoch)) { + if (!isNaN(epoch as number)) { const epochSuffix = `/${epoch}` commissionPath += epochSuffix statePath += epochSuffix