Compare commits

...
2 Commits
Author SHA1 Message Date
Github Actions f6e50f14b5 [CI Skip] release/stable 6.0.2
skip-checks: true
2021-09-18 09:12:35 +00:00
Jaco caec49a8dc Fix Substrate key generation (#3968)
* Fix Substrate key generation

* 6.0.2
2021-09-18 10:56:35 +02:00
25 changed files with 148 additions and 74 deletions
+2
View File
@@ -29,3 +29,5 @@
5.5.2
5.8.2
5.8.3
6.0.2
+9
View File
@@ -1,5 +1,14 @@
# CHANGELOG
## 6.0.2 Sep 18, 2021
Upgrade priority: Low. Recommended for all users on 6.0.1, especially those using `api.query.substrate.*` calls
Changes:
- Fix `api.query.substrate.*` key generation
## 6.0.1 Sep 18, 2021
Upgrade priority: Low. Recommended for users of the latest Substrate/Polkadot with Metadata v14.
+1 -1
View File
@@ -35,6 +35,6 @@
"@types/jest": "^27.0.1",
"copyfiles": "^2.4.1"
},
"version": "6.0.1",
"version": "6.0.2",
"packageManager": "yarn@3.0.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.1",
"@polkadot/types": "6.0.1",
"@polkadot/api": "6.0.2",
"@polkadot/types": "6.0.2",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.0.2' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -20,15 +20,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.1",
"@polkadot/rpc-core": "6.0.1",
"@polkadot/types": "6.0.1",
"@polkadot/api": "6.0.2",
"@polkadot/rpc-core": "6.0.2",
"@polkadot/types": "6.0.2",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-provider": "6.0.1"
"@polkadot/rpc-provider": "6.0.2"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.0.2' };
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -20,12 +20,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.0.1",
"@polkadot/api-derive": "6.0.2",
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-core": "6.0.1",
"@polkadot/rpc-provider": "6.0.1",
"@polkadot/types": "6.0.1",
"@polkadot/types-known": "6.0.1",
"@polkadot/rpc-core": "6.0.2",
"@polkadot/rpc-provider": "6.0.2",
"@polkadot/types": "6.0.2",
"@polkadot/types-known": "6.0.2",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"eventemitter3": "^4.0.7",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/api', version: '6.0.2' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.0.1",
"@polkadot/types": "6.0.1",
"@polkadot/rpc-provider": "6.0.2",
"@polkadot/types": "6.0.2",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.0.2' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -20,7 +20,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.0.1",
"@polkadot/types": "6.0.2",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"@polkadot/x-fetch": "^7.4.1",
@@ -30,7 +30,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types": "6.0.1",
"@polkadot/types": "6.0.2",
"mock-socket": "^9.0.3",
"nock": "^13.1.3"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.0.2' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -29,10 +29,10 @@
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.1",
"@polkadot/rpc-provider": "6.0.1",
"@polkadot/types": "6.0.1",
"@polkadot/types-support": "6.0.1",
"@polkadot/api": "6.0.2",
"@polkadot/rpc-provider": "6.0.2",
"@polkadot/types": "6.0.2",
"@polkadot/types-support": "6.0.2",
"@polkadot/util": "^7.4.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '6.0.2' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Known type definitions",
"main": "index.js",
@@ -21,7 +21,7 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/networks": "^7.4.1",
"@polkadot/types": "6.0.1",
"@polkadot/types": "6.0.2",
"@polkadot/util": "^7.4.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '6.0.2' };
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-support",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Supporting files for types, mostly for testing",
"main": "index.js",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-support', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/types-support', version: '6.0.2' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "6.0.1",
"version": "6.0.2",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -26,7 +26,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types-support": "6.0.1",
"@polkadot/types-support": "6.0.2",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.12.0"
}
@@ -1,13 +1,19 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import metadataStatic from '@polkadot/types-support/metadata/static-substrate';
import { compactAddLength, u8aToU8a } from '@polkadot/util';
import { TypeRegistry } from '../../../create';
import { Metadata } from '../../Metadata';
import { getStorage } from './getStorage';
const registry = new TypeRegistry();
const metadata = new Metadata(registry, metadataStatic);
registry.setMetadata(metadata);
describe('getSorage', (): void => {
const registry = new TypeRegistry();
const storage = getStorage(registry);
it('should return well known keys', (): void => {
@@ -1,19 +1,34 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import metadataStatic from '@polkadot/types-support/metadata/static-substrate';
import { compactAddLength, u8aToU8a } from '@polkadot/util';
import { TypeRegistry } from '../../../create';
import { Metadata } from '../../Metadata';
import { substrate } from './substrate';
const registry = new TypeRegistry();
const metadata = new Metadata(registry, metadataStatic);
registry.setMetadata(metadata);
// console.log(JSON.stringify(registry.lookup.types));
describe('substrate', (): void => {
const code = substrate.code(registry);
it('creates a well-known :code key', (): void => {
expect(
substrate.code(registry)()
code()
).toEqual(
compactAddLength(u8aToU8a(':code'))
);
});
it('has the correct metadata', (): void => {
expect(
code.meta.type.isPlain
).toEqual(true);
});
});
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { StorageEntryMetadataLatest } from '../../../interfaces';
import type { PortableType } from '../../../interfaces';
import type { StorageEntry } from '../../../primitive/types';
import type { Registry } from '../../../types';
@@ -14,18 +14,60 @@ interface SubstrateMetadata {
type Creator = (registry: Registry) => StorageEntry;
function findSiPrimitive (registry: Registry, _prim: string): PortableType | undefined {
const prim = _prim.toLowerCase();
const portable = registry.lookup.types.find((t) =>
(
t.type.def.isPrimitive &&
t.type.def.asPrimitive.toString().toLowerCase() === prim
) || (
t.type.def.isHistoricMetaCompat &&
t.type.def.asHistoricMetaCompat.toString().toLowerCase() === prim
)
);
return portable;
}
function findSiType (registry: Registry, orig: string): PortableType | undefined {
let portable = findSiPrimitive(registry, orig);
if (!portable && orig === 'Bytes') {
const u8 = findSiPrimitive(registry, 'u8');
if (u8) {
portable = registry.lookup.types.find((t) =>
(
t.type.def.isSequence &&
t.type.def.asSequence.type.eq(u8.id)
) || (
t.type.def.isHistoricMetaCompat &&
t.type.def.asHistoricMetaCompat.eq(orig)
)
);
}
}
if (!portable) {
console.warn(`Unable to map ${orig} to a lookup index`);
}
return portable;
}
// Small helper function to factorize code on this page.
/** @internal */
function createRuntimeFunction (method: string, key: string, { docs, type }: SubstrateMetadata): (registry: Registry) => StorageEntry {
return (registry: Registry): StorageEntry =>
createFunction(registry, {
meta: {
meta: registry.createType('StorageEntryMetadataLatest', {
docs: registry.createType('Vec<Text>', [docs]),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
modifier: registry.createType('StorageEntryModifierLatest', 'Required'),
name: registry.createType('Text', method),
toJSON: (): any => key,
type: registry.createType('StorageEntryTypeLatest', type, 0)
} as StorageEntryMetadataLatest,
type: registry.createType('StorageEntryTypeLatest', { Plain: findSiType(registry, type)?.id || 0 })
}),
method,
prefix: 'Substrate',
section: 'substrate'
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '6.0.1' };
export const packageInfo = { name: '@polkadot/types', version: '6.0.2' };
+27 -27
View File
@@ -1854,40 +1854,40 @@ __metadata:
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.0.1
"@polkadot/types": 6.0.1
"@polkadot/api": 6.0.2
"@polkadot/types": 6.0.2
"@polkadot/util": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/api-derive@6.0.1, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@6.0.2, @polkadot/api-derive@workspace:packages/api-derive":
version: 0.0.0-use.local
resolution: "@polkadot/api-derive@workspace:packages/api-derive"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.0.1
"@polkadot/api": 6.0.2
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-core": 6.0.1
"@polkadot/rpc-provider": 6.0.1
"@polkadot/types": 6.0.1
"@polkadot/rpc-core": 6.0.2
"@polkadot/rpc-provider": 6.0.2
"@polkadot/types": 6.0.2
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/api@6.0.1, @polkadot/api@workspace:packages/api":
"@polkadot/api@6.0.2, @polkadot/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@polkadot/api@workspace:packages/api"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api-derive": 6.0.1
"@polkadot/api-derive": 6.0.2
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-core": 6.0.1
"@polkadot/rpc-provider": 6.0.1
"@polkadot/types": 6.0.1
"@polkadot/types-known": 6.0.1
"@polkadot/rpc-core": 6.0.2
"@polkadot/rpc-provider": 6.0.2
"@polkadot/types": 6.0.2
"@polkadot/types-known": 6.0.2
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
eventemitter3: ^4.0.7
@@ -2012,26 +2012,26 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/rpc-core@6.0.1, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@6.0.2, @polkadot/rpc-core@workspace:packages/rpc-core":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-core@workspace:packages/rpc-core"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-provider": 6.0.1
"@polkadot/types": 6.0.1
"@polkadot/rpc-provider": 6.0.2
"@polkadot/types": 6.0.2
"@polkadot/util": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@6.0.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@6.0.2, @polkadot/rpc-provider@workspace:packages/rpc-provider":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/types": 6.0.1
"@polkadot/types": 6.0.2
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
"@polkadot/x-fetch": ^7.4.1
@@ -2059,10 +2059,10 @@ __metadata:
"@babel/core": ^7.15.5
"@babel/register": ^7.15.3
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.0.1
"@polkadot/rpc-provider": 6.0.1
"@polkadot/types": 6.0.1
"@polkadot/types-support": 6.0.1
"@polkadot/api": 6.0.2
"@polkadot/rpc-provider": 6.0.2
"@polkadot/types": 6.0.2
"@polkadot/types-support": 6.0.2
"@polkadot/util": ^7.4.1
"@types/websocket": ^1.0.4
"@types/yargs": ^17.0.2
@@ -2078,18 +2078,18 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-known@6.0.1, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@6.0.2, @polkadot/types-known@workspace:packages/types-known":
version: 0.0.0-use.local
resolution: "@polkadot/types-known@workspace:packages/types-known"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/networks": ^7.4.1
"@polkadot/types": 6.0.1
"@polkadot/types": 6.0.2
"@polkadot/util": ^7.4.1
languageName: unknown
linkType: soft
"@polkadot/types-support@6.0.1, @polkadot/types-support@workspace:packages/types-support":
"@polkadot/types-support@6.0.2, @polkadot/types-support@workspace:packages/types-support":
version: 0.0.0-use.local
resolution: "@polkadot/types-support@workspace:packages/types-support"
dependencies:
@@ -2098,13 +2098,13 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types@6.0.1, @polkadot/types@workspace:packages/types":
"@polkadot/types@6.0.2, @polkadot/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@polkadot/types@workspace:packages/types"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/types-support": 6.0.1
"@polkadot/types-support": 6.0.2
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
"@types/bn.js": ^4.11.6