Warn on deprecated getter usage (#5423)

* Warn on deprecated getter usage

* Adjust warning message

* Make read-only interafces for deprecations

* Re-word Codec deprecation messages

* Re-adjust warning messages

* Fix getter return

* Explicit deprecation holder
This commit is contained in:
Jaco
2023-01-19 09:56:34 +02:00
committed by GitHub
parent 96a3ef51f0
commit da1cf9d64e
23 changed files with 253 additions and 110 deletions
+6 -4
View File
@@ -7,7 +7,7 @@ import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant } from '../interfaces/types';
import type { CallFunction, CodecHasher, Definitions, DetectCodec, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
import { DoNotConstruct, Json, Raw } from '@polkadot/types-codec';
import { DoNotConstruct, Json, Raw, warnGet } 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 { blake2AsU8a } from '@polkadot/util-crypto';
@@ -166,9 +166,6 @@ function extractProperties (registry: TypeRegistry, metadata: Metadata): ChainPr
}
export class TypeRegistry implements Registry {
/** @deprecated This is not populated anymore. Use $createdAtHash instead. */
public createdAtHash?: never;
#chainProperties?: ChainProperties;
#classes = new Map<string, CodecClass>();
#definitions = new Map<string, string>();
@@ -206,6 +203,11 @@ export class TypeRegistry implements Registry {
}
}
/** @deprecated Use $createdAtHash instead. This getter will be removed in a future version. */
public get createdAtHash (): IU8a | undefined {
return warnGet(this, 'createdAtHash');
}
public get chainDecimals (): number[] {
if (this.#chainProperties?.tokenDecimals.isSome) {
const allDecimals = this.#chainProperties.tokenDecimals.unwrap();