Skip to content

Commit

Permalink
♻️ Update pos constant endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuGowda committed Dec 21, 2022
1 parent 9463383 commit c193ce1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
17 changes: 11 additions & 6 deletions src/modules/pos/validator/__fixtures__/mockPosConstants.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
export const mockPosConstants = {
data: {
factorSelfVotes: 10,
factorSelfStakes: 10,
maxLengthName: 20,
maxNumberSentVotes: 10,
maxNumberSentStakes: 10,
maxNumberPendingUnlocks: 20,
failSafeMissedBlocks: 50,
failSafeInactiveWindow: 260000,
punishmentWindow: 780000,
roundLength: 103,
bftThreshold: 68,
minWeightStandby: '100000000000',
numberActiveDelegates: 101,
numberStandbyDelegates: 2,
tokenIDDPoS: '0000000000000000',
numberActiveValidators: 101,
numberStandbyValidators: 2,
posTokenID: '0000000000000000',
maxBFTWeightCap: 500,
commissionIncreasePeriod: 260000,
maxCommissionIncreaseRate: 500,
extraCommandFees: {
validatorRegistrationFee: '1000000000'
}
},
meta: {},
};
2 changes: 1 addition & 1 deletion src/modules/pos/validator/components/EditStake/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const EditStake = ({ history, stakeEdited, network, voting, stakesRetrieved }) =
const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();

const { data: tokens } = useTokensBalance({
config: { params: { tokenID: posConstants?.tokenIDDPoS } },
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const token = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const RegisterValidatorForm = ({ nextStep, prevState }) => {

const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();
const { data: tokens } = useTokensBalance({
config: { params: { tokenID: posConstants?.tokenIDDPoS } },
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const token = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SentStakes = ({ history }) => {
const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();

const { data: tokens } = useTokensBalance({
config: { params: { tokenID: posConstants?.tokenIDDPoS } },
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const dposToken = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pos/validator/components/StakingQueue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const StakingQueue = ({ history, processLaunchProtocol }) => {
const { data: posConstants, isLoading: isGettingPosConstants } = usePosConstants();

const { data: tokens } = useTokensBalance({
config: { params: { tokenID: posConstants?.tokenIDDPoS } },
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const token = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/pos/validator/hooks/queries/usePosConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { useCustomQuery } from 'src/modules/common/hooks';

export const usePosConstants = ({ config: customConfig = {}, options } = {}) => {
const config = {
url: `/api/${API_VERSION}/dpos/constants`,
url: `/api/${API_VERSION}/pos/constants`,
method: 'get',
event: 'get.dpos.constants',
event: 'get.pos.constants',
...customConfig,
};

Expand Down
2 changes: 1 addition & 1 deletion src/modules/pos/validator/hooks/useVoteAmountField.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const useVoteAmountField = (initialValue) => {

// Since we know the dposTokenId we need to get the token's object
const { data: tokens, isLoading: isGettingDposToken } = useTokensBalance({
config: { params: { tokenID: posConstants?.tokenIDDPoS } },
config: { params: { tokenID: posConstants?.posTokenID } },
options: { enabled: !isGettingPosConstants },
});
const token = useMemo(() => tokens?.data?.[0] || {}, [tokens]);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pos/validator/mocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ export const generators = rest.get(`*/api/${API_VERSION}/generators`, async (req
return res(ctx.delay(20), ctx.json(response));
});

export const posConstants = rest.get(`*/api/${API_VERSION}/dpos/constants`, async (_, res, ctx) =>
export const posConstants = rest.get(`*/api/${API_VERSION}/pos/constants`, async (_, res, ctx) =>
res(ctx.delay(20), ctx.json(mockPosConstants))
);

0 comments on commit c193ce1

Please sign in to comment.