aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-02-28 06:29:22 +0800
committerFabio Berger <me@fabioberger.com>2018-02-28 06:29:22 +0800
commit97fcfb7f6c62aefa3f3a736f7783529d4e3e0018 (patch)
tree8b7d202ecceb6f467c94c7a4ce95049b5700b88f /packages/website/ts/utils
parentecba95250d0bfc5b4ab0950ef490a4f262672e6c (diff)
downloaddexon-0x-contracts-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.gz
dexon-0x-contracts-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.zst
dexon-0x-contracts-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.zip
Move more configs into docsInfo and remove logic that does not belong there elsewhere
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/configs.ts37
-rw-r--r--packages/website/ts/utils/typedoc_utils.ts68
2 files changed, 28 insertions, 77 deletions
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index 8e359f8bd..7e9ba69de 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -1,12 +1,5 @@
import * as _ from 'lodash';
-import {
- ContractAddresses,
- Environments,
- Networks,
- OutdatedWrappedEtherByNetworkId,
- PublicNodeUrlsByNetworkId,
- SmartContractDocSections,
-} from 'ts/types';
+import { ContractAddresses, Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types';
const BASE_URL = window.location.origin;
const isDevelopment = _.includes(
@@ -19,34 +12,6 @@ export const configs = {
BACKEND_BASE_URL: 'https://website-api.0xproject.com',
BASE_URL,
BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208',
- CONTRACT_ADDRESS: {
- '1.0.0': {
- [Networks.Mainnet]: {
- [SmartContractDocSections.Exchange]: '0x12459c951127e0c374ff9105dda097662a027093',
- [SmartContractDocSections.TokenTransferProxy]: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
- [SmartContractDocSections.ZRXToken]: '0xe41d2489571d322189246dafa5ebde1f4699f498',
- [SmartContractDocSections.TokenRegistry]: '0x926a74c5c36adf004c87399e65f75628b0f98d2c',
- },
- [Networks.Ropsten]: {
- [SmartContractDocSections.Exchange]: '0x479cc461fecd078f766ecc58533d6f69580cf3ac',
- [SmartContractDocSections.TokenTransferProxy]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
- [SmartContractDocSections.ZRXToken]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
- [SmartContractDocSections.TokenRegistry]: '0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed',
- },
- [Networks.Kovan]: {
- [SmartContractDocSections.Exchange]: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
- [SmartContractDocSections.TokenTransferProxy]: '0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4',
- [SmartContractDocSections.ZRXToken]: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
- [SmartContractDocSections.TokenRegistry]: '0xf18e504561f4347bea557f3d4558f559dddbae7f',
- },
- [Networks.Rinkeby]: {
- [SmartContractDocSections.Exchange]: '0x1d16ef40fac01cec8adac2ac49427b9384192c05',
- [SmartContractDocSections.TokenTransferProxy]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
- [SmartContractDocSections.ZRXToken]: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8',
- [SmartContractDocSections.TokenRegistry]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
- },
- },
- } as ContractAddresses,
DEFAULT_DERIVATION_PATH: `44'/60'/0'`,
// WARNING: ZRX & WETH MUST always be default trackedTokens
DEFAULT_TRACKED_TOKEN_SYMBOLS: ['WETH', 'ZRX'],
diff --git a/packages/website/ts/utils/typedoc_utils.ts b/packages/website/ts/utils/typedoc_utils.ts
index 11ec8da58..992475911 100644
--- a/packages/website/ts/utils/typedoc_utils.ts
+++ b/packages/website/ts/utils/typedoc_utils.ts
@@ -4,6 +4,7 @@ import {
CustomType,
CustomTypeChild,
DocAgnosticFormat,
+ DocPackages,
DocSection,
IndexSignature,
KindString,
@@ -108,7 +109,7 @@ export const typeDocUtils = {
isConstructor,
docsInfo.sections,
sectionName,
- docsInfo.subPackageName,
+ docsInfo.id,
);
docSection.constructors.push(constructor);
break;
@@ -121,7 +122,7 @@ export const typeDocUtils = {
isConstructor,
docsInfo.sections,
sectionName,
- docsInfo.subPackageName,
+ docsInfo.id,
);
docSection.methods.push(method);
}
@@ -133,7 +134,7 @@ export const typeDocUtils = {
entity,
docsInfo.sections,
sectionName,
- docsInfo.subPackageName,
+ docsInfo.id,
);
docSection.properties.push(property);
}
@@ -149,7 +150,7 @@ export const typeDocUtils = {
entity,
docsInfo.sections,
sectionName,
- docsInfo.subPackageName,
+ docsInfo.id,
);
docSection.types.push(customType);
}
@@ -161,21 +162,16 @@ export const typeDocUtils = {
});
return docSection;
},
- _convertCustomType(
- entity: TypeDocNode,
- sections: SectionsMap,
- sectionName: string,
- subPackageName: string,
- ): CustomType {
+ _convertCustomType(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): CustomType {
const typeIfExists = !_.isUndefined(entity.type)
- ? typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName)
+ ? typeDocUtils._convertType(entity.type, sections, sectionName, docId)
: undefined;
const isConstructor = false;
const methodIfExists = !_.isUndefined(entity.declaration)
- ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName)
+ ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, docId)
: undefined;
const indexSignatureIfExists = !_.isUndefined(entity.indexSignature)
- ? typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, subPackageName)
+ ? typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, docId)
: undefined;
const commentIfExists =
!_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText)
@@ -185,7 +181,7 @@ export const typeDocUtils = {
const childrenIfExist = !_.isUndefined(entity.children)
? _.map(entity.children, (child: TypeDocNode) => {
const childTypeIfExists = !_.isUndefined(child.type)
- ? typeDocUtils._convertType(child.type, sections, sectionName, subPackageName)
+ ? typeDocUtils._convertType(child.type, sections, sectionName, docId)
: undefined;
const c: CustomTypeChild = {
name: child.name,
@@ -212,27 +208,22 @@ export const typeDocUtils = {
entity: TypeDocNode,
sections: SectionsMap,
sectionName: string,
- subPackageName: string,
+ docId: string,
): IndexSignature {
const key = entity.parameters[0];
const indexSignature = {
keyName: key.name,
- keyType: typeDocUtils._convertType(key.type, sections, sectionName, subPackageName),
+ keyType: typeDocUtils._convertType(key.type, sections, sectionName, docId),
valueName: entity.type.name,
};
return indexSignature;
},
- _convertProperty(
- entity: TypeDocNode,
- sections: SectionsMap,
- sectionName: string,
- subPackageName: string,
- ): Property {
+ _convertProperty(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): Property {
const source = entity.sources[0];
const commentIfExists = !_.isUndefined(entity.comment) ? entity.comment.shortText : undefined;
const property = {
name: entity.name,
- type: typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName),
+ type: typeDocUtils._convertType(entity.type, sections, sectionName, docId),
source: {
fileName: source.fileName,
line: source.line,
@@ -246,7 +237,7 @@ export const typeDocUtils = {
isConstructor: boolean,
sections: SectionsMap,
sectionName: string,
- subPackageName: string,
+ docId: string,
): TypescriptMethod {
const signature = entity.signatures[0];
const source = entity.sources[0];
@@ -258,7 +249,7 @@ export const typeDocUtils = {
let callPath;
if (isConstructor || entity.name === '__type') {
callPath = '';
- } else if (subPackageName === '0x.js') {
+ } else if (docId === DocPackages.ZeroExJs) {
const topLevelInterface = isStatic ? 'ZeroEx.' : 'zeroEx.';
callPath =
!_.isUndefined(sections.zeroEx) && sectionName !== sections.zeroEx
@@ -269,12 +260,12 @@ export const typeDocUtils = {
}
const parameters = _.map(signature.parameters, param => {
- return typeDocUtils._convertParameter(param, sections, sectionName, subPackageName);
+ return typeDocUtils._convertParameter(param, sections, sectionName, docId);
});
- const returnType = typeDocUtils._convertType(signature.type, sections, sectionName, subPackageName);
+ const returnType = typeDocUtils._convertType(signature.type, sections, sectionName, docId);
const typeParameter = _.isUndefined(signature.typeParameter)
? undefined
- : typeDocUtils._convertTypeParameter(signature.typeParameter[0], sections, sectionName, subPackageName);
+ : typeDocUtils._convertTypeParameter(signature.typeParameter[0], sections, sectionName, docId);
const method = {
isConstructor,
@@ -297,21 +288,16 @@ export const typeDocUtils = {
entity: TypeDocNode,
sections: SectionsMap,
sectionName: string,
- subPackageName: string,
+ docId: string,
): TypeParameter {
- const type = typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName);
+ const type = typeDocUtils._convertType(entity.type, sections, sectionName, docId);
const parameter = {
name: entity.name,
type,
};
return parameter;
},
- _convertParameter(
- entity: TypeDocNode,
- sections: SectionsMap,
- sectionName: string,
- subPackageName: string,
- ): Parameter {
+ _convertParameter(entity: TypeDocNode, sections: SectionsMap, sectionName: string, docId: string): Parameter {
let comment = '<No comment>';
if (entity.comment && entity.comment.shortText) {
comment = entity.comment.shortText;
@@ -321,7 +307,7 @@ export const typeDocUtils = {
const isOptional = !_.isUndefined(entity.flags.isOptional) ? entity.flags.isOptional : false;
- const type = typeDocUtils._convertType(entity.type, sections, sectionName, subPackageName);
+ const type = typeDocUtils._convertType(entity.type, sections, sectionName, docId);
const parameter = {
name: entity.name,
@@ -331,17 +317,17 @@ export const typeDocUtils = {
};
return parameter;
},
- _convertType(entity: TypeDocType, sections: SectionsMap, sectionName: string, subPackageName: string): Type {
+ _convertType(entity: TypeDocType, sections: SectionsMap, sectionName: string, docId: string): Type {
const typeArguments = _.map(entity.typeArguments, typeArgument => {
- return typeDocUtils._convertType(typeArgument, sections, sectionName, subPackageName);
+ return typeDocUtils._convertType(typeArgument, sections, sectionName, docId);
});
const types = _.map(entity.types, t => {
- return typeDocUtils._convertType(t, sections, sectionName, subPackageName);
+ return typeDocUtils._convertType(t, sections, sectionName, docId);
});
const isConstructor = false;
const methodIfExists = !_.isUndefined(entity.declaration)
- ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, subPackageName)
+ ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, docId)
: undefined;
const elementTypeIfExists = !_.isUndefined(entity.elementType)