@cosmwasm/ts-codegen 0.30.1 → 0.31.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/README.md +36 -30
  2. package/main/builder/builder.js +41 -4
  3. package/main/generators/create-helpers.js +38 -0
  4. package/main/helpers/contractContextBase.js +8 -0
  5. package/main/helpers/contractsContextTSX.js +8 -0
  6. package/main/helpers/index.js +31 -0
  7. package/main/plugins/client.js +11 -6
  8. package/main/plugins/message-composer.js +10 -6
  9. package/main/plugins/msg-builder.js +1 -1
  10. package/main/plugins/plugin-base.js +9 -2
  11. package/main/plugins/provider-bundle.js +146 -0
  12. package/main/plugins/provider.js +170 -0
  13. package/main/plugins/react-query.js +1 -1
  14. package/main/plugins/recoil.js +1 -1
  15. package/main/plugins/types.js +1 -1
  16. package/main/utils/files.js +77 -0
  17. package/main/utils/unused.js +68 -0
  18. package/module/builder/builder.js +28 -2
  19. package/module/generators/create-helpers.js +25 -0
  20. package/module/helpers/contractContextBase.js +92 -0
  21. package/module/helpers/contractsContextTSX.js +73 -0
  22. package/module/helpers/index.js +2 -0
  23. package/module/plugins/client.js +13 -10
  24. package/module/plugins/message-composer.js +12 -10
  25. package/module/plugins/msg-builder.js +1 -1
  26. package/module/plugins/plugin-base.js +15 -8
  27. package/module/plugins/provider-bundle.js +65 -0
  28. package/module/plugins/provider.js +81 -0
  29. package/module/plugins/react-query.js +1 -1
  30. package/module/plugins/recoil.js +1 -1
  31. package/module/plugins/types.js +1 -1
  32. package/module/utils/files.js +44 -0
  33. package/module/utils/unused.js +45 -0
  34. package/package.json +3 -3
  35. package/src/builder/builder.ts +36 -1
  36. package/src/generators/create-helpers.ts +28 -0
  37. package/src/helpers/contractContextBase.ts +92 -0
  38. package/src/helpers/contractsContextTSX.ts +73 -0
  39. package/src/helpers/index.ts +2 -0
  40. package/src/plugins/client.ts +30 -14
  41. package/src/plugins/message-composer.ts +23 -14
  42. package/src/plugins/msg-builder.ts +1 -1
  43. package/src/plugins/plugin-base.ts +30 -20
  44. package/src/plugins/provider-bundle.ts +97 -0
  45. package/src/plugins/provider.ts +114 -0
  46. package/src/plugins/react-query.ts +1 -1
  47. package/src/plugins/recoil.ts +1 -1
  48. package/src/plugins/types.ts +1 -1
  49. package/src/utils/files.ts +73 -0
  50. package/src/utils/unused.ts +52 -0
  51. package/types/src/builder/builder.d.ts +7 -1
  52. package/types/src/generators/create-helpers.d.ts +3 -0
  53. package/types/src/helpers/contractContextBase.d.ts +1 -0
  54. package/types/src/helpers/contractsContextTSX.d.ts +1 -0
  55. package/types/src/helpers/index.d.ts +2 -0
  56. package/types/src/plugins/client.d.ts +4 -3
  57. package/types/src/plugins/message-composer.d.ts +4 -3
  58. package/types/src/plugins/plugin-base.d.ts +7 -3
  59. package/types/src/plugins/provider-bundle.d.ts +13 -0
  60. package/types/src/plugins/provider.d.ts +15 -0
  61. package/types/src/plugins/use-contracts.d.ts +12 -0
  62. package/types/src/utils/files.d.ts +3 -0
  63. package/types/src/utils/unused.d.ts +5 -0
