Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Make timelock configs synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
abandeali1 committed Nov 18, 2019
1 parent 2aafed7 commit e31171a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/migrations/src/test_contract_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';

import { getConfigsByChainId } from './utils/configs_by_chain';
import { getTimelockRegistrationsAsync } from './utils/timelocks';
import { getTimelockRegistrationsByChainId } from './utils/timelocks';

// NOTE: add your own Infura Project ID to RPC urls before running
const INFURA_PROJECT_ID = '';
Expand Down Expand Up @@ -324,7 +324,7 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise<vo
}

async function verifyZeroExGovernorConfigsAsync(): Promise<void> {
const timelockRegistrations = await getTimelockRegistrationsAsync(provider);
const timelockRegistrations = getTimelockRegistrationsByChainId(chainId);
for (const timelockRegistration of timelockRegistrations) {
const actualRegistration = await governor
.functionCallTimeLocks(timelockRegistration.functionSelector, timelockRegistration.destination)
Expand Down
4 changes: 2 additions & 2 deletions packages/migrations/src/testnet_migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { LogWithDecodedArgs, SupportedProvider, TxData } from 'ethereum-types';
import { getConfigsByChainId } from './utils/configs_by_chain';
import { constants } from './utils/constants';
import { providerFactory } from './utils/provider_factory';
import { getTimelockRegistrationsAsync } from './utils/timelocks';
import { getTimelockRegistrationsByChainId } from './utils/timelocks';

async function submitAndExecuteTransactionAsync(
governor: ZeroExGovernorContract,
Expand Down Expand Up @@ -106,7 +106,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider, txDefaults);
const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider, txDefaults);

const customTimeLocks = await getTimelockRegistrationsAsync(provider);
const customTimeLocks = getTimelockRegistrationsByChainId(chainId.toNumber());

const governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
multisigArtifacts.ZeroExGovernor,
Expand Down
8 changes: 3 additions & 5 deletions packages/migrations/src/utils/timelocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { ExchangeContract } from '@0x/contracts-exchange';
import { StakingContract, StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking';
import { IAuthorizableContract, IOwnableContract } from '@0x/contracts-utils';
import { Web3ProviderEngine } from '@0x/subproviders';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';

import { constants } from './constants';

Expand All @@ -18,11 +17,10 @@ export interface TimelockRegistration {
* Gets the custom timelock configs that correspond the the network of the given provider.
* @param provider Web3 provider instance.
*/
export async function getTimelockRegistrationsAsync(provider: SupportedProvider): Promise<TimelockRegistration[]> {
const web3Wrapper = new Web3Wrapper(provider);
const chainId = await web3Wrapper.getChainIdAsync();
export function getTimelockRegistrationsByChainId(chainId: number): TimelockRegistration[] {
const deployedAddresses = getContractAddressesForChainOrThrow(chainId);

const provider = new Web3ProviderEngine();
const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider);
const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider);
const zrxVault = new ZrxVaultContract(constants.NULL_ADDRESS, provider);
Expand Down

0 comments on commit e31171a

Please sign in to comment.