remove staking RevertReasons from TS types, ExchangeAlreadyRegisteredError -> ExchangeAddressAlreadyRegisteredError
This commit is contained in:
parent
0d5e037081
commit
2c15b3f9bd
@ -55,7 +55,7 @@ contract MixinExchangeManager is
|
|||||||
onlyOwner
|
onlyOwner
|
||||||
{
|
{
|
||||||
if (validExchanges[addr]) {
|
if (validExchanges[addr]) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.ExchangeAlreadyRegisteredError(
|
LibRichErrors.rrevert(LibStakingRichErrors.ExchangeAddressAlreadyRegisteredError(
|
||||||
addr
|
addr
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ library LibStakingRichErrors {
|
|||||||
bytes4 internal constant ONLY_CALLABLE_BY_EXCHANGE_ERROR_SELECTOR =
|
bytes4 internal constant ONLY_CALLABLE_BY_EXCHANGE_ERROR_SELECTOR =
|
||||||
0xb56d2df0;
|
0xb56d2df0;
|
||||||
|
|
||||||
// bytes4(keccak256("ExchangeAlreadyRegisteredError(address)"))
|
// bytes4(keccak256("ExchangeAddressAlreadyRegisteredError(address)"))
|
||||||
bytes4 internal constant EXCHANGE_ALREADY_REGISTERED_ERROR_SELECTOR =
|
bytes4 internal constant EXCHANGE_ADDRESS_ALREADY_REGISTERED_ERROR_SELECTOR =
|
||||||
0x5ef5b57d;
|
0xc87a78b7;
|
||||||
|
|
||||||
// bytes4(keccak256("ExchangeAddressNotRegisteredError(address)"))
|
// bytes4(keccak256("ExchangeAddressNotRegisteredError(address)"))
|
||||||
bytes4 internal constant EXCHANGE_ADDRESS_NOT_REGISTERED_ERROR_SELECTOR =
|
bytes4 internal constant EXCHANGE_ADDRESS_NOT_REGISTERED_ERROR_SELECTOR =
|
||||||
@ -118,6 +118,8 @@ library LibStakingRichErrors {
|
|||||||
bytes4 internal constant POOL_ALREADY_EXISTS_ERROR_SELECTOR =
|
bytes4 internal constant POOL_ALREADY_EXISTS_ERROR_SELECTOR =
|
||||||
0x2a5e4dcf;
|
0x2a5e4dcf;
|
||||||
|
|
||||||
|
// solhint-disable func-name-mixedcase
|
||||||
|
|
||||||
function MiscalculatedRewardsError(
|
function MiscalculatedRewardsError(
|
||||||
uint256 totalRewardsPaid,
|
uint256 totalRewardsPaid,
|
||||||
uint256 initialContractBalance
|
uint256 initialContractBalance
|
||||||
@ -146,7 +148,7 @@ library LibStakingRichErrors {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExchangeAlreadyRegisteredError(
|
function ExchangeAddressAlreadyRegisteredError(
|
||||||
address exchangeAddress
|
address exchangeAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@ -154,7 +156,7 @@ library LibStakingRichErrors {
|
|||||||
returns (bytes memory)
|
returns (bytes memory)
|
||||||
{
|
{
|
||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
EXCHANGE_ALREADY_REGISTERED_ERROR_SELECTOR,
|
EXCHANGE_ADDRESS_ALREADY_REGISTERED_ERROR_SELECTOR,
|
||||||
exchangeAddress
|
exchangeAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,7 @@ export class StakerActor extends BaseActor {
|
|||||||
expectedStakerBalances.deactivatedStakeBalance = initStakerBalances.deactivatedStakeBalance.plus(amount);
|
expectedStakerBalances.deactivatedStakeBalance = initStakerBalances.deactivatedStakeBalance.plus(amount);
|
||||||
await this.assertBalancesAsync(expectedStakerBalances);
|
await this.assertBalancesAsync(expectedStakerBalances);
|
||||||
}
|
}
|
||||||
public async burnDeactivatedStakeAndWithdrawZrxAsync(
|
public async burnDeactivatedStakeAndWithdrawZrxAsync(amount: BigNumber, revertError?: RevertError): Promise<void> {
|
||||||
amount: BigNumber,
|
|
||||||
revertError?: RevertError,
|
|
||||||
): Promise<void> {
|
|
||||||
// query init balances
|
// query init balances
|
||||||
const initZrxBalanceOfVault = await this._stakingWrapper.getZrxTokenBalanceOfZrxVaultAsync();
|
const initZrxBalanceOfVault = await this._stakingWrapper.getZrxTokenBalanceOfZrxVaultAsync();
|
||||||
const initStakerBalances = await this.getBalancesAsync();
|
const initStakerBalances = await this.getBalancesAsync();
|
||||||
|
@ -47,7 +47,7 @@ blockchainTests.only('Exchange Integrations', env => {
|
|||||||
const isValidAddressValid = await stakingWrapper.isValidExchangeAddressAsync(exchange);
|
const isValidAddressValid = await stakingWrapper.isValidExchangeAddressAsync(exchange);
|
||||||
expect(isValidAddressValid).to.be.true();
|
expect(isValidAddressValid).to.be.true();
|
||||||
// 3 try adding valid address again
|
// 3 try adding valid address again
|
||||||
let revertError = new StakingRevertErrors.ExchangeAlreadyRegisteredError(exchange);
|
let revertError = new StakingRevertErrors.ExchangeAddressAlreadyRegisteredError(exchange);
|
||||||
let tx = stakingWrapper.addExchangeAddressAsync(exchange);
|
let tx = stakingWrapper.addExchangeAddressAsync(exchange);
|
||||||
await expect(tx).to.revertWith(revertError);
|
await expect(tx).to.revertWith(revertError);
|
||||||
// 4 remove valid address
|
// 4 remove valid address
|
||||||
|
@ -113,12 +113,7 @@ blockchainTests.only('Staking Pool Management', env => {
|
|||||||
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
|
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature);
|
||||||
const revertError = new StakingRevertErrors.MakerAddressAlreadyRegisteredError(makerAddress);
|
const revertError = new StakingRevertErrors.MakerAddressAlreadyRegisteredError(makerAddress);
|
||||||
// add same maker to pool again
|
// add same maker to pool again
|
||||||
await poolOperator.addMakerToStakingPoolAsync(
|
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature, revertError);
|
||||||
poolId,
|
|
||||||
makerAddress,
|
|
||||||
makerApproval.signature,
|
|
||||||
revertError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Should fail to remove a maker that does not exist', async () => {
|
it('Should fail to remove a maker that does not exist', async () => {
|
||||||
// test parameters
|
// test parameters
|
||||||
@ -135,11 +130,7 @@ blockchainTests.only('Staking Pool Management', env => {
|
|||||||
poolId,
|
poolId,
|
||||||
);
|
);
|
||||||
// remove non-existent maker from pool
|
// remove non-existent maker from pool
|
||||||
await poolOperator.removeMakerFromStakingPoolAsync(
|
await poolOperator.removeMakerFromStakingPoolAsync(poolId, makerAddress, revertError);
|
||||||
poolId,
|
|
||||||
makerAddress,
|
|
||||||
revertError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Should fail to add a maker who signed with the wrong private key', async () => {
|
it('Should fail to add a maker who signed with the wrong private key', async () => {
|
||||||
// test parameters
|
// test parameters
|
||||||
@ -161,12 +152,7 @@ blockchainTests.only('Staking Pool Management', env => {
|
|||||||
makerAddress,
|
makerAddress,
|
||||||
makerApproval.signature,
|
makerApproval.signature,
|
||||||
);
|
);
|
||||||
await poolOperator.addMakerToStakingPoolAsync(
|
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature, revertError);
|
||||||
poolId,
|
|
||||||
makerAddress,
|
|
||||||
makerApproval.signature,
|
|
||||||
revertError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Should fail to add a maker who signed with the wrong staking contract address', async () => {
|
it('Should fail to add a maker who signed with the wrong staking contract address', async () => {
|
||||||
// test parameters
|
// test parameters
|
||||||
@ -187,12 +173,7 @@ blockchainTests.only('Staking Pool Management', env => {
|
|||||||
makerAddress,
|
makerAddress,
|
||||||
makerApproval.signature,
|
makerApproval.signature,
|
||||||
);
|
);
|
||||||
await poolOperator.addMakerToStakingPoolAsync(
|
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature, revertError);
|
||||||
poolId,
|
|
||||||
makerAddress,
|
|
||||||
makerApproval.signature,
|
|
||||||
revertError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Should fail to add a maker who signed with the wrong chain id', async () => {
|
it('Should fail to add a maker who signed with the wrong chain id', async () => {
|
||||||
// test parameters
|
// test parameters
|
||||||
@ -220,12 +201,7 @@ blockchainTests.only('Staking Pool Management', env => {
|
|||||||
makerAddress,
|
makerAddress,
|
||||||
makerApproval.signature,
|
makerApproval.signature,
|
||||||
);
|
);
|
||||||
await poolOperator.addMakerToStakingPoolAsync(
|
await poolOperator.addMakerToStakingPoolAsync(poolId, makerAddress, makerApproval.signature, revertError);
|
||||||
poolId,
|
|
||||||
makerAddress,
|
|
||||||
makerApproval.signature,
|
|
||||||
revertError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Should fail to add a maker when called by someone other than the pool operator', async () => {
|
it('Should fail to add a maker when called by someone other than the pool operator', async () => {
|
||||||
// test parameters
|
// test parameters
|
||||||
|
@ -8,11 +8,7 @@ const MAX_UINT256 = new BigNumber(2).pow(256).minus(1);
|
|||||||
export function safeAdd(a: BigNumber, b: BigNumber): BigNumber {
|
export function safeAdd(a: BigNumber, b: BigNumber): BigNumber {
|
||||||
const r = a.plus(b);
|
const r = a.plus(b);
|
||||||
if (r.isGreaterThan(MAX_UINT256)) {
|
if (r.isGreaterThan(MAX_UINT256)) {
|
||||||
throw new SafeMathRevertErrors.Uint256BinopError(
|
throw new SafeMathRevertErrors.Uint256BinopError(SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, a, b);
|
||||||
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow,
|
|
||||||
a,
|
|
||||||
b,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -52,11 +48,7 @@ export function safeMul(a: BigNumber, b: BigNumber): BigNumber {
|
|||||||
*/
|
*/
|
||||||
export function safeDiv(a: BigNumber, b: BigNumber): BigNumber {
|
export function safeDiv(a: BigNumber, b: BigNumber): BigNumber {
|
||||||
if (b.isEqualTo(0)) {
|
if (b.isEqualTo(0)) {
|
||||||
throw new SafeMathRevertErrors.Uint256BinopError(
|
throw new SafeMathRevertErrors.Uint256BinopError(SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, a, b);
|
||||||
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero,
|
|
||||||
a,
|
|
||||||
b,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return a.dividedToIntegerBy(b);
|
return a.dividedToIntegerBy(b);
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,13 @@ export class OnlyCallableByExchangeError extends RevertError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExchangeAlreadyRegisteredError extends RevertError {
|
export class ExchangeAddressAlreadyRegisteredError extends RevertError {
|
||||||
constructor(exchangeAddress?: string) {
|
constructor(exchangeAddress?: string) {
|
||||||
super('ExchangeAlreadyRegisteredError', 'ExchangeAlreadyRegisteredError(address exchangeAddress)', {
|
super(
|
||||||
exchangeAddress,
|
'ExchangeAddressAlreadyRegisteredError',
|
||||||
});
|
'ExchangeAddressAlreadyRegisteredError(address exchangeAddress)',
|
||||||
|
{ exchangeAddress },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +198,7 @@ export class PoolAlreadyExistsError extends RevertError {
|
|||||||
const types = [
|
const types = [
|
||||||
MiscalculatedRewardsError,
|
MiscalculatedRewardsError,
|
||||||
OnlyCallableByExchangeError,
|
OnlyCallableByExchangeError,
|
||||||
ExchangeAlreadyRegisteredError,
|
ExchangeAddressAlreadyRegisteredError,
|
||||||
ExchangeAddressNotRegisteredError,
|
ExchangeAddressNotRegisteredError,
|
||||||
SignatureLengthGreaterThan0RequiredError,
|
SignatureLengthGreaterThan0RequiredError,
|
||||||
SignatureUnsupportedError,
|
SignatureUnsupportedError,
|
||||||
|
@ -341,21 +341,6 @@ export enum RevertReason {
|
|||||||
TargetNotEven = 'TARGET_NOT_EVEN',
|
TargetNotEven = 'TARGET_NOT_EVEN',
|
||||||
UnexpectedStaticCallResult = 'UNEXPECTED_STATIC_CALL_RESULT',
|
UnexpectedStaticCallResult = 'UNEXPECTED_STATIC_CALL_RESULT',
|
||||||
TransfersSuccessful = 'TRANSFERS_SUCCESSFUL',
|
TransfersSuccessful = 'TRANSFERS_SUCCESSFUL',
|
||||||
// Staking
|
|
||||||
OnlyCallableByPoolOperator = 'ONLY_CALLABLE_BY_POOL_OPERATOR',
|
|
||||||
OnlyCallableByPoolOperatorOrMaker = 'ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER',
|
|
||||||
MakerAddressAlreadyRegistered = 'MAKER_ADDRESS_ALREADY_REGISTERED',
|
|
||||||
MakerAddressNotRegistered = 'MAKER_ADDRESS_NOT_REGISTERED',
|
|
||||||
OnlyCallableByExchange = 'ONLY_CALLABLE_BY_EXCHANGE',
|
|
||||||
ExchangeAddressAlreadyRegistered = 'EXCHANGE_ADDRESS_ALREADY_REGISTERED',
|
|
||||||
ExchangeAddressNotRegistered = 'EXCHANGE_ADDRESS_NOT_REGISTERED',
|
|
||||||
PoolAlreadyExists = 'POOL_ALREADY_EXISTS',
|
|
||||||
PoolBalanceIsZero = 'POOL_BALANCE_IS_ZERO',
|
|
||||||
InvalidOwner = 'INVALID_OWNER',
|
|
||||||
AmountExceedsBalanceOfPool = 'AMOUNT_EXCEEDS_BALANCE_OF_POOL',
|
|
||||||
OnlyCallableByStakingContract = 'ONLY_CALLABLE_BY_STAKING_CONTRACT',
|
|
||||||
InvalidMakerSignature = 'INVALID_MAKER_SIGNATURE',
|
|
||||||
InsufficientBalance = 'INSUFFICIENT_BALANCE',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum StatusCodes {
|
export enum StatusCodes {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user