Move Documentation to the @0xproject/react-docs package

This commit is contained in:
Fabio Berger
2018-03-06 16:31:55 +01:00
parent f014a97e9a
commit 0b1ba9f997
59 changed files with 653 additions and 488 deletions

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/src/
/scripts/
tsconfig.json

View File

@@ -0,0 +1,3 @@
# CHANGELOG
## vX.X.X - _TBD, 2018_

View File

@@ -0,0 +1,47 @@
## @0xproject/react-docs
A full-page React component for rendering beautiful documentation generated with [TypeDoc](http://typedoc.org/) or [Doxity](https://github.com/0xproject/doxity).
## Installation
```bash
yarn add @0xproject/react-docs
```
## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
```bash
yarn build
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -0,0 +1,37 @@
{
"name": "@0xproject/react-docs",
"version": "0.0.1",
"description": "React documentation component for rendering TypeDoc & Doxity generated JSON",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"lint": "tslint --project . 'src/ts/**/*.ts' 'src/ts/**/*.tsx'",
"build": "tsc",
"build:watch": "tsc -w",
"clean": "shx rm -rf lib"
},
"author": "Fabio Berger",
"license": "MIT",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.9",
"@types/lodash": "^4.14.86",
"@types/node": "^8.0.53",
"@types/material-ui": "0.18.0",
"@types/react": "^15.0.15",
"@types/react-dom": "^0.14.23",
"shx": "^0.2.2",
"tslint": "^5.9.1",
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/react-shared": "^0.0.1",
"basscss": "^8.0.3",
"compare-versions": "^3.0.1",
"react-tooltip": "^3.2.7",
"material-ui": "^0.17.1",
"react": "15.6.1",
"react-dom": "15.6.1",
"lodash": "^4.17.4",
"react-tap-event-plugin": "^2.0.1"
}
}

View File

@@ -0,0 +1,5 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -15,12 +15,12 @@ const styles: Styles = {
}, },
}; };
interface BadgeProps { export interface BadgeProps {
title: string; title: string;
backgroundColor: string; backgroundColor: string;
} }
interface BadgeState { export interface BadgeState {
isHovering: boolean; isHovering: boolean;
} }

View File

@@ -3,7 +3,7 @@ import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import * as ReactMarkdown from 'react-markdown'; import * as ReactMarkdown from 'react-markdown';
interface CommentProps { export interface CommentProps {
comment: string; comment: string;
className?: string; className?: string;
} }

View File

@@ -1,11 +1,12 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { CustomType } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { CustomType } from '../types';
import { utils } from '../utils/utils';
const STRING_ENUM_CODE_PREFIX = ' strEnum('; const STRING_ENUM_CODE_PREFIX = ' strEnum(';
interface CustomEnumProps { export interface CustomEnumProps {
type: CustomType; type: CustomType;
} }

View File

@@ -1,6 +1,7 @@
import { MenuSubsectionsBySection } from '@0xproject/react-shared'; import { MenuSubsectionsBySection } from '@0xproject/react-shared';
import compareVersions = require('compare-versions'); import compareVersions = require('compare-versions');
import * as _ from 'lodash'; import * as _ from 'lodash';
import { import {
ContractsByVersionByNetworkId, ContractsByVersionByNetworkId,
DocAgnosticFormat, DocAgnosticFormat,
@@ -10,9 +11,9 @@ import {
SectionsMap, SectionsMap,
SupportedDocJson, SupportedDocJson,
TypeDocNode, TypeDocNode,
} from 'ts/types'; } from '../types';
import { doxityUtils } from 'ts/utils/doxity_utils'; import { doxityUtils } from '../utils/doxity_utils';
import { typeDocUtils } from 'ts/utils/typedoc_utils'; import { typeDocUtils } from '../utils/typedoc_utils';
export class DocsInfo { export class DocsInfo {
public id: string; public id: string;

View File

@@ -1,9 +1,11 @@
import { import {
colors, colors,
constants as sharedConstants, constants as sharedConstants,
EtherscanLinkSuffixes,
MarkdownSection, MarkdownSection,
MenuSubsectionsBySection, MenuSubsectionsBySection,
NestedSidebarMenu, NestedSidebarMenu,
Networks,
SectionHeader, SectionHeader,
Styles, Styles,
utils as sharedUtils, utils as sharedUtils,
@@ -12,29 +14,28 @@ import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress'; import CircularProgress from 'material-ui/CircularProgress';
import * as React from 'react'; import * as React from 'react';
import { scroller } from 'react-scroll'; import { scroller } from 'react-scroll';
import { Badge } from 'ts/components/ui/badge';
import { Comment } from 'ts/pages/documentation/comment';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { EventDefinition } from 'ts/pages/documentation/event_definition';
import { MethodBlock } from 'ts/pages/documentation/method_block';
import { SourceLink } from 'ts/pages/documentation/source_link';
import { Type } from 'ts/pages/documentation/type';
import { TypeDefinition } from 'ts/pages/documentation/type_definition';
import { import {
AddressByContractName, AddressByContractName,
DocAgnosticFormat, DocAgnosticFormat,
DoxityDocObj, DoxityDocObj,
EtherscanLinkSuffixes,
Event, Event,
Networks,
Property, Property,
SolidityMethod, SolidityMethod,
SupportedDocJson, SupportedDocJson,
TypeDefinitionByName, TypeDefinitionByName,
TypescriptMethod, TypescriptMethod,
} from 'ts/types'; } from '../types';
import { constants } from 'ts/utils/constants'; import { utils } from '../utils/utils';
import { utils } from 'ts/utils/utils';
import { Badge } from './badge';
import { Comment } from './comment';
import { DocsInfo } from './docs_info';
import { EventDefinition } from './event_definition';
import { MethodBlock } from './method_block';
import { SourceLink } from './source_link';
import { Type } from './type';
import { TypeDefinition } from './type_definition';
const TOP_BAR_HEIGHT = 60; const TOP_BAR_HEIGHT = 60;
@@ -55,7 +56,7 @@ export interface DocumentationProps {
sourceUrl: string; sourceUrl: string;
} }
interface DocumentationState {} export interface DocumentationState {}
const styles: Styles = { const styles: Styles = {
mainContainers: { mainContainers: {
@@ -268,9 +269,9 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
if (_.isUndefined(contractAddress)) { if (_.isUndefined(contractAddress)) {
return null; return null;
} }
const linkIfExists = utils.getEtherScanLinkIfExists( const linkIfExists = sharedUtils.getEtherScanLinkIfExists(
contractAddress, contractAddress,
constants.NETWORK_ID_BY_NAME[networkName], sharedConstants.NETWORK_ID_BY_NAME[networkName],
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,
); );
return ( return (

View File

@@ -1,8 +1,9 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { EnumValue } from 'ts/types';
interface EnumProps { import { EnumValue } from '../types';
export interface EnumProps {
values: EnumValue[]; values: EnumValue[];
} }

View File

@@ -1,17 +1,19 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Type } from 'ts/pages/documentation/type';
import { Event, EventArg } from 'ts/types';
interface EventDefinitionProps { import { Event, EventArg } from '../types';
import { DocsInfo } from './docs_info';
import { Type } from './type';
export interface EventDefinitionProps {
event: Event; event: Event;
sectionName: string; sectionName: string;
docsInfo: DocsInfo; docsInfo: DocsInfo;
} }
interface EventDefinitionState { export interface EventDefinitionState {
shouldShowAnchor: boolean; shouldShowAnchor: boolean;
} }

View File

@@ -1,11 +1,13 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { MethodSignature } from 'ts/pages/documentation/method_signature';
import { Type } from 'ts/pages/documentation/type';
import { CustomType, TypeDocTypes } from 'ts/types';
interface InterfaceProps { import { CustomType, TypeDocTypes } from '../types';
import { DocsInfo } from './docs_info';
import { MethodSignature } from './method_signature';
import { Type } from './type';
export interface InterfaceProps {
type: CustomType; type: CustomType;
sectionName: string; sectionName: string;
docsInfo: DocsInfo; docsInfo: DocsInfo;

View File

@@ -1,14 +1,16 @@
import { AnchorTitle, colors, HeaderSizes, Styles } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes, Styles } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { Comment } from 'ts/pages/documentation/comment';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { MethodSignature } from 'ts/pages/documentation/method_signature';
import { SourceLink } from 'ts/pages/documentation/source_link';
import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from 'ts/types';
import { typeDocUtils } from 'ts/utils/typedoc_utils';
interface MethodBlockProps { import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from '../types';
import { typeDocUtils } from '../utils/typedoc_utils';
import { Comment } from './comment';
import { DocsInfo } from './docs_info';
import { MethodSignature } from './method_signature';
import { SourceLink } from './source_link';
export interface MethodBlockProps {
method: SolidityMethod | TypescriptMethod; method: SolidityMethod | TypescriptMethod;
sectionName: string; sectionName: string;
libraryVersion: string; libraryVersion: string;
@@ -17,7 +19,7 @@ interface MethodBlockProps {
sourceUrl: string; sourceUrl: string;
} }
interface MethodBlockState { export interface MethodBlockState {
shouldShowAnchor: boolean; shouldShowAnchor: boolean;
} }

View File

@@ -1,12 +1,14 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import * as ReactDOM from 'react-dom'; import * as ReactDOM from 'react-dom';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Type } from 'ts/pages/documentation/type';
import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from 'ts/types';
import { constants } from 'ts/utils/constants';
interface MethodSignatureProps { import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from '../types';
import { constants } from '../utils/constants';
import { DocsInfo } from './docs_info';
import { Type } from './type';
export interface MethodSignatureProps {
method: TypescriptMethod | SolidityMethod; method: TypescriptMethod | SolidityMethod;
sectionName: string; sectionName: string;
shouldHideMethodName?: boolean; shouldHideMethodName?: boolean;

View File

@@ -1,9 +1,10 @@
import { colors } from '@0xproject/react-shared'; import { colors } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { Source } from 'ts/types';
interface SourceLinkProps { import { Source } from '../types';
export interface SourceLinkProps {
source: Source; source: Source;
sourceUrl: string; sourceUrl: string;
version: string; version: string;

View File

@@ -3,11 +3,13 @@ import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { Link as ScrollLink } from 'react-scroll'; import { Link as ScrollLink } from 'react-scroll';
import * as ReactTooltip from 'react-tooltip'; import * as ReactTooltip from 'react-tooltip';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { TypeDefinition } from 'ts/pages/documentation/type_definition'; import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types';
import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from 'ts/types'; import { constants } from '../utils/constants';
import { constants } from 'ts/utils/constants'; import { utils } from '../utils/utils';
import { utils } from 'ts/utils/utils';
import { DocsInfo } from './docs_info';
import { TypeDefinition } from './type_definition';
// Some types reference other libraries. For these types, we want to link the user to the relevant documentation. // Some types reference other libraries. For these types, we want to link the user to the relevant documentation.
const typeToUrl: { [typeName: string]: string } = { const typeToUrl: { [typeName: string]: string } = {
@@ -34,7 +36,7 @@ const typeToSection: { [typeName: string]: string } = {
OrderStateWatcher: 'orderWatcher', OrderStateWatcher: 'orderWatcher',
}; };
interface TypeProps { export interface TypeProps {
type: TypeDef; type: TypeDef;
docsInfo: DocsInfo; docsInfo: DocsInfo;
sectionName: string; sectionName: string;
@@ -181,7 +183,7 @@ export function Type(props: TypeProps): any {
duration={sharedConstants.DOCS_SCROLL_DURATION_MS} duration={sharedConstants.DOCS_SCROLL_DURATION_MS}
containerId={sharedConstants.DOCS_CONTAINER_ID} containerId={sharedConstants.DOCS_CONTAINER_ID}
> >
{_.isUndefined(typeDefinition) || utils.isUserOnMobile() ? ( {_.isUndefined(typeDefinition) || sharedUtils.isUserOnMobile() ? (
<span <span
onClick={sharedUtils.setUrlHash.bind(null, typeDefinitionAnchorId)} onClick={sharedUtils.setUrlHash.bind(null, typeDefinitionAnchorId)}
style={{ color: colors.lightBlueA700, cursor: 'pointer' }} style={{ color: colors.lightBlueA700, cursor: 'pointer' }}

View File

@@ -1,24 +1,26 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { Comment } from 'ts/pages/documentation/comment';
import { CustomEnum } from 'ts/pages/documentation/custom_enum';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Enum } from 'ts/pages/documentation/enum';
import { Interface } from 'ts/pages/documentation/interface';
import { MethodSignature } from 'ts/pages/documentation/method_signature';
import { Type } from 'ts/pages/documentation/type';
import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from 'ts/types';
import { utils } from 'ts/utils/utils';
interface TypeDefinitionProps { import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from '../types';
import { utils } from '../utils/utils';
import { Comment } from './comment';
import { CustomEnum } from './custom_enum';
import { DocsInfo } from './docs_info';
import { Enum } from './enum';
import { Interface } from './interface';
import { MethodSignature } from './method_signature';
import { Type } from './type';
export interface TypeDefinitionProps {
sectionName: string; sectionName: string;
customType: CustomType; customType: CustomType;
shouldAddId?: boolean; shouldAddId?: boolean;
docsInfo: DocsInfo; docsInfo: DocsInfo;
} }
interface TypeDefinitionState { export interface TypeDefinitionState {
shouldShowAnchor: boolean; shouldShowAnchor: boolean;
} }

View File

@@ -0,0 +1,7 @@
declare module 'react-tooltip';
// compare-version declarations
declare function compareVersions(firstVersion: string, secondVersion: string): number;
declare module 'compare-versions' {
export = compareVersions;
}

View File

@@ -0,0 +1,20 @@
export { Documentation } from './components/documentation';
export { DocsInfo } from './components/docs_info';
// Exported to give users of this library added flexibility if they want to build
// a docs page from scratch using the individual components.
export { Badge } from './components/badge';
export { Comment } from './components/comment';
export { CustomEnum } from './components/custom_enum';
export { Enum } from './components/enum';
export { EventDefinition } from './components/event_definition';
export { Interface } from './components/interface';
export { MethodBlock } from './components/method_block';
export { MethodSignature } from './components/method_signature';
export { SourceLink } from './components/source_link';
export { TypeDefinition } from './components/type_definition';
export { Type } from './components/type';
export { DocsInfoConfig, DocAgnosticFormat, DoxityDocObj, DocsMenu, SupportedDocJson, TypeDocNode } from './types';
export { constants } from './utils/constants';

View File

@@ -0,0 +1,266 @@
export interface DocsInfoConfig {
id: string;
type: SupportedDocJson;
displayName: string;
packageUrl: string;
menu: DocsMenu;
sections: SectionsMap;
sectionNameToMarkdown: { [sectionName: string]: string };
visibleConstructors: string[];
subPackageName?: string;
publicTypes?: string[];
sectionNameToModulePath?: { [sectionName: string]: string[] };
menuSubsectionToVersionWhenIntroduced?: { [sectionName: string]: string };
contractsByVersionByNetworkId?: ContractsByVersionByNetworkId;
}
export interface DocsMenu {
[sectionName: string]: string[];
}
export interface SectionsMap {
[sectionName: string]: string;
}
export interface TypeDocType {
type: TypeDocTypes;
value: string;
name: string;
types: TypeDocType[];
typeArguments?: TypeDocType[];
declaration: TypeDocNode;
elementType?: TypeDocType;
}
export interface TypeDocFlags {
isStatic?: boolean;
isOptional?: boolean;
isPublic?: boolean;
}
export interface TypeDocGroup {
title: string;
children: number[];
}
export interface TypeDocNode {
id?: number;
name?: string;
kind?: string;
defaultValue?: string;
kindString?: string;
type?: TypeDocType;
fileName?: string;
line?: number;
comment?: TypeDocNode;
text?: string;
shortText?: string;
returns?: string;
declaration: TypeDocNode;
flags?: TypeDocFlags;
indexSignature?: TypeDocNode | TypeDocNode[]; // TypeDocNode in TypeDoc <V0.9.0, TypeDocNode[] in >V0.9.0
signatures?: TypeDocNode[];
parameters?: TypeDocNode[];
typeParameter?: TypeDocNode[];
sources?: TypeDocNode[];
children?: TypeDocNode[];
groups?: TypeDocGroup[];
}
export enum TypeDocTypes {
Intrinsic = 'intrinsic',
Reference = 'reference',
Array = 'array',
StringLiteral = 'stringLiteral',
Reflection = 'reflection',
Union = 'union',
TypeParameter = 'typeParameter',
Intersection = 'intersection',
Unknown = 'unknown',
}
// Exception: We don't make the values uppercase because these KindString's need to
// match up those returned by TypeDoc
export enum KindString {
Constructor = 'Constructor',
Property = 'Property',
Method = 'Method',
Interface = 'Interface',
TypeAlias = 'Type alias',
Variable = 'Variable',
Function = 'Function',
Enumeration = 'Enumeration',
}
export interface DocAgnosticFormat {
[sectionName: string]: DocSection;
}
export interface DocSection {
comment: string;
constructors: Array<TypescriptMethod | SolidityMethod>;
methods: Array<TypescriptMethod | SolidityMethod>;
properties: Property[];
types: CustomType[];
events?: Event[];
}
export interface TypescriptMethod extends BaseMethod {
source?: Source;
isStatic?: boolean;
typeParameter?: TypeParameter;
}
export interface SolidityMethod extends BaseMethod {
isConstant?: boolean;
isPayable?: boolean;
}
export interface Source {
fileName: string;
line: number;
}
export interface Parameter {
name: string;
comment: string;
isOptional: boolean;
type: Type;
}
export interface TypeParameter {
name: string;
type: Type;
}
export interface Type {
name: string;
typeDocType: TypeDocTypes;
value?: string;
typeArguments?: Type[];
elementType?: ElementType;
types?: Type[];
method?: TypescriptMethod;
}
export interface ElementType {
name: string;
typeDocType: TypeDocTypes;
}
export interface IndexSignature {
keyName: string;
keyType: Type;
valueName: string;
}
export interface CustomType {
name: string;
kindString: string;
type?: Type;
method?: TypescriptMethod;
indexSignature?: IndexSignature;
defaultValue?: string;
comment?: string;
children?: CustomTypeChild[];
}
export interface CustomTypeChild {
name: string;
type?: Type;
defaultValue?: string;
}
export interface Event {
name: string;
eventArgs: EventArg[];
}
export interface EventArg {
isIndexed: boolean;
name: string;
type: Type;
}
export interface Property {
name: string;
type: Type;
source?: Source;
comment?: string;
}
export interface BaseMethod {
isConstructor: boolean;
name: string;
returnComment?: string | undefined;
callPath: string;
parameters: Parameter[];
returnType: Type;
comment?: string;
}
export interface TypeDefinitionByName {
[typeName: string]: CustomType;
}
export enum SupportedDocJson {
Doxity = 'DOXITY',
TypeDoc = 'TYPEDOC',
}
export interface ContractsByVersionByNetworkId {
[version: string]: {
[networkName: string]: {
[contractName: string]: string;
};
};
}
export interface DoxityDocObj {
[contractName: string]: DoxityContractObj;
}
export interface DoxityContractObj {
title: string;
fileName: string;
name: string;
abiDocs: DoxityAbiDoc[];
}
export interface DoxityAbiDoc {
constant: boolean;
inputs: DoxityInput[];
name: string;
outputs: DoxityOutput[];
payable: boolean;
type: string;
details?: string;
return?: string;
}
export interface DoxityOutput {
name: string;
type: string;
}
export interface DoxityInput {
name: string;
type: string;
description: string;
indexed?: boolean;
}
export interface AddressByContractName {
[contractName: string]: string;
}
export interface EnumValue {
name: string;
defaultValue?: string;
}
export enum AbiTypes {
Constructor = 'constructor',
Function = 'function',
Event = 'event',
}

View File

@@ -0,0 +1,9 @@
export const constants = {
TYPES_SECTION_NAME: 'types',
URL_WEB3_DOCS: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
URL_WEB3_DECODED_LOG_ENTRY_EVENT:
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
URL_WEB3_LOG_ENTRY_EVENT: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
URL_WEB3_PROVIDER_DOCS: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
};

View File

@@ -1,4 +1,5 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { import {
AbiTypes, AbiTypes,
DocAgnosticFormat, DocAgnosticFormat,
@@ -13,7 +14,7 @@ import {
SolidityMethod, SolidityMethod,
Type, Type,
TypeDocTypes, TypeDocTypes,
} from 'ts/types'; } from '../types';
export const doxityUtils = { export const doxityUtils = {
convertToDocAgnosticFormat(doxityDocObj: DoxityDocObj): DocAgnosticFormat { convertToDocAgnosticFormat(doxityDocObj: DoxityDocObj): DocAgnosticFormat {

View File

@@ -1,10 +1,10 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { DocsInfo } from '../components/docs_info';
import { import {
CustomType, CustomType,
CustomTypeChild, CustomTypeChild,
DocAgnosticFormat, DocAgnosticFormat,
DocPackages,
DocSection, DocSection,
IndexSignature, IndexSignature,
KindString, KindString,
@@ -16,8 +16,8 @@ import {
TypeDocType, TypeDocType,
TypeParameter, TypeParameter,
TypescriptMethod, TypescriptMethod,
} from 'ts/types'; } from '../types';
import { utils } from 'ts/utils/utils'; import { utils } from '../utils/utils';
export const typeDocUtils = { export const typeDocUtils = {
isType(entity: TypeDocNode): boolean { isType(entity: TypeDocNode): boolean {
@@ -267,7 +267,8 @@ export const typeDocUtils = {
let callPath; let callPath;
if (isConstructor || entity.name === '__type') { if (isConstructor || entity.name === '__type') {
callPath = ''; callPath = '';
} else if (docId === DocPackages.ZeroExJs) { // TODO: Get rid of this 0x-specific logic
} else if (docId === 'ZERO_EX_JS') {
const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.'; const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.';
callPath = callPath =
!_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx !_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx

View File

@@ -0,0 +1,10 @@
export const utils = {
consoleLog(message: string) {
/* tslint:disable */
console.log(message);
/* tslint:enable */
},
spawnSwitchErr(name: string, value: any) {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
};

View File

@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "./lib/",
"jsx": "react",
"baseUrl": "./",
"strictNullChecks": false,
"noImplicitThis": false,
"paths": {
"*": ["node_modules/@types/*", "*"]
}
},
"include": ["./src/ts/**/*"]
}

View File

@@ -0,0 +1,9 @@
{
"extends": ["@0xproject/tslint-config"],
"rules": {
"no-implicit-dependencies": false,
"no-object-literal-type-assertion": false,
"completed-docs": false,
"prefer-function-over-method": false
}
}

View File

@@ -25,6 +25,7 @@
}, },
"dependencies": { "dependencies": {
"basscss": "^8.0.3", "basscss": "^8.0.3",
"is-mobile": "^0.2.2",
"material-ui": "^0.17.1", "material-ui": "^0.17.1",
"react": "15.6.1", "react": "15.6.1",
"react-dom": "15.6.1", "react-dom": "15.6.1",

View File

@@ -1 +1,7 @@
declare module 'react-highlight'; declare module 'react-highlight';
// is-mobile declarations
declare function isMobile(): boolean;
declare module 'is-mobile' {
export = isMobile;
}

View File

@@ -5,7 +5,7 @@ export { MarkdownSection } from './components/markdown_section';
export { NestedSidebarMenu } from './components/nested_sidebar_menu'; export { NestedSidebarMenu } from './components/nested_sidebar_menu';
export { SectionHeader } from './components/section_header'; export { SectionHeader } from './components/section_header';
export { HeaderSizes, Styles, MenuSubsectionsBySection } from './types'; export { HeaderSizes, Styles, MenuSubsectionsBySection, EtherscanLinkSuffixes, Networks } from './types';
export { utils } from './utils/utils'; export { utils } from './utils/utils';
export { constants } from './utils/constants'; export { constants } from './utils/constants';

View File

@@ -11,3 +11,15 @@ export enum HeaderSizes {
export interface MenuSubsectionsBySection { export interface MenuSubsectionsBySection {
[section: string]: string[]; [section: string]: string[];
} }
export enum EtherscanLinkSuffixes {
Address = 'address',
Tx = 'tx',
}
export enum Networks {
Mainnet = 'Mainnet',
Kovan = 'Kovan',
Ropsten = 'Ropsten',
Rinkeby = 'Rinkeby',
}

View File

@@ -1,6 +1,20 @@
import { Networks } from '../types';
export const constants = { export const constants = {
DOCS_SCROLL_DURATION_MS: 0, DOCS_SCROLL_DURATION_MS: 0,
DOCS_CONTAINER_ID: 'documentation', DOCS_CONTAINER_ID: 'documentation',
SCROLL_CONTAINER_ID: 'documentation', SCROLL_CONTAINER_ID: 'documentation',
SCROLL_TOP_ID: 'pageScrollTop', SCROLL_TOP_ID: 'pageScrollTop',
NETWORK_NAME_BY_ID: {
1: Networks.Mainnet,
3: Networks.Ropsten,
4: Networks.Rinkeby,
42: Networks.Kovan,
} as { [symbol: number]: string },
NETWORK_ID_BY_NAME: {
[Networks.Mainnet]: 1,
[Networks.Ropsten]: 3,
[Networks.Rinkeby]: 4,
[Networks.Kovan]: 42,
} as { [networkName: string]: number },
}; };

View File

@@ -1,6 +1,9 @@
import isMobile = require('is-mobile');
import * as _ from 'lodash'; import * as _ from 'lodash';
import { scroller } from 'react-scroll'; import { scroller } from 'react-scroll';
import { EtherscanLinkSuffixes, Networks } from '../types';
import { constants } from './constants'; import { constants } from './constants';
export const utils = { export const utils = {
@@ -19,6 +22,10 @@ export const utils = {
containerId, containerId,
}); });
}, },
isUserOnMobile(): boolean {
const isUserOnMobile = isMobile();
return isUserOnMobile;
},
getIdFromName(name: string) { getIdFromName(name: string) {
const id = name.replace(/ /g, '-'); const id = name.replace(/ /g, '-');
return id; return id;
@@ -29,4 +36,12 @@ export const utils = {
const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
return baseUrl; return baseUrl;
}, },
getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string {
const networkName = constants.NETWORK_NAME_BY_ID[networkId];
if (_.isUndefined(networkName)) {
return undefined;
}
const etherScanPrefix = networkName === Networks.Mainnet ? '' : `${networkName.toLowerCase()}.`;
return `https://${etherScanPrefix}etherscan.io/${suffix}/${addressOrTxHash}`;
},
}; };

