-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
lib/displayHelpers.ts
Outdated
return `Expected address prefix '${chainAddressPrefix}' but got '${prefix}'`; | ||
} | ||
|
||
if (data.length !== 20) { | ||
if (data.length < 20) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
components/forms/DelegationForm.tsx
Outdated
@@ -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`} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Since the chains on the registry don't seem to usually set their
bech32_config
I madecheckAddress()
be less strict to include validator addresses.