Skip to content

Commit

Permalink
fix: changed to testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Nov 21, 2024
1 parent 8399adc commit 788bda9
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/configs/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const isForIPFS = env.NEXT_PUBLIC_DEPLOY_FOR_IPFS === 'true';
export const isTermsAndConditionsVisible =
env.NEXT_PUBLIC_TERMS_AND_CONDITIONS_VISIBLE === 'true';

export const coreName: CoreNetworkName = 'mainnet';
export const coreName: CoreNetworkName = 'sepolia';
export const WC_PROJECT_ID =
env?.NEXT_PUBLIC_WC_PROJECT_ID || 'e6ed0c48443e54cc875462bbaec6e3a7'; // https://docs.walletconnect.com/2.0/cloud/relay

Expand Down
2 changes: 1 addition & 1 deletion src/requests/fetchActiveProposalsDataForList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function fetchActiveProposalsDataForList({
throw new Error('TODO: API not implemented');
} catch (e) {
console.error(
'Error getting proposals data from API, using RPC fallback',
'Error getting active proposals data for list from API, using RPC fallback',
e,
);
const proposalsData = await Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion src/requests/fetchProposalsDataForList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function fetchProposalsDataForList({
throw new Error('TODO: API not implemented');
} catch (e) {
console.error(
'Error getting proposals data from API, using RPC fallback',
'Error getting proposals data for list from API, using RPC fallback',
e,
);
const proposalsData = (await getProposalsData(input))
Expand Down
2 changes: 1 addition & 1 deletion src/requests/fetchTotalProposalsCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function fetchTotalProposalsCount({
throw new Error('TODO: API not implemented');
} catch (e) {
console.error(
'Error getting initial configs from API, using RPC fallback',
'Error getting proposals count from API, using RPC fallback',
e,
);
return await readContract(input.govCoreClient, {
Expand Down
58 changes: 40 additions & 18 deletions src/requests/utils/getPayloadsData.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
import { Client } from 'viem';

import { appConfig } from '../../configs/appConfig';
import { cachingLayer } from './cachingLayer';
import { getPayloadsDataRPC } from './getPayloadsDataRPC';

export type GetPayloadsData = {
chainId: number;
payloadsIds: number[];
clients?: Record<number, Client>;
};

export async function getPayloadsData({
chainId,
payloadsIds,
clients,
}: GetPayloadsData) {
const payloadsConfig = appConfig.payloadsControllerConfig[chainId];
return await Promise.all(
payloadsIds.map(async (id) => {
const data = await cachingLayer.getPayload({
chainId,
payloadsController: payloadsConfig.contractAddresses[0],
payloadId: id,
});
return {
id: BigInt(id),
chain: BigInt(chainId),
payloadsController: payloadsConfig.contractAddresses[0],
data: {
...data.payload,
},
logs: data.logs,
};
}),
);
// TODO: turn on for mainnets
// try {
// return await Promise.all(
// payloadsIds.map(async (id) => {
// const data = await cachingLayer.getPayload({
// chainId,
// payloadsController: payloadsConfig.contractAddresses[0],
// payloadId: id,
// });
// return {
// id: BigInt(id),
// chain: BigInt(chainId),
// payloadsController: payloadsConfig.contractAddresses[0],
// data: {
// ...data.payload,
// },
// logs: data.logs,
// };
// }),
// );
// } catch (e) {
// console.error(
// 'Error getting payload data for list with cache, using RPC fallback',
// e,
// );
if (clients) {
return await getPayloadsDataRPC({
chainId,
payloadsIds,
clients,
});
} else {
throw new Error('Clients not passed. Try to pass clients and try again');
}
// }
}
70 changes: 54 additions & 16 deletions src/requests/utils/getProposalsData.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,70 @@
import { Client } from 'viem';

import { appConfig } from '../../configs/appConfig';
import { cachingLayer } from './cachingLayer';
import { getProposalMetadata } from './getProposalMetadata';
import { getProposalsDataRPC } from './getProposalsDataRPC';

export type GetProposalsData = {
proposalsCount?: number;
proposalsIds?: number[];
clients?: Record<number, Client>;
};

export async function getProposalsData({
proposalsCount,
proposalsIds,
clients,
}: GetProposalsData) {
const ids = proposalsCount
? [...Array(Number(proposalsCount)).keys()]
: (proposalsIds ?? []);
return await Promise.all(
ids.map(async (id) => {
const data = await cachingLayer.getProposal({
chainId: appConfig.govCoreChainId,
governance: appConfig.govCoreConfig.contractAddress,
proposalId: BigInt(id),
});
return {
...data,
proposal: {
...data.proposal,
id,
},
};
}),
);
// TODO: turn on for mainnets
// try {
// return await Promise.all(
// ids.map(async (id) => {
// const data = await cachingLayer.getProposal({
// chainId: appConfig.govCoreChainId,
// governance: appConfig.govCoreConfig.contractAddress,
// proposalId: BigInt(id),
// });
// return {
// ...data,
// proposal: {
// ...data.proposal,
// id,
// },
// };
// }),
// );
// } catch (e) {
// console.error(
// 'Error getting proposal data for list with cache, using RPC fallback',
// e,
// );
if (clients) {
const proposalsData = await getProposalsDataRPC({
proposalsCount,
proposalsIds,
clients,
});
return await Promise.all(
proposalsData.map(async (proposal) => {
return {
proposal,
// TODO: turn on
// ipfs: {
// title: (await getProposalMetadata({ hash: proposal.ipfsHash }))
// .title,
// },
ipfs: {
title: `Proposal ${proposal.id}`,
},
};
}),
);
} else {
throw new Error('Clients not passed. Try to pass clients and try again');
}
// }
}

1 comment on commit 788bda9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.