@0x/contracts-staking: Fix contracts formatting.

`@0x/contracts-staking`: Remove typo test suite in `migration.ts`.
`@0x/contracts-staking`: Address minor review comments.
This commit is contained in:
Lawrence Forman 2019-09-09 20:51:55 -04:00
parent 1c2f4906e6
commit 6410366f8b
26 changed files with 27 additions and 31 deletions

View File

@ -25,6 +25,7 @@ import "./libs/LibProxy.sol";
contract ReadOnlyProxy is contract ReadOnlyProxy is
MixinStorage MixinStorage
{ {
using LibProxy for address; using LibProxy for address;
// solhint-disable payable-fallback // solhint-disable payable-fallback

View File

@ -50,6 +50,7 @@ contract Staking is
MixinStakingPool, MixinStakingPool,
MixinExchangeFees MixinExchangeFees
{ {
// this contract can receive ETH // this contract can receive ETH
// solhint-disable no-empty-blocks // solhint-disable no-empty-blocks
function () function ()

View File

@ -33,6 +33,7 @@ contract StakingProxy is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
using LibProxy for address; using LibProxy for address;
/// @dev Constructor. /// @dev Constructor.

View File

@ -58,6 +58,7 @@ contract MixinExchangeFees is
MixinStakingPoolRewards, MixinStakingPoolRewards,
MixinStakingPool MixinStakingPool
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Pays a protocol fee in ETH or WETH. /// @dev Pays a protocol fee in ETH or WETH.

View File

@ -35,6 +35,7 @@ contract MixinExchangeManager is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
/// @dev Asserts that the call is coming from a valid exchange. /// @dev Asserts that the call is coming from a valid exchange.
modifier onlyExchange() { modifier onlyExchange() {
if (!isValidExchangeAddress(msg.sender)) { if (!isValidExchangeAddress(msg.sender)) {

View File

@ -20,6 +20,7 @@ pragma solidity ^0.5.9;
interface IStaking { interface IStaking {
/// @dev Pays a protocol fee in ETH. /// @dev Pays a protocol fee in ETH.
/// @param makerAddress The address of the order's maker. /// @param makerAddress The address of the order's maker.
/// @param payerAddress The address that is responsible for paying the protocol fee. /// @param payerAddress The address that is responsible for paying the protocol fee.

View File

@ -20,6 +20,7 @@ pragma solidity ^0.5.9;
interface IStorageInit { interface IStorageInit {
/// @dev Initialize storage owned by this contract. /// @dev Initialize storage owned by this contract.
function init() external; function init() external;
} }

View File

@ -24,6 +24,7 @@ import "./LibFixedMathRichErrors.sol";
// solhint-disable indent // solhint-disable indent
/// @dev Signed, fixed-point, 127-bit precision math library. /// @dev Signed, fixed-point, 127-bit precision math library.
library LibFixedMath { library LibFixedMath {
// 1 // 1
int256 private constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000); int256 private constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);
// 1^2 (in fixed-point) // 1^2 (in fixed-point)

View File

@ -110,7 +110,7 @@ library LibStakingRichErrors {
bytes4 internal constant POOL_ALREADY_EXISTS_ERROR_SELECTOR = bytes4 internal constant POOL_ALREADY_EXISTS_ERROR_SELECTOR =
0x2a5e4dcf; 0x2a5e4dcf;
// bytes4(keccak256("EthVaultNotSetError()")) // bytes4(keccak256("EthVaultNotSetError()"))
bytes4 internal constant ETH_VAULT_NOT_SET_ERROR_SELECTOR = bytes4 internal constant ETH_VAULT_NOT_SET_ERROR_SELECTOR =
0xa067f596; 0xa067f596;

View File

@ -46,6 +46,7 @@ contract MixinStake is
MixinStakeBalances, MixinStakeBalances,
MixinStakingPoolRewards MixinStakingPoolRewards
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Stake ZRX tokens. Tokens are deposited into the ZRX Vault. Unstake to retrieve the ZRX. /// @dev Stake ZRX tokens. Tokens are deposited into the ZRX Vault. Unstake to retrieve the ZRX.

View File

@ -39,6 +39,7 @@ contract MixinStakeBalances is
MixinScheduler, MixinScheduler,
MixinStakeStorage MixinStakeStorage
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Returns the total stake for a given owner. /// @dev Returns the total stake for a given owner.

View File

@ -35,6 +35,7 @@ contract MixinStakeStorage is
MixinStorage, MixinStorage,
MixinScheduler MixinScheduler
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
using LibSafeDowncast for uint256; using LibSafeDowncast for uint256;

View File

@ -29,6 +29,7 @@ contract MixinZrxVault is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
/// @dev Set the Zrx Vault. /// @dev Set the Zrx Vault.
/// @param zrxVaultAddress Address of the Zrx Vault. /// @param zrxVaultAddress Address of the Zrx Vault.
function setZrxVault(address zrxVaultAddress) function setZrxVault(address zrxVaultAddress)

View File

@ -64,6 +64,7 @@ contract MixinStakingPool is
MixinStakeBalances, MixinStakeBalances,
MixinStakingPoolRewards MixinStakingPoolRewards
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Create a new staking pool. The sender will be the operator of this pool. /// @dev Create a new staking pool. The sender will be the operator of this pool.

View File

@ -38,6 +38,7 @@ contract MixinStakingPoolRewards is
MixinStakeStorage, MixinStakeStorage,
MixinStakeBalances MixinStakeBalances
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Computes the reward balance in ETH of a specific member of a pool. /// @dev Computes the reward balance in ETH of a specific member of a pool.

View File

@ -32,6 +32,7 @@ contract MixinParams is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
/// @dev Set all configurable parameters at once. /// @dev Set all configurable parameters at once.
/// @param _epochDurationInSeconds Minimum seconds between epochs. /// @param _epochDurationInSeconds Minimum seconds between epochs.
/// @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm. /// @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm.
@ -74,7 +75,7 @@ contract MixinParams is
); );
} }
/// @dev Retrives all configurable parameter values. /// @dev Retrieves all configurable parameter values.
/// @return _epochDurationInSeconds Minimum seconds between epochs. /// @return _epochDurationInSeconds Minimum seconds between epochs.
/// @return _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm. /// @return _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm.
/// @return _minimumPoolStake Minimum amount of stake required in a pool to collect rewards. /// @return _minimumPoolStake Minimum amount of stake required in a pool to collect rewards.

View File

@ -39,6 +39,7 @@ contract MixinScheduler is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
/// @dev Returns the current epoch. /// @dev Returns the current epoch.

View File

@ -30,6 +30,7 @@ contract EthVault is
IVaultCore, IVaultCore,
MixinVaultCore MixinVaultCore
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
// mapping from Owner to ETH balance // mapping from Owner to ETH balance

View File

@ -46,6 +46,7 @@ contract StakingPoolRewardVault is
MixinConstants, MixinConstants,
MixinVaultCore MixinVaultCore
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
using LibSafeDowncast for uint256; using LibSafeDowncast for uint256;

View File

@ -39,6 +39,7 @@ contract ZrxVault is
IZrxVault, IZrxVault,
MixinVaultCore MixinVaultCore
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
// mapping from Owner to ZRX balance // mapping from Owner to ZRX balance

View File

@ -24,6 +24,7 @@ import "../src/fees/MixinExchangeFees.sol";
contract TestCobbDouglas is contract TestCobbDouglas is
MixinExchangeFees MixinExchangeFees
{ {
function cobbDouglas( function cobbDouglas(
uint256 totalRewards, uint256 totalRewards,
uint256 ownerFees, uint256 ownerFees,

View File

@ -24,6 +24,7 @@ import "../src/Staking.sol";
contract TestExchangeFees is contract TestExchangeFees is
Staking Staking
{ {
struct TestPool { struct TestPool {
uint256 stake; uint256 stake;
mapping(address => bool) isMaker; mapping(address => bool) isMaker;

View File

@ -26,6 +26,7 @@ contract TestInitTarget is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
// We can't store state in this contract before it is attached, so // We can't store state in this contract before it is attached, so
// we will grant this predefined address a balance to indicate that // we will grant this predefined address a balance to indicate that
// `init()` should revert. // `init()` should revert.

View File

@ -24,6 +24,7 @@ import "../src/StakingProxy.sol";
contract TestStakingProxy is contract TestStakingProxy is
StakingProxy StakingProxy
{ {
// solhint-disable no-empty-blocks // solhint-disable no-empty-blocks
constructor(address _stakingContract) constructor(address _stakingContract)
public public

View File

@ -29,6 +29,7 @@ contract TestStorageLayout is
Ownable, Ownable,
MixinStorage MixinStorage
{ {
function assertExpectedStorageLayout() function assertExpectedStorageLayout()
public public
pure pure

View File

@ -49,7 +49,7 @@ blockchainTests('Migration tests', env => {
...env.txDefaults, ...env.txDefaults,
from: ownerAddress, from: ownerAddress,
to: revertAddress, to: revertAddress,
data: '0x', data: constants.NULL_BYTES,
value: new BigNumber(1), value: new BigNumber(1),
}), }),
); );
@ -114,34 +114,6 @@ blockchainTests('Migration tests', env => {
expect(initCounter).to.bignumber.eq(2); expect(initCounter).to.bignumber.eq(2);
}); });
}); });
blockchainTests.resets('upgrade', async () => {
let proxyContract: TestStakingProxyContract;
before(async () => {
proxyContract = await deployStakingProxyAsync();
});
it('incm', async () => {
const attachedAddress = randomAddress();
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(attachedAddress, {
from: notOwnerAddress,
});
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwnerAddress, ownerAddress);
return expect(tx).to.revertWith(expectedError);
});
it('calls init() and attaches the contract', async () => {
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
await assertInitStateAsync(proxyContract);
});
it('reverts if init() reverts', async () => {
await enableInitRevertsAsync();
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
return expect(tx).to.revertWith(REVERT_ERROR);
});
});
}); });
blockchainTests.resets('Staking.init()', async () => { blockchainTests.resets('Staking.init()', async () => {