Binop -> BinOp

This commit is contained in:
Michael Zhu 2019-08-26 16:06:31 -07:00
parent 6827ebfb78
commit 078b1af04e
19 changed files with 176 additions and 176 deletions

View File

@ -1748,8 +1748,8 @@ describe('ERC1155Proxy', () => {
nftNotOwnerBalance, nftNotOwnerBalance,
]; ];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
maxUintValue, maxUintValue,
valueMultiplier, valueMultiplier,
); );
@ -1836,8 +1836,8 @@ describe('ERC1155Proxy', () => {
// check balances before transfer // check balances before transfer
const expectedInitialBalances = [spenderInitialFungibleBalance, receiverInitialFungibleBalance]; const expectedInitialBalances = [spenderInitialFungibleBalance, receiverInitialFungibleBalance];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
spenderInitialFungibleBalance, spenderInitialFungibleBalance,
valuesToTransfer[0].times(valueMultiplier), valuesToTransfer[0].times(valueMultiplier),
); );

View File

@ -173,8 +173,8 @@ describe('ERC1155Token', () => {
const tokenToTransfer = fungibleToken; const tokenToTransfer = fungibleToken;
const valueToTransfer = spenderInitialFungibleBalance.plus(1); const valueToTransfer = spenderInitialFungibleBalance.plus(1);
// create the expected error (a uint256 underflow) // create the expected error (a uint256 underflow)
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
spenderInitialFungibleBalance, spenderInitialFungibleBalance,
valueToTransfer, valueToTransfer,
); );
@ -349,8 +349,8 @@ describe('ERC1155Token', () => {
const tokensToTransfer = [fungibleToken]; const tokensToTransfer = [fungibleToken];
const valuesToTransfer = [spenderInitialFungibleBalance.plus(1)]; const valuesToTransfer = [spenderInitialFungibleBalance.plus(1)];
// create the expected error (a uint256 underflow) // create the expected error (a uint256 underflow)
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
spenderInitialFungibleBalance, spenderInitialFungibleBalance,
valuesToTransfer[0], valuesToTransfer[0],
); );

View File

