Allow null values in bundles min/max (#3950)

* Allow null values in bundles min/max

* Adjust bundle type definition

* Backwards compat

* Lenient types
This commit is contained in:
Jaco
2021-09-14 08:43:56 +02:00
committed by GitHub
parent 367efda128
commit febcabe109
4 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ const typesBundle = {
types: [
{
minmax: [0, undefined] as [number?, number?],
minmax: [0, undefined],
types: {
Balance: 'u64',
BalanceOf: 'Balance',
+3 -3
View File
@@ -7,7 +7,7 @@ import type { Hash } from '@polkadot/types/interfaces';
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import { bnToBn, isUndefined } from '@polkadot/util';
import { bnToBn, isNull, isUndefined } from '@polkadot/util';
import typesChain from './chain';
import typesModules from './modules';
@@ -22,8 +22,8 @@ export { packageInfo } from './packageInfo';
function filterVersions (versions: OverrideVersionedType[] = [], specVersion: number): RegistryTypes {
return versions
.filter(({ minmax: [min, max] }) =>
(isUndefined(min) || specVersion >= min) &&
(isUndefined(max) || specVersion <= max)
(isUndefined(min) || isNull(min) || specVersion >= min) &&
(isUndefined(max) || isNull(max) || specVersion <= max)
)
.reduce((result: RegistryTypes, { types }): RegistryTypes => ({
...result,
+2 -1
View File
@@ -46,7 +46,8 @@ export interface RegistryError {
}
export interface OverrideVersionedType {
minmax: [number?, number?]; // min (v >= min) and max (v <= max)
// min (v >= min) and max (v <= max)
minmax: [number | undefined | null, number | undefined | null] | [number?, number?] | (number | undefined | null)[];
types: RegistryTypes;
}