Update latest extrinsic version (#1511)

* Update latest extrinsic version

* Don't export const with types
This commit is contained in:
Jaco Greeff
2019-10-25 08:51:03 +02:00
committed by GitHub
parent 44d0ced5af
commit 0b71291cf1
5 changed files with 15 additions and 15 deletions
@@ -18,16 +18,16 @@ import { ExtrinsicValueV4 } from './v4/Extrinsic';
import ExtrinsicEra from './ExtrinsicEra';
import { BIT_SIGNED, BIT_UNSIGNED, DEFAULT_VERSION, UNMASK_VERSION } from './constants';
// We use this type internally to cast the raw value since ExtrinsicUnknown does not actually properly
// implement an Extrinsic - by design, it just throws on construction, allowing for overrides
type ExtrinsicVx = ExtrinsicV1 | ExtrinsicV2 | ExtrinsicV3 | ExtrinsicV4;
type ExtrinsicValue = ExtrinsicValueV1 | ExtrinsicValueV2 | ExtrinsicValueV3 | ExtrinsicValueV4;
interface CreateOptions {
version?: number;
}
// NOTE The following 2 types, as well as the VERSION structure and the latest export
// is to be changed with the addition of a new extrinsic version
type ExtrinsicVx = ExtrinsicV1 | ExtrinsicV2 | ExtrinsicV3 | ExtrinsicV4;
type ExtrinsicValue = ExtrinsicValueV1 | ExtrinsicValueV2 | ExtrinsicValueV3 | ExtrinsicValueV4;
const VERSIONS: InterfaceTypes[] = [
'ExtrinsicUnknown', // v0 is unknown
'ExtrinsicV1',
@@ -36,6 +36,8 @@ const VERSIONS: InterfaceTypes[] = [
'ExtrinsicV4'
];
export { TRANSACTION_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
/**
* @name Extrinsic
* @description
@@ -61,8 +63,8 @@ export default class Extrinsic extends Base<ExtrinsicVx | ExtrinsicUnknown> impl
const isSigned = (version & BIT_SIGNED) === BIT_SIGNED;
const type = VERSIONS[version & UNMASK_VERSION] || VERSIONS[0];
// we cast here since the VERSION definition is incredibly broad - we don't have a slice for
// "only add extrinsic types", and more string definitions become unwieldy
// we cast here since the VERSION definition is incredibly broad - we don't have a
// slice for "only add extrinsic types", and more string definitions become unwieldy
return createType(type, value, { isSigned, version }) as ExtrinsicVx;
}
@@ -8,8 +8,6 @@ export const BIT_UNSIGNED = 0;
export const EMPTY_U8A = new Uint8Array();
export const LATEST_VERSION = 3;
// TODO We really want to swap this to V3, however all the test data is setup
// for V1, so this will take some time to convert... "some" time :)
export const DEFAULT_VERSION = 1;
@@ -12,7 +12,7 @@ import { createType, ClassOf } from '../../../codec/create';
import Struct from '../../../codec/Struct';
import ExtrinsicSignatureV4 from './ExtrinsicSignature';
const TRANSACTION_VERSION = 4;
export const TRANSACTION_VERSION = 4;
export interface ExtrinsicValueV4 {
method?: Call;