@dedot/codegen 0.0.1-next.324f6c64.55 → 0.0.1-next.358b8686.56
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/generator/ConstsGen.js +1 -1
- package/cjs/generator/ErrorsGen.js +1 -1
- package/cjs/generator/EventsGen.js +1 -1
- package/cjs/generator/IndexGen.js +1 -1
- package/cjs/generator/JsonRpcGen.js +4 -4
- package/cjs/generator/QueryGen.js +1 -1
- package/cjs/generator/RuntimeApisGen.js +2 -2
- package/cjs/generator/TxGen.js +1 -1
- package/cjs/generator/TypesGen.js +2 -2
- package/cjs/generator/known-codecs.js +8 -8
- package/cjs/index.js +4 -3
- package/generator/ApiGen.d.ts +1 -1
- package/generator/ConstsGen.js +1 -1
- package/generator/ErrorsGen.js +1 -1
- package/generator/EventsGen.js +1 -1
- package/generator/IndexGen.js +1 -1
- package/generator/JsonRpcGen.d.ts +2 -1
- package/generator/JsonRpcGen.js +2 -2
- package/generator/QueryGen.js +1 -1
- package/generator/RuntimeApisGen.js +2 -2
- package/generator/TxGen.js +1 -1
- package/generator/TypesGen.d.ts +1 -1
- package/generator/TypesGen.js +2 -2
- package/generator/known-codecs.d.ts +2 -2
- package/generator/known-codecs.js +4 -4
- package/index.d.ts +1 -1
- package/index.js +3 -2
- package/package.json +9 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConstsGen = void 0;
|
|
4
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
5
|
const ApiGen_js_1 = require("./ApiGen.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
class ConstsGen extends ApiGen_js_1.ApiGen {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorsGen = void 0;
|
|
4
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
5
|
const ApiGen_js_1 = require("./ApiGen.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
class ErrorsGen extends ApiGen_js_1.ApiGen {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventsGen = void 0;
|
|
4
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
5
|
const ApiGen_js_1 = require("./ApiGen.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
class EventsGen extends ApiGen_js_1.ApiGen {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonRpcGen = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const api_1 = require("@dedot/api");
|
|
5
|
+
const ApiGen_js_1 = require("./ApiGen.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
const HIDDEN_RPCS = [
|
|
8
8
|
// Ref: https://github.com/paritytech/polkadot-sdk/blob/43415ef58c143b985e09015cd000dbd65f6d3997/substrate/client/rpc-servers/src/lib.rs#L152C9-L158
|
|
@@ -31,7 +31,7 @@ const ALIAS_RPCS = [
|
|
|
31
31
|
'chain_subscribeFinalisedHeads',
|
|
32
32
|
'chain_unsubscribeFinalisedHeads',
|
|
33
33
|
];
|
|
34
|
-
class JsonRpcGen extends
|
|
34
|
+
class JsonRpcGen extends ApiGen_js_1.ApiGen {
|
|
35
35
|
typesGen;
|
|
36
36
|
rpcMethods;
|
|
37
37
|
constructor(typesGen, rpcMethods) {
|
|
@@ -45,7 +45,7 @@ class JsonRpcGen extends index_js_1.ApiGen {
|
|
|
45
45
|
this.typesGen.clearCache();
|
|
46
46
|
this.typesGen.typeImports.addKnownType('GenericJsonRpcApis', 'RpcVersion');
|
|
47
47
|
this.typesGen.typeImports.addKnownJsonRpcType('JsonRpcApis');
|
|
48
|
-
const toExclude = Object.values(
|
|
48
|
+
const toExclude = Object.values(api_1.subscriptionsInfo).flat();
|
|
49
49
|
const importTypes = this.typesGen.typeImports.toImports({ useSubPaths });
|
|
50
50
|
const template = (0, utils_js_1.compileTemplate)('json-rpc.hbs');
|
|
51
51
|
const jsonRpcMethods = this.rpcMethods
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueryGen = void 0;
|
|
4
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
5
|
const ApiGen_js_1 = require("./ApiGen.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
class QueryGen extends ApiGen_js_1.ApiGen {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RuntimeApisGen = void 0;
|
|
4
|
-
const runtime_specs_1 = require("dedot/runtime-specs");
|
|
5
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const runtime_specs_1 = require("@dedot/runtime-specs");
|
|
5
|
+
const utils_1 = require("@dedot/utils");
|
|
6
6
|
const ApiGen_js_1 = require("./ApiGen.js");
|
|
7
7
|
const known_codecs_js_1 = require("./known-codecs.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
package/cjs/generator/TxGen.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TxGen = void 0;
|
|
4
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
5
|
const index_js_1 = require("../generator/index.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
class TxGen extends index_js_1.ApiGen {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypesGen = exports.BASIC_KNOWN_TYPES = void 0;
|
|
4
|
-
const codecs_1 = require("dedot/codecs");
|
|
5
|
-
const utils_1 = require("dedot/utils");
|
|
4
|
+
const codecs_1 = require("@dedot/codecs");
|
|
5
|
+
const utils_1 = require("@dedot/utils");
|
|
6
6
|
const TypeImports_js_1 = require("./TypeImports.js");
|
|
7
7
|
const known_codecs_js_1 = require("./known-codecs.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.isKnownCodecType = exports.findKnownWrapperCodec = exports.findKnownCodec = exports.findKnownCodecType = exports.looseTypeCodecs = exports.normalizeCodecName = void 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const utils_1 = require("dedot/utils");
|
|
27
|
+
const Codecs = __importStar(require("@dedot/codecs"));
|
|
28
|
+
const codecs_1 = require("@dedot/codecs");
|
|
29
|
+
const $ = __importStar(require("@dedot/shape"));
|
|
30
|
+
const utils_1 = require("@dedot/utils");
|
|
31
31
|
const normalizeCodecName = (name) => {
|
|
32
32
|
return name.startsWith('$') ? name : `$${name}`;
|
|
33
33
|
};
|
|
@@ -96,7 +96,7 @@ function findKnownCodecType(name) {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
const $codec = findKnownCodec(name);
|
|
99
|
-
if ($codec.nativeType &&
|
|
99
|
+
if ($codec.nativeType && $[name]) {
|
|
100
100
|
return {
|
|
101
101
|
name: normalizedName,
|
|
102
102
|
$codec,
|
|
@@ -114,7 +114,7 @@ function findKnownCodecType(name) {
|
|
|
114
114
|
exports.findKnownCodecType = findKnownCodecType;
|
|
115
115
|
function findKnownCodec(typeName) {
|
|
116
116
|
// @ts-ignore
|
|
117
|
-
const $codec = findKnownWrapperCodec(typeName) || Codecs[(0, exports.normalizeCodecName)(typeName)] ||
|
|
117
|
+
const $codec = findKnownWrapperCodec(typeName) || Codecs[(0, exports.normalizeCodecName)(typeName)] || $[typeName];
|
|
118
118
|
(0, utils_1.assert)($codec, `Known codec not found - ${typeName}`);
|
|
119
119
|
return $codec;
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ function findKnownWrapperCodec(typeName) {
|
|
|
125
125
|
const [_, wrapper, inner] = matchNames;
|
|
126
126
|
if (KNOWN_WRAPPER_TYPES.includes(wrapper)) {
|
|
127
127
|
// @ts-ignore
|
|
128
|
-
const $Wrapper =
|
|
128
|
+
const $Wrapper = $[wrapper];
|
|
129
129
|
if (inner.match(TUPLE_TYPE_REGEX) || inner.match(WRAPPER_TYPE_REGEX)) {
|
|
130
130
|
return $Wrapper(findKnownWrapperCodec(inner));
|
|
131
131
|
}
|
|
@@ -140,7 +140,7 @@ function findKnownWrapperCodec(typeName) {
|
|
|
140
140
|
.split(',')
|
|
141
141
|
.filter((x) => x)
|
|
142
142
|
.map((one) => findKnownCodec(one.trim()));
|
|
143
|
-
return
|
|
143
|
+
return $.Tuple(...$inner);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
exports.findKnownWrapperCodec = findKnownWrapperCodec;
|
package/cjs/index.js
CHANGED
|
@@ -24,13 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.generateTypes = exports.generateTypesFromEndpoint = void 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const api_1 = require("@dedot/api");
|
|
28
|
+
const providers_1 = require("@dedot/providers");
|
|
29
|
+
const utils_1 = require("@dedot/utils");
|
|
29
30
|
const fs = __importStar(require("fs"));
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
32
|
const index_js_1 = require("./generator/index.js");
|
|
32
33
|
async function generateTypesFromEndpoint(chain, endpoint, outDir, extension = 'd.ts', useSubPaths = false) {
|
|
33
|
-
const api = await
|
|
34
|
+
const api = await api_1.Dedot.new(new providers_1.WsProvider(endpoint));
|
|
34
35
|
const { methods } = await api.rpc.rpc_methods();
|
|
35
36
|
const apis = api.runtimeVersion.apis || {};
|
|
36
37
|
if (!chain) {
|
package/generator/ApiGen.d.ts
CHANGED
package/generator/ConstsGen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeName, stringCamelCase } from 'dedot/utils';
|
|
1
|
+
import { normalizeName, stringCamelCase } from '@dedot/utils';
|
|
2
2
|
import { ApiGen } from './ApiGen.js';
|
|
3
3
|
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
4
4
|
export class ConstsGen extends ApiGen {
|
package/generator/ErrorsGen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert, stringCamelCase, stringPascalCase } from 'dedot/utils';
|
|
1
|
+
import { assert, stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
2
2
|
import { ApiGen } from './ApiGen.js';
|
|
3
3
|
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
4
4
|
export class ErrorsGen extends ApiGen {
|
package/generator/EventsGen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert, stringCamelCase, stringPascalCase } from 'dedot/utils';
|
|
1
|
+
import { assert, stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
2
2
|
import { ApiGen } from './ApiGen.js';
|
|
3
3
|
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
4
4
|
export class EventsGen extends ApiGen {
|
package/generator/IndexGen.js
CHANGED
package/generator/JsonRpcGen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { subscriptionsInfo } from 'dedot';
|
|
2
|
-
import { ApiGen } from '
|
|
1
|
+
import { subscriptionsInfo } from '@dedot/api';
|
|
2
|
+
import { ApiGen } from './ApiGen.js';
|
|
3
3
|
import { beautifySourceCode, compileTemplate } from './utils.js';
|
|
4
4
|
const HIDDEN_RPCS = [
|
|
5
5
|
// Ref: https://github.com/paritytech/polkadot-sdk/blob/43415ef58c143b985e09015cd000dbd65f6d3997/substrate/client/rpc-servers/src/lib.rs#L152C9-L158
|
package/generator/QueryGen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeName, stringCamelCase } from 'dedot/utils';
|
|
1
|
+
import { normalizeName, stringCamelCase } from '@dedot/utils';
|
|
2
2
|
import { ApiGen } from './ApiGen.js';
|
|
3
3
|
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
4
4
|
export class QueryGen extends ApiGen {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getRuntimeApiNames, getRuntimeApiSpecs } from 'dedot/runtime-specs';
|
|
2
|
-
import { calcRuntimeApiHash, stringSnakeCase, stringCamelCase } from 'dedot/utils';
|
|
1
|
+
import { getRuntimeApiNames, getRuntimeApiSpecs } from '@dedot/runtime-specs';
|
|
2
|
+
import { calcRuntimeApiHash, stringSnakeCase, stringCamelCase } from '@dedot/utils';
|
|
3
3
|
import { ApiGen } from './ApiGen.js';
|
|
4
4
|
import { findKnownCodecType } from './known-codecs.js';
|
|
5
5
|
import { beautifySourceCode, commentBlock, compileTemplate, isNativeType, TUPLE_TYPE_REGEX, WRAPPER_TYPE_REGEX, } from './utils.js';
|
package/generator/TxGen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringCamelCase, stringPascalCase } from 'dedot/utils';
|
|
1
|
+
import { stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
2
2
|
import { ApiGen } from '../generator/index.js';
|
|
3
3
|
import { beautifySourceCode, commentBlock, compileTemplate, isReservedWord } from './utils.js';
|
|
4
4
|
export class TxGen extends ApiGen {
|
package/generator/TypesGen.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, MetadataLatest, PortableRegistry, PortableType, TypeId } from 'dedot/codecs';
|
|
1
|
+
import { Field, MetadataLatest, PortableRegistry, PortableType, TypeId } from '@dedot/codecs';
|
|
2
2
|
import { TypeImports } from './TypeImports.js';
|
|
3
3
|
interface NamedType extends PortableType {
|
|
4
4
|
name: string;
|
package/generator/TypesGen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PortableRegistry } from 'dedot/codecs';
|
|
2
|
-
import { normalizeName, stringPascalCase } from 'dedot/utils';
|
|
1
|
+
import { PortableRegistry } from '@dedot/codecs';
|
|
2
|
+
import { normalizeName, stringPascalCase } from '@dedot/utils';
|
|
3
3
|
import { TypeImports } from './TypeImports.js';
|
|
4
4
|
import { findKnownCodec, findKnownCodecType, isKnownCodecType } from './known-codecs.js';
|
|
5
5
|
import { beautifySourceCode, commentBlock, compileTemplate, isNativeType } from './utils.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { assert } from 'dedot/utils';
|
|
1
|
+
import * as Codecs from '@dedot/codecs';
|
|
2
|
+
import { $AccountId20, $AccountId32, $Bytes, $ConsensusEngineId, $Era, $EthereumAddress, $MultiAddress, $OpaqueExtrinsic, $PrefixedStorageKey, $RawBytes, $StorageData, $StorageKey, $UncheckedExtrinsic, } from '@dedot/codecs';
|
|
3
|
+
import * as $ from '@dedot/shape';
|
|
4
|
+
import { assert } from '@dedot/utils';
|
|
5
5
|
export const normalizeCodecName = (name) => {
|
|
6
6
|
return name.startsWith('$') ? name : `$${name}`;
|
|
7
7
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MetadataLatest } from 'dedot/codecs';
|
|
1
|
+
import { MetadataLatest } from '@dedot/codecs';
|
|
2
2
|
export declare function generateTypesFromEndpoint(chain: string, endpoint: string, outDir?: string, extension?: string, useSubPaths?: boolean): Promise<void>;
|
|
3
3
|
export declare function generateTypes(chain: string, metadata: MetadataLatest, rpcMethods: string[], runtimeApis: Record<string, number>, outDir?: string, extension?: string, useSubPaths?: boolean): Promise<void>;
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Dedot
|
|
2
|
-
import {
|
|
1
|
+
import { Dedot } from '@dedot/api';
|
|
2
|
+
import { WsProvider } from '@dedot/providers';
|
|
3
|
+
import { stringCamelCase } from '@dedot/utils';
|
|
3
4
|
import * as fs from 'fs';
|
|
4
5
|
import * as path from 'path';
|
|
5
6
|
import { ConstsGen, ErrorsGen, EventsGen, IndexGen, JsonRpcGen, QueryGen, RuntimeApisGen, TxGen, TypesGen, } from './generator/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/codegen",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.358b8686.56+358b868",
|
|
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,7 +18,13 @@
|
|
|
18
18
|
"copy": "cp -R ./src/templates ./dist && cp -R ./src/templates ./dist/cjs"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"dedot": "0.0.1-next.
|
|
21
|
+
"@dedot/api": "0.0.1-next.358b8686.56+358b868",
|
|
22
|
+
"@dedot/codecs": "0.0.1-next.358b8686.56+358b868",
|
|
23
|
+
"@dedot/providers": "0.0.1-next.358b8686.56+358b868",
|
|
24
|
+
"@dedot/runtime-specs": "0.0.1-next.358b8686.56+358b868",
|
|
25
|
+
"@dedot/shape": "0.0.1-next.358b8686.56+358b868",
|
|
26
|
+
"@dedot/types": "0.0.1-next.358b8686.56+358b868",
|
|
27
|
+
"@dedot/utils": "0.0.1-next.358b8686.56+358b868",
|
|
22
28
|
"handlebars": "^4.7.7",
|
|
23
29
|
"prettier": "^3.2.5"
|
|
24
30
|
},
|
|
@@ -27,7 +33,7 @@
|
|
|
27
33
|
"directory": "dist"
|
|
28
34
|
},
|
|
29
35
|
"license": "Apache-2.0",
|
|
30
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "358b8686aa63d09083aed391ccd7c7eba094b8f3",
|
|
31
37
|
"module": "./index.js",
|
|
32
38
|
"types": "./index.d.ts",
|
|
33
39
|
"exports": {
|