Readability improvements ... apparently I still cant spell catastrophe.
This commit is contained in:
parent
2ad6dd1ee8
commit
b458026358
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "./immutable/MixinConstants.sol";
|
|
||||||
import "./immutable/MixinStorage.sol";
|
import "./immutable/MixinStorage.sol";
|
||||||
import "./libs/LibProxy.sol";
|
import "./libs/LibProxy.sol";
|
||||||
|
|
||||||
@ -35,8 +34,8 @@ contract ReadOnlyProxy is
|
|||||||
{
|
{
|
||||||
address(this).proxyCall(
|
address(this).proxyCall(
|
||||||
LibProxy.RevertRule.NEVER_REVERT,
|
LibProxy.RevertRule.NEVER_REVERT,
|
||||||
this.revertDelegateCall.selector,
|
this.revertDelegateCall.selector, // custom egress selector
|
||||||
false // do not ignore this selector
|
false // do not ignore ingress selector
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +46,8 @@ contract ReadOnlyProxy is
|
|||||||
{
|
{
|
||||||
readOnlyProxyCallee.proxyCall(
|
readOnlyProxyCallee.proxyCall(
|
||||||
LibProxy.RevertRule.ALWAYS_REVERT,
|
LibProxy.RevertRule.ALWAYS_REVERT,
|
||||||
bytes4(0), // no custom selector
|
bytes4(0), // no custom egress selector
|
||||||
true // ignore this selector
|
true // ignore ingress selector
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ contract StakingProxy is
|
|||||||
{
|
{
|
||||||
stakingContract.proxyCall(
|
stakingContract.proxyCall(
|
||||||
LibProxy.RevertRule.REVERT_ON_ERROR,
|
LibProxy.RevertRule.REVERT_ON_ERROR,
|
||||||
bytes4(0), // no custom selector
|
bytes4(0), // no custom egress selector
|
||||||
false // do not ignore this selector
|
false // do not ignore ingress selector
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,16 @@ library LibProxy {
|
|||||||
NEVER_REVERT
|
NEVER_REVERT
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Executes a read-only call to the staking contract, via `revertDelegateCall`.
|
/// @dev Proxies incoming call to destination contract.
|
||||||
/// By routing through `revertDelegateCall` any state changes are reverted.
|
/// @param destination Address to call.
|
||||||
|
/// @param revertRule Describes scenarios in which this function reverts.
|
||||||
|
/// @param customEgressSelector Custom selector used to call destination contract.
|
||||||
|
/// @param ignoreIngressSelector Ignore the selector used to call into this contract.
|
||||||
function proxyCall(
|
function proxyCall(
|
||||||
address destination,
|
address destination,
|
||||||
RevertRule revertRule,
|
RevertRule revertRule,
|
||||||
bytes4 customSelector,
|
bytes4 customEgressSelector,
|
||||||
bool ignoreSelector
|
bool ignoreIngressSelector
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
@ -49,14 +52,14 @@ library LibProxy {
|
|||||||
assembly {
|
assembly {
|
||||||
// store selector of destination function
|
// store selector of destination function
|
||||||
let freeMemPtr := 0
|
let freeMemPtr := 0
|
||||||
if gt(customSelector, 0) {
|
if gt(customEgressSelector, 0) {
|
||||||
mstore(0x0, customSelector)
|
mstore(0x0, customEgressSelector)
|
||||||
freeMemPtr := add(freeMemPtr, 4)
|
freeMemPtr := add(freeMemPtr, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust the calldata offset, if we should ignore the selector
|
// adjust the calldata offset, if we should ignore the selector
|
||||||
let calldataOffset := 0
|
let calldataOffset := 0
|
||||||
if gt(ignoreSelector, 0) {
|
if gt(ignoreIngressSelector, 0) {
|
||||||
calldataOffset := 4
|
calldataOffset := 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ library LibStakingRichErrors {
|
|||||||
bytes4 internal constant INVALID_COBB_DOUGLAS_ALPHA_ERROR_SELECTOR =
|
bytes4 internal constant INVALID_COBB_DOUGLAS_ALPHA_ERROR_SELECTOR =
|
||||||
0x8f8e73de;
|
0x8f8e73de;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ library LibStakingRichErrors {
|
|||||||
0xb7161acd;
|
0xb7161acd;
|
||||||
|
|
||||||
// bytes4(keccak256("ProxyDestinationCannotBeNil()"))
|
// bytes4(keccak256("ProxyDestinationCannotBeNil()"))
|
||||||
bytes4 internal constant PROXY_DESTINATION_CANNOT_BE_NIL =
|
bytes internal constant PROXY_DESTINATION_CANNOT_BE_NIL =
|
||||||
0x01ecebea;
|
hex"01ecebea";
|
||||||
|
|
||||||
// solhint-disable func-name-mixedcase
|
// solhint-disable func-name-mixedcase
|
||||||
function MiscalculatedRewardsError(
|
function MiscalculatedRewardsError(
|
||||||
@ -515,9 +515,7 @@ library LibStakingRichErrors {
|
|||||||
pure
|
pure
|
||||||
returns (bytes memory)
|
returns (bytes memory)
|
||||||
{
|
{
|
||||||
return abi.encodeWithSelector(
|
return PROXY_DESTINATION_CANNOT_BE_NIL;
|
||||||
PROXY_DESTINATION_CANNOT_BE_NIL
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ERC20ProxyContract, ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
import { ERC20ProxyContract, ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
||||||
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
|
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
|
||||||
import { blockchainTests, describe, expect, provider, web3Wrapper } from '@0x/contracts-test-utils';
|
import { blockchainTests, describe, expect } from '@0x/contracts-test-utils';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@ -10,7 +10,7 @@ import { StakingProxyReadOnlyModeSetEventArgs } from '../src';
|
|||||||
import { StakingWrapper } from './utils/staking_wrapper';
|
import { StakingWrapper } from './utils/staking_wrapper';
|
||||||
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
// tslint:disable:no-unnecessary-type-assertion
|
||||||
blockchainTests.resets('Catastrophy Tests', () => {
|
blockchainTests.resets('Catastrophe Tests', env => {
|
||||||
// constants
|
// constants
|
||||||
const ZRX_TOKEN_DECIMALS = new BigNumber(18);
|
const ZRX_TOKEN_DECIMALS = new BigNumber(18);
|
||||||
const ZERO = new BigNumber(0);
|
const ZERO = new BigNumber(0);
|
||||||
@ -26,17 +26,17 @@ blockchainTests.resets('Catastrophy Tests', () => {
|
|||||||
// tests
|
// tests
|
||||||
before(async () => {
|
before(async () => {
|
||||||
// create accounts
|
// create accounts
|
||||||
accounts = await web3Wrapper.getAvailableAddressesAsync();
|
accounts = await env.web3Wrapper.getAvailableAddressesAsync();
|
||||||
owner = accounts[0];
|
owner = accounts[0];
|
||||||
actors = accounts.slice(2, 5);
|
actors = accounts.slice(2, 5);
|
||||||
// deploy erc20 proxy
|
// deploy erc20 proxy
|
||||||
erc20Wrapper = new ERC20Wrapper(provider, accounts, owner);
|
erc20Wrapper = new ERC20Wrapper(env.provider, accounts, owner);
|
||||||
erc20ProxyContract = await erc20Wrapper.deployProxyAsync();
|
erc20ProxyContract = await erc20Wrapper.deployProxyAsync();
|
||||||
// deploy zrx token
|
// deploy zrx token
|
||||||
[zrxTokenContract] = await erc20Wrapper.deployDummyTokensAsync(1, ZRX_TOKEN_DECIMALS);
|
[zrxTokenContract] = await erc20Wrapper.deployDummyTokensAsync(1, ZRX_TOKEN_DECIMALS);
|
||||||
await erc20Wrapper.setBalancesAndAllowancesAsync();
|
await erc20Wrapper.setBalancesAndAllowancesAsync();
|
||||||
// deploy staking contracts
|
// deploy staking contracts
|
||||||
stakingWrapper = new StakingWrapper(provider, owner, erc20ProxyContract, zrxTokenContract, accounts);
|
stakingWrapper = new StakingWrapper(env.provider, owner, erc20ProxyContract, zrxTokenContract, accounts);
|
||||||
await stakingWrapper.deployAndConfigureContractsAsync();
|
await stakingWrapper.deployAndConfigureContractsAsync();
|
||||||
});
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user