aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r--packages/website/ts/utils/utils.ts71
1 files changed, 35 insertions, 36 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 39bbd404c..d083e0ffc 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]:
@@ -324,7 +323,7 @@ export const utils = {
} else if ((provider as any).isMetaMask) {
parsedProviderName = Providers.Metamask;
} else if (!_.isUndefined(_.get(window, 'SOFA'))) {
- parsedProviderName = Providers.Toshi;
+ parsedProviderName = Providers.CoinbaseWallet;
} else if (!_.isUndefined(_.get(window, '__CIPHER__'))) {
parsedProviderName = Providers.Cipher;
}
@@ -454,14 +453,14 @@ export const utils = {
if (isOnMobile) {
switch (operatingSystem) {
case OperatingSystemType.Android:
- downloadLink = constants.URL_TOSHI_ANDROID_APP_STORE;
+ downloadLink = constants.URL_COINBASE_WALLET_ANDROID_APP_STORE;
break;
case OperatingSystemType.iOS:
- downloadLink = constants.URL_TOSHI_IOS_APP_STORE;
+ downloadLink = constants.URL_COINBASE_WALLET_IOS_APP_STORE;
break;
default:
- // Toshi is only supported on these mobile OSes - just default to iOS
- downloadLink = constants.URL_TOSHI_IOS_APP_STORE;
+ // Coinbase wallet is only supported on these mobile OSes - just default to iOS
+ downloadLink = constants.URL_COINBASE_WALLET_IOS_APP_STORE;
}
} else {
switch (browserType) {