Skip to content

Commit

Permalink
feat(namada): allow querying epoch at height
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Jul 22, 2024
1 parent 86b00e1 commit bd9e4e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/namada/NamadaChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export default class NamadaChain extends CW.Chain {
fetchProposalInfo (id: number|bigint) {
return this.getConnection().fetchProposalInfoImpl(id)
}
fetchEpoch () {
return this.getConnection().fetchEpochImpl()
fetchEpoch (...args: Parameters<NamadaConnection["fetchEpochImpl"]>) {
return this.getConnection().fetchEpochImpl(...args)
}
fetchEpochFirstBlock () {
return this.getConnection().fetchEpochFirstBlockImpl()
Expand Down
4 changes: 2 additions & 2 deletions packages/namada/NamadaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default class NamadaConnection extends CW.Connection {
return fetchProtocolParameters(this)
}

fetchEpochImpl () {
return Epoch.fetchEpoch(this)
fetchEpochImpl (options?: { height?: number|bigint }) {
return Epoch.fetchEpoch(this, options?.height)
}
fetchEpochFirstBlockImpl () {
return Epoch.fetchEpochFirstBlock(this)
Expand Down
9 changes: 7 additions & 2 deletions packages/namada/NamadaEpoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import type { Decode } from './NamadaDecode'
import type NamadaConnection from './NamadaConnection'

export async function fetchEpoch (
connection: Pick<NamadaConnection, 'abciQuery'>
connection: Pick<NamadaConnection, 'abciQuery'>,
height?: number|bigint
) {
return decode(u64, await connection.abciQuery("/shell/epoch"))
if (height !== undefined) {
return decode(u64, await connection.abciQuery(`/shell/epoch_at_height/${height}`))
} else {
return decode(u64, await connection.abciQuery("/shell/epoch"))
}
}

export async function fetchEpochFirstBlock (
Expand Down

0 comments on commit bd9e4e2

Please sign in to comment.