aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/0x.js/CHANGELOG.md1
-rw-r--r--packages/0x.js/src/artifacts/TokenRegistry.json2
-rw-r--r--packages/website/ts/blockchain.ts16
-rw-r--r--packages/website/ts/components/dialogs/blockchain_err_dialog.tsx14
-rw-r--r--packages/website/ts/components/fill_order.tsx6
-rw-r--r--packages/website/ts/types.ts1
-rw-r--r--packages/website/ts/utils/utils.ts3
7 files changed, 38 insertions, 5 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index fa3b3db91..820c25449 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -2,7 +2,6 @@
## v0.34.0 - _TBD_
- * Update Kovan EtherToken artifact address to match TokenRegistry.
* Fix the bug causing `zeroEx.exchange.fillOrdersUpToAsync` validation to fail if there were some extra orders passed (#470)
## v0.33.2 - _March 18, 2018_
diff --git a/packages/0x.js/src/artifacts/TokenRegistry.json b/packages/0x.js/src/artifacts/TokenRegistry.json
index 95bee4b1d..0f583628c 100644
--- a/packages/0x.js/src/artifacts/TokenRegistry.json
+++ b/packages/0x.js/src/artifacts/TokenRegistry.json
@@ -538,7 +538,7 @@
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
},
"42": {
- "address": "0xd0a1e359811322d97991e03f863a0c30c2cf029c"
+ "address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
},
"50": {
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index a3427baee..2268bf1ab 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -544,6 +544,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);
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/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/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/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]: