Add Web3Wrapper docs to website
This commit is contained in:
17
packages/website/md/docs/web3_wrapper/installation.md
Normal file
17
packages/website/md/docs/web3_wrapper/installation.md
Normal file
@@ -0,0 +1,17 @@
|
||||
**Install**
|
||||
|
||||
```bash
|
||||
npm install @0xproject/web3-wrapper --save
|
||||
```
|
||||
|
||||
**Import**
|
||||
|
||||
```javascript
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```javascript
|
||||
var Web3Wrapper = require('@0xproject/web3-wrapper').Web3Wrapper;
|
||||
```
|
||||
1
packages/website/md/docs/web3_wrapper/introduction.md
Normal file
1
packages/website/md/docs/web3_wrapper/introduction.md
Normal file
@@ -0,0 +1 @@
|
||||
Welcome to the [Web3Wrapper](https://github.com/0xProject/0x-monorepo/tree/development/packages/web3-wrapper) documentation! Web3Wrapper is a convenience library that wraps Web3 v0.x, providing promise-based endpoints and a consistent API.
|
||||
@@ -61,6 +61,7 @@
|
||||
"CONNECT": "0x 连接",
|
||||
"WHITEPAPER": "白皮书",
|
||||
"WIKI": "维基",
|
||||
"WEB3_WRAPPER": "Web3Wrapper",
|
||||
"FAQ": "FAQ",
|
||||
"SMART_CONTRACTS": "0x 智能合约",
|
||||
"STANDARD_RELAYER_API": "中继方标准API",
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
"CONNECT": "0x Connect",
|
||||
"WHITEPAPER": "whitepaper",
|
||||
"WIKI": "wiki",
|
||||
"WEB3_WRAPPER": "Web3Wrapper",
|
||||
"FAQ": "FAQ",
|
||||
"SMART_CONTRACTS": "0x smart contracts",
|
||||
"STANDARD_RELAYER_API": "standard relayer API",
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
"CONNECT": "0x Connect",
|
||||
"WHITEPAPER": "백서",
|
||||
"WIKI": "위키",
|
||||
"WEB3_WRAPPER": "Web3Wrapper",
|
||||
"FAQ": "FAQ",
|
||||
"SMART_CONTRACTS": "0x 스마트 계약",
|
||||
"STANDARD_RELAYER_API": "Standard Relayer API",
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
"CONNECT": "0x Connect",
|
||||
"WHITEPAPER": "Whitepaper",
|
||||
"WIKI": "Вики",
|
||||
"WEB3_WRAPPER": "Web3Wrapper",
|
||||
"FAQ": "Документация",
|
||||
"SMART_CONTRACTS": "0x Смарт-контракты ",
|
||||
"STANDARD_RELAYER_API": "standard relayer API",
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
"CONNECT": "0x Connect",
|
||||
"WHITEPAPER": "documento técnico",
|
||||
"WIKI": "wiki",
|
||||
"WEB3_WRAPPER": "Web3Wrapper",
|
||||
"FAQ": "preguntas frecuentes",
|
||||
"SMART_CONTRACTS": "0x contratos inteligentes",
|
||||
"STANDARD_RELAYER_API": "API de transmisión estándar",
|
||||
|
||||
@@ -6,6 +6,7 @@ const SHOW_DURATION_MS = 4000;
|
||||
|
||||
const titleToIcon: { [title: string]: string } = {
|
||||
'0x.js': 'zeroExJs.png',
|
||||
Web3Wrapper: 'zeroExJs.png',
|
||||
'0x Connect': 'connect.png',
|
||||
'0x Smart Contracts': 'contracts.png',
|
||||
Wiki: 'wiki.png',
|
||||
|
||||
@@ -139,6 +139,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
primaryText={this.props.translate.get(Key.Whitepaper, Deco.CapWords)}
|
||||
/>
|
||||
</a>,
|
||||
<Link key="subMenuItem-web3Wrapper" to={WebsitePaths.Web3Wrapper} className="text-decoration-none">
|
||||
<MenuItem
|
||||
style={{ fontSize: styles.menuItem.fontSize }}
|
||||
primaryText={this.props.translate.get(Key.Web3Wrapper, Deco.CapWords)}
|
||||
/>
|
||||
</Link>,
|
||||
];
|
||||
const bottomBorderStyle = this._shouldDisplayBottomBar() ? styles.bottomBar : {};
|
||||
const fullWidthClasses = isFullWidthPage ? 'pr4' : '';
|
||||
@@ -277,6 +283,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
</MenuItem>
|
||||
</Link>
|
||||
)}
|
||||
{!this._isViewingWeb3WrapperDocs() && (
|
||||
<Link to={WebsitePaths.Web3Wrapper} className="text-decoration-none">
|
||||
<MenuItem className="py2">
|
||||
{this.props.translate.get(Key.Web3Wrapper, 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">
|
||||
@@ -304,7 +318,10 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
}
|
||||
private _renderDocsMenu(): React.ReactNode {
|
||||
if (
|
||||
(!this._isViewing0xjsDocs() && !this._isViewingSmartContractsDocs() && !this._isViewingConnectDocs()) ||
|
||||
(!this._isViewing0xjsDocs() &&
|
||||
!this._isViewingSmartContractsDocs() &&
|
||||
!this._isViewingWeb3WrapperDocs() &&
|
||||
!this._isViewingConnectDocs()) ||
|
||||
_.isUndefined(this.props.menu)
|
||||
) {
|
||||
return undefined;
|
||||
@@ -392,6 +409,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
private _isViewingSmartContractsDocs() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.SmartContracts);
|
||||
}
|
||||
private _isViewingWeb3WrapperDocs() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.Web3Wrapper);
|
||||
}
|
||||
private _isViewingWiki() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.Wiki);
|
||||
}
|
||||
@@ -401,6 +421,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
this._isViewing0xjsDocs() ||
|
||||
this._isViewingFAQ() ||
|
||||
this._isViewingSmartContractsDocs() ||
|
||||
this._isViewingWeb3WrapperDocs() ||
|
||||
this._isViewingConnectDocs()
|
||||
);
|
||||
}
|
||||
|
||||
103
packages/website/ts/containers/web3_wrapper_documentation.ts
Normal file
103
packages/website/ts/containers/web3_wrapper_documentation.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
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/web3_wrapper/introduction');
|
||||
const InstallationMarkdown = require('md/docs/web3_wrapper/installation');
|
||||
/* tslint:enable:no-var-requires */
|
||||
|
||||
const docSections = {
|
||||
introduction: 'introduction',
|
||||
installation: 'installation',
|
||||
web3Wrapper: 'web3Wrapper',
|
||||
types: docConstants.TYPES_SECTION_NAME,
|
||||
};
|
||||
|
||||
const docsInfoConfig: DocsInfoConfig = {
|
||||
id: DocPackages.Web3Wrapper,
|
||||
type: SupportedDocJson.TypeDoc,
|
||||
displayName: 'Web3Wrapper',
|
||||
packageUrl: 'https://github.com/0xProject/0x-monorepo',
|
||||
menu: {
|
||||
introduction: [docSections.introduction],
|
||||
install: [docSections.installation],
|
||||
web3Wrapper: [docSections.web3Wrapper],
|
||||
types: [docSections.types],
|
||||
},
|
||||
sectionNameToMarkdown: {
|
||||
[docSections.introduction]: IntroMarkdown,
|
||||
[docSections.installation]: InstallationMarkdown,
|
||||
},
|
||||
sectionNameToModulePath: {
|
||||
[docSections.web3Wrapper]: ['"web3-wrapper/src/index"'],
|
||||
[docSections.types]: ['"types/src/index"'],
|
||||
},
|
||||
menuSubsectionToVersionWhenIntroduced: {},
|
||||
sections: docSections,
|
||||
visibleConstructors: [docSections.web3Wrapper],
|
||||
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: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
|
||||
typeNameToExternalLink: {
|
||||
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
|
||||
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
|
||||
BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
|
||||
LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
|
||||
CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
|
||||
BlockWithoutTransactionData:
|
||||
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
|
||||
LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
|
||||
FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
|
||||
['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
|
||||
['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
|
||||
},
|
||||
typeNameToPrefix: {
|
||||
Provider: 'Web3',
|
||||
CallData: 'Web3',
|
||||
BlockWithoutTransactionData: 'Web3',
|
||||
LogEntry: 'Web3',
|
||||
FilterObject: 'Web3',
|
||||
},
|
||||
typeNameToDocSection: {
|
||||
Web3Wrapper: docSections.web3Wrapper,
|
||||
},
|
||||
},
|
||||
};
|
||||
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,
|
||||
);
|
||||
@@ -45,6 +45,9 @@ const LazySmartContractsDocumentation = createLazyComponent('Documentation', asy
|
||||
const LazyConnectDocumentation = createLazyComponent('Documentation', async () =>
|
||||
System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/connect_documentation'),
|
||||
);
|
||||
const LazyWeb3WrapperDocumentation = createLazyComponent('Documentation', async () =>
|
||||
System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/web3_wrapper_documentation'),
|
||||
);
|
||||
|
||||
analytics.init();
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
@@ -65,6 +68,10 @@ render(
|
||||
<Route path={`${WebsitePaths.Wiki}`} component={Wiki as any} />
|
||||
<Route path={`${WebsitePaths.ZeroExJs}/:version?`} component={LazyZeroExJSDocumentation} />
|
||||
<Route path={`${WebsitePaths.Connect}/:version?`} component={LazyConnectDocumentation} />
|
||||
<Route
|
||||
path={`${WebsitePaths.Web3Wrapper}/:version?`}
|
||||
component={LazyWeb3WrapperDocumentation}
|
||||
/>
|
||||
<Route
|
||||
path={`${WebsitePaths.SmartContracts}/:version?`}
|
||||
component={LazySmartContractsDocumentation}
|
||||
|
||||
@@ -22,12 +22,14 @@ const docIdToS3BucketName: { [id: string]: string } = {
|
||||
[DocPackages.ZeroExJs]: isDevelopment ? 'staging-0xjs-docs-jsons' : '0xjs-docs-jsons',
|
||||
[DocPackages.SmartContracts]: 'smart-contracts-docs-json',
|
||||
[DocPackages.Connect]: isDevelopment ? 'staging-connect-docs-jsons' : 'connect-docs-jsons',
|
||||
[DocPackages.Web3Wrapper]: isDevelopment ? 'staging-web3-wrapper-docs-json' : 'web3-wrapper-docs-json',
|
||||
};
|
||||
|
||||
const docIdToSubpackageName: { [id: string]: string } = {
|
||||
[DocPackages.ZeroExJs]: '0x.js',
|
||||
[DocPackages.Connect]: 'connect',
|
||||
[DocPackages.SmartContracts]: 'contracts',
|
||||
[DocPackages.Web3Wrapper]: 'web3-wrapper',
|
||||
};
|
||||
|
||||
export interface DocPageProps {
|
||||
|
||||
@@ -355,12 +355,14 @@ export enum WebsitePaths {
|
||||
Whitepaper = '/pdfs/0x_white_paper.pdf',
|
||||
SmartContracts = '/docs/contracts',
|
||||
Connect = '/docs/connect',
|
||||
Web3Wrapper = '/docs/web3_wrapper',
|
||||
}
|
||||
|
||||
export enum DocPackages {
|
||||
Connect = 'CONNECT',
|
||||
ZeroExJs = 'ZERO_EX_JS',
|
||||
SmartContracts = 'SMART_CONTRACTS',
|
||||
Web3Wrapper = 'WEB3_WRAPPER',
|
||||
}
|
||||
|
||||
export interface TimestampMsRange {
|
||||
@@ -447,6 +449,7 @@ export enum Key {
|
||||
Connect = 'CONNECT',
|
||||
Whitepaper = 'WHITEPAPER',
|
||||
Wiki = 'WIKI',
|
||||
Web3Wrapper = 'WEB3_WRAPPER',
|
||||
And = 'AND',
|
||||
Faq = 'FAQ',
|
||||
SmartContracts = 'SMART_CONTRACTS',
|
||||
|
||||
Reference in New Issue
Block a user