diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-12 04:14:03 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-12 04:14:03 +0800 |
commit | fe58b449162e0c55b6021a65a93d17719f1eb98f (patch) | |
tree | cf48b513a6f4045c0e240379fd8cb61f3974f4e9 /packages/order-utils | |
parent | 0a2694811dc680f53f9f390a379b84dbc1a39fc2 (diff) | |
download | dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar.gz dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar.bz2 dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar.lz dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar.xz dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.tar.zst dexon-sol-tools-fe58b449162e0c55b6021a65a93d17719f1eb98f.zip |
Validate all signature types rather then only ECSignatures
Diffstat (limited to 'packages/order-utils')
-rw-r--r-- | packages/order-utils/src/order_validation_utils.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/order-utils/src/order_validation_utils.ts b/packages/order-utils/src/order_validation_utils.ts index aebb6db70..3a6704f26 100644 --- a/packages/order-utils/src/order_validation_utils.ts +++ b/packages/order-utils/src/order_validation_utils.ts @@ -1,5 +1,6 @@ import { ExchangeContractErrs, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; import { OrderError, TradeSide, TransferType } from './types'; @@ -8,7 +9,7 @@ import { constants } from './constants'; import { ExchangeTransferSimulator } from './exchange_transfer_simulator'; import { ExchangeContract } from './generated_contract_wrappers/exchange'; import { orderHashUtils } from './order_hash'; -import { isValidECSignature, parseECSignature } from './signature_utils'; +import { isValidSignatureAsync } from './signature_utils'; import { utils } from './utils'; export class OrderValidationUtils { @@ -157,6 +158,7 @@ export class OrderValidationUtils { } public async validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator: ExchangeTransferSimulator, + provider: Provider, signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber, takerAddress: string, @@ -166,9 +168,13 @@ export class OrderValidationUtils { throw new Error(ExchangeContractErrs.OrderFillAmountZero); } const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - // TODO: Verify all signature types! To do this, we need access to a Provider... - const ecSignature = parseECSignature(signedOrder.signature); - if (!isValidECSignature(orderHash, ecSignature, signedOrder.makerAddress)) { + const isValid = await isValidSignatureAsync( + provider, + orderHash, + signedOrder.signature, + signedOrder.makerAddress, + ); + if (!isValid) { throw new Error(OrderError.InvalidSignature); } const filledTakerTokenAmount = await this._exchangeContract.filled.callAsync(orderHash); @@ -204,6 +210,7 @@ export class OrderValidationUtils { } public async validateFillOrKillOrderThrowIfInvalidAsync( exchangeTradeEmulator: ExchangeTransferSimulator, + provider: Provider, signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber, takerAddress: string, @@ -211,6 +218,7 @@ export class OrderValidationUtils { ): Promise<void> { const filledTakerTokenAmount = await this.validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator, + provider, signedOrder, fillTakerTokenAmount, takerAddress, |