@ -139,8 +139,8 @@ blockchainTests('LibFillResults', env => {
takerAssetAmount: MAX_UINT256_ROOT, takerAssetAmount: MAX_UINT256_ROOT,
}); });
const takerAssetFilledAmount = MAX_UINT256_ROOT; const takerAssetFilledAmount = MAX_UINT256_ROOT;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFilledAmount, takerAssetFilledAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
@ -162,8 +162,8 @@ blockchainTests('LibFillResults', env => {
order.takerAssetAmount, order.takerAssetAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
makerAssetFilledAmount, makerAssetFilledAmount,
order.makerFee, order.makerFee,
); );
@ -180,8 +180,8 @@ blockchainTests('LibFillResults', env => {
takerFee: MAX_UINT256_ROOT.times(11), takerFee: MAX_UINT256_ROOT.times(11),
}); });
const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10); const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFilledAmount, takerAssetFilledAmount,
order.takerFee, order.takerFee,
); );
@ -303,8 +303,8 @@ blockchainTests('LibFillResults', env => {
it('reverts if computing `makerAssetFilledAmount` overflows', async () => { it('reverts if computing `makerAssetFilledAmount` overflows', async () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.makerAssetFilledAmount = MAX_UINT256; b.makerAssetFilledAmount = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.makerAssetFilledAmount, a.makerAssetFilledAmount,
b.makerAssetFilledAmount, b.makerAssetFilledAmount,
); );
@ -314,8 +314,8 @@ blockchainTests('LibFillResults', env => {
it('reverts if computing `takerAssetFilledAmount` overflows', async () => { it('reverts if computing `takerAssetFilledAmount` overflows', async () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.takerAssetFilledAmount = MAX_UINT256; b.takerAssetFilledAmount = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.takerAssetFilledAmount, a.takerAssetFilledAmount,
b.takerAssetFilledAmount, b.takerAssetFilledAmount,
); );
@ -325,8 +325,8 @@ blockchainTests('LibFillResults', env => {
it('reverts if computing `makerFeePaid` overflows', async () => { it('reverts if computing `makerFeePaid` overflows', async () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.makerFeePaid = MAX_UINT256; b.makerFeePaid = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.makerFeePaid, a.makerFeePaid,
b.makerFeePaid, b.makerFeePaid,
); );
@ -336,8 +336,8 @@ blockchainTests('LibFillResults', env => {
it('reverts if computing `takerFeePaid` overflows', async () => { it('reverts if computing `takerFeePaid` overflows', async () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.takerFeePaid = MAX_UINT256; b.takerFeePaid = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.takerFeePaid, a.takerFeePaid,
b.takerFeePaid, b.takerFeePaid,
); );

View File

@ -71,8 +71,8 @@ blockchainTests('LibMath', env => {
const numerator = ONE_ETHER; const numerator = ONE_ETHER;
const denominator = ZERO_AMOUNT; const denominator = ZERO_AMOUNT;
const target = ONE_ETHER.times(0.01); const target = ONE_ETHER.times(0.01);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero,
numerator.times(target), numerator.times(target),
denominator, denominator,
); );
@ -85,8 +85,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -131,8 +131,8 @@ blockchainTests('LibMath', env => {
const denominator = ZERO_AMOUNT; const denominator = ZERO_AMOUNT;
const target = ONE_ETHER.times(0.01); const target = ONE_ETHER.times(0.01);
// This will actually manifest as a subtraction underflow. // This will actually manifest as a subtraction underflow.
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
denominator, denominator,
new BigNumber(1), new BigNumber(1),
); );
@ -145,8 +145,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -210,8 +210,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -275,8 +275,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -341,8 +341,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -407,8 +407,8 @@ blockchainTests('LibMath', env => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );

View File

@ -35,8 +35,8 @@ describe('Reference Functions', () => {
it('reverts if computing `makerAssetFilledAmount` overflows', () => { it('reverts if computing `makerAssetFilledAmount` overflows', () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.makerAssetFilledAmount = MAX_UINT256; b.makerAssetFilledAmount = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.makerAssetFilledAmount, a.makerAssetFilledAmount,
b.makerAssetFilledAmount, b.makerAssetFilledAmount,
); );
@ -46,8 +46,8 @@ describe('Reference Functions', () => {
it('reverts if computing `takerAssetFilledAmount` overflows', () => { it('reverts if computing `takerAssetFilledAmount` overflows', () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.takerAssetFilledAmount = MAX_UINT256; b.takerAssetFilledAmount = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.takerAssetFilledAmount, a.takerAssetFilledAmount,
b.takerAssetFilledAmount, b.takerAssetFilledAmount,
); );
@ -57,8 +57,8 @@ describe('Reference Functions', () => {
it('reverts if computing `makerFeePaid` overflows', () => { it('reverts if computing `makerFeePaid` overflows', () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.makerFeePaid = MAX_UINT256; b.makerFeePaid = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.makerFeePaid, a.makerFeePaid,
b.makerFeePaid, b.makerFeePaid,
); );
@ -68,8 +68,8 @@ describe('Reference Functions', () => {
it('reverts if computing `takerFeePaid` overflows', () => { it('reverts if computing `takerFeePaid` overflows', () => {
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS); const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
b.takerFeePaid = MAX_UINT256; b.takerFeePaid = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a.takerFeePaid, a.takerFeePaid,
b.takerFeePaid, b.takerFeePaid,
); );
@ -85,8 +85,8 @@ describe('Reference Functions', () => {
const numerator = ONE_ETHER; const numerator = ONE_ETHER;
const denominator = ZERO_AMOUNT; const denominator = ZERO_AMOUNT;
const target = ONE_ETHER.times(0.01); const target = ONE_ETHER.times(0.01);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero,
numerator.times(target), numerator.times(target),
denominator, denominator,
); );
@ -99,8 +99,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -118,8 +118,8 @@ describe('Reference Functions', () => {
const denominator = ZERO_AMOUNT; const denominator = ZERO_AMOUNT;
const target = ONE_ETHER.times(0.01); const target = ONE_ETHER.times(0.01);
// This will actually manifest as a subtraction underflow. // This will actually manifest as a subtraction underflow.
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
denominator, denominator,
new BigNumber(1), new BigNumber(1),
); );
@ -132,8 +132,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -170,8 +170,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -208,8 +208,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -254,8 +254,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );
@ -300,8 +300,8 @@ describe('Reference Functions', () => {
const numerator = MAX_UINT256; const numerator = MAX_UINT256;
const denominator = ONE_ETHER.dividedToIntegerBy(2); const denominator = ONE_ETHER.dividedToIntegerBy(2);
const target = MAX_UINT256_ROOT.times(2); const target = MAX_UINT256_ROOT.times(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
numerator, numerator,
target, target,
); );

View File

@ -77,8 +77,8 @@ blockchainTests('Exchange core internal functions', env => {
makerAssetAmount: constants.MAX_UINT256_ROOT, makerAssetAmount: constants.MAX_UINT256_ROOT,
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18),
}); });
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
leftOrder.makerAssetAmount, leftOrder.makerAssetAmount,
rightOrder.makerAssetAmount, rightOrder.makerAssetAmount,
); );
@ -94,8 +94,8 @@ blockchainTests('Exchange core internal functions', env => {
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(50, 18),
takerAssetAmount: constants.MAX_UINT256_ROOT, takerAssetAmount: constants.MAX_UINT256_ROOT,
}); });
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
leftOrder.takerAssetAmount, leftOrder.takerAssetAmount,
rightOrder.takerAssetAmount, rightOrder.takerAssetAmount,
); );
@ -228,8 +228,8 @@ blockchainTests('Exchange core internal functions', env => {
makerFeePaid: constants.ZERO_AMOUNT, makerFeePaid: constants.ZERO_AMOUNT,
takerFeePaid: constants.ZERO_AMOUNT, takerFeePaid: constants.ZERO_AMOUNT,
}; };
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
orderTakerAssetFilledAmount, orderTakerAssetFilledAmount,
takerAssetFillAmount, takerAssetFillAmount,
); );
@ -357,8 +357,8 @@ blockchainTests('Exchange core internal functions', env => {
rightOrder.takerFeeAssetData = leftOrder.takerFeeAssetData; rightOrder.takerFeeAssetData = leftOrder.takerFeeAssetData;
// The expected error that should be thrown by the function. // The expected error that should be thrown by the function.
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
matchedFillResults.left.takerFeePaid, matchedFillResults.left.takerFeePaid,
matchedFillResults.right.takerFeePaid, matchedFillResults.right.takerFeePaid,
); );

View File

@ -443,8 +443,8 @@ blockchainTests('Isolated fillOrder() tests', env => {
takerAssetAmount: MAX_UINT256_ROOT, takerAssetAmount: MAX_UINT256_ROOT,
}); });
const takerAssetFillAmount = MAX_UINT256_ROOT; const takerAssetFillAmount = MAX_UINT256_ROOT;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFillAmount, takerAssetFillAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
@ -464,8 +464,8 @@ blockchainTests('Isolated fillOrder() tests', env => {
order.takerAssetAmount, order.takerAssetAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
makerAssetFilledAmount, makerAssetFilledAmount,
order.makerFee, order.makerFee,
); );
@ -480,8 +480,8 @@ blockchainTests('Isolated fillOrder() tests', env => {
takerFee: MAX_UINT256_ROOT.times(11), takerFee: MAX_UINT256_ROOT.times(11),
}); });
const takerAssetFillAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10); const takerAssetFillAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFillAmount, takerAssetFillAmount,
order.takerFee, order.takerFee,
); );

View File

@ -39,8 +39,8 @@ describe('Reference functions', () => {
takerAssetAmount: MAX_UINT256_ROOT, takerAssetAmount: MAX_UINT256_ROOT,
}); });
const takerAssetFilledAmount = MAX_UINT256_ROOT; const takerAssetFilledAmount = MAX_UINT256_ROOT;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFilledAmount, takerAssetFilledAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
@ -60,8 +60,8 @@ describe('Reference functions', () => {
order.takerAssetAmount, order.takerAssetAmount,
order.makerAssetAmount, order.makerAssetAmount,
); );
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
makerAssetFilledAmount, makerAssetFilledAmount,
order.makerFee, order.makerFee,
); );
@ -76,8 +76,8 @@ describe('Reference functions', () => {
takerFee: MAX_UINT256_ROOT.times(11), takerFee: MAX_UINT256_ROOT.times(11),
}); });
const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10); const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
takerAssetFilledAmount, takerAssetFilledAmount,
order.takerFee, order.takerFee,
); );

