import { ClassDeclaration, MethodDeclaration, DiagnosticEmitter } from "visitor-as/as"; import { DecoratorConfig } from "./util"; /** * Ask supported decorators. */ export declare enum ContractDecoratorKind { SpreadLayout = "spreadLayout", PackedLayout = "packedLayout", Contract = "contract", Event = "event", Topic = "topic", Primitive = "primitive", Constructor = "constructor", Message = "message", EnvType = "envType", Ignore = "Ignore" } /** * Any decorators that support addition config * should extend this interface. */ export interface AskNode { /** contract Kind of this node. */ readonly contractKind: ContractDecoratorKind; } /** * Transform a hex string value to a JS literal array value string. * @param hex a hex with optional prefix * @returns */ export declare function hexToArrayString(hex: string, byteLength?: number): string; /** * A decorator AST interface that support contract calling. */ export interface ContractMethodNode extends AskNode { /** * Whether this method could mutate contract storage */ readonly mutates: boolean; /** * Whether this method could pay addition balance. */ readonly payable: boolean; /** * The contract method name. */ readonly methodName: string; /** * The contract method selector name. * * Used by codegen. */ readonly selectorName: string; /** * The contract selector. * @returns */ hexSelector(): string; /** * The arguments the method received. */ paramsTypeName(): string[]; /** * The value the method return. */ returnTypeName(): string; /** * The method documents. * * Not used now. */ docs(): string[]; } /** * MessageDeclaration represents a `@message` info */ export declare class MessageDeclaration implements ContractMethodNode { readonly method: MethodDeclaration; readonly selector: string | null; readonly mutates: boolean; readonly payable: boolean; readonly contractKind: ContractDecoratorKind; constructor(method: MethodDeclaration, selector: string | null, mutates: boolean, payable?: boolean); paramsTypeName(): string[]; returnTypeName(): string; /** * If not define a selector, it use blake2 of method name as hex selector * @returns */ hexSelector(): string; get methodName(): string; get selectorName(): string; get mutatesName(): string; get payableName(): string; docs(): string[]; /** * Collect message method infos from config. * @param node * @param cfg * @returns */ static extractFrom(emitter: DiagnosticEmitter, node: MethodDeclaration, cfg: DecoratorConfig): MessageDeclaration; } /** * ConstructorDeclaration represents a `@constructor` info */ export declare class ConstructorDeclaration implements ContractMethodNode { readonly method: MethodDeclaration; readonly selector: string | null; readonly contractKind: ContractDecoratorKind; /** * mutates is always be true */ readonly mutates: boolean; /** * payable is always be true */ readonly payable: boolean; constructor(method: MethodDeclaration, selector: string | null); paramsTypeName(): string[]; returnTypeName(): string; /** * If not define a selector, it use blake2 of method name as hex selector * @returns */ hexSelector(): string; get methodName(): string; get selectorName(): string; docs(): string[]; /** * Collect constructor method infos from config. * @param node * @param cfg * @returns */ static extractFrom(emitter: DiagnosticEmitter, node: MethodDeclaration, cfg: DecoratorConfig): ConstructorDeclaration; } /** * EventDeclaration represents a `@event` info */ export declare class EventDeclaration implements AskNode { /** * Event Id */ readonly id: number; readonly event: ClassDeclaration; readonly contractKind: ContractDecoratorKind; constructor( /** * Event Id */ id: number, event: ClassDeclaration); /** * Collect event infos from config. * @param node * @param cfg * @returns */ static extractFrom(emitter: DiagnosticEmitter, node: ClassDeclaration): EventDeclaration; } export declare function hexSelector(selector: string | null, methodName: string): string;