Skip to content

Commit

Permalink
Fixes issue where commission change wasn't showing up (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaw2k authored Jan 19, 2024
1 parent 8e93c78 commit d85898f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/api/hooks/useGetDelegationNodeCommissionChange.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useQuery} from "@tanstack/react-query";
import {Types} from "aptos";
import {getValidatorCommission} from "..";
import {getValidatorCommissionChange} from "..";
import {useGlobalState} from "../../global-config/GlobalConfig";
import {ResponseError} from "../client";
import {MoveValue} from "aptos/src/generated";
Expand All @@ -21,8 +21,8 @@ export function useGetDelegationNodeCommissionChange({
const [{aptos_client: client}] = useGlobalState();

const query = useQuery<Types.MoveValue[], ResponseError, number>({
queryKey: ["validatorCommission", client, validatorAddress],
queryFn: () => getValidatorCommission(client, validatorAddress),
queryKey: ["validatorCommissionChange", client, validatorAddress],
queryFn: () => getValidatorCommissionChange(client, validatorAddress),
select: (res: MoveValue[]) => Number(res ? res[0] : 0) / 100, // commission rate: 22.85% is represented as 2285
});

Expand Down
4 changes: 2 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ export async function getValidatorCommission(

export async function getValidatorCommissionChange(
client: AptosClient,
poolAddress: Types.Address,
validatorAddress: Types.Address,
): Promise<Types.MoveValue[]> {
const payload: Types.ViewRequest = {
function:
"0x1::delegation_pool::operator_commission_percentage_next_lockup_cycle",
type_arguments: [],
arguments: [poolAddress],
arguments: [validatorAddress],
};
return withResponseError(client.view(payload));
}
Expand Down

0 comments on commit d85898f

Please sign in to comment.