View File

@ -718,8 +718,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
const signatures = _.times(COUNT, i => createOrderSignature(orders[i])); const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
orders[1].takerAssetAmount = MAX_UINT256; orders[1].takerAssetAmount = MAX_UINT256;
const takerAssetFillAmount = MAX_UINT256; const takerAssetFillAmount = MAX_UINT256;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
orders[0].takerAssetAmount, orders[0].takerAssetAmount,
orders[1].takerAssetAmount, orders[1].takerAssetAmount,
); );
@ -1031,8 +1031,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })]; const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })];
const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); const signatures = _.times(orders.length, i => createOrderSignature(orders[i]));
const makerAssetFillAmount = new BigNumber(2); const makerAssetFillAmount = new BigNumber(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
orders[0].takerAssetAmount, orders[0].takerAssetAmount,
makerAssetFillAmount, makerAssetFillAmount,
); );
@ -1044,8 +1044,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })]; const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })];
const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); const signatures = _.times(orders.length, i => createOrderSignature(orders[i]));
const makerAssetFillAmount = ONE_ETHER; const makerAssetFillAmount = ONE_ETHER;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero,
orders[0].takerAssetAmount.times(makerAssetFillAmount), orders[0].takerAssetAmount.times(makerAssetFillAmount),
orders[0].makerAssetAmount, orders[0].makerAssetAmount,
); );
@ -1066,8 +1066,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
]; ];
const signatures = _.times(orders.length, i => createOrderSignature(orders[i])); const signatures = _.times(orders.length, i => createOrderSignature(orders[i]));
const makerAssetFillAmount = new BigNumber(2); const makerAssetFillAmount = new BigNumber(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
orders[0].makerAssetAmount, orders[0].makerAssetAmount,
orders[1].makerAssetAmount, orders[1].makerAssetAmount,
); );

