Skip to content

Commit

Permalink
fix edit roles links for legacy contract versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jfschwarz committed May 9, 2023
1 parent 8fafc23 commit 9b77d43
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@gnosis.pm/safe-apps-react-sdk": "4.6.2",
"@gnosis.pm/safe-deployments": "1.17.0",
"@gnosis.pm/safe-react-components": "^1.2.0",
"@gnosis.pm/zodiac": "3.2.2",
"@gnosis.pm/zodiac": "3.3.2",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
Expand Down
28 changes: 22 additions & 6 deletions packages/app/src/store/modules/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Contract as MultiCallContract, Provider as MultiCallProvider } from "et
import SafeAppsSDK from "@gnosis.pm/safe-apps-sdk"
import {
ContractAddresses,
ContractVersions,
getModuleInstance,
KnownContracts,
SupportedNetworks,
Expand All @@ -13,7 +14,6 @@ import {
DelayModule,
Module,
MODULE_NAMES,
MODULE_TYPES,
ModuleContract,
ModuleOperation,
ModuleType,
Expand Down Expand Up @@ -222,17 +222,33 @@ export function getTransactionsFromSafeTransaction(
return [safeTransaction]
}

const ZODIAC_CONTRACTS_TO_MODULE_TYPE: Record<string, ModuleType> = {
tellor: ModuleType.TELLOR,
optimisticGovernor: ModuleType.OPTIMISTIC_GOVERNOR,
realityETH: ModuleType.REALITY_ETH,
realityERC20: ModuleType.REALITY_ERC20,
delay: ModuleType.DELAY,
bridge: ModuleType.BRIDGE,
exit: ModuleType.EXIT,
scopeGuard: ModuleType.UNKNOWN,
circulatingSupply: ModuleType.UNKNOWN,
roles: ModuleType.ROLES,
ozGovernor: ModuleType.OZ_GOVERNOR,
}
export function getContractsModuleType(
chainId: number,
masterCopyAddress: string,
): ModuleType {
const masterCopyAddresses = ContractAddresses[chainId as SupportedNetworks]
if (!masterCopyAddresses) return ModuleType.UNKNOWN
const entry = Object.entries(masterCopyAddresses).find(([, address]) => {
return address.toLowerCase() === masterCopyAddress.toLowerCase()
const contractVersions = ContractVersions[chainId as SupportedNetworks]
if (!contractVersions) return ModuleType.UNKNOWN

const entry = Object.entries(contractVersions).find(([, addresses]) => {
return Object.values(addresses).some(
(address) => address.toLowerCase() === masterCopyAddress.toLowerCase(),
)
})
if (!entry) return ModuleType.UNKNOWN
return MODULE_TYPES[entry[0]] || ModuleType.UNKNOWN
return ZODIAC_CONTRACTS_TO_MODULE_TYPE[entry[0]] || ModuleType.UNKNOWN
}

/**
Expand Down
14 changes: 0 additions & 14 deletions packages/app/src/store/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ export enum ModuleType {
UNKNOWN = "unknown",
}

export const MODULE_TYPES: Record<string, ModuleType> = {
tellor: ModuleType.TELLOR,
optimisticGovernor: ModuleType.OPTIMISTIC_GOVERNOR,
realityETH: ModuleType.REALITY_ETH,
realityERC20: ModuleType.REALITY_ERC20,
delay: ModuleType.DELAY,
bridge: ModuleType.BRIDGE,
exit: ModuleType.EXIT,
scopeGuard: ModuleType.UNKNOWN,
circulatingSupply: ModuleType.UNKNOWN,
roles: ModuleType.ROLES,
ozGovernor: ModuleType.OZ_GOVERNOR,
}

export const MODULE_NAMES: Record<ModuleType, string> = {
[ModuleType.TELLOR]: "Tellor Module",
[ModuleType.OPTIMISTIC_GOVERNOR]: "UMA oSnap Module",
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/views/Panel/item/RoleModuleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const useStyles = makeStyles((theme) => ({
export const RoleModuleItem: React.FC<RoleModuleItemProps> = ({ module }) => {
const classes = useStyles()
const { safe: safeInfo } = useSafeAppsSDK()
const rolesAddress = module.address

return (
<div className={classes.root}>
Expand All @@ -67,7 +66,7 @@ export const RoleModuleItem: React.FC<RoleModuleItemProps> = ({ module }) => {
noWrap
className={classes.link}
onClick={() => {
window.location.href = rolesAppUrl(safeInfo, rolesAddress)
window.location.href = rolesAppUrl(safeInfo, module.address)
}}
underline="always"
>
Expand Down
8 changes: 4 additions & 4 deletions packages/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2371,10 +2371,10 @@
dependencies:
cross-fetch "^3.1.5"

"@gnosis.pm/zodiac@3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@gnosis.pm/zodiac/-/zodiac-3.2.2.tgz#21e20d37a2c623dca61ea8248036cacf46526b0e"
integrity sha512-VQ59OKCEPCGMlBcz9O40ZtsW3irLk9cRxhxx9Ecvq1WmepqQdu3Wv718tHraqYxSPgH+4cIUOof8pMU+9sZ01Q==
"@gnosis.pm/zodiac@3.3.2":
version "3.3.2"
resolved "https://registry.yarnpkg.com/@gnosis.pm/zodiac/-/zodiac-3.3.2.tgz#9d7b2c54b7165b8a9e6bbaf5ee2712c5739dac06"
integrity sha512-Uza/aYrhO+Qor5B5FZpHpdciuTQpeG2P1G5LXhokzLoYBF3nEmPD8XdbNop2tl6LqaghhFdymMZp5n97n7VA5g==
dependencies:
"@gnosis.pm/mock-contract" "^4.0.0"
"@gnosis.pm/safe-contracts" "1.3.0"
Expand Down

0 comments on commit 9b77d43

Please sign in to comment.