@dedot/cli 0.4.2-next.5d9d02c1.7 → 0.6.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.
@@ -31,10 +31,10 @@ export const chaintypes = {
31
31
  spinner.succeed(`Parsed static substrate generic chaintypes`);
32
32
  }
33
33
  if (parsedResult) {
34
- const { metadata, runtimeVersion, runtimeApis, rpcMethods } = parsedResult;
34
+ const { metadata, runtimeVersion, rpcMethods } = parsedResult;
35
35
  const chainName = chain || stringCamelCase(runtimeVersion.specName) || (shouldGenerateGenericTypes ? 'substrate' : 'local');
36
36
  spinner.text = `Generating ${stringPascalCase(chainName)} generic chaintypes`;
37
- generatedResult = await generateTypes(chainName, metadata.latest, rpcMethods, runtimeApis, outDir, extension, subpath);
37
+ generatedResult = await generateTypes(chainName, metadata.latest, rpcMethods, runtimeVersion, outDir, extension, subpath);
38
38
  spinner.succeed(`Generated ${stringPascalCase(chainName)} generic chaintypes`);
39
39
  }
40
40
  else {
@@ -1,9 +1,9 @@
1
- import { Metadata, RuntimeVersion } from '@dedot/codecs';
1
+ import { SubstrateRuntimeVersion } from '@dedot/api';
2
+ import { Metadata } from '@dedot/codecs';
2
3
  export interface ParsedResult extends DecodedMetadataInfo {
3
4
  rpcMethods: string[];
4
5
  }
5
6
  export interface DecodedMetadataInfo {
6
7
  metadata: Metadata;
7
- runtimeVersion: RuntimeVersion;
8
- runtimeApis: Record<string, number>;
8
+ runtimeVersion: SubstrateRuntimeVersion;
9
9
  }
@@ -17,23 +17,24 @@ export const getRuntimeVersion = (metadata) => {
17
17
  export const decodeMetadata = (metadataHex) => {
18
18
  const metadata = $Metadata.tryDecode(metadataHex);
19
19
  const runtimeVersion = getRuntimeVersion(metadata);
20
- const runtimeApis = runtimeVersion.apis.reduce((acc, [name, version]) => {
20
+ const apis = runtimeVersion.apis.reduce((acc, [name, version]) => {
21
21
  acc[name] = version;
22
22
  return acc;
23
23
  }, {});
24
24
  return {
25
25
  metadata,
26
- runtimeVersion,
27
- runtimeApis,
26
+ runtimeVersion: {
27
+ ...runtimeVersion,
28
+ apis,
29
+ },
28
30
  };
29
31
  };
30
32
  export const parseMetadataFromRaw = async (metadataFile) => {
31
33
  const metadataHex = fs.readFileSync(metadataFile, 'utf-8').trim();
32
- const { metadata, runtimeVersion, runtimeApis } = decodeMetadata(metadataHex);
34
+ const { metadata, runtimeVersion } = decodeMetadata(metadataHex);
33
35
  return {
34
36
  metadata,
35
37
  runtimeVersion,
36
- runtimeApis,
37
38
  rpcMethods: [],
38
39
  };
39
40
  };
@@ -43,20 +44,18 @@ export const parseMetadataFromWasm = async (runtimeFile) => {
43
44
  const length = $.compactU32.tryDecode(u8aMetadata);
44
45
  const offset = $.compactU32.tryEncode(length).length;
45
46
  const metadataHex = u8aToHex(u8aMetadata.subarray(offset));
46
- const { metadata, runtimeVersion, runtimeApis } = decodeMetadata(metadataHex);
47
+ const { metadata, runtimeVersion } = decodeMetadata(metadataHex);
47
48
  return {
48
49
  metadata,
49
50
  runtimeVersion,
50
- runtimeApis,
51
51
  rpcMethods: [],
52
52
  };
53
53
  };
54
54
  export const parseStaticSubstrate = async () => {
55
- const { runtimeVersion, metadata, runtimeApis } = decodeMetadata(staticSubstrate);
55
+ const { runtimeVersion, metadata } = decodeMetadata(staticSubstrate);
56
56
  return {
57
57
  metadata,
58
58
  runtimeVersion,
59
- runtimeApis,
60
59
  rpcMethods: rpc.methods,
61
60
  };
62
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/cli",
3
- "version": "0.4.2-next.5d9d02c1.7+5d9d02c",
3
+ "version": "0.6.0",
4
4
  "author": "Thang X. Vu <thang@coongcrafts.io>",
5
5
  "homepage": "https://github.com/dedotdev/dedot/tree/main/packages/cli",
6
6
  "repository": {
@@ -18,15 +18,16 @@
18
18
  "scripts": {
19
19
  "build": "tsc --project tsconfig.build.json && cp -R ./bin ./dist",
20
20
  "clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo",
21
- "start": "ts-node src/index.ts"
21
+ "start": "ts-node src/index.ts",
22
+ "test": "vitest --watch=false"
22
23
  },
23
24
  "dependencies": {
24
- "@dedot/api": "0.4.2-next.5d9d02c1.7+5d9d02c",
25
- "@dedot/codecs": "0.4.2-next.5d9d02c1.7+5d9d02c",
26
- "@dedot/codegen": "0.4.2-next.5d9d02c1.7+5d9d02c",
25
+ "@dedot/api": "0.6.0",
26
+ "@dedot/codecs": "0.6.0",
27
+ "@dedot/codegen": "0.6.0",
27
28
  "@polkadot-api/wasm-executor": "^0.1.1",
28
- "@polkadot/types-support": "^12.3.1",
29
- "ora": "^8.0.1",
29
+ "@polkadot/types-support": "^14.0.1",
30
+ "ora": "^8.1.0",
30
31
  "yargs": "^17.7.2"
31
32
  },
32
33
  "devDependencies": {
@@ -37,7 +38,7 @@
37
38
  "directory": "dist"
38
39
  },
39
40
  "license": "Apache-2.0",
40
- "gitHead": "5d9d02c17067074674ae588eb266a46f36742cb4",
41
+ "gitHead": "80e64c7da483c4f5b757f6af7259aa4fdd5397fc",
41
42
  "module": "./index.js",
42
43
  "types": "./index.d.ts"
43
44
  }