.paymentInfo never mutates the existing signature (#5659)

This commit is contained in:
Jaco
2023-05-26 08:02:18 +03:00
committed by GitHub
parent 54c96ed975
commit cdd74ea084
3 changed files with 14 additions and 5 deletions
+5 -3
View File
@@ -160,9 +160,11 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
// setup our options (same way as in signAndSend)
const eraOptions = makeEraOptions(api, this.registry, allOptions, signingInfo);
const signOptions = makeSignOptions(api, eraOptions, {});
const u8a = this.isSigned
? api.tx(this).signFake(address, signOptions).toU8a()
: this.signFake(address, signOptions).toU8a();
// 1. Don't use the internal objects inside the new tx (hence toU8a)
// 2. Don't override the data from existing signed extrinsics
// 3. Ensure that this object stays intact, with no new sign after operation
const u8a = api.tx(this.toU8a()).signFake(address, signOptions).toU8a();
return api.call.transactionPaymentApi.queryInfo(u8a, u8a.length);
})
+2 -2
View File
@@ -35,8 +35,8 @@ export class GenericExtrinsicV4 extends Struct implements IExtrinsicImpl {
public static decodeExtrinsic (registry: Registry, value?: Call | Uint8Array | ExtrinsicValueV4, isSigned = false): ExtrinsicValueV4 {
if (value instanceof GenericExtrinsicV4) {
return value;
} else if (value instanceof registry.createClassUnsafe('Call')) {
return { method: value as Call };
} else if (value instanceof registry.createClassUnsafe<Call>('Call')) {
return { method: value };
} else if (isU8a(value)) {
// here we decode manually since we need to pull through the version information
const signature = registry.createTypeUnsafe<ExtrinsicSignatureV4>('ExtrinsicSignatureV4', [value, { isSigned }]);