/** * @alpha */ export declare function contractParser(contract: string, namespace?: string): [IModule[], IPointer]; /** * Parse the regular transaction code; * * this does not include deploy contract code; for that use {@link pactParser } * @example * const code = '(coin.transfer "alice" "bob" 100)(free.my-contract.my-function "alice" "bob" [100.1 2] \{ "extra" : "some-data" \} )'; * const parsed = execCodeParser(code); * // const parsed = [ * // \{ * // function: \{ module: 'coin', name: 'transfer' \}, * // args: [\{ string: 'alice' \}, \{ string: 'bob' \}, \{ int: 100 \}], * // \}, * // \{ * // function: \{ * // namespace: 'free', * // module: 'my-contract', * // name: 'my-function', * // \}, * // args: [ * // \{ string: 'alice' \}, * // \{ string: 'bob' \}, * // \{ list: [\{ decimal: 100.1 \}, \{ int: 2 \}] \}, * // \{ object: [\{ property: 'extra', value: [\{ string: 'some-data' \}] \}] \}, * // ], * // \}, * // ]; * @alpha */ export declare function execCodeParser(code: string): undefined | IParsedCode[]; /** * @alpha */ export declare function generateDts(module: IModule): string; /** * @alpha */ export declare function generateTemplates(templates: { name: string; template: ITemplate; }[], version: string): string; declare interface ICapability extends IMethod { composeCapabilities?: string[]; } declare interface IFunction extends IMethod { bodyPointer?: number; requiredCapabilities?: string[]; withCapabilities?: string[]; events?: string[]; functionCalls?: { internal: string[]; external: Array<{ namespace?: string; module: string; func: string; }>; }; externalFnCalls?: Array<{ namespace?: string; module: string; func: string; }>; allExtractedCaps?: Array<{ name: string; fullModuleName: string; reason: 'with-capability' | 'compose-capability'; origin: string; capability: ICapability; }>; } declare interface IMethod { name: string; kind: string; returnType?: string | IType; doc?: string; parameters?: Array<{ name: string; type: string | IType; }>; } declare interface IModule { kind: string; namespace: string; name: string; doc: string; governance: string; usedModules?: Array<{ name: string; namespace?: string; hash?: string; imports?: string[]; }>; usedInterface?: Array<{ name: string; namespace?: string; }>; functions?: IFunction[]; capabilities?: ICapability[]; schemas?: ISchema[]; } /** * @alpha */ export declare interface IParsedCode { function: { module?: string; namespace?: string; name: string; }; args: Array<{ string: string; } | { int: number; } | { decimal: number; } | { object: Array<{ property: string; value: IParsedCode['args'][number]; }>; } | { list: IParsedCode['args']; } | { code: IParsedCode; }>; } declare interface IPointer { next: () => IToken | undefined; reset: (id: number) => void; snapshot: (log?: boolean) => number; done: () => boolean; } declare interface ISchema { name: string; doc?: string; properties?: Array<{ name: string; type: string | IType; }>; } /** * @alpha */ export declare interface ITemplate { parts: TemplateParts; holes: TemplateHoles; } declare interface IToken { value: string; type?: 'lparen' | 'rparen' | 'dot' | 'string' | 'namespace' | 'arom' | 'decimal' | string; } declare interface IType { kind: string; value: string; isList?: true; } /** * @alpha */ export declare function pactParser({ contractNames, files, getContract, namespace, }: { contractNames?: string[]; files?: string[]; getContract: (fullName: string) => Promise; namespace?: string; }): Promise<{ [k: string]: IModule; }>; /** * @alpha */ export declare function parseTemplate(template: string): ITemplate; /** * @alpha */ export declare type TemplateHoles = string[]; /** * @alpha */ export declare type TemplateParts = string[]; export { }