@dedot/codegen 0.4.1-next.b1afe683.1 → 0.4.2-next.5d9d02c1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chaintypes/generator/JsonRpcGen.js +4 -2
- package/chaintypes/index.js +1 -1
- package/chaintypes/templates/json-rpc.hbs +6 -1
- package/cjs/chaintypes/generator/JsonRpcGen.js +4 -2
- package/cjs/chaintypes/index.js +1 -1
- package/cjs/chaintypes/templates/json-rpc.hbs +6 -1
- package/cjs/typink/index.js +1 -1
- package/cjs/typink/templates/index.hbs +1 -1
- package/cjs/utils.js +3 -3
- package/package.json +10 -10
- package/types.d.ts +1 -0
- package/typink/index.js +1 -1
- package/typink/templates/index.hbs +1 -1
- package/utils.js +1 -1
|
@@ -35,8 +35,10 @@ export class JsonRpcGen extends ApiGen {
|
|
|
35
35
|
super(typesGen);
|
|
36
36
|
this.typesGen = typesGen;
|
|
37
37
|
this.rpcMethods = rpcMethods;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (rpcMethods.length > 0) {
|
|
39
|
+
HIDDEN_RPCS.filter((one) => !rpcMethods.includes(one)).forEach((one) => rpcMethods.push(one));
|
|
40
|
+
rpcMethods.sort();
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
generate(useSubPaths = false) {
|
|
42
44
|
this.typesGen.clearCache();
|
package/chaintypes/index.js
CHANGED
|
@@ -47,5 +47,5 @@ export async function generateTypes(chain, metadata, rpcMethods, runtimeApis, ou
|
|
|
47
47
|
fs.writeFileSync(txFileName, await txGen.generate(useSubPaths));
|
|
48
48
|
fs.writeFileSync(indexFileName, await indexGen.generate(useSubPaths));
|
|
49
49
|
fs.writeFileSync(runtimeApisFileName, await runtimeApisGen.generate(useSubPaths));
|
|
50
|
-
return { interfaceName };
|
|
50
|
+
return { interfaceName, outputFolder: dirPath };
|
|
51
51
|
}
|
|
@@ -2,4 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
{{{ importTypes }}}
|
|
4
4
|
|
|
5
|
-
export type ChainJsonRpcApis<Rv extends RpcVersion> =
|
|
5
|
+
export type ChainJsonRpcApis<Rv extends RpcVersion> =
|
|
6
|
+
{{#if jsonRpcMethods.length}}
|
|
7
|
+
Pick<JsonRpcApis, {{{jsonRpcMethods}}}> & GenericJsonRpcApis<Rv>;
|
|
8
|
+
{{else}}
|
|
9
|
+
JsonRpcApis & GenericJsonRpcApis<Rv>;
|
|
10
|
+
{{/if}}
|
|
@@ -38,8 +38,10 @@ class JsonRpcGen extends ApiGen_js_1.ApiGen {
|
|
|
38
38
|
super(typesGen);
|
|
39
39
|
this.typesGen = typesGen;
|
|
40
40
|
this.rpcMethods = rpcMethods;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (rpcMethods.length > 0) {
|
|
42
|
+
HIDDEN_RPCS.filter((one) => !rpcMethods.includes(one)).forEach((one) => rpcMethods.push(one));
|
|
43
|
+
rpcMethods.sort();
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
generate(useSubPaths = false) {
|
|
45
47
|
this.typesGen.clearCache();
|
package/cjs/chaintypes/index.js
CHANGED
|
@@ -74,6 +74,6 @@ async function generateTypes(chain, metadata, rpcMethods, runtimeApis, outDir =
|
|
|
74
74
|
fs.writeFileSync(txFileName, await txGen.generate(useSubPaths));
|
|
75
75
|
fs.writeFileSync(indexFileName, await indexGen.generate(useSubPaths));
|
|
76
76
|
fs.writeFileSync(runtimeApisFileName, await runtimeApisGen.generate(useSubPaths));
|
|
77
|
-
return { interfaceName };
|
|
77
|
+
return { interfaceName, outputFolder: dirPath };
|
|
78
78
|
}
|
|
79
79
|
exports.generateTypes = generateTypes;
|
|
@@ -2,4 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
{{{ importTypes }}}
|
|
4
4
|
|
|
5
|
-
export type ChainJsonRpcApis<Rv extends RpcVersion> =
|
|
5
|
+
export type ChainJsonRpcApis<Rv extends RpcVersion> =
|
|
6
|
+
{{#if jsonRpcMethods.length}}
|
|
7
|
+
Pick<JsonRpcApis, {{{jsonRpcMethods}}}> & GenericJsonRpcApis<Rv>;
|
|
8
|
+
{{else}}
|
|
9
|
+
JsonRpcApis & GenericJsonRpcApis<Rv>;
|
|
10
|
+
{{/if}}
|
package/cjs/typink/index.js
CHANGED
|
@@ -38,6 +38,6 @@ async function generateContractTypes(metadata, contract, outDir = '.', extension
|
|
|
38
38
|
fs_1.default.writeFileSync(constructorTxTypesFileName, await constructorTxGen.generate(useSubPaths));
|
|
39
39
|
fs_1.default.writeFileSync(eventsTypesFile, await eventsGen.generate(useSubPaths));
|
|
40
40
|
fs_1.default.writeFileSync(indexTypesFileName, await indexGen.generate(useSubPaths));
|
|
41
|
-
return { interfaceName };
|
|
41
|
+
return { interfaceName, outputFolder: dirPath };
|
|
42
42
|
}
|
|
43
43
|
exports.generateContractTypes = generateContractTypes;
|
|
@@ -9,7 +9,7 @@ import { ContractEvents } from './events';
|
|
|
9
9
|
|
|
10
10
|
export * from './types';
|
|
11
11
|
|
|
12
|
-
export interface {{{interfaceName}}}<Rv extends RpcVersion =
|
|
12
|
+
export interface {{{interfaceName}}}<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends GenericContractApi<Rv, ChainApi> {
|
|
13
13
|
query: ContractQuery<ChainApi[Rv]>;
|
|
14
14
|
tx: ContractTx<ChainApi[Rv]>;
|
|
15
15
|
constructorQuery: ConstructorQuery<ChainApi[Rv]>;
|
package/cjs/utils.js
CHANGED
|
@@ -31,7 +31,7 @@ const fs = __importStar(require("fs"));
|
|
|
31
31
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
33
|
const prettier = __importStar(require("prettier"));
|
|
34
|
-
const
|
|
34
|
+
const dirname_js_1 = require("./dirname.js");
|
|
35
35
|
exports.WRAPPER_TYPE_REGEX = /^(\w+)<(.*)>$/;
|
|
36
36
|
exports.TUPLE_TYPE_REGEX = /^\[(.*)]$/;
|
|
37
37
|
const commentBlock = (...docs) => {
|
|
@@ -49,12 +49,12 @@ ${flatLines.map((line) => `* ${line.replaceAll(/\s+/g, ' ').trim()}`).join('\n')
|
|
|
49
49
|
};
|
|
50
50
|
exports.commentBlock = commentBlock;
|
|
51
51
|
const beautifySourceCode = async (source) => {
|
|
52
|
-
const prettierOptions = await prettier.resolveConfig(path.resolve((0,
|
|
52
|
+
const prettierOptions = await prettier.resolveConfig(path.resolve((0, dirname_js_1.currentDirname)(), '../../../.prettierrc.cjs'));
|
|
53
53
|
return prettier.format(source, { parser: 'babel-ts', ...prettierOptions });
|
|
54
54
|
};
|
|
55
55
|
exports.beautifySourceCode = beautifySourceCode;
|
|
56
56
|
const compileTemplate = (templateFile) => {
|
|
57
|
-
const templateFilePath = path.resolve((0,
|
|
57
|
+
const templateFilePath = path.resolve((0, dirname_js_1.currentDirname)(), templateFile);
|
|
58
58
|
return handlebars_1.default.compile(fs.readFileSync(templateFilePath, 'utf8'));
|
|
59
59
|
};
|
|
60
60
|
exports.compileTemplate = compileTemplate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/codegen",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
4
4
|
"description": "Generate types",
|
|
5
5
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
6
6
|
"homepage": "https://github.com/dedotdev/dedot/tree/main/packages/codegen",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"copy": "cp -R ./src/chaintypes/templates ./dist/chaintypes && cp -R ./src/chaintypes/templates ./dist/cjs/chaintypes && cp -R ./src/typink/templates ./dist/typink && cp -R ./src/typink/templates ./dist/cjs/typink"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dedot/api": "0.4.
|
|
22
|
-
"@dedot/codecs": "0.4.
|
|
23
|
-
"@dedot/contracts": "0.4.
|
|
24
|
-
"@dedot/providers": "0.4.
|
|
25
|
-
"@dedot/runtime-specs": "0.4.
|
|
26
|
-
"@dedot/shape": "0.4.
|
|
27
|
-
"@dedot/types": "0.4.
|
|
28
|
-
"@dedot/utils": "0.4.
|
|
21
|
+
"@dedot/api": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
22
|
+
"@dedot/codecs": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
23
|
+
"@dedot/contracts": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
24
|
+
"@dedot/providers": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
25
|
+
"@dedot/runtime-specs": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
26
|
+
"@dedot/shape": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
27
|
+
"@dedot/types": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
28
|
+
"@dedot/utils": "0.4.2-next.5d9d02c1.7+5d9d02c",
|
|
29
29
|
"handlebars": "^4.7.8",
|
|
30
30
|
"prettier": "^3.3.3"
|
|
31
31
|
},
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"directory": "dist"
|
|
35
35
|
},
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "5d9d02c17067074674ae588eb266a46f36742cb4",
|
|
38
38
|
"module": "./index.js",
|
|
39
39
|
"types": "./index.d.ts",
|
|
40
40
|
"exports": {
|
package/types.d.ts
CHANGED
package/typink/index.js
CHANGED
|
@@ -32,5 +32,5 @@ export async function generateContractTypes(metadata, contract, outDir = '.', ex
|
|
|
32
32
|
fs.writeFileSync(constructorTxTypesFileName, await constructorTxGen.generate(useSubPaths));
|
|
33
33
|
fs.writeFileSync(eventsTypesFile, await eventsGen.generate(useSubPaths));
|
|
34
34
|
fs.writeFileSync(indexTypesFileName, await indexGen.generate(useSubPaths));
|
|
35
|
-
return { interfaceName };
|
|
35
|
+
return { interfaceName, outputFolder: dirPath };
|
|
36
36
|
}
|
|
@@ -9,7 +9,7 @@ import { ContractEvents } from './events';
|
|
|
9
9
|
|
|
10
10
|
export * from './types';
|
|
11
11
|
|
|
12
|
-
export interface {{{interfaceName}}}<Rv extends RpcVersion =
|
|
12
|
+
export interface {{{interfaceName}}}<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends GenericContractApi<Rv, ChainApi> {
|
|
13
13
|
query: ContractQuery<ChainApi[Rv]>;
|
|
14
14
|
tx: ContractTx<ChainApi[Rv]>;
|
|
15
15
|
constructorQuery: ConstructorQuery<ChainApi[Rv]>;
|
package/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from 'fs';
|
|
|
2
2
|
import handlebars from 'handlebars';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import * as prettier from 'prettier';
|
|
5
|
-
import { currentDirname } from './dirname';
|
|
5
|
+
import { currentDirname } from './dirname.js';
|
|
6
6
|
export const WRAPPER_TYPE_REGEX = /^(\w+)<(.*)>$/;
|
|
7
7
|
export const TUPLE_TYPE_REGEX = /^\[(.*)]$/;
|
|
8
8
|
export const commentBlock = (...docs) => {
|