Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pos constant endpoint #4680

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
);