Register dApp with EVM account#171
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for dApp registration using an EVM account by introducing new signature verification logic and address conversion.
- Introduces EVM signature verification with ethers.verifyMessage
- Converts EVM addresses to SS58 format when constructing the verification payload
- Updates the developer check to use the converted SS58 address
| ): Promise<boolean> { | ||
| const api = this._apiFactory.getApiInstance(network); | ||
| const isEvmSigner = isEthereumAddress(senderAddress); | ||
| const ss58SenderAddress = isEvmSigner ? evmToAddress(senderAddress, ASTAR_SS58_FORMAT) : senderAddress; |
There was a problem hiding this comment.
[nitpick] Consider adding an inline comment explaining why the sender address is converted to SS58 format for EVM signers and how this conversion aligns with the expected payload format.
| const signerAddress = ethers.verifyMessage(messageToVerify, signature); | ||
| isValidSignature = signerAddress.toLowerCase() === senderAddress.toLowerCase(); |
There was a problem hiding this comment.
Consider wrapping ethers.verifyMessage in a try-catch block to gracefully handle potential exceptions during signature verification for EVM signers.
| const signerAddress = ethers.verifyMessage(messageToVerify, signature); | |
| isValidSignature = signerAddress.toLowerCase() === senderAddress.toLowerCase(); | |
| try { | |
| const signerAddress = ethers.verifyMessage(messageToVerify, signature); | |
| isValidSignature = signerAddress.toLowerCase() === senderAddress.toLowerCase(); | |
| } catch (error) { | |
| console.error('Error verifying EVM signature:', error); | |
| isValidSignature = false; | |
| } |
|
Visit the preview URL for this PR (updated for commit 1b4c096): https://astar-token-api--pr171-feat-register-dapp-h-xya6fcmg.web.app (expires Fri, 30 May 2025 11:23:14 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f99fa4f4f8f3bb450e6e842f7e1c7783d6d896a3 |
|
This is an intriguing improvement. |
This PR enables a dApp registration with EVM account. Until now the registration was possible with SS58 account only.