aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/analytics.ts17
-rw-r--r--packages/website/ts/utils/configs.ts27
-rw-r--r--packages/website/ts/utils/constants.ts1
-rw-r--r--packages/website/ts/utils/order_parser.ts23
-rw-r--r--packages/website/ts/utils/token_address_overrides.ts24
-rw-r--r--packages/website/ts/utils/utils.ts61
6 files changed, 89 insertions, 64 deletions
diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts
index e5a1ddfa4..62dbff2b9 100644
--- a/packages/website/ts/utils/analytics.ts
+++ b/packages/website/ts/utils/analytics.ts
@@ -1,5 +1,6 @@
+import { assetDataUtils } from '@0xproject/order-utils';
import * as _ from 'lodash';
-import { ObjectMap, Order } from 'ts/types';
+import { ObjectMap, PortalOrder } from 'ts/types';
import { utils } from 'ts/utils/utils';
export interface HeapAnalytics {
@@ -53,12 +54,16 @@ export class Analytics {
}
// tslint:enable:no-floating-promises
// Custom methods
- public trackOrderEvent(eventName: string, order: Order): void {
+ public trackOrderEvent(eventName: string, order: PortalOrder): void {
+ const takerTokenAmount = order.signedOrder.takerAssetAmount.toString();
+ const makerTokenAmount = order.signedOrder.makerAssetAmount.toString();
+ const takerToken = assetDataUtils.decodeERC20AssetData(order.signedOrder.takerAssetData).tokenAddress;
+ const makerToken = assetDataUtils.decodeERC20AssetData(order.signedOrder.makerAssetData).tokenAddress;
const orderLoggingData = {
- takerTokenAmount: order.signedOrder.takerTokenAmount,
- makeTokenAmount: order.signedOrder.makerTokenAmount,
- takerToken: order.metadata.takerToken.symbol,
- makerToken: order.metadata.makerToken.symbol,
+ takerTokenAmount,
+ makerTokenAmount,
+ takerToken,
+ makerToken,
};
this.track(eventName, orderLoggingData);
}
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index a1c64f9cb..7b74eccfb 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -18,7 +18,7 @@ export const configs = {
DOMAIN_PRODUCTION: '0xproject.com',
GOOGLE_ANALYTICS_ID: 'UA-98720122-1',
LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE: '2017-11-22',
- LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2018-7-5',
+ LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2018-9-7',
OUTDATED_WRAPPED_ETHERS: [
{
42: {
@@ -44,27 +44,6 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
- SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
- SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
- 'TKN0',
- 'TKN1',
- 'TKN2',
- 'TKN3',
- 'TKN4',
- 'TKN5',
- 'TKN6',
- 'TKN7',
- 'TKN8',
- 'TKN9',
- 'TKN10',
- 'TKN11',
- 'TKN12',
- 'TKN13',
- 'TKN14',
- 'TKN15',
- 'TKN16',
- 'TKN17',
- 'TKN18',
- 'TKN19',
- ],
+ SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['ZRX', 'MKR', 'MLN', 'GNT', 'DGD', 'REP'],
+ SYMBOLS_OF_MINTABLE_ROPSTEN_TOKENS: ['ZRX', 'MKR', 'MLN', 'GNT', 'DGD', 'REP'],
};
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 005d17823..23d419907 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -24,6 +24,7 @@ export const constants = {
NETWORK_ID_MAINNET: 1,
NETWORK_ID_KOVAN: 42,
NETWORK_ID_TESTRPC: 50,
+ NETWORK_ID_ROPSTEN: 3,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
PROVIDER_NAME_LEDGER: 'Ledger',
PROVIDER_NAME_METAMASK: 'MetaMask',
diff --git a/packages/website/ts/utils/order_parser.ts b/packages/website/ts/utils/order_parser.ts
index be08da80e..816200e3b 100644
--- a/packages/website/ts/utils/order_parser.ts
+++ b/packages/website/ts/utils/order_parser.ts
@@ -1,12 +1,13 @@
+import { orderParsingUtils } from '@0xproject/order-utils';
import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { portalOrderSchema } from 'ts/schemas/portal_order_schema';
import { validator } from 'ts/schemas/validator';
-import { Order } from 'ts/types';
+import { PortalOrder } from 'ts/types';
export const orderParser = {
- parse(queryString: string): Order | undefined {
+ parseQueryString(queryString: string): PortalOrder | undefined {
if (queryString.length === 0) {
return undefined;
}
@@ -28,6 +29,22 @@ export const orderParser = {
logUtils.log(`Invalid shared order: ${validationResult.errors}`);
return undefined;
}
- return order;
+ const signedOrder = _.get(order, 'signedOrder');
+ const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder);
+ const result = {
+ ...order,
+ signedOrder: convertedSignedOrder,
+ };
+ return result;
+ },
+ parseJsonString(orderJson: string): PortalOrder {
+ const order = JSON.parse(orderJson);
+ const signedOrder = _.get(order, 'signedOrder');
+ const convertedSignedOrder = orderParsingUtils.convertOrderStringFieldsToBigNumber(signedOrder);
+ const result = {
+ ...order,
+ signedOrder: convertedSignedOrder,
+ };
+ return result;
},
};
diff --git a/packages/website/ts/utils/token_address_overrides.ts b/packages/website/ts/utils/token_address_overrides.ts
new file mode 100644
index 000000000..8353358bc
--- /dev/null
+++ b/packages/website/ts/utils/token_address_overrides.ts
@@ -0,0 +1,24 @@
+import { ObjectMap } from 'ts/types';
+import { constants } from 'ts/utils/constants';
+
+// Map of networkId -> tokenSymbol -> tokenAddress
+export type TokenOverrides = ObjectMap<ObjectMap<string>>;
+
+export const tokenAddressOverrides: TokenOverrides = {
+ [constants.NETWORK_ID_KOVAN]: {
+ ZRX: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ REP: '0x8cb3971b8eb709c14616bd556ff6683019e90d9c',
+ DGD: '0xa4f468c9c692eb6b4b8b06270dae7a2cfeedcde9',
+ GNT: '0x31fb614e223706f15d0d3c5f4b08bdf0d5c78623',
+ MKR: '0x7b6b10caa9e8e9552ba72638ea5b47c25afea1f3',
+ MLN: '0x17e394d1df6ce29d042195ea38411a98ff3ead94',
+ },
+ [constants.NETWORK_ID_ROPSTEN]: {
+ ZRX: '0xff67881f8d12f372d91baae9752eb3631ff0ed00',
+ REP: '0xb0b443fe0e8a04c4c85e8fda9c5c1ccc057d6653',
+ DGD: '0xc4895a5aafa2708d6bc1294e20ec839aad156b1d',
+ GNT: '0x7f8acc55a359ca4517c30510566ac35b800f7cac',
+ MKR: '0x06732516acd125b6e83c127752ed5f027e1b276e',
+ MLN: '0x823ebe83d39115536274a8617e00a1ff3544fd63',
+ },
+};
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 39bbd404c..b45e37aeb 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,7 +1,7 @@
-import { ContractWrappersError, ExchangeContractErrs } from '@0xproject/contract-wrappers';
-import { OrderError } from '@0xproject/order-utils';
+import { ContractWrappersError } from '@0xproject/contract-wrappers';
+import { assetDataUtils, OrderError } from '@0xproject/order-utils';
import { constants as sharedConstants, Networks } from '@0xproject/react-shared';
-import { ECSignature, Provider } from '@0xproject/types';
+import { ExchangeContractErrs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as bowser from 'bowser';
@@ -10,13 +10,14 @@ import * as _ from 'lodash';
import * as moment from 'moment';
import * as numeral from 'numeral';
+import { Provider } from 'ethereum-types';
import {
AccountState,
BlockchainCallErrs,
BrowserType,
Environments,
OperatingSystemType,
- Order,
+ PortalOrder,
Providers,
ProviderType,
ScreenWidths,
@@ -64,35 +65,36 @@ export const utils = {
return formattedDate;
},
generateOrder(
- exchangeContractAddress: string,
+ exchangeAddress: string,
sideToAssetToken: SideToAssetToken,
- expirationUnixTimestampSec: BigNumber,
+ expirationTimeSeconds: BigNumber,
orderTakerAddress: string,
orderMakerAddress: string,
makerFee: BigNumber,
takerFee: BigNumber,
- feeRecipient: string,
- ecSignature: ECSignature,
+ feeRecipientAddress: string,
+ signature: string,
tokenByAddress: TokenByAddress,
orderSalt: BigNumber,
- ): Order {
+ ): PortalOrder {
const makerToken = tokenByAddress[sideToAssetToken[Side.Deposit].address];
const takerToken = tokenByAddress[sideToAssetToken[Side.Receive].address];
const order = {
signedOrder: {
- maker: orderMakerAddress,
- taker: orderTakerAddress,
- makerFee: makerFee.toString(),
- takerFee: takerFee.toString(),
- makerTokenAmount: sideToAssetToken[Side.Deposit].amount.toString(),
- takerTokenAmount: sideToAssetToken[Side.Receive].amount.toString(),
- makerTokenAddress: makerToken.address,
- takerTokenAddress: takerToken.address,
- expirationUnixTimestampSec: expirationUnixTimestampSec.toString(),
- feeRecipient,
- salt: orderSalt.toString(),
- ecSignature,
- exchangeContractAddress,
+ senderAddress: constants.NULL_ADDRESS,
+ makerAddress: orderMakerAddress,
+ takerAddress: orderTakerAddress,
+ makerFee,
+ takerFee,
+ makerAssetAmount: sideToAssetToken[Side.Deposit].amount,
+ takerAssetAmount: sideToAssetToken[Side.Receive].amount,
+ makerAssetData: assetDataUtils.encodeERC20AssetData(makerToken.address),
+ takerAssetData: assetDataUtils.encodeERC20AssetData(takerToken.address),
+ expirationTimeSeconds,
+ feeRecipientAddress,
+ salt: orderSalt,
+ signature,
+ exchangeAddress,
},
metadata: {
makerToken: {
@@ -231,10 +233,10 @@ export const utils = {
const ContractWrappersErrorToHumanReadableError: { [error: string]: string } = {
[ContractWrappersError.ExchangeContractDoesNotExist]: 'Exchange contract does not exist',
[ContractWrappersError.EtherTokenContractDoesNotExist]: 'EtherToken contract does not exist',
- [ContractWrappersError.TokenTransferProxyContractDoesNotExist]:
- 'TokenTransferProxy contract does not exist',
- [ContractWrappersError.TokenRegistryContractDoesNotExist]: 'TokenRegistry contract does not exist',
- [ContractWrappersError.TokenContractDoesNotExist]: 'Token contract does not exist',
+ [ContractWrappersError.ERC20ProxyContractDoesNotExist]: 'ERC20 proxy contract des not exist',
+ [ContractWrappersError.ERC721ProxyContractDoesNotExist]: 'ERC721 proxy contract des not exist',
+ [ContractWrappersError.ERC20TokenContractDoesNotExist]: 'ERC20 token contract does not exist',
+ [ContractWrappersError.ERC721TokenContractDoesNotExist]: 'ERC721 token contract does not exist',
[ContractWrappersError.ZRXContractDoesNotExist]: 'ZRX contract does not exist',
[BlockchainCallErrs.UserHasNoAssociatedAddresses]: 'User has no addresses available',
[OrderError.InvalidSignature]: 'Order signature is not valid',
@@ -247,12 +249,9 @@ export const utils = {
} = {
[ExchangeContractErrs.OrderFillExpired]: 'This order has expired',
[ExchangeContractErrs.OrderCancelExpired]: 'This order has expired',
- [ExchangeContractErrs.OrderCancelAmountZero]: "Order cancel amount can't be 0",
- [ExchangeContractErrs.OrderAlreadyCancelledOrFilled]:
- 'This order has already been completely filled or cancelled',
+ [ExchangeContractErrs.OrderCancelled]: 'This order has been cancelled',
[ExchangeContractErrs.OrderFillAmountZero]: "Order fill amount can't be 0",
- [ExchangeContractErrs.OrderRemainingFillAmountZero]:
- 'This order has already been completely filled or cancelled',
+ [ExchangeContractErrs.OrderRemainingFillAmountZero]: 'This order has already been completely filled',
[ExchangeContractErrs.OrderFillRoundingError]:
'Rounding error will occur when filling this order. Please try filling a different amount.',
[ExchangeContractErrs.InsufficientTakerBalance]: