Skip to content

Commit

Permalink
fix: the vote page could not render proposals without signature data
Browse files Browse the repository at this point in the history
fixes #3380
  • Loading branch information
moodysalem committed Feb 28, 2022
1 parent 00f1582 commit 1835de7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/constants/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const COMMON_CONTRACT_NAMES: Record<number, { [address: string]: string }
[TIMELOCK_ADDRESS[SupportedChainId.MAINNET]]: 'Timelock',
[GOVERNANCE_ALPHA_V0_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance (V0)',
[GOVERNANCE_ALPHA_V1_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance',
'0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e': 'ENS Registry',
'0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41': 'ENS Public Resolver',
},
}

Expand Down
20 changes: 18 additions & 2 deletions src/state/governance/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ interface FormattedProposalLog {
description: string
details: { target: string; functionSig: string; callData: string }[]
}

const FOUR_BYTES_DIR: { [sig: string]: string } = {
'0x5ef2c7f0': 'setSubnodeRecord(bytes32,bytes32,address,address,uint64)',
'0x10f13a8c': 'setText(bytes32,string,string)',
}

/**
* Need proposal events to get description data emitted from
* new proposal event.
Expand Down Expand Up @@ -172,8 +178,18 @@ function useFormattedProposalCreatedLogs(
description,
details: parsed.targets.map((target: string, i: number) => {
const signature = parsed.signatures[i]
const [name, types] = signature.substr(0, signature.length - 1).split('(')
const calldata = parsed.calldatas[i]
let calldata = parsed.calldatas[i]
let name: string
let types: string
if (signature === '') {
const fourbyte = calldata.slice(0, 10)
const sig = FOUR_BYTES_DIR[fourbyte]
if (!sig) throw new Error('Missing four byte sig')
;[name, types] = sig.substring(0, sig.length - 1).split('(')
calldata = `0x${calldata.slice(10)}`
} else {
;[name, types] = signature.substring(0, signature.length - 1).split('(')
}
const decoded = defaultAbiCoder.decode(types.split(','), calldata)
return {
target,
Expand Down

3 comments on commit 1835de7

@vercel
Copy link

@vercel vercel bot commented on 1835de7 Feb 28, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

widgets – ./

widgets-git-main-uniswap.vercel.app
widgets-uniswap.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 1835de7 Feb 28, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

interface – ./

interface-git-main-uniswap.vercel.app
interface-uniswap.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 1835de7 Mar 1, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

donate – ./

donate-sepia.vercel.app
donate-uniswap.vercel.app
donate-git-main-uniswap.vercel.app

Please sign in to comment.