Skip to content

Commit

Permalink
Merge pull request #10 from gnosis/fix-checkboxes
Browse files Browse the repository at this point in the history
Various bugfixes
  • Loading branch information
jfschwarz authored Jan 5, 2024
2 parents e42930f + 010dc2c commit e2143a0
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
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
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
5 changes: 1 addition & 4 deletions packages/app/src/components/views/Role/RoleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const PlaceholderPerType: Record<ParamNativeType, string> = {
[ParamNativeType.ARRAY]: "[value 1, value 2, ...]",
[ParamNativeType.TUPLE]: "(1,2,3)",
[ParamNativeType.BOOLEAN]: "true",
[ParamNativeType.INT]: "235000000",
[ParamNativeType.INT]: "-235000000",
[ParamNativeType.UINT]: "235000000",
[ParamNativeType.ADDRESS]: "0xABF...123",
[ParamNativeType.STRING]: "Enter a string",
[ParamNativeType.BYTES]: "0x...",
Expand Down Expand Up @@ -149,9 +150,11 @@ const tryAbiEncode = (param: ethers.utils.ParamType | null, value: string) => {
}

const tryAbiDecode = (param: string, value: string, onDecodingError?: (err: Error) => void) => {
if (!value) return value
try {
return ethers.utils.defaultAbiCoder.decode([param], value).toString()
} catch (err) {
console.error("Error decoding value", err, { param, value })
if (onDecodingError) onDecodingError(err as Error)
return value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const useStyles = makeStyles((theme) => ({
},
},
disabledArea: {
pointerEvents: "none",
opacity: 0.5,
"&::after": {
content: "''",
Expand Down
52 changes: 33 additions & 19 deletions packages/app/src/data/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
"symbol": "OETH",
"decimals": 18
},
"rpc": ["https://mainnet.optimism.io/"],
"rpc": [
"https://mainnet.optimism.io/"
],
"explorers": [
{
"name": "etherscan",
Expand All @@ -74,7 +76,11 @@
"symbol": "BNB",
"decimals": 18
},
"rpc": ["https://bsc-dataseed1.binance.org", "https://bsc-dataseed2.binance.org", "wss://bsc-ws-node.nariox.org"],
"rpc": [
"https://bsc-dataseed1.binance.org",
"https://bsc-dataseed2.binance.org",
"wss://bsc-ws-node.nariox.org"
],
"explorers": [
{
"name": "bscscan",
Expand All @@ -97,22 +103,18 @@
"decimals": 18
},
"rpc": [
"https://rpc.xdaichain.com",
"https://xdai.poanetwork.dev",
"wss://rpc.xdaichain.com/wss",
"wss://xdai.poanetwork.dev/wss",
"http://xdai.poanetwork.dev",
"https://dai.poa.network",
"ws://xdai.poanetwork.dev:8546"
"https://rpc.gnosischain.com",
"https://rpc.gnosis.gateway.fm",
"wss://rpc.gnosischain.com/wss"
],
"explorers": [
{
"name": "blockscout",
"url": "https://blockscout.com/xdai/mainnet",
"name": "gnosisscan",
"url": "https:/gnosisscan.io",
"standard": "EIP3091"
}
],
"infoURL": "https://forum.poa.network/c/xdai-chain"
"infoURL": "https://gnosis.io"
},
"137": {
"name": "Polygon Mainnet",
Expand Down Expand Up @@ -149,7 +151,10 @@
"symbol": "EWT",
"decimals": 18
},
"rpc": ["https://rpc.energyweb.org", "wss://rpc.energyweb.org/ws"],
"rpc": [
"https://rpc.energyweb.org",
"wss://rpc.energyweb.org/ws"
],
"explorers": [
{
"name": "blockscout",
Expand All @@ -168,7 +173,10 @@
"symbol": "xDAI",
"decimals": 18
},
"rpc": ["https://optimism.gnosischain.com", "wss://optimism.gnosischain.com/wss"],
"rpc": [
"https://optimism.gnosischain.com",
"wss://optimism.gnosischain.com/wss"
],
"explorers": [
{
"name": "blockscout",
Expand All @@ -178,7 +186,6 @@
],
"infoURL": "https://www.gnosischain.com/"
},

"42161": {
"name": "Arbitrum One",
"chainId": 42161,
Expand Down Expand Up @@ -217,7 +224,9 @@
"symbol": "AVAX",
"decimals": 18
},
"rpc": ["https://api.avax.network/ext/bc/C/rpc"],
"rpc": [
"https://api.avax.network/ext/bc/C/rpc"
],
"explorers": [
{
"name": "snowtrace",
Expand All @@ -243,7 +252,10 @@
"standard": "none"
}
],
"rpc": ["https://volta-rpc.energyweb.org", "wss://volta-rpc.energyweb.org/ws"],
"rpc": [
"https://volta-rpc.energyweb.org",
"wss://volta-rpc.energyweb.org/ws"
],
"infoURL": "https://energyweb.org"
},
"1313161554": {
Expand All @@ -255,7 +267,9 @@
"symbol": "aETH",
"decimals": 18
},
"rpc": ["https://mainnet.aurora.dev"],
"rpc": [
"https://mainnet.aurora.dev"
],
"explorers": [
{
"name": "explorer.aurora.dev",
Expand All @@ -265,4 +279,4 @@
],
"infoURL": "https://aurora.dev"
}
}
}
1 change: 1 addition & 0 deletions packages/app/src/typings/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export enum ParameterType {

export enum ParamNativeType {
INT,
UINT,
BOOLEAN,
BYTES,
BYTES_FIXED,
Expand Down
7 changes: 4 additions & 3 deletions packages/app/src/utils/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ export function getNativeType(param: ethers.utils.ParamType | null): ParamNative
if (param.baseType === "string") return ParamNativeType.STRING
if (param.baseType === "bool") return ParamNativeType.BOOLEAN
if (param.baseType === "tuple") return ParamNativeType.TUPLE
if (param.baseType.startsWith("uint") || param.baseType.startsWith("int")) return ParamNativeType.INT
if (param.baseType.startsWith("uint")) return ParamNativeType.UINT
if (param.baseType.startsWith("int")) return ParamNativeType.INT
if (param.baseType === "array") {
if (param.arrayChildren.baseType === "array") return ParamNativeType.UNSUPPORTED
return ParamNativeType.ARRAY
}
if(param.baseType.startsWith('bytes') && param.baseType !== 'bytes') {
if (param.baseType.startsWith("bytes") && param.baseType !== "bytes") {
return ParamNativeType.BYTES_FIXED
}
return ParamNativeType.BYTES
}

export function getConditionsPerType(type: ParamNativeType): ParamComparison[] {
switch (type) {
case ParamNativeType.INT:
case ParamNativeType.UINT:
return [ParamComparison.EQUAL_TO, ParamComparison.ONE_OF, ParamComparison.LESS_THAN, ParamComparison.GREATER_THAN]

case ParamNativeType.BOOLEAN:
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/utils/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import memoize from "lodash.memoize"
import { ethers } from "ethers"

const ETHERSCAN_KEY = process.env.REACT_APP_ETHERSCAN_KEY as string
const GNOSISSCAN_KEY = process.env.REACT_APP_GNOSISSCAN_KEY as string
const POLYGONSCAN_KEY = process.env.REACT_APP_POLYGONSCAN_KEY as string
const ARBISCAN_KEY = process.env.REACT_APP_ARBISCAN_KEY as string
const BSCSCAN_KEY = process.env.REACT_APP_BSCSCAN_KEY as string
const OPTIMISTICSCAN_KEY = process.env.REACT_APP_OPTIMISTICSCAN_KEY as string
const SNOWTRACE_KEY = process.env.REACT_APP_SNOWTRACE_KEY as string

if (!ETHERSCAN_KEY) throw new Error("ETHERSCAN_KEY env is not set")
if (!GNOSISSCAN_KEY) throw new Error("GNOSISSCAN_KEY env is not set")
if (!POLYGONSCAN_KEY) throw new Error("POLYGONSCAN_KEY env is not set")
if (!ARBISCAN_KEY) throw new Error("ARBISCAN_KEY env is not set")
if (!BSCSCAN_KEY) throw new Error("BSCSCAN_KEY env is not set")
Expand Down Expand Up @@ -38,7 +40,8 @@ const explorerConfig: Record<Network, ExplorerConfig> = {
apiKey: ARBISCAN_KEY,
},
[Network.GNOSIS]: {
apiUrl: "https://blockscout.com/xdai/mainnet/api",
apiUrl: "https://api.gnosisscan.io/api",
apiKey: GNOSISSCAN_KEY,
},
[Network.BINANCE]: {
apiUrl: "https://api.bscscan.com/api",
Expand Down

1 comment on commit e2143a0

@vercel
Copy link

@vercel vercel bot commented on e2143a0 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.