From 452f760d4133d1aba15434beaaaa8b3b3e71b457 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 18 Oct 2023 14:29:42 +0200 Subject: [PATCH] feat: gov v3-abis (#268) * feat: gov v3-abis * fix: fix ci --- .github/workflows/cron.yml | 2 +- foundry.toml | 6 + package.json | 6 +- scripts/configs/abis.ts | 22 ++ scripts/generateABIs.ts | 15 +- scripts/generator/abis.ts | 6 +- src/ts/AaveAddressBook.ts | 4 + src/ts/abis/IGovernanceDataHelper.ts | 344 +++++++++++++++++++ src/ts/abis/IMetaDelegateHelper.ts | 66 ++++ src/ts/abis/IPayloadsControllerDataHelper.ts | 200 +++++++++++ src/ts/abis/IVotingMachineDataHelper.ts | 179 ++++++++++ 11 files changed, 844 insertions(+), 6 deletions(-) create mode 100644 src/ts/abis/IGovernanceDataHelper.ts create mode 100644 src/ts/abis/IMetaDelegateHelper.ts create mode 100644 src/ts/abis/IPayloadsControllerDataHelper.ts create mode 100644 src/ts/abis/IVotingMachineDataHelper.ts diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 37a07cb3..db82a50d 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -43,7 +43,7 @@ jobs: run: yarn install --frozen-lockfile - name: Generate library - run: yarn start + run: yarn generate:addresses - name: Create Pull Request uses: peter-evans/create-pull-request@712add83f26c1e359c046a6ca3dd677fb7017626 diff --git a/foundry.toml b/foundry.toml index 1876b208..b52eb713 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,3 +6,9 @@ ffi = false optimizer = true optimizer_runs = 1000000 verbosity = 1 + +[rpc_endpoints] +mainnet = "${RPC_MAINNET}" + +[etherscan] +mainnet={key="${ETHERSCAN_API_KEY_MAINNET}",chainId=1} \ No newline at end of file diff --git a/package.json b/package.json index 38f14cf0..1d73cd33 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "sideEffects": false, "scripts": { "prettier": "prettier --write 'src/**/*.{sol,ts}'", - "generate:abis": "tsx scripts/generateABIs.ts", - "generate:addresses": "tsx scripts/generateAddresses.ts", - "start": "yarn generate:abis && yarn generate:addresses && npm run prettier", + "generate:abis": "tsx scripts/generateABIs.ts && npm run prettier", + "generate:addresses": "tsx scripts/generateAddresses.ts && npm run prettier", + "start": "tsx scripts/generateABIs.ts &&tsx scripts/generateAddresses.ts && npm run prettier", "build": "tsup", "ci:publish": "npm run build && npm publish --access=public" }, diff --git a/scripts/configs/abis.ts b/scripts/configs/abis.ts index e08613eb..9b77739a 100644 --- a/scripts/configs/abis.ts +++ b/scripts/configs/abis.ts @@ -1,3 +1,6 @@ +import {ChainId} from '../generator/chains'; +import {governanceConfigMainnet} from './governance/ethereum'; + export const ABI_INTERFACES = [ 'IAaveGovernanceV2', 'ICollector', @@ -20,3 +23,22 @@ export const ABI_INTERFACES = [ 'IRescuable', 'IOwnable', ]; + +export const DOWNLOAD_ABI_INTERFACES = [ + { + address: governanceConfigMainnet.ADDRESSES.PC_DATA_HELPER, + name: 'IPayloadsControllerDataHelper', + }, + { + address: governanceConfigMainnet.ADDRESSES.GOV_DATA_HELPER, + name: 'IGovernanceDataHelper', + }, + { + address: governanceConfigMainnet.ADDRESSES.META_DELEGATE_HELPER, + name: 'IMetaDelegateHelper', + }, + { + address: governanceConfigMainnet.ADDRESSES.VM_DATA_HELPER, + name: 'IVotingMachineDataHelper', + }, +]; diff --git a/scripts/generateABIs.ts b/scripts/generateABIs.ts index 77136dc0..a3fa8300 100644 --- a/scripts/generateABIs.ts +++ b/scripts/generateABIs.ts @@ -2,7 +2,7 @@ import util from 'node:util'; import {exec} from 'node:child_process'; import {existsSync, mkdirSync, rmSync, writeFileSync} from 'node:fs'; import {prefixWithGeneratedWarning} from './generator/utils'; -import {ABI_INTERFACES} from './configs/abis'; +import {ABI_INTERFACES, DOWNLOAD_ABI_INTERFACES} from './configs/abis'; const awaitableExec = util.promisify(exec); @@ -24,6 +24,19 @@ export async function generateABIs() { ), ); } + for (const INTERFACE of DOWNLOAD_ABI_INTERFACES) { + const {stdout, stderr} = await awaitableExec(`cast interface -j ${INTERFACE.address}`); + if (stderr) { + throw new Error(`Failed to generate abi for ${INTERFACE.name} from ${INTERFACE.address}`); + } + const varName = `${INTERFACE.name}_ABI`; + writeFileSync( + `./src/ts/abis/${INTERFACE.name}.ts`, + prefixWithGeneratedWarning( + `export const ${varName} = ${JSON.stringify(JSON.parse(stdout.trim()), null, 2)} as const;`, + ), + ); + } } generateABIs(); diff --git a/scripts/generator/abis.ts b/scripts/generator/abis.ts index 10b0769c..b45f2076 100644 --- a/scripts/generator/abis.ts +++ b/scripts/generator/abis.ts @@ -1,4 +1,4 @@ -import {ABI_INTERFACES} from '../configs/abis'; +import {ABI_INTERFACES, DOWNLOAD_ABI_INTERFACES} from '../configs/abis'; export function generateABIImports() { const jsExports: string[] = []; @@ -6,6 +6,10 @@ export function generateABIImports() { const varName = `${INTERFACE}_ABI`; jsExports.push(`export {${varName}} from './abis/${INTERFACE}';`); } + for (const INTERFACE of DOWNLOAD_ABI_INTERFACES) { + const varName = `${INTERFACE.name}_ABI`; + jsExports.push(`export {${varName}} from './abis/${INTERFACE.name}';`); + } return { solidity: [], js: jsExports, diff --git a/src/ts/AaveAddressBook.ts b/src/ts/AaveAddressBook.ts index 0b053b18..a49c1824 100644 --- a/src/ts/AaveAddressBook.ts +++ b/src/ts/AaveAddressBook.ts @@ -66,3 +66,7 @@ export {ICrossChainController_ABI} from './abis/ICrossChainController'; export {IWithGuardian_ABI} from './abis/IWithGuardian'; export {IRescuable_ABI} from './abis/IRescuable'; export {IOwnable_ABI} from './abis/IOwnable'; +export {IPayloadsControllerDataHelper_ABI} from './abis/IPayloadsControllerDataHelper'; +export {IGovernanceDataHelper_ABI} from './abis/IGovernanceDataHelper'; +export {IMetaDelegateHelper_ABI} from './abis/IMetaDelegateHelper'; +export {IVotingMachineDataHelper_ABI} from './abis/IVotingMachineDataHelper'; diff --git a/src/ts/abis/IGovernanceDataHelper.ts b/src/ts/abis/IGovernanceDataHelper.ts new file mode 100644 index 00000000..70d0ca25 --- /dev/null +++ b/src/ts/abis/IGovernanceDataHelper.ts @@ -0,0 +1,344 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IGovernanceDataHelper_ABI = [ + { + inputs: [ + { + internalType: 'contract IGovernanceCore', + name: 'govCore', + type: 'address', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl[]', + name: 'accessLevels', + type: 'uint8[]', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getConstants', + outputs: [ + { + internalType: 'struct IGovernanceDataHelper.Constants', + name: '', + type: 'tuple', + components: [ + { + internalType: 'struct IGovernanceDataHelper.VotingConfig[]', + name: 'votingConfigs', + type: 'tuple[]', + components: [ + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'accessLevel', + type: 'uint8', + components: [], + }, + { + internalType: 'struct IGovernanceCore.VotingConfig', + name: 'config', + type: 'tuple', + components: [ + { + internalType: 'uint24', + name: 'coolDownBeforeVotingStart', + type: 'uint24', + components: [], + }, + { + internalType: 'uint24', + name: 'votingDuration', + type: 'uint24', + components: [], + }, + { + internalType: 'uint56', + name: 'yesThreshold', + type: 'uint56', + components: [], + }, + { + internalType: 'uint56', + name: 'yesNoDifferential', + type: 'uint56', + components: [], + }, + { + internalType: 'uint56', + name: 'minPropositionPower', + type: 'uint56', + components: [], + }, + ], + }, + ], + }, + { + internalType: 'uint256', + name: 'precisionDivider', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'cooldownPeriod', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'expirationTime', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'cancellationFee', + type: 'uint256', + components: [], + }, + ], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IGovernanceCore', + name: 'govCore', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'from', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'to', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'pageSize', + type: 'uint256', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getProposalsData', + outputs: [ + { + internalType: 'struct IGovernanceDataHelper.Proposal[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'votingChainId', + type: 'uint256', + components: [], + }, + { + internalType: 'struct IGovernanceCore.Proposal', + name: 'proposalData', + type: 'tuple', + components: [ + { + internalType: 'enum IGovernanceCore.State', + name: 'state', + type: 'uint8', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'accessLevel', + type: 'uint8', + components: [], + }, + { + internalType: 'uint40', + name: 'creationTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint24', + name: 'votingDuration', + type: 'uint24', + components: [], + }, + { + internalType: 'uint40', + name: 'votingActivationTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'queuingTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'cancelTimestamp', + type: 'uint40', + components: [], + }, + { + internalType: 'address', + name: 'creator', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'votingPortal', + type: 'address', + components: [], + }, + { + internalType: 'bytes32', + name: 'snapshotBlockHash', + type: 'bytes32', + components: [], + }, + { + internalType: 'bytes32', + name: 'ipfsHash', + type: 'bytes32', + components: [], + }, + { + internalType: 'uint128', + name: 'forVotes', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'againstVotes', + type: 'uint128', + components: [], + }, + { + internalType: 'uint256', + name: 'cancellationFee', + type: 'uint256', + components: [], + }, + { + internalType: 'struct PayloadsControllerUtils.Payload[]', + name: 'payloads', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'chain', + type: 'uint256', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'accessLevel', + type: 'uint8', + components: [], + }, + { + internalType: 'address', + name: 'payloadsController', + type: 'address', + components: [], + }, + { + internalType: 'uint40', + name: 'payloadId', + type: 'uint40', + components: [], + }, + ], + }, + ], + }, + ], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IGovernanceCore', + name: 'govCore', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'wallet', + type: 'address', + components: [], + }, + { + internalType: 'uint256[]', + name: 'chainIds', + type: 'uint256[]', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getRepresentationData', + outputs: [ + { + internalType: 'struct IGovernanceDataHelper.Representatives[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + components: [], + }, + { + internalType: 'address', + name: 'representative', + type: 'address', + components: [], + }, + ], + }, + { + internalType: 'struct IGovernanceDataHelper.Represented[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + components: [], + }, + { + internalType: 'address[]', + name: 'votersRepresented', + type: 'address[]', + components: [], + }, + ], + }, + ], + }, +] as const; diff --git a/src/ts/abis/IMetaDelegateHelper.ts b/src/ts/abis/IMetaDelegateHelper.ts new file mode 100644 index 00000000..87feb884 --- /dev/null +++ b/src/ts/abis/IMetaDelegateHelper.ts @@ -0,0 +1,66 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IMetaDelegateHelper_ABI = [ + { + inputs: [ + { + internalType: 'struct IMetaDelegateHelper.MetaDelegateParams[]', + name: 'delegateParams', + type: 'tuple[]', + components: [ + { + internalType: 'contract IGovernancePowerDelegationToken', + name: 'underlyingAsset', + type: 'address', + components: [], + }, + { + internalType: 'enum IMetaDelegateHelper.DelegationType', + name: 'delegationType', + type: 'uint8', + components: [], + }, + { + internalType: 'address', + name: 'delegator', + type: 'address', + components: [], + }, + { + internalType: 'address', + name: 'delegatee', + type: 'address', + components: [], + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + components: [], + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + components: [], + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + components: [], + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + components: [], + }, + ], + }, + ], + stateMutability: 'nonpayable', + type: 'function', + name: 'batchMetaDelegate', + outputs: [], + }, +] as const; diff --git a/src/ts/abis/IPayloadsControllerDataHelper.ts b/src/ts/abis/IPayloadsControllerDataHelper.ts new file mode 100644 index 00000000..2d2b3b79 --- /dev/null +++ b/src/ts/abis/IPayloadsControllerDataHelper.ts @@ -0,0 +1,200 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IPayloadsControllerDataHelper_ABI = [ + { + inputs: [ + { + internalType: 'contract IPayloadsController', + name: 'payloadsController', + type: 'address', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl[]', + name: 'accessLevels', + type: 'uint8[]', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getExecutorConfigs', + outputs: [ + { + internalType: 'struct IPayloadsControllerDataHelper.ExecutorConfig[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'accessLevel', + type: 'uint8', + components: [], + }, + { + internalType: 'struct IPayloadsControllerCore.ExecutorConfig', + name: 'config', + type: 'tuple', + components: [ + { + internalType: 'address', + name: 'executor', + type: 'address', + components: [], + }, + { + internalType: 'uint40', + name: 'delay', + type: 'uint40', + components: [], + }, + ], + }, + ], + }, + ], + }, + { + inputs: [ + { + internalType: 'contract IPayloadsController', + name: 'payloadsController', + type: 'address', + components: [], + }, + { + internalType: 'uint40[]', + name: 'payloadsIds', + type: 'uint40[]', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getPayloadsData', + outputs: [ + { + internalType: 'struct IPayloadsControllerDataHelper.Payload[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + components: [], + }, + { + internalType: 'struct IPayloadsControllerCore.Payload', + name: 'data', + type: 'tuple', + components: [ + { + internalType: 'address', + name: 'creator', + type: 'address', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'maximumAccessLevelRequired', + type: 'uint8', + components: [], + }, + { + internalType: 'enum IPayloadsControllerCore.PayloadState', + name: 'state', + type: 'uint8', + components: [], + }, + { + internalType: 'uint40', + name: 'createdAt', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'queuedAt', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'executedAt', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'cancelledAt', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'expirationTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'delay', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'gracePeriod', + type: 'uint40', + components: [], + }, + { + internalType: 'struct IPayloadsControllerCore.ExecutionAction[]', + name: 'actions', + type: 'tuple[]', + components: [ + { + internalType: 'address', + name: 'target', + type: 'address', + components: [], + }, + { + internalType: 'bool', + name: 'withDelegateCall', + type: 'bool', + components: [], + }, + { + internalType: 'enum PayloadsControllerUtils.AccessControl', + name: 'accessLevel', + type: 'uint8', + components: [], + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + components: [], + }, + { + internalType: 'string', + name: 'signature', + type: 'string', + components: [], + }, + { + internalType: 'bytes', + name: 'callData', + type: 'bytes', + components: [], + }, + ], + }, + ], + }, + ], + }, + ], + }, +] as const; diff --git a/src/ts/abis/IVotingMachineDataHelper.ts b/src/ts/abis/IVotingMachineDataHelper.ts new file mode 100644 index 00000000..c4ad4291 --- /dev/null +++ b/src/ts/abis/IVotingMachineDataHelper.ts @@ -0,0 +1,179 @@ +// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR +export const IVotingMachineDataHelper_ABI = [ + { + inputs: [ + { + internalType: 'contract IVotingMachineWithProofs', + name: 'votingMachine', + type: 'address', + components: [], + }, + { + internalType: 'struct IVotingMachineDataHelper.InitialProposal[]', + name: 'initialProposals', + type: 'tuple[]', + components: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + components: [], + }, + { + internalType: 'bytes32', + name: 'snapshotBlockHash', + type: 'bytes32', + components: [], + }, + ], + }, + { + internalType: 'address', + name: 'user', + type: 'address', + components: [], + }, + ], + stateMutability: 'view', + type: 'function', + name: 'getProposalsData', + outputs: [ + { + internalType: 'struct IVotingMachineDataHelper.Proposal[]', + name: '', + type: 'tuple[]', + components: [ + { + internalType: 'struct IVotingMachineWithProofs.ProposalWithoutVotes', + name: 'proposalData', + type: 'tuple', + components: [ + { + internalType: 'uint256', + name: 'id', + type: 'uint256', + components: [], + }, + { + internalType: 'bool', + name: 'sentToGovernance', + type: 'bool', + components: [], + }, + { + internalType: 'uint40', + name: 'startTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'endTime', + type: 'uint40', + components: [], + }, + { + internalType: 'uint40', + name: 'votingClosedAndSentTimestamp', + type: 'uint40', + components: [], + }, + { + internalType: 'uint128', + name: 'forVotes', + type: 'uint128', + components: [], + }, + { + internalType: 'uint128', + name: 'againstVotes', + type: 'uint128', + components: [], + }, + { + internalType: 'uint256', + name: 'creationBlockNumber', + type: 'uint256', + components: [], + }, + { + internalType: 'uint256', + name: 'votingClosedAndSentBlockNumber', + type: 'uint256', + components: [], + }, + ], + }, + { + internalType: 'struct IVotingMachineDataHelper.VotedInfo', + name: 'votedInfo', + type: 'tuple', + components: [ + { + internalType: 'bool', + name: 'support', + type: 'bool', + components: [], + }, + { + internalType: 'uint248', + name: 'votingPower', + type: 'uint248', + components: [], + }, + ], + }, + { + internalType: 'contract IVotingStrategy', + name: 'strategy', + type: 'address', + components: [], + }, + { + internalType: 'contract IDataWarehouse', + name: 'dataWarehouse', + type: 'address', + components: [], + }, + { + internalType: 'address[]', + name: 'votingAssets', + type: 'address[]', + components: [], + }, + { + internalType: 'bool', + name: 'hasRequiredRoots', + type: 'bool', + components: [], + }, + { + internalType: 'struct IVotingMachineWithProofs.ProposalVoteConfiguration', + name: 'voteConfig', + type: 'tuple', + components: [ + { + internalType: 'uint24', + name: 'votingDuration', + type: 'uint24', + components: [], + }, + { + internalType: 'bytes32', + name: 'l1ProposalBlockHash', + type: 'bytes32', + components: [], + }, + ], + }, + { + internalType: 'enum IVotingMachineWithProofs.ProposalState', + name: 'state', + type: 'uint8', + components: [], + }, + ], + }, + ], + }, +] as const;