-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/oct-714-history-deposit-refetch' into 'master'
OCT-714 Locking/unlocking GLM does not show up in history & effective deposit doesnt update See merge request wildland/governance/octant!561
- Loading branch information
Showing
12 changed files
with
205 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useQuery, UseQueryResult } from '@tanstack/react-query'; | ||
import request from 'graphql-request'; | ||
|
||
import { QUERY_KEYS } from 'api/queryKeys'; | ||
import env from 'env'; | ||
import { graphql } from 'gql/gql'; | ||
|
||
type Test = { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
_meta?: | ||
| { | ||
block: { | ||
number: number; | ||
}; | ||
} | ||
| undefined | ||
| null; | ||
}; | ||
|
||
const GET_BLOCK_NUMBER = graphql(` | ||
query GetBlockNumber { | ||
_meta { | ||
block { | ||
number | ||
} | ||
} | ||
} | ||
`); | ||
|
||
export default function useBlockNumber( | ||
isRefetchEnabled = true, | ||
): UseQueryResult<number | null | undefined> { | ||
const { subgraphAddress } = env; | ||
|
||
return useQuery<Test, any, number | undefined, any>( | ||
QUERY_KEYS.blockNumber, | ||
async () => request(subgraphAddress, GET_BLOCK_NUMBER), | ||
{ | ||
refetchInterval: isRefetchEnabled ? 1000 : false, | ||
select: data => data._meta?.block.number, | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import useMetaStore from './store'; | ||
|
||
describe('useMetaStore', () => { | ||
it('initial state should be correct', () => { | ||
expect(useMetaStore.getState().data.blockNumberWithLatestTx).toEqual(null); | ||
}); | ||
|
||
it('should correctly set setBlockNumberWithLatestTx', () => { | ||
const { setBlockNumberWithLatestTx } = useMetaStore.getState(); | ||
|
||
expect(useMetaStore.getState().data.blockNumberWithLatestTx).toEqual(null); | ||
setBlockNumberWithLatestTx(1000); | ||
expect(useMetaStore.getState().data.blockNumberWithLatestTx).toEqual(1000); | ||
setBlockNumberWithLatestTx(1001); | ||
expect(useMetaStore.getState().data.blockNumberWithLatestTx).toEqual(1001); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getStoreWithMeta } from 'store/utils/getStoreWithMeta'; | ||
|
||
import { MetaData, MetaMethods } from './types'; | ||
|
||
export const initialState: MetaData = { | ||
blockNumberWithLatestTx: null, | ||
}; | ||
|
||
export default getStoreWithMeta<MetaData, MetaMethods>({ | ||
getStoreMethods: set => ({ | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
setBlockNumberWithLatestTx: payload => { | ||
set(state => ({ | ||
data: { ...state.data, blockNumberWithLatestTx: payload }, | ||
})); | ||
}, | ||
}), | ||
initialState, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface MetaData { | ||
blockNumberWithLatestTx: number | null; | ||
} | ||
|
||
export interface MetaMethods { | ||
setBlockNumberWithLatestTx: (payload: MetaData['blockNumberWithLatestTx']) => void; | ||
} |