Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
chore: check transaction signature format
Browse files Browse the repository at this point in the history
  • Loading branch information
danroc committed Sep 12, 2023
1 parent e466cde commit 52a82c9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/SnapKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<string, Json>),
...(signature as Record<string, Json>),
r: signature.r,
s: signature.s,
v: signature.v,
});
}

Expand Down

0 comments on commit 52a82c9

Please sign in to comment.