Compare commits

..
8 Commits
Author SHA1 Message Date
github-actions[bot] eab2f76884 [CI Skip] release/stable 15.3.1
skip-checks: true
2025-01-12 02:15:08 +00:00
Tarik Gul 8c30ac2170 15.3.1 (#6064) 2025-01-12 04:07:10 +02:00
github-actions[bot] 77432e6860 [CI Skip] bump/beta 15.2.2-2-x
skip-checks: true
2025-01-12 00:26:11 +00:00
Tarik Gul 5e5e72b485 Add metadataVer cli arg for polkadot-types-internal-metadata, and ensure backwards compatibility with v14 (#6063)
* Ensure ws util has added options

* Ensure backwards compatibility
2025-01-12 02:18:13 +02:00
github-actions[bot] c5aeea29b2 [CI Skip] bump/beta 15.2.2-1-x
skip-checks: true
2025-01-10 20:12:38 +00:00
Tarik Gul 4f702089c3 Add Asset hub options to polkadot-types-internal-metadata (#6062) 2025-01-10 22:04:21 +02:00
github-actions[bot] 75f594b10d [CI Skip] bump/beta 15.2.2-0-x
skip-checks: true
2025-01-10 16:01:27 +00:00
Tarik Gul 70bb4bdf0b Set typegen scripts for Docs to use v15 (#6060)
* Set typegen scripts for Docs to use v15

* Fix runtime generation for docs
2025-01-10 17:53:22 +02:00
36 changed files with 339 additions and 201 deletions
+8
View File
@@ -1,5 +1,13 @@
# CHANGELOG
## 15.3.1 Jan 11, 2024
- Set typegen scripts for Docs to use v15 ([#6060](https://github.com/polkadot-js/api/pull/6060))
- Add Asset hub options to polkadot-types-internal-metadata ([#6062](https://github.com/polkadot-js/api/pull/6062))
- Add metadataVer cli arg for polkadot-types-internal-metadata, and ensure backwards compatibility with v14 ([#](https://github.com/polkadot-js/api/pull/6063))
- This adds `--metadataVer` to `polkadot-types-internal-metadata`. It is meant to be used along side `--endpoint` which will allow for the use of metadata versions above v14.
## 15.2.1 Jan 6, 2024
- Give compatibility for nodejs v22
+1 -1
View File
@@ -1,5 +1,5 @@
3512 Jaco Bump deps (#5785)
148 Tarik Gul 15.2.1 (#6058)
152 Tarik Gul 15.3.1 (#6064)
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
37 Keith Ingram Update contract types and rpc (#4541)
35 Stefanie Doll Updated child storage parameters (#1709)
+3 -3
View File
@@ -14,10 +14,10 @@
},
"sideEffects": false,
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"versions": {
"git": "15.2.1",
"npm": "15.2.1"
"git": "15.3.1",
"npm": "15.3.1"
},
"workspaces": [
"packages/*"
+6 -6
View File
@@ -18,14 +18,14 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/api-base": "15.2.1",
"@polkadot/rpc-augment": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-augment": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/api-base": "15.3.1",
"@polkadot/rpc-augment": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-augment": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/util": "^13.3.1",
"tslib": "^2.8.1"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '15.3.1' };
+3 -3
View File
@@ -18,11 +18,11 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/rpc-core": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/rpc-core": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/util": "^13.3.1",
"rxjs": "^7.8.1",
"tslib": "^2.8.1"
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '15.3.1' };
+8 -8
View File
@@ -18,22 +18,22 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/api": "15.2.1",
"@polkadot/api-augment": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-create": "15.2.1",
"@polkadot/api": "15.3.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/types-create": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"rxjs": "^7.8.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/api-augment": "15.2.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/keyring": "^13.3.1",
"@polkadot/types-support": "15.2.1"
"@polkadot/types-support": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '15.3.1' };
+12 -12
View File
@@ -18,25 +18,25 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/api": "15.2.1",
"@polkadot/api-augment": "15.2.1",
"@polkadot/api-base": "15.2.1",
"@polkadot/rpc-core": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/api": "15.3.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/api-base": "15.3.1",
"@polkadot/rpc-core": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"rxjs": "^7.8.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/api": "15.2.1",
"@polkadot/api-augment": "15.2.1",
"@polkadot/rpc-augment": "15.2.1",
"@polkadot/rpc-provider": "15.2.1",
"@polkadot/types-support": "15.2.1"
"@polkadot/api": "15.3.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/rpc-augment": "15.3.1",
"@polkadot/rpc-provider": "15.3.1",
"@polkadot/types-support": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '15.3.1' };
+14 -14
View File
@@ -18,21 +18,21 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/api-augment": "15.2.1",
"@polkadot/api-base": "15.2.1",
"@polkadot/api-derive": "15.2.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/api-base": "15.3.1",
"@polkadot/api-derive": "15.3.1",
"@polkadot/keyring": "^13.3.1",
"@polkadot/rpc-augment": "15.2.1",
"@polkadot/rpc-core": "15.2.1",
"@polkadot/rpc-provider": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-augment": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-create": "15.2.1",
"@polkadot/types-known": "15.2.1",
"@polkadot/rpc-augment": "15.3.1",
"@polkadot/rpc-core": "15.3.1",
"@polkadot/rpc-provider": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-augment": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/types-create": "15.3.1",
"@polkadot/types-known": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"eventemitter3": "^5.0.1",
@@ -40,7 +40,7 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/api-augment": "15.2.1",
"@polkadot/types-support": "15.2.1"
"@polkadot/api-augment": "15.3.1",
"@polkadot/types-support": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '15.3.1' };
+4 -4
View File
@@ -18,12 +18,12 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/rpc-core": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/rpc-core": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/util": "^13.3.1",
"tslib": "^2.8.1"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '15.3.1' };
+5 -5
View File
@@ -18,18 +18,18 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/rpc-augment": "15.2.1",
"@polkadot/rpc-provider": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/rpc-augment": "15.3.1",
"@polkadot/rpc-provider": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/util": "^13.3.1",
"rxjs": "^7.8.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/keyring": "^13.3.1",
"@polkadot/rpc-augment": "15.2.1"
"@polkadot/rpc-augment": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '15.3.1' };
+3 -3
View File
@@ -18,12 +18,12 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/keyring": "^13.3.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-support": "15.2.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-support": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"@polkadot/x-fetch": "^13.3.1",
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '15.3.1' };
+10 -10
View File
@@ -18,7 +18,7 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"bin": {
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.mjs",
@@ -28,15 +28,15 @@
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.mjs"
},
"dependencies": {
"@polkadot/api": "15.2.1",
"@polkadot/api-augment": "15.2.1",
"@polkadot/rpc-augment": "15.2.1",
"@polkadot/rpc-provider": "15.2.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-augment": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-create": "15.2.1",
"@polkadot/types-support": "15.2.1",
"@polkadot/api": "15.3.1",
"@polkadot/api-augment": "15.3.1",
"@polkadot/rpc-augment": "15.3.1",
"@polkadot/rpc-provider": "15.3.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-augment": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/types-create": "15.3.1",
"@polkadot/types-support": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"@polkadot/x-ws": "^13.3.1",
+133 -12
View File
@@ -1,10 +1,10 @@
// Copyright 2017-2025 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { MetadataLatest, SiLookupTypeId } from '@polkadot/types/interfaces';
import type { MetadataLatest, RuntimeApiMethodMetadataV15, SiLookupTypeId } from '@polkadot/types/interfaces';
import type { PortableRegistry } from '@polkadot/types/metadata';
import type { Text } from '@polkadot/types/primitive';
import type { Codec, DefinitionRpcParam } from '@polkadot/types/types';
import type { Codec, DefinitionCall, DefinitionRpcParam, DefinitionsCall, Registry } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import fs from 'node:fs';
@@ -17,9 +17,19 @@ import { Metadata, TypeRegistry, Vec } from '@polkadot/types';
import * as definitions from '@polkadot/types/interfaces/definitions';
import { getStorage as getSubstrateStorage } from '@polkadot/types/metadata/decorate/storage/getStorage';
import { unwrapStorageType } from '@polkadot/types/util';
import kusamaMeta, { rpc as kusamaRpc, version as kusamaVer } from '@polkadot/types-support/metadata/static-kusama';
import polkadotMeta, { rpc as polkadotRpc, version as polkadotVer } from '@polkadot/types-support/metadata/static-polkadot';
import substrateMeta from '@polkadot/types-support/metadata/static-substrate';
import assetHubKusamaMeta from '@polkadot/types-support/metadata/v15/asset-hub-kusama-hex';
import assetHubKusamaRpc from '@polkadot/types-support/metadata/v15/asset-hub-kusama-rpc';
import assetHubKusamaVer from '@polkadot/types-support/metadata/v15/asset-hub-kusama-ver';
import assetHubPolkadotMeta from '@polkadot/types-support/metadata/v15/asset-hub-polkadot-hex';
import assetHubPolkadotRpc from '@polkadot/types-support/metadata/v15/asset-hub-polkadot-rpc';
import assetHubPolkadotVer from '@polkadot/types-support/metadata/v15/asset-hub-polkadot-ver';
import kusamaMeta from '@polkadot/types-support/metadata/v15/kusama-hex';
import kusamaRpc from '@polkadot/types-support/metadata/v15/kusama-rpc';
import kusamaVer from '@polkadot/types-support/metadata/v15/kusama-ver';
import polkadotMeta from '@polkadot/types-support/metadata/v15/polkadot-hex';
import polkadotRpc from '@polkadot/types-support/metadata/v15/polkadot-rpc';
import polkadotVer from '@polkadot/types-support/metadata/v15/polkadot-ver';
import substrateMeta from '@polkadot/types-support/metadata/v15/substrate-hex';
import { isHex, stringCamelCase, stringLowerFirst } from '@polkadot/util';
import { blake2AsHex } from '@polkadot/util-crypto';
@@ -55,6 +65,16 @@ interface StaticDef {
const headerFn = (runtimeDesc: string) => `\n\n(NOTE: These were generated from a static/snapshot view of a recent ${runtimeDesc}. Some items may not be available in older nodes, or in any customized implementations.)`;
const ALL_STATIC: Record<string, StaticDef> = {
'asset-hub-kusama': {
meta: assetHubKusamaMeta,
rpc: assetHubKusamaRpc,
ver: assetHubKusamaVer as unknown as { apis: ApiDef[] }
},
'asset-hub-polkadot': {
meta: assetHubPolkadotMeta,
rpc: assetHubPolkadotRpc,
ver: assetHubPolkadotVer as unknown as { apis: ApiDef[] }
},
kusama: {
meta: kusamaMeta,
rpc: kusamaRpc,
@@ -218,7 +238,89 @@ function addRpc (_runtimeDesc: string, rpcMethods?: string[]): string {
}
/** @internal */
function addRuntime (_runtimeDesc: string, apis?: ApiDef[]): string {
function getMethods (registry: Registry, methods: Vec<RuntimeApiMethodMetadataV15>) {
const result: Record<string, DefinitionCall> = {};
methods.forEach((m) => {
const { docs, inputs, name, output } = m;
result[name.toString()] = {
description: docs.map((d) => d.toString()).join(),
params: inputs.map(({ name, type }) => {
return { name: name.toString(), type: registry.lookup.getName(type) || registry.lookup.getTypeDef(type).type };
}),
type: registry.lookup.getName(output) || registry.lookup.getTypeDef(output).type
};
});
return result;
}
/** @internal */
function getRuntimeDefViaMetadata (registry: Registry) {
const result: DefinitionsCall = {};
const { apis } = registry.metadata;
for (let i = 0, count = apis.length; i < count; i++) {
const { methods, name } = apis[i];
result[name.toString()] = [{
methods: getMethods(registry, methods),
// We set the version to 0 here since it will not be relevant when we are grabbing the runtime apis
// from the Metadata.
version: 0
}];
}
return Object.entries(result);
}
function runtimeSections (registry: Registry) {
const sections = getRuntimeDefViaMetadata(registry);
const all = [];
for (let j = 0, jcount = sections.length; j < jcount; j++) {
const [_section, secs] = sections[j];
const sec = secs[0];
const section = stringCamelCase(_section);
const methods = Object.entries(sec.methods);
const container: Section = { items: [], name: section };
all.push(container);
methods
.sort(([a], [b]) => a.localeCompare(b))
.forEach(([methodName, { description, params, type }]): void => {
const args = params.map(({ name, type }): string => {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return name + ': `' + type + '`';
}).join(', ');
container.items.push({
interface: '`' + `api.call.${stringCamelCase(section)}.${stringCamelCase(methodName)}` + '`',
name: `${stringCamelCase(methodName)}(${args}): ${'`' + type + '`'}`,
runtime: '`' + `${section}_${methodName}` + '`',
summary: description
});
});
}
return all.sort(sortByName);
}
/** @internal */
function addRuntime (_runtimeDesc: string, registry: Registry): string {
return renderPage({
description: 'The following section contains known runtime calls that may be available on specific runtimes (depending on configuration and available pallets). These call directly into the WASM runtime for queries and operations.',
sections: runtimeSections(registry),
title: 'Runtime'
});
}
/** @internal */
function addLegacyRuntime (_runtimeDesc: string, _registry: Registry, apis?: ApiDef[]) {
return renderPage({
description: 'The following section contains known runtime calls that may be available on specific runtimes (depending on configuration and available pallets). These call directly into the WASM runtime for queries and operations.',
sections: Object
@@ -460,10 +562,10 @@ function writeFile (name: string, ...chunks: any[]): void {
writeStream.end();
}
interface ArgV { chain?: string; endpoint?: string; }
interface ArgV { chain?: string; endpoint?: string; metadataVer?: number; }
async function mainPromise (): Promise<void> {
const { chain, endpoint } = yargs(hideBin(process.argv)).strict().options({
const { chain, endpoint, metadataVer } = yargs(hideBin(process.argv)).strict().options({
chain: {
description: 'The chain name to use for the output (defaults to "Substrate")',
type: 'string'
@@ -471,9 +573,19 @@ async function mainPromise (): Promise<void> {
endpoint: {
description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
type: 'string'
},
metadataVer: {
description: 'The metadata version to use for generating type information. This will use state_call::Metadata_metadata_at_version to query metadata',
type: 'number'
}
}).argv as ArgV;
/**
* This is unique to when the endpoint arg is used. Since the endpoint requires us to query the chain, it may query the chains
* rpc state_getMetadata method to get metadata, but this restricts us to v14 only. Therefore we must also check if the `metadataVer` is passed
* in as well. These checks will help us decide if we are using v14 or newer.
*/
const useV14Metadata = endpoint && ((metadataVer && metadataVer < 15) || !metadataVer);
const chainName = chain || 'Substrate';
let metaHex: HexString;
let rpcMethods: string[] | undefined;
@@ -481,7 +593,7 @@ async function mainPromise (): Promise<void> {
if (endpoint) {
if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
metaHex = await getMetadataViaWs(endpoint);
metaHex = await getMetadataViaWs(endpoint, metadataVer);
rpcMethods = await getRpcMethodsViaWs(endpoint);
runtimeApis = await getRuntimeVersionViaWs(endpoint);
} else {
@@ -498,13 +610,20 @@ async function mainPromise (): Promise<void> {
} else if (ALL_STATIC[chainName.toLowerCase()]) {
metaHex = ALL_STATIC[chainName.toLowerCase()].meta;
rpcMethods = ALL_STATIC[chainName.toLowerCase()].rpc?.methods;
runtimeApis = ALL_STATIC[chainName.toLowerCase()].ver?.apis;
} else {
metaHex = substrateMeta;
}
let metadata: Metadata;
const registry = new TypeRegistry();
const metadata = new Metadata(registry, metaHex);
if (useV14Metadata) {
metadata = new Metadata(registry, metaHex);
} else {
const opaqueMetadata = registry.createType('Option<OpaqueMetadata>', registry.createType('Raw', metaHex).toU8a()).unwrap();
metadata = new Metadata(registry, opaqueMetadata.toHex());
}
registry.setMetadata(metadata);
@@ -514,7 +633,9 @@ async function mainPromise (): Promise<void> {
writeFile(`${docRoot}/rpc.md`, addRpc(runtimeDesc, rpcMethods));
writeFile(`${docRoot}/runtime.md`, addRuntime(runtimeDesc, runtimeApis));
useV14Metadata
? writeFile(`${docRoot}/runtime.md`, addLegacyRuntime(runtimeDesc, registry, runtimeApis))
: writeFile(`${docRoot}/runtime.md`, addRuntime(runtimeDesc, registry));
writeFile(`${docRoot}/constants.md`, addConstants(runtimeDesc, latest));
writeFile(`${docRoot}/storage.md`, addStorage(runtimeDesc, latest));
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '15.3.1' };
+14 -5
View File
@@ -4,10 +4,11 @@
import type { HexString } from '@polkadot/util/types';
import { promiseTracker } from '@polkadot/api/promise/decorateMethod';
import { stringify } from '@polkadot/util';
import { TypeRegistry } from '@polkadot/types';
import { stringify, u8aToHex } from '@polkadot/util';
import { WebSocket } from '@polkadot/x-ws';
async function getWsData <T> (endpoint: string, method: 'rpc_methods' | 'state_getMetadata' | 'state_getRuntimeVersion'): Promise<T> {
async function getWsData <T> (endpoint: string, method: 'rpc_methods' | 'state_call' | 'state_getMetadata' | 'state_getRuntimeVersion', params?: string[]): Promise<T> {
return new Promise((resolve, reject): void => {
const tracker = promiseTracker<T>(resolve, reject);
@@ -26,7 +27,9 @@ async function getWsData <T> (endpoint: string, method: 'rpc_methods' | 'state_g
websocket.onopen = (): void => {
console.log('connected');
websocket.send(`{"id":"1","jsonrpc":"2.0","method":"${method}","params":[]}`);
params
? websocket.send(`{"id":"1","jsonrpc":"2.0","method":"${method}","params":[${params.map((param) => `"${param}"`).join(',')}]}`)
: websocket.send(`{"id":"1","jsonrpc":"2.0","method":"${method}","params":[]}`);
};
websocket.onmessage = (message: { data: string }): void => {
@@ -44,8 +47,14 @@ async function getWsData <T> (endpoint: string, method: 'rpc_methods' | 'state_g
});
}
export async function getMetadataViaWs (endpoint: string): Promise<HexString> {
return getWsData<HexString>(endpoint, 'state_getMetadata');
export async function getMetadataViaWs (endpoint: string, metadataVer?: number): Promise<HexString> {
const registry = new TypeRegistry();
if (metadataVer) {
return await getWsData<HexString>(endpoint, 'state_call', ['Metadata_metadata_at_version', u8aToHex(registry.createType('u32', metadataVer).toU8a())]);
} else {
return await getWsData<HexString>(endpoint, 'state_getMetadata');
}
}
export async function getRpcMethodsViaWs (endpoint: string): Promise<string[]> {
+3 -3
View File
@@ -18,11 +18,11 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/types": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/util": "^13.3.1",
"tslib": "^2.8.1"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '15.3.1' };
+4 -4
View File
@@ -18,7 +18,7 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/util": "^13.3.1",
@@ -26,9 +26,9 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/types": "15.2.1",
"@polkadot/types-augment": "15.2.1",
"@polkadot/types-support": "15.2.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-augment": "15.3.1",
"@polkadot/types-support": "15.3.1",
"@polkadot/util-crypto": "^13.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '15.3.1' };
+3 -3
View File
@@ -18,14 +18,14 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/util": "^13.3.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/types": "15.2.1"
"@polkadot/types": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '15.3.1' };
+5 -5
View File
@@ -18,17 +18,17 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/networks": "^13.3.1",
"@polkadot/types": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-create": "15.2.1",
"@polkadot/types": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/types-create": "15.3.1",
"@polkadot/util": "^13.3.1",
"tslib": "^2.8.1"
},
"devDependencies": {
"@polkadot/api": "15.2.1"
"@polkadot/api": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '15.3.1' };
+1 -1
View File
@@ -18,7 +18,7 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/util": "^13.3.1",
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '15.3.1' };
+5 -5
View File
@@ -18,13 +18,13 @@
"./packageDetect.cjs"
],
"type": "module",
"version": "15.2.1",
"version": "15.3.1",
"main": "index.js",
"dependencies": {
"@polkadot/keyring": "^13.3.1",
"@polkadot/types-augment": "15.2.1",
"@polkadot/types-codec": "15.2.1",
"@polkadot/types-create": "15.2.1",
"@polkadot/types-augment": "15.3.1",
"@polkadot/types-codec": "15.3.1",
"@polkadot/types-create": "15.3.1",
"@polkadot/util": "^13.3.1",
"@polkadot/util-crypto": "^13.3.1",
"rxjs": "^7.8.1",
@@ -32,6 +32,6 @@
},
"devDependencies": {
"@polkadot/keyring": "^13.3.1",
"@polkadot/types-support": "15.2.1"
"@polkadot/types-support": "15.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '15.2.1' };
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '15.3.1' };
+79 -79
View File
@@ -447,26 +447,26 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/api-augment@npm:15.2.1, @polkadot/api-augment@workspace:packages/api-augment":
"@polkadot/api-augment@npm:15.3.1, @polkadot/api-augment@workspace:packages/api-augment":
version: 0.0.0-use.local
resolution: "@polkadot/api-augment@workspace:packages/api-augment"
dependencies:
"@polkadot/api-base": "npm:15.2.1"
"@polkadot/rpc-augment": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-augment": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/api-base": "npm:15.3.1"
"@polkadot/rpc-augment": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-augment": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/api-base@npm:15.2.1, @polkadot/api-base@workspace:packages/api-base":
"@polkadot/api-base@npm:15.3.1, @polkadot/api-base@workspace:packages/api-base":
version: 0.0.0-use.local
resolution: "@polkadot/api-base@workspace:packages/api-base"
dependencies:
"@polkadot/rpc-core": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/rpc-core": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
rxjs: "npm:^7.8.1"
tslib: "npm:^2.8.1"
@@ -477,13 +477,13 @@ __metadata:
version: 0.0.0-use.local
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@polkadot/api": "npm:15.2.1"
"@polkadot/api-augment": "npm:15.2.1"
"@polkadot/api": "npm:15.3.1"
"@polkadot/api-augment": "npm:15.3.1"
"@polkadot/keyring": "npm:^13.3.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-create": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-create": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
rxjs: "npm:^7.8.1"
@@ -491,19 +491,19 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/api-derive@npm:15.2.1, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@npm:15.3.1, @polkadot/api-derive@workspace:packages/api-derive":
version: 0.0.0-use.local
resolution: "@polkadot/api-derive@workspace:packages/api-derive"
dependencies:
"@polkadot/api": "npm:15.2.1"
"@polkadot/api-augment": "npm:15.2.1"
"@polkadot/api-base": "npm:15.2.1"
"@polkadot/rpc-augment": "npm:15.2.1"
"@polkadot/rpc-core": "npm:15.2.1"
"@polkadot/rpc-provider": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/api": "npm:15.3.1"
"@polkadot/api-augment": "npm:15.3.1"
"@polkadot/api-base": "npm:15.3.1"
"@polkadot/rpc-augment": "npm:15.3.1"
"@polkadot/rpc-core": "npm:15.3.1"
"@polkadot/rpc-provider": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
rxjs: "npm:^7.8.1"
@@ -511,23 +511,23 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/api@npm:15.2.1, @polkadot/api@workspace:packages/api":
"@polkadot/api@npm:15.3.1, @polkadot/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@polkadot/api@workspace:packages/api"
dependencies:
"@polkadot/api-augment": "npm:15.2.1"
"@polkadot/api-base": "npm:15.2.1"
"@polkadot/api-derive": "npm:15.2.1"
"@polkadot/api-augment": "npm:15.3.1"
"@polkadot/api-base": "npm:15.3.1"
"@polkadot/api-derive": "npm:15.3.1"
"@polkadot/keyring": "npm:^13.3.1"
"@polkadot/rpc-augment": "npm:15.2.1"
"@polkadot/rpc-core": "npm:15.2.1"
"@polkadot/rpc-provider": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-augment": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-create": "npm:15.2.1"
"@polkadot/types-known": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/rpc-augment": "npm:15.3.1"
"@polkadot/rpc-core": "npm:15.3.1"
"@polkadot/rpc-provider": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-augment": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-create": "npm:15.3.1"
"@polkadot/types-known": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
eventemitter3: "npm:^5.0.1"
@@ -657,39 +657,39 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/rpc-augment@npm:15.2.1, @polkadot/rpc-augment@workspace:packages/rpc-augment":
"@polkadot/rpc-augment@npm:15.3.1, @polkadot/rpc-augment@workspace:packages/rpc-augment":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-augment@workspace:packages/rpc-augment"
dependencies:
"@polkadot/rpc-core": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/rpc-core": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/rpc-core@npm:15.2.1, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@npm:15.3.1, @polkadot/rpc-core@workspace:packages/rpc-core":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-core@workspace:packages/rpc-core"
dependencies:
"@polkadot/keyring": "npm:^13.3.1"
"@polkadot/rpc-augment": "npm:15.2.1"
"@polkadot/rpc-provider": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/rpc-augment": "npm:15.3.1"
"@polkadot/rpc-provider": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
rxjs: "npm:^7.8.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@npm:15.2.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@npm:15.3.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider"
dependencies:
"@polkadot/keyring": "npm:^13.3.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
"@polkadot/x-fetch": "npm:^13.3.1"
@@ -710,15 +710,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "@polkadot/typegen@workspace:packages/typegen"
dependencies:
"@polkadot/api": "npm:15.2.1"
"@polkadot/api-augment": "npm:15.2.1"
"@polkadot/rpc-augment": "npm:15.2.1"
"@polkadot/rpc-provider": "npm:15.2.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-augment": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-create": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/api": "npm:15.3.1"
"@polkadot/api-augment": "npm:15.3.1"
"@polkadot/rpc-augment": "npm:15.3.1"
"@polkadot/rpc-provider": "npm:15.3.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-augment": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-create": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
"@polkadot/x-ws": "npm:^13.3.1"
@@ -735,24 +735,24 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-augment@npm:15.2.1, @polkadot/types-augment@workspace:packages/types-augment":
"@polkadot/types-augment@npm:15.3.1, @polkadot/types-augment@workspace:packages/types-augment":
version: 0.0.0-use.local
resolution: "@polkadot/types-augment@workspace:packages/types-augment"
dependencies:
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/types-codec@npm:15.2.1, @polkadot/types-codec@workspace:packages/types-codec":
"@polkadot/types-codec@npm:15.3.1, @polkadot/types-codec@workspace:packages/types-codec":
version: 0.0.0-use.local
resolution: "@polkadot/types-codec@workspace:packages/types-codec"
dependencies:
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-augment": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-augment": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
"@polkadot/x-bigint": "npm:^13.3.1"
@@ -760,32 +760,32 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-create@npm:15.2.1, @polkadot/types-create@workspace:packages/types-create":
"@polkadot/types-create@npm:15.3.1, @polkadot/types-create@workspace:packages/types-create":
version: 0.0.0-use.local
resolution: "@polkadot/types-create@workspace:packages/types-create"
dependencies:
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/types-known@npm:15.2.1, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@npm:15.3.1, @polkadot/types-known@workspace:packages/types-known":
version: 0.0.0-use.local
resolution: "@polkadot/types-known@workspace:packages/types-known"
dependencies:
"@polkadot/api": "npm:15.2.1"
"@polkadot/api": "npm:15.3.1"
"@polkadot/networks": "npm:^13.3.1"
"@polkadot/types": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-create": "npm:15.2.1"
"@polkadot/types": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-create": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
tslib: "npm:^2.8.1"
languageName: unknown
linkType: soft
"@polkadot/types-support@npm:15.2.1, @polkadot/types-support@workspace:packages/types-support":
"@polkadot/types-support@npm:15.3.1, @polkadot/types-support@workspace:packages/types-support":
version: 0.0.0-use.local
resolution: "@polkadot/types-support@workspace:packages/types-support"
dependencies:
@@ -794,15 +794,15 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types@npm:15.2.1, @polkadot/types@workspace:packages/types":
"@polkadot/types@npm:15.3.1, @polkadot/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@polkadot/types@workspace:packages/types"
dependencies:
"@polkadot/keyring": "npm:^13.3.1"
"@polkadot/types-augment": "npm:15.2.1"
"@polkadot/types-codec": "npm:15.2.1"
"@polkadot/types-create": "npm:15.2.1"
"@polkadot/types-support": "npm:15.2.1"
"@polkadot/types-augment": "npm:15.3.1"
"@polkadot/types-codec": "npm:15.3.1"
"@polkadot/types-create": "npm:15.3.1"
"@polkadot/types-support": "npm:15.3.1"
"@polkadot/util": "npm:^13.3.1"
"@polkadot/util-crypto": "npm:^13.3.1"
rxjs: "npm:^7.8.1"