Skip to content

Commit 5a44d3b

Browse files
authored
Ensure SignerPayload has withSignedTransaction (#5922)
* Ensure SignerPayload has `withSignedTransaction` * remove console.log * fix tests
1 parent 0bac3d4 commit 5a44d3b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

packages/types/src/extrinsic/SignerPayload.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ describe('SignerPayload', (): void => {
3131
specVersion: '0x00000006',
3232
tip: '0x00000000000000000000000000005678',
3333
transactionVersion: '0x00000007',
34-
version: 4
34+
version: 4,
35+
withSignedTransaction: false
3536
};
3637

3738
it('creates a valid JSON output', (): void => {
@@ -50,7 +51,8 @@ describe('SignerPayload', (): void => {
5051
nonce: 0x1234,
5152
signedExtensions: ['CheckNonce'],
5253
tip: 0x5678,
53-
version: 4
54+
version: 4,
55+
withSignedTransaction: true
5456
}).toPayload()
5557
).toEqual({
5658
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
@@ -68,7 +70,8 @@ describe('SignerPayload', (): void => {
6870
specVersion: '0x00000000',
6971
tip: '0x00000000000000000000000000005678',
7072
transactionVersion: '0x00000000',
71-
version: 4
73+
version: 4,
74+
withSignedTransaction: true
7275
});
7376
});
7477

@@ -164,7 +167,8 @@ describe('SignerPayload', (): void => {
164167
specVersion: '0x00000006',
165168
tip: '0x00000000000000000000000000005678',
166169
transactionVersion: '0x00000007',
167-
version: 4
170+
version: 4,
171+
withSignedTransaction: false
168172
};
169173

170174
it('can build SignerPayload without additional SignedExtensions', (): void => {

packages/types/src/extrinsic/SignerPayload.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2017-2024 @polkadot/types authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import type { Text, Vec } from '@polkadot/types-codec';
4+
import type { bool, Text, Vec } from '@polkadot/types-codec';
55
import type { AnyJson, Registry } from '@polkadot/types-codec/types';
66
import type { HexString } from '@polkadot/util/types';
77
import type { Address, BlockHash, Call, ExtrinsicEra, Hash, MultiLocation } from '../interfaces/index.js';
@@ -55,7 +55,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
5555
constructor (registry: Registry, value?: HexString | Record<string, unknown> | Map<unknown, unknown> | unknown[]) {
5656
const extensionTypes = objectSpread<Record<string, string>>({}, registry.getSignedExtensionTypes(), registry.getSignedExtensionExtra());
5757

58-
super(registry, objectSpread<Record<string, string>>({}, extensionTypes, knownTypes), value);
58+
super(registry, objectSpread<Record<string, string>>({}, extensionTypes, knownTypes, { withSignedTransaction: 'bool' }), value);
5959

6060
this.#extraTypes = {};
6161
const getter = (key: string) => this.get(key);
@@ -126,6 +126,12 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
126126
return this.getT('metadataHash');
127127
}
128128

129+
get withSignedTransaction (): boolean {
130+
const val: bool = this.getT('withSignedTransaction');
131+
132+
return val.isTrue;
133+
}
134+
129135
/**
130136
* @description Creates an representation of the structure as an ISignerPayload JSON
131137
*/
@@ -166,7 +172,8 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
166172
specVersion: this.runtimeVersion.specVersion.toHex(),
167173
tip: this.tip.toHex(),
168174
transactionVersion: this.runtimeVersion.transactionVersion.toHex(),
169-
version: this.version.toNumber()
175+
version: this.version.toNumber(),
176+
withSignedTransaction: this.withSignedTransaction
170177
});
171178
}
172179

0 commit comments

Comments
 (0)