Skip to content

Commit

Permalink
Merge branch 'main' into mainnet-presets-progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jfschwarz authored Jan 10, 2024
2 parents 87890a1 + 0c39bc6 commit 794e3fe
Show file tree
Hide file tree
Showing 37 changed files with 2,982 additions and 1,646 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/dev-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ on:
branches: main

env:
REACT_APP_ETHERSCAN_KEY: ${{ secrets.REACT_APP_ETHERSCAN_KEY }}
REACT_APP_POLYGONSCAN_KEY: ${{ secrets.REACT_APP_POLYGONSCAN_KEY }}
REACT_APP_ARBISCAN_KEY: ${{ secrets.REACT_APP_ARBISCAN_KEY }}
REACT_APP_BSCSCAN_KEY: ${{ secrets.REACT_APP_BSCSCAN_KEY }}
REACT_APP_OPTIMISTICSCAN_KEY: ${{ secrets.REACT_APP_OPTIMISTICSCAN_KEY }}
REACT_APP_SNOWTRACE_KEY: $${{ secrets.REACT_APP_SNOWTRACE_KEY }}
REACT_APP_INFURA_KEY: ${{ secrets.REACT_APP_INFURA_KEY }}
REACT_APP_ONBOARD_JS_DAPP_ID: ${{ secrets.REACT_APP_ONBOARD_JS_DAPP_ID }}
REACT_APP_SUBGRAPH_BASE_URL: ${{ secrets.REACT_APP_SUBGRAPH_BASE_URL }}
REACT_APP_SUBGRAPH_GOERLI: ${{ secrets.REACT_APP_SUBGRAPH_GOERLI }}
REACT_APP_SUBGRAPH_GNOSIS_CHAIN: ${{ secrets.REACT_APP_SUBGRAPH_GNOSIS_CHAIN }}
REACT_APP_SUBGRAPH_MAINNET: ${{ secrets.REACT_APP_SUBGRAPH_MAINNET }}
REACT_APP_SUBGRAPH_POLYGON: ${{ secrets.REACT_APP_SUBGRAPH_POLYGON }}
REACT_APP_SUBGRAPH_ARBITRUM: ${{ secrets.REACT_APP_SUBGRAPH_ARBITRUM }}
REACT_APP_SUBGRAPH_OPTIMISM: ${{ secrets.REACT_APP_SUBGRAPH_OPTIMISM }}
REACT_APP_SUBGRAPH_AVALANCHE: ${{ secrets.REACT_APP_SUBGRAPH_AVALANCHE }}
REACT_APP_SUBGRAPH_BSC: ${{ secrets.REACT_APP_SUBGRAPH_BSC }}
REACT_APP_ETHERSCAN_KEY: 6RJ8KT4B1S9V7E3CIYECNY7HFW8IPWQ3C4
REACT_APP_GNOSISSCAN_KEY: 8ENCUFT4D3XVJS7N9ZFS5Z9XQPNUGRKSN5
REACT_APP_POLYGONSCAN_KEY: NM937M1IZXVQ6QVDXS73XMF8JSAB677JWQ
REACT_APP_ARBISCAN_KEY: CSITWCYI9UDAJ7QS92FNVJ2XQP5B23P4J9
REACT_APP_BSCSCAN_KEY: AMXEAU3N9P7RJHFSZ7KAJDRY5MFJ1N29D6
REACT_APP_OPTIMISTICSCAN_KEY: 6RJ8KT4B1S9V7E3CIYECNY7HFW8IPWQ3C4
REACT_APP_SNOWTRACE_KEY: IAST9REKWMIW1QSE2M7K2IKKAZVNQPHC1U
REACT_APP_INFURA_KEY: 0de1a96486754f8b98f284d093905198
REACT_APP_ONBOARD_JS_DAPP_ID: 30fd8cd4-93a1-4c0e-a463-b5eceb9a3956
REACT_APP_SUBGRAPH_BASE_URL: https://api.thegraph.com/subgraphs/name/
REACT_APP_SUBGRAPH_GOERLI: samepant/zodiac-roles-mod-goerli
REACT_APP_SUBGRAPH_GNOSIS_CHAIN: samepant/zodiac-roles-mod-gnosis-chain
REACT_APP_SUBGRAPH_MAINNET: samepant/zodiac-roles-mod-mainnet
REACT_APP_SUBGRAPH_POLYGON: samepant/zodiac-roles-mod-polygon
REACT_APP_SUBGRAPH_ARBITRUM: samepant/zodiac-roles-mod-arbitrum
REACT_APP_SUBGRAPH_OPTIMISM: samepant/zodiac-roles-mod-optimism
REACT_APP_SUBGRAPH_AVALANCHE: samepant/zodiac-roles-mod-avalanche
REACT_APP_SUBGRAPH_BSC: samepant/zodiac-roles-mod-bsc

