@dedot/cli 0.0.1-next.41a5fa17.16 → 0.0.1-next.4f5df6a3.2
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.
|
@@ -22,18 +22,36 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.chaintypes = void 0;
|
|
27
30
|
const path = __importStar(require("path"));
|
|
28
31
|
const codegen_1 = require("@dedot/codegen");
|
|
32
|
+
const codecs_1 = require("@dedot/codecs");
|
|
33
|
+
const dedot_1 = require("dedot");
|
|
34
|
+
const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
|
|
35
|
+
const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
|
|
29
36
|
exports.chaintypes = {
|
|
30
37
|
command: 'chaintypes',
|
|
31
38
|
describe: 'Generate chain types & APIs for a Substrate-based blockchain',
|
|
32
39
|
handler: async (yargs) => {
|
|
33
|
-
const { wsUrl, output = '', chain = '' } = yargs;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
40
|
+
const { wsUrl, output = '', chain = '', dts = true } = yargs;
|
|
41
|
+
const outDir = path.resolve(output);
|
|
42
|
+
const extension = dts ? 'd.ts' : 'ts';
|
|
43
|
+
if (wsUrl === 'substrate') {
|
|
44
|
+
console.log(`- Generating generic chaintypes`);
|
|
45
|
+
const metadataHex = substrate_hex_1.default;
|
|
46
|
+
const rpcMethods = static_substrate_1.rpc.methods;
|
|
47
|
+
const metadata = codecs_1.$Metadata.tryDecode(metadataHex);
|
|
48
|
+
const runtimeVersion = getRuntimeVersion(metadata);
|
|
49
|
+
await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeVersion.apis, outDir, extension);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(`- Generating chaintypes via endpoint ${wsUrl}`);
|
|
53
|
+
await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension);
|
|
54
|
+
}
|
|
37
55
|
console.log(`- DONE! Output: ${outDir}`);
|
|
38
56
|
},
|
|
39
57
|
builder: (yargs) => {
|
|
@@ -54,6 +72,20 @@ exports.chaintypes = {
|
|
|
54
72
|
type: 'string',
|
|
55
73
|
describe: 'Chain name',
|
|
56
74
|
alias: 'c',
|
|
75
|
+
})
|
|
76
|
+
.option('dts', {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
describe: 'Generate d.ts files',
|
|
79
|
+
alias: 'd',
|
|
80
|
+
default: true,
|
|
57
81
|
})); // TODO check to verify inputs
|
|
58
82
|
},
|
|
59
83
|
};
|
|
84
|
+
const getRuntimeVersion = (metadata) => {
|
|
85
|
+
const registry = new codecs_1.PortableRegistry(metadata.latest);
|
|
86
|
+
const executor = new dedot_1.ConstantExecutor({
|
|
87
|
+
registry,
|
|
88
|
+
metadataLatest: metadata.latest,
|
|
89
|
+
});
|
|
90
|
+
return executor.execute('system', 'version');
|
|
91
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/cli",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.4f5df6a3.2+4f5df6a",
|
|
4
4
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dedot": "./bin/dedot",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"start": "ts-node src/index.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@dedot/codegen": "0.0.1-next.
|
|
17
|
+
"@dedot/codegen": "0.0.1-next.4f5df6a3.2+4f5df6a",
|
|
18
|
+
"@polkadot/types-support": "^10.12.4",
|
|
18
19
|
"yargs": "^17.7.2"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
@@ -25,5 +26,5 @@
|
|
|
25
26
|
"directory": "dist"
|
|
26
27
|
},
|
|
27
28
|
"license": "Apache-2.0",
|
|
28
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "4f5df6a328a278f140f5e0f69ef4a92d96e4b34a"
|
|
29
30
|
}
|
package/cjs/packageInfo.d.ts
DELETED