@dedot/codegen 0.0.1-alpha.22 → 0.0.1-alpha.24
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/cjs/genSupportedChainTypes.js +4 -1
- package/cjs/generator/utils.js +31 -5
- package/cjs/index.js +31 -5
- package/cjs/packageInfo.js +1 -1
- package/index.js +7 -4
- package/package.json +7 -7
- package/packageInfo.js +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const index_1 = require("./index");
|
|
4
7
|
const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
|
|
5
|
-
const substrate_hex_1 = require("@polkadot/types-support/metadata/v15/substrate-hex");
|
|
8
|
+
const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
|
|
6
9
|
const codecs_1 = require("@dedot/codecs");
|
|
7
10
|
const dedot_1 = require("dedot");
|
|
8
11
|
const NETWORKS = [
|
package/cjs/generator/utils.js
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.isReservedWord = exports.compileTemplate = exports.beautifySourceCode = exports.resolveFilePath = exports.commentBlock = exports.TUPLE_TYPE_REGEX = exports.WRAPPER_TYPE_REGEX = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const handlebars_1 = require("handlebars");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const process = require("process");
|
|
8
|
-
const prettier = require("prettier");
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
32
|
+
const path = __importStar(require("path"));
|
|
33
|
+
const process = __importStar(require("process"));
|
|
34
|
+
const prettier = __importStar(require("prettier"));
|
|
9
35
|
exports.WRAPPER_TYPE_REGEX = /^(\w+)<(.*)>$/;
|
|
10
36
|
exports.TUPLE_TYPE_REGEX = /^\[(.*)]$/;
|
|
11
37
|
const commentBlock = (...docs) => {
|
package/cjs/index.js
CHANGED
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.generateTypes = exports.generateTypesFromChain = void 0;
|
|
4
27
|
const dedot_1 = require("dedot");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const process = require("process");
|
|
28
|
+
const fs = __importStar(require("fs"));
|
|
29
|
+
const path = __importStar(require("path"));
|
|
8
30
|
const generator_1 = require("./generator");
|
|
31
|
+
const util_1 = require("@polkadot/util");
|
|
9
32
|
async function generateTypesFromChain(network, endpoint, outDir) {
|
|
10
33
|
const api = await dedot_1.Dedot.create(endpoint);
|
|
11
34
|
const { methods } = await api.rpc.rpc.methods();
|
|
12
35
|
const apis = api.runtimeVersion?.apis || [];
|
|
36
|
+
if (!network.chain) {
|
|
37
|
+
network.chain = (0, util_1.stringCamelCase)(api.runtimeVersion?.specName || api.runtimeChain || 'local');
|
|
38
|
+
}
|
|
13
39
|
await generateTypes(network, api.metadataLatest, methods, apis, outDir);
|
|
14
40
|
await api.disconnect();
|
|
15
41
|
}
|
|
16
42
|
exports.generateTypesFromChain = generateTypesFromChain;
|
|
17
43
|
async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir = '.') {
|
|
18
|
-
const dirPath = path.resolve(
|
|
44
|
+
const dirPath = path.resolve(outDir, network.chain);
|
|
19
45
|
const defTypesFileName = path.join(dirPath, `types.ts`);
|
|
20
46
|
const constsTypesFileName = path.join(dirPath, `consts.ts`);
|
|
21
47
|
const queryTypesFileName = path.join(dirPath, `query.ts`);
|
|
@@ -26,7 +52,7 @@ async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir
|
|
|
26
52
|
const runtimeApisFileName = path.join(dirPath, `runtime.ts`);
|
|
27
53
|
const txFileName = path.join(dirPath, `tx.ts`);
|
|
28
54
|
if (!fs.existsSync(dirPath)) {
|
|
29
|
-
fs.mkdirSync(dirPath);
|
|
55
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
30
56
|
}
|
|
31
57
|
const typesGen = new generator_1.TypesGen(metadata);
|
|
32
58
|
const constsGen = new generator_1.ConstsGen(typesGen);
|
package/cjs/packageInfo.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.packageInfo = void 0;
|
|
5
|
-
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.
|
|
5
|
+
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.23' };
|
package/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Dedot } from 'dedot';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { ConstsGen, ErrorsGen, EventsGen, IndexGen, QueryGen, RpcGen, RuntimeApisGen, TxGen, TypesGen, } from './generator';
|
|
5
|
+
import { stringCamelCase } from '@polkadot/util';
|
|
6
6
|
export async function generateTypesFromChain(network, endpoint, outDir) {
|
|
7
7
|
const api = await Dedot.create(endpoint);
|
|
8
8
|
const { methods } = await api.rpc.rpc.methods();
|
|
9
9
|
const apis = api.runtimeVersion?.apis || [];
|
|
10
|
+
if (!network.chain) {
|
|
11
|
+
network.chain = stringCamelCase(api.runtimeVersion?.specName || api.runtimeChain || 'local');
|
|
12
|
+
}
|
|
10
13
|
await generateTypes(network, api.metadataLatest, methods, apis, outDir);
|
|
11
14
|
await api.disconnect();
|
|
12
15
|
}
|
|
13
16
|
export async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir = '.') {
|
|
14
|
-
const dirPath = path.resolve(
|
|
17
|
+
const dirPath = path.resolve(outDir, network.chain);
|
|
15
18
|
const defTypesFileName = path.join(dirPath, `types.ts`);
|
|
16
19
|
const constsTypesFileName = path.join(dirPath, `consts.ts`);
|
|
17
20
|
const queryTypesFileName = path.join(dirPath, `query.ts`);
|
|
@@ -22,7 +25,7 @@ export async function generateTypes(network, metadata, rpcMethods, runtimeApis,
|
|
|
22
25
|
const runtimeApisFileName = path.join(dirPath, `runtime.ts`);
|
|
23
26
|
const txFileName = path.join(dirPath, `tx.ts`);
|
|
24
27
|
if (!fs.existsSync(dirPath)) {
|
|
25
|
-
fs.mkdirSync(dirPath);
|
|
28
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
26
29
|
}
|
|
27
30
|
const typesGen = new TypesGen(metadata);
|
|
28
31
|
const constsGen = new ConstsGen(typesGen);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/codegen",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.24",
|
|
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",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dedot/codecs": "0.0.1-alpha.
|
|
20
|
-
"@dedot/shape": "0.0.1-alpha.
|
|
21
|
-
"@dedot/specs": "0.0.1-alpha.
|
|
22
|
-
"@dedot/utils": "0.0.1-alpha.
|
|
19
|
+
"@dedot/codecs": "0.0.1-alpha.24",
|
|
20
|
+
"@dedot/shape": "0.0.1-alpha.24",
|
|
21
|
+
"@dedot/specs": "0.0.1-alpha.24",
|
|
22
|
+
"@dedot/utils": "0.0.1-alpha.24",
|
|
23
23
|
"@polkadot/util": "^12.6.2",
|
|
24
|
-
"dedot": "0.0.1-alpha.
|
|
24
|
+
"dedot": "0.0.1-alpha.24",
|
|
25
25
|
"handlebars": "^4.7.8",
|
|
26
26
|
"prettier": "^3.0.3"
|
|
27
27
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"directory": "dist"
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "1f9e0958a787fbbd99b965e1955d7cdce076ca28",
|
|
34
34
|
"module": "./index.js",
|
|
35
35
|
"types": "./index.d.ts",
|
|
36
36
|
"exports": {
|
package/packageInfo.js
CHANGED