Skip to content

Commit

Permalink
Refactor useService and useStakingAccount hooks, add orderBy and orde…
Browse files Browse the repository at this point in the history
…rDirection parameters
  • Loading branch information
snoopy1412 committed Sep 25, 2024
1 parent 40d4ef9 commit d9efc64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/hooks/useService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ export function useStakingAccount({ enabled = true }: StakingAccountParams) {
const params: StakingAccountQueryParams = {
where: {
account: toLowerCase(address)
}
},
orderBy: 'latestChangeTimestamp',
orderDirection: 'desc'
};
const queryKey = ['stakingAccounts', params];
const result = useQuery({
Expand Down
3 changes: 0 additions & 3 deletions src/service/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ export async function fetchStakingAccount(
params: StakingAccountQueryParams,
chainId: ChainId
): Promise<StakingAccount[] | null> {
console.log('fetchStakingAccount', chainId);

const client = getClient(chainId);
console.log('client', client);
try {
const response = await client.request<{ stakingAccounts: StakingAccount[] }>(
GET_STAKING_ACCOUNT,
Expand Down
8 changes: 7 additions & 1 deletion src/service/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ export interface CollatorSetQueryParams {

export type CollatorSetQueryFunction = (params: CollatorSetQueryParams) => Promise<CollatorSet[]>;

export type StakingAccountOrderByField = 'id' | 'pool' | 'collator' | 'account' | 'assets';
export type StakingAccountOrderByField =
| 'id'
| 'pool'
| 'collator'
| 'account'
| 'assets'
| 'latestChangeTimestamp';
export interface StakingAccount {
account: `0x${string}`;
assets: string;
Expand Down

0 comments on commit d9efc64

Please sign in to comment.