From eb80b0b059af0a8933b59458ed2787faae2a2c71 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:08:55 +0200 Subject: [PATCH] refactor: Host UMA VotingV2 contracts locally Removes another dependency on @uma. --- src/common/ContractAddresses.ts | 18 ++++++++++++++++++ src/utils/UmaUtils.ts | 11 +++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/common/ContractAddresses.ts b/src/common/ContractAddresses.ts index 93d8c988f..69a317aef 100644 --- a/src/common/ContractAddresses.ts +++ b/src/common/ContractAddresses.ts @@ -454,6 +454,24 @@ export const CONTRACT_ADDRESSES: { }, ], }, + VotingV2: { + address: "0x004395edb43EFca9885CEdad51EC9fAf93Bd34ac", + abi: [ + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "address", name: "requester", type:"address"}, + { indexed: true, internalType: "uint32", name: "roundId", type: "uint32" }, + { indexed: true, internalType: "bytes32", name: "identifier", type: "bytes32" }, + { indexed: false, internalType: "uint256", name: "time", type: "uint256" }, + { indexed: false, internalType: "bytes", name: "ancillaryData", type: "bytes" }, + { indexed:false, internalType: "bool", name: "isGovernance", type: "bool" } + ], + name: "RequestAdded", + type: "event", + } + ] + }, }, 10: { daiOptimismBridge: { diff --git a/src/utils/UmaUtils.ts b/src/utils/UmaUtils.ts index 0da1db626..9096e52cd 100644 --- a/src/utils/UmaUtils.ts +++ b/src/utils/UmaUtils.ts @@ -1,11 +1,14 @@ -import { Contract, ethers, getBlockForTimestamp, isEventOlder, sortEventsDescending } from "."; -import * as uma from "@uma/contracts-node"; import { HubPoolClient } from "../clients"; +import { CONTRACT_ADDRESSES } from "../common"; import { ProposedRootBundle, SortableEvent } from "../interfaces"; +import { Contract, ethers, getBlockForTimestamp, isEventOlder, sortEventsDescending } from "."; -export async function getDvmContract(mainnetProvider: ethers.providers.Provider): Promise { - return new Contract(await uma.getVotingV2Address(1), uma.getAbi("VotingV2"), mainnetProvider); +export async function getDvmContract(provider: ethers.providers.Provider): Promise { + const { chainId } = await provider.getNetwork(); + const { address, abi } = CONTRACT_ADDRESSES[chainId].VotingV2; + return new Contract(address, abi, provider); } + export function getDisputedProposal( hubPoolClient: HubPoolClient, disputeEvent: SortableEvent