Merge pull request #2271 from 0xProject/feat/3.0/zero-ex-governor
Rename AssetProxyOwner to ZeroExGovernor
This commit is contained in:
commit
083216a0c6
@ -16,7 +16,7 @@ import {
|
||||
ExchangeContract,
|
||||
Ownable,
|
||||
} from '@0x/contracts-exchange';
|
||||
import { artifacts as multisigArtifacts, AssetProxyOwnerContract } from '@0x/contracts-multisig';
|
||||
import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig';
|
||||
import {
|
||||
artifacts as stakingArtifacts,
|
||||
ReadOnlyProxyContract,
|
||||
@ -76,7 +76,7 @@ async function batchRegisterAssetProxyAsync(
|
||||
*/
|
||||
async function batchTransferOwnershipAsync(
|
||||
owner: string,
|
||||
newOwner: AssetProxyOwnerContract,
|
||||
newOwner: ZeroExGovernorContract,
|
||||
ownedContracts: Ownable[],
|
||||
): Promise<void> {
|
||||
for (const ownedContract of ownedContracts) {
|
||||
@ -115,7 +115,7 @@ export class DeploymentManager {
|
||||
public static protocolFeeMultiplier = new BigNumber(150000);
|
||||
|
||||
public assetProxies: AssetProxyContracts;
|
||||
public assetProxyOwner: AssetProxyOwnerContract;
|
||||
public governor: ZeroExGovernorContract;
|
||||
public exchange: ExchangeContract;
|
||||
public staking: StakingContracts;
|
||||
public tokens: TokenContracts;
|
||||
@ -142,8 +142,8 @@ export class DeploymentManager {
|
||||
exchangeArtifacts,
|
||||
new BigNumber(chainId),
|
||||
);
|
||||
const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
multisigArtifacts.AssetProxyOwner,
|
||||
const governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
multisigArtifacts.ZeroExGovernor,
|
||||
environment.provider,
|
||||
txDefaults,
|
||||
multisigArtifacts,
|
||||
@ -168,10 +168,10 @@ export class DeploymentManager {
|
||||
await DeploymentManager._configureExchangeWithStakingAsync(exchange, staking, owner);
|
||||
|
||||
// Authorize the asset-proxy owner in the staking proxy and in the zrx vault.
|
||||
await staking.stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address, {
|
||||
await staking.stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, {
|
||||
from: owner,
|
||||
});
|
||||
await staking.zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address, {
|
||||
await staking.zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, {
|
||||
from: owner,
|
||||
});
|
||||
|
||||
@ -180,7 +180,7 @@ export class DeploymentManager {
|
||||
await staking.zrxVault.removeAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner });
|
||||
|
||||
// Transfer complete ownership of the system to the asset proxy owner.
|
||||
await batchTransferOwnershipAsync(owner, assetProxyOwner, [
|
||||
await batchTransferOwnershipAsync(owner, governor, [
|
||||
assetProxies.erc20Proxy,
|
||||
assetProxies.erc721Proxy,
|
||||
assetProxies.erc1155Proxy,
|
||||
@ -190,7 +190,7 @@ export class DeploymentManager {
|
||||
staking.stakingProxy,
|
||||
]);
|
||||
|
||||
return new DeploymentManager(assetProxies, assetProxyOwner, exchange, staking, tokens);
|
||||
return new DeploymentManager(assetProxies, governor, exchange, staking, tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,13 +443,13 @@ export class DeploymentManager {
|
||||
|
||||
private constructor(
|
||||
assetProxies: AssetProxyContracts,
|
||||
assetProxyOwner: AssetProxyOwnerContract,
|
||||
governor: ZeroExGovernorContract,
|
||||
exchange: ExchangeContract,
|
||||
staking: StakingContracts,
|
||||
tokens: TokenContracts,
|
||||
) {
|
||||
this.assetProxies = assetProxies;
|
||||
this.assetProxyOwner = assetProxyOwner;
|
||||
this.governor = governor;
|
||||
this.exchange = exchange;
|
||||
this.staking = staking;
|
||||
this.tokens = tokens;
|
||||
|
@ -42,14 +42,14 @@ blockchainTests('Deployment Manager', env => {
|
||||
describe('asset proxy owner', () => {
|
||||
it('should be owned by `owner`', async () => {
|
||||
// Ensure that the owners of the asset proxy only contain the owner.
|
||||
const owners = await deploymentManager.assetProxyOwner.getOwners.callAsync();
|
||||
const owners = await deploymentManager.governor.getOwners.callAsync();
|
||||
expect(owners).to.be.deep.eq([owner]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('asset proxies', () => {
|
||||
it('should be owned be the asset proxy owner', async () => {
|
||||
await batchAssertOwnerAsync(deploymentManager.assetProxyOwner.address, [
|
||||
await batchAssertOwnerAsync(deploymentManager.governor.address, [
|
||||
deploymentManager.assetProxies.erc1155Proxy,
|
||||
deploymentManager.assetProxies.erc20Proxy,
|
||||
deploymentManager.assetProxies.erc721Proxy,
|
||||
@ -95,7 +95,7 @@ blockchainTests('Deployment Manager', env => {
|
||||
describe('exchange', () => {
|
||||
it('should be owned by the asset proxy owner', async () => {
|
||||
const exchangeOwner = await deploymentManager.exchange.owner.callAsync();
|
||||
expect(exchangeOwner).to.be.eq(deploymentManager.assetProxyOwner.address);
|
||||
expect(exchangeOwner).to.be.eq(deploymentManager.governor.address);
|
||||
});
|
||||
|
||||
/*
|
||||
@ -103,7 +103,7 @@ blockchainTests('Deployment Manager', env => {
|
||||
made an Authorizable contract.
|
||||
it('should have authorized the asset proxy owner', async () => {
|
||||
const isAuthorized = await deploymentManager.exchange.owner.callAsync(
|
||||
deploymentManager.assetProxyOwner.address,
|
||||
deploymentManager.governor.address,
|
||||
);
|
||||
expect(isAuthorized).to.be.true();
|
||||
});
|
||||
@ -123,12 +123,12 @@ blockchainTests('Deployment Manager', env => {
|
||||
describe('staking', () => {
|
||||
it('should be owned by the asset proxy owner', async () => {
|
||||
const stakingOwner = await deploymentManager.staking.stakingProxy.owner.callAsync();
|
||||
expect(stakingOwner).to.be.eq(deploymentManager.assetProxyOwner.address);
|
||||
expect(stakingOwner).to.be.eq(deploymentManager.governor.address);
|
||||
});
|
||||
|
||||
it('should have authorized the asset proxy owner in the staking proxy', async () => {
|
||||
const isAuthorized = await deploymentManager.staking.stakingProxy.authorized.callAsync(
|
||||
deploymentManager.assetProxyOwner.address,
|
||||
deploymentManager.governor.address,
|
||||
);
|
||||
expect(isAuthorized).to.be.true();
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
ExchangeProtocolFeeMultiplierEventArgs,
|
||||
Ownable,
|
||||
} from '@0x/contracts-exchange';
|
||||
import { artifacts as multisigArtifacts, AssetProxyOwnerContract } from '@0x/contracts-multisig';
|
||||
import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig';
|
||||
import {
|
||||
artifacts as stakingArtifacts,
|
||||
constants as stakingConstants,
|
||||
@ -43,7 +43,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => {
|
||||
let owner: string;
|
||||
|
||||
// Contract Instances
|
||||
let assetProxyOwner: AssetProxyOwnerContract;
|
||||
let governor: ZeroExGovernorContract;
|
||||
let erc20Proxy: ERC20ProxyContract;
|
||||
let erc721Proxy: ERC721ProxyContract;
|
||||
let erc1155Proxy: ERC1155ProxyContract;
|
||||
@ -75,11 +75,11 @@ blockchainTests('Deployment and Configuration End to End Tests', env => {
|
||||
from: owner,
|
||||
};
|
||||
|
||||
// Deploy AssetProxyOwner. For the purposes of this test, we will assume that
|
||||
// the AssetProxyOwner does not know what destinations will be needed during
|
||||
// Deploy ZeroExGovernor. For the purposes of this test, we will assume that
|
||||
// the ZeroExGovernor does not know what destinations will be needed during
|
||||
// construction.
|
||||
assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
multisigArtifacts.AssetProxyOwner,
|
||||
governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
multisigArtifacts.ZeroExGovernor,
|
||||
env.provider,
|
||||
txDefaults,
|
||||
multisigArtifacts,
|
||||
@ -387,7 +387,7 @@ blockchainTests('Deployment and Configuration End to End Tests', env => {
|
||||
expect(isAuthorized).to.be.false();
|
||||
|
||||
// Authorize the asset-proxy owner.
|
||||
receipt = await contract.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address, {
|
||||
receipt = await contract.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address, {
|
||||
from: owner,
|
||||
});
|
||||
|
||||
@ -396,21 +396,21 @@ blockchainTests('Deployment and Configuration End to End Tests', env => {
|
||||
receipt.logs,
|
||||
AuthorizableEvents.AuthorizedAddressAdded,
|
||||
);
|
||||
expect(logs).to.be.deep.eq([{ target: assetProxyOwner.address, caller: owner }]);
|
||||
expect(logs).to.be.deep.eq([{ target: governor.address, caller: owner }]);
|
||||
|
||||
// Ensure that the asset-proxy owner was actually authorized.
|
||||
isAuthorized = await contract.authorized.callAsync(assetProxyOwner.address);
|
||||
isAuthorized = await contract.authorized.callAsync(governor.address);
|
||||
expect(isAuthorized).to.be.true();
|
||||
}
|
||||
|
||||
// Transfers ownership of a contract to the asset-proxy owner, and ensures that the change was actually made.
|
||||
async function transferOwnershipAndAssertSuccessAsync(contract: Ownable): Promise<void> {
|
||||
// Transfer ownership to the new owner.
|
||||
await contract.transferOwnership.awaitTransactionSuccessAsync(assetProxyOwner.address, { from: owner });
|
||||
await contract.transferOwnership.awaitTransactionSuccessAsync(governor.address, { from: owner });
|
||||
|
||||
// Ensure that the owner address has been updated.
|
||||
const ownerAddress = await contract.owner.callAsync();
|
||||
expect(ownerAddress).to.be.eq(assetProxyOwner.address);
|
||||
expect(ownerAddress).to.be.eq(governor.address);
|
||||
}
|
||||
|
||||
it('should transfer authorization of the owner to the asset-proxy owner in the staking contracts', async () => {
|
||||
|
@ -24,7 +24,7 @@ import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
||||
|
||||
|
||||
contract AssetProxyOwner is
|
||||
contract ZeroExGovernor is
|
||||
MultiSigWalletWithTimeLock
|
||||
{
|
||||
using LibBytes for bytes;
|
@ -19,12 +19,12 @@
|
||||
pragma solidity ^0.5.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../src/AssetProxyOwner.sol";
|
||||
import "../src/ZeroExGovernor.sol";
|
||||
|
||||
|
||||
// solhint-disable no-empty-blocks
|
||||
contract TestAssetProxyOwner is
|
||||
AssetProxyOwner
|
||||
contract TestZeroExGovernor is
|
||||
ZeroExGovernor
|
||||
{
|
||||
constructor (
|
||||
bytes4[] memory _functionSelectors,
|
||||
@ -35,7 +35,7 @@ contract TestAssetProxyOwner is
|
||||
uint256 _defaultSecondsTimeLocked
|
||||
)
|
||||
public
|
||||
AssetProxyOwner(
|
||||
ZeroExGovernor(
|
||||
_functionSelectors,
|
||||
_destinations,
|
||||
_functionCallTimeLockSeconds,
|
@ -34,7 +34,7 @@
|
||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||
},
|
||||
"config": {
|
||||
"abis": "./generated-artifacts/@(AssetProxyOwner|ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json",
|
||||
"abis": "./generated-artifacts/@(ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther|TestZeroExGovernor|ZeroExGovernor).json",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||
},
|
||||
"repository": {
|
||||
|
@ -5,17 +5,17 @@
|
||||
*/
|
||||
import { ContractArtifact } from 'ethereum-types';
|
||||
|
||||
import * as AssetProxyOwner from '../generated-artifacts/AssetProxyOwner.json';
|
||||
import * as ContractCallReceiver from '../generated-artifacts/ContractCallReceiver.json';
|
||||
import * as MultiSigWallet from '../generated-artifacts/MultiSigWallet.json';
|
||||
import * as MultiSigWalletWithTimeLock from '../generated-artifacts/MultiSigWalletWithTimeLock.json';
|
||||
import * as TestAssetProxyOwner from '../generated-artifacts/TestAssetProxyOwner.json';
|
||||
import * as TestRejectEther from '../generated-artifacts/TestRejectEther.json';
|
||||
import * as TestZeroExGovernor from '../generated-artifacts/TestZeroExGovernor.json';
|
||||
import * as ZeroExGovernor from '../generated-artifacts/ZeroExGovernor.json';
|
||||
export const artifacts = {
|
||||
AssetProxyOwner: AssetProxyOwner as ContractArtifact,
|
||||
MultiSigWallet: MultiSigWallet as ContractArtifact,
|
||||
MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
|
||||
ZeroExGovernor: ZeroExGovernor as ContractArtifact,
|
||||
ContractCallReceiver: ContractCallReceiver as ContractArtifact,
|
||||
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
|
||||
TestRejectEther: TestRejectEther as ContractArtifact,
|
||||
TestZeroExGovernor: TestZeroExGovernor as ContractArtifact,
|
||||
};
|
||||
|
@ -3,9 +3,9 @@
|
||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
export * from '../generated-wrappers/asset_proxy_owner';
|
||||
export * from '../generated-wrappers/contract_call_receiver';
|
||||
export * from '../generated-wrappers/multi_sig_wallet';
|
||||
export * from '../generated-wrappers/multi_sig_wallet_with_time_lock';
|
||||
export * from '../generated-wrappers/test_asset_proxy_owner';
|
||||
export * from '../generated-wrappers/test_reject_ether';
|
||||
export * from '../generated-wrappers/test_zero_ex_governor';
|
||||
export * from '../generated-wrappers/zero_ex_governor';
|
||||
|
@ -1,2 +1,2 @@
|
||||
export * from './multi_sig_wrapper';
|
||||
export * from './asset_proxy_owner_wrapper';
|
||||
export * from './zero_ex_governor_wrapper';
|
||||
|
@ -3,13 +3,13 @@ import { AbiEncoder, BigNumber } from '@0x/utils';
|
||||
import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { AssetProxyOwnerContract, AssetProxyOwnerSubmissionEventArgs, TestAssetProxyOwnerContract } from '../../src';
|
||||
import { TestZeroExGovernorContract, ZeroExGovernorContract, ZeroExGovernorSubmissionEventArgs } from '../../src';
|
||||
|
||||
// tslint:disable: no-unnecessary-type-assertion
|
||||
export class AssetProxyOwnerWrapper {
|
||||
private readonly _assetProxyOwner: AssetProxyOwnerContract | TestAssetProxyOwnerContract;
|
||||
constructor(assetproxyOwnerContract: AssetProxyOwnerContract | TestAssetProxyOwnerContract) {
|
||||
this._assetProxyOwner = assetproxyOwnerContract;
|
||||
export class ZeroExGovernorWrapper {
|
||||
private readonly _governor: ZeroExGovernorContract | TestZeroExGovernorContract;
|
||||
constructor(assetproxyOwnerContract: ZeroExGovernorContract | TestZeroExGovernorContract) {
|
||||
this._governor = assetproxyOwnerContract;
|
||||
}
|
||||
public async submitTransactionAsync(
|
||||
data: string[],
|
||||
@ -20,13 +20,13 @@ export class AssetProxyOwnerWrapper {
|
||||
const values = opts.values === undefined ? data.map(() => constants.ZERO_AMOUNT) : opts.values;
|
||||
const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])');
|
||||
const batchTransactionData = batchTransactionEncoder.encode([data, destinations, values]);
|
||||
const txReceipt = await this._assetProxyOwner.submitTransaction.awaitTransactionSuccessAsync(
|
||||
const txReceipt = await this._governor.submitTransaction.awaitTransactionSuccessAsync(
|
||||
hexRandom(20), // submitTransaction will fail if this is a null address
|
||||
constants.ZERO_AMOUNT,
|
||||
batchTransactionData,
|
||||
{ from },
|
||||
);
|
||||
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<AssetProxyOwnerSubmissionEventArgs>).args.transactionId;
|
||||
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<ZeroExGovernorSubmissionEventArgs>).args.transactionId;
|
||||
return { txReceipt, txId };
|
||||
}
|
||||
public async submitConfirmAndExecuteTransactionAsync(
|
||||
@ -39,12 +39,12 @@ export class AssetProxyOwnerWrapper {
|
||||
const submitResults = await this.submitTransactionAsync(data, destinations, signerAddresses[0], opts);
|
||||
const requiredSignatures = opts.requiredSignatures === undefined ? 2 : opts.requiredSignatures;
|
||||
for (const index of _.range(1, requiredSignatures)) {
|
||||
await this._assetProxyOwner.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, {
|
||||
await this._governor.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, {
|
||||
from: signerAddresses[index],
|
||||
});
|
||||
}
|
||||
await increaseTimeAndMineBlockAsync(increaseTimeSeconds);
|
||||
const executionTxReceipt = await this._assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(
|
||||
const executionTxReceipt = await this._governor.executeTransaction.awaitTransactionSuccessAsync(
|
||||
submitResults.txId,
|
||||
{ from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress },
|
||||
);
|
@ -6,18 +6,18 @@ import * as _ from 'lodash';
|
||||
|
||||
import {
|
||||
artifacts,
|
||||
AssetProxyOwnerExecutionEventArgs,
|
||||
AssetProxyOwnerFunctionCallTimeLockRegistrationEventArgs,
|
||||
AssetProxyOwnerWrapper,
|
||||
ContractCallReceiverContract,
|
||||
ContractCallReceiverEventArgs,
|
||||
TestAssetProxyOwnerContract,
|
||||
TestZeroExGovernorContract,
|
||||
ZeroExGovernorExecutionEventArgs,
|
||||
ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs,
|
||||
ZeroExGovernorWrapper,
|
||||
} from '../src';
|
||||
|
||||
// tslint:disable: no-unnecessary-type-assertion
|
||||
blockchainTests.resets('AssetProxyOwner', env => {
|
||||
let assetProxyOwner: TestAssetProxyOwnerContract;
|
||||
let assetProxyOwnerWrapper: AssetProxyOwnerWrapper;
|
||||
blockchainTests.resets('ZeroExGovernor', env => {
|
||||
let governor: TestZeroExGovernorContract;
|
||||
let governorWrapper: ZeroExGovernorWrapper;
|
||||
let receiver: ContractCallReceiverContract;
|
||||
let signerAddresses: string[];
|
||||
let notSignerAddress: string;
|
||||
@ -31,8 +31,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const accounts = await env.web3Wrapper.getAvailableAddressesAsync();
|
||||
signerAddresses = accounts.slice(0, TOTAL_SIGNERS);
|
||||
notSignerAddress = accounts[TOTAL_SIGNERS];
|
||||
assetProxyOwner = await TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
governor = await TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -46,11 +46,11 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
await env.web3Wrapper.awaitTransactionMinedAsync(
|
||||
await env.web3Wrapper.sendTransactionAsync({
|
||||
from: signerAddresses[0],
|
||||
to: assetProxyOwner.address,
|
||||
to: governor.address,
|
||||
value: INITIAL_BALANCE,
|
||||
}),
|
||||
);
|
||||
assetProxyOwnerWrapper = new AssetProxyOwnerWrapper(assetProxyOwner);
|
||||
governorWrapper = new ZeroExGovernorWrapper(governor);
|
||||
receiver = await ContractCallReceiverContract.deployFrom0xArtifactAsync(
|
||||
artifacts.ContractCallReceiver,
|
||||
env.provider,
|
||||
@ -82,8 +82,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
blockchainTests.resets('constructor', () => {
|
||||
it('should fail if destinations.length != functionSelectors.length', async () => {
|
||||
const reg = createFunctionRegistration(1, 2, 1);
|
||||
const tx = TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const tx = TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -98,8 +98,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should fail if functionCallTimeLockSeconds.length != functionSelectors.length', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 2);
|
||||
const tx = TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const tx = TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -114,8 +114,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should fail if functionCallTimeLockSeconds.length != destinations.length', async () => {
|
||||
const reg = createFunctionRegistration(2, 1, 1);
|
||||
const tx = TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const tx = TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -129,8 +129,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
await expect(tx).to.revertWith(RevertReason.EqualLengthsRequired);
|
||||
});
|
||||
it('should allow no function calls to be registered', async () => {
|
||||
const tx = TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const tx = TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -145,8 +145,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should register a single functon call', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const apOwner = await TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const governorContract = await TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -157,7 +157,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
new BigNumber(REQUIRED_SIGNERS),
|
||||
new BigNumber(DEFAULT_TIME_LOCK),
|
||||
);
|
||||
const timelock = await apOwner.functionCallTimeLocks.callAsync(
|
||||
const timelock = await governorContract.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
@ -166,8 +166,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should register multiple function calls', async () => {
|
||||
const reg = createFunctionRegistration(2, 2, 2);
|
||||
const apOwner = await TestAssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestAssetProxyOwner,
|
||||
const governorContract = await TestZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestZeroExGovernor,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
@ -179,7 +179,10 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
new BigNumber(DEFAULT_TIME_LOCK),
|
||||
);
|
||||
for (const [index, selector] of reg.functionSelectors.entries()) {
|
||||
const timelock = await apOwner.functionCallTimeLocks.callAsync(selector, reg.destinations[index]);
|
||||
const timelock = await governorContract.functionCallTimeLocks.callAsync(
|
||||
selector,
|
||||
reg.destinations[index],
|
||||
);
|
||||
expect(timelock[0]).to.equal(true);
|
||||
expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[index]);
|
||||
}
|
||||
@ -189,7 +192,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
blockchainTests.resets('registerFunctionCall', () => {
|
||||
it('should revert if not called by wallet', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const tx = assetProxyOwner.registerFunctionCall.awaitTransactionSuccessAsync(
|
||||
const tx = governor.registerFunctionCall.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -200,7 +203,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should register a function call', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const txReceipt = await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
const txReceipt = await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -208,13 +211,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
);
|
||||
expect(txReceipt.logs.length).to.eq(1);
|
||||
const logArgs = (txReceipt.logs[0] as LogWithDecodedArgs<
|
||||
AssetProxyOwnerFunctionCallTimeLockRegistrationEventArgs
|
||||
ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs
|
||||
>).args;
|
||||
expect(logArgs.functionSelector).to.eq(reg.functionSelectors[0]);
|
||||
expect(logArgs.destination).to.eq(reg.destinations[0]);
|
||||
expect(logArgs.hasCustomTimeLock).to.eq(true);
|
||||
expect(logArgs.newSecondsTimeLocked).to.bignumber.eq(reg.functionCallTimeLockSeconds[0]);
|
||||
const timelock = await assetProxyOwner.functionCallTimeLocks.callAsync(
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
@ -223,20 +226,20 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should be able to overwrite existing function calls', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const newTimeLock = reg.functionCallTimeLockSeconds[0].plus(1000);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
newTimeLock,
|
||||
);
|
||||
const timelock = await assetProxyOwner.functionCallTimeLocks.callAsync(
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
@ -245,19 +248,19 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should clear the function timelock if hasCustomTimeLock is set to false', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
false,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const timelock = await assetProxyOwner.functionCallTimeLocks.callAsync(
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
@ -268,7 +271,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
|
||||
describe('assertValidFunctionCall', () => {
|
||||
it('should revert if the data is less than 4 bytes long', async () => {
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
constants.ZERO_AMOUNT,
|
||||
constants.NULL_BYTES,
|
||||
constants.NULL_ADDRESS,
|
||||
@ -284,7 +287,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp);
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -293,7 +296,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should revert if a registered function is called before the custom timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -301,7 +304,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
);
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp);
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -310,7 +313,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should revert if a registered function is called before the custom timelock and after the default timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -318,7 +321,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
);
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK);
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -329,7 +332,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK);
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -338,7 +341,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should be successful if a registered function is called after the custom timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -348,7 +351,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -357,14 +360,14 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
});
|
||||
it('should allow a custom timelock to be set to 0', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
new BigNumber(latestTimestamp),
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
@ -390,15 +393,15 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const value = values === undefined ? constants.ZERO_AMOUNT : values[i];
|
||||
expect(contractCallLogArgs.value).to.bignumber.eq(value);
|
||||
});
|
||||
const executionLog = logs[data.length] as LogWithDecodedArgs<AssetProxyOwnerExecutionEventArgs>;
|
||||
const executionLog = logs[data.length] as LogWithDecodedArgs<ZeroExGovernorExecutionEventArgs>;
|
||||
expect(executionLog.event).to.eq('Execution');
|
||||
expect(executionLog.args.transactionId).to.bignumber.eq(txId);
|
||||
}
|
||||
it('should revert if the transaction is not confirmed by the required amount of signers', async () => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
from: signerAddresses[1],
|
||||
});
|
||||
expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed);
|
||||
@ -406,8 +409,8 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should revert if the transaction is not confirmed by the required amount of signers and called by the submitter', async () => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
from: signerAddresses[0],
|
||||
});
|
||||
expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed);
|
||||
@ -415,7 +418,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should be able to execute an unregistered function after the default timelock with no value', async () => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -427,7 +430,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const values = [INITIAL_BALANCE];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -440,13 +443,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -458,13 +461,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = constants.ZERO_AMOUNT;
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -476,14 +479,14 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
const values = [INITIAL_BALANCE];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -495,7 +498,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should be able to call multiple functions with a single destination and no values', async () => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -513,7 +516,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver2.address];
|
||||
const values = [INITIAL_BALANCE.dividedToIntegerBy(4), INITIAL_BALANCE.dividedToIntegerBy(3)];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -526,13 +529,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -544,13 +547,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -561,7 +564,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should be able to execute a transaction if called by any address', async () => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -574,7 +577,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
// NOTE: elements of `data` must be at least 4 bytes long
|
||||
const data = [constants.NULL_BYTES4];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -585,7 +588,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should not call a function if the input array lengths are 0', async () => {
|
||||
const data: string[] = [];
|
||||
const destinations: string[] = [];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -596,7 +599,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should revert if destinations.length != data.length', async () => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -608,7 +611,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const values = [constants.ZERO_AMOUNT, constants.ZERO_AMOUNT];
|
||||
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -620,20 +623,20 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should revert if the transaction is already executed', async () => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
DEFAULT_TIME_LOCK,
|
||||
);
|
||||
const tx = assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(results.txId);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId);
|
||||
expect(tx).to.revertWith(RevertReason.TxAlreadyExecuted);
|
||||
});
|
||||
it('should revert if the only call is unsuccessful', async () => {
|
||||
const alwaysRevertSelector = '0xF1F2F3F4';
|
||||
const data = [alwaysRevertSelector];
|
||||
const destinations = [receiver.address];
|
||||
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -645,7 +648,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
const alwaysRevertSelector = '0xF1F2F3F4';
|
||||
const data = [hexRandom(), alwaysRevertSelector];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -656,15 +659,15 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
it('should be able to call registerFunctionCall after the default timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const data = [
|
||||
assetProxyOwner.registerFunctionCall.getABIEncodedTransactionData(
|
||||
governor.registerFunctionCall.getABIEncodedTransactionData(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
),
|
||||
];
|
||||
const destinations = [assetProxyOwner.address];
|
||||
const results = await assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
const destinations = [governor.address];
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
signerAddresses,
|
||||
@ -672,7 +675,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
|
||||
);
|
||||
expect(results.executionTxReceipt.logs.length).to.eq(2);
|
||||
const registrationLogArgs = (results.executionTxReceipt.logs[0] as LogWithDecodedArgs<
|
||||
AssetProxyOwnerFunctionCallTimeLockRegistrationEventArgs
|
||||
ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs
|
||||
>).args;
|
||||
expect(registrationLogArgs.destination).to.eq(reg.destinations[0]);
|
||||
expect(registrationLogArgs.functionSelector).to.eq(reg.functionSelectors[0]);
|
@ -3,12 +3,12 @@
|
||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||
"files": [
|
||||
"generated-artifacts/AssetProxyOwner.json",
|
||||
"generated-artifacts/ContractCallReceiver.json",
|
||||
"generated-artifacts/MultiSigWallet.json",
|
||||
"generated-artifacts/MultiSigWalletWithTimeLock.json",
|
||||
"generated-artifacts/TestAssetProxyOwner.json",
|
||||
"generated-artifacts/TestRejectEther.json"
|
||||
"generated-artifacts/TestRejectEther.json",
|
||||
"generated-artifacts/TestZeroExGovernor.json",
|
||||
"generated-artifacts/ZeroExGovernor.json"
|
||||
],
|
||||
"exclude": ["./deploy/solc/solc_bin"]
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export enum ContractName {
|
||||
DummyERC20Token = 'DummyERC20Token',
|
||||
EtherToken = 'WETH9',
|
||||
DutchAuction = 'DutchAuction',
|
||||
AssetProxyOwner = 'AssetProxyOwner',
|
||||
ZeroExGovernor = 'ZeroExGovernor',
|
||||
AccountLevels = 'AccountLevels',
|
||||
EtherDelta = 'EtherDelta',
|
||||
Arbitrage = 'Arbitrage',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
|
||||
import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange';
|
||||
import { artifacts, AssetProxyOwnerContract, AssetProxyOwnerSubmissionEventArgs } from '@0x/contracts-multisig';
|
||||
import { artifacts, ZeroExGovernorContract, ZeroExGovernorSubmissionEventArgs } from '@0x/contracts-multisig';
|
||||
import {
|
||||
artifacts as stakingArtifacts,
|
||||
ReadOnlyProxyContract,
|
||||
@ -17,19 +17,19 @@ import { constants } from './utils/constants';
|
||||
import { providerFactory } from './utils/provider_factory';
|
||||
|
||||
async function submitAndExecuteTransactionAsync(
|
||||
assetProxyOwner: AssetProxyOwnerContract,
|
||||
governor: ZeroExGovernorContract,
|
||||
destination: string,
|
||||
data: string,
|
||||
): Promise<void> {
|
||||
const txReceipt = await assetProxyOwner.submitTransaction.awaitTransactionSuccessAsync(
|
||||
const txReceipt = await governor.submitTransaction.awaitTransactionSuccessAsync(
|
||||
destination,
|
||||
constants.ZERO_AMOUNT,
|
||||
data,
|
||||
);
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<AssetProxyOwnerSubmissionEventArgs>).args.transactionId;
|
||||
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<ZeroExGovernorSubmissionEventArgs>).args.transactionId;
|
||||
logUtils.log(`${txId} submitted`);
|
||||
await assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(txId);
|
||||
await governor.executeTransaction.awaitTransactionSuccessAsync(txId);
|
||||
logUtils.log(`${txId} executed`);
|
||||
}
|
||||
|
||||
@ -148,8 +148,8 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
|
||||
},
|
||||
];
|
||||
|
||||
const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.AssetProxyOwner,
|
||||
const governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
|
||||
artifacts.ZeroExGovernor,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
@ -169,43 +169,43 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
|
||||
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc1155Proxy);
|
||||
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.multiAssetProxy);
|
||||
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.staticCallProxy);
|
||||
await exchange.transferOwnership.awaitTransactionSuccessAsync(assetProxyOwner.address);
|
||||
await exchange.transferOwnership.awaitTransactionSuccessAsync(governor.address);
|
||||
logUtils.log('Exchange configured!');
|
||||
|
||||
logUtils.log('Configuring ZrxVault...');
|
||||
await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address);
|
||||
await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address);
|
||||
logUtils.log('ZrxVault configured!');
|
||||
|
||||
logUtils.log('Configuring StakingProxy...');
|
||||
await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address);
|
||||
await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address);
|
||||
logUtils.log('StakingProxy configured!');
|
||||
|
||||
logUtils.log('Transfering ownership of 2.0 contracts...');
|
||||
const oldAssetProxyOwner = new AssetProxyOwnerContract(deployedAddresses.assetProxyOwner, provider, txDefaults);
|
||||
const oldAssetProxyOwner = new ZeroExGovernorContract(deployedAddresses.assetProxyOwner, provider, txDefaults);
|
||||
await submitAndExecuteTransactionAsync(
|
||||
oldAssetProxyOwner,
|
||||
deployedAddresses.exchangeV2, // Exchange 2.1 address
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address),
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address),
|
||||
);
|
||||
await submitAndExecuteTransactionAsync(
|
||||
oldAssetProxyOwner,
|
||||
deployedAddresses.erc20Proxy,
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address),
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address),
|
||||
);
|
||||
await submitAndExecuteTransactionAsync(
|
||||
oldAssetProxyOwner,
|
||||
deployedAddresses.erc721Proxy,
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address),
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address),
|
||||
);
|
||||
await submitAndExecuteTransactionAsync(
|
||||
oldAssetProxyOwner,
|
||||
deployedAddresses.erc1155Proxy,
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address),
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address),
|
||||
);
|
||||
await submitAndExecuteTransactionAsync(
|
||||
oldAssetProxyOwner,
|
||||
deployedAddresses.multiAssetProxy,
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address),
|
||||
ownableInterface.transferOwnership.getABIEncodedTransactionData(governor.address),
|
||||
);
|
||||
logUtils.log('Ownership transferred!');
|
||||
|
||||
@ -245,7 +245,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
|
||||
functionCalls.map(item => item.destination),
|
||||
functionCalls.map(() => constants.ZERO_AMOUNT),
|
||||
]);
|
||||
await submitAndExecuteTransactionAsync(assetProxyOwner, assetProxyOwner.address, batchTransactionData);
|
||||
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user