From 52a82c96546fa5dad22c73d4045a07e1b6d1b722 Mon Sep 17 00:00:00 2001 From: Daniel Rocha <68558152+danroc@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:32:28 +0200 Subject: [PATCH] chore: check transaction signature format --- src/SnapKeyring.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/SnapKeyring.ts b/src/SnapKeyring.ts index cb3f6409..3608b87d 100644 --- a/src/SnapKeyring.ts +++ b/src/SnapKeyring.ts @@ -15,7 +15,7 @@ import { KeyringEvent } from '@metamask/keyring-api/dist/events'; import { SnapController } from '@metamask/snaps-controllers'; import { Json, bigIntToHex } from '@metamask/utils'; import { EventEmitter } from 'events'; -import { assert, object, string, record, Infer } from 'superstruct'; +import { assert, object, string, record, Infer, mask } from 'superstruct'; import { v4 as uuid } from 'uuid'; import { CaseInsensitiveMap } from './CaseInsensitiveMap'; @@ -226,15 +226,26 @@ export class SnapKeyring extends EventEmitter { chainId: bigIntToHex(transaction.common.chainId()), }); - const signature = await this.#submitRequest({ + const signedTx = await this.#submitRequest({ address, method: EthMethod.SignTransaction, params: [tx], }); + const signature = mask( + signedTx, + object({ + r: string(), + s: string(), + v: string(), + }), + ); + return TransactionFactory.fromTxData({ ...(tx as Record), - ...(signature as Record), + r: signature.r, + s: signature.s, + v: signature.v, }); }