@@ -0,0 +1,114 @@
1
+ import { pascal } from "case";
2
+ import * as w from "wasm-ast-types";
3
+ import { ContractInfo, RenderContextBase, RenderContext } from "wasm-ast-types";
4
+ import { BuilderFileType, TSBuilderOptions } from "../builder";
5
+ import { BuilderPluginBase } from "./plugin-base";
6
+
7
+ export const GetLocalNameByContractName = (name) =>
8
+ `${pascal(name)}.provider.ts`;
9
+
10
+ export const GetLocalBaseNameByContractName = (name) =>
11
+ `${pascal(name)}.provider`;
12
+
13
+ export class ContractsContextProviderPlugin extends BuilderPluginBase<TSBuilderOptions> {
14
+ constructor(opt: TSBuilderOptions) {
15
+ super(opt);
16
+
17
+ this.utils = {
18
+ ContractBase: "__contractContextBase__",
19
+ IContractConstructor: "__contractContextBase__",
20
+ IEmptyClient: "__contractContextBase__",
21
+ };
22
+ }
23
+
24
+ initContext(
25
+ contract: ContractInfo,
26
+ options?: TSBuilderOptions
27
+ ): RenderContextBase<TSBuilderOptions> {
28
+ return new RenderContext(contract, options, this.builder.builderContext);
29
+ }
30
+
31
+ async doRender(
32
+ name: string,
33
+ context: RenderContext
34
+ ): Promise<
35
+ {
36
+ type: BuilderFileType;
37
+ pluginType?: string;
38
+ localname: string;
39
+ body: any[];
40
+ }[]
41
+ > {
42
+ if (!this.option?.useContracts?.enabled) {
43
+ return;
44
+ }
45
+
46
+ const providerInfo = context.getProviderInfos()[name];
47
+
48
+ if (!Object.keys(providerInfo)?.length) {
49
+ return;
50
+ }
51
+
52
+ context.addUtil("ContractBase");
53
+ context.addUtil("IContractConstructor");
54
+
55
+ const localname = GetLocalNameByContractName(name);
56
+ let needEmptyClientType = false;
57
+ let clientFile = null;
58
+ let clientClasses = [];
59
+
60
+ const body = [];
61
+
62
+ const signClientProviderInfo =
63
+ providerInfo[w.PROVIDER_TYPES.SIGNING_CLIENT_TYPE];
64
+
65
+ if (signClientProviderInfo) {
66
+ clientFile = `./${signClientProviderInfo.basename}`;
67
+ clientClasses.push(signClientProviderInfo.classname);
68
+ } else {
69
+ needEmptyClientType = true;
70
+ }
71
+
72
+ const queryClientProviderInfo =
73
+ providerInfo[w.PROVIDER_TYPES.QUERY_CLIENT_TYPE];
74
+
75
+ if (queryClientProviderInfo) {
76
+ clientFile = `./${queryClientProviderInfo.basename}`;
77
+ clientClasses.push(queryClientProviderInfo.classname);
78
+ } else {
79
+ needEmptyClientType = true;
80
+ }
81
+
82
+ if (clientFile) {
83
+ body.push(w.importStmt(clientClasses, clientFile));
84
+ }
85
+
86
+ const messageComposerProviderInfo =
87
+ providerInfo[w.PROVIDER_TYPES.MESSAGE_COMPOSER_TYPE];
88
+
89
+ if (messageComposerProviderInfo) {
90
+ body.push(
91
+ w.importStmt(
92
+ [messageComposerProviderInfo.classname],
93
+ `./${messageComposerProviderInfo.basename}`
94
+ )
95
+ );
96
+ } else {
97
+ needEmptyClientType = true;
98
+ }
99
+
100
+ if (needEmptyClientType) {
101
+ context.addUtil("IEmptyClient");
102
+ }
103
+
104
+ body.push(w.createProvider(name, providerInfo));
105
+
106
+ return [
107
+ {
108
+ type: "plugin",
109
+ localname,
110
+ body,
111
+ },
112
+ ];
113
+ }
114
+ }
@@ -16,7 +16,7 @@ export class ReactQueryPlugin extends BuilderPluginBase<RenderOptions> {
16
16
  contract: ContractInfo,
17
17
  options?: RenderOptions
18
18
  ): RenderContextBase<RenderOptions> {
19
- return new RenderContext(contract, options);
19
+ return new RenderContext(contract, options, this.builder.builderContext);
20
20
  }
