Add specVersion to SignedExtra payload (#1324)
* Add specVersion to SignedExtra payload * Update ExtrinsicPayload.ts * Cleanup linting & tests (code-only) * Update after e2e testing in apps * Check and fix tests * Grrr... case sensitivity * Use interfaces where available * Case sensitive fixes
This commit is contained in:
@@ -16,6 +16,7 @@ describe('SignerPayload', (): void => {
|
||||
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
|
||||
method: '0x0500ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
|
||||
nonce: '0x00001234',
|
||||
specVersion: '0x00000000',
|
||||
tip: '0x00000000000000000000000000005678',
|
||||
version: 3
|
||||
};
|
||||
@@ -45,6 +46,7 @@ describe('SignerPayload', (): void => {
|
||||
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
|
||||
method: '0x0500ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
|
||||
nonce: '0x00001234',
|
||||
specVersion: '0x00000000',
|
||||
tip: '0x00000000000000000000000000005678',
|
||||
version: 3
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Address, Balance, BlockNumber, Call, ExtrinsicEra, Hash, Index } from '@polkadot/types/interfaces';
|
||||
import { Address, Balance, BlockNumber, Call, ExtrinsicEra, Hash, Index, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { Constructor } from '@polkadot/types/types';
|
||||
import { SignerPayload, SignerPayloadRaw } from './types';
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface SignerPayloadType {
|
||||
genesisHash: Hash;
|
||||
method: Call;
|
||||
nonce: Compact<Index>;
|
||||
runtimeVersion: RuntimeVersion;
|
||||
tip: Compact<Balance>;
|
||||
version: u8;
|
||||
}
|
||||
@@ -30,6 +31,7 @@ const _Payload: Constructor<SignerPayloadType> = Struct.with({
|
||||
genesisHash: 'Hash',
|
||||
method: 'Call',
|
||||
nonce: 'Compact<Index>',
|
||||
runtimeVersion: 'RuntimeVersion',
|
||||
tip: 'Compact<Balance>',
|
||||
version: u8
|
||||
});
|
||||
@@ -46,7 +48,7 @@ export default class Payload extends _Payload {
|
||||
* @description Creates an representation of the structure as an ISignerPayload JSON
|
||||
*/
|
||||
public toPayload (): SignerPayload {
|
||||
const { address, blockHash, blockNumber, era, genesisHash, method, nonce, tip, version } = this.self;
|
||||
const { address, blockHash, blockNumber, era, genesisHash, method, nonce, runtimeVersion: { specVersion }, tip, version } = this.self;
|
||||
|
||||
return {
|
||||
address: address.toString(),
|
||||
@@ -56,6 +58,7 @@ export default class Payload extends _Payload {
|
||||
genesisHash: genesisHash.toHex(),
|
||||
method: method.toHex(),
|
||||
nonce: nonce.toHex(),
|
||||
specVersion: specVersion.toHex(),
|
||||
tip: tip.toHex(),
|
||||
version: version.toNumber()
|
||||
};
|
||||
|
||||
@@ -176,10 +176,11 @@ export default function createSubmittableExtrinsic<ApiType> (
|
||||
function expandOptions (options: Partial<SignerOptions>, extras: { blockHash?: Hash; era?: ExtrinsicEra; nonce?: Index }): SignatureOptions {
|
||||
return {
|
||||
blockHash: api.genesisHash,
|
||||
version: api.runtimeVersion,
|
||||
...options,
|
||||
...extras,
|
||||
genesisHash: api.genesisHash
|
||||
genesisHash: api.genesisHash,
|
||||
runtimeVersion: api.runtimeVersion,
|
||||
version: api.extrinsicType
|
||||
} as unknown as SignatureOptions;
|
||||
}
|
||||
|
||||
@@ -272,9 +273,7 @@ export default function createSubmittableExtrinsic<ApiType> (
|
||||
...eraOptions,
|
||||
address,
|
||||
method: _extrinsic.method,
|
||||
blockNumber: header ? header.number : 0,
|
||||
genesisHash: api.genesisHash,
|
||||
version: api.extrinsicType
|
||||
blockNumber: header ? header.number : 0
|
||||
});
|
||||
|
||||
if (api.signer.signPayload) {
|
||||
|
||||
@@ -246,6 +246,11 @@ export interface SignerPayload {
|
||||
*/
|
||||
nonce: string;
|
||||
|
||||
/**
|
||||
* @description The current spec version for the runtime
|
||||
*/
|
||||
specVersion: string;
|
||||
|
||||
/**
|
||||
* @description The tip for this transaction, in hex
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user