Skip to content

Commit

Permalink
Add signatureMethod property to MessageParams (#273)
Browse files Browse the repository at this point in the history
* add signatureMethod property to MessageParams

* simplify
  • Loading branch information
hmalik88 authored Dec 6, 2023
1 parent bf3aa95 commit 21701a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ describe('wallet', () => {
expect(witnessedMsgParams[0]).toStrictEqual({
from: testAddresses[0],
data: message,
signatureMethod: 'eth_signTypedData',
});
});

Expand Down Expand Up @@ -352,6 +353,7 @@ describe('wallet', () => {
expect(witnessedMsgParams[0]).toStrictEqual({
data: message,
from: testAddresses[0],
signatureMethod: 'personal_sign',
});
});

Expand Down
6 changes: 6 additions & 0 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type TransactionParams = {

export type MessageParams = TransactionParams & {
data: string;
signatureMethod?: string;
};

export type TypedMessageParams = MessageParams & {
Expand Down Expand Up @@ -212,6 +213,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
...extraParams,
from: address,
data: message,
signatureMethod: 'eth_sign',
};

res.result = await processEthSignMessage(msgParams, req);
Expand Down Expand Up @@ -241,6 +243,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
...extraParams,
from: address,
data: message,
signatureMethod: 'eth_signTypedData',
};

res.result = await processTypedMessage(msgParams, req, version);
Expand Down Expand Up @@ -270,6 +273,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
data: message,
from: address,
version,
signatureMethod: 'eth_signTypedData_v3',
};

res.result = await processTypedMessageV3(msgParams, req, version);
Expand Down Expand Up @@ -299,6 +303,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
data: message,
from: address,
version,
signatureMethod: 'eth_signTypedData_v4',
};

res.result = await processTypedMessageV4(msgParams, req, version);
Expand Down Expand Up @@ -354,6 +359,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
...extraParams,
from: address,
data: message,
signatureMethod: 'personal_sign',
};

// eslint-disable-next-line require-atomic-updates
Expand Down

0 comments on commit 21701a6

Please sign in to comment.