View File

@@ -18,6 +18,7 @@
"author": "Fabio Berger", "author": "Fabio Berger",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@0xproject/react-docs": "^0.0.1",
"@0xproject/react-shared": "^0.0.1", "@0xproject/react-shared": "^0.0.1",
"@0xproject/subproviders": "^0.6.0", "@0xproject/subproviders": "^0.6.0",
"@0xproject/utils": "^0.4.0", "@0xproject/utils": "^0.4.0",
@@ -25,14 +26,12 @@
"accounting": "^0.4.1", "accounting": "^0.4.1",
"basscss": "^8.0.3", "basscss": "^8.0.3",
"blockies": "^0.0.2", "blockies": "^0.0.2",
"compare-versions": "^3.0.1",
"dateformat": "^2.0.0", "dateformat": "^2.0.0",
"deep-equal": "^1.0.1", "deep-equal": "^1.0.1",
"dharma-loan-frame": "^0.0.12", "dharma-loan-frame": "^0.0.12",
"ethereumjs-tx": "^1.3.3", "ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"find-versions": "^2.0.0", "find-versions": "^2.0.0",
"is-mobile": "^0.2.2",
"jsonschema": "^1.2.0", "jsonschema": "^1.2.0",
"less": "^2.7.2", "less": "^2.7.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",

