Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check validator address #89

Merged
merged 5 commits into from
Apr 12, 2023
Merged

Conversation

abefernan
Copy link
Contributor

Since the chains on the registry don't seem to usually set their bech32_config I made checkAddress() be less strict to include validator addresses.

@abefernan abefernan requested a review from webmaster128 April 12, 2023 08:18
@abefernan abefernan self-assigned this Apr 12, 2023
@vercel
Copy link

vercel bot commented Apr 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cosmos-multisig-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2023 8:53am

return `Expected address prefix '${chainAddressPrefix}' but got '${prefix}'`;
}

if (data.length !== 20) {
if (data.length < 20) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you need this change? The validator addresses should all be 20 bytes. This is the data encoded in the bech32 length, not the string length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not then, we did this check that way for tgrade to be on the safe side but it might not be needed

Copy link
Member

@webmaster128 webmaster128 Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two possible lengths: 20 and 32 bytes. But 32 bytes is only needed for contracts at the moment.

@@ -93,7 +93,7 @@ const DelegationForm = (props: Props) => {
value={validatorAddress}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setValidatorAddress(e.target.value)}
error={addressError}
placeholder={`E.g. cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0`}
placeholder={`E.g. ${state.chain.addressPrefix}1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get some exampleValidatorAddress function just like exampleAddress and use it here. We need to explain the user to use the XXXXvaloper1YYYYYY address somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are chains that seem to use valoper for validator addresses but don't set it on the chain json, so we can't know beforehand

Copy link
Member

@webmaster128 webmaster128 Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all chains use valoper addresses. Tgrade is an exception here.

So we can just guess it will be XXXXvaloper1YYYYYY like this:

  • Take some random 20 bytes
  • Use const validatorPrefix = prefix + valoper
  • call toBech32 to generate a full example address with the two inputs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation can remain less strict but the example should hint to valoper addresses

@webmaster128 webmaster128 merged commit 85a0d2d into master Apr 12, 2023
@webmaster128 webmaster128 deleted the fix/check-validator-address branch April 12, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants