From cb1078ac4bce72377052e76cefcd52a4174f3d22 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:18:14 +0100 Subject: [PATCH] Allow external signers to modify the payload (#6030) * remove validateSignedTransaction * add optional allowCallDataAlteration defaulting to true * nit * spacing * Update packages/api/src/submittable/createClass.ts --- packages/api/src/submittable/createClass.ts | 6 +++++- packages/types/src/types/extrinsic.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/api/src/submittable/createClass.ts b/packages/api/src/submittable/createClass.ts index 1c8b1088ad4..cff1c268c27 100644 --- a/packages/api/src/submittable/createClass.ts +++ b/packages/api/src/submittable/createClass.ts @@ -325,6 +325,7 @@ export function createClass ({ api, apiType, blockHas #signViaSigner = async (address: Address | string | Uint8Array, options: SignatureOptions, header: Header | null): Promise => { const signer = options.signer || api.signer; + const allowCallDataAlteration = options.allowCallDataAlteration ?? true; if (!signer) { throw new Error('No signer specified, either via api.setSigner or via sign options. You possibly need to pass through an explicit keypair for the origin so it can be used for signing.'); @@ -367,7 +368,10 @@ export function createClass ({ api, apiType, blockHas throw new Error(`When using the signedTransaction field, the transaction must be signed. Recieved isSigned: ${ext.isSigned}`); } - this.#validateSignedTransaction(payload, ext); + if (!allowCallDataAlteration) { + this.#validateSignedTransaction(payload, ext); + } + // This is only used for signAsync - signAndSend does not need to adjust the super payload or // add the signature. super.addSignature(address, result.signature, newSignerPayload.toPayload()); diff --git a/packages/types/src/types/extrinsic.ts b/packages/types/src/types/extrinsic.ts index ed0546aef04..897483d308c 100644 --- a/packages/types/src/types/extrinsic.ts +++ b/packages/types/src/types/extrinsic.ts @@ -188,6 +188,7 @@ export interface IExtrinsicEra extends Codec { } export interface SignatureOptions { + allowCallDataAlteration?: boolean; blockHash: Uint8Array | string; era?: IExtrinsicEra; genesisHash: Uint8Array | string;