-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
207 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{-| | ||
Module : GeniusYield.Types.Certificate | ||
Copyright : (c) 2023 GYELD GMBH | ||
License : Apache 2.0 | ||
Maintainer : support@geniusyield.co | ||
Stability : develop | ||
-} | ||
module GeniusYield.Types.Certificate ( | ||
GYCertificate (..), | ||
certificateToApi, | ||
certificateFromApiMaybe, | ||
certificateToStakeCredential, | ||
) where | ||
|
||
import qualified Cardano.Api as Api | ||
import GeniusYield.Types.Credential (GYStakeCredential, | ||
stakeCredentialFromApi, | ||
stakeCredentialToApi) | ||
import GeniusYield.Types.StakePoolId | ||
|
||
data GYCertificate = | ||
GYStakeAddressRegistrationCertificate !GYStakeCredential | ||
| GYStakeAddressDeregistrationCertificate !GYStakeCredential | ||
| GYStakeAddressPoolDelegationCertificate !GYStakeCredential !GYStakePoolId | ||
deriving stock (Eq, Show) | ||
|
||
certificateToApi :: GYCertificate -> Api.Certificate | ||
certificateToApi = \case | ||
GYStakeAddressRegistrationCertificate sc -> Api.StakeAddressRegistrationCertificate (f sc) | ||
GYStakeAddressDeregistrationCertificate sc -> Api.StakeAddressDeregistrationCertificate (f sc) | ||
GYStakeAddressPoolDelegationCertificate sc spId -> Api.StakeAddressPoolDelegationCertificate (f sc) (g spId) | ||
where | ||
f = stakeCredentialToApi | ||
g = stakePoolIdToApi | ||
|
||
certificateFromApiMaybe :: Api.Certificate -> Maybe GYCertificate | ||
certificateFromApiMaybe = \case | ||
Api.StakeAddressRegistrationCertificate sc -> Just $ GYStakeAddressRegistrationCertificate (f sc) | ||
Api.StakeAddressDeregistrationCertificate sc -> Just $ GYStakeAddressDeregistrationCertificate (f sc) | ||
Api.StakeAddressPoolDelegationCertificate sc spId -> Just $ GYStakeAddressPoolDelegationCertificate (f sc) (g spId) | ||
_ -> Nothing | ||
where | ||
f = stakeCredentialFromApi | ||
g = stakePoolIdFromApi | ||
|
||
certificateToStakeCredential :: GYCertificate -> GYStakeCredential | ||
certificateToStakeCredential = \case | ||
GYStakeAddressRegistrationCertificate sc -> sc | ||
GYStakeAddressDeregistrationCertificate sc -> sc | ||
GYStakeAddressPoolDelegationCertificate sc _ -> sc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-| | ||
Module : GeniusYield.Types.TxCert | ||
Copyright : (c) 2023 GYELD GMBH | ||
License : Apache 2.0 | ||
Maintainer : support@geniusyield.co | ||
Stability : develop | ||
-} | ||
module GeniusYield.Types.TxCert ( | ||
GYTxCert, | ||
GYTxCertWitness (..), | ||
txCertToApi, | ||
mkStakeAddressRegistrationCertificate, | ||
mkStakeAddressDeregistrationCertificate, | ||
mkStakeAddressPoolDelegationCertificate, | ||
) where | ||
|
||
import GeniusYield.Types.Certificate | ||
import GeniusYield.Types.Credential (GYStakeCredential) | ||
import GeniusYield.Types.StakePoolId | ||
import GeniusYield.Types.TxCert.Internal | ||
|
||
mkStakeAddressRegistrationCertificate :: GYStakeCredential -> GYTxCert v | ||
mkStakeAddressRegistrationCertificate sc = GYTxCert (GYStakeAddressRegistrationCertificate sc) Nothing | ||
|
||
mkStakeAddressDeregistrationCertificate :: GYStakeCredential -> GYTxCertWitness v -> GYTxCert v | ||
mkStakeAddressDeregistrationCertificate sc wit = GYTxCert (GYStakeAddressDeregistrationCertificate sc) (Just wit) | ||
|
||
mkStakeAddressPoolDelegationCertificate :: GYStakeCredential -> GYStakePoolId -> GYTxCertWitness v -> GYTxCert v | ||
mkStakeAddressPoolDelegationCertificate sc spId wit = GYTxCert (GYStakeAddressPoolDelegationCertificate sc spId) (Just wit) |
Oops, something went wrong.