diff --git a/packages/types/src/codec/create/registry.ts b/packages/types/src/codec/create/registry.ts index 793cdedf41..e5d4dc1fbc 100644 --- a/packages/types/src/codec/create/registry.ts +++ b/packages/types/src/codec/create/registry.ts @@ -10,7 +10,7 @@ import { assert, isFunction, isString, isUndefined, stringCamelCase, u8aToHex } import Raw from '../Raw'; import { EventData } from '../../primitive/Generic/Event'; -import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '../../primitive/Extrinsic/SignedExtensions'; +import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '../../primitive/Extrinsic/signedExtensions'; import { createClass } from './createClass'; import { getTypeClass } from './getTypeClass'; import { getTypeDef } from './getTypeDef'; diff --git a/packages/types/src/primitive/Extrinsic/SignedExtensions.ts b/packages/types/src/primitive/Extrinsic/signedExtensions/index.ts similarity index 61% rename from packages/types/src/primitive/Extrinsic/SignedExtensions.ts rename to packages/types/src/primitive/Extrinsic/signedExtensions/index.ts index 836ef756f4..6ad6b76dba 100644 --- a/packages/types/src/primitive/Extrinsic/SignedExtensions.ts +++ b/packages/types/src/primitive/Extrinsic/signedExtensions/index.ts @@ -2,62 +2,21 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { InterfaceTypes } from '../../types'; +import { ExtDef, ExtInfo, ExtTypes } from './types'; -type ExtTypes = Record; -type ExtInfo = { - extra: ExtTypes; - types: ExtTypes; -} +import polkadotExtensions from './polkadot'; +import substrateExtensions from './substrate'; // A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions, // we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded // into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are // deemded fixed and non-changeable) -const allExtensions: Record = { - ChargeTransactionPayment: { - extra: {}, - types: { - tip: 'Compact' - } - }, - CheckBlockGasLimit: { - extra: {}, - types: {} - }, - CheckEra: { - extra: { - blockHash: 'Hash' - }, - types: { - era: 'ExtrinsicEra' - } - }, - CheckGenesis: { - extra: { - genesisHash: 'Hash' - }, - types: {} - }, - CheckNonce: { - extra: {}, - types: { - nonce: 'Compact' - } - }, - CheckVersion: { - extra: { - specVersion: 'u32' - }, - types: {} - }, - CheckWeight: { - extra: {}, - types: {} - } +const allExtensions: ExtDef = { + ...substrateExtensions, + ...polkadotExtensions }; -// the v4 signed extensions (the order is important here) +// the v4 signed extensions (the order is important here, as applied by default) const defaultExtensions: Array = [ 'CheckVersion', 'CheckGenesis', diff --git a/packages/types/src/primitive/Extrinsic/signedExtensions/polkadot.ts b/packages/types/src/primitive/Extrinsic/signedExtensions/polkadot.ts new file mode 100644 index 0000000000..6e8b64f61e --- /dev/null +++ b/packages/types/src/primitive/Extrinsic/signedExtensions/polkadot.ts @@ -0,0 +1,16 @@ +// Copyright 2017-2020 @polkadot/types authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { ExtDef } from './types'; + +export default { + RestrictFunctionality: { + extra: {}, + types: {} + }, + LimitParathreadCommits: { + extra: {}, + types: {} + } +} as ExtDef; diff --git a/packages/types/src/primitive/Extrinsic/signedExtensions/substrate.ts b/packages/types/src/primitive/Extrinsic/signedExtensions/substrate.ts new file mode 100644 index 0000000000..78dd430b33 --- /dev/null +++ b/packages/types/src/primitive/Extrinsic/signedExtensions/substrate.ts @@ -0,0 +1,48 @@ +// Copyright 2017-2020 @polkadot/types authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { ExtDef } from './types'; + +export default { + ChargeTransactionPayment: { + extra: {}, + types: { + tip: 'Compact' + } + }, + CheckBlockGasLimit: { + extra: {}, + types: {} + }, + CheckEra: { + extra: { + blockHash: 'Hash' + }, + types: { + era: 'ExtrinsicEra' + } + }, + CheckGenesis: { + extra: { + genesisHash: 'Hash' + }, + types: {} + }, + CheckNonce: { + extra: {}, + types: { + nonce: 'Compact' + } + }, + CheckVersion: { + extra: { + specVersion: 'u32' + }, + types: {} + }, + CheckWeight: { + extra: {}, + types: {} + } +} as ExtDef; diff --git a/packages/types/src/primitive/Extrinsic/signedExtensions/types.ts b/packages/types/src/primitive/Extrinsic/signedExtensions/types.ts new file mode 100644 index 0000000000..960f425602 --- /dev/null +++ b/packages/types/src/primitive/Extrinsic/signedExtensions/types.ts @@ -0,0 +1,14 @@ +// Copyright 2017-2020 @polkadot/types authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { InterfaceTypes } from '../../../types'; + +export type ExtTypes = Record; + +export type ExtInfo = { + extra: ExtTypes; + types: ExtTypes; +} + +export type ExtDef = Record;