diff --git a/package.json b/package.json index 20f7236b3..11d713912 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@bgd-labs/aave-address-book": "^2.19.0", - "@bgd-labs/js-utils": "1.1.1", + "@bgd-labs/js-utils": "1.3.0", "@size-limit/preset-small-lib": "^11.0.2", "@types/lodash": "^4.14.202", "@types/node": "^20.11.16", diff --git a/src/scripts/tsconfig.json b/src/scripts/tsconfig.json new file mode 100644 index 000000000..73d90308b --- /dev/null +++ b/src/scripts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "strict": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "NodeNext", + }, +} diff --git a/src/scripts/update-cache-package.ts b/src/scripts/update-cache-package.ts index 7a900bcd9..1e46179cf 100644 --- a/src/scripts/update-cache-package.ts +++ b/src/scripts/update-cache-package.ts @@ -21,12 +21,13 @@ import { ProposalsCache, ProposalState, } from '../'; -import { getGovernanceEvents } from '../utils/viem/events/governance.ts'; +import { getGovernanceEvents } from '../utils/viem/events/governance'; import { getPayloadsControllerEvents, isPayloadFinal, -} from '../utils/viem/events/payloadsController.ts'; -import { getVotingMachineEvents } from '../utils/viem/events/votingMachine.ts'; +} from '../utils/viem/events/payloadsController'; +import { getVotingMachineEvents } from '../utils/viem/events/votingMachine'; +import { getBlock, getBlockNumber } from 'viem/actions'; async function updateIpfsCache(proposalsCache: ProposalsCache) { const ipfsCache: Record = @@ -54,7 +55,7 @@ async function updatePayloadsEvents( const client = CHAIN_ID_CLIENT_MAP[chainId]; const payloadsPath = `${chainId}/payloads`; - const currentBlockOnPayloadsControllerChain = await client.getBlock(); + const currentBlockOnPayloadsControllerChain = await getBlock(client); const eventsPath = `${chainId}/events`; const eventsCache = readJSONCache>>( @@ -149,7 +150,7 @@ async function updateGovCoreEvents( const eventsPath = `${Number(govCoreChainId)}/events`; const client = CHAIN_ID_CLIENT_MAP[Number(govCoreChainId)]; - const currentBlockOnGovernanceChain = await client.getBlockNumber(); + const currentBlockOnGovernanceChain = await getBlockNumber(client); const contract = getContract({ abi: IGovernanceCore_ABI, address: govCoreContractAddress, @@ -215,7 +216,7 @@ async function updateVMEvents( const path = `${chainId}/events`; const address = machine; const client = CHAIN_ID_CLIENT_MAP[chainId]; - const currentBlockOnVotingMachineChain = await client.getBlockNumber(); + const currentBlockOnVotingMachineChain = await getBlockNumber(client); const votesCache = readJSONCache>>( path, @@ -279,7 +280,7 @@ export async function updateCache({ // check proposals count const proposalsCount = await govCore.read.getProposalsCount(); if (proposalsCount === BigInt(0)) { - const currentBlockOnGovernanceChain = await govCoreClient.getBlockNumber(); + const currentBlockOnGovernanceChain = await getBlockNumber(govCoreClient); bookKeepingCache[`${govCoreChainId}/governance`] = currentBlockOnGovernanceChain.toString(); writeJSONCache('bookKeeping', 'lastFetchedBlocks', bookKeepingCache); diff --git a/src/utils/ether-v5/index.ts b/src/utils/ether-v5/index.ts index c8912b80a..e999fd46d 100644 --- a/src/utils/ether-v5/index.ts +++ b/src/utils/ether-v5/index.ts @@ -1 +1 @@ -export * from './proofsHelpers.ts'; +export * from './proofsHelpers'; diff --git a/src/utils/generic/constants.ts b/src/utils/generic/constants.ts index 237af9b4a..4fee81e15 100644 --- a/src/utils/generic/constants.ts +++ b/src/utils/generic/constants.ts @@ -1,4 +1,4 @@ -import { Asset } from './types.ts'; +import { Asset } from './types'; // balance slots by assets name export const baseSlots = { diff --git a/src/utils/generic/genericFunctions.ts b/src/utils/generic/genericFunctions.ts index 3b2d732e0..e7f005b83 100644 --- a/src/utils/generic/genericFunctions.ts +++ b/src/utils/generic/genericFunctions.ts @@ -7,8 +7,8 @@ import { blockLimit, ProposalMetadata, zeroHash, -} from './index.ts'; -import { AssetsBalanceSlots } from './types.ts'; +} from './index'; +import { AssetsBalanceSlots } from './types'; export function baseToCidv0(hash: string) { return bs58.encode(Buffer.from(`1220${hash.slice(2)}`, 'hex')); diff --git a/src/utils/generic/index.ts b/src/utils/generic/index.ts index 941622b03..09c7bb3f1 100644 --- a/src/utils/generic/index.ts +++ b/src/utils/generic/index.ts @@ -1,3 +1,3 @@ -export * from './constants.ts'; -export * from './genericFunctions.ts'; -export * from './types.ts'; +export * from './constants'; +export * from './genericFunctions'; +export * from './types'; diff --git a/src/utils/viem/formatProposal.ts b/src/utils/viem/formatProposal.ts index cea127d95..7b8dd48ef 100644 --- a/src/utils/viem/formatProposal.ts +++ b/src/utils/viem/formatProposal.ts @@ -12,7 +12,7 @@ import { valueToBigNumber, VotingMachineProposalState, } from '../generic'; -import { Proposal, ProposalData as BasicProposal } from './types.ts'; +import { Proposal, ProposalData as BasicProposal } from './types'; export function normalizeVotes(forVotes: string, againstVotes: string) { const forVotesN = normalizeBN(forVotes, 18).toNumber(); diff --git a/src/utils/viem/getGovCoreConfigs.ts b/src/utils/viem/getGovCoreConfigs.ts index 38f561e23..f59f3ccb8 100644 --- a/src/utils/viem/getGovCoreConfigs.ts +++ b/src/utils/viem/getGovCoreConfigs.ts @@ -2,7 +2,7 @@ import { IGovernanceDataHelper_ABI } from '@bgd-labs/aave-address-book'; import { Client, Hex } from 'viem'; import { readContract } from 'viem/actions'; -import { VotingConfig } from './types.ts'; +import { VotingConfig } from './types'; export async function getGovCoreConfigs({ client, diff --git a/src/utils/viem/getProposalData.ts b/src/utils/viem/getProposalData.ts index c19f80368..8b585ef08 100644 --- a/src/utils/viem/getProposalData.ts +++ b/src/utils/viem/getProposalData.ts @@ -7,7 +7,7 @@ import { ProposalStructOutput, VMProposalStructOutput, VotingConfig, -} from './types.ts'; +} from './types'; export function getVotingMachineProposalState(proposal: BasicProposal) { const now = dayjs().unix(); diff --git a/src/utils/viem/getProposalEvents.ts b/src/utils/viem/getProposalEvents.ts index 4ac4166e9..d03fde1d1 100644 --- a/src/utils/viem/getProposalEvents.ts +++ b/src/utils/viem/getProposalEvents.ts @@ -3,7 +3,7 @@ import { Hex, zeroAddress, zeroHash } from 'viem'; import { getContractEvents } from 'viem/actions'; import { getEventsBySteps, normalizeBN } from '../generic'; -import { InitEventWithChainId } from './types.ts'; +import { InitEventWithChainId } from './types'; async function getVoteEvents({ contractAddress, diff --git a/src/utils/viem/index.ts b/src/utils/viem/index.ts index 97de45aa8..2967449f7 100644 --- a/src/utils/viem/index.ts +++ b/src/utils/viem/index.ts @@ -1,9 +1,9 @@ -export * from './appConfig.ts'; -export * from './formatProposal.ts'; -export * from './getBlockNumberByTimestamp.ts'; -export * from './getGovCoreConfigs.ts'; -export * from './getHistoryEvents.ts'; -export * from './getProposalData.ts'; -export * from './getProposalEvents.ts'; -export * from './proofsHelpers.ts'; -export * from './types.ts'; +export * from './appConfig'; +export * from './formatProposal'; +export * from './getBlockNumberByTimestamp'; +export * from './getGovCoreConfigs'; +export * from './getHistoryEvents'; +export * from './getProposalData'; +export * from './getProposalEvents'; +export * from './proofsHelpers'; +export * from './types'; diff --git a/tsconfig.json b/tsconfig.json index 6f186f630..700c73171 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,12 @@ "esModuleInterop": true, "resolveJsonModule": true, "moduleResolution": "node", - "allowImportingTsExtensions": true }, "include": ["src/**/*.ts"], - "exclude": ["node_modules", "cache"] -} \ No newline at end of file + "exclude": [ + "node_modules", + "cache", + "src/update-cache-package.ts", + "src/update-cache.ts", + ], +} diff --git a/tsup.config.ts b/tsup.config.ts index d1ed295d6..101b7384e 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -12,13 +12,6 @@ const config: Options = { ], sourcemap: true, format: ['iife', 'cjs', 'esm'], - dts: { - compilerOptions: { - moduleResolution: 'node', - allowSyntheticDefaultImports: true, - strict: true, - }, - }, // otherwise .env is ordered wrongly // https://github.com/evanw/esbuild/issues/399 splitting: false, diff --git a/yarn.lock b/yarn.lock index ac3a942e4..a2d2a59b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1133,15 +1133,15 @@ resolved "https://registry.yarnpkg.com/@bgd-labs/aave-address-book/-/aave-address-book-2.19.0.tgz#5278bd4c8645b4ee783680c1b9d3df489f571060" integrity sha512-JrZOZqzunJqFe4+/ZpL3vD7ddtGjjlBRCnMeQ68egNBAB2CYXvkXj6pSZLJBWklkoLgh17or1IdAQHTMYtBSsg== -"@bgd-labs/js-utils@1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@bgd-labs/js-utils/-/js-utils-1.1.1.tgz#0e400061169cd38d1dd44b401dc3c05b904cbd76" - integrity sha512-CWzoY+3IWpu/YhDgVYbnZhBEGQ8kGJwAgqZexrIkD9+GJh5raEcOWByV8psWapOwttWO4ppxS/RgmMdJQ5Hhxg== +"@bgd-labs/js-utils@1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@bgd-labs/js-utils/-/js-utils-1.3.0.tgz#0cb7649acf175c5127a5077f4a8168118a8966c2" + integrity sha512-jk3Wmw/qA9T2dTMTDN9B+O3dUxfuZhnlW8OaaJBo+Lb9uqH2irTi3ex9dNoR+JYw8cSw+RQnV7fI2UWLJ8vXOw== dependencies: - "@supercharge/promise-pool" "^3.1.0" + "@supercharge/promise-pool" "^3.1.1" bs58 "^5.0.0" gray-matter "^4.0.3" - tsx "^4.4.0" + tsx "^4.7.1" "@esbuild/aix-ppc64@0.19.11": version "0.19.11" @@ -1962,10 +1962,10 @@ "@size-limit/file" "11.0.2" size-limit "11.0.2" -"@supercharge/promise-pool@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-3.1.0.tgz#308b9f4d4bf1d607695f916d9454a3556cd4c2b4" - integrity sha512-gB3NukbIcYzRtPoE6dx9svQYPodxvnfQlaaQd8N/z87E6WaMfRE7o5HwB+LZ+KeM0nsNAq1n4TmBtfz1VCUR+Q== +"@supercharge/promise-pool@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-3.1.1.tgz#237d4e151b8591e2ff4f0ae388f7d6b4741bacc0" + integrity sha512-TgCm6jVqMPv+OgD5uBNND/CkCwNDdXPQlcprtnXsWSBpTCy0q5CI6vRj+jsUiXE1xeRaKIX4UeaYJqzZBL92sg== "@types/json-schema@^7.0.9": version "7.0.12" @@ -4902,7 +4902,7 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" -tsx@^4.4.0, tsx@^4.7.0: +tsx@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.7.0.tgz#1689cfe7dda495ca1f9a66d4cad79cb57b9f6f4a" integrity sha512-I+t79RYPlEYlHn9a+KzwrvEwhJg35h/1zHsLC2JXvhC2mdynMv6Zxzvhv5EMV6VF5qJlLlkSnMVvdZV3PSIGcg== @@ -4912,6 +4912,16 @@ tsx@^4.4.0, tsx@^4.7.0: optionalDependencies: fsevents "~2.3.3" +tsx@^4.7.1: + version "4.7.1" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.7.1.tgz#27af6cbf4e1cdfcb9b5425b1c61bb7e668eb5e84" + integrity sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g== + dependencies: + esbuild "~0.19.10" + get-tsconfig "^4.7.2" + optionalDependencies: + fsevents "~2.3.3" + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"