@dedot/cli 0.0.1-next.fecbe32d.13 → 0.1.0
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 +11 -5
- package/cjs/commands/index.d.ts +1 -0
- package/cjs/commands/index.js +1 -0
- package/cjs/commands/typink.d.ts +10 -0
- package/cjs/commands/typink.js +76 -0
- package/cjs/dedot.js +1 -0
- package/package.json +12 -4
|
@@ -29,15 +29,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.chaintypes = void 0;
|
|
30
30
|
const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
|
|
31
31
|
const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
|
|
32
|
+
const api_1 = require("@dedot/api");
|
|
32
33
|
const codecs_1 = require("@dedot/codecs");
|
|
33
34
|
const codegen_1 = require("@dedot/codegen");
|
|
34
|
-
const dedot_1 = require("dedot");
|
|
35
35
|
const path = __importStar(require("path"));
|
|
36
36
|
exports.chaintypes = {
|
|
37
37
|
command: 'chaintypes',
|
|
38
38
|
describe: 'Generate chain types & APIs for a Substrate-based blockchain',
|
|
39
39
|
handler: async (yargs) => {
|
|
40
|
-
const { wsUrl, output = '', chain = '', dts = true } = yargs;
|
|
40
|
+
const { wsUrl, output = '', chain = '', dts = true, subpath = true } = yargs;
|
|
41
41
|
const outDir = path.resolve(output);
|
|
42
42
|
const extension = dts ? 'd.ts' : 'ts';
|
|
43
43
|
if (wsUrl === 'substrate') {
|
|
@@ -50,11 +50,11 @@ exports.chaintypes = {
|
|
|
50
50
|
acc[name] = version;
|
|
51
51
|
return acc;
|
|
52
52
|
}, {});
|
|
53
|
-
await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeApis, outDir, extension);
|
|
53
|
+
await (0, codegen_1.generateTypes)('substrate', metadata.latest, rpcMethods, runtimeApis, outDir, extension, subpath);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
console.log(`- Generating chaintypes via endpoint ${wsUrl}`);
|
|
57
|
-
await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension);
|
|
57
|
+
await (0, codegen_1.generateTypesFromEndpoint)(chain, wsUrl, outDir, extension, subpath);
|
|
58
58
|
}
|
|
59
59
|
console.log(`- DONE! Output: ${outDir}`);
|
|
60
60
|
},
|
|
@@ -82,12 +82,18 @@ exports.chaintypes = {
|
|
|
82
82
|
describe: 'Generate d.ts files',
|
|
83
83
|
alias: 'd',
|
|
84
84
|
default: true,
|
|
85
|
+
})
|
|
86
|
+
.option('subpath', {
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
describe: 'Using subpath for shared packages',
|
|
89
|
+
alias: 's',
|
|
90
|
+
default: true,
|
|
85
91
|
})); // TODO check to verify inputs
|
|
86
92
|
},
|
|
87
93
|
};
|
|
88
94
|
const getRuntimeVersion = (metadata) => {
|
|
89
95
|
const registry = new codecs_1.PortableRegistry(metadata.latest);
|
|
90
|
-
const executor = new
|
|
96
|
+
const executor = new api_1.ConstantExecutor({
|
|
91
97
|
registry,
|
|
92
98
|
metadata,
|
|
93
99
|
});
|
package/cjs/commands/index.d.ts
CHANGED
package/cjs/commands/index.js
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.typink = void 0;
|
|
27
|
+
const codegen_1 = require("@dedot/codegen");
|
|
28
|
+
const utils_1 = require("@dedot/utils");
|
|
29
|
+
const fs = __importStar(require("node:fs"));
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
exports.typink = {
|
|
32
|
+
command: 'typink',
|
|
33
|
+
describe: 'Generate types & APIs for a ink! smart contracts',
|
|
34
|
+
handler: async (yargs) => {
|
|
35
|
+
const { contract, output = '', metadata, dts = true, subpath = true } = yargs;
|
|
36
|
+
(0, utils_1.assert)(metadata, 'Metadata file is required, -h or --help to known more about the command');
|
|
37
|
+
const outDir = path.resolve(output);
|
|
38
|
+
const metadataFile = path.resolve(metadata);
|
|
39
|
+
const extension = dts ? 'd.ts' : 'ts';
|
|
40
|
+
const rawMetadata = fs.readFileSync(metadataFile, 'utf-8');
|
|
41
|
+
console.log(`- Generating contract types via metadata ${metadata}`);
|
|
42
|
+
await (0, codegen_1.generateContractTypes)(rawMetadata, contract, outDir, extension, subpath);
|
|
43
|
+
console.log(`- DONE! Output: ${outDir}`);
|
|
44
|
+
},
|
|
45
|
+
builder: (yargs) => {
|
|
46
|
+
return yargs
|
|
47
|
+
.option('metadata', {
|
|
48
|
+
type: 'string',
|
|
49
|
+
describe: 'Path to contract metadata file (.json, .contract)',
|
|
50
|
+
alias: 'm',
|
|
51
|
+
demandOption: true,
|
|
52
|
+
})
|
|
53
|
+
.option('output', {
|
|
54
|
+
type: 'string',
|
|
55
|
+
describe: 'Output folder to put generated files',
|
|
56
|
+
alias: 'o',
|
|
57
|
+
})
|
|
58
|
+
.option('contract', {
|
|
59
|
+
type: 'string',
|
|
60
|
+
describe: 'Contract name',
|
|
61
|
+
alias: 'c',
|
|
62
|
+
})
|
|
63
|
+
.option('dts', {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
describe: 'Generate d.ts files',
|
|
66
|
+
alias: 'd',
|
|
67
|
+
default: true,
|
|
68
|
+
})
|
|
69
|
+
.option('subpath', {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
describe: 'Using subpath for shared packages',
|
|
72
|
+
alias: 's',
|
|
73
|
+
default: true,
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
};
|
package/cjs/dedot.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
5
|
+
"homepage": "https://github.com/dedotdev/dedot/tree/main/packages/cli",
|
|
6
|
+
"repository": {
|
|
7
|
+
"directory": "packages/cli",
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dedotdev/dedot.git"
|
|
10
|
+
},
|
|
5
11
|
"bin": {
|
|
6
12
|
"dedot": "./bin/dedot",
|
|
7
13
|
"djs": "./bin/dedot"
|
|
@@ -14,8 +20,10 @@
|
|
|
14
20
|
"start": "ts-node src/index.ts"
|
|
15
21
|
},
|
|
16
22
|
"dependencies": {
|
|
17
|
-
"@dedot/
|
|
18
|
-
"@
|
|
23
|
+
"@dedot/api": "0.1.0",
|
|
24
|
+
"@dedot/codecs": "0.1.0",
|
|
25
|
+
"@dedot/codegen": "0.1.0",
|
|
26
|
+
"@polkadot/types-support": "^12.2.1",
|
|
19
27
|
"yargs": "^17.7.2"
|
|
20
28
|
},
|
|
21
29
|
"devDependencies": {
|
|
@@ -26,5 +34,5 @@
|
|
|
26
34
|
"directory": "dist"
|
|
27
35
|
},
|
|
28
36
|
"license": "Apache-2.0",
|
|
29
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c8220a4ab4b171fe04adb49759318bde865d7c17"
|
|
30
38
|
}
|