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

fixes https://github.com/Uniswap/interface/issues/3380
This commit is contained in:
Moody Salem 2022-02-28 18:16:24 -05:00
parent 00f158209c
commit 1835de7f5f
No known key found for this signature in database
GPG Key ID: 8CB5CD10385138DB
2 changed files with 20 additions and 2 deletions

@ -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',
},
}

@ -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.
@ -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,