Skip to content

Commit 85c5acb

Browse files
authored
fix: update-cache scripts that had been failing due to unsupported chain id (#108)
* fix: update-cache script that failed due to sonium * feat: migrate to @bgd-labs/toolbox
1 parent c6ab9ba commit 85c5acb

File tree

5 files changed

+628
-32
lines changed

5 files changed

+628
-32
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"devDependencies": {
4949
"@bgd-labs/aave-address-book": "^4.22.1",
5050
"@bgd-labs/js-utils": "^1.4.7",
51-
"@bgd-labs/rpc-env": "^2.3.3",
51+
"@bgd-labs/toolbox": "^0.0.38",
5252
"@types/lodash": "^4.17.15",
5353
"@types/node": "^22.12.0",
5454
"bignumber.js": "^9.1.2",
@@ -63,7 +63,8 @@
6363
"ethers": "5",
6464
"globals": "^15.14.0",
6565
"lodash": "^4.17.21",
66-
"prettier": "^3.4.2",
66+
"prettier": "^3.5.2",
67+
"prettier-plugin-solidity": "^1.0.0",
6768
"tsup": "^8.3.6",
6869
"tsx": "^4.19.2",
6970
"typescript": "^5.7.3",

src/scripts/createClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Chain, createClient, http } from 'viem';
1+
import { createClient, http } from 'viem';
22

33
export const createViemClient = ({
44
chain,
55
rpcUrl,
66
}: {
7-
chain: Chain;
7+
chain: any;
88
rpcUrl?: string;
99
}) =>
1010
createClient({

src/scripts/parse-cache.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {
88
ChainList,
99
getRPCUrl,
1010
SupportedChainIds,
11-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
12-
// @ts-expect-error
13-
} from '@bgd-labs/rpc-env';
11+
} from '@bgd-labs/toolbox';
1412
import { Address, getContract, Hex, zeroAddress, zeroHash } from 'viem';
1513
import { getBlock, getEnsName } from 'viem/actions';
1614

@@ -87,15 +85,16 @@ export function getVotingMachineAddress(
8785
}
8886

8987
async function getVotingData(initialProposals: InitialProposal[]) {
90-
const votingMachineDataHelpers = {
88+
const votingMachineDataHelpers: Record<number, any> = {
9189
[appConfig.votingMachineChainIds[0]]: getContract({
9290
address:
9391
appConfig.votingMachineConfig[appConfig.votingMachineChainIds[0]]
9492
.dataHelperContractAddress,
9593
abi: IVotingMachineDataHelper_ABI,
9694
client: createViemClient({
97-
chain:
98-
ChainList[appConfig.votingMachineChainIds[0] as SupportedChainIds],
95+
chain: ChainList[
96+
appConfig.votingMachineChainIds[0] as SupportedChainIds
97+
] as any,
9998
rpcUrl: getRPCUrl(
10099
appConfig.votingMachineChainIds[0] as SupportedChainIds,
101100
),
@@ -109,7 +108,7 @@ async function getVotingData(initialProposals: InitialProposal[]) {
109108
address: votingMachineConfig.dataHelperContractAddress,
110109
abi: IVotingMachineDataHelper_ABI,
111110
client: createViemClient({
112-
chain: ChainList[chainId as SupportedChainIds],
111+
chain: ChainList[chainId as SupportedChainIds] as any,
113112
rpcUrl: getRPCUrl(chainId as SupportedChainIds),
114113
}),
115114
});
@@ -447,7 +446,9 @@ async function parseProposalEvents(
447446
const executedTimestamp = (
448447
await getBlock(
449448
createViemClient({
450-
chain: ChainList[appConfig.govCoreChainId as SupportedChainIds],
449+
chain: ChainList[
450+
appConfig.govCoreChainId as SupportedChainIds
451+
] as any,
451452
rpcUrl: getRPCUrl(appConfig.govCoreChainId as SupportedChainIds),
452453
}),
453454
{

src/scripts/update-cache-package.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import {
99
readJSONCache,
1010
writeJSONCache,
1111
} from '@bgd-labs/js-utils';
12-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13-
// @ts-expect-error
14-
import { ChainList, getRPCUrl, SupportedChainIds } from '@bgd-labs/rpc-env';
12+
import { ChainList, getRPCUrl, SupportedChainIds } from '@bgd-labs/toolbox';
1513
import { Address, getContract, Hex } from 'viem';
1614
import { getBlock, getBlockNumber } from 'viem/actions';
1715

@@ -74,7 +72,7 @@ async function updatePayloadsEvents(
7472
bookKeepingCache: BookKeepingCache,
7573
) {
7674
const client = createViemClient({
77-
chain: ChainList[chainId as SupportedChainIds],
75+
chain: ChainList[chainId as SupportedChainIds] as any,
7876
rpcUrl: getRPCUrl(chainId as SupportedChainIds, {
7977
alchemyKey: process.env.ALCHEMY_API_KEY,
8078
}),
@@ -129,7 +127,7 @@ async function updatePayloadsData(
129127
readJSONCache<PayloadsCache>(payloadsPath, controller) || {};
130128

131129
const client = createViemClient({
132-
chain: ChainList[chainId as SupportedChainIds],
130+
chain: ChainList[chainId as SupportedChainIds] as any,
133131
rpcUrl: getRPCUrl(chainId as SupportedChainIds, {
134132
alchemyKey: process.env.ALCHEMY_API_KEY,
135133
}),
@@ -181,7 +179,7 @@ async function updateGovCoreEvents(
181179
const eventsPath = `${Number(govCoreChainId)}/events`;
182180

183181
const client = createViemClient({
184-
chain: ChainList[govCoreChainId as SupportedChainIds],
182+
chain: ChainList[govCoreChainId as SupportedChainIds] as any,
185183
rpcUrl: getRPCUrl(govCoreChainId as SupportedChainIds, {
186184
alchemyKey: process.env.ALCHEMY_API_KEY,
187185
}),
@@ -238,7 +236,7 @@ async function updateVMEvents(
238236
const portalContract = getContract({
239237
abi: IVotingPortal_ABI,
240238
client: createViemClient({
241-
chain: ChainList[govCoreChainId as SupportedChainIds],
239+
chain: ChainList[govCoreChainId as SupportedChainIds] as any,
242240
rpcUrl: getRPCUrl(govCoreChainId as SupportedChainIds),
243241
}),
244242
address: portal,
@@ -255,7 +253,7 @@ async function updateVMEvents(
255253
const path = `${chainId}/events`;
256254
const address = machine;
257255
const client = createViemClient({
258-
chain: ChainList[chainId as SupportedChainIds],
256+
chain: ChainList[chainId as SupportedChainIds] as any,
259257
rpcUrl: getRPCUrl(chainId as SupportedChainIds, {
260258
alchemyKey: process.env.ALCHEMY_API_KEY,
261259
}),
@@ -316,7 +314,7 @@ export async function updateCache({
316314
{};
317315
// initialize contracts
318316
const govCoreClient = createViemClient({
319-
chain: ChainList[govCoreChainId as SupportedChainIds],
317+
chain: ChainList[govCoreChainId as SupportedChainIds] as any,
320318
rpcUrl: getRPCUrl(govCoreChainId as SupportedChainIds, {
321319
alchemyKey: process.env.ALCHEMY_API_KEY,
322320
}),

0 commit comments

Comments
 (0)