-
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: Added the network
and accountId
to the response of validate
endpoint
#926
Conversation
For the moonbeam address I will need to look into that, and play with it. Not exactly sure whats happening there. Note: Once were satisfied with the changes to the endpoint we'll need to update the docs. |
For Ethereum style addresses they are not SS58 formatted, they are just 20 raw bytes. It should be a variant of |
Ahh okay cool, I assumed they were leveraging ethereums aaddress format. Thanks for the info. |
As a note as well, when its out of [WIP] to change the squashed commit name (title of the PR) to a conventional commit structure. |
- If the address given is not a hex value then it returns the hex value of the related registry type - If the address given is a hex value then it returns the same as the 'accountId' - The tests were updated based on this logic
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.
- Comments on the added
accountId
in the response of the endpoint and - Thoughts on the implementation related to the conversion of the
accountId
/accounts/:address/validate
endpoint
/accounts/:address/validate
endpoint/accounts/:address/validate
endpoint
- Replaced `filter` with a `for..of` loop when retrieving the `network`. - Replaced `new TypeRegistry` with `this.api.registry` when retrieving the `accountID`. - Renamed `networkName` to `network` so it is aligned with the key naming in the SS58 registry. - Updated the JSDocs of the function `validateAddress`. - Added the default mock api into the service in the tests. - Updated the docs.
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.
Few nits to resolve, but overall great job! 👍
You will also need to run yarn build:docs
to regenerate the docs.
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.
For the Should give the correct response for a {network} hex value
tests, I don't understand how the sanitization should know to which network the hex belongs? Wouldn't you have to pass it a network name or prefix as an arg? The hex value should generally speaking be the same across most networks (exceptions being those that don't use AccountId32: [u8; 32]
as their AccountId
type).
@joepetrowski Our process for converting a hex address goes as such:
Hope that clears that up :) |
- Changes in code based on Tarik's feedback. - Run `yarn build:docs`.
- Fix for accountId when the input from user is an address in hex (from u8 array) format. - Corrected the output of the corresponding tests also.
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.
Great updates, and changes. Good catch @joepetrowski .
Just seems like there is a conflict with the docs.
git pull origin master
yarn && yarn build:docs
That should sort out the merge conflict
/accounts/:address/validate
endpointnetwork
and accountId
to the response of /accounts/:address/validate
endpoint
network
and accountId
to the response of /accounts/:address/validate
endpointnetwork
and accountId
to the response of validate
endpoint
Thank you @TarikGul and @joepetrowski for all the comments and reviews on this PR. Very much appreciated!!! |
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.
Couple of wee comments but LGTM!
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.
Awesome LGTM 👍 Thank you!
…sidecar into domi-changes-to-address-validate
Description
Added the
network
andaccountId
in the response from the/accounts/:address/validate
endpoint when the given addressisValid
. If it is an invalid address (isValid: false
) thennetwork
andaccountId
havenull
values.Functionality of the endpoint
Below you can find a description of how this endpoint behaves and why.
This endpoint is meant to receive only valid
addresses
and these can be in the following formats :null
which meansisValid
field will befalse
and all other fields will benull
.Comparing with
subkey
functionalityIf we compare this endpoint's functionality with how subkey works then we have the following behaviours :
subkey
andvalidate
endpoint will return a result :AccountId
returned will be the same as the one returned from thevalidate
endpointsubkey
:AccountId
validate
endpoint :AccountId
Important Note
If we give as input the address (stripped from prefix+checksum hence
AccountId
) :validate
endpoint : it will returnnull
AccountId
and this endpoint is meant to validate only addresses. For account ids we intend to create another endpoint.