From 188b321cc9274ac0b42afaa536e9f65a97513f89 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Wed, 3 Nov 2021 13:12:39 -0400 Subject: [PATCH] fix: Parse latest proposal description correctly --- src/constants/proposals/index.ts | 1 + src/state/governance/hooks.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/constants/proposals/index.ts b/src/constants/proposals/index.ts index 46c108b523..f4d64c8285 100644 --- a/src/constants/proposals/index.ts +++ b/src/constants/proposals/index.ts @@ -1,2 +1,3 @@ export const UNISWAP_GRANTS_START_BLOCK = 11473815 export const BRAVO_START_BLOCK = 13059344 +export const ONE_BIP_START_BLOCK = 13551293 diff --git a/src/state/governance/hooks.ts b/src/state/governance/hooks.ts index aeb02eca8b..36d7886fed 100644 --- a/src/state/governance/hooks.ts +++ b/src/state/governance/hooks.ts @@ -21,7 +21,7 @@ import { useCallback, useMemo } from 'react' import { calculateGasMargin } from 'utils/calculateGasMargin' import { SupportedChainId } from '../../constants/chains' -import { BRAVO_START_BLOCK, UNISWAP_GRANTS_START_BLOCK } from '../../constants/proposals' +import { BRAVO_START_BLOCK, ONE_BIP_START_BLOCK, UNISWAP_GRANTS_START_BLOCK } from '../../constants/proposals' import { UNI } from '../../constants/tokens' import { useLogs } from '../logs/hooks' import { useSingleCallResult, useSingleContractMultipleData } from '../multicall/hooks' @@ -104,6 +104,8 @@ function useFormattedProposalCreatedLogs( ?.filter((parsed) => indices.flat().some((i) => i === parsed.id.toNumber())) ?.map((parsed) => { let description!: string + + const startBlock = parseInt(parsed.startBlock?.toString()) try { description = parsed.description } catch (error) { @@ -111,7 +113,6 @@ function useFormattedProposalCreatedLogs( let onError = Utf8ErrorFuncs.replace // Bravo proposal reverses the codepoints for U+2018 (‘) and U+2026 (…) - const startBlock = parseInt(parsed.startBlock?.toString()) if (startBlock === BRAVO_START_BLOCK) { const U2018 = [0xe2, 0x80, 0x98].toString() const U2026 = [0xe2, 0x80, 0xa6].toString() @@ -131,12 +132,13 @@ function useFormattedProposalCreatedLogs( } description = JSON.parse(toUtf8String(error.error.value, onError)) || '' - - // Bravo proposal omits newlines - if (startBlock === BRAVO_START_BLOCK) { - description = description.replace(/ /g, '\n').replace(/\d\. /g, '\n$&') - } } + + // Bravo and one bip proposals omit newlines + if (startBlock === BRAVO_START_BLOCK || startBlock === ONE_BIP_START_BLOCK) { + description = description.replace(/ /g, '\n').replace(/\d\. /g, '\n$&') + } + return { description, details: parsed.targets.map((target: string, i: number) => {