Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Closed
Changes from 1 commit
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
30 changes: 30 additions & 0 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export interface WalletMiddlewareOptions {
req: JsonRpcRequest<unknown>,
version: string,
) => Promise<string>;
processPlumeSignature?: (
msgParams: MessageParams,
req: JsonRpcRequest<unknown>,
) => Promise<string>;
}

export function createWalletMiddleware({
Expand All @@ -75,6 +79,7 @@ export function createWalletMiddleware({
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPlumeSignature,
}: WalletMiddlewareOptions): JsonRpcMiddleware<string, Block> {
if (!getAccounts) {
throw new Error('opts.getAccounts is required');
Expand All @@ -96,6 +101,7 @@ export function createWalletMiddleware({
eth_getEncryptionPublicKey: createAsyncMiddleware(encryptionPublicKey),
eth_decrypt: createAsyncMiddleware(decryptMessage),
personal_ecRecover: createAsyncMiddleware(personalRecover),
eth_getPlumeSignature: createAsyncMiddleware(plumeSignature),
});

//
Expand Down Expand Up @@ -356,6 +362,30 @@ export function createWalletMiddleware({
res.result = await processDecryptMessage(msgParams, req);
}

async function plumeSignature(
req: JsonRpcRequest<unknown>,
res: PendingJsonRpcResponse<unknown>,
): Promise<void> {
if (!processPlumeSignature) {
throw ethErrors.rpc.methodNotSupported();
}

const message: string = (req.params as string[])[0];
const address: string = await validateAndNormalizeKeyholder(
(req.params as string[])[1],
req,
);
const extraParams: Record<string, unknown> =
(req.params as Record<string, unknown>[])[2] || {};
const msgParams: MessageParams = {
...extraParams,
from: address,
data: message,
};

res.result = await processPlumeSignature(msgParams, req);
}

//
// utility
//
Expand Down