21
21
 
22
22
  async doRender(
@@ -19,7 +19,7 @@ export class RecoilPlugin extends BuilderPluginBase<RenderOptions> {
19
19
  contract: ContractInfo,
20
20
  options?: RenderOptions
21
21
  ): RenderContextBase<RenderOptions> {
22
- return new RenderContext(contract, options);
22
+ return new RenderContext(contract, options, this.builder.builderContext);
23
23
  }
24
24
 
25
25
  async doRender(
@@ -16,7 +16,7 @@ export class TypesPlugin extends BuilderPluginBase<RenderOptions> {
16
16
  contract: ContractInfo,
17
17
  options?: RenderOptions
18
18
  ): RenderContextBase<RenderOptions> {
19
- return new RenderContext(contract, options);
19
+ return new RenderContext(contract, options, this.builder.builderContext);
20
20
  }
21
21
 
22
22
  async doRender(
@@ -0,0 +1,73 @@
1
+ import * as t from "@babel/types";
2
+ import { parse, ParserPlugin } from "@babel/parser";
3
+ import { sync as mkdirp } from "mkdirp";
4
+ import { writeFileSync } from "fs";
5
+ import { dirname } from "path";
6
+ import generate from "@babel/generator";
7
+ import { unused } from "./unused";
8
+ import traverse from "@babel/traverse";
9
+
10
+ export const writeAstToFile = (
11
+ outPath: string,
12
+ program: t.Statement[],
13
+ filename: string,
14
+ removeUnusedImports = false,
15
+ isTsDisable = false,
16
+ isEslintDisable = false
17
+ ) => {
18
+ const ast = t.program(program);
19
+ const content = generate(ast).code;
20
+
21
+ if (removeUnusedImports) {
22
+ const plugins: ParserPlugin[] = ["typescript"];
23
+ const newAst = parse(content, {
24
+ sourceType: "module",
25
+ plugins,
26
+ });
27
+ traverse(newAst, unused);
28
+ const content2 = generate(newAst).code;
29
+ writeContentToFile(
30
+ outPath,
31
+ content2,
32
+ filename,
33
+ isTsDisable,
34
+ isEslintDisable
35
+ );
36
+ } else {
37
+ writeContentToFile(
38
+ outPath,
39
+ content,
40
+ filename,
41
+ isTsDisable,
42
+ isEslintDisable
43
+ );
44
+ }
45
+ };
46
+
47
+ export const writeContentToFile = (
48
+ outPath: string,
49
+ content: string,
50
+ filename: string,
51
+ isTsDisable = false,
52
+ isEslintDisable = false
53
+ ) => {
54
+ let esLintPrefix = "";
55
+ let tsLintPrefix = "";
56
+
57
+ let nameWithoutPath = filename.replace(outPath, "");
58
+ // strip off leading slash
59
+ if (nameWithoutPath.startsWith("/"))
60
+ nameWithoutPath = nameWithoutPath.replace(/^\//, "");
61
+
62
+ if (isTsDisable) {
63
+ tsLintPrefix = `//@ts-nocheck\n`;
64
+ }
65
+
66
+ if (isEslintDisable) {
67
+ esLintPrefix = `/* eslint-disable */\n`;
68
+ }
69
+
70
+ const text = tsLintPrefix + esLintPrefix + content;
71
+ mkdirp(dirname(filename));
72
+ writeFileSync(filename, text);
73
+ };
@@ -0,0 +1,52 @@
1
+ //@ts-nocheck
2
+
3
+ import * as t from '@babel/types';
4
+
5
+ // https://github.com/chuyik/babel-plugin-danger-remove-unused-import
6
+ // https://github.com/chuyik/babel-plugin-danger-remove-unused-import/blob/c5454c21e94698a2464a12baa5590761932a71a8/License#L1
7
+
8
+ export const unused = {
9
+ Program: {
10
+ exit: (path) => {
11
+ const UnRefBindings = new Map()
12
+ for (const [name, binding] of Object.entries(path.scope.bindings)) {
13
+ if (!binding.path.parentPath || binding.kind !== 'module') continue
14
+
15
+ const source = binding.path.parentPath.get('source')
16
+ const importName = source.node.value
17
+ if (
18
+ !t.isStringLiteral(source)
19
+ )
20
+ continue
21
+
22
+ const key = `${importName}(${source.node.loc &&
23
+ source.node.loc.start.line})`
24
+
25
+ if (!UnRefBindings.has(key)) {
26
+ UnRefBindings.set(key, binding)
27
+ }
28
+
29
+ if (binding.referenced) {
30
+ UnRefBindings.set(key, null)
31
+ } else {
32
+ const nodeType = binding.path.node.type
33
+ if (nodeType === 'ImportSpecifier') {
34
+ binding.path.remove()
35
+ } else if (nodeType === 'ImportDefaultSpecifier') {
36
+ binding.path.remove()
37
+ } else if (nodeType === 'ImportNamespaceSpecifier') {
38
+ binding.path.remove()
39
+ } else if (binding.path.parentPath) {
40
+ binding.path.parentPath.remove()
41
+ }
42
+ }
43
+ }
44
+
45
+ UnRefBindings.forEach((binding, key) => {
46
+ if (binding && binding.path.parentPath) {
47
+ binding.path.parentPath.remove()
48
+ }
49
+ })
50
+ }
51
+ }
52
+ };
@@ -1,4 +1,4 @@
1
- import { RenderOptions } from "wasm-ast-types";
1
+ import { RenderOptions, BuilderContext } from "wasm-ast-types";
2
2
  import { IBuilderPlugin } from '../plugins';
3
3
  export interface TSBuilderInput {
4
4
  contracts: Array<ContractFile | string>;
@@ -12,8 +12,13 @@ export interface BundleOptions {
12
12
  bundleFile?: string;
13
13
  bundlePath?: string;
14
14
  }
15
+ export interface UseContractsOptions {
16
+ enabled?: boolean;
17
+ filename?: string;
18
+ }
15
19
  export type TSBuilderOptions = {
16
20
  bundle?: BundleOptions;
21
+ useContracts?: UseContractsOptions;
17
22
  } & RenderOptions;
18
23
  export type BuilderFileType = 'type' | 'client' | 'recoil' | 'react-query' | 'message-composer' | 'msg-builder' | 'plugin';
19
24
  export interface BuilderFile {
@@ -32,6 +37,7 @@ export declare class TSBuilder {
32
37
  outPath: string;
33
38
  options?: TSBuilderOptions;
34
39
  plugins: IBuilderPlugin[];
40
+ builderContext: BuilderContext;
35
41
  protected files: BuilderFile[];
36
42
  loadDefaultPlugins(): void;
37
43
  constructor({ contracts, outPath, options, plugins }: TSBuilderInput);
@@ -0,0 +1,3 @@
1
+ import { TSBuilderInput } from "../builder";
2
+ import { BuilderContext } from "wasm-ast-types";
3
+ export declare const createHelpers: (input: TSBuilderInput, builderContext: BuilderContext) => void;
@@ -0,0 +1 @@
1
+ export declare const contractContextBase = "\nimport {\n CosmWasmClient,\n SigningCosmWasmClient,\n} from '@cosmjs/cosmwasm-stargate';\n\nexport interface IContractConstructor {\n address: string | undefined;\n cosmWasmClient: CosmWasmClient | undefined;\n signingCosmWasmClient: SigningCosmWasmClient | undefined;\n}\n\nexport const NO_SINGING_ERROR_MESSAGE = 'signingCosmWasmClient not connected';\n\nexport const NO_COSMWASW_CLIENT_ERROR_MESSAGE = 'cosmWasmClient not connected';\n\nexport const NO_ADDRESS_ERROR_MESSAGE = \"address doesn't exist\";\n\nexport const NO_SIGNING_CLIENT_ERROR_MESSAGE =\n 'Signing client is not generated. Please check ts-codegen config';\n\nexport const NO_QUERY_CLIENT_ERROR_MESSAGE =\n 'Query client is not generated. Please check ts-codegen config';\n\nexport const NO_MESSAGE_COMPOSER_ERROR_MESSAGE =\n 'Message composer client is not generated. Please check ts-codegen config';\n\n/**\n * a placeholder for non-generated classes\n */\nexport interface IEmptyClient {}\n\nexport interface ISigningClientProvider<T> {\n getSigningClient(contractAddr: string): T;\n}\n\nexport interface IQueryClientProvider<T> {\n getQueryClient(contractAddr: string): T;\n}\n\nexport interface IMessageComposerProvider<T> {\n getMessageComposer(contractAddr: string): T;\n}\n\nexport class ContractBase<\n TSign = IEmptyClient,\n TQuery = IEmptyClient,\n TMsgComposer = IEmptyClient\n> {\n constructor(\n protected address: string | undefined,\n protected cosmWasmClient: CosmWasmClient | undefined,\n protected signingCosmWasmClient: SigningCosmWasmClient | undefined,\n private TSign?: new (\n client: SigningCosmWasmClient,\n sender: string,\n contractAddress: string\n ) => TSign,\n private TQuery?: new (\n client: CosmWasmClient,\n contractAddress: string\n ) => TQuery,\n private TMsgComposer?: new (\n sender: string,\n contractAddress: string\n ) => TMsgComposer\n ) {}\n\n public getSigningClient(contractAddr: string): TSign {\n if (!this.signingCosmWasmClient) throw new Error(NO_SINGING_ERROR_MESSAGE);\n if (!this.address) throw new Error(NO_ADDRESS_ERROR_MESSAGE);\n if (!this.TSign) throw new Error(NO_SIGNING_CLIENT_ERROR_MESSAGE);\n return new this.TSign(\n this.signingCosmWasmClient,\n this.address,\n contractAddr\n );\n }\n\n public getQueryClient(contractAddr: string): TQuery {\n if (!this.cosmWasmClient) throw new Error(NO_COSMWASW_CLIENT_ERROR_MESSAGE);\n if (!this.TQuery) throw new Error(NO_QUERY_CLIENT_ERROR_MESSAGE);\n return new this.TQuery(this.cosmWasmClient, contractAddr);\n }\n\n public getMessageComposer(contractAddr: string): TMsgComposer {\n if (!this.address) throw new Error(NO_ADDRESS_ERROR_MESSAGE);\n if (!this.TMsgComposer) throw new Error(NO_MESSAGE_COMPOSER_ERROR_MESSAGE);\n return new this.TMsgComposer(this.address, contractAddr);\n }\n}\n";
@@ -0,0 +1 @@
1
+ export declare const contractsContextTSX = "\nimport React, { useEffect, useMemo, useRef, useState, useContext } from 'react';\nimport {\n CosmWasmClient,\n SigningCosmWasmClient,\n} from '@cosmjs/cosmwasm-stargate';\n\nimport { IContractsContext, getProviders } from './contractContextProviders';\n\ninterface ContractsConfig {\n address: string | undefined;\n getCosmWasmClient: () => Promise<CosmWasmClient>;\n getSigningCosmWasmClient: () => Promise<SigningCosmWasmClient>;\n}\n\nconst ContractsContext = React.createContext<IContractsContext | null>(null);\n\nexport const ContractsProvider = ({\n children,\n contractsConfig,\n}: {\n children: React.ReactNode;\n contractsConfig: ContractsConfig;\n}) => {\n const [cosmWasmClient, setCosmWasmClient] = useState<CosmWasmClient>();\n const [signingCosmWasmClient, setSigningCosmWasmClient] =\n useState<SigningCosmWasmClient>();\n\n const { address, getCosmWasmClient, getSigningCosmWasmClient } =\n contractsConfig;\n\n const prevAddressRef = useRef<string | undefined>(address);\n\n const contracts: IContractsContext = useMemo(() => {\n return getProviders(address, cosmWasmClient, signingCosmWasmClient);\n }, [address, cosmWasmClient, signingCosmWasmClient]);\n\n useEffect(() => {\n const connectSigningCwClient = async () => {\n if (address && prevAddressRef.current !== address) {\n const signingCosmWasmClient = await getSigningCosmWasmClient();\n setSigningCosmWasmClient(signingCosmWasmClient);\n } else if (!address) {\n setSigningCosmWasmClient(undefined);\n }\n prevAddressRef.current = address;\n };\n connectSigningCwClient();\n }, [address, getSigningCosmWasmClient]);\n\n useEffect(() => {\n const connectCosmWasmClient = async () => {\n const cosmWasmClient = await getCosmWasmClient();\n setCosmWasmClient(cosmWasmClient);\n };\n connectCosmWasmClient();\n }, [getCosmWasmClient]);\n\n return (\n <ContractsContext.Provider value={contracts}>\n {children}\n </ContractsContext.Provider>\n );\n};\n\nexport const useContracts = () => {\n const contracts = useContext(ContractsContext);\n if (contracts === null) {\n throw new Error('useContracts must be used within a ContractsProvider');\n }\n return contracts;\n};\n";
@@ -0,0 +1,2 @@
1
+ export * from './contractContextBase';
2
+ export * from './contractsContextTSX';
@@ -1,6 +1,7 @@
1
- import { RenderContext, ContractInfo, RenderContextBase, RenderOptions } from 'wasm-ast-types';
2
- import { BuilderFileType } from '../builder';
3
- import { BuilderPluginBase } from './plugin-base';
1
+ import { RenderContext, ContractInfo, RenderContextBase, RenderOptions } from "wasm-ast-types";
2
+ import { BuilderFileType } from "../builder";
3
+ import { BuilderPluginBase } from "./plugin-base";
4
+ export declare const TYPE = "client";
4
5
  export declare class ClientPlugin extends BuilderPluginBase<RenderOptions> {
5
6
  initContext(contract: ContractInfo, options?: RenderOptions): RenderContextBase<RenderOptions>;
6
7
  doRender(name: string, context: RenderContext): Promise<{
@@ -1,6 +1,7 @@
1
- import { ContractInfo, RenderContextBase, RenderContext, RenderOptions } from 'wasm-ast-types';
2
- import { BuilderFileType } from '../builder';
3
- import { BuilderPluginBase } from './plugin-base';
1
+ import { ContractInfo, RenderContextBase, RenderContext, RenderOptions } from "wasm-ast-types";
2
+ import { BuilderFileType } from "../builder";
3
+ import { BuilderPluginBase } from "./plugin-base";
4
+ export declare const TYPE = "message-composer";
4
5
  export declare class MessageComposerPlugin extends BuilderPluginBase<RenderOptions> {
5
6
  initContext(contract: ContractInfo, options?: RenderOptions): RenderContextBase<RenderOptions>;
6
7
  doRender(name: string, context: RenderContext): Promise<{
@@ -1,5 +1,5 @@
1
- import { ContractInfo, UtilMapping, IContext } from 'wasm-ast-types';
2
- import { BuilderFile, BuilderFileType } from '../builder';
1
+ import { ContractInfo, UtilMapping, IContext } from "wasm-ast-types";
2
+ import { BuilderFile, BuilderFileType, TSBuilder } from "../builder";
3
3
  /**
4
4
  * IBuilderPlugin is a common plugin that render generated code.
5
5
  */
@@ -8,6 +8,8 @@ export interface IBuilderPlugin {
8
8
  * a mapping of utils will be used in generated code.
9
9
  */
10
10
  utils: UtilMapping;
11
+ builder?: TSBuilder;
12
+ setBuilder(builder: TSBuilder): any;
11
13
  /**
12
14
  * render generated cdoe.
13
15
  * @param name the name of contract
@@ -23,9 +25,11 @@ export interface IBuilderPlugin {
23
25
  export declare abstract class BuilderPluginBase<TOpt extends {
24
26
  enabled?: boolean;
25
27
  }> implements IBuilderPlugin {
28
+ builder?: TSBuilder;
26
29
  option: TOpt;
27
30
  utils: UtilMapping;
28
- constructor(opt: TOpt);
31
+ constructor(opt: TOpt, builder?: TSBuilder);
32
+ setBuilder(builder: TSBuilder): void;
29
33
  render(name: string, contractInfo: ContractInfo, outPath: string): Promise<BuilderFile[]>;
30
34
  /**
31
35
  * init context here
@@ -0,0 +1,13 @@
1
+ import { ContractInfo, RenderContextBase, RenderContext } from "wasm-ast-types";
2
+ import { BuilderFileType, TSBuilderOptions } from "../builder";
3
+ import { BuilderPluginBase } from "./plugin-base";
4
+ export declare class ContractsProviderBundlePlugin extends BuilderPluginBase<TSBuilderOptions> {
5
+ constructor(opt: TSBuilderOptions);
6
+ initContext(contract: ContractInfo, options?: TSBuilderOptions): RenderContextBase<TSBuilderOptions>;
7
+ doRender(name: string, context: RenderContext): Promise<{
8
+ type: BuilderFileType;
9
+ pluginType?: string;
10
+ localname: string;
11
+ body: any[];
12
+ }[]>;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { ContractInfo, RenderContextBase, RenderContext } from "wasm-ast-types";
2
+ import { BuilderFileType, TSBuilderOptions } from "../builder";
3
+ import { BuilderPluginBase } from "./plugin-base";
4
+ export declare const GetLocalNameByContractName: (name: any) => string;
5
+ export declare const GetLocalBaseNameByContractName: (name: any) => string;
6
+ export declare class ContractsContextProviderPlugin extends BuilderPluginBase<TSBuilderOptions> {
7
+ constructor(opt: TSBuilderOptions);
8
+ initContext(contract: ContractInfo, options?: TSBuilderOptions): RenderContextBase<TSBuilderOptions>;
9
+ doRender(name: string, context: RenderContext): Promise<{
10
+ type: BuilderFileType;
11
+ pluginType?: string;
12
+ localname: string;
13
+ body: any[];
14
+ }[]>;
15
+ }
@@ -0,0 +1,12 @@
1
+ import { ContractInfo, RenderContextBase, RenderContext } from 'wasm-ast-types';
2
+ import { BuilderFileType, TSBuilderOptions } from '../builder';
3
+ import { BuilderPluginBase } from './plugin-base';
4
+ export declare class ContractsContextPlugin extends BuilderPluginBase<TSBuilderOptions> {
5
+ initContext(contract: ContractInfo, options?: TSBuilderOptions): RenderContextBase<TSBuilderOptions>;
6
+ doRender(name: string, context: RenderContext): Promise<{
7
+ type: BuilderFileType;
8
+ pluginType?: string;
9
+ localname: string;
10
+ body: any[];
11
+ }[]>;
12
+ }
@@ -0,0 +1,3 @@
1
+ import * as t from "@babel/types";
2
+ export declare const writeAstToFile: (outPath: string, program: t.Statement[], filename: string, removeUnusedImports?: boolean, isTsDisable?: boolean, isEslintDisable?: boolean) => void;
3
+ export declare const writeContentToFile: (outPath: string, content: string, filename: string, isTsDisable?: boolean, isEslintDisable?: boolean) => void;
@@ -0,0 +1,5 @@
1
+ export declare const unused: {
2
+ Program: {
3
+ exit: (path: any) => void;
4
+ };
5
+ };