Commit 1835de7f authored by Moody Salem's avatar Moody Salem

fix: the vote page could not render proposals without signature data

fixes https://github.com/Uniswap/interface/issues/3380
parent 00f15820
...@@ -12,6 +12,8 @@ export const COMMON_CONTRACT_NAMES: Record<number, { [address: string]: string } ...@@ -12,6 +12,8 @@ export const COMMON_CONTRACT_NAMES: Record<number, { [address: string]: string }
[TIMELOCK_ADDRESS[SupportedChainId.MAINNET]]: 'Timelock', [TIMELOCK_ADDRESS[SupportedChainId.MAINNET]]: 'Timelock',
[GOVERNANCE_ALPHA_V0_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance (V0)', [GOVERNANCE_ALPHA_V0_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance (V0)',
[GOVERNANCE_ALPHA_V1_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance', [GOVERNANCE_ALPHA_V1_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance',
'0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e': 'ENS Registry',
'0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41': 'ENS Public Resolver',
}, },
} }
......
...@@ -111,6 +111,12 @@ interface FormattedProposalLog { ...@@ -111,6 +111,12 @@ interface FormattedProposalLog {
description: string description: string
details: { target: string; functionSig: string; callData: 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 * Need proposal events to get description data emitted from
* new proposal event. * new proposal event.
...@@ -172,8 +178,18 @@ function useFormattedProposalCreatedLogs( ...@@ -172,8 +178,18 @@ function useFormattedProposalCreatedLogs(
description, description,
details: parsed.targets.map((target: string, i: number) => { details: parsed.targets.map((target: string, i: number) => {
const signature = parsed.signatures[i] const signature = parsed.signatures[i]
const [name, types] = signature.substr(0, signature.length - 1).split('(') let calldata = parsed.calldatas[i]
const 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) const decoded = defaultAbiCoder.decode(types.split(','), calldata)
return { return {
target, target,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment