diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-05 18:22:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-06 16:33:34 +0800 |
commit | 501f054d5115ffe923cfc2b21393e36674097a82 (patch) | |
tree | e43c846efe2a151b9809bcf00a155956f51e48e6 /src/utils/order_validation_utils.ts | |
parent | 0275ac9dada35648ffb3b543f6ba2546117a3b63 (diff) | |
download | dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar.gz dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar.bz2 dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar.lz dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar.xz dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.tar.zst dexon-0x-contracts-501f054d5115ffe923cfc2b21393e36674097a82.zip |
Add signature verification as a part of order validation and tests for it
Diffstat (limited to 'src/utils/order_validation_utils.ts')
-rw-r--r-- | src/utils/order_validation_utils.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/utils/order_validation_utils.ts b/src/utils/order_validation_utils.ts index 445ad43f9..e64666dfc 100644 --- a/src/utils/order_validation_utils.ts +++ b/src/utils/order_validation_utils.ts @@ -1,4 +1,5 @@ -import {ExchangeContractErrs, SignedOrder, Order} from '../types'; +import {ExchangeContractErrs, SignedOrder, Order, ZeroExError} from '../types'; +import {ZeroEx} from '../0x.js'; import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; import {utils} from '../utils/utils'; @@ -19,6 +20,9 @@ export class OrderValidationUtils { throw new Error(ExchangeContractErrs.OrderFillAmountZero); } const orderHash = utils.getOrderHashHex(signedOrder); + if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) { + throw new Error(ZeroExError.InvalidSignature); + } const unavailableTakerTokenAmount = await this.exchangeWrapper.getUnavailableTakerAmountAsync(orderHash); if (signedOrder.makerTokenAmount.eq(unavailableTakerTokenAmount)) { throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero); |