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:
@@ -150,7 +150,7 @@ const typesBundle = {
|
||||
|
||||
types: [
|
||||
{
|
||||
minmax: [0, undefined] as [number?, number?],
|
||||
minmax: [0, undefined],
|
||||
types: {
|
||||
Balance: 'u64',
|
||||
BalanceOf: 'Balance',
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user