Skip to content

Commit

Permalink
clean up all contract metadata and use abi from zodiac package instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jfschwarz committed Jan 9, 2024
1 parent 9627896 commit af6a2fc
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 7,963 deletions.
391 changes: 0 additions & 391 deletions packages/app/src/contracts/AMBModule.json

This file was deleted.

502 changes: 0 additions & 502 deletions packages/app/src/contracts/ConnextModule.json

This file was deleted.

737 changes: 0 additions & 737 deletions packages/app/src/contracts/Delay.json

This file was deleted.

409 changes: 0 additions & 409 deletions packages/app/src/contracts/Exit.json

This file was deleted.

1,090 changes: 0 additions & 1,090 deletions packages/app/src/contracts/OZGovernorModule.json

This file was deleted.

923 changes: 0 additions & 923 deletions packages/app/src/contracts/OptimisticGovernor.json

This file was deleted.

880 changes: 0 additions & 880 deletions packages/app/src/contracts/RealityModuleERC20.json

This file was deleted.

880 changes: 0 additions & 880 deletions packages/app/src/contracts/RealityModuleETH.json

This file was deleted.

1,121 changes: 0 additions & 1,121 deletions packages/app/src/contracts/RolesMod.json

This file was deleted.

987 changes: 0 additions & 987 deletions packages/app/src/contracts/Tellor.json

This file was deleted.

20 changes: 18 additions & 2 deletions packages/app/src/store/modules/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ContractInterface } from "@ethersproject/contracts"
import { ContractAbis, KnownContracts } from "@gnosis.pm/zodiac"

