Skip to content
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

CAD-2337 API extensions for address and credentials #2127

Merged
merged 2 commits into from
Nov 26, 2020
Merged

Conversation

deepfire
Copy link
Contributor

  • toAddressAny :: Address addr -> AddressAny
  • fromShelleyPaymentCredential :: Shelley.PaymentCredential StandardShelley -> PaymentCredential
  • fromShelleyStakeReference :: Shelley.StakeReference StandardShelley -> StakeAddressReference
  • export fromShelleyStakeCredential

Comment on lines 68 to 71
fromShelleyPaymentCredential,
fromShelleyStakeCredential,
StakeAddressReference(..),
fromShelleyStakeReference,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w.r.t. these exports you've added, if you need them, could we export them from Cardano.Api.Shelley instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these should only be exported from Cardano.Api.Shelley and not from Cardano.Api

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fine to add these definitions and export them from appropriate modules.

Comments below. Please follow the local style.

Comment on lines 393 to 398
toAddressAny = \case
a@ShelleyAddress{} -> AddressShelley a
a@ByronAddress{} -> AddressByron a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local style would be

toAddressAny a@ShelleyAddress{} = AddressShelley a
toAddressAny a@ByronAddress{}   = AddressByron a

no need for case or lambda case at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be exported, both from this module and from Cardano.API and Cardano.Api.Typed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1,5 +1,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the local style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -32,6 +33,7 @@ module Cardano.Api.Address (
shelleyAddressInEra,
anyAddressInShelleyBasedEra,
anyAddressInEra,
toAddressAny,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this in the previous patch, where it gets defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -51,6 +53,10 @@ module Cardano.Api.Address (
fromShelleyStakeAddr,
fromShelleyStakeCredential,

fromShelleyPaymentCredential,
fromShelleyStakeCredential,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? This is already exported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you, missed it.

Comment on lines 562 to 573
fromShelleyPaymentCredential ::
Shelley.PaymentCredential StandardShelley -> PaymentCredential
fromShelleyPaymentCredential = \case
Shelley.KeyHashObj kh -> PaymentCredentialByKey (PaymentKeyHash kh)
Shelley.ScriptHashObj sh -> PaymentCredentialByScript (ScriptHash sh)

fromShelleyStakeReference ::
Shelley.StakeReference StandardShelley -> StakeAddressReference
fromShelleyStakeReference = \case
Shelley.StakeRefBase stakecred -> StakeAddressByValue (fromShelleyStakeCredential stakecred)
Shelley.StakeRefPtr ptr -> StakeAddressByPointer ptr
Shelley.StakeRefNull -> NoStakeAddress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we follow the local style (e.g. the functions immediately above) and use

foo (Shelley.Blah ..) = Blah ...

rather than lambda case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 68 to 71
fromShelleyPaymentCredential,
fromShelleyStakeCredential,
StakeAddressReference(..),
fromShelleyStakeReference,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these should only be exported from Cardano.Api.Shelley and not from Cardano.Api

@deepfire deepfire force-pushed the cad-2337-api branch 3 times, most recently from b7e7704 to 8661c8c Compare November 25, 2020 20:58
@deepfire
Copy link
Contributor Author

All suggestions addressed.

Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deepfire
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Nov 26, 2020
2125: Update cardano-node-cli-reference.md r=kevinhammond a=kevinhammond

Added additional documentation for query ledger/protocol-state

2127: CAD-2337 API extensions for address and credentials r=deepfire a=deepfire

- `toAddressAny :: Address addr -> AddressAny`
- `fromShelleyPaymentCredential ::  Shelley.PaymentCredential StandardShelley -> PaymentCredential`
- `fromShelleyStakeReference ::  Shelley.StakeReference StandardShelley -> StakeAddressReference`
- export `fromShelleyStakeCredential`

2130: Testnet with more configurable parameters r=newhoggy a=newhoggy



Co-authored-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
Co-authored-by: John Ky <john.ky@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 26, 2020

This PR was included in a batch that timed out, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 26, 2020

@iohk-bors iohk-bors bot merged commit 63ba413 into master Nov 26, 2020
@iohk-bors iohk-bors bot deleted the cad-2337-api branch November 26, 2020 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants