Replace remaining strEnums with property TS string enums

This commit is contained in:
Fabio Berger 2017-12-17 20:48:23 -05:00
parent 90d274ffc4
commit abbad68eb8
15 changed files with 78 additions and 91 deletions

View File

@ -186,7 +186,7 @@ export class Blockchain {
// later on in the logic. // later on in the logic.
let provider; let provider;
switch (providerType) { switch (providerType) {
case ProviderType.LEDGER: { case ProviderType.Ledger: {
const isU2FSupported = await utils.isU2FSupportedAsync(); const isU2FSupported = await utils.isU2FSupportedAsync();
if (!isU2FSupported) { if (!isU2FSupported) {
throw new Error('Cannot update providerType to LEDGER without U2F support'); throw new Error('Cannot update providerType to LEDGER without U2F support');
@ -220,7 +220,7 @@ export class Blockchain {
break; break;
} }
case ProviderType.INJECTED: { case ProviderType.Injected: {
if (_.isUndefined(this.cachedProvider)) { if (_.isUndefined(this.cachedProvider)) {
return; // Going from injected to injected, so we noop return; // Going from injected to injected, so we noop
} }
@ -241,8 +241,8 @@ export class Blockchain {
await this.fetchTokenInformationAsync(); await this.fetchTokenInformationAsync();
} }
public async setProxyAllowanceAsync(token: Token, amountInBaseUnits: BigNumber): Promise<void> { public async setProxyAllowanceAsync(token: Token, amountInBaseUnits: BigNumber): Promise<void> {
utils.assert(this.isValidAddress(token.address), BlockchainCallErrs.TOKEN_ADDRESS_IS_INVALID); utils.assert(this.isValidAddress(token.address), BlockchainCallErrs.TokenAddressIsInvalid);
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.');
const txHash = await this.zeroEx.token.setProxyAllowanceAsync( const txHash = await this.zeroEx.token.setProxyAllowanceAsync(
@ -258,7 +258,7 @@ export class Blockchain {
token.address, this.userAddress, toAddress, amountInBaseUnits, token.address, this.userAddress, toAddress, amountInBaseUnits,
); );
await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash);
const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.tx); const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx);
this.dispatcher.showFlashMessage(React.createElement(TokenSendCompleted, { this.dispatcher.showFlashMessage(React.createElement(TokenSendCompleted, {
etherScanLinkIfExists, etherScanLinkIfExists,
token, token,
@ -294,7 +294,7 @@ export class Blockchain {
} }
public async fillOrderAsync(signedOrder: SignedOrder, public async fillOrderAsync(signedOrder: SignedOrder,
fillTakerTokenAmount: BigNumber): Promise<BigNumber> { fillTakerTokenAmount: BigNumber): Promise<BigNumber> {
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
const shouldThrowOnInsufficientBalanceOrAllowance = true; const shouldThrowOnInsufficientBalanceOrAllowance = true;
@ -346,7 +346,7 @@ export class Blockchain {
return this.web3Wrapper.isAddress(lowercaseAddress); return this.web3Wrapper.isAddress(lowercaseAddress);
} }
public async pollTokenBalanceAsync(token: Token) { public async pollTokenBalanceAsync(token: Token) {
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this.userAddress, token.address); const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this.userAddress, token.address);
@ -375,7 +375,7 @@ export class Blockchain {
return signatureData; return signatureData;
} }
public async mintTestTokensAsync(token: Token) { public async mintTestTokensAsync(token: Token) {
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
const mintableContract = await this.instantiateContractIfExistsAsync(MintableArtifacts, token.address); const mintableContract = await this.instantiateContractIfExistsAsync(MintableArtifacts, token.address);
await mintableContract.mint(constants.MINT_AMOUNT, { await mintableContract.mint(constants.MINT_AMOUNT, {
@ -390,14 +390,14 @@ export class Blockchain {
} }
public async convertEthToWrappedEthTokensAsync(amount: BigNumber): Promise<void> { public async convertEthToWrappedEthTokensAsync(amount: BigNumber): Promise<void> {
utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.');
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
const txHash = await this.zeroEx.etherToken.depositAsync(amount, this.userAddress); const txHash = await this.zeroEx.etherToken.depositAsync(amount, this.userAddress);
await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash);
} }
public async convertWrappedEthTokensToEthAsync(amount: BigNumber): Promise<void> { public async convertWrappedEthTokensToEthAsync(amount: BigNumber): Promise<void> {
utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.');
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
const txHash = await this.zeroEx.etherToken.withdrawAsync(amount, this.userAddress); const txHash = await this.zeroEx.etherToken.withdrawAsync(amount, this.userAddress);
await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); await this.showEtherScanLinkAndAwaitTransactionMinedAsync(txHash);
@ -463,7 +463,7 @@ export class Blockchain {
} }
private async showEtherScanLinkAndAwaitTransactionMinedAsync( private async showEtherScanLinkAndAwaitTransactionMinedAsync(
txHash: string): Promise<TransactionReceiptWithDecodedLogs> { txHash: string): Promise<TransactionReceiptWithDecodedLogs> {
const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.tx); const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx);
this.dispatcher.showFlashMessage(React.createElement(TransactionSubmitted, { this.dispatcher.showFlashMessage(React.createElement(TransactionSubmitted, {
etherScanLinkIfExists, etherScanLinkIfExists,
})); }));
@ -491,7 +491,7 @@ export class Blockchain {
} }
private async startListeningForExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues): Promise<void> { private async startListeningForExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues): Promise<void> {
utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.');
utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES); utils.assert(this.doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
// Fetch historical logs // Fetch historical logs
await this.fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues); await this.fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues);
@ -733,7 +733,7 @@ export class Blockchain {
const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress); const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress);
if (!doesContractExist) { if (!doesContractExist) {
utils.consoleLog(`Contract does not exist: ${artifact.contract_name} at ${contractAddress}`); utils.consoleLog(`Contract does not exist: ${artifact.contract_name} at ${contractAddress}`);
throw new Error(BlockchainCallErrs.CONTRACT_DOES_NOT_EXIST); throw new Error(BlockchainCallErrs.ContractDoesNotExist);
} }
} }
@ -746,10 +746,10 @@ export class Blockchain {
const errMsg = `${err}`; const errMsg = `${err}`;
utils.consoleLog(`Notice: Error encountered: ${err} ${err.stack}`); utils.consoleLog(`Notice: Error encountered: ${err} ${err.stack}`);
if (_.includes(errMsg, 'not been deployed to detected network')) { if (_.includes(errMsg, 'not been deployed to detected network')) {
throw new Error(BlockchainCallErrs.CONTRACT_DOES_NOT_EXIST); throw new Error(BlockchainCallErrs.ContractDoesNotExist);
} else { } else {
await errorReporter.reportAsync(err); await errorReporter.reportAsync(err);
throw new Error(BlockchainCallErrs.UNHANDLED_ERROR); throw new Error(BlockchainCallErrs.UnhandledError);
} }
} }
} }

View File

@ -104,7 +104,7 @@ export class EthWethConversionButton extends
this.props.onConversionSuccessful(); this.props.onConversionSuccessful();
} catch (err) { } catch (err) {
const errMsg = '' + err; const errMsg = '' + err;
if (_.includes(errMsg, BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES)) { if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
} else if (!_.includes(errMsg, 'User denied transaction')) { } else if (!_.includes(errMsg, 'User denied transaction')) {
utils.consoleLog(`Unexpected error encountered: ${err}`); utils.consoleLog(`Unexpected error encountered: ${err}`);

View File

@ -70,7 +70,7 @@ export class SendButton extends React.Component<SendButtonProps, SendButtonState
this.props.dispatcher.replaceTokenBalanceByAddress(token.address, balance); this.props.dispatcher.replaceTokenBalanceByAddress(token.address, balance);
} catch (err) { } catch (err) {
const errMsg = `${err}`; const errMsg = `${err}`;
if (_.includes(errMsg, BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES)) { if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return; return;
} else if (!_.includes(errMsg, 'User denied transaction')) { } else if (!_.includes(errMsg, 'User denied transaction')) {

View File

@ -156,7 +156,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
const tokenTableHeight = allTokenRowHeight < MAX_TOKEN_TABLE_HEIGHT ? const tokenTableHeight = allTokenRowHeight < MAX_TOKEN_TABLE_HEIGHT ?
allTokenRowHeight : allTokenRowHeight :
MAX_TOKEN_TABLE_HEIGHT; MAX_TOKEN_TABLE_HEIGHT;
const isSmallScreen = this.props.screenWidth === ScreenWidths.SM; const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
const tokenColSpan = isSmallScreen ? TOKEN_COL_SPAN_SM : TOKEN_COL_SPAN_LG; const tokenColSpan = isSmallScreen ? TOKEN_COL_SPAN_SM : TOKEN_COL_SPAN_LG;
const dharmaLoanExplanation = 'If you need access to larger amounts of ether,<br> \ const dharmaLoanExplanation = 'If you need access to larger amounts of ether,<br> \
you can request a loan from the Dharma Loan<br> \ you can request a loan from the Dharma Loan<br> \
@ -311,7 +311,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
<TableHeaderColumn> <TableHeaderColumn>
Action Action
</TableHeaderColumn> </TableHeaderColumn>
{this.props.screenWidth !== ScreenWidths.SM && {this.props.screenWidth !== ScreenWidths.Sm &&
<TableHeaderColumn> <TableHeaderColumn>
Send Send
</TableHeaderColumn> </TableHeaderColumn>
@ -360,7 +360,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
if (!this.props.blockchainIsLoaded || this.props.blockchainErr !== BlockchainErrs.NoError) { if (!this.props.blockchainIsLoaded || this.props.blockchainErr !== BlockchainErrs.NoError) {
return ''; return '';
} }
const isSmallScreen = this.props.screenWidth === ScreenWidths.SM; const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
const tokenColSpan = isSmallScreen ? TOKEN_COL_SPAN_SM : TOKEN_COL_SPAN_LG; const tokenColSpan = isSmallScreen ? TOKEN_COL_SPAN_SM : TOKEN_COL_SPAN_LG;
const actionPaddingX = isSmallScreen ? 2 : 24; const actionPaddingX = isSmallScreen ? 2 : 24;
const allTokens = _.values(this.props.tokenByAddress); const allTokens = _.values(this.props.tokenByAddress);
@ -379,7 +379,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
private renderTokenRow(tokenColSpan: number, actionPaddingX: number, token: Token) { private renderTokenRow(tokenColSpan: number, actionPaddingX: number, token: Token) {
const tokenState = this.props.tokenStateByAddress[token.address]; const tokenState = this.props.tokenStateByAddress[token.address];
const tokenLink = utils.getEtherScanLinkIfExists(token.address, this.props.networkId, const tokenLink = utils.getEtherScanLinkIfExists(token.address, this.props.networkId,
EtherscanLinkSuffixes.address); EtherscanLinkSuffixes.Address);
const isMintable = _.includes(configs.symbolsOfMintableTokens, token.symbol) && const isMintable = _.includes(configs.symbolsOfMintableTokens, token.symbol) &&
this.props.networkId !== constants.MAINNET_NETWORK_ID; this.props.networkId !== constants.MAINNET_NETWORK_ID;
return ( return (
@ -432,7 +432,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
/> />
} }
</TableRowColumn> </TableRowColumn>
{this.props.screenWidth !== ScreenWidths.SM && {this.props.screenWidth !== ScreenWidths.Sm &&
<TableRowColumn <TableRowColumn
style={{paddingLeft: actionPaddingX, paddingRight: actionPaddingX}} style={{paddingLeft: actionPaddingX, paddingRight: actionPaddingX}}
> >
@ -580,7 +580,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
return true; return true;
} catch (err) { } catch (err) {
const errMsg = '' + err; const errMsg = '' + err;
if (_.includes(errMsg, BlockchainCallErrs.USER_HAS_NO_ASSOCIATED_ADDRESSES)) { if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true); this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return false; return false;
} }

View File

@ -87,7 +87,7 @@ export class TradeHistoryItem extends React.Component<TradeHistoryItemProps, Tra
<EtherScanIcon <EtherScanIcon
addressOrTxHash={fill.transactionHash} addressOrTxHash={fill.transactionHash}
networkId={this.props.networkId} networkId={this.props.networkId}
etherscanLinkSuffixes={EtherscanLinkSuffixes.tx} etherscanLinkSuffixes={EtherscanLinkSuffixes.Tx}
/> />
</div> </div>
</div> </div>

View File

@ -26,7 +26,7 @@ export const EthereumAddress = (props: EthereumAddressProps) => {
<EtherScanIcon <EtherScanIcon
addressOrTxHash={props.address} addressOrTxHash={props.address}
networkId={props.networkId} networkId={props.networkId}
etherscanLinkSuffixes={EtherscanLinkSuffixes.address} etherscanLinkSuffixes={EtherscanLinkSuffixes.Address}
/> />
</div> </div>
<ReactTooltip id={tooltipId}>{props.address}</ReactTooltip> <ReactTooltip id={tooltipId}>{props.address}</ReactTooltip>

View File

@ -13,7 +13,7 @@ interface EtherScanIconProps {
export const EtherScanIcon = (props: EtherScanIconProps) => { export const EtherScanIcon = (props: EtherScanIconProps) => {
const etherscanLinkIfExists = utils.getEtherScanLinkIfExists( const etherscanLinkIfExists = utils.getEtherScanLinkIfExists(
props.addressOrTxHash, props.networkId, EtherscanLinkSuffixes.address, props.addressOrTxHash, props.networkId, EtherscanLinkSuffixes.Address,
); );
const transactionTooltipId = `${props.addressOrTxHash}-etherscan-icon-tooltip`; const transactionTooltipId = `${props.addressOrTxHash}-etherscan-icon-tooltip`;
return ( return (

View File

@ -45,7 +45,7 @@ export class Party extends React.Component<PartyProps, PartyState> {
height: IMAGE_DIMENSION, height: IMAGE_DIMENSION,
}; };
const etherscanLinkIfExists = utils.getEtherScanLinkIfExists( const etherscanLinkIfExists = utils.getEtherScanLinkIfExists(
this.props.address, this.props.networkId, EtherscanLinkSuffixes.address, this.props.address, this.props.networkId, EtherscanLinkSuffixes.Address,
); );
const isRegistered = this.props.isInTokenRegistry; const isRegistered = this.props.isInTokenRegistry;
const registeredTooltipId = `${this.props.address}-${isRegistered}-registeredTooltip`; const registeredTooltipId = `${this.props.address}-${isRegistered}-registeredTooltip`;

View File

@ -281,7 +281,7 @@ export class Documentation extends
return null; return null;
} }
const linkIfExists = utils.getEtherScanLinkIfExists( const linkIfExists = utils.getEtherScanLinkIfExists(
contractAddress, constants.networkIdByName[networkName], EtherscanLinkSuffixes.address, contractAddress, constants.networkIdByName[networkName], EtherscanLinkSuffixes.Address,
); );
return ( return (
<a <a

View File

@ -76,7 +76,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
); );
break; break;
case KindString['Type alias']: case KindString.TypeAlias:
typePrefix = 'Type Alias'; typePrefix = 'Type Alias';
codeSnippet = ( codeSnippet = (
<span> <span>

View File

@ -181,7 +181,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderHero() { private renderHero() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const buttonLabelStyle: React.CSSProperties = { const buttonLabelStyle: React.CSSProperties = {
textTransform: 'none', textTransform: 'none',
fontSize: isSmallScreen ? 12 : 14, fontSize: isSmallScreen ? 12 : 14,
@ -265,8 +265,8 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderProjects() { private renderProjects() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const isMediumScreen = this.state.screenWidth === ScreenWidths.MD; const isMediumScreen = this.state.screenWidth === ScreenWidths.Md;
const projectList = _.map(projects, (project: Project, i: number) => { const projectList = _.map(projects, (project: Project, i: number) => {
const colWidth = isSmallScreen ? 3 : (isMediumScreen ? 4 : 2 - (i % 2)); const colWidth = isSmallScreen ? 3 : (isMediumScreen ? 4 : 2 - (i % 2));
return ( return (
@ -329,7 +329,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderTokenizationSection() { private renderTokenizationSection() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
return ( return (
<div <div
className="clearfix lg-py4 md-py4 sm-pb4 sm-pt2" className="clearfix lg-py4 md-py4 sm-pb4 sm-pt2"
@ -382,7 +382,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderProtocolSection() { private renderProtocolSection() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
return ( return (
<div <div
className="clearfix lg-py4 md-py4 sm-pt4" className="clearfix lg-py4 md-py4 sm-pt4"
@ -468,7 +468,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderBuildingBlocksSection() { private renderBuildingBlocksSection() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const descriptionStyle: React.CSSProperties = { const descriptionStyle: React.CSSProperties = {
fontFamily: 'Roboto Mono', fontFamily: 'Roboto Mono',
lineHeight: isSmallScreen ? 1.5 : 2, lineHeight: isSmallScreen ? 1.5 : 2,
@ -540,7 +540,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderBlockChipImage() { private renderBlockChipImage() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
return ( return (
<div className="col lg-col-6 md-col-6 col-12 sm-center"> <div className="col lg-col-6 md-col-6 col-12 sm-center">
<img <img
@ -551,7 +551,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderTokenCloud() { private renderTokenCloud() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
return ( return (
<div className="col lg-col-6 md-col-6 col-12 center"> <div className="col lg-col-6 md-col-6 col-12 center">
<img <img
@ -562,7 +562,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderAssetTypes() { private renderAssetTypes() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const assetTypes: AssetType[] = [ const assetTypes: AssetType[] = [
{ {
title: 'Currency', title: 'Currency',
@ -601,7 +601,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
return assets; return assets;
} }
private renderInfoBoxes() { private renderInfoBoxes() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const boxStyle: React.CSSProperties = { const boxStyle: React.CSSProperties = {
maxWidth: 252, maxWidth: 252,
height: 386, height: 386,
@ -654,7 +654,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderUseCases() { private renderUseCases() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const useCases: UseCase[] = [ const useCases: UseCase[] = [
{ {
@ -765,7 +765,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
); );
} }
private renderCallToAction() { private renderCallToAction() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.SM; const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const buttonLabelStyle: React.CSSProperties = { const buttonLabelStyle: React.CSSProperties = {
textTransform: 'none', textTransform: 'none',
fontSize: 15, fontSize: 15,

View File

@ -87,7 +87,7 @@ const INITIAL_STATE: State = {
// Shared // Shared
flashMessage: undefined, flashMessage: undefined,
providerType: ProviderType.INJECTED, providerType: ProviderType.Injected,
injectedProviderName: '', injectedProviderName: '',
}; };

View File

@ -1,15 +1,6 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import * as _ from 'lodash'; import * as _ from 'lodash';
// Utility function to create a K:V from a list of strings
// Adapted from: https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html
function strEnum(values: string[]): {[key: string]: string} {
return _.reduce(values, (result, key) => {
result[key] = key;
return result;
}, Object.create(null));
}
export enum Side { export enum Side {
Receive = 'RECEIVE', Receive = 'RECEIVE',
Deposit = 'DEPOSIT', Deposit = 'DEPOSIT',
@ -229,23 +220,21 @@ export interface ContractEvent {
export type InputErrMsg = React.ReactNode | string | undefined; export type InputErrMsg = React.ReactNode | string | undefined;
export type ValidatedBigNumberCallback = (isValid: boolean, amount?: BigNumber) => void; export type ValidatedBigNumberCallback = (isValid: boolean, amount?: BigNumber) => void;
export const ScreenWidths = strEnum([ export enum ScreenWidths {
'SM', Sm = 'SM',
'MD', Md = 'MD',
'LG', Lg = 'LG',
]); }
export type ScreenWidths = keyof typeof ScreenWidths;
export enum AlertTypes { export enum AlertTypes {
ERROR, ERROR,
SUCCESS, SUCCESS,
} }
export const EtherscanLinkSuffixes = strEnum([ export enum EtherscanLinkSuffixes {
'address', Address = 'address',
'tx', Tx = 'tx',
]); }
export type EtherscanLinkSuffixes = keyof typeof EtherscanLinkSuffixes;
export enum BlockchainErrs { export enum BlockchainErrs {
AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK', AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK',
@ -253,26 +242,25 @@ export enum BlockchainErrs {
NoError = 'NO_ERROR', NoError = 'NO_ERROR',
} }
export const BlockchainCallErrs = strEnum([ export enum BlockchainCallErrs {
'CONTRACT_DOES_NOT_EXIST', ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST',
'USER_HAS_NO_ASSOCIATED_ADDRESSES', UserHasNoAssociatedAddresses = 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
'UNHANDLED_ERROR', UnhandledError = 'UNHANDLED_ERROR',
'TOKEN_ADDRESS_IS_INVALID', TokenAddressIsInvalid = 'TOKEN_ADDRESS_IS_INVALID',
'INVALID_SIGNATURE', }
]);
export type BlockchainCallErrs = keyof typeof BlockchainCallErrs;
export const KindString = strEnum([ // Exception: We don't make the values uppercase because these KindString's need to
'Constructor', // match up those returned by TypeDoc
'Property', export enum KindString {
'Method', Constructor = 'Constructor',
'Interface', Property = 'Property',
'Type alias', Method = 'Method',
'Variable', Interface = 'Interface',
'Function', TypeAlias = 'Type alias',
'Enumeration', Variable = 'Variable',
]); Function = 'Function',
export type KindString = keyof typeof KindString; Enumeration = 'Enumeration',
}
export interface EnumValue { export interface EnumValue {
name: string; name: string;
@ -468,11 +456,10 @@ export interface MenuSubsectionsBySection {
[section: string]: string[]; [section: string]: string[];
} }
export const ProviderType = strEnum([ export enum ProviderType {
'INJECTED', Injected = 'INJECTED',
'LEDGER', Ledger = 'LEDGER',
]); }
export type ProviderType = keyof typeof ProviderType;
export interface Fact { export interface Fact {
title: string; title: string;

View File

@ -22,7 +22,7 @@ export const typeDocUtils = {
isType(entity: TypeDocNode): boolean { isType(entity: TypeDocNode): boolean {
return entity.kindString === KindString.Interface || return entity.kindString === KindString.Interface ||
entity.kindString === KindString.Function || entity.kindString === KindString.Function ||
entity.kindString === KindString['Type alias'] || entity.kindString === KindString.TypeAlias ||
entity.kindString === KindString.Variable || entity.kindString === KindString.Variable ||
entity.kindString === KindString.Enumeration; entity.kindString === KindString.Enumeration;
}, },
@ -126,7 +126,7 @@ export const typeDocUtils = {
case KindString.Function: case KindString.Function:
case KindString.Variable: case KindString.Variable:
case KindString.Enumeration: case KindString.Enumeration:
case KindString['Type alias']: case KindString.TypeAlias:
if (docsInfo.isPublicType(entity.name)) { if (docsInfo.isPublicType(entity.name)) {
const customType = typeDocUtils._convertCustomType( const customType = typeDocUtils._convertCustomType(
entity, docsInfo.sections, sectionName, docsInfo.subPackageName); entity, docsInfo.sections, sectionName, docsInfo.subPackageName);

View File

@ -124,11 +124,11 @@ export const utils = {
// This logic mirrors the CSS media queries in BassCSS for the `lg-`, `md-` and `sm-` CSS // This logic mirrors the CSS media queries in BassCSS for the `lg-`, `md-` and `sm-` CSS
// class prefixes. Do not edit these. // class prefixes. Do not edit these.
if (widthInEm > LG_MIN_EM) { if (widthInEm > LG_MIN_EM) {
return ScreenWidths.LG; return ScreenWidths.Lg;
} else if (widthInEm > MD_MIN_EM) { } else if (widthInEm > MD_MIN_EM) {
return ScreenWidths.MD; return ScreenWidths.Md;
} else { } else {
return ScreenWidths.SM; return ScreenWidths.Sm;
} }
}, },
isUserOnMobile(): boolean { isUserOnMobile(): boolean {