View File

@ -32,8 +32,8 @@ library LibSafeMath {
function _add(uint256 a, uint256 b) internal pure returns (uint256) { function _add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b; uint256 c = a + b;
if (c < a) { if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a, a,
b b
)); ));
@ -46,8 +46,8 @@ library LibSafeMath {
/// Note that this reverts on underflow. /// Note that this reverts on underflow.
function _sub(uint256 a, uint256 b) internal pure returns (uint256) { function _sub(uint256 a, uint256 b) internal pure returns (uint256) {
if (b > a) { if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a, a,
b b
)); ));
@ -69,8 +69,8 @@ library LibSafeMath {
uint256 c = a * b; uint256 c = a * b;
if (c / a != b) { if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a, a,
b b
)); ));
@ -83,8 +83,8 @@ library LibSafeMath {
/// Note that this reverts on division by zero. The result is rounded towards zero. /// Note that this reverts on division by zero. The result is rounded towards zero.
function _div(uint256 a, uint256 b) internal pure returns (uint256) { function _div(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) { if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO, LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a, a,
b b
)); ));

View File

@ -29,8 +29,8 @@ library LibSafeMath64 {
function _add(uint64 a, uint64 b) internal pure returns (uint64) { function _add(uint64 a, uint64 b) internal pure returns (uint64) {
uint64 c = a + b; uint64 c = a + b;
if (c < a) { if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a, a,
b b
)); ));
@ -43,8 +43,8 @@ library LibSafeMath64 {
/// Note that this reverts on underflow. /// Note that this reverts on underflow.
function _sub(uint64 a, uint64 b) internal pure returns (uint64) { function _sub(uint64 a, uint64 b) internal pure returns (uint64) {
if (b > a) { if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a, a,
b b
)); ));
@ -66,8 +66,8 @@ library LibSafeMath64 {
uint64 c = a * b; uint64 c = a * b;
if (c / a != b) { if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a, a,
b b
)); ));
@ -80,8 +80,8 @@ library LibSafeMath64 {
/// Note that this reverts on division by zero. The result is rounded towards zero. /// Note that this reverts on division by zero. The result is rounded towards zero.
function _div(uint64 a, uint64 b) internal pure returns (uint64) { function _div(uint64 a, uint64 b) internal pure returns (uint64) {
if (b == 0) { if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO, LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a, a,
b b
)); ));

