-
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 derivation path to api address #2598
Add derivation path to api address #2598
Conversation
remove stack.yaml.lock
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.
LGTM. Some minor suggestions left.
w <- fixture ctx | ||
r <- request @[ApiAddress n] ctx (Link.listAddresses @'Byron w) Default Empty | ||
verify r [ expectResponseCode HTTP.status200 ] | ||
let n = length $ getFromResponse id r | ||
forM_ [0..n-1] $ \addrIx -> do | ||
expectListField addrIx #state (`shouldBe` ApiT Unused) r | ||
expectListField addrIx #derivationPath (\derPath -> NE.length derPath `shouldBe` derPathSize) r |
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.
👍
toDerivationPath ix = NE.fromList $ map DerivationIndex | ||
[ getIndex purposeBIP44 | ||
, getIndex purposeCIP1852 | ||
, 0 |
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.
Okay-ish because we assume the first account. I'd however rather leave a note as comment explaining this hard-coded value.
constructAddrWithPath path (addr,state) acc = | ||
(addr, state, toDerivationIndexes path):acc | ||
retrieveAddrsWithPaPath = | ||
Map.foldrWithKey constructAddrWithPath [] |
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.
Suggestion to avoid the extra traversal on pending addresses and also, make the function a bit more symmetric to more clearly see how the output is constructed:
instance KnownAddresses (RndState n) where
knownAddresses s = mconcat
[ toListWithPath (\path (addr, state) -> (addr, state, path))
(discoveredAddresses s)
, toListWithPath (\path addr -> (addr, Unused, path))
(pendingAddresses s)
]
where
toListWithPath
:: (NonEmpty DerivationIndex -> v -> result)
-> Map DerivationPath v
-> [result]
toListWithPath mk =
Map.foldrWithKey
(\path v result -> mk (toDerivationIndexes path) v : result)
[]
bors r+ |
Build succeeded: |
Issue Number
adp-766
Overview
Comments