File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
cardano-wasm/src-lib/Cardano/Wasm/Api/Certificate Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -121,18 +121,23 @@ instance FromJSON StakeCertificateObject where
121121 , delegateStake
122122 }
123123
124- -- | Creates an empty stake certificate object for the given stake key hash.
124+ -- | Creates an empty stake certificate object for the given stake key base16 hash.
125125-- For the certificate to be valid must be either a registration, an unregistration or
126126-- a delegation certificate. But it can be both registration and delegation.
127- createStakeKeyCertificateImpl :: Hash StakeKey -> StakeCertificateObject
128- createStakeKeyCertificateImpl skHash =
129- StakeCertificateObject
130- { era = ConwayEra
131- , stakeCredential = skHash
132- , deposit = Nothing
133- , action = DelegateOnly
134- , delegateStake = Nothing
135- }
127+ createStakeKeyCertificateImpl :: MonadThrow m => String -> m StakeCertificateObject
128+ createStakeKeyCertificateImpl skHashStr = do
129+ skHash <- readHash skHashStr
130+ return $
131+ StakeCertificateObject
132+ { era = ConwayEra
133+ , stakeCredential = skHash
134+ , deposit = Nothing
135+ , action = DelegateOnly
136+ , delegateStake = Nothing
137+ }
138+ where
139+ readHash :: MonadThrow m => String -> m (Hash StakeKey )
140+ readHash = rightOrError . Api. deserialiseFromRawBytesHex . Text. encodeUtf8 . Text. pack
136141
137142-- | Marks the certificate as a stake registration certificate.
138143asStakeRegistrationImpl :: StakeCertificateObject -> StakeCertificateObject
You can’t perform that action at this time.
0 commit comments