diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-09-05 02:55:08 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-09-05 02:55:08 +0800 |
commit | f5237f79716fb9ab5f16a64445fb21ea715d70b8 (patch) | |
tree | b05b201bedf699fb4ab858c46a8d4866f8c15335 /packages/website/ts | |
parent | a14450f367d1a1f651f85ac6b0ad710fc2785e83 (diff) | |
download | dexon-0x-contracts-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.gz dexon-0x-contracts-f5237f79716fb9ab5f16a64445fb21ea715d70b8.tar.zst dexon-0x-contracts-f5237f79716fb9ab5f16a64445fb21ea715d70b8.zip |
Use order parser utils from order utils
Diffstat (limited to 'packages/website/ts')
-rw-r--r-- | packages/website/ts/blockchain.ts | 3 | ||||
-rw-r--r-- | packages/website/ts/components/fill_order.tsx | 4 | ||||
-rw-r--r-- | packages/website/ts/components/generate_order/generate_order_form.tsx | 3 | ||||
-rw-r--r-- | packages/website/ts/components/order_json.tsx | 1 | ||||
-rw-r--r-- | packages/website/ts/containers/generate_order_form.ts | 1 | ||||
-rw-r--r-- | packages/website/ts/redux/dispatcher.ts | 1 | ||||
-rw-r--r-- | packages/website/ts/redux/reducer.ts | 1 | ||||
-rw-r--r-- | packages/website/ts/types.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/utils/order_parser.ts | 33 | ||||
-rw-r--r-- | packages/website/ts/utils/utils.ts | 2 |
10 files changed, 9 insertions, 42 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index b97d86e99..711185cb1 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -19,7 +19,7 @@ import { SignerSubprovider, Web3ProviderEngine, } from '@0xproject/subproviders'; -import { ECSignature, Order, SignedOrder, Token as ZeroExToken } from '@0xproject/types'; +import { SignedOrder, Token as ZeroExToken } from '@0xproject/types'; import { BigNumber, intervalUtils, logUtils, promisify } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { BlockParam, LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; @@ -42,7 +42,6 @@ import { InjectedProviderObservable, InjectedProviderUpdate, InjectedWeb3, - PortalOrder, Providers, ProviderType, Side, diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index 95f2039b3..d082b9f70 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -1,6 +1,5 @@ -import { assetDataUtils, orderHashUtils, signatureUtils } from '@0xproject/order-utils'; +import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils'; import { colors } from '@0xproject/react-shared'; -import { Order as ZeroExOrder } from '@0xproject/types'; import { BigNumber, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as accounting from 'accounting'; @@ -24,7 +23,6 @@ import { portalOrderSchema } from 'ts/schemas/portal_order_schema'; import { validator } from 'ts/schemas/validator'; import { AlertTypes, BlockchainErrs, PortalOrder, Token, TokenByAddress, WebsitePaths } from 'ts/types'; import { analytics } from 'ts/utils/analytics'; -import { constants } from 'ts/utils/constants'; import { errorReporter } from 'ts/utils/error_reporter'; import { orderParser } from 'ts/utils/order_parser'; import { utils } from 'ts/utils/utils'; diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx index bb6265170..ec153c005 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -1,6 +1,6 @@ import { assetDataUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils'; import { colors } from '@0xproject/react-shared'; -import { ECSignature, Order as ZeroExOrder } from '@0xproject/types'; +import { Order as ZeroExOrder } from '@0xproject/types'; import { BigNumber, logUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; @@ -353,7 +353,6 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G this.props.tokenByAddress, hashData.orderSalt, ); - console.log(order); const validationResult = validator.validate(order, portalOrderSchema); if (validationResult.errors.length > 0) { globalErrMsg = 'Order signing failed. Please refresh and try again'; diff --git a/packages/website/ts/components/order_json.tsx b/packages/website/ts/components/order_json.tsx index 2a4d992a0..a2a53a523 100644 --- a/packages/website/ts/components/order_json.tsx +++ b/packages/website/ts/components/order_json.tsx @@ -1,4 +1,3 @@ -import { ECSignature } from '@0xproject/types'; import { BigNumber, fetchAsync, logUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import Paper from 'material-ui/Paper'; diff --git a/packages/website/ts/containers/generate_order_form.ts b/packages/website/ts/containers/generate_order_form.ts index b2f74f0f8..bc9d6f524 100644 --- a/packages/website/ts/containers/generate_order_form.ts +++ b/packages/website/ts/containers/generate_order_form.ts @@ -1,4 +1,3 @@ -import { ECSignature } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as React from 'react'; import { connect } from 'react-redux'; diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 5e79b6518..c418cab3f 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -1,4 +1,3 @@ -import { ECSignature } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Dispatch } from 'redux'; import { State } from 'ts/redux/reducer'; diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index 99907e93e..f54801639 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -1,5 +1,4 @@ import { generatePseudoRandomSalt } from '@0xproject/order-utils'; -import { ECSignature } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as moment from 'moment'; diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 19cc8f858..5fe9eef99 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -1,4 +1,4 @@ -import { ECSignature, SignedOrder } from '@0xproject/types'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Provider } from 'ethereum-types'; import * as React from 'react'; diff --git a/packages/website/ts/utils/order_parser.ts b/packages/website/ts/utils/order_parser.ts index 2e1d4d2f2..816200e3b 100644 --- a/packages/website/ts/utils/order_parser.ts +++ b/packages/website/ts/utils/order_parser.ts @@ -1,4 +1,5 @@ -import { BigNumber, logUtils } from '@0xproject/utils'; +import { orderParsingUtils } from '@0xproject/order-utils'; +import { logUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import { portalOrderSchema } from 'ts/schemas/portal_order_schema'; @@ -29,7 +30,7 @@ export const orderParser = { return undefined; } const signedOrder = _.get(order, 'signedOrder'); - const convertedSignedOrder = convertOrderStringFieldsToBigNumber(signedOrder); + const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder); const result = { ...order, signedOrder: convertedSignedOrder, @@ -39,7 +40,7 @@ export const orderParser = { parseJsonString(orderJson: string): PortalOrder { const order = JSON.parse(orderJson); const signedOrder = _.get(order, 'signedOrder'); - const convertedSignedOrder = convertOrderStringFieldsToBigNumber(signedOrder); + const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder); const result = { ...order, signedOrder: convertedSignedOrder, @@ -47,29 +48,3 @@ export const orderParser = { return result; }, }; - -// TODO: consolidate this function with that in typeConverters in @0xproject/connect -function convertOrderStringFieldsToBigNumber(order: any): any { - return convertStringsFieldsToBigNumbers(order, [ - 'makerAssetAmount', - 'takerAssetAmount', - 'makerFee', - 'takerFee', - 'expirationTimeSeconds', - 'salt', - ]); -} - -// TODO: consolidate this function with that in typeConverters in @0xproject/connect -function convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any { - const result = _.assign({}, obj); - _.each(fields, field => { - _.update(result, field, (value: string) => { - if (_.isUndefined(value)) { - throw new Error(`Could not find field '${field}' while converting string fields to BigNumber.`); - } - return new BigNumber(value); - }); - }); - return result; -} diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index eda0e513d..027810905 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -1,7 +1,7 @@ import { ContractWrappersError } from '@0xproject/contract-wrappers'; import { assetDataUtils, OrderError } from '@0xproject/order-utils'; import { constants as sharedConstants, Networks } from '@0xproject/react-shared'; -import { ECSignature, ExchangeContractErrs } from '@0xproject/types'; +import { ExchangeContractErrs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as bowser from 'bowser'; |