export enum ModuleType {
TELLOR = "tellor",
Expand Down Expand Up @@ -32,6 +33,22 @@ export const MODULE_NAMES: Record<ModuleType, string> = {
[ModuleType.CONNEXT]: "Connext Module",
}

export const MODULE_ABIS: Record<ModuleType, ContractInterface> = {
[ModuleType.TELLOR]: ContractAbis[KnownContracts.TELLOR],
[ModuleType.OPTIMISTIC_GOVERNOR]: ContractAbis[KnownContracts.OPTIMISTIC_GOVERNOR],
[ModuleType.REALITY_ERC20]: ContractAbis[KnownContracts.REALITY_ERC20],
[ModuleType.REALITY_ETH]: ContractAbis[KnownContracts.REALITY_ETH],
[ModuleType.KLEROS_REALITY]: ContractAbis[KnownContracts.REALITY_ETH],
[ModuleType.UNKNOWN]: [],
[ModuleType.BRIDGE]: ContractAbis[KnownContracts.BRIDGE],
[ModuleType.DELAY]: ContractAbis[KnownContracts.DELAY],
[ModuleType.ROLES_V1]: ContractAbis[KnownContracts.ROLES_V1],
[ModuleType.ROLES_V2]: ContractAbis[KnownContracts.ROLES_V2],
[ModuleType.EXIT]: ContractAbis[KnownContracts.EXIT_ERC20],
[ModuleType.OZ_GOVERNOR]: ContractAbis[KnownContracts.OZ_GOVERNOR],
[ModuleType.CONNEXT]: ContractAbis[KnownContracts.CONNEXT],
}

export enum ModuleOperation {
CREATE,
REMOVE,
Expand All @@ -53,13 +70,12 @@ export interface ModuleContract {
type: ModuleType
name?: string
abi?: ContractInterface
bytecode?: string
}

export interface ModuleContractMetadata {
type: ModuleType
name?: string
abi: ContractInterface
bytecode: string
}

export interface DelayModule extends Module {
Expand Down
33 changes: 7 additions & 26 deletions packages/app/src/utils/modulesValidation.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
import { Contract, ethers } from "ethers"
import { ModuleContractMetadata, ModuleType } from "../store/modules/models"
import DELAY_MODIFIER_METADATA from "../contracts/Delay.json"
import REALITY_ERC20_MODULE_METADATA from "../contracts/RealityModuleERC20.json"
import REALITY_ETH_MODULE_METADATA from "../contracts/RealityModuleETH.json"
import TELLOR_MODULE_METADATA from "../contracts/Tellor.json"
import OPTIMISTIC_GOVERNOR_MODULE_METADATA from "../contracts/OptimisticGovernor.json"
import BRIDGE_MODULE_METADATA from "../contracts/AMBModule.json"
import EXIT_MODULE_METADATA from "../contracts/Exit.json"
import ROLES_MODIFIER_METADATA from "../contracts/RolesMod.json"
import OZ_GOVERNOR_METADATA from "../contracts/OZGovernorModule.json"
import CONNEXT_METADATA from "../contracts/ConnextModule.json"
import {
MODULE_ABIS,
MODULE_NAMES,
ModuleContractMetadata,
ModuleType,
} from "../store/modules/models"
import { NETWORK } from "./networks"

const MODULES_METADATA = {
[ModuleType.TELLOR]: TELLOR_MODULE_METADATA,
[ModuleType.OPTIMISTIC_GOVERNOR]: OPTIMISTIC_GOVERNOR_MODULE_METADATA,
[ModuleType.REALITY_ETH]: REALITY_ETH_MODULE_METADATA,
[ModuleType.KLEROS_REALITY]: REALITY_ETH_MODULE_METADATA,
[ModuleType.REALITY_ERC20]: REALITY_ERC20_MODULE_METADATA,
[ModuleType.EXIT]: EXIT_MODULE_METADATA,
[ModuleType.BRIDGE]: BRIDGE_MODULE_METADATA,
[ModuleType.DELAY]: DELAY_MODIFIER_METADATA,
[ModuleType.ROLES_V1]: ROLES_MODIFIER_METADATA,
[ModuleType.OZ_GOVERNOR]: OZ_GOVERNOR_METADATA,
[ModuleType.CONNEXT]: CONNEXT_METADATA,
}

const GNOSIS_GENERIC_PROXY_CONTRACT_BYTECODE =
"0x608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea265627a7a72315820d8a00dc4fe6bf675a9d7416fc2d00bb3433362aa8186b750f76c4027269667ff64736f6c634300050e0032"

Expand All @@ -43,7 +24,7 @@ export function getModuleContractMetadata(
module: ModuleType,
): ModuleContractMetadata | undefined {
if (module === ModuleType.UNKNOWN) return
return { type: module, ...MODULES_METADATA[module] }
return { type: module, name: MODULE_NAMES[module], abi: MODULE_ABIS[module] }
}

export function isGnosisGenericProxy(bytecode: string) {
Expand Down
30 changes: 15 additions & 15 deletions packages/app/src/views/ModuleDetails/ModuleNoAvailable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { makeStyles, Typography } from "@material-ui/core";
import { ZodiacPaper } from "zodiac-ui-components";
import { Link } from "../../components/text/Link";
import { useSafeAppsSDK } from "@gnosis.pm/safe-apps-react-sdk";
import { getNetworkExplorerInfo } from "../../utils/explorers";
import React from "react"
import { makeStyles, Typography } from "@material-ui/core"
import { ZodiacPaper } from "zodiac-ui-components"
import { Link } from "../../components/text/Link"
import { useSafeAppsSDK } from "@gnosis.pm/safe-apps-react-sdk"
import { getNetworkExplorerInfo } from "../../utils/explorers"

const useStyles = makeStyles((theme) => ({
root: {
Expand All @@ -14,26 +14,26 @@ const useStyles = makeStyles((theme) => ({
},
link: {
fontSize: 16,
}
}));
},
}))

export const ModuleNoAvailable = () => {
const classes = useStyles();
const { safe } = useSafeAppsSDK();
const { verifyUrl } = getNetworkExplorerInfo(safe.chainId) || {};
const classes = useStyles()
const { safe } = useSafeAppsSDK()
const { verifyUrl } = getNetworkExplorerInfo(safe.chainId) || {}

return (
<ZodiacPaper borderStyle="double" className={classes.root}>
<Typography variant="h5" className={classes.title}>
No Read or Write functions available
</Typography>
<Typography>
We couldn't find an ABI and didn't recognize the bytecode for this
module’s contract.
We couldn't find an ABI and didn't recognize it as one of the known Zodiac
contracts.
</Typography>
<Link target="_blank" href={verifyUrl} className={classes.link}>
Verify this contract on Etherscan to fix this.
</Link>
</ZodiacPaper>
);
};
)
}

0 comments on commit af6a2fc

Please sign in to comment.