From b9cbb9e2e80205606168fdf04d029646a9499b29 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 1 Feb 2023 08:20:06 +0200 Subject: [PATCH] Adjust Weight alias for WeightV0 injection (#5462) * Adjust Weight alias for WeightV0 injection * 9.13.3 --- CHANGELOG.md | 7 + package.json | 2 +- packages/api-augment/package.json | 12 +- packages/api-base/package.json | 6 +- packages/api-contract/package.json | 12 +- packages/api-derive/package.json | 24 +-- packages/api/package.json | 28 ++-- packages/rpc-augment/package.json | 8 +- packages/rpc-core/package.json | 10 +- packages/rpc-provider/package.json | 6 +- packages/typegen/package.json | 20 +-- packages/types-augment/package.json | 6 +- .../types-augment/src/registry/interfaces.ts | 3 +- packages/types-codec/package.json | 8 +- packages/types-codec/src/base/Vec.ts | 16 +- packages/types-create/package.json | 6 +- packages/types-known/package.json | 10 +- packages/types-support/package.json | 2 +- packages/types/package.json | 10 +- packages/types/src/create/registry.ts | 17 +- .../src/interfaces/runtime/definitions.ts | 1 + .../types/src/interfaces/runtime/types.ts | 3 + yarn.lock | 156 +++++++++--------- 23 files changed, 192 insertions(+), 181 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c05e7ac7ec..a3e1590fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## 9.13.3 Feb 1, 2023 + +Changes: + +- Adjust `Weight` alias detection to cater for `WeightV0/u32` overrides (e.g. early Kusama blocks) + + ## 9.13.2 Jan 29, 2023 Changes: diff --git a/package.json b/package.json index 43bf2c0478..9763985167 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "sideEffects": false, "type": "module", - "version": "9.13.2", + "version": "9.13.3", "versions": { "git": "9.13.2", "npm": "9.13.2" diff --git a/packages/api-augment/package.json b/packages/api-augment/package.json index 47fb2506bd..a349eeee68 100644 --- a/packages/api-augment/package.json +++ b/packages/api-augment/package.json @@ -20,15 +20,15 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/api-base": "9.13.2", - "@polkadot/rpc-augment": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-augment": "9.13.2", - "@polkadot/types-codec": "9.13.2", + "@polkadot/api-base": "9.13.3", + "@polkadot/rpc-augment": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-augment": "9.13.3", + "@polkadot/types-codec": "9.13.3", "@polkadot/util": "^10.3.1" } } diff --git a/packages/api-base/package.json b/packages/api-base/package.json index 98d0aa8e9a..ad7a50e8bd 100644 --- a/packages/api-base/package.json +++ b/packages/api-base/package.json @@ -20,12 +20,12 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/rpc-core": "9.13.2", - "@polkadot/types": "9.13.2", + "@polkadot/rpc-core": "9.13.3", + "@polkadot/types": "9.13.3", "@polkadot/util": "^10.3.1", "rxjs": "^7.8.0" } diff --git a/packages/api-contract/package.json b/packages/api-contract/package.json index 31f127006e..5964f5ecc4 100644 --- a/packages/api-contract/package.json +++ b/packages/api-contract/package.json @@ -20,20 +20,20 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/api": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-codec": "9.13.2", - "@polkadot/types-create": "9.13.2", + "@polkadot/api": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-codec": "9.13.3", + "@polkadot/types-create": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "rxjs": "^7.8.0" }, "devDependencies": { - "@polkadot/api-augment": "9.13.2", + "@polkadot/api-augment": "9.13.3", "@polkadot/keyring": "^10.3.1" } } diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index c58a1c0064..b2e8022b96 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -20,25 +20,25 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/api": "9.13.2", - "@polkadot/api-augment": "9.13.2", - "@polkadot/api-base": "9.13.2", - "@polkadot/rpc-core": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-codec": "9.13.2", + "@polkadot/api": "9.13.3", + "@polkadot/api-augment": "9.13.3", + "@polkadot/api-base": "9.13.3", + "@polkadot/rpc-core": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-codec": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "rxjs": "^7.8.0" }, "devDependencies": { - "@polkadot/api": "9.13.2", - "@polkadot/api-augment": "9.13.2", - "@polkadot/rpc-augment": "9.13.2", - "@polkadot/rpc-provider": "9.13.2", - "@polkadot/types-support": "9.13.2" + "@polkadot/api": "9.13.3", + "@polkadot/api-augment": "9.13.3", + "@polkadot/rpc-augment": "9.13.3", + "@polkadot/rpc-provider": "9.13.3", + "@polkadot/types-support": "9.13.3" } } diff --git a/packages/api/package.json b/packages/api/package.json index eb6388b97f..645579dd63 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -20,29 +20,29 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/api-augment": "9.13.2", - "@polkadot/api-base": "9.13.2", - "@polkadot/api-derive": "9.13.2", + "@polkadot/api-augment": "9.13.3", + "@polkadot/api-base": "9.13.3", + "@polkadot/api-derive": "9.13.3", "@polkadot/keyring": "^10.3.1", - "@polkadot/rpc-augment": "9.13.2", - "@polkadot/rpc-core": "9.13.2", - "@polkadot/rpc-provider": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-augment": "9.13.2", - "@polkadot/types-codec": "9.13.2", - "@polkadot/types-create": "9.13.2", - "@polkadot/types-known": "9.13.2", + "@polkadot/rpc-augment": "9.13.3", + "@polkadot/rpc-core": "9.13.3", + "@polkadot/rpc-provider": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-augment": "9.13.3", + "@polkadot/types-codec": "9.13.3", + "@polkadot/types-create": "9.13.3", + "@polkadot/types-known": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "eventemitter3": "^5.0.0", "rxjs": "^7.8.0" }, "devDependencies": { - "@polkadot/api-augment": "9.13.2", - "@polkadot/types-support": "9.13.2" + "@polkadot/api-augment": "9.13.3", + "@polkadot/types-support": "9.13.3" } } diff --git a/packages/rpc-augment/package.json b/packages/rpc-augment/package.json index 009706ebd5..4c5229c8a5 100644 --- a/packages/rpc-augment/package.json +++ b/packages/rpc-augment/package.json @@ -20,13 +20,13 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/rpc-core": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-codec": "9.13.2", + "@polkadot/rpc-core": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-codec": "9.13.3", "@polkadot/util": "^10.3.1" } } diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index 3153723520..2ae2a70ada 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -20,18 +20,18 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/rpc-augment": "9.13.2", - "@polkadot/rpc-provider": "9.13.2", - "@polkadot/types": "9.13.2", + "@polkadot/rpc-augment": "9.13.3", + "@polkadot/rpc-provider": "9.13.3", + "@polkadot/types": "9.13.3", "@polkadot/util": "^10.3.1", "rxjs": "^7.8.0" }, "devDependencies": { "@polkadot/keyring": "^10.3.1", - "@polkadot/rpc-augment": "9.13.2" + "@polkadot/rpc-augment": "9.13.3" } } diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index b53787828a..494b05ec94 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -20,13 +20,13 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", "@polkadot/keyring": "^10.3.1", - "@polkadot/types": "9.13.2", - "@polkadot/types-support": "9.13.2", + "@polkadot/types": "9.13.3", + "@polkadot/types-support": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "@polkadot/x-fetch": "^10.3.1", diff --git a/packages/typegen/package.json b/packages/typegen/package.json index 210ec0aa89..161ffc333a 100644 --- a/packages/typegen/package.json +++ b/packages/typegen/package.json @@ -20,7 +20,7 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "bin": { "polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs", @@ -33,15 +33,15 @@ "@babel/core": "^7.20.12", "@babel/register": "^7.18.9", "@babel/runtime": "^7.20.13", - "@polkadot/api": "9.13.2", - "@polkadot/api-augment": "9.13.2", - "@polkadot/rpc-augment": "9.13.2", - "@polkadot/rpc-provider": "9.13.2", - "@polkadot/types": "9.13.2", - "@polkadot/types-augment": "9.13.2", - "@polkadot/types-codec": "9.13.2", - "@polkadot/types-create": "9.13.2", - "@polkadot/types-support": "9.13.2", + "@polkadot/api": "9.13.3", + "@polkadot/api-augment": "9.13.3", + "@polkadot/rpc-augment": "9.13.3", + "@polkadot/rpc-provider": "9.13.3", + "@polkadot/types": "9.13.3", + "@polkadot/types-augment": "9.13.3", + "@polkadot/types-codec": "9.13.3", + "@polkadot/types-create": "9.13.3", + "@polkadot/types-support": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "@polkadot/x-ws": "^10.3.1", diff --git a/packages/types-augment/package.json b/packages/types-augment/package.json index 04e332a91a..534d477691 100644 --- a/packages/types-augment/package.json +++ b/packages/types-augment/package.json @@ -20,12 +20,12 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/types": "9.13.2", - "@polkadot/types-codec": "9.13.2", + "@polkadot/types": "9.13.3", + "@polkadot/types-codec": "9.13.3", "@polkadot/util": "^10.3.1" } } diff --git a/packages/types-augment/src/registry/interfaces.ts b/packages/types-augment/src/registry/interfaces.ts index 0ab33bc6b3..fa7f66458d 100644 --- a/packages/types-augment/src/registry/interfaces.ts +++ b/packages/types-augment/src/registry/interfaces.ts @@ -52,7 +52,7 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase'; import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; import type { RpcMethods } from '@polkadot/types/interfaces/rpc'; -import type { AccountId, AccountId20, AccountId32, AccountId33, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, CrateVersion, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, SlotDuration, StorageData, StorageInfo, StorageProof, TransactionInfo, TransactionLongevity, TransactionPriority, TransactionStorageProof, TransactionTag, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier, WeightV1, WeightV2 } from '@polkadot/types/interfaces/runtime'; +import type { AccountId, AccountId20, AccountId32, AccountId33, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, CrateVersion, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, SlotDuration, StorageData, StorageInfo, StorageProof, TransactionInfo, TransactionLongevity, TransactionPriority, TransactionStorageProof, TransactionTag, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier, WeightV0, WeightV1, WeightV2 } from '@polkadot/types/interfaces/runtime'; import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, Si1Field, Si1LookupTypeId, Si1Path, Si1Type, Si1TypeDef, Si1TypeDefArray, Si1TypeDefBitSequence, Si1TypeDefCompact, Si1TypeDefComposite, Si1TypeDefPrimitive, Si1TypeDefSequence, Si1TypeDefTuple, Si1TypeDefVariant, Si1TypeParameter, Si1Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo'; import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session'; @@ -1153,6 +1153,7 @@ declare module '@polkadot/types/types/registry' { WeightMultiplier: WeightMultiplier; WeightPerClass: WeightPerClass; WeightToFeeCoefficient: WeightToFeeCoefficient; + WeightV0: WeightV0; WeightV1: WeightV1; WeightV2: WeightV2; WildFungibility: WildFungibility; diff --git a/packages/types-codec/package.json b/packages/types-codec/package.json index c19f2f401d..5a9595eea0 100644 --- a/packages/types-codec/package.json +++ b/packages/types-codec/package.json @@ -20,7 +20,7 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", @@ -28,9 +28,9 @@ "@polkadot/x-bigint": "^10.3.1" }, "devDependencies": { - "@polkadot/types": "9.13.2", - "@polkadot/types-augment": "9.13.2", - "@polkadot/types-support": "9.13.2", + "@polkadot/types": "9.13.3", + "@polkadot/types-augment": "9.13.3", + "@polkadot/types-support": "9.13.3", "@polkadot/util-crypto": "^10.3.1" } } diff --git a/packages/types-codec/src/base/Vec.ts b/packages/types-codec/src/base/Vec.ts index 7d252cba2e..30ad79e41c 100644 --- a/packages/types-codec/src/base/Vec.ts +++ b/packages/types-codec/src/base/Vec.ts @@ -87,17 +87,11 @@ export class Vec extends AbstractArray { this.#Type = definition || setDefinition(typeToConstructor(registry, Type)); - try { - this.initialU8aLength = ( - isU8a(decodeFrom) - ? decodeU8aVec(registry, this, decodeFrom, startAt, this.#Type) - : decodeVec(registry, this, decodeFrom, startAt, this.#Type) - )[0]; - } catch (e) { - console.error(decodeFrom, length, startAt); - - throw e; - } + this.initialU8aLength = ( + isU8a(decodeFrom) + ? decodeU8aVec(registry, this, decodeFrom, startAt, this.#Type) + : decodeVec(registry, this, decodeFrom, startAt, this.#Type) + )[0]; } public static with (Type: CodecClass | string): CodecClass> { diff --git a/packages/types-create/package.json b/packages/types-create/package.json index 38ed7ef657..d58aab944f 100644 --- a/packages/types-create/package.json +++ b/packages/types-create/package.json @@ -20,14 +20,14 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", - "@polkadot/types-codec": "9.13.2", + "@polkadot/types-codec": "9.13.3", "@polkadot/util": "^10.3.1" }, "devDependencies": { - "@polkadot/types": "9.13.2" + "@polkadot/types": "9.13.3" } } diff --git a/packages/types-known/package.json b/packages/types-known/package.json index 79b9781502..f0cb159dfd 100644 --- a/packages/types-known/package.json +++ b/packages/types-known/package.json @@ -20,17 +20,17 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", "@polkadot/networks": "^10.3.1", - "@polkadot/types": "9.13.2", - "@polkadot/types-codec": "9.13.2", - "@polkadot/types-create": "9.13.2", + "@polkadot/types": "9.13.3", + "@polkadot/types-codec": "9.13.3", + "@polkadot/types-create": "9.13.3", "@polkadot/util": "^10.3.1" }, "devDependencies": { - "@polkadot/api": "9.13.2" + "@polkadot/api": "9.13.3" } } diff --git a/packages/types-support/package.json b/packages/types-support/package.json index 3813d513b7..a847147e04 100644 --- a/packages/types-support/package.json +++ b/packages/types-support/package.json @@ -20,7 +20,7 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", diff --git a/packages/types/package.json b/packages/types/package.json index 9cc71c7bda..52ab045473 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -20,20 +20,20 @@ "./detectPackage.cjs" ], "type": "module", - "version": "9.13.2", + "version": "9.13.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.20.13", "@polkadot/keyring": "^10.3.1", - "@polkadot/types-augment": "9.13.2", - "@polkadot/types-codec": "9.13.2", - "@polkadot/types-create": "9.13.2", + "@polkadot/types-augment": "9.13.3", + "@polkadot/types-codec": "9.13.3", + "@polkadot/types-create": "9.13.3", "@polkadot/util": "^10.3.1", "@polkadot/util-crypto": "^10.3.1", "rxjs": "^7.8.0" }, "devDependencies": { "@polkadot/keyring": "^10.3.1", - "@polkadot/types-support": "9.13.2" + "@polkadot/types-support": "9.13.3" } } diff --git a/packages/types/src/create/registry.ts b/packages/types/src/create/registry.ts index 6beb11b971..6fafc11082 100644 --- a/packages/types/src/create/registry.ts +++ b/packages/types/src/create/registry.ts @@ -4,12 +4,12 @@ import type { AnyString, Codec, CodecClass, IU8a, LookupString } from '@polkadot/types-codec/types'; import type { CreateOptions, TypeDef } from '@polkadot/types-create/types'; import type { ExtDef } from '../extrinsic/signedExtensions/types'; -import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant, WeightV2 } from '../interfaces/types'; +import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant, WeightV1, WeightV2 } from '../interfaces/types'; import type { CallFunction, CodecHasher, Definitions, DetectCodec, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types'; import { DoNotConstruct, Json, Raw } from '@polkadot/types-codec'; import { constructTypeClass, createClassUnsafe, createTypeUnsafe } from '@polkadot/types-create'; -import { assertReturn, BN_ZERO, formatBalance, isFunction, isNumber, isString, isU8a, lazyMethod, logger, objectSpread, stringCamelCase, stringify } from '@polkadot/util'; +import { assertReturn, BN_ZERO, formatBalance, isBn, isFunction, isNumber, isString, isU8a, lazyMethod, logger, objectSpread, stringCamelCase, stringify } from '@polkadot/util'; import { blake2AsU8a } from '@polkadot/util-crypto'; import { expandExtensionTypes, fallbackExtensions, findUnknownExtensions } from '../extrinsic/signedExtensions'; @@ -542,18 +542,23 @@ export class TypeRegistry implements Registry { // default to V1 - this includes 1.5 (with single field) let weightType = 'WeightV1'; - const Clazz = this.get('SpWeightsWeightV2Weight'); + const WeightV2 = this.get('SpWeightsWeightV2Weight'); // detection for WeightV2 type - if (Clazz) { - const weight = new Clazz(this); + if (WeightV2) { + const weight = new WeightV2(this); if (weight.refTime && weight.proofSize) { weightType = 'SpWeightsWeightV2Weight'; } } - this.register({ Weight: weightType }); + if (weightType !== 'WeightV1' || !isBn(this.createType('Weight'))) { + // where we have an already-supplied override, we don't clobber + // it with our detected value (This protects against pre-defines + // where Weight may be aliassed to WeightV0, e.g. in early Kusama chains) + this.register({ Weight: weightType }); + } }; // sets the metadata diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index fe305627cf..85268a7bcc 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -212,6 +212,7 @@ export default { }, ValidatorId: 'AccountId', ValidatorIdOf: 'ValidatorId', + WeightV0: 'u32', WeightV1: 'u64', WeightV2: { refTime: 'Compact', diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index 6958d54f04..08f8e33516 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -394,6 +394,9 @@ export interface Weight extends WeightV2 {} /** @name WeightMultiplier */ export interface WeightMultiplier extends Fixed64 {} +/** @name WeightV0 */ +export interface WeightV0 extends u32 {} + /** @name WeightV1 */ export interface WeightV1 extends u64 {} diff --git a/yarn.lock b/yarn.lock index 2aee2f31de..0dfb34153d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1988,27 +1988,27 @@ __metadata: languageName: node linkType: hard -"@polkadot/api-augment@9.13.2, @polkadot/api-augment@workspace:packages/api-augment": +"@polkadot/api-augment@9.13.3, @polkadot/api-augment@workspace:packages/api-augment": version: 0.0.0-use.local resolution: "@polkadot/api-augment@workspace:packages/api-augment" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/api-base": 9.13.2 - "@polkadot/rpc-augment": 9.13.2 - "@polkadot/types": 9.13.2 - "@polkadot/types-augment": 9.13.2 - "@polkadot/types-codec": 9.13.2 + "@polkadot/api-base": 9.13.3 + "@polkadot/rpc-augment": 9.13.3 + "@polkadot/types": 9.13.3 + "@polkadot/types-augment": 9.13.3 + "@polkadot/types-codec": 9.13.3 "@polkadot/util": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/api-base@9.13.2, @polkadot/api-base@workspace:packages/api-base": +"@polkadot/api-base@9.13.3, @polkadot/api-base@workspace:packages/api-base": version: 0.0.0-use.local resolution: "@polkadot/api-base@workspace:packages/api-base" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/rpc-core": 9.13.2 - "@polkadot/types": 9.13.2 + "@polkadot/rpc-core": 9.13.3 + "@polkadot/types": 9.13.3 "@polkadot/util": ^10.3.1 rxjs: ^7.8.0 languageName: unknown @@ -2019,56 +2019,56 @@ __metadata: resolution: "@polkadot/api-contract@workspace:packages/api-contract" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/api": 9.13.2 - "@polkadot/api-augment": 9.13.2 + "@polkadot/api": 9.13.3 + "@polkadot/api-augment": 9.13.3 "@polkadot/keyring": ^10.3.1 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-create": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-create": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 rxjs: ^7.8.0 languageName: unknown linkType: soft -"@polkadot/api-derive@9.13.2, @polkadot/api-derive@workspace:packages/api-derive": +"@polkadot/api-derive@9.13.3, @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.20.13 - "@polkadot/api": 9.13.2 - "@polkadot/api-augment": 9.13.2 - "@polkadot/api-base": 9.13.2 - "@polkadot/rpc-augment": 9.13.2 - "@polkadot/rpc-core": 9.13.2 - "@polkadot/rpc-provider": 9.13.2 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/api": 9.13.3 + "@polkadot/api-augment": 9.13.3 + "@polkadot/api-base": 9.13.3 + "@polkadot/rpc-augment": 9.13.3 + "@polkadot/rpc-core": 9.13.3 + "@polkadot/rpc-provider": 9.13.3 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 rxjs: ^7.8.0 languageName: unknown linkType: soft -"@polkadot/api@9.13.2, @polkadot/api@workspace:packages/api": +"@polkadot/api@9.13.3, @polkadot/api@workspace:packages/api": version: 0.0.0-use.local resolution: "@polkadot/api@workspace:packages/api" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/api-augment": 9.13.2 - "@polkadot/api-base": 9.13.2 - "@polkadot/api-derive": 9.13.2 + "@polkadot/api-augment": 9.13.3 + "@polkadot/api-base": 9.13.3 + "@polkadot/api-derive": 9.13.3 "@polkadot/keyring": ^10.3.1 - "@polkadot/rpc-augment": 9.13.2 - "@polkadot/rpc-core": 9.13.2 - "@polkadot/rpc-provider": 9.13.2 - "@polkadot/types": 9.13.2 - "@polkadot/types-augment": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-create": 9.13.2 - "@polkadot/types-known": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/rpc-augment": 9.13.3 + "@polkadot/rpc-core": 9.13.3 + "@polkadot/rpc-provider": 9.13.3 + "@polkadot/types": 9.13.3 + "@polkadot/types-augment": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-create": 9.13.3 + "@polkadot/types-known": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 eventemitter3: ^5.0.0 @@ -2200,40 +2200,40 @@ __metadata: languageName: node linkType: hard -"@polkadot/rpc-augment@9.13.2, @polkadot/rpc-augment@workspace:packages/rpc-augment": +"@polkadot/rpc-augment@9.13.3, @polkadot/rpc-augment@workspace:packages/rpc-augment": version: 0.0.0-use.local resolution: "@polkadot/rpc-augment@workspace:packages/rpc-augment" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/rpc-core": 9.13.2 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 + "@polkadot/rpc-core": 9.13.3 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 "@polkadot/util": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/rpc-core@9.13.2, @polkadot/rpc-core@workspace:packages/rpc-core": +"@polkadot/rpc-core@9.13.3, @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.20.13 "@polkadot/keyring": ^10.3.1 - "@polkadot/rpc-augment": 9.13.2 - "@polkadot/rpc-provider": 9.13.2 - "@polkadot/types": 9.13.2 + "@polkadot/rpc-augment": 9.13.3 + "@polkadot/rpc-provider": 9.13.3 + "@polkadot/types": 9.13.3 "@polkadot/util": ^10.3.1 rxjs: ^7.8.0 languageName: unknown linkType: soft -"@polkadot/rpc-provider@9.13.2, @polkadot/rpc-provider@workspace:packages/rpc-provider": +"@polkadot/rpc-provider@9.13.3, @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.20.13 "@polkadot/keyring": ^10.3.1 - "@polkadot/types": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 "@polkadot/x-fetch": ^10.3.1 @@ -2256,15 +2256,15 @@ __metadata: "@babel/core": ^7.20.12 "@babel/register": ^7.18.9 "@babel/runtime": ^7.20.13 - "@polkadot/api": 9.13.2 - "@polkadot/api-augment": 9.13.2 - "@polkadot/rpc-augment": 9.13.2 - "@polkadot/rpc-provider": 9.13.2 - "@polkadot/types": 9.13.2 - "@polkadot/types-augment": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-create": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/api": 9.13.3 + "@polkadot/api-augment": 9.13.3 + "@polkadot/rpc-augment": 9.13.3 + "@polkadot/rpc-provider": 9.13.3 + "@polkadot/types": 9.13.3 + "@polkadot/types-augment": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-create": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 "@polkadot/x-ws": ^10.3.1 @@ -2282,57 +2282,57 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/types-augment@9.13.2, @polkadot/types-augment@workspace:packages/types-augment": +"@polkadot/types-augment@9.13.3, @polkadot/types-augment@workspace:packages/types-augment": version: 0.0.0-use.local resolution: "@polkadot/types-augment@workspace:packages/types-augment" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 "@polkadot/util": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/types-codec@9.13.2, @polkadot/types-codec@workspace:packages/types-codec": +"@polkadot/types-codec@9.13.3, @polkadot/types-codec@workspace:packages/types-codec": version: 0.0.0-use.local resolution: "@polkadot/types-codec@workspace:packages/types-codec" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/types": 9.13.2 - "@polkadot/types-augment": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-augment": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 "@polkadot/x-bigint": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/types-create@9.13.2, @polkadot/types-create@workspace:packages/types-create": +"@polkadot/types-create@9.13.3, @polkadot/types-create@workspace:packages/types-create": version: 0.0.0-use.local resolution: "@polkadot/types-create@workspace:packages/types-create" dependencies: "@babel/runtime": ^7.20.13 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 "@polkadot/util": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/types-known@9.13.2, @polkadot/types-known@workspace:packages/types-known": +"@polkadot/types-known@9.13.3, @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.20.13 - "@polkadot/api": 9.13.2 + "@polkadot/api": 9.13.3 "@polkadot/networks": ^10.3.1 - "@polkadot/types": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-create": 9.13.2 + "@polkadot/types": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-create": 9.13.3 "@polkadot/util": ^10.3.1 languageName: unknown linkType: soft -"@polkadot/types-support@9.13.2, @polkadot/types-support@workspace:packages/types-support": +"@polkadot/types-support@9.13.3, @polkadot/types-support@workspace:packages/types-support": version: 0.0.0-use.local resolution: "@polkadot/types-support@workspace:packages/types-support" dependencies: @@ -2341,16 +2341,16 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/types@9.13.2, @polkadot/types@workspace:packages/types": +"@polkadot/types@9.13.3, @polkadot/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@polkadot/types@workspace:packages/types" dependencies: "@babel/runtime": ^7.20.13 "@polkadot/keyring": ^10.3.1 - "@polkadot/types-augment": 9.13.2 - "@polkadot/types-codec": 9.13.2 - "@polkadot/types-create": 9.13.2 - "@polkadot/types-support": 9.13.2 + "@polkadot/types-augment": 9.13.3 + "@polkadot/types-codec": 9.13.3 + "@polkadot/types-create": 9.13.3 + "@polkadot/types-support": 9.13.3 "@polkadot/util": ^10.3.1 "@polkadot/util-crypto": ^10.3.1 rxjs: ^7.8.0