Skip to content

Commit

Permalink
use ArbitrumProvider to get l1 block timestamp (not multicall)
Browse files Browse the repository at this point in the history
  • Loading branch information
DZGoldman committed Sep 14, 2023
1 parent aaf67d6 commit 2b37ff5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions src-ts/proposalMonitorCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
21 changes: 12 additions & 9 deletions src-ts/securityCouncilElectionCreator.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2b37ff5

Please sign in to comment.