Compare commits

...
10 Commits
Author SHA1 Message Date
Github Actions d917861a77 [CI Skip] release/stable 6.5.2
skip-checks: true
2021-10-26 06:02:42 +00:00
Jaco 12a54efde5 Fix Struct decoding for null (#4112)
* Fix Struct decoding for null

* CHANGELOG

* 6.5.2
2021-10-26 08:46:03 +03:00
Github Actions 9ae87bed78 [CI Skip] release/beta 6.5.2-3
skip-checks: true
2021-10-25 14:27:40 +00:00
Jaco 7f5a52258c Adjust toHuman on Call (#4109) 2021-10-25 17:10:26 +03:00
Github Actions 2c212e6b4d [CI Skip] release/beta 6.5.2-2
skip-checks: true
2021-10-25 14:07:57 +00:00
Jaco 3d75744a20 Bump dev deps (#4108) 2021-10-25 16:51:05 +03:00
Github Actions d2ff259989 [CI Skip] release/beta 6.5.2-1
skip-checks: true
2021-10-25 12:08:53 +00:00
Jaco cac2ef30a1 Bump dev (#4106) 2021-10-25 14:44:47 +03:00
Github Actions ea38dedcc1 [CI Skip] release/beta 6.5.2-0
skip-checks: true
2021-10-25 06:15:30 +00:00
Jaco 0bd632e612 Allow for optional known RuntimeVersion on api.at (#4103)
* Allow for optional known RuntimeVersion on api.at

* CHANGELOG typo
2021-10-25 08:57:26 +03:00
27 changed files with 337 additions and 250 deletions
+2 -1
View File
@@ -40,4 +40,5 @@
6.0.5
6.1.2
6.4.2
6.4.2
6.5.2
+15 -2
View File
@@ -1,10 +1,23 @@
# CHANGELOG
## 6.5.2 Oct 26, 2021
Upgrade priority: Low. Recommended for users with `.at` queries on unknown blocks.
Changes:
- Adjust `toHuman` on `Call` to return names & (not only) values
- Allow for optional known `RuntimeVersion` to short-circuit `api.at`
- Ensure `Struct` decodes fully on `null` input (equivalent to `undefined` & `{}`)
## 6.5.1 Oct 24, 2021
Upgrade priority: Low. Internal maintenance upgrades.
Contributed:
- Add `Auction` to Polkadot pre-0.9.11 `ProxyType` (Thnaks to https://github.com/wirednkod)
- Add `Auction` to Polkadot pre-0.9.11 `ProxyType` (Thanks to https://github.com/wirednkod)
Changes:
@@ -13,7 +26,7 @@ Changes:
- `TypeDef` structures now contain the `typeName` from metadata v14 on fields
- Fix browser bundle imports for xcm-mapping (move to `types-known`)
- Expose all extracted type names in `PortableRegistry`
- Adjust `toJSON` (Asicc) output detection on `Raw`
- Adjust `toJSON` (Ascii) output detection on `Raw`
- Adjust `api.rpc.*.*.raw(..args)` return to the actual over-the-wire JSON result
- Remove `api.rpc.*.*.json(..args)` since it now overlaps with new `.raw`
- Bump static metadata for latest Substrate, Polkadot & Kusama
+18 -11
View File
@@ -1,25 +1,31 @@
{
"repository": "https://github.com/polkadot-js/api",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"engines": {},
"homepage": "https://github.com/polkadot-js/api#readme",
"license": "Apache-2",
"packageManager": "yarn@3.0.1",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": false,
"type": "commonjs",
"version": "6.5.2",
"workspaces": [
"packages/*"
],
"resolutions": {
"typescript": "^4.4.4"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
"build:interfaces": "polkadot-types-internal-interfaces",
"build:release": "polkadot-ci-ghact-build",
"build:rollup": "polkadot-exec-rollup --config",
"docs:metadata": "polkadot-types-internal-metadata",
"chain:info": "polkadot-types-chain-info",
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"docs:metadata": "polkadot-types-internal-metadata",
"lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --coverage --forceExit --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
@@ -29,12 +35,13 @@
"@babel/core": "^7.15.8",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/dev": "^0.63.6",
"@polkadot/ts": "^0.4.10",
"@polkadot/dev": "^0.63.9",
"@polkadot/ts": "^0.4.12",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^27.0.2",
"copyfiles": "^2.4.1"
},
"version": "6.5.1",
"packageManager": "yarn@3.0.1"
}
"resolutions": {
"typescript": "^4.4.4"
}
}
+22 -17
View File
@@ -1,28 +1,33 @@
{
"name": "@polkadot/api-contract",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/api-contract",
"private": false,
"repository": {
"directory": "packages/api-contract",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.5.1",
"@polkadot/types": "6.5.1",
"@polkadot/api": "6.5.2",
"@polkadot/types": "6.5.2",
"@polkadot/util": "^7.6.1",
"rxjs": "^7.4.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.5.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.5.2' };
+24 -19
View File
@@ -1,34 +1,39 @@
{
"name": "@polkadot/api-derive",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/api-derive",
"private": false,
"repository": {
"directory": "packages/api-derive",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.5.1",
"@polkadot/rpc-core": "6.5.1",
"@polkadot/types": "6.5.1",
"@polkadot/api": "6.5.2",
"@polkadot/rpc-core": "6.5.2",
"@polkadot/types": "6.5.2",
"@polkadot/util": "^7.6.1",
"@polkadot/util-crypto": "^7.6.1",
"rxjs": "^7.4.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.6.1",
"@polkadot/rpc-provider": "6.5.1"
"@polkadot/rpc-provider": "6.5.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.5.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.5.2' };
+25 -20
View File
@@ -1,34 +1,39 @@
{
"name": "@polkadot/api",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/api",
"private": false,
"repository": {
"directory": "packages/api",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.5.1",
"@polkadot/api-derive": "6.5.2",
"@polkadot/keyring": "^7.6.1",
"@polkadot/rpc-core": "6.5.1",
"@polkadot/rpc-provider": "6.5.1",
"@polkadot/types": "6.5.1",
"@polkadot/types-known": "6.5.1",
"@polkadot/rpc-core": "6.5.2",
"@polkadot/rpc-provider": "6.5.2",
"@polkadot/types": "6.5.2",
"@polkadot/types-known": "6.5.2",
"@polkadot/util": "^7.6.1",
"@polkadot/util-crypto": "^7.6.1",
"eventemitter3": "^4.0.7",
"rxjs": "^7.4.0"
}
}
}
+1 -1
View File
@@ -163,7 +163,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
}
public abstract at (blockHash: Uint8Array | string): Promise<ApiDecoration<ApiType>>;
public abstract at (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion): Promise<ApiDecoration<ApiType>>;
/**
* @description Return the current used registry
+30 -12
View File
@@ -3,7 +3,7 @@
import type { Observable, Subscription } from 'rxjs';
import type { Text } from '@polkadot/types';
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { ChainProperties, Hash, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { ApiBase, ApiDecoration, ApiOptions, ApiTypes, DecorateMethod } from '../types';
@@ -111,15 +111,34 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
/**
* @description Returns a decorated API instance at a specific point in time
*/
public async at (blockHash: Uint8Array | string): Promise<ApiDecoration<ApiType>> {
public async at (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion): Promise<ApiDecoration<ApiType>> {
const u8aHash = u8aToU8a(blockHash);
const registry = await this.getBlockRegistry(u8aHash);
const registry = await this.getBlockRegistry(u8aHash, knownVersion);
// always create a new decoration - since we are pointing to a specific hash, this
// means that all queries needs to use that hash (not a previous one already existing)
return this._createDecorated(registry, true, u8aHash).decoratedApi;
}
private _getBlockRegistryViaVersion (blockHash: Uint8Array, version?: RuntimeVersionPartial): VersionedRegistry<ApiType> | null {
if (version) {
// check for pre-existing registries. We also check specName, e.g. it
// could be changed like in Westmint with upgrade from shell -> westmint
const existingViaVersion = this.#registries.find(({ specName, specVersion }) =>
specName.eq(version.specName) &&
specVersion.eq(version.specVersion)
);
if (existingViaVersion) {
existingViaVersion.lastBlockHash = blockHash;
return existingViaVersion;
}
}
return null;
}
private async _getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry<ApiType>> {
// ensure we have everything required
assert(this._genesisHash && this._runtimeVersion, 'Cannot retrieve data on an uninitialized chain');
@@ -142,16 +161,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
: await firstValueFrom(this._rpcCore.state.getRuntimeVersion.raw(header.parentHash))
);
// check for pre-existing registries. We also check specName, e.g. it
// could be changed like in Westmint with upgrade from shell -> westmint
const existingViaVersion = this.#registries.find(({ specName, specVersion }) =>
specName.eq(version.specName) &&
specVersion.eq(version.specVersion)
);
const existingViaVersion = this._getBlockRegistryViaVersion(blockHash, version);
if (existingViaVersion) {
existingViaVersion.lastBlockHash = blockHash;
return existingViaVersion;
}
@@ -174,7 +186,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
/**
* @description Sets up a registry based on the block hash defined
*/
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry<ApiType>> {
public async getBlockRegistry (blockHash: Uint8Array, knownVersion?: RuntimeVersion): Promise<VersionedRegistry<ApiType>> {
const existingViaHash = this.#registries.find(({ lastBlockHash }) =>
lastBlockHash && u8aEq(lastBlockHash, blockHash)
);
@@ -183,6 +195,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
return existingViaHash;
}
const existingViaVersion = this._getBlockRegistryViaVersion(blockHash, knownVersion);
if (existingViaVersion) {
return existingViaVersion;
}
const blockHashHex = u8aToHex(blockHash);
let waiting = this.#waitingRegistries[blockHashHex];
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '6.5.1' };
export const packageInfo = { name: '@polkadot/api', version: '6.5.2' };
+22 -17
View File
@@ -1,31 +1,36 @@
{
"name": "@polkadot/rpc-core",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/rpc-core",
"private": false,
"repository": {
"directory": "packages/rpc-core",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.5.1",
"@polkadot/types": "6.5.1",
"@polkadot/rpc-provider": "6.5.2",
"@polkadot/types": "6.5.2",
"@polkadot/util": "^7.6.1",
"rxjs": "^7.4.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.6.1"
}
}
}
+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.5.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.5.2' };
+22 -17
View File
@@ -1,26 +1,31 @@
{
"name": "@polkadot/rpc-provider",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Transport providers for the API",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/rpc-provider",
"private": false,
"repository": {
"directory": "packages/rpc-provider",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.5.1",
"@polkadot/types": "6.5.2",
"@polkadot/util": "^7.6.1",
"@polkadot/util-crypto": "^7.6.1",
"@polkadot/x-fetch": "^7.6.1",
@@ -30,8 +35,8 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.6.1",
"@polkadot/types": "6.5.1",
"@polkadot/types": "6.5.2",
"mock-socket": "^9.0.6",
"nock": "^13.1.4"
}
}
}
+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.5.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.5.2' };
+24 -19
View File
@@ -1,16 +1,28 @@
{
"name": "@polkadot/typegen",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Type generation scripts",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/typegen",
"private": false,
"repository": {
"directory": "packages/typegen",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"type": "module",
"version": "6.5.2",
"main": "index.js",
"bin": {
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.cjs",
@@ -18,21 +30,14 @@
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.cjs",
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
},
"repository": "github:polkadot-js/api",
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.15.8",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.5.1",
"@polkadot/rpc-provider": "6.5.1",
"@polkadot/types": "6.5.1",
"@polkadot/types-support": "6.5.1",
"@polkadot/api": "6.5.2",
"@polkadot/rpc-provider": "6.5.2",
"@polkadot/types": "6.5.2",
"@polkadot/types-support": "6.5.2",
"@polkadot/util": "^7.6.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
@@ -42,4 +47,4 @@
"@types/websocket": "^1.0.4",
"@types/yargs": "^17.0.4"
}
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '6.5.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '6.5.2' };
+21 -16
View File
@@ -1,27 +1,32 @@
{
"name": "@polkadot/types-known",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Known type definitions",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/types-known",
"private": false,
"repository": {
"directory": "packages/types-known",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/networks": "^7.6.1",
"@polkadot/types": "6.5.1",
"@polkadot/types": "6.5.2",
"@polkadot/util": "^7.6.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.5.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '6.5.2' };
+20 -15
View File
@@ -1,25 +1,30 @@
{
"name": "@polkadot/types-support",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Supporting files for types, mostly for testing",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-support#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/types-support",
"private": false,
"repository": {
"directory": "packages/types-support",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-support#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/util": "^7.6.1"
}
}
}
+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.5.1' };
export const packageInfo = { name: '@polkadot/types-support', version: '6.5.2' };
+21 -16
View File
@@ -1,23 +1,28 @@
{
"name": "@polkadot/types",
"version": "6.5.1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"bugs": "https://github.com/polkadot-js/api/issues",
"contributors": [],
"description": "Implementation of the Parity codec",
"main": "index.js",
"engines": {
"node": ">=14.0.0"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"license": "Apache-2.0",
"maintainers": [],
"name": "@polkadot/types",
"private": false,
"repository": {
"directory": "packages/types",
"type": "git",
"url": "https://github.com/polkadot-js/api.git"
},
"sideEffects": [
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
"license": "Apache-2.0",
"repository": "github:polkadot-js/api",
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"type": "module",
"version": "6.5.2",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/util": "^7.6.1",
@@ -26,8 +31,8 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.6.1",
"@polkadot/types-support": "6.5.1",
"@polkadot/types-support": "6.5.2",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.12.0"
}
}
}
+10 -9
View File
@@ -52,15 +52,16 @@ describe('Struct', (): void => {
testEncode('toString', '{"foo":"bazzing","bar":69}');
});
it('decodes null', (): void => {
expect(
new (
Struct.with({
txt: Text,
u32: U32
})
)(registry, null).toString()
).toEqual('{}');
it('decodes null/undefined/empty correctly (& equivalently)', (): void => {
const Clazz = Struct.with({
txt: Text,
u32: U32
});
const expected = { txt: '', u32: '0' };
expect(new Clazz(registry, {}).toHuman()).toEqual(expected);
expect(new Clazz(registry, null).toHuman()).toEqual(expected);
expect(new Clazz(registry, undefined).toHuman()).toEqual(expected);
});
it('decodes reusing instantiated inputs', (): void => {
+2 -4
View File
@@ -113,12 +113,10 @@ function decodeStruct <T> (registry: Registry, Types: ConstructorDef, value: unk
return raw;
}, {} as T);
} else if (!value) {
return {} as T;
}
// We assume from here that value is a JS object (Array, Map, Object)
return decodeStructFromObject(registry, Types, value, jsonMap);
return decodeStructFromObject(registry, Types, value || {}, jsonMap);
}
/**
@@ -147,7 +145,7 @@ export class Struct<
readonly #Types: ConstructorDef;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
constructor (registry: Registry, Types: S, value: V | Map<unknown, unknown> | unknown[] | string = {} as V, jsonMap: Map<keyof S, string> = new Map()) {
constructor (registry: Registry, Types: S, value?: V | Map<unknown, unknown> | unknown[] | string | null, jsonMap: Map<keyof S, string> = new Map()) {
super(Object.entries(decodeStruct(registry, mapToTypeMap(registry, Types), value, jsonMap)));
this.registry = registry;
+12 -8
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { FunctionMetadataLatest } from '../interfaces/metadata';
import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, CallBase, CallFunction, IMethod, InterfaceTypes, Registry } from '../types';
import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, CallBase, CallFunction, Codec, IMethod, InterfaceTypes, Registry } from '../types';
import { isHex, isObject, isU8a, u8aToU8a } from '@polkadot/util';
@@ -145,7 +145,6 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
* @description The arguments for the function call
*/
public get args (): A {
// FIXME This should return a Struct instead of an Array
return [...(this.get('args') as Struct).values()] as A;
}
@@ -156,6 +155,13 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
return getArgsDef(this.registry, this.meta);
}
/**
* @description The argument entries
*/
public get argsEntries (): [string, Codec][] {
return [...(this.get('args') as Struct).entries()];
}
/**
* @description The encoded `[sectionIndex, methodIndex]` identifier
*/
@@ -211,12 +217,10 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
}
return {
args: this.args.map((arg) => arg.toHuman(isExpanded)),
// args: this.args.map((arg, index) => call
// ? { [call.meta.args[index].name.toString()]: arg.toHuman(isExpanded) }
// : arg.toHuman(isExpanded)
// ),
// callIndex: u8aToHex(this.callIndex),
args: this.argsEntries.reduce<Record<string, AnyJson>>((args, [n, a]) => ({
...args,
[n]: a.toHuman(isExpanded)
}), {}),
method: call?.method,
section: call?.section,
...(isExpanded && call
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '6.5.1' };
export const packageInfo = { name: '@polkadot/types', version: '6.5.2' };
+37 -37
View File
@@ -1833,40 +1833,40 @@ __metadata:
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.5.1
"@polkadot/types": 6.5.1
"@polkadot/api": 6.5.2
"@polkadot/types": 6.5.2
"@polkadot/util": ^7.6.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/api-derive@6.5.1, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@6.5.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.5.1
"@polkadot/api": 6.5.2
"@polkadot/keyring": ^7.6.1
"@polkadot/rpc-core": 6.5.1
"@polkadot/rpc-provider": 6.5.1
"@polkadot/types": 6.5.1
"@polkadot/rpc-core": 6.5.2
"@polkadot/rpc-provider": 6.5.2
"@polkadot/types": 6.5.2
"@polkadot/util": ^7.6.1
"@polkadot/util-crypto": ^7.6.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/api@6.5.1, @polkadot/api@workspace:packages/api":
"@polkadot/api@6.5.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.5.1
"@polkadot/api-derive": 6.5.2
"@polkadot/keyring": ^7.6.1
"@polkadot/rpc-core": 6.5.1
"@polkadot/rpc-provider": 6.5.1
"@polkadot/types": 6.5.1
"@polkadot/types-known": 6.5.1
"@polkadot/rpc-core": 6.5.2
"@polkadot/rpc-provider": 6.5.2
"@polkadot/types": 6.5.2
"@polkadot/types-known": 6.5.2
"@polkadot/util": ^7.6.1
"@polkadot/util-crypto": ^7.6.1
eventemitter3: ^4.0.7
@@ -1874,9 +1874,9 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/dev@npm:^0.63.6":
version: 0.63.6
resolution: "@polkadot/dev@npm:0.63.6"
"@polkadot/dev@npm:^0.63.9":
version: 0.63.9
resolution: "@polkadot/dev@npm:0.63.9"
dependencies:
"@babel/cli": ^7.15.7
"@babel/core": ^7.15.8
@@ -1964,7 +1964,7 @@ __metadata:
polkadot-exec-rollup: scripts/polkadot-exec-rollup.cjs
polkadot-exec-tsc: scripts/polkadot-exec-tsc.cjs
polkadot-exec-webpack: scripts/polkadot-exec-webpack.cjs
checksum: dfe6364421fdff1b1bc464137b2a39e8a1323d020741dee7480fca073819a3d945114d4a3929807eb23d3a3dfeede90c2ab61c3b9b589a59822d2eb0d1fdfa5f
checksum: b569cab03503a3de225a573d2246e7cacedf2fa4fa22e0ff58ad50248aeca9782fb577d071d2e388f6413eb86cd82e4479da529baaba6a5ce79c81bd5d56cf9b
languageName: node
linkType: hard
@@ -1991,26 +1991,26 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/rpc-core@6.5.1, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@6.5.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.6.1
"@polkadot/rpc-provider": 6.5.1
"@polkadot/types": 6.5.1
"@polkadot/rpc-provider": 6.5.2
"@polkadot/types": 6.5.2
"@polkadot/util": ^7.6.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@6.5.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@6.5.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.6.1
"@polkadot/types": 6.5.1
"@polkadot/types": 6.5.2
"@polkadot/util": ^7.6.1
"@polkadot/util-crypto": ^7.6.1
"@polkadot/x-fetch": ^7.6.1
@@ -2022,12 +2022,12 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/ts@npm:^0.4.10":
version: 0.4.10
resolution: "@polkadot/ts@npm:0.4.10"
"@polkadot/ts@npm:^0.4.12":
version: 0.4.12
resolution: "@polkadot/ts@npm:0.4.12"
dependencies:
"@types/chrome": ^0.0.159
checksum: ec2d5d2070354368d533067c62b2f75ebeea937205a54ae53e0d21e22926a28db0d6b952ff4a0cdae712a026bcb08664f855d727e68d594628b06928847f0fe3
checksum: 9000d625a52bcbd473c090e35989394706104fb8bfdd52f13e8dd0b81bd5061a132f89b0e3f7a04cf449eab34b944be222aa78340b2e381e3773a4466caea172
languageName: node
linkType: hard
@@ -2038,10 +2038,10 @@ __metadata:
"@babel/core": ^7.15.8
"@babel/register": ^7.15.3
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.5.1
"@polkadot/rpc-provider": 6.5.1
"@polkadot/types": 6.5.1
"@polkadot/types-support": 6.5.1
"@polkadot/api": 6.5.2
"@polkadot/rpc-provider": 6.5.2
"@polkadot/types": 6.5.2
"@polkadot/types-support": 6.5.2
"@polkadot/util": ^7.6.1
"@types/websocket": ^1.0.4
"@types/yargs": ^17.0.4
@@ -2057,18 +2057,18 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-known@6.5.1, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@6.5.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.6.1
"@polkadot/types": 6.5.1
"@polkadot/types": 6.5.2
"@polkadot/util": ^7.6.1
languageName: unknown
linkType: soft
"@polkadot/types-support@6.5.1, @polkadot/types-support@workspace:packages/types-support":
"@polkadot/types-support@6.5.2, @polkadot/types-support@workspace:packages/types-support":
version: 0.0.0-use.local
resolution: "@polkadot/types-support@workspace:packages/types-support"
dependencies:
@@ -2077,13 +2077,13 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types@6.5.1, @polkadot/types@workspace:packages/types":
"@polkadot/types@6.5.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.6.1
"@polkadot/types-support": 6.5.1
"@polkadot/types-support": 6.5.2
"@polkadot/util": ^7.6.1
"@polkadot/util-crypto": ^7.6.1
"@types/bn.js": ^4.11.6
@@ -8952,8 +8952,8 @@ resolve@^2.0.0-next.3:
"@babel/core": ^7.15.8
"@babel/register": ^7.15.3
"@babel/runtime": ^7.15.4
"@polkadot/dev": ^0.63.6
"@polkadot/ts": ^0.4.10
"@polkadot/dev": ^0.63.9
"@polkadot/ts": ^0.4.12
"@polkadot/typegen": "workspace:packages/typegen"
"@types/jest": ^27.0.2
copyfiles: ^2.4.1