View File

@ -29,8 +29,8 @@ library LibSafeMath96 {
function _add(uint96 a, uint96 b) internal pure returns (uint96) { function _add(uint96 a, uint96 b) internal pure returns (uint96) {
uint96 c = a + b; uint96 c = a + b;
if (c < a) { if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a, a,
b b
)); ));
@ -43,8 +43,8 @@ library LibSafeMath96 {
/// Note that this reverts on underflow. /// Note that this reverts on underflow.
function _sub(uint96 a, uint96 b) internal pure returns (uint96) { function _sub(uint96 a, uint96 b) internal pure returns (uint96) {
if (b > a) { if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a, a,
b b
)); ));
@ -66,8 +66,8 @@ library LibSafeMath96 {
uint96 c = a * b; uint96 c = a * b;
if (c / a != b) { if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a, a,
b b
)); ));
@ -80,8 +80,8 @@ library LibSafeMath96 {
/// Note that this reverts on division by zero. The result is rounded towards zero. /// Note that this reverts on division by zero. The result is rounded towards zero.
function _div(uint96 a, uint96 b) internal pure returns (uint96) { function _div(uint96 a, uint96 b) internal pure returns (uint96) {
if (b == 0) { if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO, LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a, a,
b b
)); ));

View File

@ -16,8 +16,8 @@ library LibSafeMath {
} }
uint256 c = a * b; uint256 c = a * b;
if (c / a != b) { if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a, a,
b b
)); ));
@ -31,8 +31,8 @@ library LibSafeMath {
returns (uint256) returns (uint256)
{ {
if (b == 0) { if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO, LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a, a,
b b
)); ));
@ -47,8 +47,8 @@ library LibSafeMath {
returns (uint256) returns (uint256)
{ {
if (b > a) { if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a, a,
b b
)); ));
@ -63,8 +63,8 @@ library LibSafeMath {
{ {
uint256 c = a + b; uint256 c = a + b;
if (c < a) { if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a, a,
b b
)); ));

View File

@ -3,23 +3,23 @@ pragma solidity ^0.5.9;
library LibSafeMathRichErrors { library LibSafeMathRichErrors {
// bytes4(keccak256("Uint256BinopError(uint8,uint256,uint256)")) // bytes4(keccak256("Uint256BinOpError(uint8,uint256,uint256)"))
bytes4 internal constant UINT256_BINOP_ERROR_SELECTOR = bytes4 internal constant UINT256_BINOP_ERROR_SELECTOR =
0x8d8e1919; 0xe946c1bb;
// bytes4(keccak256("Uint96BinopError(uint8,uint96,uint96)")) // bytes4(keccak256("Uint96BinOpError(uint8,uint96,uint96)"))
bytes4 internal constant UINT96_BINOP_ERROR_SELECTOR = bytes4 internal constant UINT96_BINOP_ERROR_SELECTOR =
0x224cf712; 0xe486a353;
// bytes4(keccak256("Uint64BinopError(uint8,uint64,uint64)")) // bytes4(keccak256("Uint64BinOpError(uint8,uint64,uint64)"))
bytes4 internal constant UINT64_BINOP_ERROR_SELECTOR = bytes4 internal constant UINT64_BINOP_ERROR_SELECTOR =
0x4e79032d; 0x67e71b32;
// bytes4(keccak256("Uint256DowncastError(uint8,uint256)")) // bytes4(keccak256("Uint256DowncastError(uint8,uint256)"))
bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR = bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR =
0xc996af7b; 0xc996af7b;
enum BinopErrorCodes { enum BinOpErrorCodes {
ADDITION_OVERFLOW, ADDITION_OVERFLOW,
MULTIPLICATION_OVERFLOW, MULTIPLICATION_OVERFLOW,
SUBTRACTION_UNDERFLOW, SUBTRACTION_UNDERFLOW,
@ -32,8 +32,8 @@ library LibSafeMathRichErrors {
} }
// solhint-disable func-name-mixedcase // solhint-disable func-name-mixedcase
function Uint256BinopError( function Uint256BinOpError(
BinopErrorCodes errorCode, BinOpErrorCodes errorCode,
uint256 a, uint256 a,
uint256 b uint256 b
) )
@ -49,8 +49,8 @@ library LibSafeMathRichErrors {
); );
} }
function Uint96BinopError( function Uint96BinOpError(
BinopErrorCodes errorCode, BinOpErrorCodes errorCode,
uint96 a, uint96 a,
uint96 b uint96 b
) )
@ -66,8 +66,8 @@ library LibSafeMathRichErrors {
); );
} }
function Uint64BinopError( function Uint64BinOpError(
BinopErrorCodes errorCode, BinOpErrorCodes errorCode,
uint64 a, uint64 a,
uint64 b uint64 b
) )

