From 2b37ff59d139f0459f698bd13baa2b89d322bdf7 Mon Sep 17 00:00:00 2001 From: dzgoldman Date: Thu, 14 Sep 2023 14:35:58 -0400 Subject: [PATCH] use ArbitrumProvider to get l1 block timestamp (not multicall) --- package.json | 4 ++-- src-ts/proposalMonitorCli.ts | 5 +++-- src-ts/securityCouncilElectionCreator.ts | 21 ++++++++++++--------- yarn.lock | 8 ++++---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 040832e4..e8a1ec71 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,11 @@ "coverage:report": "yarn coverage:filtered-report && yarn coverage:htmlreport && yarn coverage:open-report", "coverage:refresh": "yarn coverage:filtered-report && yarn coverage:htmlreport", "propmon:ui": "cd src-ts && http-server . -p 8080", - "propmon:service": "ts-node ./src-ts/proposalMonitorCli.ts --jsonOutputLocation ./src-ts/propMonUi/proposalState.json --l1RpcUrl $ETH_RPC --govChainRpcUrl https://arb1.arbitrum.io/rpc --novaRpcUrl https://nova.arbitrum.io/rpc --coreGovernorAddress 0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9 --treasuryGovernorAddress 0x789fC99093B09aD01C34DC7251D0C89ce743e5a4 --sevenTwelveCouncil 0x895c9fc6bcf06e553b54A9fE11D948D67a9B76FA --nomineeElectionGovernorAddress 0x8a1cDA8dee421cD06023470608605934c16A05a0 --pollingIntervalSeconds 1", + "propmon:service": "ts-node ./src-ts/proposalMonitorCli.ts --jsonOutputLocation ./src-ts/propMonUi/proposalState.json --l1RpcUrl https://mainnet.infura.io/v3/8838d00c028a46449be87e666387c71a --govChainRpcUrl https://arb1.arbitrum.io/rpc --novaRpcUrl https://nova.arbitrum.io/rpc --coreGovernorAddress 0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9 --treasuryGovernorAddress 0x789fC99093B09aD01C34DC7251D0C89ce743e5a4 --sevenTwelveCouncil 0x895c9fc6bcf06e553b54A9fE11D948D67a9B76FA --nomineeElectionGovernorAddress 0x8a1cDA8dee421cD06023470608605934c16A05a0 --pollingIntervalSeconds 1", "propmon": "yarn propmon:service & yarn propmon:ui" }, "devDependencies": { - "@arbitrum/sdk": "^3.1.6", + "@arbitrum/sdk": "^3.1.11", "@ethersproject/abi": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@nomicfoundation/hardhat-chai-matchers": "^1.0.4", diff --git a/src-ts/proposalMonitorCli.ts b/src-ts/proposalMonitorCli.ts index 6b48909b..737bb3e6 100644 --- a/src-ts/proposalMonitorCli.ts +++ b/src-ts/proposalMonitorCli.ts @@ -295,8 +295,9 @@ const main = async () => { if (options.writeMode) { const electionCreator = new SecurityCouncilElectionCreator( govChainSignerOrProvider as Wallet, - options.nomineeElectionGovernorAddress, - "0x7eCfBaa8742fDf5756DAC92fbc8b90a19b8815bF" + govChainProvider, + l1Provider, + options.nomineeElectionGovernorAddress ); electionCreator.run(); } diff --git a/src-ts/securityCouncilElectionCreator.ts b/src-ts/securityCouncilElectionCreator.ts index fd86e6ce..95cd0e61 100644 --- a/src-ts/securityCouncilElectionCreator.ts +++ b/src-ts/securityCouncilElectionCreator.ts @@ -1,25 +1,28 @@ import { Wallet } from "ethers"; -import { Multicall2__factory } from "../token-bridge-contracts/build/types"; import { SecurityCouncilNomineeElectionGovernor__factory } from "../typechain-types"; - +import { ArbitrumProvider } from "@arbitrum/sdk"; +import { JsonRpcProvider } from "@ethersproject/providers"; export class SecurityCouncilElectionCreator { retryTime = 10 * 1000; public constructor( public readonly connectedSigner: Wallet, - public readonly nomineeElectionGovAddress: string, - public readonly multicallAddress: string + public readonly govChainProvider: JsonRpcProvider, + public readonly parentChainProvider: JsonRpcProvider, + public readonly nomineeElectionGovAddress: string ) {} public async checkAndCreateElection() { - const multicall = Multicall2__factory.connect( - this.multicallAddress, - this.connectedSigner.provider - ); const gov = SecurityCouncilNomineeElectionGovernor__factory.connect( this.nomineeElectionGovAddress, this.connectedSigner.provider ); - const parentChainTimestamp = await multicall.getCurrentBlockTimestamp(); + const arbProvider = new ArbitrumProvider(this.govChainProvider); + + const { l1BlockNumber } = await arbProvider.getBlock(await arbProvider.getBlockNumber()); + const { timestamp: parentChainTimestamp } = await this.parentChainProvider.getBlock( + l1BlockNumber + ); + const electionTimestamp = await gov.electionToTimestamp(await gov.electionCount()); const timeToElectionSeconds = electionTimestamp.sub(parentChainTimestamp).toNumber(); diff --git a/yarn.lock b/yarn.lock index e0de3737..874201ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,10 +28,10 @@ "@openzeppelin/contracts-upgradeable" "4.5.2" hardhat "^2.6.6" -"@arbitrum/sdk@^3.1.6": - version "3.1.6" - resolved "https://registry.npmjs.org/@arbitrum/sdk/-/sdk-3.1.6.tgz" - integrity sha512-wY7RHmvY26yc/OuwpJY+kjgAmUJZDGDXaQxfSQTp2t6sSFO+8oFFVsKIthBCY2RpDGFUVTGpRjCUEXiuJ6/SFA== +"@arbitrum/sdk@^3.1.11": + version "3.1.11" + resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.1.11.tgz#14fa67daceef7568b949e4a2695d561dd47eec5b" + integrity sha512-qD+igbOn8IoBH6ofvoV8OVYiEv/Dhszw9mFNp1QDY6srBihGAh/cUuA1PQ+tBSdhYda+gWcELBT5kbbVkpbE9w== dependencies: "@ethersproject/address" "^5.0.8" "@ethersproject/bignumber" "^5.1.1"