From f3ebe412a27b9d5bceefc30adadea77a765a14fd Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 12 Jan 2024 21:00:20 +0100 Subject: [PATCH] fix: patch issues created by viem alignment --- src/commands/governance.ts | 14 +++++++------- src/govv3/checks/targetsVerified.ts | 2 +- src/govv3/proofs.ts | 4 ++-- src/govv3/utils/stateDiffInterpreter.ts | 2 +- src/utils/constants.ts | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/commands/governance.ts b/src/commands/governance.ts index daeea15..50df417 100644 --- a/src/commands/governance.ts +++ b/src/commands/governance.ts @@ -8,7 +8,7 @@ import { Hex, PublicClient, encodeAbiParameters, encodeFunctionData, getContract import { confirm, input, select } from '@inquirer/prompts'; import { getCachedIpfs } from '../ipfs/getCachedProposalMetaData'; import { toAddressLink, toTxLink } from '../govv3/utils/markdownUtils'; -import { getAccountRPL, getBLockRLP } from '../govv3/proofs'; +import { getAccountRPL, getBlockRLP } from '../govv3/proofs'; import { DEFAULT_GOVERNANCE, DEFAULT_GOVERNANCE_CLIENT, FORMAT } from '../utils/constants'; import { getPayloadsController } from '../govv3/payloadsController'; @@ -163,7 +163,7 @@ export function addCommand(program: Command) { const portal = getContract({ address: proposal.votingPortal, abi: IVotingPortal_ABI, - publicClient: DEFAULT_GOVERNANCE_CLIENT, + client: DEFAULT_GOVERNANCE_CLIENT, }); const [machine, chainId] = await Promise.all([ portal.read.VOTING_MACHINE(), @@ -205,7 +205,7 @@ export function addCommand(program: Command) { const portalContract = getContract({ address: proposal.votingPortal, abi: IVotingPortal_ABI, - publicClient: DEFAULT_GOVERNANCE_CLIENT, + client: DEFAULT_GOVERNANCE_CLIENT, }); const [machine, chainId] = await Promise.all([ portalContract.read.VOTING_MACHINE(), @@ -214,7 +214,7 @@ export function addCommand(program: Command) { const machineContract = getContract({ address: machine, abi: IVotingMachineWithProofs_ABI, - publicClient: CHAIN_ID_CLIENT_MAP[Number(chainId) as keyof typeof CHAIN_ID_CLIENT_MAP] as PublicClient, + client: CHAIN_ID_CLIENT_MAP[Number(chainId) as keyof typeof CHAIN_ID_CLIENT_MAP] as PublicClient, }); const dataWarehouse = await machineContract.read.DATA_WAREHOUSE(); const roots = await governance.getStorageRoots(selectedProposalId); @@ -227,7 +227,7 @@ export function addCommand(program: Command) { ) ); const block = await DEFAULT_GOVERNANCE_CLIENT.getBlock({ blockHash: proposal.snapshotBlockHash }); - const blockRPL = getBLockRLP(block); + const blockRPL = getBlockRLP(block); console.log(FORMAT); if (FORMAT === 'raw') { logSuccess('Method', 'processStorageRoot'); @@ -272,7 +272,7 @@ export function addCommand(program: Command) { const roots = await governance.getStorageRoots(proposalId); const block = await DEFAULT_GOVERNANCE_CLIENT.getBlock({ blockHash: proposal.snapshotBlockHash }); - const blockRPL = getBLockRLP(block); + const blockRPL = getBlockRLP(block); const params = roots.map((root) => { const accountRPL = getAccountRPL(root.accountProof); return { @@ -323,7 +323,7 @@ export function addCommand(program: Command) { const portal = getContract({ address: proposal.votingPortal, abi: IVotingPortal_ABI, - publicClient: DEFAULT_GOVERNANCE_CLIENT, + client: DEFAULT_GOVERNANCE_CLIENT, }); const chainId = await portal.read.VOTING_MACHINE_CHAIN_ID(); const proofs = await governance.getVotingProofs(proposalId, voter as Hex, chainId); diff --git a/src/govv3/checks/targetsVerified.ts b/src/govv3/checks/targetsVerified.ts index 1e5b948..2f90791 100644 --- a/src/govv3/checks/targetsVerified.ts +++ b/src/govv3/checks/targetsVerified.ts @@ -37,7 +37,7 @@ async function checkVerificationStatuses( addresses: Hex[], provider: PublicClient ): Promise { - let info = []; // prepare output + let info: string[] = []; // prepare output for (const addr of addresses) { const status = await checkVerificationStatus(sim, addr, provider); if (status === 'eoa') { diff --git a/src/govv3/proofs.ts b/src/govv3/proofs.ts index 32a6cbe..4a60c76 100644 --- a/src/govv3/proofs.ts +++ b/src/govv3/proofs.ts @@ -1,5 +1,5 @@ import { AaveSafetyModule, AaveV3Ethereum, GovernanceV3Ethereum } from '@bgd-labs/aave-address-book'; -import { Block, Hex, PublicClient, fromRlp, toHex, toRlp } from 'viem'; +import { Block, Chain, GetBlockReturnType, Hex, PublicClient, fromRlp, toHex, toRlp } from 'viem'; /** * Slots that represent configuration values relevant for all accounts @@ -33,7 +33,7 @@ export async function getProof(publicClient: PublicClient, address: Hex, slots: } // IMPORTANT valid only for post-Shapella blocks, as it includes `withdrawalsRoot` -export const getBLockRLP = (rawBlock: Block): Hex => { +export const getBlockRLP = (rawBlock: GetBlockReturnType): Hex => { const rawData: Hex[] = [ rawBlock.parentHash, rawBlock.sha3Uncles, diff --git a/src/govv3/utils/stateDiffInterpreter.ts b/src/govv3/utils/stateDiffInterpreter.ts index 3e89b29..62ba336 100644 --- a/src/govv3/utils/stateDiffInterpreter.ts +++ b/src/govv3/utils/stateDiffInterpreter.ts @@ -28,7 +28,7 @@ async function reserveConfigurationChanged( const configurationAfter = getDecodedReserveData(contractAddress, dirty.configuration.data); let symbol = 'unknown'; try { - const erc20Contract = getContract({ publicClient, address: key, abi: ERC20_ABI }); + const erc20Contract = getContract({ client: publicClient, address: key, abi: ERC20_ABI }); symbol = await erc20Contract.read.symbol(); } catch (e) {} // const symbol = diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b1c3dcd..2dc2d29 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,5 +1,6 @@ import { GovernanceV3Ethereum } from '@bgd-labs/aave-address-book'; import { mainnetClient } from '@bgd-labs/js-utils'; +import { PublicClient } from 'viem'; // arbitrary from EOA for proposal executions export const EOA = '0xD73a92Be73EfbFcF3854433A5FcbAbF9c1316073' as const; @@ -12,4 +13,4 @@ export const VERBOSE = process.env.VERBOSE; export const FORMAT = (process.env.FORMAT || 'raw') as 'raw' | 'encoded'; export const DEFAULT_GOVERNANCE = GovernanceV3Ethereum.GOVERNANCE; -export const DEFAULT_GOVERNANCE_CLIENT = mainnetClient; +export const DEFAULT_GOVERNANCE_CLIENT = mainnetClient as PublicClient;