View File

@ -16,8 +16,8 @@ contract SafeMath {
} }
uint256 c = a * b; uint256 c = a * b;
if (c / a != b) { if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a, a,
b b
)); ));
@ -31,8 +31,8 @@ contract SafeMath {
returns (uint256) returns (uint256)
{ {
if (b == 0) { if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO, LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a, a,
b b
)); ));
@ -47,8 +47,8 @@ contract SafeMath {
returns (uint256) returns (uint256)
{ {
if (b > a) { if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a, a,
b b
)); ));
@ -63,8 +63,8 @@ contract SafeMath {
{ {
uint256 c = a + b; uint256 c = a + b;
if (c < a) { if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError( LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW, LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a, a,
b b
)); ));

View File

@ -8,7 +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(SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, a, b); throw new SafeMathRevertErrors.Uint256BinOpError(SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow, a, b);
} }
return r; return r;
} }
@ -19,8 +19,8 @@ export function safeAdd(a: BigNumber, b: BigNumber): BigNumber {
export function safeSub(a: BigNumber, b: BigNumber): BigNumber { export function safeSub(a: BigNumber, b: BigNumber): BigNumber {
const r = a.minus(b); const r = a.minus(b);
if (r.isLessThan(0)) { if (r.isLessThan(0)) {
throw new SafeMathRevertErrors.Uint256BinopError( throw new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
a, a,
b, b,
); );
@ -34,8 +34,8 @@ export function safeSub(a: BigNumber, b: BigNumber): BigNumber {
export function safeMul(a: BigNumber, b: BigNumber): BigNumber { export function safeMul(a: BigNumber, b: BigNumber): BigNumber {
const r = a.times(b); const r = a.times(b);
if (r.isGreaterThan(MAX_UINT256)) { if (r.isGreaterThan(MAX_UINT256)) {
throw new SafeMathRevertErrors.Uint256BinopError( throw new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
a, a,
b, b,
); );
@ -48,7 +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(SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, a, b); throw new SafeMathRevertErrors.Uint256BinOpError(SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero, a, b);
} }
return a.dividedToIntegerBy(b); return a.dividedToIntegerBy(b);
} }

View File

@ -21,8 +21,8 @@ describe('Reference Functions', () => {
it('reverts on overflow', () => { it('reverts on overflow', () => {
const a = MAX_UINT256.dividedToIntegerBy(2); const a = MAX_UINT256.dividedToIntegerBy(2);
const b = MAX_UINT256.dividedToIntegerBy(2).plus(2); const b = MAX_UINT256.dividedToIntegerBy(2).plus(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a, a,
b, b,
); );
@ -41,8 +41,8 @@ describe('Reference Functions', () => {
it('reverts on underflow', () => { it('reverts on underflow', () => {
const a = MAX_UINT256.dividedToIntegerBy(2); const a = MAX_UINT256.dividedToIntegerBy(2);
const b = MAX_UINT256.dividedToIntegerBy(2).plus(2); const b = MAX_UINT256.dividedToIntegerBy(2).plus(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
a, a,
b, b,
); );
@ -61,8 +61,8 @@ describe('Reference Functions', () => {
it('reverts on overflow', () => { it('reverts on overflow', () => {
const a = MAX_UINT256.dividedToIntegerBy(2); const a = MAX_UINT256.dividedToIntegerBy(2);
const b = MAX_UINT256.dividedToIntegerBy(2).plus(2); const b = MAX_UINT256.dividedToIntegerBy(2).plus(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
a, a,
b, b,
); );
@ -81,8 +81,8 @@ describe('Reference Functions', () => {
it('reverts if denominator is zero', () => { it('reverts if denominator is zero', () => {
const a = MAX_UINT256.dividedToIntegerBy(2); const a = MAX_UINT256.dividedToIntegerBy(2);
const b = ZERO_AMOUNT; const b = ZERO_AMOUNT;
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero,
a, a,
b, b,
); );

View File

@ -45,8 +45,8 @@ blockchainTests('SafeMath', env => {
it('should revert if the multiplication overflows', async () => { it('should revert if the multiplication overflows', async () => {
const a = toBigNumber('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number const a = toBigNumber('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number
const b = toBigNumber(2); const b = toBigNumber(2);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow, SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
a, a,
b, b,
); );
@ -91,8 +91,8 @@ blockchainTests('SafeMath', env => {
it('should revert if second argument is zero', async () => { it('should revert if second argument is zero', async () => {
const a = toBigNumber(1); const a = toBigNumber(1);
const b = toBigNumber(0); const b = toBigNumber(0);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.DivisionByZero, SafeMathRevertErrors.BinOpErrorCodes.DivisionByZero,
a, a,
b, b,
); );
@ -112,8 +112,8 @@ blockchainTests('SafeMath', env => {
it('should revert if the subtraction underflows', async () => { it('should revert if the subtraction underflows', async () => {
const a = toBigNumber(0); const a = toBigNumber(0);
const b = toBigNumber(1); const b = toBigNumber(1);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow, SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
a, a,
b, b,
); );
@ -143,8 +143,8 @@ blockchainTests('SafeMath', env => {
it('should revert if the addition overflows', async () => { it('should revert if the addition overflows', async () => {
const a = toBigNumber('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number const a = toBigNumber('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number
const b = toBigNumber(1); const b = toBigNumber(1);
const expectedError = new SafeMathRevertErrors.Uint256BinopError( const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinopErrorCodes.AdditionOverflow, SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
a, a,
b, b,
); );

View File

@ -3,7 +3,7 @@ import { RevertError } from './revert_error';
// tslint:disable:max-classes-per-file // tslint:disable:max-classes-per-file
export enum BinopErrorCodes { export enum BinOpErrorCodes {
AdditionOverflow, AdditionOverflow,
MultiplicationOverflow, MultiplicationOverflow,
SubtractionUnderflow, SubtractionUnderflow,
@ -15,9 +15,9 @@ export enum DowncastErrorCodes {
ValueTooLargeToDowncastToUint96, ValueTooLargeToDowncastToUint96,
} }
export class Uint256BinopError extends RevertError { export class Uint256BinOpError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) { constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint256BinopError', 'Uint256BinopError(uint8 error, uint256 a, uint256 b)', { super('Uint256BinOpError', 'Uint256BinOpError(uint8 error, uint256 a, uint256 b)', {
error, error,
a, a,
b, b,
@ -25,9 +25,9 @@ export class Uint256BinopError extends RevertError {
} }
} }
export class Uint96BinopError extends RevertError { export class Uint96BinOpError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) { constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint96BinopError', 'Uint96BinopError(uint8 error, uint96 a, uint96 b)', { super('Uint96BinOpError', 'Uint96BinOpError(uint8 error, uint96 a, uint96 b)', {
error, error,
a, a,
b, b,
@ -35,9 +35,9 @@ export class Uint96BinopError extends RevertError {
} }
} }
export class Uint64BinopError extends RevertError { export class Uint64BinOpError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) { constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint64BinopError', 'Uint64BinopError(uint8 error, uint64 a, uint64 b)', { super('Uint64BinOpError', 'Uint64BinOpError(uint8 error, uint64 a, uint64 b)', {
error, error,
a, a,
b, b,
@ -54,7 +54,7 @@ export class Uint256DowncastError extends RevertError {
} }
} }
const types = [Uint256BinopError, Uint96BinopError, Uint64BinopError, Uint256DowncastError]; const types = [Uint256BinOpError, Uint96BinOpError, Uint64BinOpError, Uint256DowncastError];
// Register the types we've defined. // Register the types we've defined.
for (const type of types) { for (const type of types) {