Skip to content

Commit

Permalink
feat: impl personal_ecRecover
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed May 12, 2024
1 parent deaf19a commit 434c324
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 46 deletions.
89 changes: 43 additions & 46 deletions packages/mask/entry-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
Methods listed in this document is not a commitment that it will be implemented.
The list is built from what [MetaMask supported](https://docs.metamask.io/wallet/reference/json-rpc-api/).

- <https://ethereum.github.io/execution-apis/api-documentation/>
- <https://ethereum.github.io/execution-apis/api-documentation/> or <https://eips.ethereum.org/EIPS/eip-1474>

## Read ETH methods
## Readonly ETH methods

- [x] net_version
- [x] eth_accounts
- [ ] eth_blobBaseFee
- [x] eth_blockNumber
- [x] eth_call
- [x] eth_chainId
- eth_coinbase: not supported by infura
- [ ] eth_createAccessList: not in MetaMask
- [x] eth_estimateGas
- [x] eth_feeHistory
- [x] eth_gasPrice
Expand All @@ -32,69 +34,64 @@ The list is built from what [MetaMask supported](https://docs.metamask.io/wallet
- [x] eth_getTransactionReceipt
- [x] eth_getUncleCountByBlockHash
- [x] eth_getUncleCountByBlockNumber
- [ ] eth_maxPriorityFeePerGas: not in MetaMask but in their docs <https://docs.metamask.io/wallet/reference/eth_maxpriorityfeepergas/>
- [x] eth_syncing

## Write ETH methods

- [ ] eth_sign (EIP-191): <https://support.metamask.io/hc/en-us/articles/14764161421467-What-is-eth-sign-and-why-is-it-a-risk->
- [x] personal_sign
- [ ] personal_ecRecover
- [x] eth_sendTransaction
- [ ] ~~eth_signTransaction: MetaMask refuse to add, we should follow them. <https://github.com/MetaMask/metamask-extension/issues/3475>~~
- [x] eth_sendRawTransaction

## ETH methods

## Subscribe to events (unknown specification)

- [x] eth_subscribe
- [x] eth_unsubscribe

## Filters
### Filters

- [x] eth_getFilterChanges
- [x] eth_getFilterLogs
- [x] eth_newBlockFilter
- [x] eth_newFilter
- [ ] eth_newPendingTransactionFilter (not supported by infura)
- eth_newPendingTransactionFilter (not supported by infura)
- [x] eth_uninstallFilter

## Deprecated methods
### [EIP-1474: Remote procedure call specification](https://eips.ethereum.org/EIPS/eip-1474)

- [ ] eth_decrypt
- [ ] eth_getEncryptionPublicKey
This section excludes PoW era methods and methods listed in <https://ethereum.github.io/execution-apis/api-documentation/>.

## [EIP-1102: Opt-in account exposure](https://eips.ethereum.org/EIPS/eip-1102)
- [ ] eth_protocolVersion
- [ ] net_listening
- [ ] net_peerCount
- [x] net_version
- [ ] web3_clientVersion
- [ ] web3_sha3

- [x] eth_requestAccounts
- [ ] (Deprecated) Provider.enable()
### [EIP-758: Subscriptions and filters for completed transactions](https://eips.ethereum.org/EIPS/eip-758)

## [EIP-2255: Wallet Permissions System](https://eips.ethereum.org/EIPS/eip-2255)
- [x] eth_subscribe
- [x] eth_unsubscribe

- [x] wallet_getPermissions
- [x] wallet_requestPermissions
- [ ] wallet_revokePermissions (not in EIP-2255)
## Wallet managements

## [EIP-712: Typed structured data hashing and signing](https://eips.ethereum.org/EIPS/eip-712)
- [x] wallet_watchAsset ([EIP-747](https://eips.ethereum.org/EIPS/eip-747))
- [ ] wallet_addEthereumChain ([EIP-3085](https://eips.ethereum.org/EIPS/eip-3085))
- [ ] wallet_switchEthereumChain ([EIP-3326](https://eips.ethereum.org/EIPS/eip-3326))

- [ ] eth_signTypedData
- [ ] eth_signTypedData_v3
- [ ] eth_signTypedData_v4
### [EIP-1102: Opt-in account exposure](https://eips.ethereum.org/EIPS/eip-1102)

## Other EIP
- [x] eth_requestAccounts
- (Deprecated) Provider.enable()

- [ ] wallet_watchAsset <https://eips.ethereum.org/EIPS/eip-747>
- [ ] wallet_addEthereumChain <https://eips.ethereum.org/EIPS/eip-3085>
- [ ] wallet_switchEthereumChain <https://ethereum-magicians.org/t/eip-3326-wallet-switchethereumchain>
### [EIP-2255: Wallet Permissions System](https://eips.ethereum.org/EIPS/eip-2255)

## Methods that has no specification?
- [x] wallet_getPermissions
- [x] wallet_requestPermissions
- [ ] wallet_revokePermissions (not in EIP-2255)

Methods not on a standard track is unlikely to be implemented.
## Readwrite ETH methods

- [ ] web3_clientVersion <https://docs.metamask.io/wallet/reference/web3_clientversion/>
- (Deprecated) eth_decrypt (replacement <https://eips.ethereum.org/EIPS/eip-5630>)
- (Deprecated) eth_getEncryptionPublicKey (replacement <https://eips.ethereum.org/EIPS/eip-5630>)
- eth_sign (EIP-191): <https://support.metamask.io/hc/en-us/articles/14764161421467-What-is-eth-sign-and-why-is-it-a-risk->
- [x] eth_sendTransaction
- [x] eth_sendRawTransaction
- eth_signTransaction: <https://github.com/MetaMask/metamask-extension/issues/3475>
- [x] personal_ecRecover (unknown EIP)
- [x] personal_sign (EIP-191)

## Other question
### [EIP-712: Typed structured data hashing and signing](https://eips.ethereum.org/EIPS/eip-712)

- [ ] eth_coinbase (not supported by infura)
- [ ] eth_maxPriorityFeePerGas: does not exist / is not available (MetaMask) but in their docs <https://docs.metamask.io/wallet/reference/eth_maxpriorityfeepergas/>
- [ ] eth_createAccessList: in ETH RPC specification but not in MetaMask.
- (Deprecated) eth_signTypedData
- (Deprecated) eth_signTypedData_v3
- [x] eth_signTypedData_v4
3 changes: 3 additions & 0 deletions packages/mask/entry-sdk/bridge/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const methods: Methods = {
params: [challenge, requestedAddress],
})
},
async personal_ecRecover(message, signature) {
return providers.EVMWeb3.getWeb3().eth.accounts.recover(message, signature)
},
async eth_sendTransaction(options) {
const wallets = await Services.Wallet.sdk_getGrantedWallets(location.origin)
if (!wallets.some((addr) => isSameAddress(addr, options.from)))
Expand Down
1 change: 1 addition & 0 deletions packages/mask/entry-sdk/bridge/eth/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const methodValidate = {
return: _.hex,
},
personal_sign: { args: z.tuple([_.hexAllowCap.describe('Challenge'), _.address]), return: _.hex },
personal_ecRecover: { args: z.tuple([z.string(), _.hex]), return: _.hex },
eth_sendTransaction: {
args: z.tuple([
// ! not same as _.transaction
Expand Down

0 comments on commit 434c324

Please sign in to comment.