1- import {
2- IDataWarehouse_ABI ,
3- IVotingMachineWithProofs_ABI ,
4- IVotingPortal_ABI ,
5- } from '@bgd-labs/aave-address-book/abis' ;
61import type { Command } from '@commander-js/extra-typings' ;
72import { confirm , input , select } from '@inquirer/prompts' ;
83import { type Hex , encodeAbiParameters , encodeFunctionData , getContract } from 'viem' ;
@@ -20,6 +15,68 @@ const localCacheAdapter = customStorageProvider(fileSystemStorageAdapter);
2015import { refreshCache } from '@bgd-labs/aave-v3-governance-cache/refreshCache' ;
2116import { ChainList } from '@bgd-labs/toolbox' ;
2217
18+ const VOTING_PORTAL_ABI = [
19+ {
20+ type : 'function' ,
21+ name : 'VOTING_MACHINE' ,
22+ stateMutability : 'view' ,
23+ inputs : [ ] ,
24+ outputs : [ { name : '' , type : 'address' , internalType : 'address' } ] ,
25+ } ,
26+ {
27+ type : 'function' ,
28+ name : 'VOTING_MACHINE_CHAIN_ID' ,
29+ stateMutability : 'view' ,
30+ inputs : [ ] ,
31+ outputs : [ { name : '' , type : 'uint256' , internalType : 'uint256' } ] ,
32+ } ,
33+ ] as const ;
34+
35+ const VOTING_MACHINE_WITH_PROOFS_ABI = [
36+ {
37+ type : 'function' ,
38+ name : 'DATA_WAREHOUSE' ,
39+ stateMutability : 'view' ,
40+ inputs : [ ] ,
41+ outputs : [ { name : '' , type : 'address' , internalType : 'address' } ] ,
42+ } ,
43+ {
44+ type : 'function' ,
45+ name : 'submitVote' ,
46+ stateMutability : 'nonpayable' ,
47+ inputs : [
48+ { name : 'proposalId' , type : 'uint256' , internalType : 'uint256' } ,
49+ { name : 'support' , type : 'bool' , internalType : 'bool' } ,
50+ {
51+ name : 'votingBalanceProofs' ,
52+ type : 'tuple[]' ,
53+ internalType : 'struct VotingBalanceProof[]' ,
54+ components : [
55+ { name : 'underlyingAsset' , type : 'address' , internalType : 'address' } ,
56+ { name : 'slot' , type : 'uint128' , internalType : 'uint128' } ,
57+ { name : 'proof' , type : 'bytes' , internalType : 'bytes' } ,
58+ ] ,
59+ } ,
60+ ] ,
61+ outputs : [ ] ,
62+ } ,
63+ ] as const ;
64+
65+ const DATA_WAREHOUSE_ABI = [
66+ {
67+ type : 'function' ,
68+ name : 'processStorageRoot' ,
69+ stateMutability : 'nonpayable' ,
70+ inputs : [
71+ { name : 'account' , type : 'address' , internalType : 'address' } ,
72+ { name : 'blockHash' , type : 'bytes32' , internalType : 'bytes32' } ,
73+ { name : 'blockHeaderRLP' , type : 'bytes' , internalType : 'bytes' } ,
74+ { name : 'accountStateProofRLP' , type : 'bytes' , internalType : 'bytes' } ,
75+ ] ,
76+ outputs : [ ] ,
77+ } ,
78+ ] as const ;
79+
2380enum DialogOptions {
2481 DETAILS = 0 ,
2582 IPFS_TEXT = 1 ,
@@ -161,7 +218,7 @@ export function addCommand(program: Command) {
161218 } ) ;
162219 const portal = getContract ( {
163220 address : cache . proposal . votingPortal ,
164- abi : IVotingPortal_ABI ,
221+ abi : VOTING_PORTAL_ABI ,
165222 client : DEFAULT_GOVERNANCE_CLIENT ,
166223 } ) ;
167224 const [ machine , chainId ] = await Promise . all ( [
@@ -184,7 +241,7 @@ export function addCommand(program: Command) {
184241 logSuccess (
185242 'encoded calldata' ,
186243 encodeFunctionData ( {
187- abi : IVotingMachineWithProofs_ABI ,
244+ abi : VOTING_MACHINE_WITH_PROOFS_ABI ,
188245 functionName : 'submitVote' ,
189246 args : [ selectedProposalId , support , proofs ] ,
190247 } ) ,
@@ -196,7 +253,7 @@ export function addCommand(program: Command) {
196253 if ( moreInfo === DialogOptions . HOW_TO_REGISTER_STORAGE_ROOTS ) {
197254 const portalContract = getContract ( {
198255 address : cache . proposal . votingPortal ,
199- abi : IVotingPortal_ABI ,
256+ abi : VOTING_PORTAL_ABI ,
200257 client : DEFAULT_GOVERNANCE_CLIENT ,
201258 } ) ;
202259 const [ machine , chainId ] = await Promise . all ( [
@@ -205,7 +262,7 @@ export function addCommand(program: Command) {
205262 ] ) ;
206263 const machineContract = getContract ( {
207264 address : machine ,
208- abi : IVotingMachineWithProofs_ABI ,
265+ abi : VOTING_MACHINE_WITH_PROOFS_ABI ,
209266 client : getClient ( Number ( chainId ) ) ,
210267 } ) ;
211268 const dataWarehouse = await machineContract . read . DATA_WAREHOUSE ( ) ;
@@ -234,7 +291,7 @@ export function addCommand(program: Command) {
234291 logSuccess (
235292 'Encoded callData' ,
236293 encodeFunctionData ( {
237- abi : IDataWarehouse_ABI ,
294+ abi : DATA_WAREHOUSE_ABI ,
238295 functionName : 'processStorageRoot' ,
239296 args : [ root . address , cache . proposal . snapshotBlockHash , blockRPL , accountRPL ] ,
240297 } ) ,
@@ -314,7 +371,7 @@ export function addCommand(program: Command) {
314371
315372 const portal = getContract ( {
316373 address : proposal . votingPortal ,
317- abi : IVotingPortal_ABI ,
374+ abi : VOTING_PORTAL_ABI ,
318375 client : DEFAULT_GOVERNANCE_CLIENT ,
319376 } ) ;
320377 const chainId = await portal . read . VOTING_MACHINE_CHAIN_ID ( ) ;
0 commit comments