diff --git a/CHANGELOG.md b/CHANGELOG.md index 146666cad0..b567463fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ Changes: -- Default to hex-only in `Int/Uint.toJSON` for > 128-bit values +- Default to hex-only in `Int/UInt.toJSON` for > 128-bit values +- Adjust compilation output for `__internal__` class fields ## 10.4.1 Apr 22, 2023 diff --git a/package.json b/package.json index 77af36c9f7..2d4894694e 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,9 @@ "test:one": "polkadot-dev-run-test --env node" }, "devDependencies": { - "@polkadot/dev": "^0.73.4", + "@polkadot/dev": "^0.73.6", "@polkadot/typegen": "workspace:packages/typegen", - "@types/node": "^18.16.1" + "@types/node": "^18.16.2" }, "resolutions": { "typescript": "^5.0.4" diff --git a/packages/api-base/package.json b/packages/api-base/package.json index 4e98592588..f6cd624e7b 100644 --- a/packages/api-base/package.json +++ b/packages/api-base/package.json @@ -24,7 +24,7 @@ "@polkadot/rpc-core": "10.4.2-3-x", "@polkadot/types": "10.4.2-3-x", "@polkadot/util": "^12.0.1", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" } } diff --git a/packages/api-contract/package.json b/packages/api-contract/package.json index d398925ee2..cae6b5b1a8 100644 --- a/packages/api-contract/package.json +++ b/packages/api-contract/package.json @@ -27,7 +27,7 @@ "@polkadot/types-create": "10.4.2-3-x", "@polkadot/util": "^12.0.1", "@polkadot/util-crypto": "^12.0.1", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index 3934feb4e8..89efc98e9a 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -29,7 +29,7 @@ "@polkadot/types-codec": "10.4.2-3-x", "@polkadot/util": "^12.0.1", "@polkadot/util-crypto": "^12.0.1", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/packages/api/package.json b/packages/api/package.json index 2de904edea..e33e5abd00 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -36,7 +36,7 @@ "@polkadot/util": "^12.0.1", "@polkadot/util-crypto": "^12.0.1", "eventemitter3": "^5.0.0", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/packages/api/src/rx/Api.ts b/packages/api/src/rx/Api.ts index 4afacc2753..2d33053cbe 100644 --- a/packages/api/src/rx/Api.ts +++ b/packages/api/src/rx/Api.ts @@ -14,7 +14,7 @@ import { toRxMethod } from './decorateMethod.js'; /** * # @polkadot/api/rx * - * ## Overview + * ## Overview * * @name ApiRx * diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index 94adaa01eb..ead17e1482 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -25,7 +25,7 @@ "@polkadot/rpc-provider": "10.4.2-3-x", "@polkadot/types": "10.4.2-3-x", "@polkadot/util": "^12.0.1", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/packages/rpc-core/src/bundle.ts b/packages/rpc-core/src/bundle.ts index c1727cba55..93fb2c2fbf 100644 --- a/packages/rpc-core/src/bundle.ts +++ b/packages/rpc-core/src/bundle.ts @@ -47,11 +47,11 @@ function logErrorMessage (method: string, { noErrorLog, params, type }: Definiti return; } - const inputs = params.map(({ isOptional, name, type }): string => - `${name}${isOptional ? '?' : ''}: ${type}` - ).join(', '); - - l.error(`${method}(${inputs}): ${type}:: ${error.message}`); + l.error(`${method}(${ + params.map(({ isOptional, name, type }): string => + `${name}${isOptional ? '?' : ''}: ${type}` + ).join(', ') + }): ${type}:: ${error.message}`); } function isTreatAsHex (key: StorageKey): boolean { @@ -98,8 +98,8 @@ export class RpcCore { /** * @constructor - * Default constructor for the Api Object - * @param {ProviderInterface} provider An API provider using HTTP or WebSocket + * Default constructor for the core RPC handler + * @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket) */ constructor (instanceId: string, registry: Registry, provider: ProviderInterface, userRpc: Record> = {}) { // eslint-disable-next-line @typescript-eslint/unbound-method @@ -227,7 +227,7 @@ export class RpcCore { ? await this.#getBlockRegistry(u8aToU8a(blockHash)) : { registry: this.#registryDefault }; - const params = this._formatInputs(registry, null, def, values); + const params = this._formatParams(registry, null, def, values); // only cache .at() queries, e.g. where valid blockHash was supplied const result = await this.provider.send(rpcName, params.map((p) => p.toJSON()), !!blockHash); @@ -307,8 +307,7 @@ export class RpcCore { }; try { - const params = this._formatInputs(registry, null, def, values); - const paramsJson = params.map((p) => p.toJSON()); + const params = this._formatParams(registry, null, def, values); const update = (error?: Error | null, result?: unknown): void => { if (error) { @@ -324,7 +323,7 @@ export class RpcCore { } }; - subscriptionPromise = this._createSubscriber({ paramsJson, subName, subType, update }, errorHandler); + subscriptionPromise = this._createSubscriber({ paramsJson: params.map((p) => p.toJSON()), subName, subType, update }, errorHandler); } catch (error) { errorHandler(error as Error); } @@ -355,19 +354,20 @@ export class RpcCore { return memoized; } - private _formatInputs (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: unknown[]): Codec[] { - const reqArgCount = def.params.filter(({ isOptional }) => !isOptional).length; - const optText = reqArgCount === def.params.length - ? '' - : ` (${def.params.length - reqArgCount} optional)`; + private _formatParams (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: unknown[]): Codec[] { + const reqCount = def.params.filter(({ isOptional }) => !isOptional).length; - if (inputs.length < reqArgCount || inputs.length > def.params.length) { - throw new Error(`Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`); + if (inputs.length < reqCount || inputs.length > def.params.length) { + throw new Error(`Expected ${def.params.length} parameters${reqCount === def.params.length ? '' : ` (${def.params.length - reqCount} optional)`}, ${inputs.length} found instead`); } - return inputs.map((input, index): Codec => - registry.createTypeUnsafe(def.params[index].type, [input], { blockHash }) - ); + const params = new Array(inputs.length); + + for (let i = 0; i < inputs.length; i++) { + params[i] = registry.createTypeUnsafe(def.params[i].type, [inputs[i]], { blockHash }); + } + + return params; } private _formatOutput (registry: Registry, blockHash: Uint8Array | string | null | undefined, method: string, rpc: DefinitionRpc, params: Codec[], result?: unknown): Codec | Codec[] { @@ -382,10 +382,17 @@ export class RpcCore { ? this._formatStorageSet(registry, (result as StorageChangeSetJSON).block, keys, (result as StorageChangeSetJSON).changes) : registry.createType('StorageChangeSet', result); } else if (rpc.type === 'Vec') { - const mapped = (result as StorageChangeSetJSON[]).map(({ block, changes }): [Hash, Codec[]] => [ - registry.createType('Hash', block), - this._formatStorageSet(registry, block, params[0] as Vec, changes) - ]); + const jsonSet = (result as StorageChangeSetJSON[]); + const mapped = new Array<[Hash, Codec[]]>(jsonSet.length); + + for (let i = 0; i < jsonSet.length; i++) { + const { block, changes } = jsonSet[i]; + + mapped[i] = [ + registry.createType('BlockHash', block), + this._formatStorageSet(registry, block, params[0] as Vec, changes) + ]; + } // we only query at a specific block, not a range - flatten return method === 'queryStorageAt' @@ -413,16 +420,15 @@ export class RpcCore { private _formatStorageSet (registry: Registry, blockHash: string, keys: Vec, changes: [string, string | null][]): Codec[] { // For StorageChangeSet, the changes has the [key, value] mappings const withCache = keys.length !== 1; + const values = new Array(keys.length); - // multiple return values (via state.storage subscription), decode the values - // one at a time, all based on the query types. Three values can be returned - - // - Codec - There is a valid value, non-empty - // - null - The storage key is empty - return keys.reduce((results: Codec[], key: StorageKey, index): Codec[] => { - results.push(this._formatStorageSetEntry(registry, blockHash, key, changes, withCache, index)); + // multiple return values (via state.storage subscription), decode the + // values one at a time, all based on the supplied query types + for (let i = 0; i < keys.length; i++) { + values[i] = this._formatStorageSetEntry(registry, blockHash, keys[i], changes, withCache, i); + } - return results; - }, []); + return values; } private _formatStorageSetEntry (registry: Registry, blockHash: string, key: StorageKey, changes: [string, string | null][], withCache: boolean, entryIndex: number): Codec { diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index 431367dcb0..f216629aa5 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -31,7 +31,7 @@ "@polkadot/x-ws": "^12.0.1", "eventemitter3": "^5.0.0", "mock-socket": "^9.2.1", - "nock": "^13.3.0", + "nock": "^13.3.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/packages/typegen/package.json b/packages/typegen/package.json index 5242cc059b..a6de850551 100644 --- a/packages/typegen/package.json +++ b/packages/typegen/package.json @@ -42,7 +42,7 @@ "@polkadot/x-ws": "^12.0.1", "handlebars": "^4.7.7", "tslib": "^2.5.0", - "yargs": "^17.7.1" + "yargs": "^17.7.2" }, "devDependencies": { "@types/websocket": "^1.0.5", diff --git a/packages/types/package.json b/packages/types/package.json index a3ae97e601..d7c1a74aed 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -27,7 +27,7 @@ "@polkadot/types-create": "10.4.2-3-x", "@polkadot/util": "^12.0.1", "@polkadot/util-crypto": "^12.0.1", - "rxjs": "^7.8.0", + "rxjs": "^7.8.1", "tslib": "^2.5.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index a4dc9d59ac..208fd6c459 100644 --- a/yarn.lock +++ b/yarn.lock @@ -387,7 +387,7 @@ __metadata: "@polkadot/rpc-core": 10.4.2-3-x "@polkadot/types": 10.4.2-3-x "@polkadot/util": ^12.0.1 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft @@ -404,7 +404,7 @@ __metadata: "@polkadot/types-create": 10.4.2-3-x "@polkadot/util": ^12.0.1 "@polkadot/util-crypto": ^12.0.1 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft @@ -424,7 +424,7 @@ __metadata: "@polkadot/types-support": 10.4.2-3-x "@polkadot/util": ^12.0.1 "@polkadot/util-crypto": ^12.0.1 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft @@ -449,39 +449,39 @@ __metadata: "@polkadot/util": ^12.0.1 "@polkadot/util-crypto": ^12.0.1 eventemitter3: ^5.0.0 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft -"@polkadot/dev-test@npm:^0.73.4": - version: 0.73.4 - resolution: "@polkadot/dev-test@npm:0.73.4" +"@polkadot/dev-test@npm:^0.73.6": + version: 0.73.6 + resolution: "@polkadot/dev-test@npm:0.73.6" dependencies: jsdom: ^21.1.1 tslib: ^2.5.0 - checksum: 5da15e33d82d37f1222fa41497608f703c6d8aa0f23fc4c3fbcf3367af9ba275e8631502de8a8b1c7c8a2dc789508e367f27406dc5d17152660cd2381a644f2e + checksum: 9a1f2af0fbaf20fc33bb52d9f7268991acf15aa0a7fb62a77e86fd04411e03e092b90ea14efb9f696ee0bb41cc70b088071de7c6f073dd161951e403ede247aa languageName: node linkType: hard -"@polkadot/dev-ts@npm:^0.73.4": - version: 0.73.4 - resolution: "@polkadot/dev-ts@npm:0.73.4" +"@polkadot/dev-ts@npm:^0.73.6": + version: 0.73.6 + resolution: "@polkadot/dev-ts@npm:0.73.6" dependencies: json5: ^2.2.3 tslib: ^2.5.0 typescript: ^5.0.4 - checksum: 0a75dd09dc3e7ba2bb00ebc3cf8824ce3fe63a6afcddeb267d16d916b26908685f9249e9c869869b9283b05b9f96541519d37f314198074adaa69f6ac5c5db39 + checksum: c07b746f6cd215daff16b60fea17bf6ad5b4d3f67c23364279a45b0519f36eccfd034fbe16b3d16613b86a2d94668029febfa16865392a2c1e866bfec1a4ba71 languageName: node linkType: hard -"@polkadot/dev@npm:^0.73.4": - version: 0.73.4 - resolution: "@polkadot/dev@npm:0.73.4" +"@polkadot/dev@npm:^0.73.6": + version: 0.73.6 + resolution: "@polkadot/dev@npm:0.73.6" dependencies: "@eslint/js": ^8.39.0 - "@polkadot/dev-test": ^0.73.4 - "@polkadot/dev-ts": ^0.73.4 + "@polkadot/dev-test": ^0.73.6 + "@polkadot/dev-ts": ^0.73.6 "@rollup/plugin-alias": ^5.0.0 "@rollup/plugin-commonjs": ^24.1.0 "@rollup/plugin-dynamic-import-vars": ^2.0.3 @@ -513,12 +513,12 @@ __metadata: rollup-plugin-cleanup: ^3.2.1 tslib: ^2.5.0 typescript: ^5.0.4 - webpack: ^5.80.0 + webpack: ^5.81.0 webpack-cli: ^5.0.2 webpack-dev-server: ^4.13.3 webpack-merge: ^5.8.0 webpack-subresource-integrity: ^5.2.0-rc.1 - yargs: ^17.7.1 + yargs: ^17.7.2 bin: polkadot-ci-ghact-build: scripts/polkadot-ci-ghact-build.mjs polkadot-ci-ghact-docs: scripts/polkadot-ci-ghact-docs.mjs @@ -543,7 +543,7 @@ __metadata: polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs - checksum: 06bc908e182a08866cea35f721e40b20bbfc6a75d5394e053aea2ac0b5bd442d043523acafd3033821fa752baa16f4a987802d06cf2c1704883e7cf1100a1d5f + checksum: ee295bc31e7d4a3ea8256ceec2527e8c2e607f5d8d133e2dfde625eaf349e9be6daf901289e40ac716a835285e8e14df5959a85bd5776f09b252a4fa25c9e826 languageName: node linkType: hard @@ -593,7 +593,7 @@ __metadata: "@polkadot/rpc-provider": 10.4.2-3-x "@polkadot/types": 10.4.2-3-x "@polkadot/util": ^12.0.1 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft @@ -613,7 +613,7 @@ __metadata: "@substrate/connect": 0.7.24 eventemitter3: ^5.0.0 mock-socket: ^9.2.1 - nock: ^13.3.0 + nock: ^13.3.1 tslib: ^2.5.0 dependenciesMeta: "@substrate/connect": @@ -641,7 +641,7 @@ __metadata: "@types/yargs": ^17.0.24 handlebars: ^4.7.7 tslib: ^2.5.0 - yargs: ^17.7.1 + yargs: ^17.7.2 bin: polkadot-types-chain-info: ./scripts/polkadot-types-chain-info.mjs polkadot-types-from-chain: ./scripts/polkadot-types-from-chain.mjs @@ -721,7 +721,7 @@ __metadata: "@polkadot/types-support": 10.4.2-3-x "@polkadot/util": ^12.0.1 "@polkadot/util-crypto": ^12.0.1 - rxjs: ^7.8.0 + rxjs: ^7.8.1 tslib: ^2.5.0 languageName: unknown linkType: soft @@ -1235,10 +1235,10 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^18.16.1": - version: 18.16.1 - resolution: "@types/node@npm:18.16.1" - checksum: 799026b949a48993cba7c9b81b2eabfdfb34c880744cb44c1c990fbedc9e315f3634d126eb2cf9a6e0795577c01016e2326d98565bef695ada9d363fadeb6946 +"@types/node@npm:*, @types/node@npm:^18.16.2": + version: 18.16.2 + resolution: "@types/node@npm:18.16.2" + checksum: 7ad66d23b3b93885a9f879bff98e0196790ad35589b47a3d81b52db969ad17ee298082020296df5166c2d72d3cd6a4b9ab34d254483637d967944a4b3e6febdb languageName: node linkType: hard @@ -6164,15 +6164,15 @@ fsevents@~2.3.2: languageName: node linkType: hard -"nock@npm:^13.3.0": - version: 13.3.0 - resolution: "nock@npm:13.3.0" +"nock@npm:^13.3.1": + version: 13.3.1 + resolution: "nock@npm:13.3.1" dependencies: debug: ^4.1.0 json-stringify-safe: ^5.0.1 lodash: ^4.17.21 propagate: ^2.0.0 - checksum: 118d04e95a17f493898a82b5dfecc03762776e1980d9c3b2077479747e60b77109c5f7c0df969d1a8f6039260abe5961733553a5841f0f627bb35238576a0009 + checksum: 0f2a73e8432f6b5650656c53eef99f9e5bbde3df538dc2f07057edc4438cfc61a394c9d06dd82e60f6e86d42433f20f3c04364a1f088beee7bf03a24e3f0fdd0 languageName: node linkType: hard @@ -7372,9 +7372,9 @@ fsevents@~2.3.2: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: - "@polkadot/dev": ^0.73.4 + "@polkadot/dev": ^0.73.6 "@polkadot/typegen": "workspace:packages/typegen" - "@types/node": ^18.16.1 + "@types/node": ^18.16.2 languageName: unknown linkType: soft @@ -7408,12 +7408,12 @@ fsevents@~2.3.2: languageName: node linkType: hard -"rxjs@npm:^7.8.0": - version: 7.8.0 - resolution: "rxjs@npm:7.8.0" +"rxjs@npm:^7.8.1": + version: 7.8.1 + resolution: "rxjs@npm:7.8.1" dependencies: tslib: ^2.1.0 - checksum: 61b4d4fd323c1043d8d6ceb91f24183b28bcf5def4f01ca111511d5c6b66755bc5578587fe714ef5d67cf4c9f2e26f4490d4e1d8cabf9bd5967687835e9866a2 + checksum: de4b53db1063e618ec2eca0f7965d9137cabe98cf6be9272efe6c86b47c17b987383df8574861bcced18ebd590764125a901d5506082be84a8b8e364bf05f119 languageName: node linkType: hard @@ -8788,9 +8788,9 @@ fsevents@~2.3.2: languageName: node linkType: hard -"webpack@npm:^5.80.0": - version: 5.80.0 - resolution: "webpack@npm:5.80.0" +"webpack@npm:^5.81.0": + version: 5.81.0 + resolution: "webpack@npm:5.81.0" dependencies: "@types/eslint-scope": ^3.7.3 "@types/estree": ^1.0.0 @@ -8821,7 +8821,7 @@ fsevents@~2.3.2: optional: true bin: webpack: bin/webpack.js - checksum: 7b9229d64439ceb20372e0b1452025e2a37cf136f7867102e095b99c3f2bbaf8b0e7e8ff093278238e45b0b1efaae4ed5f0709be48c20e8dab94e94f11c8e5c7 + checksum: 1a6eecaffac3226d80f4e8f330b32e0ff117d9dafd8700166d230afbc171d68ea1ff55a9939fa789307f7b9d11881889ccb8e6cd79d4ccbaeef916788ce73fdb languageName: node linkType: hard @@ -9050,9 +9050,9 @@ fsevents@~2.3.2: languageName: node linkType: hard -"yargs@npm:^17.0.0, yargs@npm:^17.7.1": - version: 17.7.1 - resolution: "yargs@npm:17.7.1" +"yargs@npm:^17.0.0, yargs@npm:^17.7.2": + version: 17.7.2 + resolution: "yargs@npm:17.7.2" dependencies: cliui: ^8.0.1 escalade: ^3.1.1 @@ -9061,7 +9061,7 @@ fsevents@~2.3.2: string-width: ^4.2.3 y18n: ^5.0.5 yargs-parser: ^21.1.1 - checksum: 3d8a43c336a4942bc68080768664aca85c7bd406f018bad362fd255c41c8f4e650277f42fd65d543fce99e084124ddafee7bbfc1a5c6a8fda4cec78609dcf8d4 + checksum: 73b572e863aa4a8cbef323dd911d79d193b772defd5a51aab0aca2d446655216f5002c42c5306033968193bdbf892a7a4c110b0d77954a7fdf563e653967b56a languageName: node linkType: hard