aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 18:20:28 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 19:26:13 +0800
commit8c44b102fc48a4ba8a662be3b603ce2af0e8acf6 (patch)
treec6aa3b3a811ea3d07491c79c6540c90d1475e91c /src
parent65beef5b9cf3a859ec2d24a7b68d02e6d8425fba (diff)
downloaddexon-sol-tools-8c44b102fc48a4ba8a662be3b603ce2af0e8acf6.tar.gz
dexon-sol-tools-8c44b102fc48a4ba8a662be3b603ce2af0e8acf6.tar.zst
dexon-sol-tools-8c44b102fc48a4ba8a662be3b603ce2af0e8acf6.zip
Remove assertions from utils methods
Diffstat (limited to 'src')
-rw-r--r--src/0x.js.ts4
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts5
-rw-r--r--src/utils/utils.ts7
3 files changed, 5 insertions, 11 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index fa52d4ad8..7b53b70ea 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -16,6 +16,8 @@ import {ecSignatureSchema} from './schemas/ec_signature_schema';
import {TokenWrapper} from './contract_wrappers/token_wrapper';
import {ECSignature, ZeroExError, Order, SignedOrder} from './types';
import * as ExchangeArtifacts from './artifacts/Exchange.json';
+import {SchemaValidator} from './utils/schema_validator';
+import {orderSchema} from './schemas/order_schemas';
// Customize our BigNumber instances
bigNumberConfigs.configure();
@@ -128,6 +130,8 @@ export class ZeroEx {
* Computes the orderHash for a given order and returns it as a hex encoded string.
*/
public async getOrderHashHexAsync(order: Order|SignedOrder): Promise<string> {
+ assert.doesConformToSchema(
+ 'order', SchemaValidator.convertToJSONSchemaCompatibleObject(order as object), orderSchema);
const exchangeContractAddr = await this.getExchangeAddressAsync();
const hashHex = utils.getOrderHashHex(order, exchangeContractAddr);
return hashHex;
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index bd057eacd..408d3deed 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -253,10 +253,7 @@ export class ExchangeWrapper extends ContractWrapper {
logEventObj.watch(callback);
this.exchangeLogEventObjs.push(logEventObj);
}
- /**
- * Computes the orderHash for a given order and returns it as a hex encoded string.
- */
- public async getOrderHashAsync(order: Order|SignedOrder): Promise<string> {
+ private async getOrderHashAsync(order: Order|SignedOrder): Promise<string> {
const [orderAddresses, orderValues] = ExchangeWrapper.getOrderAddressesAndValues(order);
const exchangeInstance = await this.getExchangeContractAsync();
const orderHash = utils.getOrderHashHex(order, exchangeInstance.address);
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index 0da83c366..5786bab07 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -2,10 +2,7 @@ import * as _ from 'lodash';
import * as BN from 'bn.js';
import * as ethABI from 'ethereumjs-abi';
import * as ethUtil from 'ethereumjs-util';
-import {orderSchema} from '../schemas/order_schemas';
-import {SchemaValidator} from './schema_validator';
import {Order, SignedOrder, SolidityTypes} from '../types';
-import {assert} from './assert';
import * as BigNumber from 'bignumber.js';
export const utils = {
@@ -33,10 +30,6 @@ export const utils = {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
getOrderHashHex(order: Order|SignedOrder, exchangeContractAddr: string): string {
- assert.doesConformToSchema('order',
- SchemaValidator.convertToJSONSchemaCompatibleObject(order as object),
- orderSchema);
-
const orderParts = [
{value: exchangeContractAddr, type: SolidityTypes.address},
{value: order.maker, type: SolidityTypes.address},