View File

@@ -15,6 +15,7 @@ import {
TransactionReceiptWithDecodedLogs, TransactionReceiptWithDecodedLogs,
ZeroEx, ZeroEx,
} from '0x.js'; } from '0x.js';
import { EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared';
import { import {
InjectedWeb3Subprovider, InjectedWeb3Subprovider,
ledgerEthereumBrowserClientFactoryAsync, ledgerEthereumBrowserClientFactoryAsync,
@@ -35,7 +36,6 @@ import {
BlockchainCallErrs, BlockchainCallErrs,
BlockchainErrs, BlockchainErrs,
ContractInstance, ContractInstance,
EtherscanLinkSuffixes,
Order as PortalOrder, Order as PortalOrder,
ProviderType, ProviderType,
Side, Side,
@@ -271,7 +271,11 @@ export class Blockchain {
}, },
); );
await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash); await this._showEtherScanLinkAndAwaitTransactionMinedAsync(txHash);
const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx); const etherScanLinkIfExists = sharedUtils.getEtherScanLinkIfExists(
txHash,
this.networkId,
EtherscanLinkSuffixes.Tx,
);
this._dispatcher.showFlashMessage( this._dispatcher.showFlashMessage(
React.createElement(TokenSendCompleted, { React.createElement(TokenSendCompleted, {
etherScanLinkIfExists, etherScanLinkIfExists,
@@ -542,7 +546,11 @@ export class Blockchain {
private async _showEtherScanLinkAndAwaitTransactionMinedAsync( private async _showEtherScanLinkAndAwaitTransactionMinedAsync(
txHash: string, txHash: string,
): Promise<TransactionReceiptWithDecodedLogs> { ): Promise<TransactionReceiptWithDecodedLogs> {
const etherScanLinkIfExists = utils.getEtherScanLinkIfExists(txHash, this.networkId, EtherscanLinkSuffixes.Tx); const etherScanLinkIfExists = sharedUtils.getEtherScanLinkIfExists(
txHash,
this.networkId,
EtherscanLinkSuffixes.Tx,
);
this._dispatcher.showFlashMessage( this._dispatcher.showFlashMessage(
React.createElement(TransactionSubmitted, { React.createElement(TransactionSubmitted, {
etherScanLinkIfExists, etherScanLinkIfExists,

View File

@@ -1,10 +1,10 @@
import { colors } from '@0xproject/react-shared'; import { colors, Networks } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Dialog from 'material-ui/Dialog'; import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton'; import FlatButton from 'material-ui/FlatButton';
import * as React from 'react'; import * as React from 'react';
import { Blockchain } from 'ts/blockchain'; import { Blockchain } from 'ts/blockchain';
import { BlockchainErrs, Networks } from 'ts/types'; import { BlockchainErrs } from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';

View File

@@ -1,4 +1,4 @@
import { colors } from '@0xproject/react-shared'; import { colors, constants as sharedConstants } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Dialog from 'material-ui/Dialog'; import Dialog from 'material-ui/Dialog';
@@ -82,7 +82,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
); );
} }
private _renderConnectStep() { private _renderConnectStep() {
const networkIds = _.values(constants.NETWORK_ID_BY_NAME); const networkIds = _.values(sharedConstants.NETWORK_ID_BY_NAME);
return ( return (
<div> <div>
<div className="h4 pt3">Follow these instructions before proceeding:</div> <div className="h4 pt3">Follow these instructions before proceeding:</div>
@@ -163,7 +163,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
const balance = this.state.addressBalances[i]; const balance = this.state.addressBalances[i];
const addressTooltipId = `address-${userAddress}`; const addressTooltipId = `address-${userAddress}`;
const balanceTooltipId = `balance-${userAddress}`; const balanceTooltipId = `balance-${userAddress}`;
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
// We specifically prefix kovan ETH. // We specifically prefix kovan ETH.
// TODO: We should probably add prefixes for all networks // TODO: We should probably add prefixes for all networks
const isKovanNetwork = networkName === 'Kovan'; const isKovanNetwork = networkName === 'Kovan';

View File

@@ -1,8 +1,8 @@
import { constants as sharedConstants } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import DropDownMenu from 'material-ui/DropDownMenu'; import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem'; import MenuItem from 'material-ui/MenuItem';
import * as React from 'react'; import * as React from 'react';
import { constants } from 'ts/utils/constants';
interface NetworkDropDownProps { interface NetworkDropDownProps {
updateSelectedNetwork: (e: any, index: number, value: number) => void; updateSelectedNetwork: (e: any, index: number, value: number) => void;
@@ -24,7 +24,7 @@ export class NetworkDropDown extends React.Component<NetworkDropDownProps, Netwo
} }
private _renderDropDownItems() { private _renderDropDownItems() {
const items = _.map(this.props.avialableNetworkIds, networkId => { const items = _.map(this.props.avialableNetworkIds, networkId => {
const networkName = constants.NETWORK_NAME_BY_ID[networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[networkId];
const primaryText = ( const primaryText = (
<div className="flex"> <div className="flex">
<div className="pr1" style={{ width: 14, paddingTop: 2 }}> <div className="pr1" style={{ width: 14, paddingTop: 2 }}>

View File

@@ -1,5 +1,5 @@
import { ZeroEx } from '0x.js'; import { ZeroEx } from '0x.js';
import { colors } from '@0xproject/react-shared'; import { colors, EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Divider from 'material-ui/Divider'; import Divider from 'material-ui/Divider';
@@ -10,14 +10,7 @@ import ReactTooltip = require('react-tooltip');
import { Blockchain } from 'ts/blockchain'; import { Blockchain } from 'ts/blockchain';
import { EthWethConversionButton } from 'ts/components/eth_weth_conversion_button'; import { EthWethConversionButton } from 'ts/components/eth_weth_conversion_button';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { import { OutdatedWrappedEtherByNetworkId, Side, Token, TokenByAddress, TokenState } from 'ts/types';
EtherscanLinkSuffixes,
OutdatedWrappedEtherByNetworkId,
Side,
Token,
TokenByAddress,
TokenState,
} from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
@@ -99,7 +92,7 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
const etherToken = this._getEthToken(); const etherToken = this._getEthToken();
const wethBalance = ZeroEx.toUnitAmount(this.state.ethTokenState.balance, constants.DECIMAL_PLACES_ETH); const wethBalance = ZeroEx.toUnitAmount(this.state.ethTokenState.balance, constants.DECIMAL_PLACES_ETH);
const isBidirectional = true; const isBidirectional = true;
const etherscanUrl = utils.getEtherScanLinkIfExists( const etherscanUrl = sharedUtils.getEtherScanLinkIfExists(
etherToken.address, etherToken.address,
this.props.networkId, this.props.networkId,
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,
@@ -281,7 +274,7 @@ export class EthWrappers extends React.Component<EthWrappersProps, EthWrappersSt
this, this,
outdatedWETHIfExists.address, outdatedWETHIfExists.address,
); );
const etherscanUrl = utils.getEtherScanLinkIfExists( const etherscanUrl = sharedUtils.getEtherScanLinkIfExists(
outdatedWETHIfExists.address, outdatedWETHIfExists.address,
this.props.networkId, this.props.networkId,
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,

View File

@@ -1,5 +1,5 @@
import { Order as ZeroExOrder, ZeroEx } from '0x.js'; import { Order as ZeroExOrder, ZeroEx } from '0x.js';
import { colors } from '@0xproject/react-shared'; import { colors, constants as sharedConstants } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as accounting from 'accounting'; import * as accounting from 'accounting';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -537,7 +537,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}); });
return; return;
} }
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${parsedOrder.metadata.takerToken.symbol}-${networkName}`; const eventLabel = `${parsedOrder.metadata.takerToken.symbol}-${networkName}`;
try { try {
const orderFilledAmount: BigNumber = await this.props.blockchain.fillOrderAsync( const orderFilledAmount: BigNumber = await this.props.blockchain.fillOrderAsync(
@@ -623,7 +623,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}); });
return; return;
} }
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${parsedOrder.metadata.makerToken.symbol}-${networkName}`; const eventLabel = `${parsedOrder.metadata.makerToken.symbol}-${networkName}`;
try { try {
await this.props.blockchain.cancelOrderAsync(signedOrder, availableTakerTokenAmount); await this.props.blockchain.cancelOrderAsync(signedOrder, availableTakerTokenAmount);

View File

@@ -1,3 +1,4 @@
import { constants as sharedConstants } from '@0xproject/react-shared';
import { ECSignature, Order, ZeroEx } from '0x.js'; import { ECSignature, Order, ZeroEx } from '0x.js';
import { colors } from '@0xproject/react-shared'; import { colors } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
@@ -253,7 +254,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
) { ) {
const didSignSuccessfully = await this._signTransactionAsync(); const didSignSuccessfully = await this._signTransactionAsync();
if (didSignSuccessfully) { if (didSignSuccessfully) {
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${this.props.tokenByAddress[debitToken.address].symbol}-${networkName}`; const eventLabel = `${this.props.tokenByAddress[debitToken.address].symbol}-${networkName}`;
ReactGA.event({ ReactGA.event({
category: 'Portal', category: 'Portal',

View File

@@ -1,3 +1,4 @@
import { constants as sharedConstants } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Toggle from 'material-ui/Toggle'; import Toggle from 'material-ui/Toggle';
@@ -76,7 +77,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
if (!this._isAllowanceSet()) { if (!this._isAllowanceSet()) {
newAllowanceAmountInBaseUnits = DEFAULT_ALLOWANCE_AMOUNT_IN_BASE_UNITS; newAllowanceAmountInBaseUnits = DEFAULT_ALLOWANCE_AMOUNT_IN_BASE_UNITS;
} }
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${this.props.token.symbol}-${networkName}`; const eventLabel = `${this.props.token.symbol}-${networkName}`;
try { try {
await this.props.blockchain.setProxyAllowanceAsync(this.props.token, newAllowanceAmountInBaseUnits); await this.props.blockchain.setProxyAllowanceAsync(this.props.token, newAllowanceAmountInBaseUnits);

View File

@@ -1,5 +1,12 @@
import { ZeroEx } from '0x.js'; import { ZeroEx } from '0x.js';
import { colors, Styles } from '@0xproject/react-shared'; import {
colors,
constants as sharedConstants,
EtherscanLinkSuffixes,
Networks,
Styles,
utils as sharedUtils,
} from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import DharmaLoanFrame from 'dharma-loan-frame'; import DharmaLoanFrame from 'dharma-loan-frame';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -27,8 +34,6 @@ import {
BalanceErrs, BalanceErrs,
BlockchainCallErrs, BlockchainCallErrs,
BlockchainErrs, BlockchainErrs,
EtherscanLinkSuffixes,
Networks,
ScreenWidths, ScreenWidths,
Token, Token,
TokenByAddress, TokenByAddress,
@@ -117,7 +122,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
if (nextProps.userEtherBalance !== this.props.userEtherBalance) { if (nextProps.userEtherBalance !== this.props.userEtherBalance) {
if (this.state.isBalanceSpinnerVisible) { if (this.state.isBalanceSpinnerVisible) {
const receivedAmount = nextProps.userEtherBalance.minus(this.props.userEtherBalance); const receivedAmount = nextProps.userEtherBalance.minus(this.props.userEtherBalance);
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
this.props.dispatcher.showFlashMessage(`Received ${receivedAmount.toString(10)} ${networkName} Ether`); this.props.dispatcher.showFlashMessage(`Received ${receivedAmount.toString(10)} ${networkName} Ether`);
} }
this.setState({ this.setState({
@@ -357,17 +362,20 @@ 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.state.trackedTokenStateByAddress[token.address]; const tokenState = this.state.trackedTokenStateByAddress[token.address];
const tokenLink = utils.getEtherScanLinkIfExists( const tokenLink = sharedUtils.getEtherScanLinkIfExists(
token.address, token.address,
this.props.networkId, this.props.networkId,
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,
); );
const isMintable = const isMintable =
(_.includes(configs.SYMBOLS_OF_MINTABLE_KOVAN_TOKENS, token.symbol) && (_.includes(configs.SYMBOLS_OF_MINTABLE_KOVAN_TOKENS, token.symbol) &&
this.props.networkId === constants.NETWORK_ID_BY_NAME[Networks.Kovan]) || this.props.networkId === sharedConstants.NETWORK_ID_BY_NAME[Networks.Kovan]) ||
(_.includes(configs.SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS, token.symbol) && (_.includes(configs.SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS, token.symbol) &&
_.includes( _.includes(
[constants.NETWORK_ID_BY_NAME[Networks.Rinkeby], constants.NETWORK_ID_BY_NAME[Networks.Ropsten]], [
sharedConstants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
sharedConstants.NETWORK_ID_BY_NAME[Networks.Ropsten],
],
this.props.networkId, this.props.networkId,
)); ));
return ( return (
@@ -539,7 +547,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
} }
} }
private _renderDharmaLoanFrame() { private _renderDharmaLoanFrame() {
if (utils.isUserOnMobile()) { if (sharedUtils.isUserOnMobile()) {
return ( return (
<h4 style={{ textAlign: 'center' }}> <h4 style={{ textAlign: 'center' }}>
We apologize -- Dharma loan requests are not available on mobile yet. Please try again through your We apologize -- Dharma loan requests are not available on mobile yet. Please try again through your

View File

@@ -1,3 +1,4 @@
import { constants as sharedConstants } from '@0xproject/react-shared';
import { colors } from '@0xproject/react-shared'; import { colors } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton'; import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton';
@@ -56,7 +57,7 @@ export class ProviderPicker extends React.Component<ProviderPickerProps, Provide
return label; return label;
} }
private _renderNetwork() { private _renderNetwork() {
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId]; const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
return ( return (
<div className="flex" style={{ marginTop: 1 }}> <div className="flex" style={{ marginTop: 1 }}>
<div className="relative" style={{ width: 14, paddingLeft: 14 }}> <div className="relative" style={{ width: 14, paddingLeft: 14 }}>

View File

@@ -1,3 +1,4 @@
import { DocsInfo, DocsMenu } from '@0xproject/react-docs';
import { colors, MenuSubsectionsBySection, NestedSidebarMenu, Styles } from '@0xproject/react-shared'; import { colors, MenuSubsectionsBySection, NestedSidebarMenu, Styles } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer'; import Drawer from 'material-ui/Drawer';
@@ -12,9 +13,8 @@ import { ProviderDisplay } from 'ts/components/top_bar/provider_display';
import { TopBarMenuItem } from 'ts/components/top_bar/top_bar_menu_item'; import { TopBarMenuItem } from 'ts/components/top_bar/top_bar_menu_item';
import { DropDown } from 'ts/components/ui/drop_down'; import { DropDown } from 'ts/components/ui/drop_down';
import { Identicon } from 'ts/components/ui/identicon'; import { Identicon } from 'ts/components/ui/identicon';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { Deco, DocsMenu, Key, ProviderType, WebsitePaths } from 'ts/types'; import { Deco, Key, ProviderType, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate'; import { Translate } from 'ts/utils/translate';

View File

@@ -1,5 +1,5 @@
import { ZeroEx } from '0x.js'; import { ZeroEx } from '0x.js';
import { colors } from '@0xproject/react-shared'; import { colors, EtherscanLinkSuffixes } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Paper from 'material-ui/Paper'; import Paper from 'material-ui/Paper';
@@ -8,7 +8,7 @@ import * as React from 'react';
import * as ReactTooltip from 'react-tooltip'; import * as ReactTooltip from 'react-tooltip';
import { EtherScanIcon } from 'ts/components/ui/etherscan_icon'; import { EtherScanIcon } from 'ts/components/ui/etherscan_icon';
import { Party } from 'ts/components/ui/party'; import { Party } from 'ts/components/ui/party';
import { EtherscanLinkSuffixes, Fill, Token, TokenByAddress } from 'ts/types'; import { Fill, Token, TokenByAddress } from 'ts/types';
const PRECISION = 5; const PRECISION = 5;
const IDENTICON_DIAMETER = 40; const IDENTICON_DIAMETER = 40;

View File

@@ -1,7 +1,7 @@
import { EtherscanLinkSuffixes } from '@0xproject/react-shared';
import * as React from 'react'; import * as React from 'react';
import ReactTooltip = require('react-tooltip'); import ReactTooltip = require('react-tooltip');
import { EtherScanIcon } from 'ts/components/ui/etherscan_icon'; import { EtherScanIcon } from 'ts/components/ui/etherscan_icon';
import { EtherscanLinkSuffixes } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
interface EthereumAddressProps { interface EthereumAddressProps {

View File

@@ -1,8 +1,7 @@
import { colors } from '@0xproject/react-shared'; import { colors, EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import ReactTooltip = require('react-tooltip'); import ReactTooltip = require('react-tooltip');
import { EtherscanLinkSuffixes } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
interface EtherScanIconProps { interface EtherScanIconProps {
@@ -12,7 +11,7 @@ interface EtherScanIconProps {
} }
export const EtherScanIcon = (props: EtherScanIconProps) => { export const EtherScanIcon = (props: EtherScanIconProps) => {
const etherscanLinkIfExists = utils.getEtherScanLinkIfExists( const etherscanLinkIfExists = sharedUtils.getEtherScanLinkIfExists(
props.addressOrTxHash, props.addressOrTxHash,
props.networkId, props.networkId,
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,

View File

@@ -1,10 +1,9 @@
import { colors } from '@0xproject/react-shared'; import { colors, EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import ReactTooltip = require('react-tooltip'); import ReactTooltip = require('react-tooltip');
import { EthereumAddress } from 'ts/components/ui/ethereum_address'; import { EthereumAddress } from 'ts/components/ui/ethereum_address';
import { Identicon } from 'ts/components/ui/identicon'; import { Identicon } from 'ts/components/ui/identicon';
import { EtherscanLinkSuffixes } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
const IMAGE_DIMENSION = 100; const IMAGE_DIMENSION = 100;
@@ -43,7 +42,7 @@ export class Party extends React.Component<PartyProps, PartyState> {
width: IMAGE_DIMENSION, width: IMAGE_DIMENSION,
height: IMAGE_DIMENSION, height: IMAGE_DIMENSION,
}; };
const etherscanLinkIfExists = utils.getEtherScanLinkIfExists( const etherscanLinkIfExists = sharedUtils.getEtherScanLinkIfExists(
this.props.address, this.props.address,
this.props.networkId, this.props.networkId,
EtherscanLinkSuffixes.Address, EtherscanLinkSuffixes.Address,

View File

@@ -1,12 +1,12 @@
import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer'; import { State } from 'ts/redux/reducer';
import { DocPackages, DocsInfoConfig, Environments, SupportedDocJson, WebsitePaths } from 'ts/types'; import { DocPackages, Environments, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate'; import { Translate } from 'ts/utils/translate';
@@ -21,7 +21,7 @@ const connectDocSections = {
installation: 'installation', installation: 'installation',
httpClient: 'httpClient', httpClient: 'httpClient',
webSocketOrderbookChannel: 'webSocketOrderbookChannel', webSocketOrderbookChannel: 'webSocketOrderbookChannel',
types: constants.TYPES_SECTION_NAME, types: docConstants.TYPES_SECTION_NAME,
}; };
const docsInfoConfig: DocsInfoConfig = { const docsInfoConfig: DocsInfoConfig = {

View File

@@ -1,19 +1,13 @@
import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
import { Networks } from '@0xproject/react-shared';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer'; import { State } from 'ts/redux/reducer';
import { import { DocPackages, SmartContractDocSections as Sections, WebsitePaths } from 'ts/types';
DocPackages,
DocsInfoConfig,
Networks,
SmartContractDocSections as Sections,
SupportedDocJson,
WebsitePaths,
} from 'ts/types';
import { Translate } from 'ts/utils/translate'; import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */ /* tslint:disable:no-var-requires */

View File

@@ -1,12 +1,12 @@
import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer'; import { State } from 'ts/redux/reducer';
import { DocPackages, DocsInfoConfig, Environments, SupportedDocJson, WebsitePaths } from 'ts/types'; import { DocPackages, Environments, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate'; import { Translate } from 'ts/utils/translate';
@@ -33,7 +33,7 @@ const zeroExJsDocSections = {
etherToken: 'etherToken', etherToken: 'etherToken',
proxy: 'proxy', proxy: 'proxy',
orderWatcher: 'orderWatcher', orderWatcher: 'orderWatcher',
types: constants.TYPES_SECTION_NAME, types: docConstants.TYPES_SECTION_NAME,
}; };
const docsInfoConfig: DocsInfoConfig = { const docsInfoConfig: DocsInfoConfig = {

View File

@@ -27,12 +27,6 @@ declare module 'find-versions' {
export = findVersions; export = findVersions;
} }
// compare-version declarations
declare function compareVersions(firstVersion: string, secondVersion: string): number;
declare module 'compare-versions' {
export = compareVersions;
}
// semver-sort declarations // semver-sort declarations
declare module 'semver-sort' { declare module 'semver-sort' {
const desc: (versions: string[]) => string[]; const desc: (versions: string[]) => string[];
@@ -115,12 +109,6 @@ declare module 'blockies' {
export = blockies; export = blockies;
} }
// is-mobile declarations
declare function isMobile(): boolean;
declare module 'is-mobile' {
export = isMobile;
}
// web3-provider-engine declarations // web3-provider-engine declarations
declare class Subprovider {} declare class Subprovider {}
declare module 'web3-provider-engine/subproviders/subprovider' { declare module 'web3-provider-engine/subproviders/subprovider' {

View File

@@ -1,3 +1,4 @@
import { DocAgnosticFormat, DocsInfo, Documentation, DoxityDocObj } from '@0xproject/react-docs';
import { MenuSubsectionsBySection } from '@0xproject/react-shared'; import { MenuSubsectionsBySection } from '@0xproject/react-shared';
import findVersions = require('find-versions'); import findVersions = require('find-versions');
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -5,10 +6,8 @@ import * as React from 'react';
import DocumentTitle = require('react-document-title'); import DocumentTitle = require('react-document-title');
import semverSort = require('semver-sort'); import semverSort = require('semver-sort');
import { TopBar } from 'ts/components/top_bar/top_bar'; import { TopBar } from 'ts/components/top_bar/top_bar';
import { DocsInfo } from 'ts/pages/documentation/docs_info';
import { Documentation } from 'ts/pages/documentation/documentation';
import { Dispatcher } from 'ts/redux/dispatcher'; import { Dispatcher } from 'ts/redux/dispatcher';
import { DocAgnosticFormat, DocPackages, DoxityDocObj, Environments } from 'ts/types'; import { DocPackages, Environments } from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { docUtils } from 'ts/utils/doc_utils'; import { docUtils } from 'ts/utils/doc_utils';

View File

@@ -225,11 +225,6 @@ export enum AlertTypes {
SUCCESS, SUCCESS,
} }
export enum EtherscanLinkSuffixes {
Address = 'address',
Tx = 'tx',
}
export enum BlockchainErrs { export enum BlockchainErrs {
AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK', AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK',
DisconnectedFromEthereumNode = 'DISCONNECTED_FROM_ETHEREUM_NODE', DisconnectedFromEthereumNode = 'DISCONNECTED_FROM_ETHEREUM_NODE',
@@ -243,24 +238,6 @@ export enum BlockchainCallErrs {
TokenAddressIsInvalid = 'TOKEN_ADDRESS_IS_INVALID', TokenAddressIsInvalid = 'TOKEN_ADDRESS_IS_INVALID',
} }
// Exception: We don't make the values uppercase because these KindString's need to
// match up those returned by TypeDoc
export enum KindString {
Constructor = 'Constructor',
Property = 'Property',
Method = 'Method',
Interface = 'Interface',
TypeAlias = 'Type alias',
Variable = 'Variable',
Function = 'Function',
Enumeration = 'Enumeration',
}
export interface EnumValue {
name: string;
defaultValue?: string;
}
export enum Environments { export enum Environments {
DEVELOPMENT, DEVELOPMENT,
PRODUCTION, PRODUCTION,
@@ -268,170 +245,6 @@ export enum Environments {
export type ContractInstance = any; // TODO: add type definition for Contract export type ContractInstance = any; // TODO: add type definition for Contract
export interface TypeDocType {
type: TypeDocTypes;
value: string;
name: string;
types: TypeDocType[];
typeArguments?: TypeDocType[];
declaration: TypeDocNode;
elementType?: TypeDocType;
}
export interface TypeDocFlags {
isStatic?: boolean;
isOptional?: boolean;
isPublic?: boolean;
}
export interface TypeDocGroup {
title: string;
children: number[];
}
export interface TypeDocNode {
id?: number;
name?: string;
kind?: string;
defaultValue?: string;
kindString?: string;
type?: TypeDocType;
fileName?: string;
line?: number;
comment?: TypeDocNode;
text?: string;
shortText?: string;
returns?: string;
declaration: TypeDocNode;
flags?: TypeDocFlags;
indexSignature?: TypeDocNode | TypeDocNode[]; // TypeDocNode in TypeDoc <V0.9.0, TypeDocNode[] in >V0.9.0
signatures?: TypeDocNode[];
parameters?: TypeDocNode[];
typeParameter?: TypeDocNode[];
sources?: TypeDocNode[];
children?: TypeDocNode[];
groups?: TypeDocGroup[];
}
export enum TypeDocTypes {
Intrinsic = 'intrinsic',
Reference = 'reference',
Array = 'array',
StringLiteral = 'stringLiteral',
Reflection = 'reflection',
Union = 'union',
TypeParameter = 'typeParameter',
Intersection = 'intersection',
Unknown = 'unknown',
}
export interface DocAgnosticFormat {
[sectionName: string]: DocSection;
}
export interface DocSection {
comment: string;
constructors: Array<TypescriptMethod | SolidityMethod>;
methods: Array<TypescriptMethod | SolidityMethod>;
properties: Property[];
types: CustomType[];
events?: Event[];
}
export interface Event {
name: string;
eventArgs: EventArg[];
}
export interface EventArg {
isIndexed: boolean;
name: string;
type: Type;
}
export interface Property {
name: string;
type: Type;
source?: Source;
comment?: string;
}
export interface BaseMethod {
isConstructor: boolean;
name: string;
returnComment?: string | undefined;
callPath: string;
parameters: Parameter[];
returnType: Type;
comment?: string;
}
export interface TypescriptMethod extends BaseMethod {
source?: Source;
isStatic?: boolean;
typeParameter?: TypeParameter;
}
export interface SolidityMethod extends BaseMethod {
isConstant?: boolean;
isPayable?: boolean;
}
export interface Source {
fileName: string;
line: number;
}
export interface Parameter {
name: string;
comment: string;
isOptional: boolean;
type: Type;
}
export interface TypeParameter {
name: string;
type: Type;
}
export interface Type {
name: string;
typeDocType: TypeDocTypes;
value?: string;
typeArguments?: Type[];
elementType?: ElementType;
types?: Type[];
method?: TypescriptMethod;
}
export interface ElementType {
name: string;
typeDocType: TypeDocTypes;
}
export interface IndexSignature {
keyName: string;
keyType: Type;
valueName: string;
}
export interface CustomType {
name: string;
kindString: string;
type?: Type;
method?: TypescriptMethod;
indexSignature?: IndexSignature;
defaultValue?: string;
comment?: string;
children?: CustomTypeChild[];
}
export interface CustomTypeChild {
name: string;
type?: Type;
defaultValue?: string;
}
export interface FAQQuestion { export interface FAQQuestion {
prompt: string; prompt: string;
answer: React.ReactNode; answer: React.ReactNode;
@@ -500,10 +313,6 @@ export interface BlogPost {
url: string; url: string;
} }
export interface TypeDefinitionByName {
[typeName: string]: CustomType;
}
export interface Article { export interface Article {
section: string; section: string;
title: string; title: string;
@@ -527,40 +336,6 @@ export enum TokenVisibility {
TRACKED = 'TRACKED', TRACKED = 'TRACKED',
} }
export interface DoxityDocObj {
[contractName: string]: DoxityContractObj;
}
export interface DoxityContractObj {
title: string;
fileName: string;
name: string;
abiDocs: DoxityAbiDoc[];
}
export interface DoxityAbiDoc {
constant: boolean;
inputs: DoxityInput[];
name: string;
outputs: DoxityOutput[];
payable: boolean;
type: string;
details?: string;
return?: string;
}
export interface DoxityOutput {
name: string;
type: string;
}
export interface DoxityInput {
name: string;
type: string;
description: string;
indexed?: boolean;
}
export interface VersionToFileName { export interface VersionToFileName {
[version: string]: string; [version: string]: string;
} }
@@ -570,29 +345,6 @@ export enum Docs {
SmartContracts, SmartContracts,
} }
export interface ContractAddresses {
[version: string]: {
[network: string]: AddressByContractName;
};
}
export interface AddressByContractName {
[contractName: string]: string;
}
export enum Networks {
Mainnet = 'Mainnet',
Kovan = 'Kovan',
Ropsten = 'Ropsten',
Rinkeby = 'Rinkeby',
}
export enum AbiTypes {
Constructor = 'constructor',
Function = 'function',
Event = 'event',
}
export enum WebsitePaths { export enum WebsitePaths {
Portal = '/portal', Portal = '/portal',
Wiki = '/wiki', Wiki = '/wiki',
@@ -605,49 +357,12 @@ export enum WebsitePaths {
Connect = '/docs/connect', Connect = '/docs/connect',
} }
export interface DocsMenu {
[sectionName: string]: string[];
}
export interface SectionsMap {
[sectionName: string]: string;
}
export enum DocPackages { export enum DocPackages {
Connect = 'CONNECT', Connect = 'CONNECT',
ZeroExJs = 'ZERO_EX_JS', ZeroExJs = 'ZERO_EX_JS',
SmartContracts = 'SMART_CONTRACTS', SmartContracts = 'SMART_CONTRACTS',
} }
export enum SupportedDocJson {
Doxity = 'DOXITY',
TypeDoc = 'TYPEDOC',
}
export interface ContractsByVersionByNetworkId {
[version: string]: {
[networkName: string]: {
[contractName: string]: string;
};
};
}
export interface DocsInfoConfig {
id: string;
type: SupportedDocJson;
displayName: string;
packageUrl: string;
menu: DocsMenu;
sections: SectionsMap;
sectionNameToMarkdown: { [sectionName: string]: string };
visibleConstructors: string[];
subPackageName?: string;
publicTypes?: string[];
sectionNameToModulePath?: { [sectionName: string]: string[] };
menuSubsectionToVersionWhenIntroduced?: { [sectionName: string]: string };
contractsByVersionByNetworkId?: ContractsByVersionByNetworkId;
}
export interface TimestampMsRange { export interface TimestampMsRange {
startTimestampMs: number; startTimestampMs: number;
endTimestampMs: number; endTimestampMs: number;

View File

@@ -1,5 +1,5 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { ContractAddresses, Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types'; import { Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types';
const BASE_URL = window.location.origin; const BASE_URL = window.location.origin;
const isDevelopment = _.includes( const isDevelopment = _.includes(

View File

@@ -1,5 +1,5 @@
import { Networks } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import { Networks } from 'ts/types';
export const constants = { export const constants = {
DECIMAL_PLACES_ETH: 18, DECIMAL_PLACES_ETH: 18,
@@ -21,18 +21,6 @@ export const constants = {
NETWORK_ID_MAINNET: 1, NETWORK_ID_MAINNET: 1,
NETWORK_ID_KOVAN: 42, NETWORK_ID_KOVAN: 42,
NETWORK_ID_TESTRPC: 50, NETWORK_ID_TESTRPC: 50,
NETWORK_NAME_BY_ID: {
1: Networks.Mainnet,
3: Networks.Ropsten,
4: Networks.Rinkeby,
42: Networks.Kovan,
} as { [symbol: number]: string },
NETWORK_ID_BY_NAME: {
[Networks.Mainnet]: 1,
[Networks.Ropsten]: 3,
[Networks.Rinkeby]: 4,
[Networks.Kovan]: 42,
} as { [networkName: string]: number },
NULL_ADDRESS: '0x0000000000000000000000000000000000000000', NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
PROVIDER_NAME_LEDGER: 'Ledger', PROVIDER_NAME_LEDGER: 'Ledger',
PROVIDER_NAME_METAMASK: 'Metamask', PROVIDER_NAME_METAMASK: 'Metamask',
@@ -45,7 +33,6 @@ export const constants = {
UNAVAILABLE_STATUS: 503, UNAVAILABLE_STATUS: 503,
TAKER_FEE: new BigNumber(0), TAKER_FEE: new BigNumber(0),
TESTNET_NAME: 'Kovan', TESTNET_NAME: 'Kovan',
TYPES_SECTION_NAME: 'types',
PROJECT_URL_ETHFINEX: 'https://www.bitfinex.com/ethfinex', PROJECT_URL_ETHFINEX: 'https://www.bitfinex.com/ethfinex',
PROJECT_URL_AMADEUS: 'http://amadeusrelay.org', PROJECT_URL_AMADEUS: 'http://amadeusrelay.org',
PROJECT_URL_DDEX: 'https://ddex.io', PROJECT_URL_DDEX: 'https://ddex.io',
@@ -70,7 +57,6 @@ export const constants = {
PROJECT_URL_OPEN_ANX: 'https://www.openanx.org', PROJECT_URL_OPEN_ANX: 'https://www.openanx.org',
PROJECT_URL_IDT: 'https://kinalpha.com', PROJECT_URL_IDT: 'https://kinalpha.com',
URL_ANGELLIST: 'https://angel.co/0xproject/jobs', URL_ANGELLIST: 'https://angel.co/0xproject/jobs',
URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
URL_BITLY_API: 'https://api-ssl.bitly.com', URL_BITLY_API: 'https://api-ssl.bitly.com',
URL_BLOG: 'https://blog.0xproject.com/latest', URL_BLOG: 'https://blog.0xproject.com/latest',
URL_DISCOURSE_FORUM: 'https://forum.0xproject.com', URL_DISCOURSE_FORUM: 'https://forum.0xproject.com',
@@ -85,11 +71,6 @@ export const constants = {
URL_REDDIT: 'https://reddit.com/r/0xproject', URL_REDDIT: 'https://reddit.com/r/0xproject',
URL_STANDARD_RELAYER_API_GITHUB: 'https://github.com/0xProject/standard-relayer-api/blob/master/README.md', URL_STANDARD_RELAYER_API_GITHUB: 'https://github.com/0xProject/standard-relayer-api/blob/master/README.md',
URL_TWITTER: 'https://twitter.com/0xproject', URL_TWITTER: 'https://twitter.com/0xproject',
URL_WEB3_DOCS: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
URL_WEB3_DECODED_LOG_ENTRY_EVENT:
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
URL_WEB3_LOG_ENTRY_EVENT: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
URL_WEB3_PROVIDER_DOCS: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
URL_WETH_IO: 'https://weth.io/', URL_WETH_IO: 'https://weth.io/',
URL_ZEROEX_CHAT: 'https://chat.0xproject.com', URL_ZEROEX_CHAT: 'https://chat.0xproject.com',
}; };

View File

@@ -1,6 +1,7 @@
import { DoxityDocObj, TypeDocNode } from '@0xproject/react-docs';
import findVersions = require('find-versions'); import findVersions = require('find-versions');
import * as _ from 'lodash'; import * as _ from 'lodash';
import { DoxityDocObj, S3FileObject, TypeDocNode, VersionToFileName } from 'ts/types'; import { S3FileObject, VersionToFileName } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
import convert = require('xml-js'); import convert = require('xml-js');

View File

@@ -1,19 +1,10 @@
import { ECSignature, ExchangeContractErrs, ZeroEx, ZeroExError } from '0x.js'; import { ECSignature, ExchangeContractErrs, ZeroEx, ZeroExError } from '0x.js';
import { constants as sharedConstants, EtherscanLinkSuffixes, Networks } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import deepEqual = require('deep-equal'); import deepEqual = require('deep-equal');
import isMobile = require('is-mobile');
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as moment from 'moment'; import * as moment from 'moment';
import { import { Order, ScreenWidths, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
EtherscanLinkSuffixes,
Networks,
Order,
ScreenWidths,
Side,
SideToAssetToken,
Token,
TokenByAddress,
} from 'ts/types';
import { configs } from 'ts/utils/configs'; import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import * as u2f from 'ts/vendor/u2f_api'; import * as u2f from 'ts/vendor/u2f_api';
@@ -139,18 +130,6 @@ export const utils = {
return ScreenWidths.Sm; return ScreenWidths.Sm;
} }
}, },
isUserOnMobile(): boolean {
const isUserOnMobile = isMobile();
return isUserOnMobile;
},
getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string {
const networkName = constants.NETWORK_NAME_BY_ID[networkId];
if (_.isUndefined(networkName)) {
return undefined;
}
const etherScanPrefix = networkName === Networks.Mainnet ? '' : `${networkName.toLowerCase()}.`;
return `https://${etherScanPrefix}etherscan.io/${suffix}/${addressOrTxHash}`;
},
async isU2FSupportedAsync(): Promise<boolean> { async isU2FSupportedAsync(): Promise<boolean> {
const w = window as any; const w = window as any;
return new Promise((resolve: (isSupported: boolean) => void) => { return new Promise((resolve: (isSupported: boolean) => void) => {
@@ -275,9 +254,9 @@ export const utils = {
isTestNetwork(networkId: number): boolean { isTestNetwork(networkId: number): boolean {
const isTestNetwork = _.includes( const isTestNetwork = _.includes(
[ [
constants.NETWORK_ID_BY_NAME[Networks.Kovan], sharedConstants.NETWORK_ID_BY_NAME[Networks.Kovan],
constants.NETWORK_ID_BY_NAME[Networks.Rinkeby], sharedConstants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
constants.NETWORK_ID_BY_NAME[Networks.Ropsten], sharedConstants.NETWORK_ID_BY_NAME[Networks.Ropsten],
], ],
networkId, networkId,
); );