aboutsummaryrefslogtreecommitdiffstats
path: root/packages/assert/src
diff options
context:
space:
mode:
authorJacob Evans <dekz@dekz.net>2018-01-19 09:19:14 +0800
committerGitHub <noreply@github.com>2018-01-19 09:19:14 +0800
commit22b1ee132a904757e4bfb7ed33826cb849029d2a (patch)
tree7fa2dcd7a8a14cc640a2a7b75d28dfcdf9b9b1f0 /packages/assert/src
parent4ac6e5477dfe648722faa7cdd7b7752ad929d08d (diff)
parentab7f681f153778a5af4e2e2ac7713c384fe3ec79 (diff)
downloaddexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar.gz
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar.bz2
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar.lz
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar.xz
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.tar.zst
dexon-sol-tools-22b1ee132a904757e4bfb7ed33826cb849029d2a.zip
Merge pull request #324 from 0xProject/fix/0x.js/negativeFillValues
Reject negative amounts in public methods
Diffstat (limited to 'packages/assert/src')
-rw-r--r--packages/assert/src/index.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 56f663780..7ad574ec7 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -12,6 +12,8 @@ export const assert = {
},
isValidBaseUnitAmount(variableName: string, value: BigNumber) {
assert.isBigNumber(variableName, value);
+ const isNegative = value.lessThan(0);
+ this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
const hasDecimals = value.decimalPlaces() !== 0;
this.assert(
!hasDecimals,