Skip to content

Commit

Permalink
Use constant for latest extrinsic version (#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr authored Aug 16, 2022
1 parent 69c1295 commit 26e550f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/base/Decorate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray
import { getAvailableDerives } from '@polkadot/api-derive';
import { memo, RpcCore } from '@polkadot/rpc-core';
import { WsProvider } from '@polkadot/rpc-provider';
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry } from '@polkadot/types';
import { expandMetadata, GenericExtrinsic, Metadata, typeDefinitions, TypeRegistry } from '@polkadot/types';
import { getSpecRuntime } from '@polkadot/types-known';
import { arrayChunk, arrayFlatten, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, stringUpperFirst, u8aConcatStrict, u8aToHex } from '@polkadot/util';
import { blake2AsHex } from '@polkadot/util-crypto';
Expand Down Expand Up @@ -84,7 +84,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {

protected _extrinsics?: SubmittableExtrinsics<ApiType>;

protected _extrinsicType = 4; // latest extrinsic version
protected _extrinsicType = GenericExtrinsic.LATEST_EXTRINSIC_VERSION;

protected _genesisHash?: Hash;

Expand Down
5 changes: 4 additions & 1 deletion packages/types/src/extrinsic/Extrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { ExtrinsicValueV4 } from './v4/Extrinsic';
import { AbstractBase } from '@polkadot/types-codec';
import { compactAddLength, compactFromU8a, compactToU8a, isHex, isU8a, objectProperty, objectSpread, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';

import { EXTRINSIC_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
import { BIT_SIGNED, BIT_UNSIGNED, DEFAULT_VERSION, UNMASK_VERSION } from './constants';

interface CreateOptions {
Expand All @@ -33,7 +34,7 @@ const VERSIONS = [
'ExtrinsicV4'
];

export { EXTRINSIC_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
export { LATEST_EXTRINSIC_VERSION };

/** @internal */
function newFromValue (registry: Registry, value: any, version: number): ExtrinsicVx | ExtrinsicUnknown {
Expand Down Expand Up @@ -235,6 +236,8 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBase<A> implements IExtrinsic<A> {
#hashCache?: CodecHash;

static LATEST_EXTRINSIC_VERSION = LATEST_EXTRINSIC_VERSION;

constructor (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, { version }: CreateOptions = {}) {
super(registry, decodeExtrinsic(registry, value, version));
}
Expand Down

0 comments on commit 26e550f

Please sign in to comment.