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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,8 +16,8 @@ contract SafeMath {
}
uint256 c = a * b;
if (c / a != b) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError(
LibSafeMathRichErrors.BinopErrorCodes.MULTIPLICATION_OVERFLOW,
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
a,
b
));
@ -31,8 +31,8 @@ contract SafeMath {
returns (uint256)
{
if (b == 0) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError(
LibSafeMathRichErrors.BinopErrorCodes.DIVISION_BY_ZERO,
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
a,
b
));
@ -47,8 +47,8 @@ contract SafeMath {
returns (uint256)
{
if (b > a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError(
LibSafeMathRichErrors.BinopErrorCodes.SUBTRACTION_UNDERFLOW,
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
a,
b
));
@ -63,8 +63,8 @@ contract SafeMath {
{
uint256 c = a + b;
if (c < a) {
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinopError(
LibSafeMathRichErrors.BinopErrorCodes.ADDITION_OVERFLOW,
LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError(
LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
a,
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 {
const r = a.plus(b);
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;
}
@ -19,8 +19,8 @@ export function safeAdd(a: BigNumber, b: BigNumber): BigNumber {
export function safeSub(a: BigNumber, b: BigNumber): BigNumber {
const r = a.minus(b);
if (r.isLessThan(0)) {
throw new SafeMathRevertErrors.Uint256BinopError(
SafeMathRevertErrors.BinopErrorCodes.SubtractionUnderflow,
throw new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow,
a,
b,
);
@ -34,8 +34,8 @@ export function safeSub(a: BigNumber, b: BigNumber): BigNumber {
export function safeMul(a: BigNumber, b: BigNumber): BigNumber {
const r = a.times(b);
if (r.isGreaterThan(MAX_UINT256)) {
throw new SafeMathRevertErrors.Uint256BinopError(
SafeMathRevertErrors.BinopErrorCodes.MultiplicationOverflow,
throw new SafeMathRevertErrors.Uint256BinOpError(
SafeMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow,
a,
b,
);
@ -48,7 +48,7 @@ export function safeMul(a: BigNumber, b: BigNumber): BigNumber {
*/
export function safeDiv(a: BigNumber, b: BigNumber): BigNumber {
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);
}

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import { RevertError } from './revert_error';
// tslint:disable:max-classes-per-file
export enum BinopErrorCodes {
export enum BinOpErrorCodes {
AdditionOverflow,
MultiplicationOverflow,
SubtractionUnderflow,
@ -15,9 +15,9 @@ export enum DowncastErrorCodes {
ValueTooLargeToDowncastToUint96,
}
export class Uint256BinopError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint256BinopError', 'Uint256BinopError(uint8 error, uint256 a, uint256 b)', {
export class Uint256BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint256BinOpError', 'Uint256BinOpError(uint8 error, uint256 a, uint256 b)', {
error,
a,
b,
@ -25,9 +25,9 @@ export class Uint256BinopError extends RevertError {
}
}
export class Uint96BinopError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint96BinopError', 'Uint96BinopError(uint8 error, uint96 a, uint96 b)', {
export class Uint96BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint96BinOpError', 'Uint96BinOpError(uint8 error, uint96 a, uint96 b)', {
error,
a,
b,
@ -35,9 +35,9 @@ export class Uint96BinopError extends RevertError {
}
}
export class Uint64BinopError extends RevertError {
constructor(error?: BinopErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint64BinopError', 'Uint64BinopError(uint8 error, uint64 a, uint64 b)', {
export class Uint64BinOpError extends RevertError {
constructor(error?: BinOpErrorCodes, a?: BigNumber, b?: BigNumber) {
super('Uint64BinOpError', 'Uint64BinOpError(uint8 error, uint64 a, uint64 b)', {
error,
a,
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.
for (const type of types) {