Skip to content

Commit

Permalink
feat: add sanity checks (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Sep 19, 2024
1 parent 27ce23b commit 42247e9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Checks if all addresses are verified and generates a diff if not
name: Address verification diff
# Also checks for sanity of values (by performing various checks to ensure correctness)
name: Checks

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
Expand All @@ -12,7 +13,38 @@ on:
- main

jobs:
check:
sanity:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: install
run: yarn install --frozen-lockfile

- name: verify
run: yarn check:sanity
env:
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
RPC_POLYGON: ${{ secrets.RPC_POLYGON }}
RPC_AVALANCHE: ${{ secrets.RPC_AVALANCHE }}
RPC_OPTIMISM: ${{ secrets.RPC_OPTIMISM }}
RPC_ARBITRUM: ${{ secrets.RPC_ARBITRUM }}
RPC_BASE: ${{ secrets.RPC_BASE }}
RPC_GNOSIS: ${{ secrets.RPC_GNOSIS }}
RPC_BNB: ${{ secrets.RPC_BNB }}
RPC_METIS: ${{ secrets.RPC_METIS }}
RPC_SCROLL: ${{ secrets.RPC_SCROLL }}
verification:
runs-on: ubuntu-latest
permissions:
pull-requests: write
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"scripts": {
"prettier": "prettier --write 'src/**/*.{sol,ts}'",
"check:verification": "tsx scripts/verifyVerified.ts",
"check:sanity": "tsx scripts/sanity.ts",
"generate:abis": "tsx scripts/generateABIs.ts && npm run prettier",
"generate:safe": "tsx scripts/generateSafeCSV.ts",
"generate:addresses": "tsx scripts/generateAddresses.ts && npm run generate:safe && npm run prettier",
Expand Down
32 changes: 32 additions & 0 deletions scripts/checks/stataFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {CHAIN_ID_CLIENT_MAP} from '@bgd-labs/js-utils';
import {getContract} from 'viem';
import {IStaticATokenFactory_ABI} from '../../src/ts/AaveAddressBook';

export async function check(addresses: Record<string, any>) {
if (addresses.STATIC_A_TOKEN_FACTORY) {
const client = CHAIN_ID_CLIENT_MAP[addresses.CHAIN_ID];
const factory = getContract({
abi: [
{
type: 'function',
name: 'POOL',
inputs: [],
outputs: [
{
name: '',
type: 'address',
internalType: 'address',
},
],
stateMutability: 'view',
},
] as const,
address: addresses['STATIC_A_TOKEN_FACTORY'],
client,
});
const factoryPool = await factory.read.POOL();
if (factoryPool !== addresses.POOL)
throw new Error(`SANITY_STATA: POOL MISMATCH ${addresses.POOL}:${factoryPool}`);
console.log('SANITY_STATA: PASSED');
}
}
16 changes: 16 additions & 0 deletions scripts/sanity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Runs sanity checks over the given set of addresses
*/
import * as addressBook from '../src/ts/AaveAddressBook';
import {check as stataCheck} from './checks/stataFactory';

async function sanity() {
const sanitySuites = [stataCheck];
for (const key of Object.keys(addressBook)) {
for (const suite of sanitySuites) {
await suite(addressBook[key]);
}
}
}

sanity();

0 comments on commit 42247e9

Please sign in to comment.