Skip to content

Commit

Permalink
find more filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sgc-code committed Oct 9, 2023
1 parent bfdedb4 commit f51f1e8
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions scripts/remove-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getContractName(contractAddress: string, apiKey: string) {
export async function main() {
let environment;
if (hre.network.name == "hardhat") {
environment = "staging";
environment = "prod";
} else {
environment = hre.network.name;
}
Expand Down Expand Up @@ -65,8 +65,16 @@ export async function main() {
const allDappsInEvents = events.map(e => (e?.args[1]).toLowerCase());
const dapps = [...new Set(allDappsInEvents)];

const allFiltersInEvents = events.map(e => (e?.args[2]).toLowerCase());
const filters = [...new Set(allFiltersInEvents)]
console.log(`Querying dapp filters...`);
const dappToFilter: Record<string, string> = {};
for (const dapp of dapps) {
await setTimeout(500);
const authorisation = await dappRegistry.authorisations(TRUSTLIST, dapp);
const dappFilter = ("0x" + authorisation.substring(10, 50)).toLowerCase();
console.log(`dapp ${dapp} -> filter ${dappFilter}`);
dappToFilter[dapp] = dappFilter;
}
const filters = [...new Set(Object.values(dappToFilter))]

console.log(`Querying filter names...`);
const filterWithNames: any[] = [];
Expand All @@ -77,26 +85,17 @@ export async function main() {
filterWithNames.push([filter, name]);
}

const filtersToRemove = filterWithNames.filter(([filterAddress, filterName]) => FILTERS_TO_REMOVE.includes(filterName));
console.log(`Filters to remove:`);
const filtersToRemove = filterWithNames.filter(([, filterName]) => FILTERS_TO_REMOVE.includes(filterName));
console.log(filtersToRemove);
const filtersAddressesToRemove = filtersToRemove.map(([filterAddress, filterName]) => filterAddress);

const dappsToRemove: string[] = []
console.log(`Querying dapp filters...`);
for (const dapp of dapps) {
await setTimeout(500);
const authorisation = await dappRegistry.authorisations(TRUSTLIST, dapp);
const dappFilter = ("0x" + authorisation.substring(10, 50)).toLowerCase();
console.log(`dapp ${dapp} -> filter ${dappFilter}`);
if (filtersAddressesToRemove.includes(dappFilter)) {
dappsToRemove.push(dapp);
}
}
console.log(`Dapps to remove:`);
const dappsToRemove = Object.entries(dappToFilter)
.filter(([dapp, filter]) => filtersAddressesToRemove.includes(filter))
.map(([dapp, filter]) => dapp);
console.log(dappsToRemove);


console.log(`Removing...`);
if (registryOwner != ownerAccount.address) {
console.log(`The account ${ownerAccount} is not the owner of the registry`);
Expand All @@ -105,7 +104,7 @@ export async function main() {

for (const dappToRemove of dappsToRemove) {
const tx = await dappRegistry.removeDapp.populateTransaction(TRUSTLIST, dappToRemove)
const response = await ownerAccount.sendTransaction({...tx, maxFeePerGas: MAX_FEE_PER_GAS, maxPriorityFeePerGas: MAX_TIP });
const response = await ownerAccount.sendTransaction({ ...tx, maxFeePerGas: MAX_FEE_PER_GAS, maxPriorityFeePerGas: MAX_TIP });
console.log(`Sent tx: ${response.hash}`);
const receipt = await response.wait();
if (receipt?.status != 1) {
Expand Down

0 comments on commit f51f1e8

Please sign in to comment.