jobs:
deploy:
Expand Down
35 changes: 18 additions & 17 deletions .github/workflows/prod-release-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ on:
types: created

env:
REACT_APP_ETHERSCAN_KEY: ${{ secrets.REACT_APP_ETHERSCAN_KEY }}
REACT_APP_POLYGONSCAN_KEY: ${{ secrets.REACT_APP_POLYGONSCAN_KEY }}
REACT_APP_ARBISCAN_KEY: ${{ secrets.REACT_APP_ARBISCAN_KEY }}
REACT_APP_BSCSCAN_KEY: ${{ secrets.REACT_APP_BSCSCAN_KEY }}
REACT_APP_OPTIMISTICSCAN_KEY: ${{ secrets.REACT_APP_OPTIMISTICSCAN_KEY }}
REACT_APP_SNOWTRACE_KEY: $${{ secrets.REACT_APP_SNOWTRACE_KEY }}
REACT_APP_INFURA_KEY: ${{ secrets.REACT_APP_INFURA_KEY }}
REACT_APP_ONBOARD_JS_DAPP_ID: ${{ secrets.REACT_APP_ONBOARD_JS_DAPP_ID }}
REACT_APP_SUBGRAPH_BASE_URL: ${{ secrets.REACT_APP_SUBGRAPH_BASE_URL }}
REACT_APP_SUBGRAPH_GOERLI: ${{ secrets.REACT_APP_SUBGRAPH_GOERLI }}
REACT_APP_SUBGRAPH_GNOSIS_CHAIN: ${{ secrets.REACT_APP_SUBGRAPH_GNOSIS_CHAIN }}
REACT_APP_SUBGRAPH_MAINNET: ${{ secrets.REACT_APP_SUBGRAPH_MAINNET }}
REACT_APP_SUBGRAPH_POLYGON: ${{ secrets.REACT_APP_SUBGRAPH_POLYGON }}
REACT_APP_SUBGRAPH_ARBITRUM: ${{ secrets.REACT_APP_SUBGRAPH_ARBITRUM }}
REACT_APP_SUBGRAPH_OPTIMISM: ${{ secrets.REACT_APP_SUBGRAPH_OPTIMISM }}
REACT_APP_SUBGRAPH_AVALANCHE: ${{ secrets.REACT_APP_SUBGRAPH_AVALANCHE }}
REACT_APP_SUBGRAPH_BSC: ${{ secrets.REACT_APP_SUBGRAPH_BSC }}
REACT_APP_ETHERSCAN_KEY: 6RJ8KT4B1S9V7E3CIYECNY7HFW8IPWQ3C4
REACT_APP_GNOSISSCAN_KEY: 8ENCUFT4D3XVJS7N9ZFS5Z9XQPNUGRKSN5
REACT_APP_POLYGONSCAN_KEY: NM937M1IZXVQ6QVDXS73XMF8JSAB677JWQ
REACT_APP_ARBISCAN_KEY: CSITWCYI9UDAJ7QS92FNVJ2XQP5B23P4J9
REACT_APP_BSCSCAN_KEY: AMXEAU3N9P7RJHFSZ7KAJDRY5MFJ1N29D6
REACT_APP_OPTIMISTICSCAN_KEY: 6RJ8KT4B1S9V7E3CIYECNY7HFW8IPWQ3C4
REACT_APP_SNOWTRACE_KEY: IAST9REKWMIW1QSE2M7K2IKKAZVNQPHC1U
REACT_APP_INFURA_KEY: 0de1a96486754f8b98f284d093905198
REACT_APP_ONBOARD_JS_DAPP_ID: 30fd8cd4-93a1-4c0e-a463-b5eceb9a3956
REACT_APP_SUBGRAPH_BASE_URL: https://api.thegraph.com/subgraphs/name/
REACT_APP_SUBGRAPH_GOERLI: samepant/zodiac-roles-mod-goerli
REACT_APP_SUBGRAPH_GNOSIS_CHAIN: samepant/zodiac-roles-mod-gnosis-chain
REACT_APP_SUBGRAPH_MAINNET: samepant/zodiac-roles-mod-mainnet
REACT_APP_SUBGRAPH_POLYGON: samepant/zodiac-roles-mod-polygon
REACT_APP_SUBGRAPH_ARBITRUM: samepant/zodiac-roles-mod-arbitrum
REACT_APP_SUBGRAPH_OPTIMISM: samepant/zodiac-roles-mod-optimism
REACT_APP_SUBGRAPH_AVALANCHE: samepant/zodiac-roles-mod-avalanche
REACT_APP_SUBGRAPH_BSC: samepant/zodiac-roles-mod-bsc

