Revert all recent $ renames (#5429)
* Revert "[CI Skip] bump/beta 9.11.4-6-x" This reverts commit7ee4f7aaf8. * Revert "Rename Code .registry to .$registry (#5428)" This reverts commitdd6826fadd. * Revert "[CI Skip] bump/beta 9.11.4-5-x" This reverts commitabc68bf2e2. * Revert "Convert encodedLength to $encodedLength (#5426)" This reverts commitccab89304b. * Revert "[CI Skip] bump/beta 9.11.4-4-x" This reverts commit044465eee4. * Revert "Rename inspect() to inspectU8a() (#5425)" This reverts commit42af205546. * Revert "[CI Skip] bump/beta 9.11.4-3-x" This reverts commit545ad50097. * Revert "Move .isEmpty to $isEmpty (#5424)" This reverts commit6f19084a4d. * Revert "[CI Skip] bump/beta 9.11.4-2-x" This reverts commit4688291ecf. * Revert "Warn on deprecated getter usage (#5423)" This reverts commitda1cf9d64e. * Revert "[CI Skip] bump/beta 9.11.4-1-x" This reverts commit96a3ef51f0. * Revert "Revert "[CI Skip] bump/beta 9.11.4-1-x"" This reverts commit 2eca0730a630d587878f12c141e21ea631dcdd19. * Revert "Revert "[CI Skip] bump/beta 9.11.4-2-x"" This reverts commit 66284b40692071aa03a1064997c9402fc0b0987c. * Revert "Revert "[CI Skip] bump/beta 9.11.4-3-x"" This reverts commit 9b820eaefccdb7b51d893000e5480d11e5195e22. * Revert "Revert "[CI Skip] bump/beta 9.11.4-4-x"" This reverts commit cb5149adf98a5eefd8da61b8793707f85deb7c09. * Revert "Revert "[CI Skip] bump/beta 9.11.4-5-x"" This reverts commit 489a64439860fefba163695ec36b319dcb1eeddc. * Revert "Revert "[CI Skip] bump/beta 9.11.4-6-x"" This reverts commit 34a0fd4e2784a1b40ea8e06534d1f39328250e7a. * Adjust linebreaks * Adjust isStorageFallback naming * Fix build
This commit is contained in:
@@ -98,4 +98,4 @@ const tt9 = registry.createType('(u32, (u32, u64), Vec<u8>, Vec<(u32, u64)>, [u8
|
||||
// tuple with nested fixed
|
||||
const tta = registry.createType('([u8;32], [u16;5])');
|
||||
|
||||
assert(tt1[2].bitLength() && tt2.bitLength() && tt4[3].bitLength() && tt5.$isEmpty && tt6[1].toHuman() && tt7.toHuman() && tt8.toHuman() && tt9.toHuman() && tta[1][1].bitLength(), 'All ok');
|
||||
assert(tt1[2].bitLength() && tt2.bitLength() && tt4[3].bitLength() && tt5.isEmpty && tt6[1].toHuman() && tt7.toHuman() && tt8.toHuman() && tt9.toHuman() && tta[1][1].bitLength(), 'All ok');
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('createType', (): void => {
|
||||
|
||||
expect(f64.toRawType()).toEqual('Fixed64');
|
||||
expect(f64.bitLength()).toEqual(64);
|
||||
expect(f64.$isUnsigned).toBe(false);
|
||||
expect(f64.isUnsigned).toBe(false);
|
||||
expect(f64 instanceof Int).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -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, warnGet } from '@polkadot/types-codec';
|
||||
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 { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
@@ -186,7 +186,7 @@ export class TypeRegistry implements Registry {
|
||||
readonly #metadataEvents: Record<string, Record<string, CodecClass<GenericEventData>>> = {};
|
||||
readonly #moduleMap: Record<string, string[]> = {};
|
||||
|
||||
public $createdAtHash?: Hash;
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
constructor (createdAtHash?: Hash | Uint8Array | string) {
|
||||
this.#knownDefaults = objectSpread({ Json, Metadata, PortableRegistry, Raw }, baseTypes);
|
||||
@@ -199,15 +199,10 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
|
||||
if (createdAtHash) {
|
||||
this.$createdAtHash = this.createType('BlockHash', createdAtHash);
|
||||
this.createdAtHash = this.createType('BlockHash', createdAtHash);
|
||||
}
|
||||
}
|
||||
|
||||
/** @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();
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('EthereumAccountId', (): void => {
|
||||
});
|
||||
|
||||
it('is empty by default', (): void => {
|
||||
expect(id.$isEmpty).toBe(true);
|
||||
expect(id.isEmpty).toBe(true);
|
||||
});
|
||||
|
||||
it('equals the empty address', (): void => {
|
||||
@@ -77,7 +77,7 @@ describe('EthereumAccountId', (): void => {
|
||||
]));
|
||||
|
||||
it('decodes to a non-empty value', (): void => {
|
||||
expect(registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887').$isEmpty).toBe(false);
|
||||
expect(registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887').isEmpty).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ export class GenericEthereumLookupSource extends AbstractBase<GenericEthereumAcc
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
const rawLength = this._rawLength;
|
||||
|
||||
return rawLength + (
|
||||
@@ -86,7 +86,7 @@ export class GenericEthereumLookupSource extends AbstractBase<GenericEthereumAcc
|
||||
protected get _rawLength (): number {
|
||||
return this.inner instanceof GenericAccountIndex
|
||||
? GenericAccountIndex.calcLength(this.inner)
|
||||
: this.inner.$encodedLength;
|
||||
: this.inner.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,7 +131,7 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
@@ -266,13 +266,13 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspectU8a (): Inspect {
|
||||
override inspect (): Inspect {
|
||||
const encoded = u8aConcat(...this.toU8aInner());
|
||||
|
||||
return {
|
||||
inner: this.isSigned
|
||||
? this.inner.inspectU8a().inner
|
||||
: this.inner.method.inspectU8a().inner,
|
||||
? this.inner.inspect().inner
|
||||
: this.inner.method.inspect().inner,
|
||||
outer: [compactToU8a(encoded.length), new Uint8Array([this.version])]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class MortalEra extends Tuple {
|
||||
/**
|
||||
* @description Encoded length for mortals occupy 2 bytes, different from the actual Tuple since it is encoded. This is a shortcut fro `toU8a().length`
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -247,10 +247,10 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra {
|
||||
/**
|
||||
* @description Override the encoded length method
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.isImmortalEra
|
||||
? this.asImmortalEra.$encodedLength
|
||||
: this.asMortalEra.$encodedLength;
|
||||
? this.asImmortalEra.encodedLength
|
||||
: this.asMortalEra.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('ExtrinsicPayload', (): void => {
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 4 });
|
||||
const b = new ExtrinsicPayload(registry, a.toU8a(), { version: 4 });
|
||||
|
||||
expect(a.inspectU8a()).toEqual(b.inspectU8a());
|
||||
expect(a.inspect()).toEqual(b.inspect());
|
||||
expect(a.toJSON()).toEqual(b.toJSON());
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('ExtrinsicPayload', (): void => {
|
||||
const a = new ExtrinsicPayload(registry, TEST, { version: 4 });
|
||||
const b = new ExtrinsicPayload(registry, a.toHex(), { version: 4 });
|
||||
|
||||
expect(a.inspectU8a()).toEqual(b.inspectU8a());
|
||||
expect(a.inspect()).toEqual(b.inspect());
|
||||
expect(a.toJSON()).toEqual(b.toJSON());
|
||||
});
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get genesisHash (): BlockHash {
|
||||
// NOTE only v3+
|
||||
return this.inner.genesisHash || this.$registry.createTypeUnsafe('Hash', []);
|
||||
return this.inner.genesisHash || this.registry.createTypeUnsafe('Hash', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get specVersion (): INumber {
|
||||
// NOTE only v3+
|
||||
return this.inner.specVersion || this.$registry.createTypeUnsafe('u32', []);
|
||||
return this.inner.specVersion || this.registry.createTypeUnsafe('u32', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get tip (): ICompact<INumber> {
|
||||
// NOTE from v2+
|
||||
return this.inner.tip || this.$registry.createTypeUnsafe('Compact<Balance>', []);
|
||||
return this.inner.tip || this.registry.createTypeUnsafe('Compact<Balance>', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
*/
|
||||
public get transactionVersion (): INumber {
|
||||
// NOTE only v4+
|
||||
return this.inner.transactionVersion || this.$registry.createTypeUnsafe('u32', []);
|
||||
return this.inner.transactionVersion || this.registry.createTypeUnsafe('u32', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,7 +150,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
|
||||
public toRaw (): SignerPayloadRaw {
|
||||
const payload = this.toPayload();
|
||||
const data = u8aToHex(
|
||||
this.$registry
|
||||
this.registry
|
||||
.createTypeUnsafe('ExtrinsicPayload', [payload, { version: payload.version }])
|
||||
// NOTE Explicitly pass the bare flag so the method is encoded un-prefixed (non-decodable, for signing only)
|
||||
.toU8a({ method: true })
|
||||
|
||||
@@ -40,7 +40,7 @@ export class GenericExtrinsicV4 extends Struct implements IExtrinsicImpl {
|
||||
} else if (isU8a(value)) {
|
||||
// here we decode manually since we need to pull through the version information
|
||||
const signature = registry.createTypeUnsafe<ExtrinsicSignatureV4>('ExtrinsicSignatureV4', [value, { isSigned }]);
|
||||
const method = registry.createTypeUnsafe<Call>('Call', [value.subarray(signature.$encodedLength)]);
|
||||
const method = registry.createTypeUnsafe<Call>('Call', [value.subarray(signature.encodedLength)]);
|
||||
|
||||
return {
|
||||
method,
|
||||
@@ -54,7 +54,7 @@ export class GenericExtrinsicV4 extends Struct implements IExtrinsicImpl {
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('ExtrinsicPayload', (): void => {
|
||||
it('has a sane inspect', (): void => {
|
||||
// we don't expect this to fail, however it is actually a good
|
||||
// reference for the ordering in base Substrate
|
||||
expect(new ExtrinsicPayload(registry, { method: tx.timestamp.set(0).toHex() } as never).inspectU8a()).toEqual({
|
||||
expect(new ExtrinsicPayload(registry, { method: tx.timestamp.set(0).toHex() } as never).inspect()).toEqual({
|
||||
inner: [
|
||||
{ name: 'method', outer: [new Uint8Array([3, 0, 0])] },
|
||||
{ name: 'era', outer: [new Uint8Array([0]), new Uint8Array([0])] },
|
||||
|
||||
@@ -40,8 +40,8 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
public override inspectU8a (): Inspect {
|
||||
return super.inspectU8a({ method: true });
|
||||
public override inspect (): Inspect {
|
||||
return super.inspect({ method: true });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,6 +116,6 @@ export class GenericExtrinsicPayloadV4 extends Struct {
|
||||
// means that the data-as-signed is un-decodable, but is also doesn't need
|
||||
// the extra information, only the pure data (and is not decoded) ...
|
||||
// The same applies to V1..V3, if we have a V5, carry this comment
|
||||
return sign(this.$registry, signerPair, this.toU8a({ method: true }), this.#signOptions);
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }), this.#signOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.isSigned
|
||||
? super.$encodedLength
|
||||
? super.encodedLength
|
||||
: 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
* @description `true` if the signature is valid
|
||||
*/
|
||||
public get isSigned (): boolean {
|
||||
return !this.signature.$isEmpty;
|
||||
return !this.signature.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,9 +141,9 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | HexString, payload: ExtrinsicPayloadValue | Uint8Array | HexString): IExtrinsicSignature {
|
||||
return this._injectSignature(
|
||||
toAddress(this.$registry, signer),
|
||||
this.$registry.createTypeUnsafe('ExtrinsicSignature', [signature]),
|
||||
new GenericExtrinsicPayloadV4(this.$registry, payload)
|
||||
toAddress(this.registry, signer),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [signature]),
|
||||
new GenericExtrinsicPayloadV4(this.registry, payload)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
public createPayload (method: Call, options: SignatureOptions): GenericExtrinsicPayloadV4 {
|
||||
const { era, runtimeVersion: { specVersion, transactionVersion } } = options;
|
||||
|
||||
return new GenericExtrinsicPayloadV4(this.$registry, objectSpread<ExtrinsicPayloadValue>({}, options, {
|
||||
return new GenericExtrinsicPayloadV4(this.registry, objectSpread<ExtrinsicPayloadValue>({}, options, {
|
||||
era: era || IMMORTAL_ERA,
|
||||
method: method.toHex(),
|
||||
specVersion,
|
||||
@@ -172,8 +172,8 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
const payload = this.createPayload(method, options);
|
||||
|
||||
return this._injectSignature(
|
||||
toAddress(this.$registry, account.addressRaw),
|
||||
this.$registry.createTypeUnsafe('ExtrinsicSignature', [payload.sign(account)]),
|
||||
toAddress(this.registry, account.addressRaw),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [payload.sign(account)]),
|
||||
payload
|
||||
);
|
||||
}
|
||||
@@ -189,8 +189,8 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
const payload = this.createPayload(method, options);
|
||||
|
||||
return this._injectSignature(
|
||||
toAddress(this.$registry, address),
|
||||
this.$registry.createTypeUnsafe('ExtrinsicSignature', [FAKE_SIGNATURE]),
|
||||
toAddress(this.registry, address),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [FAKE_SIGNATURE]),
|
||||
payload
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('AccountId', (): void => {
|
||||
});
|
||||
|
||||
it('is empty by default', (): void => {
|
||||
expect(id.$isEmpty).toBe(true);
|
||||
expect(id.isEmpty).toBe(true);
|
||||
});
|
||||
|
||||
it('equals the empty address', (): void => {
|
||||
@@ -125,7 +125,7 @@ describe('AccountId', (): void => {
|
||||
expect(
|
||||
registry
|
||||
.createType('AccountId', 'FVU8T5yaAssHAUwo3PnKso7fqNthEqJZGCZgJZSR9cKjWAf')
|
||||
.$isEmpty
|
||||
.isEmpty
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class BaseAccountId extends U8aFixed {
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public override toString (): string {
|
||||
return encodeAddress(this, this.$registry.chainSS58);
|
||||
return encodeAddress(this, this.registry.chainSS58);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ export class GenericAccountIndex extends u32 {
|
||||
}
|
||||
|
||||
// convert and compare
|
||||
return super.eq(this.$registry.createTypeUnsafe('AccountIndex', [other]));
|
||||
return super.eq(this.registry.createTypeUnsafe('AccountIndex', [other]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ export class GenericAccountIndex extends u32 {
|
||||
public override toString (): string {
|
||||
const length = GenericAccountIndex.calcLength(this);
|
||||
|
||||
return encodeAddress(this.toU8a().subarray(0, length), this.$registry.chainSS58);
|
||||
return encodeAddress(this.toU8a().subarray(0, length), this.registry.chainSS58);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ export class GenericBlock extends Struct {
|
||||
* @description Encodes a content [[Hash]] for the block
|
||||
*/
|
||||
public get contentHash (): IU8a {
|
||||
return this.$registry.hash(this.toU8a());
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,7 +158,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
|
||||
* @description The argument definitions
|
||||
*/
|
||||
public get argsDef (): ArgsDef {
|
||||
return getArgsDef(this.$registry, this.meta);
|
||||
return getArgsDef(this.registry, this.meta);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,14 +193,14 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
|
||||
* @description Returns the name of the method
|
||||
*/
|
||||
public get method (): string {
|
||||
return this.$registry.findMetaCall(this.callIndex).method;
|
||||
return this.registry.findMetaCall(this.callIndex).method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the module containing the method
|
||||
*/
|
||||
public get section (): string {
|
||||
return this.$registry.findMetaCall(this.callIndex).section;
|
||||
return this.registry.findMetaCall(this.callIndex).section;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
|
||||
let call: CallFunction | undefined;
|
||||
|
||||
try {
|
||||
call = this.$registry.findMetaCall(this.callIndex);
|
||||
call = this.registry.findMetaCall(this.callIndex);
|
||||
} catch (error) {
|
||||
// swallow
|
||||
}
|
||||
|
||||
@@ -83,15 +83,15 @@ export class GenericConsensusEngineId extends U8aFixed {
|
||||
public extractAuthor (bytes: Bytes, sessionValidators: AccountId[]): AccountId | undefined {
|
||||
if (sessionValidators?.length) {
|
||||
if (this.isAura) {
|
||||
return getAuraAuthor(this.$registry, bytes, sessionValidators);
|
||||
return getAuraAuthor(this.registry, bytes, sessionValidators);
|
||||
} else if (this.isBabe) {
|
||||
return getBabeAuthor(this.$registry, bytes, sessionValidators);
|
||||
return getBabeAuthor(this.registry, bytes, sessionValidators);
|
||||
}
|
||||
}
|
||||
|
||||
// For pow & Moonbeam, the bytes are the actual author
|
||||
if (this.isPow || bytes.length === 20) {
|
||||
return getBytesAsAuthor(this.$registry, bytes);
|
||||
return getBytesAsAuthor(this.registry, bytes);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@@ -70,7 +70,7 @@ export class GenericLookupSource extends AbstractBase<GenericAccountId | Generic
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
const rawLength = this._rawLength;
|
||||
|
||||
return rawLength + (
|
||||
@@ -87,13 +87,13 @@ export class GenericLookupSource extends AbstractBase<GenericAccountId | Generic
|
||||
protected get _rawLength (): number {
|
||||
return this.inner instanceof GenericAccountIndex
|
||||
? GenericAccountIndex.calcLength(this.inner)
|
||||
: this.inner.$encodedLength;
|
||||
: this.inner.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspectU8a (): Inspect {
|
||||
override inspect (): Inspect {
|
||||
const value = this.inner.toU8a().subarray(0, this._rawLength);
|
||||
|
||||
return {
|
||||
|
||||
@@ -55,8 +55,8 @@ export class GenericMultiAddress extends Enum {
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspectU8a (): Inspect {
|
||||
const { inner, outer = [] } = this.inner.inspectU8a();
|
||||
override inspect (): Inspect {
|
||||
const { inner, outer = [] } = this.inner.inspect();
|
||||
|
||||
return {
|
||||
inner,
|
||||
|
||||
@@ -80,7 +80,7 @@ export class GenericVote extends U8aFixed {
|
||||
super(registry, decoded, 8);
|
||||
|
||||
this.#aye = (decoded[0] & AYE_BITS) === AYE_BITS;
|
||||
this.#conviction = this.$registry.createTypeUnsafe('Conviction', [decoded[0] & CON_MASK]);
|
||||
this.#conviction = this.registry.createTypeUnsafe('Conviction', [decoded[0] & CON_MASK]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('IdentityFields', (): void => {
|
||||
|
||||
it('has a custom u64 (64-bit) encodedLength', (): void => {
|
||||
expect(
|
||||
registry.createType('IdentityFields').$encodedLength
|
||||
registry.createType('IdentityFields').encodedLength
|
||||
).toEqual(8);
|
||||
});
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export class MagicNumber extends U32 {
|
||||
constructor (registry: Registry, value?: AnyNumber) {
|
||||
super(registry, value);
|
||||
|
||||
if (!this.$isEmpty && !this.eq(MAGIC_NUMBER)) {
|
||||
if (!this.isEmpty && !this.eq(MAGIC_NUMBER)) {
|
||||
throw new Error(`MagicNumber mismatch: expected ${registry.createTypeUnsafe('u32', [MAGIC_NUMBER]).toHex()}, found ${this.toHex()}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
if (!this.#converted.has(version)) {
|
||||
this.#converted.set(version, fromPrev(this.$registry, this[asPrev] as F, this.version));
|
||||
this.#converted.set(version, fromPrev(this.registry, this[asPrev] as F, this.version));
|
||||
}
|
||||
|
||||
return this.#converted.get(version) as T;
|
||||
@@ -82,9 +82,9 @@ export class MetadataVersioned extends Struct {
|
||||
* @description Returns the wrapped metadata as a limited calls-only (latest) version
|
||||
*/
|
||||
public get asCallsOnly (): MetadataVersioned {
|
||||
return new MetadataVersioned(this.$registry, {
|
||||
return new MetadataVersioned(this.registry, {
|
||||
magicNumber: this.magicNumber,
|
||||
metadata: this.$registry.createTypeUnsafe('MetadataAll', [toCallsOnly(this.$registry, this.asLatest), LATEST_VERSION])
|
||||
metadata: this.registry.createTypeUnsafe('MetadataAll', [toCallsOnly(this.registry, this.asLatest), LATEST_VERSION])
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
public getUniqTypes (throwError: boolean): string[] {
|
||||
return getUniqTypes(this.$registry, this.asLatest, throwError);
|
||||
return getUniqTypes(this.registry, this.asLatest, throwError);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -388,7 +388,7 @@ function removeDupeNames (lookup: PortableRegistry, portable: PortableType[], na
|
||||
/** @internal */
|
||||
function registerTypes (lookup: PortableRegistry, lookups: Record<string, string>, names: Record<number, string>, params: Record<string, SiTypeParameter[]>): void {
|
||||
// Register the types we extracted
|
||||
lookup.$registry.register(lookups);
|
||||
lookup.registry.register(lookups);
|
||||
|
||||
// Try and extract the AccountId/Address/Signature type from UncheckedExtrinsic
|
||||
if (params.SpRuntimeUncheckedExtrinsic) {
|
||||
@@ -408,7 +408,7 @@ function registerTypes (lookup: PortableRegistry, lookups: Record<string, string
|
||||
nsAccountId = lookup.getSiType(idParam.type.unwrap()).path.join('::');
|
||||
}
|
||||
|
||||
lookup.$registry.register({
|
||||
lookup.registry.register({
|
||||
AccountId: ['sp_core::crypto::AccountId32'].includes(nsAccountId)
|
||||
? 'AccountId32'
|
||||
: ['account::AccountId20', 'primitive_types::H160'].includes(nsAccountId)
|
||||
@@ -435,7 +435,7 @@ function registerTypes (lookup: PortableRegistry, lookups: Record<string, string
|
||||
|
||||
const weightDef = lookup.getTypeDef(`Lookup${weight[0]}`);
|
||||
|
||||
lookup.$registry.register({
|
||||
lookup.registry.register({
|
||||
Weight: Array.isArray(weightDef.sub) && weightDef.sub.length !== 1
|
||||
// we have a complex structure
|
||||
? 'SpWeightsWeightV2Weight'
|
||||
@@ -501,7 +501,7 @@ function extractTypeInfo (lookup: PortableRegistry, portable: PortableType[]): T
|
||||
const { lookupIndex, name, params: p } = dedup[i];
|
||||
|
||||
names[lookupIndex] = name;
|
||||
lookups[name] = lookup.$registry.createLookupType(lookupIndex);
|
||||
lookups[name] = lookup.registry.createLookupType(lookupIndex);
|
||||
params[name] = p;
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
info: TypeDefInfo.DoNotConstruct,
|
||||
lookupIndex,
|
||||
lookupName,
|
||||
type: this.$registry.createLookupType(lookupIndex)
|
||||
type: this.registry.createLookupType(lookupIndex)
|
||||
};
|
||||
|
||||
// Set named items since we will get into circular lookups along the way
|
||||
@@ -645,14 +645,14 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
info: TypeDefInfo.Si,
|
||||
lookupIndex,
|
||||
lookupName: this.#names[lookupIndex],
|
||||
type: this.$registry.createLookupType(lookupId)
|
||||
type: this.registry.createLookupType(lookupId)
|
||||
}
|
||||
: typeDef;
|
||||
}
|
||||
|
||||
#getLookupId (lookupId: SiLookupTypeId | string | number): number {
|
||||
if (isString(lookupId)) {
|
||||
if (!this.$registry.isLookupType(lookupId)) {
|
||||
if (!this.registry.isLookupType(lookupId)) {
|
||||
throw new Error(`PortableRegistry: Expected a lookup string type, found ${lookupId}`);
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error('Only support for [Type; <length>], where length <= 2048');
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
length,
|
||||
sub: this.#createSiDef(type)
|
||||
@@ -735,7 +735,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
}
|
||||
|
||||
#extractCompact (_: number, { type }: SiTypeDefCompact): TypeDef {
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Compact,
|
||||
sub: this.#createSiDef(type)
|
||||
});
|
||||
@@ -751,7 +751,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error(`BTreeMap requires 2 parameters, found ${params.length}`);
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.BTreeMap,
|
||||
sub: params.map(({ type }) => this.#createSiDef(type.unwrap()))
|
||||
});
|
||||
@@ -760,7 +760,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error(`BTreeSet requires 1 parameter, found ${params.length}`);
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.BTreeSet,
|
||||
sub: this.#createSiDef(params[0].type.unwrap())
|
||||
});
|
||||
@@ -769,7 +769,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error(`Range requires 1 parameter, found ${params.length}`);
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: pathFirst === 'Range'
|
||||
? TypeDefInfo.Range
|
||||
: TypeDefInfo.RangeInclusive,
|
||||
@@ -781,7 +781,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error(`WrapperOpaque requires 1 parameter, found ${params.length}`);
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: pathLast === 'WrapperKeepOpaque'
|
||||
? TypeDefInfo.WrapperKeepOpaque
|
||||
: TypeDefInfo.WrapperOpaque,
|
||||
@@ -801,9 +801,9 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error('Set handling expects param/field as single entries');
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Set,
|
||||
length: this.$registry.createTypeUnsafe<u32>(this.$registry.createLookupType(fields[0].type), []).bitLength(),
|
||||
length: this.registry.createTypeUnsafe<u32>(this.registry.createLookupType(fields[0].type), []).bitLength(),
|
||||
sub: this.getSiType(params[0].type.unwrap()).def.asVariant.variants.map(({ index, name }): TypeDef => ({
|
||||
// This will be an issue > 2^53 - 1 ... don't have those (yet)
|
||||
index: index.toNumber(),
|
||||
@@ -855,7 +855,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
|
||||
const [sub, alias] = this.#extractFieldsAlias(fields);
|
||||
|
||||
return withTypeString(this.$registry, objectSpread(
|
||||
return withTypeString(this.registry, objectSpread(
|
||||
{
|
||||
info: isTuple // Tuple check first
|
||||
? TypeDefInfo.Tuple
|
||||
@@ -940,7 +940,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
};
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Vec,
|
||||
lookupIndex,
|
||||
lookupName: this.#names[lookupIndex],
|
||||
@@ -960,7 +960,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
|
||||
const sub = ids.map((t) => this.#createSiDef(t));
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Tuple,
|
||||
lookupIndex,
|
||||
lookupName: this.#names[lookupIndex],
|
||||
@@ -979,13 +979,13 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
|
||||
// NOTE This is opt-in (unhandled), not by default
|
||||
// if (sub.type === 'bool') {
|
||||
// return withTypeString(this.$registry, {
|
||||
// return withTypeString(this.registry, {
|
||||
// info: TypeDefInfo.Plain,
|
||||
// type: 'OptionBool'
|
||||
// });
|
||||
// }
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Option,
|
||||
sub: this.#createSiDef(params[0].type.unwrap())
|
||||
});
|
||||
@@ -994,7 +994,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
throw new Error(`Result requires 2 parameters, found ${params.length}`);
|
||||
}
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: params.map(({ type }, index) =>
|
||||
objectSpread({
|
||||
@@ -1043,7 +1043,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
);
|
||||
});
|
||||
|
||||
return withTypeString(this.$registry, {
|
||||
return withTypeString(this.registry, {
|
||||
info: TypeDefInfo.Enum,
|
||||
lookupIndex,
|
||||
lookupName: this.#names[lookupIndex],
|
||||
|
||||
@@ -17,7 +17,7 @@ export function decorateConstants (registry: Registry, { pallets }: MetadataLate
|
||||
for (let i = 0; i < pallets.length; i++) {
|
||||
const { constants, name } = pallets[i];
|
||||
|
||||
if (!constants.$isEmpty) {
|
||||
if (!constants.isEmpty) {
|
||||
lazyMethod(result, stringCamelCase(name), () =>
|
||||
lazyMethods(
|
||||
{},
|
||||
|
||||
@@ -108,7 +108,7 @@ export class Data extends Enum {
|
||||
/**
|
||||
* @description The encoded length
|
||||
*/
|
||||
public override get $encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ function decodeHashers <A extends AnyTuple> (registry: Registry, value: Uint8Arr
|
||||
? registry.createTypeUnsafe(getSiName(registry.lookup, type), [value.subarray(offset + hashLen)])
|
||||
: registry.createTypeUnsafe('Raw', [value.subarray(offset, offset + hashLen)]);
|
||||
|
||||
offset += hashLen + (canDecode ? decoded.$encodedLength : 0);
|
||||
offset += hashLen + (canDecode ? decoded.encodedLength : 0);
|
||||
result[i] = decoded;
|
||||
}
|
||||
|
||||
@@ -236,11 +236,11 @@ export class StorageKey<A extends AnyTuple = AnyTuple> extends Bytes implements
|
||||
this.#section = section || this.#section;
|
||||
|
||||
if (meta) {
|
||||
this.#outputType = unwrapStorageType(this.$registry, meta.type);
|
||||
this.#outputType = unwrapStorageType(this.registry, meta.type);
|
||||
}
|
||||
|
||||
try {
|
||||
this.#args = decodeArgsFromMeta(this.$registry, this.toU8a(true), meta);
|
||||
this.#args = decodeArgsFromMeta(this.registry, this.toU8a(true), meta);
|
||||
} catch (error) {
|
||||
// ignore...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user