-
Notifications
You must be signed in to change notification settings - Fork 150
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
feat: add /accounts/:address/validate endpoint #726
Conversation
docs/src/openapi-v1.yaml
Outdated
networkId: | ||
type: string | ||
description: Name of the network the address is associated with | ||
ss58: |
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.
I think we should change this to ss58Prefix
for clarity. SS58 is the name of the address format
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.
And specify what happens when an address has no prefix
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.
And specify what happens when an address has no prefix
I think any valid base58 will provide a "ss58Prefix" that we plug into checkAddressChecksum
,
const ss58Length = (decoded[0] & 0b0100_0000) ? 2 : 1;
// ss58Decoded is the prefix
const ss58Decoded = ss58Length === 1
? decoded[0]
: ((decoded[0] & 0b0011_1111) << 2) | (decoded[1] >> 6) | ((decoded[1] & 0b0011_1111) << 8);
so in this case do you think we should just say if the address is not valid a prefix may still be returned.
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.
Or if we receive a non valid address we just return null for the ss58Prefix
sanitizeNumbers(validateService.validateAddress(karuraHex)) | ||
).toStrictEqual(expectedResponse); | ||
}); | ||
|
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.
should have a test for a hex value with no prefix and a ss58 value with no prefix to show it works and what the expected prefix is (null
?)
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.
Is an ss58 address with no prefix just a base58 address?
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.
I think
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.
Yea so to build on that too, every base58 address will always have a prefix as well
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.
Just add a couple of the mentioned tests, maybe consider my recommendations for what we consider valid and excluding network id from response, and then I think its good to go
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: David <dvdplm@gmail.com>
This endpoint will validate the address for the given chain.
Response
/accounts/:address/validate
TODO