aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
commit665011174bab7cfc6ec53e0044d60e1463222aee (patch)
tree44bc55bd390044d6cbfe8e0f7dddb621a8be7249 /packages/website/ts
parentd106079d9b69191d9cdc6d9323dbae3e4b45daf2 (diff)
parentc4dd9658e791a9f821ea3b6eb4326bcba53b081a (diff)
downloaddexon-0x-contracts-665011174bab7cfc6ec53e0044d60e1463222aee.tar.gz
dexon-0x-contracts-665011174bab7cfc6ec53e0044d60e1463222aee.tar.zst
dexon-0x-contracts-665011174bab7cfc6ec53e0044d60e1463222aee.zip
Merge branch 'development' into feature/website/wallet-wrap
* development: (35 commits) Fix CHANGELOG Update Yarn.lock Standardize changelog dates and format Fix stubbing of a non-existent property Remove redundant cast Move common types out of web3 types Add monorepo_scripts to npmignore Add typeRoots Add clean-state tests Remove nested .gitignore files since `yarn publish` gets confused by them and ignores their contents on the top-level scope Remove WETH hack now that updated WETH address is in TokenRegistry Revert TokenRegistry address on Kovan Improve rounding error message Portal fill with mixed decimals Add error popover if TokenRegistry on network user is browsing on don't include the requisite default tokens for 0x Portal to function Set timeout for compiler tests Remove redundant types Add missing param comments Fix a comment Add a comment ...
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/blockchain.ts38
-rw-r--r--packages/website/ts/components/dialogs/blockchain_err_dialog.tsx14
-rw-r--r--packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx4
-rw-r--r--packages/website/ts/components/dialogs/send_dialog.tsx4
-rw-r--r--packages/website/ts/components/fill_order.tsx6
-rw-r--r--packages/website/ts/components/footer.tsx2
-rw-r--r--packages/website/ts/containers/web3_wrapper_documentation.ts27
-rw-r--r--packages/website/ts/globals.d.ts4
-rw-r--r--packages/website/ts/types.ts1
-rw-r--r--packages/website/ts/utils/configs.ts7
-rw-r--r--packages/website/ts/utils/utils.ts3
11 files changed, 58 insertions, 52 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index a3427baee..72cb94c02 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -151,13 +151,6 @@ export class Blockchain {
}
public async isAddressInTokenRegistryAsync(tokenAddress: string): Promise<boolean> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
- // HACK: temporarily whitelist the new WETH token address `as if` they were
- // already in the tokenRegistry.
- // TODO: Remove this hack once we've updated the TokenRegistries
- // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz
- if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && tokenAddress === configs.NEW_WRAPPED_ETHERS[this.networkId]) {
- return true;
- }
const tokenIfExists = await this._zeroEx.tokenRegistry.getTokenIfExistsAsync(tokenAddress);
return !_.isUndefined(tokenIfExists);
}
@@ -544,6 +537,22 @@ export class Blockchain {
? {}
: trackedTokenStorage.getTrackedTokensByAddress(this._userAddressIfExists, this.networkId);
const tokenRegistryTokens = _.values(tokenRegistryTokensByAddress);
+ const tokenRegistryTokenSymbols = _.map(tokenRegistryTokens, t => t.symbol);
+ const defaultTrackedTokensInRegistry = _.intersection(
+ tokenRegistryTokenSymbols,
+ configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
+ );
+ if (defaultTrackedTokensInRegistry.length !== configs.DEFAULT_TRACKED_TOKEN_SYMBOLS.length) {
+ this._dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
+ this._dispatcher.encounteredBlockchainError(BlockchainErrs.DefaultTokensNotInTokenRegistry);
+ const err = new Error(
+ `Default tracked tokens (${JSON.stringify(
+ configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
+ )}) not found in tokenRegistry: ${JSON.stringify(tokenRegistryTokens)}`,
+ );
+ await errorReporter.reportAsync(err);
+ return;
+ }
if (_.isEmpty(trackedTokensByAddress)) {
_.each(configs.DEFAULT_TRACKED_TOKEN_SYMBOLS, symbol => {
const token = _.find(tokenRegistryTokens, t => t.symbol === symbol);
@@ -728,22 +737,9 @@ export class Blockchain {
// HACK: For now we have a hard-coded list of iconUrls for the dummyTokens
// TODO: Refactor this out and pull the iconUrl directly from the TokenRegistry
const iconUrl = configs.ICON_URL_BY_SYMBOL[t.symbol];
- // HACK: Temporarily we hijack the WETH addresses fetched from the tokenRegistry
- // so that we can take our time with actually updating it. This ensures that when
- // we deploy the new WETH page, everyone will re-fill their trackedTokens with the
- // new canonical WETH.
- // TODO: Remove this hack once we've updated the TokenRegistries
- // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz
- let address = t.address;
- if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && t.symbol === 'WETH') {
- const newEtherTokenAddressIfExists = configs.NEW_WRAPPED_ETHERS[this.networkId];
- if (!_.isUndefined(newEtherTokenAddressIfExists)) {
- address = newEtherTokenAddressIfExists;
- }
- }
const token: Token = {
iconUrl,
- address,
+ address: t.address,
name: t.name,
symbol: t.symbol,
decimals: t.decimals,
diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
index e71a0f7d1..1c3b7458d 100644
--- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
+++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
@@ -52,6 +52,8 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
return 'Enable wallet communication';
} else if (this.props.blockchainErr === BlockchainErrs.DisconnectedFromEthereumNode) {
return 'Disconnected from Ethereum network';
+ } else if (this.props.blockchainErr === BlockchainErrs.DefaultTokensNotInTokenRegistry) {
+ return 'Default TokenRegistry tokens missing';
} else {
return 'Unexpected error';
}
@@ -63,6 +65,8 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
return this._renderNoWalletFoundExplanation();
} else if (this.props.blockchainErr === BlockchainErrs.DisconnectedFromEthereumNode) {
return this._renderDisconnectedFromNode();
+ } else if (this.props.blockchainErr === BlockchainErrs.DefaultTokensNotInTokenRegistry) {
+ return this._renderDefaultTokenNotInTokenRegistry();
} else {
return this._renderUnexpectedErrorExplanation();
}
@@ -82,6 +86,16 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
</div>
);
}
+ private _renderDefaultTokenNotInTokenRegistry() {
+ return (
+ <div>
+ The TokenRegistry deployed on your network does not contain the needed default tokens for 0x Portal to
+ operate. Please try one of the supported networks (Mainnet, Kovan, Ropsten, Rinkeby). If on a local
+ Testnet, make sure the TokenRegistry contract is deployed and loaded with some default tokens (i.e WETH
+ & ZRX).
+ </div>
+ );
+ }
private _renderUnexpectedErrorExplanation() {
return <div>We encountered an unexpected error. Please try refreshing the page.</div>;
}
diff --git a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
index d1bdb447f..42ca1713d 100644
--- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
+++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
@@ -37,8 +37,8 @@ export class EthWethConversionDialog extends React.Component<
EthWethConversionDialogState
> {
private _isUnmounted: boolean;
- constructor() {
- super();
+ constructor(props: EthWethConversionDialogProps) {
+ super(props);
this._isUnmounted = false;
this.state = {
shouldShowIncompleteErrs: false,
diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx
index d44dd9aab..2af7fd7ac 100644
--- a/packages/website/ts/components/dialogs/send_dialog.tsx
+++ b/packages/website/ts/components/dialogs/send_dialog.tsx
@@ -27,8 +27,8 @@ interface SendDialogState {
}
export class SendDialog extends React.Component<SendDialogProps, SendDialogState> {
- constructor() {
- super();
+ constructor(props: SendDialogProps) {
+ super(props);
this.state = {
recipient: '',
shouldShowIncompleteErrs: false,
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index a6144bd6b..ea94e0987 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -198,11 +198,13 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
symbol: takerToken.symbol,
};
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec);
- const exchangeRate = orderMakerAmount.div(orderTakerAmount);
let orderReceiveAmount = 0;
if (!_.isUndefined(this.props.orderFillAmount)) {
- const orderReceiveAmountBigNumber = exchangeRate.mul(this.props.orderFillAmount);
+ const orderReceiveAmountBigNumber = orderMakerAmount
+ .times(this.props.orderFillAmount)
+ .dividedBy(orderTakerAmount)
+ .floor();
orderReceiveAmount = this._formatCurrencyAmount(orderReceiveAmountBigNumber, makerToken.decimals);
}
const isUserMaker =
diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx
index 957ed2044..6c0186ac0 100644
--- a/packages/website/ts/components/footer.tsx
+++ b/packages/website/ts/components/footer.tsx
@@ -45,7 +45,7 @@ interface FooterState {
export class Footer extends React.Component<FooterProps, FooterState> {
constructor(props: FooterProps) {
- super();
+ super(props);
this.state = {
selectedLanguage: props.translate.getLanguage(),
};
diff --git a/packages/website/ts/containers/web3_wrapper_documentation.ts b/packages/website/ts/containers/web3_wrapper_documentation.ts
index 0a0911b80..289006f10 100644
--- a/packages/website/ts/containers/web3_wrapper_documentation.ts
+++ b/packages/website/ts/containers/web3_wrapper_documentation.ts
@@ -48,26 +48,25 @@ const docsInfoConfig: DocsInfoConfig = {
typeConfigs: {
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
// currently no way to extract the re-exported types from index.ts via TypeDoc :(
- publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
+ publicTypes: [
+ 'TxData',
+ 'TransactionReceipt',
+ 'RawLogEntry',
+ 'ContractAbi',
+ 'BlockParam',
+ 'FilterObject',
+ 'LogEntry',
+ 'BlockWithoutTransactionData',
+ 'CallData',
+ 'LogEntryEvent',
+ ],
typeNameToExternalLink: {
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
- BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
- LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
- CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
- BlockWithoutTransactionData:
- 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
- LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
- FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
- ['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
- ['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
+ BigNumber: 'http://mikemcl.github.io/bignumber.js',
},
typeNameToPrefix: {
Provider: 'Web3',
- CallData: 'Web3',
- BlockWithoutTransactionData: 'Web3',
- LogEntry: 'Web3',
- FilterObject: 'Web3',
},
typeNameToDocSection: {
Web3Wrapper: docSections.web3Wrapper,
diff --git a/packages/website/ts/globals.d.ts b/packages/website/ts/globals.d.ts
index ef276519c..3791b3269 100644
--- a/packages/website/ts/globals.d.ts
+++ b/packages/website/ts/globals.d.ts
@@ -115,11 +115,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider;
}
declare module 'web3-provider-engine/subproviders/rpc' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider {
constructor(options: { rpcUrl: string });
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 104d2e50f..901483327 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -223,6 +223,7 @@ export enum AlertTypes {
export enum BlockchainErrs {
AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK',
DisconnectedFromEthereumNode = 'DISCONNECTED_FROM_ETHEREUM_NODE',
+ DefaultTokensNotInTokenRegistry = 'DEFAULT_TOKENS_NOT_IN_TOKEN_REGISTRY',
NoError = 'NO_ERROR',
}
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index 597e9689a..a54fc56a8 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -65,12 +65,6 @@ export const configs = {
GOOGLE_ANALYTICS_ID: 'UA-98720122-1',
LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE: '2017-11-22',
LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2017-12-19',
- // NEW_WRAPPED_ETHERS is temporary until we remove the SHOULD_DEPRECATE_OLD_WETH_TOKEN flag
- // and add the new WETHs to the tokenRegistry
- NEW_WRAPPED_ETHERS: {
- 1: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
- 42: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
- } as { [networkId: string]: string },
OUTDATED_WRAPPED_ETHERS: [
{
42: {
@@ -96,7 +90,6 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
- SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
'TKN0',
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 25d7e449b..75597a7e2 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -219,7 +219,8 @@ export const utils = {
[ExchangeContractErrs.OrderFillAmountZero]: "Order fill amount can't be 0",
[ExchangeContractErrs.OrderRemainingFillAmountZero]:
'This order has already been completely filled or cancelled',
- [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order',
+ [ExchangeContractErrs.OrderFillRoundingError]:
+ 'Rounding error will occur when filling this order. Please try filling a different amount.',
[ExchangeContractErrs.InsufficientTakerBalance]:
'Taker no longer has a sufficient balance to complete this order',
[ExchangeContractErrs.InsufficientTakerAllowance]: