From 7ec232a4707b7816bbebd8267ce7b0f324e7b71a Mon Sep 17 00:00:00 2001 From: David Sun Date: Mon, 29 Jul 2019 18:42:24 -0700 Subject: [PATCH] bumped version and added to docs --- packages/asset-swapper/src/index.ts | 1 + .../forwarder_swap_quote_consumer.ts | 2 +- .../quote_consumers/swap_quote_consumer.ts | 15 +++++++ .../monorepo-scripts/src/doc_gen_configs.ts | 3 ++ .../md/docs/asset_swapper/installation.md | 18 ++++++++ .../md/docs/asset_swapper/introduction.md | 1 + .../containers/asset_swapper_documentation.ts | 42 +++++++++++++++++++ packages/website/ts/index.tsx | 7 ++++ .../ts/pages/documentation/doc_page.tsx | 1 + .../ts/pages/documentation/docs_home.tsx | 8 ++++ packages/website/ts/types.ts | 3 ++ 11 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 packages/website/md/docs/asset_swapper/installation.md create mode 100644 packages/website/md/docs/asset_swapper/introduction.md create mode 100644 packages/website/ts/containers/asset_swapper_documentation.ts diff --git a/packages/asset-swapper/src/index.ts b/packages/asset-swapper/src/index.ts index 8b0006c110..64c1d6e383 100644 --- a/packages/asset-swapper/src/index.ts +++ b/packages/asset-swapper/src/index.ts @@ -16,6 +16,7 @@ export { DataItem, StateMutability, EventParameter, + TupleDataItem, ConstructorStateMutability, } from 'ethereum-types'; diff --git a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts index 516b78914a..fd89136938 100644 --- a/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts +++ b/packages/asset-swapper/src/quote_consumers/forwarder_swap_quote_consumer.ts @@ -77,7 +77,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase, @@ -53,6 +58,11 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase, @@ -62,6 +72,11 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase, diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts index c209d1f588..fa510b56e5 100644 --- a/packages/monorepo-scripts/src/doc_gen_configs.ts +++ b/packages/monorepo-scripts/src/doc_gen_configs.ts @@ -25,6 +25,9 @@ export const docGenConfigs: DocGenConfigs = { 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8', 'lightwallet.keystore': 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36', + // HACK: Asset-swapper specifies marketSell and marketBuy quotes with a descriminant MarketOperation Type to ignore the error, linking Buy and Sell to MarketOperation + Buy: 'https://github.com/0xProject/0x-monorepo/blob/development/packages/types/src/index.ts', + Sell: 'https://github.com/0xProject/0x-monorepo/blob/development/packages/types/src/index.ts', }, // If a 0x package re-exports an external package, we should add a link to it's exported items here EXTERNAL_EXPORT_TO_LINK: { diff --git a/packages/website/md/docs/asset_swapper/installation.md b/packages/website/md/docs/asset_swapper/installation.md new file mode 100644 index 0000000000..113590ac84 --- /dev/null +++ b/packages/website/md/docs/asset_swapper/installation.md @@ -0,0 +1,18 @@ +#### Install + +```bash +yarn add @0x/asset-swapper +``` + +#### Import + +```javascript +import { SwapQuoter, SwapQuoteConsumer } from '@0x/asset-swapper'; +``` + +or + +```javascript +var SwapQuoter = require('@0x/asset-swapper').SwapQuoter; +var SwapQuoteConsumer = require('@0x/asset-swapper').SwapQuoteConsumer; +``` diff --git a/packages/website/md/docs/asset_swapper/introduction.md b/packages/website/md/docs/asset_swapper/introduction.md new file mode 100644 index 0000000000..a696a68241 --- /dev/null +++ b/packages/website/md/docs/asset_swapper/introduction.md @@ -0,0 +1 @@ +Welcome to the [asset-swapper](https://github.com/0xProject/0x-monorepo/tree/development/packages/asset-swapper) documentation! Asset-swapper is a library that provides an easy way to swap any ERC asset for another ERC asset for smart contract integrations, leveraging 0x liquidity. diff --git a/packages/website/ts/containers/asset_swapper_documentation.ts b/packages/website/ts/containers/asset_swapper_documentation.ts new file mode 100644 index 0000000000..f632bb2ab9 --- /dev/null +++ b/packages/website/ts/containers/asset_swapper_documentation.ts @@ -0,0 +1,42 @@ +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/docs/asset_swapper/introduction'); +const InstallationMarkdown = require('md/docs/asset_swapper/installation'); +/* tslint:enable:no-var-requires */ + +const markdownSections = { + introduction: 'introduction', + installation: 'installation', +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.AssetSwapper, + packageName: '@0x/asset-swapper', + type: SupportedDocJson.TypeDoc, + displayName: 'AssetSwapper', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/asset-swapper', + markdownMenu: { + introduction: [markdownSections.introduction], + install: [markdownSections.installation], + }, + sectionNameToMarkdownByVersion: { + '0.0.1': { + [markdownSections.introduction]: IntroMarkdown, + [markdownSections.installation]: InstallationMarkdown, + }, + }, + markdownSections, +}; +const mapStateToProps = getMapStateToProps(docsInfoConfig); + +export const Documentation: React.ComponentClass = connect( + mapStateToProps, + mapDispatchToProps, +)(DocPageComponent); diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index dfe7bac067..6b45ee9ae2 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -95,6 +95,9 @@ const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', asyn const LazyAssetBuyerDocumentation = createLazyComponent('Documentation', async () => import(/* webpackChunkName: "assetBuyerDocs" */ 'ts/containers/asset_buyer_documentation'), ); +const LazyAssetSwapperDocumentation = createLazyComponent('Documentation', async () => + import(/* webpackChunkName: "assetSwapperDocs" */ 'ts/containers/asset_swapper_documentation'), +); const DOCUMENT_TITLE = '0x: The Protocol for Trading Tokens'; const DOCUMENT_DESCRIPTION = 'An Open Protocol For Decentralized Exchange On The Ethereum Blockchain'; @@ -204,6 +207,10 @@ render( path={`${WebsitePaths.AssetBuyer}/:version?`} component={LazyAssetBuyerDocumentation} /> + {/* Legacy endpoints */} = { to: WebsitePaths.AssetBuyer, }, }, + { + description: + 'Coonvenience package for discovering and performing swaps for any ERC20 Assets', + link: { + title: '@0x/asset-swapper', + to: WebsitePaths.AssetSwapper, + }, + }, ], [Categories.ZeroExProtocolPython]: [ { diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index ffe1478309..b88a37d1ba 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -473,6 +473,7 @@ export enum WebsitePaths { OrderUtils = '/docs/order-utils', EthereumTypes = '/docs/ethereum-types', AssetBuyer = '/docs/asset-buyer', + AssetSwapper = '/docs/asset-swapper', Migrations = '/docs/migrations', Careers = '/careers', Credits = '/credits', @@ -497,6 +498,7 @@ export enum DocPackages { ContractWrappers = 'CONTRACT_WRAPPERS', OrderWatcher = 'ORDER_WATCHER', AssetBuyer = 'ASSET_BUYER', + AssetSwapper = 'ASSET_SWAPPER', Migrations = 'MIGRATIONS', } @@ -560,6 +562,7 @@ export enum Key { ContractWrappers = 'CONTRACT_WRAPPERS', OrderWatcher = 'ORDER_WATCHER', AssetBuyer = 'ASSET_BUYER', + AssetSwapper = 'ASSET_SWAPPER', Blog = 'BLOG', Forum = 'FORUM', Connect = 'CONNECT',