Skip to content

Commit

Permalink
feat: update API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
therealemjy committed Aug 9, 2023
1 parent 51a0cb7 commit 8920c0e
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export const parameters = {
rest.post('http://localhost:8545/', (req, res, ctx) => {
return res(ctx.json({}));
}),
rest.get('https://testnetapi.venus.io/api/governance/venus', (req, res, ctx) => {
rest.get('https://testnetapi.venus.io/api/markets/core-pool', (req, res, ctx) => {
return res(ctx.json(GovernanceResponse));
}),
rest.get('https://testnetapi.venus.io/api/proposals', (req, res, ctx) => {
rest.get('https://testnetapi.venus.io/api/governance/proposals', (req, res, ctx) => {
return res(ctx.json(VotersReponse));
}),
rest.get('https://testnetapi.venus.io/api/transactions?page=1', (req, res, ctx) => {
return res(ctx.json(TransactionResponse));
}),
rest.get(
'https://testnetapi.venus.io/api/market_history/graph?asset=0x74469281310195A04840Daf6EdF576F559a3dE80&type=1hr&limit=168',
'https://testnetapi.venus.io/api/markets/history?asset=0x74469281310195A04840Daf6EdF576F559a3dE80&type=1hr&limit=168',
(req, res, ctx) => {
return res(
ctx.json({
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getMainMarkets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface GetMainMarketsOutput {

const getMainMarkets = async (): Promise<GetMainMarketsOutput> => {
const response = await restService<GetMainMarketsResponse>({
endpoint: '/governance/venus',
endpoint: '/markets/core-pool',
method: 'GET',
});
if ('result' in response && response.result === 'error') {
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getMarketHistory/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('api/queries/getMarketHistory', () => {

expect(restService).toHaveBeenCalledTimes(1);
expect(restService).toHaveBeenCalledWith({
endpoint: `/market_history/graph?asset=${TESTNET_VBEP_TOKENS['0x714db6c38a17883964b68a07d56ce331501d9eb6'].address}&version=v2`,
endpoint: `/markets/history?asset=${TESTNET_VBEP_TOKENS['0x714db6c38a17883964b68a07d56ce331501d9eb6'].address}&version=v2`,
method: 'GET',
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getMarketHistory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getMarketHistory = async ({
vToken,
type = '1 month',
}: GetMarketHistoryInput): Promise<GetMarketHistoryOutput> => {
const endpoint = `/market_history/graph?asset=${vToken.address}&version=v2`;
const endpoint = `/markets/history?asset=${vToken.address}&version=v2`;

const response = await restService<GetMarketHistoryResponse>({
endpoint,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getProposals/getProposal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('api/queries/getProposal', () => {
});

expect(restService).toBeCalledWith({
endpoint: '/proposals/1',
endpoint: '/governance/proposals/1',
method: 'GET',
params: {
version: 'v2',
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getProposals/getProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetProposalInput, GetProposalOutput, ProposalApiResponse } from './type

const getProposal = async ({ id }: GetProposalInput): Promise<GetProposalOutput> => {
const response = await restService<ProposalApiResponse>({
endpoint: `/proposals/${id}`,
endpoint: `/governance/proposals/${id}`,
method: 'GET',
params: { version: 'v2' },
});
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getProposals/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('api/queries/getProposals', () => {
});

expect(restService).toBeCalledWith({
endpoint: '/proposals',
endpoint: '/governance/proposals',
method: 'GET',
params: {
limit: 10,
Expand All @@ -41,7 +41,7 @@ describe('api/queries/getProposals', () => {
const response = await getProposals({});

expect(restService).toBeCalledWith({
endpoint: '/proposals',
endpoint: '/governance/proposals',
method: 'GET',
params: {
limit: 5,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getProposals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getProposals = async ({
const offset = page * limit;

const response = await restService<ProposalsApiResponse>({
endpoint: '/proposals',
endpoint: '/governance/proposals',
method: 'GET',
params: { offset, limit, version: 'v2' },
});
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getTransactions/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('api/queries/getTransactions', () => {
expect(transactions).toHaveLength(20);

expect(restService).toBeCalledWith({
endpoint: '/transactions',
endpoint: '/activity/transactions',
method: 'GET',
params: {
page: 2,
Expand All @@ -52,7 +52,7 @@ describe('api/queries/getTransactions', () => {
expect(transactions).toHaveLength(20);

expect(restService).toBeCalledWith({
endpoint: '/transactions',
endpoint: '/activity/transactions',
method: 'GET',
params: {
page: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getTransactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getTransactions = async ({
sort = 'desc',
}: GetTransactionsInput): Promise<GetTransactionsOutput> => {
const response = await restService<GetTransactionsResponse>({
endpoint: '/transactions',
endpoint: '/activity/transactions',
method: 'GET',
params: {
page,
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getVoterAccounts/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('api/queries/getVoterAccounts', () => {
expect(voterAccounts).toHaveLength(7);

expect(restService).toBeCalledWith({
endpoint: '/voters/accounts',
endpoint: '/governance/voters',
method: 'GET',
params: {
limit: 16,
Expand All @@ -44,7 +44,7 @@ describe('api/queries/getVoterAccounts', () => {
// Expected length: 20
// Received length: 7
expect(restService).toBeCalledWith({
endpoint: '/voters/accounts',
endpoint: '/governance/voters',
method: 'GET',
params: {
limit: 16,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getVoterAccounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getVoterAccounts = async ({
page = 0,
}: GetVoterAccountsInput): Promise<GetVoterAccountsOutput> => {
const response = await restService<GetVoterAccountsResponse>({
endpoint: '/voters/accounts',
endpoint: '/governance/voters',
method: 'GET',
params: {
limit: 16,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getVoterDetails/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('api/queries/getVoterDetail', () => {
const response = await getVoterDetail({ address: fakeAddress });

expect(restService).toBeCalledWith({
endpoint: `/voters/accounts/${fakeAddress}`,
endpoint: `/governance/voters/${fakeAddress}/summary`,
method: 'GET',
});

Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getVoterDetails/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getVoterDetails = async ({
address,
}: GetVoterDetailsInput): Promise<GetVoterDetailsOutput> => {
const response = await restService<GetVoterDetailsResponse>({
endpoint: `/voters/accounts/${address}`,
endpoint: `/governance/voters/${address}/summary`,
method: 'GET',
});
const payload = response.data?.data;
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getVoterHistory/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('api/queries/getVoterHistory', () => {
});

expect(restService).toBeCalledWith({
endpoint: `/voters/history/${fakeAddress}`,
endpoint: `/governance/voters/${fakeAddress}/history`,
method: 'GET',
params: {
limit: 6,
Expand All @@ -44,7 +44,7 @@ describe('api/queries/getVoterHistory', () => {
expect(payload.voterHistory).toHaveLength(5);

expect(restService).toBeCalledWith({
endpoint: `/voters/history/${fakeAddress}`,
endpoint: `/governance/voters/${fakeAddress}/history`,
method: 'GET',
params: {
limit: 6,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getVoterHistory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getVoterHistory = async ({
address,
}: GetVoterHistoryInput): Promise<GetVoterHistoryOutput> => {
const response = await restService<GetVoterHistoryResponse>({
endpoint: `/voters/history/${address}`,
endpoint: `/governance/voters/${address}/history`,
method: 'GET',
params: {
limit: 6,
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getVoters/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe('api/queries/getVoters', () => {
}));

const response = await getVoters({
id: 1,
proposalId: 1,
});

expect(restService).toBeCalledWith({
endpoint: '/voters/1',
endpoint: '/governance/proposals/1/voters',
method: 'GET',
params: {
filter: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/clients/api/queries/getVoters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { GetVotersApiResponse, GetVotersInput, GetVotersOutput } from './types';
export * from './types';

const getVoters = async ({
id,
proposalId,
filter,
limit,
offset,
}: GetVotersInput): Promise<GetVotersOutput> => {
const response = await restService<GetVotersApiResponse>({
endpoint: `/voters/${id}`,
endpoint: `/governance/proposals/${proposalId}/voters`,
method: 'GET',
params: {
filter,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/api/queries/getVoters/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VotersDetails } from 'types';

export interface GetVotersInput {
id: string | number;
proposalId: number;
// 0 - "for" votes, 1 – "against" votes, 2 – "abstain" votes
filter?: 0 | 1 | 2;
limit?: number;
Expand Down
10 changes: 5 additions & 5 deletions src/constants/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { ChainId } from 'packages/contracts';
import { Environment } from 'types';

export const API_ENDPOINT_URLS: Record<Environment, string> = {
mainnet: 'https://api.venus.io/api',
preview: 'https://api-preview.venus.io/api',
testnet: 'https://testnetapi.venus.io/api',
storybook: 'https://testnetapi.venus.io/api',
ci: 'https://testnetapi.venus.io/api',
mainnet: 'https://api.venus.io',
preview: 'https://api-preview.venus.io',
testnet: 'https://testnetapi.venus.io',
storybook: 'https://testnetapi.venus.io',
ci: 'https://testnetapi.venus.io',
};

export const RPC_URLS: {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Proposal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ const Proposal = () => {
},
};
const { data: againstVoters = defaultValue } = useGetVoters(
{ id: proposalId || '', filter: 0 },
{ proposalId: parseInt(proposalId, 10), filter: 0 },
{ enabled: !!proposalId },
);
const { data: forVoters = defaultValue } = useGetVoters(
{ id: proposalId || '', filter: 1 },
{ proposalId: parseInt(proposalId, 10), filter: 1 },
{ enabled: !!proposalId },
);
const { data: abstainVoters = defaultValue } = useGetVoters(
{ id: proposalId || '', filter: 2 },
{ proposalId: parseInt(proposalId, 10), filter: 2 },
{ enabled: !!proposalId },
);

Expand Down

0 comments on commit 8920c0e

Please sign in to comment.