Skip to content

Commit

Permalink
fix(evm): proxy several methods with Etherscan correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Feb 26, 2025
1 parent 44b3b4d commit 8f6a973
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/content-scripts/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ const runContentScript = () => {
handleEthRpcRequest(event, method, { address: event.data.params[0] });
} else if (method === ETH_RPC_METHODS.signPersonal) {
handleEthRpcRequest(event, method, { data: event.data.params?.[0] });
} else if (
method === ETH_RPC_ETHERSCAN_PROXY_METHODS.getTransactionByHash
|| method === ETH_RPC_ETHERSCAN_PROXY_METHODS.getTransactionReceipt
) {
handleEthRpcRequest(event, method, { txhash: event.data.params?.[0] });
} else if (method === ETH_RPC_ETHERSCAN_PROXY_METHODS.getBlockByNumber) {
handleEthRpcRequest(event, method, {
tag: event.data.params?.[0],
boolean: event.data.params?.[1],
});
} else if (method === ETH_RPC_ETHERSCAN_PROXY_METHODS.getUncleByBlockNumberAndIndex) {
handleEthRpcRequest(event, method, {
tag: event.data.params?.[0],
index: event.data.params?.[1],
});
} else if (
Object.values(ETH_RPC_METHODS).includes(method)
|| Object.values(ETH_RPC_ETHERSCAN_PROXY_METHODS).includes(method)
Expand Down
3 changes: 3 additions & 0 deletions src/protocols/ethereum/libs/EthereumRpcMethodsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ export async function handleEthereumRpcMethod(
action: method,
...params,
});
if (!response?.message?.startsWith('OK')) {
getUnknownError(response?.result || 'Unknown error');
}
return { result: response?.result };
} catch (error: any) {
return getUnknownError(error.message);
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/ethereum/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface IEthRpcMethodParameters {
value?: string;
chainId?: string;
result?: string;
/** This exist for proxy Etherscan methods */
[key: string]: string | undefined;
}

export type EthRpcMethod = ObjectValues<typeof ETH_RPC_METHODS>;
Expand Down

0 comments on commit 8f6a973

Please sign in to comment.