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