Skip to content

Commit

Permalink
fix: update to new version of js-utils (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Feb 28, 2024
1 parent 8fd479d commit 4e1a66a
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions src/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "NodeNext",
},
}
15 changes: 8 additions & 7 deletions src/scripts/update-cache-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ProposalMetadata> =
Expand Down Expand Up @@ -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<Awaited<ReturnType<typeof getPayloadsControllerEvents>>>(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<Awaited<ReturnType<typeof getVotingMachineEvents>>>(
path,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ether-v5/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './proofsHelpers.ts';
export * from './proofsHelpers';
2 changes: 1 addition & 1 deletion src/utils/generic/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asset } from './types.ts';
import { Asset } from './types';

// balance slots by assets name
export const baseSlots = {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/generic/genericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
6 changes: 3 additions & 3 deletions src/utils/generic/index.ts
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion src/utils/viem/formatProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/viem/getGovCoreConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/viem/getProposalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ProposalStructOutput,
VMProposalStructOutput,
VotingConfig,
} from './types.ts';
} from './types';

export function getVotingMachineProposalState(proposal: BasicProposal) {
const now = dayjs().unix();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/viem/getProposalEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions src/utils/viem/index.ts
Original file line number Diff line number Diff line change
@@ -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';
10 changes: 7 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"allowImportingTsExtensions": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "cache"]
}
"exclude": [
"node_modules",
"cache",
"src/update-cache-package.ts",
"src/update-cache.ts",
],
}
7 changes: 0 additions & 7 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 21 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "0.19.11"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand All @@ -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"
Expand Down

0 comments on commit 4e1a66a

Please sign in to comment.