kodadot / sub-scaffold

🏗 forkable Substrate dev stack focused on fast product iterations
sub-scaffold.vercel.app
MIT License
12 stars 1 forks source link

Create Address Component #9

Closed dudo50 closed 1 year ago

dudo50 commented 1 year ago

Create a component, that will handle addresses (eg AccountID32, AccountKey20 and will verify them)

dudo50 commented 1 year ago

Let me clarify this issue a little closer. Suppose we have user entering the address to which they wish to transfer their funds (on another network). We need to handle situations where they type in the wrong address (for example too many characters or too few characters). There are mainly two kinds of addresses we are looking to handle:

The way we handle if AccountKey20 is valid at the moment in Paraspell/SDK is by importing ethers and checking if the function returns true. This is sufficient and can be integrated. On Polkadot however, we only check if the size of the string is long enough as we have not yet found a way to check for this more efficiently. If possible, explore this a little and see if there is any way to validate AccountId32 address types. We generally want to give user a warning for typing in the wrong address format, but non-invasive although it should be clear, that address they pasted is not compliant..

Example of checking if AccountKey20 has a valid format:

import { ethers } from 'ethers'
 if (ethers.utils.isAddress(to)) ...

Example of each:


AccountKey20 - 0xa085190c859eAe92bCCED9CE05b10DDb363FE5Ea
AccountId32 - 1jbEnzKdwYZMDsmz5ee2L1H6CMfW1Za3MqjtXFwmeZsRe9P
brano-hozza commented 1 year ago

I will look into kodadot implementation for solution