Skip to content

Commit

Permalink
Remove Hash Method from Request Router (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith authored Sep 19, 2024
1 parent 09317d9 commit 72d718e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 deletions.
40 changes: 21 additions & 19 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MpcContract } from "./mpcContract";
import {
Address,
Hash,
Hex,
SignableMessage,
Signature,
TransactionSerializable,
TypedDataDomain,
} from "viem";

/**
Expand Down Expand Up @@ -145,35 +145,39 @@ export interface MessageData {
message: SignableMessage;
}

interface TypedDataTypes {
name: string;
type: string;
}
type TypedMessageTypes = {
[key: string]: TypedDataTypes[];
};

/**
* Represents the data for a typed message.
*
* @property {Hex} address - The address associated with the message.
* @property {any} types - The types of the message.
* @property {any} primaryType - The primary type of the message.
* @property {any} message - The message itself.
* @property {any} domain - The domain of the message.
* @property {TypedDataDomain} domain - The domain of the message.
* @property {TypedMessageTypes} types - The types of the message.
* @property {Record<string, unknown>} message - The message itself.
* @property {string} primaryType - The primary type of the message.
*/
export interface TypedMessageData {
address: Hex;
/* eslint-disable @typescript-eslint/no-explicit-any */
types: any;
primaryType: any;
message: any;
domain: any;
/* eslint-enable @typescript-eslint/no-explicit-any */
}
export type EIP712TypedData = {
domain: TypedDataDomain;
types: TypedMessageTypes;
message: Record<string, unknown>;
primaryType: string;
};

/**
* Represents the recovery data.
*
* @property {string} type - The type of the recovery data.
* @property {MessageData | TypedMessageData | Hex} data - The recovery data.
* @property {MessageData | EIP712TypedData | Hex} data - The recovery data.
*/
export interface RecoveryData {
// TODO use enum!
type: string;
data: MessageData | TypedMessageData | Hex;
data: MessageData | EIP712TypedData | Hex;
}

/**
Expand Down Expand Up @@ -243,7 +247,6 @@ export type TypedDataParams = [Hex, string];
* @property {TypedDataParams} - Parameters for signing structured data.
*/
export type SessionRequestParams =
| Hash
| EthTransactionParams[]
| Hex
| PersonalSignParams
Expand All @@ -254,7 +257,6 @@ export type SessionRequestParams =
* An array of supported signing methods.
*/
export const signMethods = [
"hash",
"eth_sign",
"personal_sign",
"eth_sendTransaction",
Expand Down
11 changes: 0 additions & 11 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Hash,
Hex,
fromHex,
hashMessage,
Expand Down Expand Up @@ -39,16 +38,6 @@ export async function requestRouter({
recoveryData: RecoveryData;
}> {
switch (method) {
case "hash": {
console.warn("Unsafe hash without context sign request");
const hash = params as Hash;
return {
payload: toPayload(hash),
// These should be more.
evmMessage: hash,
recoveryData: { type: "hash", data: hash },
};
}
case "eth_sign": {
const [sender, messageHash] = params as EthSignParams;
return {
Expand Down

0 comments on commit 72d718e

Please sign in to comment.