remove staking RevertReasons from TS types, ExchangeAlreadyRegisteredError -> ExchangeAddressAlreadyRegisteredError

This commit is contained in:
Michael Zhu 2019-08-26 11:21:16 -07:00
parent 0d5e037081
commit 2c15b3f9bd
8 changed files with 95 additions and 141 deletions

View File

@ -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
)); ));
} }

View File

@ -23,101 +23,103 @@ import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
library LibStakingRichErrors { library LibStakingRichErrors {
// bytes4(keccak256("MiscalculatedRewardsError(uint256,uint256)")) // bytes4(keccak256("MiscalculatedRewardsError(uint256,uint256)"))
bytes4 internal constant MISCALCULATED_REWARDS_ERROR_SELECTOR = bytes4 internal constant MISCALCULATED_REWARDS_ERROR_SELECTOR =
0xf7806c4e; 0xf7806c4e;
// bytes4(keccak256("OnlyCallableByExchangeError(address)")) // bytes4(keccak256("OnlyCallableByExchangeError(address)"))
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 =
0x7dc025b0; 0x7dc025b0;
// bytes4(keccak256("SignatureLengthGreaterThan0RequiredError()")) // bytes4(keccak256("SignatureLengthGreaterThan0RequiredError()"))
bytes4 internal constant SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR = bytes4 internal constant SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR =
0x2dcb01d9; 0x2dcb01d9;
// bytes4(keccak256("SignatureUnsupportedError(bytes)")) // bytes4(keccak256("SignatureUnsupportedError(bytes)"))
bytes4 internal constant SIGNATURE_UNSUPPORTED_ERROR_SELECTOR = bytes4 internal constant SIGNATURE_UNSUPPORTED_ERROR_SELECTOR =
0xffca2a70; 0xffca2a70;
// bytes4(keccak256("SignatureIllegalError(bytes)")) // bytes4(keccak256("SignatureIllegalError(bytes)"))
bytes4 internal constant SIGNATURE_ILLEGAL_ERROR_SELECTOR = bytes4 internal constant SIGNATURE_ILLEGAL_ERROR_SELECTOR =
0x4a95093c; 0x4a95093c;
// bytes4(keccak256("SignatureLength0RequiredError(bytes)")) // bytes4(keccak256("SignatureLength0RequiredError(bytes)"))
bytes4 internal constant SIGNATURE_LENGTH_0_REQUIRED_ERROR_SELECTOR = bytes4 internal constant SIGNATURE_LENGTH_0_REQUIRED_ERROR_SELECTOR =
0xcbcd59a2; 0xcbcd59a2;
// bytes4(keccak256("SignatureLength65RequiredError(bytes)")) // bytes4(keccak256("SignatureLength65RequiredError(bytes)"))
bytes4 internal constant SIGNATURE_LENGTH_65_REQUIRED_ERROR_SELECTOR = bytes4 internal constant SIGNATURE_LENGTH_65_REQUIRED_ERROR_SELECTOR =
0x091d7ab9; 0x091d7ab9;
// bytes4(keccak256("WalletError(address,bytes)")) // bytes4(keccak256("WalletError(address,bytes)"))
bytes4 internal constant WALLET_ERROR_SELECTOR = bytes4 internal constant WALLET_ERROR_SELECTOR =
0x0cfc935d; 0x0cfc935d;
// bytes4(keccak256("InsufficientBalanceError(uint256,uint256)")) // bytes4(keccak256("InsufficientBalanceError(uint256,uint256)"))
bytes4 internal constant INSUFFICIENT_BALANCE_ERROR_SELECTOR = bytes4 internal constant INSUFFICIENT_BALANCE_ERROR_SELECTOR =
0x84c8b7c9; 0x84c8b7c9;
// bytes4(keccak256("OnlyCallableByPoolOperatorError(address,address)")) // bytes4(keccak256("OnlyCallableByPoolOperatorError(address,address)"))
bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_ERROR_SELECTOR = bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_ERROR_SELECTOR =
0x6cfa0c22; 0x6cfa0c22;
// bytes4(keccak256("OnlyCallableByPoolOperatorOrMakerError(address,address,address)")) // bytes4(keccak256("OnlyCallableByPoolOperatorOrMakerError(address,address,address)"))
bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER_ERROR_SELECTOR = bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER_ERROR_SELECTOR =
0x7d9e1c10; 0x7d9e1c10;
// bytes4(keccak256("InvalidMakerSignatureError(bytes32,address,bytes)")) // bytes4(keccak256("InvalidMakerSignatureError(bytes32,address,bytes)"))
bytes4 internal constant INVALID_MAKER_SIGNATURE_ERROR_SELECTOR = bytes4 internal constant INVALID_MAKER_SIGNATURE_ERROR_SELECTOR =
0x726b89c8; 0x726b89c8;
// bytes4(keccak256("MakerAddressAlreadyRegisteredError(address)")) // bytes4(keccak256("MakerAddressAlreadyRegisteredError(address)"))
bytes4 internal constant MAKER_ADDRESS_ALREADY_REGISTERED_ERROR_SELECTOR = bytes4 internal constant MAKER_ADDRESS_ALREADY_REGISTERED_ERROR_SELECTOR =
0x5a3971da; 0x5a3971da;
// bytes4(keccak256("MakerAddressNotRegisteredError(address,bytes32,bytes32)")) // bytes4(keccak256("MakerAddressNotRegisteredError(address,bytes32,bytes32)"))
bytes4 internal constant MAKER_ADDRESS_NOT_REGISTERED_ERROR_SELECTOR = bytes4 internal constant MAKER_ADDRESS_NOT_REGISTERED_ERROR_SELECTOR =
0x12ab07e8; 0x12ab07e8;
// bytes4(keccak256("WithdrawAmountExceedsMemberBalanceError(uint256,uint256)")) // bytes4(keccak256("WithdrawAmountExceedsMemberBalanceError(uint256,uint256)"))
bytes4 internal constant WITHDRAW_AMOUNT_EXCEEDS_MEMBER_BALANCE_ERROR_SELECTOR = bytes4 internal constant WITHDRAW_AMOUNT_EXCEEDS_MEMBER_BALANCE_ERROR_SELECTOR =
0xfc9c065f; 0xfc9c065f;
// bytes4(keccak256("BlockTimestampTooLowError(uint64,uint64)")) // bytes4(keccak256("BlockTimestampTooLowError(uint64,uint64)"))
bytes4 internal constant BLOCK_TIMESTAMP_TOO_LOW_ERROR_SELECTOR = bytes4 internal constant BLOCK_TIMESTAMP_TOO_LOW_ERROR_SELECTOR =
0x887225f7; 0x887225f7;
// bytes4(keccak256("OnlyCallableByStakingContractError(address)")) // bytes4(keccak256("OnlyCallableByStakingContractError(address)"))
bytes4 internal constant ONLY_CALLABLE_BY_STAKING_CONTRACT_ERROR_SELECTOR = bytes4 internal constant ONLY_CALLABLE_BY_STAKING_CONTRACT_ERROR_SELECTOR =
0xca1d07a2; 0xca1d07a2;
// bytes4(keccak256("OnlyCallableInCatastrophicFailureError()")) // bytes4(keccak256("OnlyCallableInCatastrophicFailureError()"))
bytes4 internal constant ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR = bytes4 internal constant ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR =
0xa4f5de9d; 0xa4f5de9d;
// bytes4(keccak256("OnlyCallableNotInCatastrophicFailureError()")) // bytes4(keccak256("OnlyCallableNotInCatastrophicFailureError()"))
bytes4 internal constant ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR = bytes4 internal constant ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR =
0x7e8d2ed9; 0x7e8d2ed9;
// bytes4(keccak256("AmountExceedsBalanceOfPoolError(uint256,uint96)")) // bytes4(keccak256("AmountExceedsBalanceOfPoolError(uint256,uint96)"))
bytes4 internal constant AMOUNT_EXCEEDS_BALANCE_OF_POOL_ERROR_SELECTOR = bytes4 internal constant AMOUNT_EXCEEDS_BALANCE_OF_POOL_ERROR_SELECTOR =
0x4c5c09dd; 0x4c5c09dd;
// bytes4(keccak256("OperatorShareMustBeBetween0And100Error(bytes32,uint8)")) // bytes4(keccak256("OperatorShareMustBeBetween0And100Error(bytes32,uint8)"))
bytes4 internal constant OPERATOR_SHARE_MUST_BE_BETWEEN_0_AND_100_ERROR_SELECTOR = bytes4 internal constant OPERATOR_SHARE_MUST_BE_BETWEEN_0_AND_100_ERROR_SELECTOR =
0xde447684; 0xde447684;
// bytes4(keccak256("PoolAlreadyExistsError(bytes32)")) // bytes4(keccak256("PoolAlreadyExistsError(bytes32)"))
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
@ -132,7 +134,7 @@ library LibStakingRichErrors {
initialContractBalance initialContractBalance
); );
} }
function OnlyCallableByExchangeError( function OnlyCallableByExchangeError(
address senderAddress address senderAddress
) )
@ -145,8 +147,8 @@ library LibStakingRichErrors {
senderAddress senderAddress
); );
} }
function ExchangeAlreadyRegisteredError( function ExchangeAddressAlreadyRegisteredError(
address exchangeAddress address exchangeAddress
) )
internal internal
@ -154,11 +156,11 @@ 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
); );
} }
function ExchangeAddressNotRegisteredError( function ExchangeAddressNotRegisteredError(
address exchangeAddress address exchangeAddress
) )
@ -171,7 +173,7 @@ library LibStakingRichErrors {
exchangeAddress exchangeAddress
); );
} }
function SignatureLengthGreaterThan0RequiredError() function SignatureLengthGreaterThan0RequiredError()
internal internal
pure pure
@ -179,7 +181,7 @@ library LibStakingRichErrors {
{ {
return abi.encodeWithSelector(SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR); return abi.encodeWithSelector(SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR);
} }
function SignatureUnsupportedError( function SignatureUnsupportedError(
bytes memory signature bytes memory signature
) )
@ -192,7 +194,7 @@ library LibStakingRichErrors {
signature signature
); );
} }
function SignatureIllegalError( function SignatureIllegalError(
bytes memory signature bytes memory signature
) )
@ -205,7 +207,7 @@ library LibStakingRichErrors {
signature signature
); );
} }
function SignatureLength0RequiredError( function SignatureLength0RequiredError(
bytes memory signature bytes memory signature
) )
@ -218,7 +220,7 @@ library LibStakingRichErrors {
signature signature
); );
} }
function SignatureLength65RequiredError( function SignatureLength65RequiredError(
bytes memory signature bytes memory signature
) )
@ -231,7 +233,7 @@ library LibStakingRichErrors {
signature signature
); );
} }
function WalletError( function WalletError(
address walletAddress, address walletAddress,
bytes memory errorData bytes memory errorData
@ -246,7 +248,7 @@ library LibStakingRichErrors {
errorData errorData
); );
} }
function InsufficientBalanceError( function InsufficientBalanceError(
uint256 amount, uint256 amount,
uint256 balance uint256 balance
@ -261,7 +263,7 @@ library LibStakingRichErrors {
balance balance
); );
} }
function OnlyCallableByPoolOperatorError( function OnlyCallableByPoolOperatorError(
address senderAddress, address senderAddress,
address poolOperatorAddress address poolOperatorAddress
@ -276,7 +278,7 @@ library LibStakingRichErrors {
poolOperatorAddress poolOperatorAddress
); );
} }
function OnlyCallableByPoolOperatorOrMakerError( function OnlyCallableByPoolOperatorOrMakerError(
address senderAddress, address senderAddress,
address poolOperatorAddress, address poolOperatorAddress,
@ -293,7 +295,7 @@ library LibStakingRichErrors {
makerAddress makerAddress
); );
} }
function InvalidMakerSignatureError( function InvalidMakerSignatureError(
bytes32 poolId, bytes32 poolId,
address makerAddress, address makerAddress,
@ -310,7 +312,7 @@ library LibStakingRichErrors {
makerSignature makerSignature
); );
} }
function MakerAddressAlreadyRegisteredError( function MakerAddressAlreadyRegisteredError(
address makerAddress address makerAddress
) )
@ -323,7 +325,7 @@ library LibStakingRichErrors {
makerAddress makerAddress
); );
} }
function MakerAddressNotRegisteredError( function MakerAddressNotRegisteredError(
address makerAddress, address makerAddress,
bytes32 makerPoolId, bytes32 makerPoolId,
@ -340,7 +342,7 @@ library LibStakingRichErrors {
poolId poolId
); );
} }
function WithdrawAmountExceedsMemberBalanceError( function WithdrawAmountExceedsMemberBalanceError(
uint256 withdrawAmount, uint256 withdrawAmount,
uint256 balance uint256 balance
@ -355,7 +357,7 @@ library LibStakingRichErrors {
balance balance
); );
} }
function BlockTimestampTooLowError( function BlockTimestampTooLowError(
uint64 epochEndTime, uint64 epochEndTime,
uint64 currentBlockTimestamp uint64 currentBlockTimestamp
@ -370,7 +372,7 @@ library LibStakingRichErrors {
currentBlockTimestamp currentBlockTimestamp
); );
} }
function OnlyCallableByStakingContractError( function OnlyCallableByStakingContractError(
address senderAddress address senderAddress
) )
@ -383,7 +385,7 @@ library LibStakingRichErrors {
senderAddress senderAddress
); );
} }
function OnlyCallableInCatastrophicFailureError() function OnlyCallableInCatastrophicFailureError()
internal internal
pure pure
@ -391,7 +393,7 @@ library LibStakingRichErrors {
{ {
return abi.encodeWithSelector(ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR); return abi.encodeWithSelector(ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR);
} }
function OnlyCallableNotInCatastrophicFailureError() function OnlyCallableNotInCatastrophicFailureError()
internal internal
pure pure
@ -399,7 +401,7 @@ library LibStakingRichErrors {
{ {
return abi.encodeWithSelector(ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR); return abi.encodeWithSelector(ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR);
} }
function AmountExceedsBalanceOfPoolError( function AmountExceedsBalanceOfPoolError(
uint256 amount, uint256 amount,
uint96 poolBalance uint96 poolBalance
@ -414,7 +416,7 @@ library LibStakingRichErrors {
poolBalance poolBalance
); );
} }
function OperatorShareMustBeBetween0And100Error( function OperatorShareMustBeBetween0And100Error(
bytes32 poolId, bytes32 poolId,
uint8 poolOperatorShare uint8 poolOperatorShare
@ -429,7 +431,7 @@ library LibStakingRichErrors {
poolOperatorShare poolOperatorShare
); );
} }
function PoolAlreadyExistsError( function PoolAlreadyExistsError(
bytes32 poolId bytes32 poolId
) )
@ -442,4 +444,4 @@ library LibStakingRichErrors {
poolId poolId
); );
} }
} }

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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);
} }

View File

@ -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,

View File

@ -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 {