diff options
Diffstat (limited to 'packages/website/ts')
-rw-r--r-- | packages/website/ts/components/token_balances.tsx | 37 | ||||
-rw-r--r-- | packages/website/ts/utils/configs.ts | 24 | ||||
-rw-r--r-- | packages/website/ts/utils/constants.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/utils/utils.ts | 11 |
4 files changed, 57 insertions, 17 deletions
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index dfb62bbb3..6c3f4748b 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -176,13 +176,14 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala onTouchTap={this._onDharmaDialogToggle.bind(this, false)} />, ]; + const isTestNetwork = utils.isTestNetwork(this.props.networkId); const isKovanTestNetwork = this.props.networkId === constants.NETWORK_ID_KOVAN; const dharmaButtonColumnStyle = { paddingLeft: 3, display: isKovanTestNetwork ? 'table-cell' : 'none', }; const stubColumnStyle = { - display: isKovanTestNetwork ? 'none' : 'table-cell', + display: isTestNetwork ? 'none' : 'table-cell', }; const allTokenRowHeight = _.size(this.props.tokenByAddress) * TOKEN_TABLE_ROW_HEIGHT; const tokenTableHeight = @@ -201,10 +202,10 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala smart contract so you can start trading that token.'; return ( <div className="lg-px4 md-px4 sm-px1 pb2"> - <h3>{isKovanTestNetwork ? 'Test ether' : 'Ether'}</h3> + <h3>{isTestNetwork ? 'Test ether' : 'Ether'}</h3> <Divider /> <div className="pt2 pb2"> - {isKovanTestNetwork + {isTestNetwork ? 'In order to try out the 0x Portal Dapp, request some test ether to pay for \ gas costs. It might take a bit of time for the test ether to show up.' : 'Ether must be converted to Ether Tokens in order to be tradable via 0x. \ @@ -216,7 +217,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala <TableHeaderColumn>Currency</TableHeaderColumn> <TableHeaderColumn>Balance</TableHeaderColumn> <TableRowColumn className="sm-hide xs-hide" style={stubColumnStyle} /> - {isKovanTestNetwork && ( + {isTestNetwork && ( <TableHeaderColumn style={{ paddingLeft: 3 }}> {isSmallScreen ? 'Faucet' : 'Request from faucet'} </TableHeaderColumn> @@ -243,7 +244,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala )} </TableRowColumn> <TableRowColumn className="sm-hide xs-hide" style={stubColumnStyle} /> - {isKovanTestNetwork && ( + {isTestNetwork && ( <TableRowColumn style={{ paddingLeft: 3 }}> <LifeCycleRaisedButton labelReady="Request" @@ -267,7 +268,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala </Table> <div className="clearfix" style={{ paddingBottom: 1 }}> <div className="col col-10"> - <h3 className="pt2">{isKovanTestNetwork ? 'Test tokens' : 'Tokens'}</h3> + <h3 className="pt2">{isTestNetwork ? 'Test tokens' : 'Tokens'}</h3> </div> <div className="col col-1 pt3 align-right"> <FloatingActionButton mini={true} zDepth={0} onClick={this._onAddTokenClicked.bind(this)}> @@ -282,7 +283,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala </div> <Divider /> <div className="pt2 pb2"> - {isKovanTestNetwork + {isTestNetwork ? "Mint some test tokens you'd like to use to generate or fill an order using 0x." : "Set trading permissions for a token you'd like to start trading."} </div> @@ -362,8 +363,13 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala EtherscanLinkSuffixes.Address, ); const isMintable = - _.includes(configs.SYMBOLS_OF_MINTABLE_TOKENS, token.symbol) && - this.props.networkId !== constants.NETWORK_ID_MAINNET; + (_.includes(configs.SYMBOLS_OF_MINTABLE_KOVAN_TOKENS, token.symbol) && + this.props.networkId === constants.NETWORK_ID_BY_NAME[Networks.Kovan]) || + (_.includes(configs.SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS, token.symbol) && + _.includes( + [constants.NETWORK_ID_BY_NAME[Networks.Rinkeby], constants.NETWORK_ID_BY_NAME[Networks.Ropsten]], + this.props.networkId, + )); return ( <TableRow key={token.address} style={{ height: TOKEN_TABLE_ROW_HEIGHT }}> <TableRowColumn colSpan={tokenColSpan}> @@ -413,7 +419,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala /> )} {token.symbol === ZRX_TOKEN_SYMBOL && - this.props.networkId === constants.NETWORK_ID_KOVAN && ( + utils.isTestNetwork(this.props.networkId) && ( <LifeCycleRaisedButton labelReady="Request" labelLoading="Sending..." @@ -498,9 +504,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala case BalanceErrs.incorrectNetworkForFaucet: return ( <div> - Our faucet can only send test Ether to addresses on the {Networks.Kovan} testnet (networkId{' '} - {constants.NETWORK_ID_KOVAN}). Please make sure you are connected to the {Networks.Kovan}{' '} - testnet and try requesting ether again. + Our faucet can only send test Ether to addresses on testnets. Please make sure you are connected + to a testnet and try requesting again. </div> ); @@ -589,7 +594,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala // If on another network other then the testnet our faucet serves test ether // from, we must show user an error message - if (this.props.blockchain.networkId !== constants.NETWORK_ID_KOVAN) { + if (!utils.isTestNetwork(this.props.blockchain.networkId)) { this.setState({ errorType: BalanceErrs.incorrectNetworkForFaucet, }); @@ -599,7 +604,9 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala await utils.sleepAsync(ARTIFICIAL_FAUCET_REQUEST_DELAY); const segment = isEtherRequest ? 'ether' : 'zrx'; - const response = await fetch(`${constants.URL_ETHER_FAUCET}/${segment}/${this.props.userAddress}`); + const response = await fetch( + `${constants.URL_TESTNET_FAUCET}/${segment}/${this.props.userAddress}?networkId=${this.props.networkId}`, + ); const responseBody = await response.text(); if (response.status !== constants.SUCCESS_STATUS) { utils.consoleLog(`Unexpected status code: ${response.status} -> ${responseBody}`); diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts index 874ad04c2..69773eae7 100644 --- a/packages/website/ts/utils/configs.ts +++ b/packages/website/ts/utils/configs.ts @@ -124,5 +124,27 @@ export const configs = { [4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`], } as PublicNodeUrlsByNetworkId, SHOULD_DEPRECATE_OLD_WETH_TOKEN: true, - SYMBOLS_OF_MINTABLE_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'], + 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', + ], }; diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts index 26a793f38..3df4c9370 100644 --- a/packages/website/ts/utils/constants.ts +++ b/packages/website/ts/utils/constants.ts @@ -69,7 +69,7 @@ export const constants = { URL_BLOG: 'https://blog.0xproject.com/latest', URL_DISCOURSE_FORUM: 'https://forum.0xproject.com', URL_FIREFOX_U2F_ADDON: 'https://addons.mozilla.org/en-US/firefox/addon/u2f-support-add-on/', - URL_ETHER_FAUCET: 'https://faucet.0xproject.com', + URL_TESTNET_FAUCET: 'https://faucet.0xproject.com', URL_GITHUB_ORG: 'https://github.com/0xProject', URL_GITHUB_WIKI: 'https://github.com/0xProject/wiki', URL_METAMASK_CHROME_STORE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn', diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 7e69b1c5f..a7865d41b 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -282,4 +282,15 @@ export const utils = { isTestRpc(nodeVersion: string): boolean { return _.includes(nodeVersion, 'TestRPC'); }, + isTestNetwork(networkId: number): boolean { + const isTestNetwork = _.includes( + [ + constants.NETWORK_ID_BY_NAME[Networks.Kovan], + constants.NETWORK_ID_BY_NAME[Networks.Rinkeby], + constants.NETWORK_ID_BY_NAME[Networks.Ropsten], + ], + networkId, + ); + return isTestNetwork; + }, }; |