@dedot/cli 0.0.1-next.3 → 0.0.1-next.3662494a.39
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/commands/chaintypes.d.ts +1 -0
- package/cjs/commands/chaintypes.js +41 -5
- package/cjs/commands/index.d.ts +1 -1
- package/cjs/commands/index.js +1 -1
- package/cjs/dedot.js +2 -2
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +3 -3
- package/package.json +5 -3
- package/cjs/packageInfo.d.ts +0 -4
- package/cjs/packageInfo.js +0 -5
|
@@ -22,18 +22,40 @@ 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
|
-
const
|
|
30
|
+
const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
|
|
31
|
+
const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
|
|
32
|
+
const codecs_1 = require("@dedot/codecs");
|
|
28
33
|
const codegen_1 = require("@dedot/codegen");
|
|
34
|
+
const dedot_1 = require("dedot");
|
|
35
|
+
const path = __importStar(require("path"));
|
|
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
|
+
const runtimeApis = runtimeVersion.apis.reduce((acc, [name, version]) => {
|
|
50
|
+
acc[name] = version;
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeApis, outDir, extension);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.log(`- Generating chaintypes via endpoint ${wsUrl}`);
|
|
57
|
+
await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension);
|
|
58
|
+
}
|
|
37
59
|
console.log(`- DONE! Output: ${outDir}`);
|
|
38
60
|
},
|
|
39
61
|
builder: (yargs) => {
|
|
@@ -54,6 +76,20 @@ exports.chaintypes = {
|
|
|
54
76
|
type: 'string',
|
|
55
77
|
describe: 'Chain name',
|
|
56
78
|
alias: 'c',
|
|
79
|
+
})
|
|
80
|
+
.option('dts', {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
describe: 'Generate d.ts files',
|
|
83
|
+
alias: 'd',
|
|
84
|
+
default: true,
|
|
57
85
|
})); // TODO check to verify inputs
|
|
58
86
|
},
|
|
59
87
|
};
|
|
88
|
+
const getRuntimeVersion = (metadata) => {
|
|
89
|
+
const registry = new codecs_1.PortableRegistry(metadata.latest);
|
|
90
|
+
const executor = new dedot_1.ConstantExecutor({
|
|
91
|
+
registry,
|
|
92
|
+
metadata,
|
|
93
|
+
});
|
|
94
|
+
return executor.execute('system', 'version');
|
|
95
|
+
};
|
package/cjs/commands/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './chaintypes';
|
|
1
|
+
export * from './chaintypes.js';
|
package/cjs/commands/index.js
CHANGED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./chaintypes"), exports);
|
|
17
|
+
__exportStar(require("./chaintypes.js"), exports);
|
package/cjs/dedot.js
CHANGED
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.dedot = void 0;
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
8
|
const helpers_1 = require("yargs/helpers");
|
|
9
|
-
const
|
|
9
|
+
const index_js_1 = require("./commands/index.js");
|
|
10
10
|
const dedot = () => {
|
|
11
11
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
12
12
|
.scriptName('dedot')
|
|
13
13
|
.showHelpOnFail(true)
|
|
14
|
-
.command(
|
|
14
|
+
.command(index_js_1.chaintypes)
|
|
15
15
|
.help('help', 'Show help instructions')
|
|
16
16
|
.alias('h', 'help')
|
|
17
17
|
.alias('v', 'version')
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { dedot } from './dedot';
|
|
1
|
+
import { dedot } from './dedot.js';
|
|
2
2
|
export { dedot };
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dedot = void 0;
|
|
4
|
-
const
|
|
5
|
-
Object.defineProperty(exports, "dedot", { enumerable: true, get: function () { return
|
|
4
|
+
const dedot_js_1 = require("./dedot.js");
|
|
5
|
+
Object.defineProperty(exports, "dedot", { enumerable: true, get: function () { return dedot_js_1.dedot; } });
|
|
6
6
|
// We run this directly for development purpose via ts-node
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
if (process[Symbol.for('ts-node.register.instance')]) {
|
|
9
|
-
(0,
|
|
9
|
+
(0, dedot_js_1.dedot)();
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/cli",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.3662494a.39+3662494",
|
|
4
4
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dedot": "./bin/dedot",
|
|
7
7
|
"djs": "./bin/dedot"
|
|
8
8
|
},
|
|
9
9
|
"main": "./cjs/index.js",
|
|
10
|
+
"sideEffects": false,
|
|
10
11
|
"scripts": {
|
|
11
12
|
"build": "tsc --project tsconfig.build.cjs.json && cp -R ./bin ./dist",
|
|
12
13
|
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.cjs.tsbuildinfo && rm -rf ./src/codegen",
|
|
13
14
|
"start": "ts-node src/index.ts"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@dedot/codegen": "0.0.1-next.
|
|
17
|
+
"@dedot/codegen": "0.0.1-next.3662494a.39+3662494",
|
|
18
|
+
"@polkadot/types-support": "^11.0.2",
|
|
17
19
|
"yargs": "^17.7.2"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
@@ -24,5 +26,5 @@
|
|
|
24
26
|
"directory": "dist"
|
|
25
27
|
},
|
|
26
28
|
"license": "Apache-2.0",
|
|
27
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "3662494a12d632c9e3c2315544c652fe6e92929d"
|
|
28
30
|
}
|
package/cjs/packageInfo.d.ts
DELETED