Skip to content

Commit 15153ab

Browse files
authored
fix unknown request arg types equivalency issue (#120)
1 parent f8e03d8 commit 15153ab

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

src/content-scripts/bypassCheck.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
SimulateRequestArgs,
77
Transaction,
88
TransactionArgs,
9+
UnstandardizedSignatureRequestArgs,
910
} from '../models/simulation/Transaction';
1011
import { uuid4 } from '@sentry/utils';
1112
import { PortMessage, PortIdentifiers } from '../lib/helpers/chrome/messageHandler';
@@ -84,8 +85,9 @@ window.addEventListener('message', (message) => {
8485
const contentScriptPort = Browser.runtime.connect({ name: PortIdentifiers.WG_CONTENT_SCRIPT });
8586
sendMessageToPort(contentScriptPort, request);
8687
} catch (e) {
87-
const request: SignatureRequestArgs = {
88-
...data.params,
88+
const request: UnstandardizedSignatureRequestArgs = {
89+
signer: 'unknown request type',
90+
params: data.params,
8991
id: uuid4(),
9092
chainId: String(chainId),
9193
method: data.method,

src/injected/injectWalletGuard.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ const addWalletGuardProxy = (provider: any) => {
173173

174174
// Request does not conform to EIP-712 - pass along the params
175175
response = await REQUEST_MANAGER.request({
176-
...request.params,
176+
signer: 'unknown request type',
177+
params: request.params,
177178
chainId: await provider.request({ method: 'eth_chainId' }),
178179
method: request.method,
179180
});
@@ -368,7 +369,8 @@ const addWalletGuardProxy = (provider: any) => {
368369
.request({ method: 'eth_chainId' })
369370
.then((chainId: any) => {
370371
return REQUEST_MANAGER.request({
371-
...request.params,
372+
signer: 'unknown request type',
373+
params: request.params,
372374
chainId,
373375
method: request.method,
374376
});

src/lib/helpers/chrome/messageHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function findApprovedTransaction(approvedTxns: TransactionArgs[], txn: Tr
4646
return approvedTxns.find((x: any) => x.signMessage === txn.signMessage);
4747
} else if ('hash' in txn) {
4848
return approvedTxns.find((x: any) => x.hash === txn.hash);
49+
} else if ('params' in txn) {
50+
return approvedTxns.find((x: any) => txn.signer === 'unknown request type');
4951
}
5052
}
5153

src/lib/simulation/requests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class RequestManager {
4242
signMessage: string;
4343
}
4444
| {
45-
[key: string]: any
45+
params: any
4646
}
4747
)
4848
): Promise<Response> {

src/models/simulation/Transaction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ export enum SimulationMethodType {
3232
PersonalSign = 'personal_sign',
3333
}
3434

35-
export type TransactionArgs = SimulateRequestArgs | SignatureRequestArgs | SignatureHashSignArgs | PersonalSignArgs;
35+
export type TransactionArgs = SimulateRequestArgs | SignatureRequestArgs | SignatureHashSignArgs | PersonalSignArgs | UnstandardizedSignatureRequestArgs;
3636

3737
// Transaction we want to forward.
3838
export interface SimulateRequestArgs extends RequestArgs {
3939
transaction: Transaction;
4040
};
4141

42+
export interface UnstandardizedSignatureRequestArgs extends RequestArgs {
43+
params: any;
44+
}
45+
4246
export interface SignatureRequestArgs extends RequestArgs {
4347
// Domain for this signature request.
4448
domain: any; // TODO: add types here?

0 commit comments

Comments
 (0)