@cosmology/ast
Version:
Cosmos TypeScript AST generation
18 lines (17 loc) • 881 B
JavaScript
import { identifier } from '../../../../../utils';
import * as t from '@babel/types';
// second params for grpc-web method
export const metadata = identifier('metadata', t.tSTypeAnnotation(t.tsTypeReference(t.tsQualifiedName(t.identifier('grpc'), t.identifier('Metadata')))), true);
// this.Accounts = this.Accounts.bind(this);
// MARKED AS NOT DRY (used in rpc/lcd)
export const bindThis = (name) => {
return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(name)), t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(name)), t.identifier('bind')), [
t.thisExpression()
])));
};
export const makeComment = (comment) => {
return [{ type: 'CommentBlock', value: ` ${comment} ` }];
};
export const getRpcClassName = (service) => {
return `${service.name}ClientImpl`;
};