jobs:
deploy:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ packages/subgraph/abis/*.json

# This will be generated from the themplate on deployment (to support multiple networks)
packages/subgraph/subgraph.yaml
.vscode/settings.json

.vscode
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
}
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Zodiac Roles Modifier
**This is the code for the legacy V1 contracts, current version at: [gnosis/zodiac-modifier-roles](https://github.com/gnosis/zodiac-modifier-roles)**
___

[![Build Status](https://github.com/gnosis/zodiac-modifier-roles/actions/workflows/ci.yml/badge.svg)](https://github.com/gnosis/zodiac-modifier-roles/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/gnosis/zodiac-modifier-roles/badge.svg?branch=main&cache_bust=1)](https://coveralls.io/github/gnosis/zodiac-modifier-roles?branch=main)
# Zodiac Roles Modifier V1

[![Build Status](https://github.com/gnosis/zodiac-modifier-roles-v1/actions/workflows/ci.yml/badge.svg)](https://github.com/gnosis/zodiac-modifier-roles/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/gnosis/zodiac-modifier-roles-v1/badge.svg?branch=main&cache_bust=1)](https://coveralls.io/github/gnosis/zodiac-modifier-roles-v1?branch=main)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/gnosis/CODE_OF_CONDUCT)

The Roles Modifier belongs to the [Zodiac](https://github.com/gnosis/zodiac) collection of tools, which can be accessed through the Zodiac App available on [Gnosis Safe](https://gnosis-safe.io/), as well as in this repository.
Expand Down Expand Up @@ -46,7 +49,7 @@ The contracts have been developed with [Solidity 0.8.6](https://github.com/ether

An audit has been performed by the [G0 group](https://github.com/g0-group).

All identified issues have been resolved as of commit [454be9d3c26f90221ca717518df002d1eca1845f](https://github.com/gnosis/zodiac-modifier-roles/tree/454be9d3c26f90221ca717518df002d1eca1845f/contracts)
All identified issues have been resolved as of commit [454be9d3c26f90221ca717518df002d1eca1845f](https://github.com/gnosis/zodiac-modifier-roles-v1/tree/454be9d3c26f90221ca717518df002d1eca1845f/contracts)

The audit results are available as a pdf in [this repo](packages/evm/docs/ZodiacRolesModifierJan2022.pdf).

Expand Down
1 change: 1 addition & 0 deletions packages/app/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REACT_APP_ETHERSCAN_KEY=
REACT_APP_POLYGONSCAN_KEY=
REACT_APP_ARBISCAN_KEY=
REACT_APP_BSCSCAN_KEY=
REACT_APP_GNOSISSCAN_KEY=
REACT_APP_OPTIMISTICSCAN_KEY=
REACT_APP_SNOWTRACE_KEY=

Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"classnames": "^2.3.1",
"ethereum-blockies-base64": "^1.0.2",
"ethers": "^5.5.3",
"evm-proxy-detection": "^1.1.0",
"graphql": "^16.2.0",
"localforage": "^1.10.0",
"localforage-memoryStorageDriver": "^0.9.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/components/modals/AddTargetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Modal from "../commons/Modal"
import { colors, ZodiacTextField } from "zodiac-ui-components"
import AddIcon from "@material-ui/icons/Add"
import { ConditionType, ExecutionOption, Target } from "../../typings/role"
import { ExecutionTypeSelect } from "../views/Role/targets/ExecutionTypeSelect"
import { ExecutionOptions } from "../views/Role/targets/ExecutionOptions"

const useStyles = makeStyles((theme) => ({
link: {
Expand Down Expand Up @@ -33,7 +33,7 @@ type Props = {
const AddTargetModal = ({ onAddTarget, onClose, isOpen }: Props): React.ReactElement => {
const classes = useStyles()
const [address, setAddress] = useState("")
const [executionOptions, setExecutionOptions] = useState(ExecutionOption.SEND)
const [executionOptions, setExecutionOptions] = useState(ExecutionOption.NONE)
const [isValidAddress, setIsValidAddress] = useState(false)

const onAddressChange = (address: string) => {
Expand Down Expand Up @@ -72,12 +72,12 @@ const AddTargetModal = ({ onAddTarget, onClose, isOpen }: Props): React.ReactEle
<Box sx={{ mt: 2 }} className={classes.textField}>
<ZodiacTextField
onChange={(e) => onAddressChange(e.target.value)}
label={`target address`}
label={`Target address`}
placeholder={`Add a new target address`}
/>
</Box>
<Box sx={{ mt: 2 }}>
<ExecutionTypeSelect value={executionOptions} onChange={setExecutionOptions} />
<ExecutionOptions value={executionOptions} onChange={setExecutionOptions} />
</Box>

<Box sx={{ mt: 2 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const ConnectWalletBox = () => {
address={address}
emptyText="No Wallet Connected"
onClick={walletType !== WalletType.GNOSIS_SAFE ? () => setShowWalletOption(!showWalletOption) : undefined}
linkToZodiac={walletType === WalletType.GNOSIS_SAFE}
/>
{showWalletOption && (
<Box className={classes.connectWalletBoxMenu}>
Expand Down
16 changes: 15 additions & 1 deletion packages/app/src/components/views/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const useStyles = makeStyles((theme) => ({
grow: {
flexGrow: 1,
},
badge: {
marginLeft: theme.spacing(2),
},
warning: {
color: theme.palette.warning.main,
textTransform: "uppercase",
},
}))

export const Header = () => {
Expand All @@ -40,7 +47,14 @@ export const Header = () => {
Roles
</Typography>
</HeaderBox>
<HeaderBox className={classes.grow} />
<HeaderBox className={classes.grow}>
<div className={classes.badge}>
<Typography className={classes.warning}>Experimental</Typography>
<Typography variant="body2">
Use this app with caution and carefully review all applied permissions
</Typography>
</div>
</HeaderBox>
<ChainPicker />
<HeaderAddressBox address={module} emptyText="No Safe Attached" />
<ConnectWalletBox />
Expand Down
47 changes: 39 additions & 8 deletions packages/app/src/components/views/Header/HeaderAddressBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HeaderBox } from "./HeaderBox"
import { makeStyles, Typography } from "@material-ui/core"
import { Box, Link, makeStyles, Typography } from "@material-ui/core"
import { ArrowForward } from "@material-ui/icons"
import { EthHashInfo } from "@gnosis.pm/safe-react-components"
import { truncateEthAddress } from "../../../utils/address"
import classNames from "classnames"
Expand All @@ -22,6 +23,19 @@ const useStyles = makeStyles((theme) => ({
title: {
marginLeft: theme.spacing(1),
},
zodiacArrow: {
color: "currentColor",
marginLeft: theme.spacing(0.5),
width: theme.spacing(2),
},
zodiacLink: {
color: "rgba(255,255,255,0.8)",
display: "flex",
alignItems: "center",
"&:hover": {
color: "white",
},
},
addressFont: {
fontFamily: "Roboto Mono",
},
Expand All @@ -34,10 +48,12 @@ interface HeaderAddressBoxProps {
address?: string
emptyText: string
onClick?: () => void
linkToZodiac?: boolean
}

export const HeaderAddressBox = ({ address, emptyText, onClick }: HeaderAddressBoxProps) => {
export const HeaderAddressBox = ({ address, emptyText, onClick, linkToZodiac }: HeaderAddressBoxProps) => {
const classes = useStyles()

return (
<HeaderBox
icon={
Expand All @@ -54,12 +70,27 @@ export const HeaderAddressBox = ({ address, emptyText, onClick }: HeaderAddressB
}
onClick={onClick}
>
<Typography
variant="body1"
className={classNames(classes.title, { [classes.empty]: !address, [classes.addressFont]: address })}
>
{address ? truncateEthAddress(address) : emptyText}
</Typography>
<Box className={classes.title}>
<Typography
variant="body1"
className={classNames({ [classes.empty]: !address, [classes.addressFont]: address })}
>
{address ? truncateEthAddress(address) : emptyText}
</Typography>
{address && linkToZodiac && (
<Link
rel="noredirect"
onClick={() => {
window.location.href = `https://zodiac.gnosisguild.org/`
}}
className={classes.zodiacLink}
underline="always"
>
Open Zodiac
<ArrowForward className={classes.zodiacArrow} />
</Link>
)}
</Box>
</HeaderBox>
)
}
80 changes: 55 additions & 25 deletions packages/app/src/components/views/Role/RoleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ExecutionOption,
FunctionCondition,
ParamCondition,
ParameterType,
Role,
Target,
TargetConditions,
Expand Down Expand Up @@ -185,13 +186,10 @@ function handleTargetConditions(state: RoleContextState, payload: SetTargetCondi
if (type !== ConditionType.WILDCARDED) {
const hasWildcardedFunction = conditionTypes.some((condition) => condition === ConditionType.WILDCARDED)
const hasScopedFunction = conditionTypes.some((condition) => condition === ConditionType.SCOPED)
const hasBlockedFunction = conditionTypes.some((condition) => condition === ConditionType.BLOCKED)

type = ConditionType.SCOPED
if (hasBlockedFunction && !hasScopedFunction && !hasWildcardedFunction) {
if (!hasScopedFunction && !hasWildcardedFunction) {
type = ConditionType.BLOCKED
} else if (!hasBlockedFunction && !hasScopedFunction && hasWildcardedFunction) {
type = ConditionType.WILDCARDED
}
}

Expand All @@ -214,9 +212,7 @@ function handleAddMember(state: RoleContextState, payload: string): RoleContextS
function handleSetTargetClearance(state: RoleContextState, payload: SetTargetClearancePayload): RoleContextState {
const replaceOption = (target: Target): Target => {
if (target.id !== payload.targetId) return target
const executionOption =
target.executionOption === ExecutionOption.NONE ? ExecutionOption.SEND : target.executionOption
return { ...target, executionOption, type: payload.option }
return { ...target, executionOption: ExecutionOption.NONE, type: payload.option }
}

return {
Expand Down Expand Up @@ -379,25 +375,59 @@ function getParamUpdate(
funcCondition: FunctionCondition,
original?: FunctionCondition,
): UpdateEvent[] {
return funcCondition.params
.map((param): UpdateEvent[] => {
if (!param) return []
const originalParam = original?.params.find((_param) => param.index === _param?.index)

// TODO: Get unscope param UpdateEvent

if (
originalParam &&
param.value === originalParam.value &&
param.type === originalParam.type &&
param.condition === originalParam.condition
) {
return []
}
const updates = funcCondition.params.reduce((toUpdate, newParamConfig) => {
// console.log("getParamUpdate - param:", newParamConfig)
if (!newParamConfig) return toUpdate
const originalParamConfig = original?.params.find((_param) => newParamConfig.index === _param?.index)
// console.log("getParamUpdate - originalParam:", originalParamConfig)

if (
originalParamConfig &&
newParamConfig.value === originalParamConfig.value &&
newParamConfig.type === originalParamConfig.type &&
newParamConfig.condition === originalParamConfig.condition
) {
return toUpdate
}

return [{ level: Level.SCOPE_PARAM, value: param, old: param, targetAddress, funcSighash: funcCondition.sighash }]
})
.flat()
return [
...toUpdate,
{
level: Level.SCOPE_PARAM,
value: newParamConfig,
old: newParamConfig,
targetAddress,
funcSighash: funcCondition.sighash,
} as UpdateEvent,
]
}, [] as UpdateEvent[])

const removals = (original?.params ?? []).reduce((toRemove, originalParamConfig) => {
const newParamConfig = funcCondition.params.find((_param) => originalParamConfig.index === _param?.index)

if (
newParamConfig == null &&
updates.find((update: any) => update.value.index === originalParamConfig.index) == null // check if param was updated
) {
// param was removed
return [
...toRemove,
{
level: Level.SCOPE_PARAM,
value: {
...originalParamConfig,
type: ParameterType.NO_RESTRICTION, // remove restriction
},
old: originalParamConfig,
targetAddress,
funcSighash: funcCondition.sighash,
},
] as UpdateEvent[]
}
return toRemove
}, [] as UpdateEvent[])

return [...updates, ...removals]
}

function getFunctionUpdate(
Expand Down
Loading

0 comments on commit 794e3fe

Please sign in to comment.