Update known extensions (with Polkadot) (#1800)
* Update known extensions (with Polkadot) * Split definitions for signed extensions
This commit is contained in:
@@ -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';
|
||||
|
||||
+7
-48
@@ -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<string, InterfaceTypes>;
|
||||
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<string, ExtInfo> = {
|
||||
ChargeTransactionPayment: {
|
||||
extra: {},
|
||||
types: {
|
||||
tip: 'Compact<Balance>'
|
||||
}
|
||||
},
|
||||
CheckBlockGasLimit: {
|
||||
extra: {},
|
||||
types: {}
|
||||
},
|
||||
CheckEra: {
|
||||
extra: {
|
||||
blockHash: 'Hash'
|
||||
},
|
||||
types: {
|
||||
era: 'ExtrinsicEra'
|
||||
}
|
||||
},
|
||||
CheckGenesis: {
|
||||
extra: {
|
||||
genesisHash: 'Hash'
|
||||
},
|
||||
types: {}
|
||||
},
|
||||
CheckNonce: {
|
||||
extra: {},
|
||||
types: {
|
||||
nonce: 'Compact<Index>'
|
||||
}
|
||||
},
|
||||
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<keyof typeof allExtensions> = [
|
||||
'CheckVersion',
|
||||
'CheckGenesis',
|
||||
@@ -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;
|
||||
@@ -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<Balance>'
|
||||
}
|
||||
},
|
||||
CheckBlockGasLimit: {
|
||||
extra: {},
|
||||
types: {}
|
||||
},
|
||||
CheckEra: {
|
||||
extra: {
|
||||
blockHash: 'Hash'
|
||||
},
|
||||
types: {
|
||||
era: 'ExtrinsicEra'
|
||||
}
|
||||
},
|
||||
CheckGenesis: {
|
||||
extra: {
|
||||
genesisHash: 'Hash'
|
||||
},
|
||||
types: {}
|
||||
},
|
||||
CheckNonce: {
|
||||
extra: {},
|
||||
types: {
|
||||
nonce: 'Compact<Index>'
|
||||
}
|
||||
},
|
||||
CheckVersion: {
|
||||
extra: {
|
||||
specVersion: 'u32'
|
||||
},
|
||||
types: {}
|
||||
},
|
||||
CheckWeight: {
|
||||
extra: {},
|
||||
types: {}
|
||||
}
|
||||
} as ExtDef;
|
||||
@@ -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<string, InterfaceTypes>;
|
||||
|
||||
export type ExtInfo = {
|
||||
extra: ExtTypes;
|
||||
types: ExtTypes;
|
||||
}
|
||||
|
||||
export type ExtDef = Record<string, ExtInfo>;
|
||||
Reference in New Issue
Block a user