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