How to use the @0x/types.TypeDocTypes.Intrinsic function in @0x/types

To help you get started, we’ve selected a few @0x/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / sol-doc / src / sol_doc.ts View on Github external
private _getTypeFromDataItem(dataItem: DataItem): Type {
        const typeDocType = dataItem.components !== undefined ? TypeDocTypes.Reference : TypeDocTypes.Intrinsic;
        let typeName: string;
        if (typeDocType === TypeDocTypes.Reference) {
            const nameIfExists = this._getNameFromDataItemIfExists(dataItem);
            typeName = nameIfExists === undefined ? SolDoc._capitalize(dataItem.name) : nameIfExists;
        } else {
            typeName = dataItem.type;
        }

        const isArrayType = _.endsWith(dataItem.type, '[]');
        let type: Type;
        if (isArrayType) {
            // tslint:disable-next-line:custom-no-magic-numbers
            typeName = typeDocType === TypeDocTypes.Intrinsic ? typeName.slice(0, -2) : typeName;
            type = {
                elementType: { name: typeName, typeDocType },
                typeDocType: TypeDocTypes.Array,
                name: '',
            };
        } else {
            type = { name: typeName, typeDocType };
        }
        return type;
    }
    private _overwriteStructNames(customTypes: CustomType[]): CustomType[] {
github 0xProject / 0x-monorepo / packages / sol-doc / src / sol_doc.ts View on Github external
private _getTypeFromDataItem(dataItem: DataItem): Type {
        const typeDocType = dataItem.components !== undefined ? TypeDocTypes.Reference : TypeDocTypes.Intrinsic;
        let typeName: string;
        if (typeDocType === TypeDocTypes.Reference) {
            const nameIfExists = this._getNameFromDataItemIfExists(dataItem);
            typeName = nameIfExists === undefined ? SolDoc._capitalize(dataItem.name) : nameIfExists;
        } else {
            typeName = dataItem.type;
        }

        const isArrayType = _.endsWith(dataItem.type, '[]');
        let type: Type;
        if (isArrayType) {
            // tslint:disable-next-line:custom-no-magic-numbers
            typeName = typeDocType === TypeDocTypes.Intrinsic ? typeName.slice(0, -2) : typeName;
            type = {
                elementType: { name: typeName, typeDocType },
                typeDocType: TypeDocTypes.Array,
github 0xProject / 0x-monorepo / packages / sol-doc / src / sol_doc.ts View on Github external
name: '',
                typeDocType: TypeDocTypes.Tuple,
                tupleElements: [],
            };
            for (const output of outputs) {
                const tupleType = this._getTypeFromDataItem(output);
                (type.tupleElements as Type[]).push(tupleType);
            }
            return type;
        } else if (outputs.length === 1) {
            const output = outputs[0];
            type = this._getTypeFromDataItem(output);
        } else {
            type = {
                name: 'void',
                typeDocType: TypeDocTypes.Intrinsic,
            };
        }
        return type;
    }
    private _getStructsAsCustomTypes(abiDefinition: AbiDefinition): CustomType[] {
github 0xProject / 0x-monorepo / packages / react-docs / src / components / type.tsx View on Github external
export const Type: React.SFC = (props: TypeProps): any => {
    const type = props.type;
    const isReference = type.typeDocType === TypeDocTypes.Reference;
    const isArray = type.typeDocType === TypeDocTypes.Array;
    let typeNameColor = 'inherit';
    let typeName: string | React.ReactNode;
    let typeArgs: React.ReactNode[] = [];
    switch (type.typeDocType) {
        case TypeDocTypes.Intrinsic:
        case TypeDocTypes.Unknown:
            typeName = type.name;
            typeNameColor = colors.orange;
            break;

        case TypeDocTypes.Reference:
            typeName = type.name;
            typeArgs = _.map(type.typeArguments, (arg: TypeDef) => {
                if (arg.typeDocType === TypeDocTypes.Array) {
                    const key = `type-${arg.elementType.name}-${arg.elementType.typeDocType}`;
                    return (
                        <span>
                            </span>