Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Hash Method from Request Router #120

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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