diff --git a/packages/mask/entry-sdk/README.md b/packages/mask/entry-sdk/README.md index 916549ed276..e126964b3f8 100644 --- a/packages/mask/entry-sdk/README.md +++ b/packages/mask/entry-sdk/README.md @@ -54,12 +54,12 @@ The list is built from what [MetaMask supported](https://docs.metamask.io/wallet ## Filters -- [ ] eth_getFilterChanges -- [ ] eth_getFilterLogs -- [ ] eth_newBlockFilter -- [ ] eth_newFilter -- [ ] eth_newPendingTransactionFilter -- [ ] eth_uninstallFilter +- [x] eth_getFilterChanges +- [x] eth_getFilterLogs +- [x] eth_newBlockFilter +- [x] eth_newFilter +- [ ] eth_newPendingTransactionFilter (not supported by infura) +- [x] eth_uninstallFilter ## Deprecated methods diff --git a/packages/mask/entry-sdk/bridge/eth.ts b/packages/mask/entry-sdk/bridge/eth.ts index a4519a40363..a77a5e8f9df 100644 --- a/packages/mask/entry-sdk/bridge/eth.ts +++ b/packages/mask/entry-sdk/bridge/eth.ts @@ -10,9 +10,18 @@ import { maskSDK } from '../index.js' import { sample } from 'lodash-es' import { AsyncCall, JSONSerialization } from 'async-call-rpc/full' -const readonlyMethods: Record Promise> = {} as any -for (const method of readonlyMethodType) { - readonlyMethods[method] = async (...params: unknown[]) => { +const PassthroughMethods = [ + ...readonlyMethodType, + EthereumMethodType.ETH_GET_FILTER_CHANGES, + EthereumMethodType.ETH_GET_FILTER_LOGS, + EthereumMethodType.ETH_NEW_BLOCK_FILTER, + EthereumMethodType.ETH_NEW_FILTER, + EthereumMethodType.ETH_UNINSTALL_FILTER, +] +type PassthroughMethods = (typeof PassthroughMethods)[number] +const passthroughMethods: Record Promise> = {} as any +for (const method of PassthroughMethods) { + passthroughMethods[method] = async (...params: unknown[]) => { return (await Services.Wallet.send({ jsonrpc: '2.0', method, params })).result } } @@ -69,7 +78,7 @@ function getInteractiveClient(): Promise { // https://ethereum.github.io/execution-apis/api-documentation/ // https://docs.metamask.io/wallet/reference/eth_subscribe/ const methods = { - ...readonlyMethods, + ...passthroughMethods, async eth_chainId() { const chainId = await Services.Wallet.sdk_eth_chainId() diff --git a/packages/mask/entry-sdk/bridge/eth/validator.ts b/packages/mask/entry-sdk/bridge/eth/validator.ts index b97830fb8f1..81f2d2c400b 100644 --- a/packages/mask/entry-sdk/bridge/eth/validator.ts +++ b/packages/mask/entry-sdk/bridge/eth/validator.ts @@ -37,11 +37,12 @@ namespace _ { export const decimal = z.number().min(0).max(36) export const filter = z .object({ - fromBlock: unpadded_hex.nullish(), - toBlock: unpadded_hex.nullish(), - address: address.or(address.array()), - topics: z.any(), + fromBlock: unpadded_hex.nullish().nullable(), + toBlock: unpadded_hex.nullish().nullable(), + address: address.or(address.array()).nullable(), + topics: z.any().nullable(), }) + .partial() .strict() .describe('Filter') export const filter_identifier = unpadded_hex.describe('FilterIdentifier') diff --git a/packages/web3-shared/evm/src/types/index.ts b/packages/web3-shared/evm/src/types/index.ts index d18fba99189..124183c19e0 100644 --- a/packages/web3-shared/evm/src/types/index.ts +++ b/packages/web3-shared/evm/src/types/index.ts @@ -212,7 +212,11 @@ export enum EthereumMethodType { ETH_GET_TRANSACTION_RECEIPT = 'eth_getTransactionReceipt', ETH_GET_TRANSACTION_COUNT = 'eth_getTransactionCount', ETH_GET_FILTER_CHANGES = 'eth_getFilterChanges', + ETH_GET_FILTER_LOGS = 'eth_getFilterLogs', + ETH_NEW_BLOCK_FILTER = 'eth_newBlockFilter', + ETH_NEW_FILTER = 'eth_newFilter', ETH_NEW_PENDING_TRANSACTION_FILTER = 'eth_newPendingTransactionFilter', + ETH_UNINSTALL_FILTER = 'eth_uninstallFilter', ETH_ESTIMATE_GAS = 'eth_estimateGas', ETH_CALL = 'eth_call', ETH_SIGN = 'eth_sign',