@0x:contracts-integrations
Addressed review feedback
This commit is contained in:
parent
24e4567b25
commit
3c6957095d
4
.gitignore
vendored
4
.gitignore
vendored
@ -82,7 +82,7 @@ TODO.md
|
||||
packages/testnet-faucets/server/
|
||||
|
||||
# generated contract artifacts/
|
||||
contracts/integration-tests/generated-artifacts/
|
||||
contracts/integrations/generated-artifacts/
|
||||
contracts/staking/generated-artifacts/
|
||||
contracts/coordinator/generated-artifacts/
|
||||
contracts/exchange/generated-artifacts/
|
||||
@ -116,7 +116,7 @@ contracts/dev-utils/build/
|
||||
|
||||
# generated contract wrappers
|
||||
packages/python-contract-wrappers/generated/
|
||||
contracts/integration-tests/generated-wrappers/
|
||||
contracts/integrations/generated-wrappers/
|
||||
contracts/staking/generated-wrappers/
|
||||
contracts/coordinator/generated-wrappers/
|
||||
contracts/exchange/generated-wrappers/
|
||||
|
@ -1,7 +1,7 @@
|
||||
lib
|
||||
.nyc_output
|
||||
/contracts/integration-tests/generated-wrappers
|
||||
/contracts/integration-tests/generated-artifacts
|
||||
/contracts/integrations/generated-wrappers
|
||||
/contracts/integrations/generated-artifacts
|
||||
/contracts/staking/generated-wrappers
|
||||
/contracts/staking/generated-artifacts
|
||||
/contracts/coordinator/generated-wrappers
|
||||
|
@ -1,7 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
|
||||
// TODO(jalextowle): This contract must be included to ensure that `abi-gen`
|
||||
// doesn't fail to run. Remove this contract or remove the contracts directory
|
||||
// depending on whether or not this package should contain packages.
|
||||
contract Empty { } // solhint-disable-line no-empty-blocks
|
@ -1,53 +0,0 @@
|
||||
pragma solidity ^0.5.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-staking/contracts/src/Staking.sol";
|
||||
|
||||
|
||||
contract StakingWithTokens is
|
||||
Staking
|
||||
{
|
||||
address public wethAddress;
|
||||
address public zrxVault;
|
||||
|
||||
bytes4 internal constant WETH_PROXY_ID = 0xf47261b0;
|
||||
|
||||
function setWethAddress(address weth)
|
||||
public
|
||||
{
|
||||
wethAddress = weth;
|
||||
}
|
||||
|
||||
function setZrxVault(address vault)
|
||||
public
|
||||
{
|
||||
zrxVault = vault;
|
||||
}
|
||||
|
||||
function getWethAssetData()
|
||||
public
|
||||
view
|
||||
returns (bytes memory)
|
||||
{
|
||||
return abi.encodeWithSelector(
|
||||
WETH_PROXY_ID,
|
||||
wethAddress
|
||||
);
|
||||
}
|
||||
|
||||
function getWethContract()
|
||||
public
|
||||
view
|
||||
returns (IEtherToken)
|
||||
{
|
||||
return IEtherToken(wethAddress);
|
||||
}
|
||||
|
||||
function getZrxVault()
|
||||
public
|
||||
view
|
||||
returns (IZrxVault)
|
||||
{
|
||||
return IZrxVault(zrxVault);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ This package implements integration tests against 0x's smart contracts and will
|
||||
**Install**
|
||||
|
||||
```bash
|
||||
npm install @0x/contracts-staking --save
|
||||
npm install @0x/contracts-integrations --save
|
||||
```
|
||||
|
||||
## Contributing
|
||||
@ -37,13 +37,13 @@ yarn install
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
PKG=@0x/contracts-integration-tests yarn build
|
||||
PKG=@0x/contracts-integrations yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
PKG=@0x/contracts-integration-tests yarn watch
|
||||
PKG=@0x/contracts-integrations yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
@ -0,0 +1,15 @@
|
||||
pragma solidity ^0.5.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-staking/contracts/test/TestStaking.sol";
|
||||
|
||||
|
||||
// TODO(jalextowle): This contract can be removed when the added to this package.
|
||||
contract TestStakingPlaceholder is
|
||||
TestStaking
|
||||
{
|
||||
constructor(address wethAddress, address zrxVaultAddress)
|
||||
public
|
||||
TestStaking(wethAddress, zrxVaultAddress)
|
||||
{} // solhint-disable-line no-empty-blocks
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@0x/contracts-integration-tests",
|
||||
"name": "@0x/contracts-integrations",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Integration tests for the 0x protocol",
|
||||
"description": "Integrations with the 0x protocol",
|
||||
"main": "lib/src/index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
@ -35,7 +35,7 @@
|
||||
"compile:truffle": "truffle compile"
|
||||
},
|
||||
"config": {
|
||||
"abis": "./generated-artifacts/@(StakingWithTokens).json",
|
||||
"abis": "./generated-artifacts/@(TestStakingPlaceholder).json",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||
},
|
||||
"repository": {
|
@ -5,5 +5,5 @@
|
||||
*/
|
||||
import { ContractArtifact } from 'ethereum-types';
|
||||
|
||||
import * as StakingWithTokens from '../generated-artifacts/StakingWithTokens.json';
|
||||
export const artifacts = { StakingWithTokens: StakingWithTokens as ContractArtifact };
|
||||
import * as TestStakingPlaceholder from '../generated-artifacts/TestStakingPlaceholder.json';
|
||||
export const artifacts = { TestStakingPlaceholder: TestStakingPlaceholder as ContractArtifact };
|
@ -30,7 +30,7 @@ import { BigNumber } from '@0x/utils';
|
||||
import { TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, StakingWithTokensContract } from './';
|
||||
import { artifacts, TestStakingPlaceholderContract } from './';
|
||||
|
||||
/**
|
||||
* Adds a batch of authorities to a list of authorizable contracts.
|
||||
@ -96,9 +96,9 @@ interface AssetProxyContracts {
|
||||
// Contract wrappers for all of the staking contracts
|
||||
interface StakingContracts {
|
||||
readOnlyProxy: ReadOnlyProxyContract;
|
||||
stakingLogic: StakingWithTokensContract;
|
||||
stakingLogic: TestStakingPlaceholderContract;
|
||||
stakingProxy: StakingProxyContract;
|
||||
stakingWrapper: StakingWithTokensContract;
|
||||
stakingWrapper: TestStakingPlaceholderContract;
|
||||
zrxVault: ZrxVaultContract;
|
||||
}
|
||||
|
||||
@ -349,11 +349,13 @@ export class DeploymentManager {
|
||||
txDefaults,
|
||||
stakingArtifacts,
|
||||
);
|
||||
const stakingLogic = await StakingWithTokensContract.deployFrom0xArtifactAsync(
|
||||
artifacts.StakingWithTokens,
|
||||
const stakingLogic = await TestStakingPlaceholderContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestStakingPlaceholder,
|
||||
environment.provider,
|
||||
txDefaults,
|
||||
stakingArtifacts,
|
||||
tokens.weth.address,
|
||||
tokens.zrx.address,
|
||||
);
|
||||
const stakingProxy = await StakingProxyContract.deployFrom0xArtifactAsync(
|
||||
stakingArtifacts.StakingProxy,
|
||||
@ -363,7 +365,11 @@ export class DeploymentManager {
|
||||
stakingLogic.address,
|
||||
readOnlyProxy.address,
|
||||
);
|
||||
const stakingWrapper = new StakingWithTokensContract(stakingProxy.address, environment.provider);
|
||||
const stakingWrapper = new TestStakingPlaceholderContract(stakingProxy.address, environment.provider);
|
||||
|
||||
// Add the zrx vault and the weth contract to the staking proxy.
|
||||
await stakingWrapper.setWethContract.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner });
|
||||
await stakingWrapper.setZrxVault.awaitTransactionSuccessAsync(zrxVault.address, { from: owner });
|
||||
|
||||
// Authorize the owner address in the staking proxy and the zrx vault.
|
||||
await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner, { from: owner });
|
||||
@ -372,8 +378,6 @@ export class DeploymentManager {
|
||||
// Configure the zrx vault and the staking contract.
|
||||
await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy.address, { from: owner });
|
||||
await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy.address, { from: owner });
|
||||
await stakingWrapper.setZrxVault.awaitTransactionSuccessAsync(zrxVault.address, { from: owner });
|
||||
await stakingWrapper.setWethAddress.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner });
|
||||
|
||||
return {
|
||||
readOnlyProxy,
|
@ -3,4 +3,4 @@
|
||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
export * from '../generated-wrappers/staking_with_tokens';
|
||||
export * from '../generated-wrappers/test_staking_placeholder';
|
@ -1,4 +1,5 @@
|
||||
import { Authorizable, Ownable } from '@0x/contracts-exchange';
|
||||
import { constants as stakingConstants } from '@0x/contracts-staking';
|
||||
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
@ -150,12 +151,12 @@ blockchainTests('Deployment Manager', env => {
|
||||
});
|
||||
|
||||
it('should have registered the weth contract in the staking contract', async () => {
|
||||
const weth = await deploymentManager.staking.stakingWrapper.wethAddress.callAsync();
|
||||
const weth = await deploymentManager.staking.stakingWrapper.testWethAddress.callAsync();
|
||||
expect(weth).to.be.eq(deploymentManager.tokens.weth.address);
|
||||
});
|
||||
|
||||
it('should have registered the zrx vault in the staking contract', async () => {
|
||||
const zrxVault = await deploymentManager.staking.stakingWrapper.zrxVault.callAsync();
|
||||
const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress.callAsync();
|
||||
expect(zrxVault).to.be.eq(deploymentManager.staking.zrxVault.address);
|
||||
});
|
||||
|
||||
@ -166,11 +167,14 @@ blockchainTests('Deployment Manager', env => {
|
||||
|
||||
it('should have correctly set the params', async () => {
|
||||
const params = await deploymentManager.staking.stakingWrapper.getParams.callAsync();
|
||||
expect(params).to.be.deep.eq(
|
||||
[10 * 60 * 60 * 24, (90 * constants.PPM_DENOMINATOR) / 100, 100 * 1e18, 10, 1, 2].map(
|
||||
value => new BigNumber(value),
|
||||
),
|
||||
);
|
||||
expect(params).to.be.deep.eq([
|
||||
stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds,
|
||||
stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight,
|
||||
stakingConstants.DEFAULT_PARAMS.minimumPoolStake,
|
||||
stakingConstants.DEFAULT_PARAMS.maximumMakersInPool,
|
||||
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaNumerator,
|
||||
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaDenominator,
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
@ -20,6 +20,7 @@ import {
|
||||
import { artifacts as multisigArtifacts, AssetProxyOwnerContract } from '@0x/contracts-multisig';
|
||||
import {
|
||||
artifacts as stakingArtifacts,
|
||||
constants as stakingConstants,
|
||||
ReadOnlyProxyContract,
|
||||
StakingContract,
|
||||
StakingEvents,
|
||||
@ -287,16 +288,14 @@ blockchainTests('Deployment and Configuration End to End Tests', env => {
|
||||
it('should have initialized the correct parameters in the staking proxy', async () => {
|
||||
// Ensure that the correct parameters were set.
|
||||
const params = await stakingWrapper.getParams.callAsync();
|
||||
expect(params).to.be.deep.eq(
|
||||
[
|
||||
864000, // epochDurationInSeconds
|
||||
900000, // rewardDelegatedStakeWeight
|
||||
100000000000000000000, // minimumPoolStake
|
||||
10, // maximumMakerInPool
|
||||
1, // cobbDouglasAlphaNumerator
|
||||
2, // cobbDouglasAlphaDenominator
|
||||
].map(value => new BigNumber(value)),
|
||||
);
|
||||
expect(params).to.be.deep.eq([
|
||||
stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds,
|
||||
stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight,
|
||||
stakingConstants.DEFAULT_PARAMS.minimumPoolStake,
|
||||
stakingConstants.DEFAULT_PARAMS.maximumMakersInPool,
|
||||
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaNumerator,
|
||||
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaDenominator,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -2,5 +2,5 @@
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||
"files": ["generated-artifacts/StakingWithTokens.json"]
|
||||
"files": ["generated-artifacts/TestStakingPlaceholder.json"]
|
||||
}
|
@ -40,6 +40,22 @@ contract TestStaking is
|
||||
testZrxVaultAddress = zrxVaultAddress;
|
||||
}
|
||||
|
||||
/// @dev Sets the weth contract address.
|
||||
/// @param wethAddress The address of the weth contract.
|
||||
function setWethContract(address wethAddress)
|
||||
external
|
||||
{
|
||||
testWethAddress = wethAddress;
|
||||
}
|
||||
|
||||
/// @dev Sets the zrx vault address.
|
||||
/// @param zrxVaultAddress The address of a zrx vault.
|
||||
function setZrxVault(address zrxVaultAddress)
|
||||
external
|
||||
{
|
||||
testZrxVaultAddress = zrxVaultAddress;
|
||||
}
|
||||
|
||||
/// @dev Overridden to use testWethAddress;
|
||||
function getWethContract()
|
||||
public
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './wrappers';
|
||||
export * from './artifacts';
|
||||
export { constants } from '../test/utils/constants';
|
||||
|
Loading…
x
Reference in New Issue
Block a user