-
Notifications
You must be signed in to change notification settings - Fork 217
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
Provide a way to validate addresses via the API. #2180
Comments
2138: Save intermediate state when restoring the Byron chain in the stake pools worker r=hasufell a=hasufell This completely skips byron era for mainnet when syncing stake pools. I extracted the first shelley block by looking at a fully synced stake pool DB and selecting the lowest `block_height` from the `pool_production` table. For non-mainnet it will record the last byron block of a chunk from the node into the `byron_headers` table and read it out during `readPoolProductionCursor` if there are no stake pools and otherwise ignore it. Remarks: - the "genesis shelley header" is hardcoded, because the node currently does not have an endpoint to get this 2184: Allow address inspection via the API r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #2180 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 2daae7e 📍 **implement new stateless endpoint for inspecting addresses** It takes any arbitrary string as input and tries to deserialize it into some address information if possible, otherwise it fails with a proper error. - 76d13ba 📍 **add unit and integration tests for the new 'inspectAddress' function & endpoint** # Comments <!-- Additional comments or screenshots to attach if any --> ![Screenshot from 2020-09-24 18-52-44](https://user-images.githubusercontent.com/5680256/94175596-2b686480-fe97-11ea-8325-66fa41c5577e.png) <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Julian Ospald <[email protected]> Co-authored-by: KtorZ <[email protected]>
2184: Allow address inspection via the API r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #2180 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 2daae7e 📍 **implement new stateless endpoint for inspecting addresses** It takes any arbitrary string as input and tries to deserialize it into some address information if possible, otherwise it fails with a proper error. - 76d13ba 📍 **add unit and integration tests for the new 'inspectAddress' function & endpoint** # Comments <!-- Additional comments or screenshots to attach if any --> ![Screenshot from 2020-09-24 18-52-44](https://user-images.githubusercontent.com/5680256/94175596-2b686480-fe97-11ea-8325-66fa41c5577e.png) <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
Lgtm. However I wonder if there is a point of showing
|
It'd rather be explicit about that one and show it. It's not that the information is not available (in which case not showing the key would make more sense), it's that, we know that there's no network tag. So that's a bit different and a |
Context
Exchanges prefer validating data before submission (even though the API will validate things upon submission). There's no easy to simply validate arbitrary string an know whether they are valid addresses or not. That feature exists in cardano-address but only available via command-line.
Decision
Make the API able to inspect addresses.
Acceptance Criteria
Development
QA
The
inspect
feature comes fromcardano-addresses
and is well-tested there.Added two straightforward integration tests showing that the API reacts correctly to inputs:
https://github.com/input-output-hk/cardano-wallet/blob/d4d5cf3f1dbf478e49186f9e1742939af528bcaa/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Addresses.hs#L229-L237
Make sure that the generated JSON matches the OpenAPI schema:
https://github.com/input-output-hk/cardano-wallet/blob/d4d5cf3f1dbf478e49186f9e1742939af528bcaa/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs#L1524-L1525
Although, this is a bit of a lie because we don't yet have a proper type to represent the result of an address inspection. What we get from
cardano-addresses
is an opaque JSON value which (from a type perspective) could be anything. So we should ultimately replace this with a proper Haskell data-type so that we can have static type-checking on this:https://github.com/input-output-hk/cardano-wallet/blob/d4d5cf3f1dbf478e49186f9e1742939af528bcaa/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs#L1460-L1467
Ported the test cases from
cardano-addresses
and tested them at the unit-level. Ideally, once we have cardano-addresses to return a proper Haskell data-type, we can make the test a bit more expressive instead of simplyisRight
andisLeft
https://github.com/input-output-hk/cardano-wallet/blob/d4d5cf3f1dbf478e49186f9e1742939af528bcaa/lib/shelley/test/unit/Cardano/Wallet/Shelley/CompatibilitySpec.hs#L232-L292
The text was updated successfully, but these errors were encountered: