aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
commite0d5b9daf84cba31bbbcd2cfbe1f64623eace61a (patch)
tree84929c7ae4e95896dacfb69517aaaba97ec8ad85 /packages/website/ts
parenta97d77064aacda3de74b04894f110b05298c5ca8 (diff)
parent785b9811f30869f01242ce9ff81c282bf7f5352f (diff)
downloaddexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.gz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.bz2
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.lz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.xz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.zst
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.zip
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/improve-linting
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/components/top_bar/top_bar.tsx17
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx23
-rw-r--r--packages/website/ts/containers/ethereum_types_documentation.ts124
-rw-r--r--packages/website/ts/index.tsx7
-rw-r--r--packages/website/ts/pages/documentation/doc_page.tsx1
-rw-r--r--packages/website/ts/types.ts3
-rw-r--r--packages/website/ts/utils/doc_utils.ts2
7 files changed, 167 insertions, 10 deletions
diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx
index 8fcf5bbae..05cc6e3ad 100644
--- a/packages/website/ts/components/top_bar/top_bar.tsx
+++ b/packages/website/ts/components/top_bar/top_bar.tsx
@@ -162,6 +162,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
primaryText={this.props.translate.get(Key.SolCov, Deco.CapWords)}
/>
</Link>,
+ <Link key="subMenuItem-ethereum-types" to={WebsitePaths.EthereumTypes} className="text-decoration-none">
+ <MenuItem
+ style={{ fontSize: styles.menuItem.fontSize }}
+ primaryText={this.props.translate.get(Key.EthereumTypes, Deco.CapWords)}
+ />
+ </Link>,
<a
key="subMenuItem-whitePaper"
target="_blank"
@@ -376,6 +382,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</MenuItem>
</Link>
)}
+ {!this._isViewingEthereumTypesDocs() && (
+ <Link to={WebsitePaths.EthereumTypes} className="text-decoration-none">
+ <MenuItem className="py2">
+ {this.props.translate.get(Key.EthereumTypes, Deco.Cap)}{' '}
+ {this.props.translate.get(Key.Docs, Deco.Cap)}
+ </MenuItem>
+ </Link>
+ )}
{!this._isViewingPortal() && (
<Link to={`${WebsitePaths.Portal}`} className="text-decoration-none">
<MenuItem className="py2">
@@ -502,6 +516,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
private _isViewingSubprovidersDocs(): boolean {
return _.includes(this.props.location.pathname, WebsitePaths.Subproviders);
}
+ private _isViewingEthereumTypesDocs(): boolean {
+ return _.includes(this.props.location.pathname, WebsitePaths.EthereumTypes);
+ }
private _isViewingWiki(): boolean {
return _.includes(this.props.location.pathname, WebsitePaths.Wiki);
}
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 4f099d636..977902103 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -124,7 +124,7 @@ const styles: Styles = {
const ETHER_ICON_PATH = '/images/ether.png';
const ICON_DIMENSION = 28;
-const TOKEN_AMOUNT_DISPLAY_PRECISION = 3;
+const TOKEN_AMOUNT_DISPLAY_PRECISION = 5;
const BODY_ITEM_KEY = 'BODY';
const HEADER_ITEM_KEY = 'HEADER';
const FOOTER_ITEM_KEY = 'FOOTER';
@@ -434,14 +434,19 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
symbol: string,
isLoading: boolean = false,
): React.ReactNode {
- const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
- const formattedAmount = unitAmount.toPrecision(TOKEN_AMOUNT_DISPLAY_PRECISION);
- const result = `${formattedAmount} ${symbol}`;
- return (
- <PlaceHolder hideChildren={isLoading}>
- <div style={styles.amountLabel}>{result}</div>
- </PlaceHolder>
- );
+ if (isLoading) {
+ return (
+ <PlaceHolder hideChildren={isLoading}>
+ <div style={styles.amountLabel}>0.00 XXX</div>
+ </PlaceHolder>
+ );
+ } else {
+ const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
+ const precision = Math.min(TOKEN_AMOUNT_DISPLAY_PRECISION, unitAmount.decimalPlaces());
+ const formattedAmount = unitAmount.toFixed(precision);
+ const result = `${formattedAmount} ${symbol}`;
+ return <div style={styles.amountLabel}>{result}</div>;
+ }
}
private _renderValue(
amount: BigNumber,
diff --git a/packages/website/ts/containers/ethereum_types_documentation.ts b/packages/website/ts/containers/ethereum_types_documentation.ts
new file mode 100644
index 000000000..28d3d92dc
--- /dev/null
+++ b/packages/website/ts/containers/ethereum_types_documentation.ts
@@ -0,0 +1,124 @@
+import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
+import { Dispatcher } from 'ts/redux/dispatcher';
+import { State } from 'ts/redux/reducer';
+import { DocPackages, Environments, WebsitePaths } from 'ts/types';
+import { configs } from 'ts/utils/configs';
+import { constants } from 'ts/utils/constants';
+import { Translate } from 'ts/utils/translate';
+
+/* tslint:disable:no-var-requires */
+const IntroMarkdown = require('md/docs/ethereum_types/introduction');
+const InstallationMarkdown = require('md/docs/ethereum_types/installation');
+/* tslint:enable:no-var-requires */
+
+const docSections = {
+ introduction: 'introduction',
+ installation: 'installation',
+ types: docConstants.TYPES_SECTION_NAME,
+};
+
+const docsInfoConfig: DocsInfoConfig = {
+ id: DocPackages.EthereumTypes,
+ type: SupportedDocJson.TypeDoc,
+ displayName: 'Ethereum Types',
+ packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/ethereum-types',
+ menu: {
+ introduction: [docSections.introduction],
+ install: [docSections.installation],
+ types: [docSections.types],
+ },
+ sectionNameToMarkdown: {
+ [docSections.introduction]: IntroMarkdown,
+ [docSections.installation]: InstallationMarkdown,
+ },
+ sectionNameToModulePath: {
+ [docSections.types]: ['"index"'],
+ },
+ visibleConstructors: [],
+ menuSubsectionToVersionWhenIntroduced: {},
+ sections: docSections,
+ typeConfigs: {
+ // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
+ // currently no way to extract the re-exported types from index.ts via TypeDoc :(
+ publicTypes: [
+ 'Provider',
+ 'JSONRPCErrorCallback',
+ 'Provider',
+ 'ContractAbi',
+ 'AbiDefinition',
+ 'FunctionAbi',
+ 'ConstructorStateMutability',
+ 'StateMutability',
+ 'MethodAbi',
+ 'ConstructorAbi',
+ 'FallbackAbi',
+ 'EventParameter',
+ 'EventAbi',
+ 'DataItem',
+ 'OpCode',
+ // 'StructLog', // TODO: This type breaks the docs so we don't render it for now
+ 'TransactionTrace',
+ 'Unit',
+ 'JSONRPCRequestPayload',
+ 'JSONRPCResponsePayload',
+ 'BlockWithoutTransactionData',
+ 'BlockWithTransactionData',
+ 'Transaction',
+ 'TxData',
+ 'CallData',
+ 'FilterObject',
+ 'LogTopic',
+ 'DecodedLogEntry',
+ 'DecodedLogEntryEvent',
+ 'LogEntryEvent',
+ 'LogEntry',
+ 'TxDataPayable',
+ 'TransactionReceipt',
+ 'AbiType',
+ 'ContractEventArg',
+ 'DecodedLogArgs',
+ 'LogWithDecodedArgs',
+ 'RawLog',
+ 'BlockParamLiteral',
+ 'BlockParam',
+ 'RawLogEntry',
+ 'SolidityTypes',
+ 'TransactionReceiptWithDecodedLogs',
+ ],
+ typeNameToExternalLink: {
+ BigNumber: constants.URL_BIGNUMBERJS_GITHUB,
+ },
+ },
+};
+const docsInfo = new DocsInfo(docsInfoConfig);
+
+interface ConnectedState {
+ docsVersion: string;
+ availableDocVersions: string[];
+ docsInfo: DocsInfo;
+ translate: Translate;
+}
+
+interface ConnectedDispatch {
+ dispatcher: Dispatcher;
+}
+
+const mapStateToProps = (state: State, ownProps: DocPageProps): ConnectedState => ({
+ docsVersion: state.docsVersion,
+ availableDocVersions: state.availableDocVersions,
+ translate: state.translate,
+ docsInfo,
+});
+
+const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
+ dispatcher: new Dispatcher(dispatch),
+});
+
+export const Documentation: React.ComponentClass<DocPageProps> = connect(mapStateToProps, mapDispatchToProps)(
+ DocPageComponent,
+);
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index a6bfe7dd2..719604c02 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -69,6 +69,9 @@ const LazySubprovidersDocumentation = createLazyComponent('Documentation', async
const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async () =>
System.import<any>(/* webpackChunkName: "orderUtilsDocs" */ 'ts/containers/order_utils_documentation'),
);
+const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', async () =>
+ System.import<any>(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'),
+);
analytics.init();
// tslint:disable-next-line:no-floating-promises
@@ -116,6 +119,10 @@ render(
path={`${WebsitePaths.SmartContracts}/:version?`}
component={LazySmartContractsDocumentation}
/>
+ <Route
+ path={`${WebsitePaths.EthereumTypes}/:version?`}
+ component={LazyEthereumTypesDocumentation}
+ />
{/* Legacy endpoints */}
<Route
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx
index 4dffa13f1..8159bbd49 100644
--- a/packages/website/ts/pages/documentation/doc_page.tsx
+++ b/packages/website/ts/pages/documentation/doc_page.tsx
@@ -33,6 +33,7 @@ const docIdToSubpackageName: { [id: string]: string } = {
[DocPackages.SolCov]: 'sol-cov',
[DocPackages.Subproviders]: 'subproviders',
[DocPackages.OrderUtils]: 'order-utils',
+ [DocPackages.EthereumTypes]: 'ethereum-types',
};
export interface DocPageProps {
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 5481e90be..15444e517 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -369,6 +369,7 @@ export enum WebsitePaths {
SolCov = '/docs/sol-cov',
Subproviders = '/docs/subproviders',
OrderUtils = '/docs/order-utils',
+ EthereumTypes = '/docs/ethereum-types',
Jobs = '/jobs',
}
@@ -382,6 +383,7 @@ export enum DocPackages {
SolCov = 'SOL_COV',
Subproviders = 'SUBPROVIDERS',
OrderUtils = 'ORDER_UTILS',
+ EthereumTypes = 'ETHEREUM_TYPES',
}
export enum Key {
@@ -433,6 +435,7 @@ export enum Key {
SolCompiler = 'SOL_COMPILER',
JsonSchemas = 'JSON_SCHEMAS',
SolCov = 'SOL_COV',
+ EthereumTypes = 'ETHEREUM_TYPES',
Subproviders = 'SUBPROVIDERS',
Blog = 'BLOG',
Forum = 'FORUM',
diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts
index 019a29f5c..7768835fb 100644
--- a/packages/website/ts/utils/doc_utils.ts
+++ b/packages/website/ts/utils/doc_utils.ts
@@ -7,7 +7,7 @@ import convert = require('xml-js');
export const docUtils = {
async getVersionToFilePathAsync(s3DocJsonRoot: string, folderName: string): Promise<VersionToFilePath> {
- const versionFilePaths = await this.getVersionFileNamesAsync(s3DocJsonRoot, folderName);
+ const versionFilePaths = await docUtils.getVersionFileNamesAsync(s3DocJsonRoot, folderName);
const versionToFilePath: VersionToFilePath = {};
_.each(versionFilePaths, filePath => {
const [version] = findVersions(filePath);