Skip to content

Commit

Permalink
fix: patch issues created by viem alignment (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 12, 2024
1 parent 5197889 commit 6e2ee02
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/commands/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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);
Expand All @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/govv3/checks/targetsVerified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function checkVerificationStatuses(
addresses: Hex[],
provider: PublicClient
): Promise<string[]> {
let info = []; // prepare output
let info: string[] = []; // prepare output
for (const addr of addresses) {
const status = await checkVerificationStatus(sim, addr, provider);
if (status === 'eoa') {
Expand Down
4 changes: 2 additions & 2 deletions src/govv3/proofs.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<Chain | undefined, false, 'latest'>): Hex => {
const rawData: Hex[] = [
rawBlock.parentHash,
rawBlock.sha3Uncles,
Expand Down
2 changes: 1 addition & 1 deletion src/govv3/utils/stateDiffInterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

0 comments on commit 6e2ee02

Please sign in to comment.