-
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
Add GET /wallets/{walletId}/stake-keys endpoint #2666
Conversation
518d6d8
to
22bfb2a
Compare
@@ -1426,6 +1431,42 @@ newtype ApiMnemonicT (sizes :: [Nat]) = | |||
ApiMnemonicT { getApiMnemonicT :: SomeMnemonic } | |||
deriving (Generic, Show, Eq) | |||
|
|||
|
|||
data ApiOurStakeKey n = ApiOurStakeKey | |||
{ _index :: ApiT DerivationIndex |
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.
Seems DerivationIndex
is encoded as a JSON string, which seems unnecessary. Going with Natural
then, I guess. Could maybe have some ApiSoftIndex
newtype if desired…
lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs
Outdated
Show resolved
Hide resolved
data ApiStakeKeys n = ApiStakeKeys | ||
{ _ours :: ![ApiOurStakeKey n] | ||
, _foreign :: ![ApiForeignStakeKey n] | ||
, _null :: !ApiNullStakeKey |
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.
null
being a special keyword in JavaScript and JSON, I'd highly recommend to NOT using null
as a field name! Perhaps none
could work a bit better or inactive
(though stake can be associated with a stake key and still be inactive.. so perhaps it is a poor choice).
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.
Ok, fair! Probably none
then
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.
Another thing: I think currently the balance of say script and pointer addresses get included into this none
, which could be really confusing if it happens...
none
should probably only correspond to enterprise addresses.
Then we could have another bucket for "other/unknown", or leave it out for now.
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.
Then we could have another bucket for "other/unknown", or leave it out for now.
For now I just mentioned that none
could include more things than enterprise addresses in the swagger API. There is no clear use-case besides testing/debugging, so I think this is fine as long as it is mentioned.
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.
Looks pretty sensible 👍
-> ctx | ||
-> ApiT WalletId | ||
-> Handler (ApiStakeKeys n) | ||
listStakeKeys stakeRef ctx (ApiT wid) = do |
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.
This is quite a big function. Is it at all possible to break it up a little? Then it might be possible to unit test some of it.
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 thought occurred to me, but wasn't sure if worth it; thanks for suggesting, will give it a shot
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 split off a helper that could run in Identity
. But to actually unit-test it, I can't get a way with only defining Api types like I do here. Will do in a separate PR.
Edit: although those attempts didn't go great, so maybe not.
dea7b6e
to
58075a5
Compare
bors r+ |
2666: Add GET /wallets/{walletId}/stake-keys endpoint r=Anviking a=Anviking # Issue Number <!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. --> ADP-721 # Overview - [x] Add `GET /wallets/{wid}/stake-keys` endpoint - [x] Provide information about stake-key 0 - [x] Show the distribution of ada across different stake keys # Comments <img width="1238" alt="Skärmavbild 2021-05-25 kl 13 01 30" src="https://user-images.githubusercontent.com/304423/119487609-e6643d00-bd59-11eb-835d-49e42057fac2.png"> <!-- Additional comments or screenshots to attach if any --> <!-- 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) ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket ✓ Acknowledge any changes required to the Wiki ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. --> Co-authored-by: Johannes Lund <[email protected]>
Build failed: |
It provides information on: - The wallet's stake keys (now 1, later many) - Stake keys that appear in the UTxO, but are not ours - Breakdown of how much ada is associated with which key, and how much ada is not associated with any key at all. The goal is to provide enough information for the multi-delegation Proof-of-Concept. Example JSON: ``` { "foreign": [], "none": { "stake": { "quantity": 0, "unit": "lovelace" } }, "ours": [ { "delegation": { "active": { "status": "not_delegating" }, "next": [] }, "index": 0, "key": "stake_test1ur7tw2l4t0d4dcdg46rnlw58axcqa0rlju0tcak0f50usnq9xtnxm", "reward_balance": { "quantity": 0, "unit": "lovelace" }, "stake": { "quantity": 1000000000, "unit": "lovelace" } } ] } ``` fixup: use Natural instead of DerivationIndex fixup: make fields strict fixup: inline delegationBalance fixup: docs and api docs Rename null -> none, tweak api docs fixup to fixup: rename to none factor out a more testable listStakeKeys helper Minor polish fixup golden
c1083e3
to
de38a17
Compare
bors r+ |
2666: Add GET /wallets/{walletId}/stake-keys endpoint r=Anviking a=Anviking # Issue Number <!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. --> ADP-721 # Overview - [x] Add `GET /wallets/{wid}/stake-keys` endpoint - [x] Provide information about stake-key 0 - [x] Show the distribution of ada across different stake keys # Comments <img width="1238" alt="Skärmavbild 2021-05-25 kl 13 01 30" src="https://user-images.githubusercontent.com/304423/119487609-e6643d00-bd59-11eb-835d-49e42057fac2.png"> <!-- Additional comments or screenshots to attach if any --> <!-- 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) ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket ✓ Acknowledge any changes required to the Wiki ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. --> Co-authored-by: Johannes Lund <[email protected]>
Build failed: |
bors r+ |
Build succeeded: |
2666: Add GET /wallets/{walletId}/stake-keys endpoint r=Anviking a=Anviking # Issue Number <!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. --> ADP-721 # Overview - [x] Add `GET /wallets/{wid}/stake-keys` endpoint - [x] Provide information about stake-key 0 - [x] Show the distribution of ada across different stake keys # Comments <img width="1238" alt="Skärmavbild 2021-05-25 kl 13 01 30" src="https://user-images.githubusercontent.com/304423/119487609-e6643d00-bd59-11eb-835d-49e42057fac2.png"> <!-- Additional comments or screenshots to attach if any --> <!-- 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) ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket ✓ Acknowledge any changes required to the Wiki ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. --> Co-authored-by: Johannes Lund <[email protected]> d659651
Issue Number
ADP-721
Overview
GET /wallets/{wid}/stake-keys
endpointComments