UNPKG

@cosmology/ast

Version:
15 lines (14 loc) 593 B
import * as t from '@babel/types'; import { getAminoTypeName, getTypeUrl } from '../../amino'; export const createTypeUrlProperty = (context, proto) => { const typeUrl = getTypeUrl(context.ref.proto, proto); if (!typeUrl) return; return t.objectProperty(t.identifier('typeUrl'), t.stringLiteral(typeUrl)); }; export const createAminoTypeProperty = (context, proto) => { const str = getAminoTypeName(context, context.ref.proto, proto); if (!str || str.startsWith('/')) return; return t.objectProperty(t.identifier('aminoType'), t.stringLiteral(str)); };