Skip to content

Commit

Permalink
feat: add ui pool data provider abis
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Nov 2, 2023
1 parent f126131 commit 0123110
Show file tree
Hide file tree
Showing 4 changed files with 1,168 additions and 5 deletions.
10 changes: 9 additions & 1 deletion scripts/configs/abis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ChainId} from '../generator/chains';
import {governanceConfigMainnet} from './governance/ethereum';
import {mainnetProtoV2Pool, mainnetProtoV3Pool} from './pools/ethereum';

export const ABI_INTERFACES = [
'IAaveGovernanceV2',
Expand Down Expand Up @@ -41,4 +41,12 @@ export const DOWNLOAD_ABI_INTERFACES = [
address: governanceConfigMainnet.ADDRESSES.VM_DATA_HELPER,
name: 'IVotingMachineDataHelper',
},
{
address: mainnetProtoV3Pool.additionalAddresses.UI_POOL_DATA_PROVIDER,
name: 'IUiPoolDataProviderV3',
},
{
address: mainnetProtoV2Pool.additionalAddresses.UI_POOL_DATA_PROVIDER,
name: 'IUiPoolDataProviderV2',
},
];
17 changes: 13 additions & 4 deletions scripts/generateABIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import {ABI_INTERFACES, DOWNLOAD_ABI_INTERFACES} from './configs/abis';

const awaitableExec = util.promisify(exec);

export async function generateABIs() {
export async function generateABIs(removeExisting: boolean) {
if (existsSync('./src/ts/abis')) {
rmSync('./src/ts/abis', {recursive: true});
if (removeExisting) {
rmSync('./src/ts/abis', {recursive: true});
mkdirSync('./src/ts/abis');
}
} else {
mkdirSync('./src/ts/abis');
}
mkdirSync('./src/ts/abis');
for (const INTERFACE of ABI_INTERFACES) {
const {stdout, stderr} = await awaitableExec(`forge inspect ${INTERFACE} abi`);
if (stderr) {
Expand All @@ -25,13 +29,18 @@ export async function generateABIs() {
);
}
for (const INTERFACE of DOWNLOAD_ABI_INTERFACES) {
const fileName = `./src/ts/abis/${INTERFACE.name}.ts`;
if (existsSync(fileName)) {
console.log(`skipping download of abi ${INTERFACE.name} as it already exists`);
continue;
}
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`,
fileName,
prefixWithGeneratedWarning(
`export const ${varName} = ${JSON.stringify(JSON.parse(stdout.trim()), null, 2)} as const;`,
),
Expand Down
Loading

0 comments on commit 0123110

Please sign in to comment.