Skip to content

Commit

Permalink
applying review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Dec 13, 2024
1 parent be83ff0 commit 8b5d36d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/primitive/lib/Cardano/Wallet/Primitive/Types/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data DRepID =
deriving (Eq, Generic, Show, Ord)
deriving anyclass NFData

-- | Encode 'DRepID' as Bech32 with "drep" hrp.
-- | Encode 'DRepID' as Bech32 with "drep" human readable prefix.
encodeDRepIDBech32 :: DRepID -> Text
encodeDRepIDBech32 drepid =
Bech32.encodeLenient hrp
Expand Down
16 changes: 11 additions & 5 deletions lib/unit/test/unit/Cardano/Wallet/Api/Malformed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ instance Wellformed (PathParam ApiDRepSpecifier) where
wellformed = PathParam <$>
[ "abstain"
, "no_confidence"
, "drep1ytje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcvy952y" --28-byte payload with key hash byte prefix ('22' in hex prefixed)
, "drep1y0je8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcvk492r" --28-byte payload with script hash byte prefix ('23' in hex prefixed)
, payloadKeyHashWith22HexByte
, payloadScriptHashWith23HexByte
]
where
payloadKeyHashWith22HexByte = "drep1ytje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcvy952y"
payloadScriptHashWith23HexByte = "drep1y0je8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcvk492r"

instance Malformed (PathParam ApiDRepSpecifier) where
malformed = first PathParam <$>
Expand All @@ -226,13 +229,16 @@ instance Malformed (PathParam ApiDRepSpecifier) where
, (T.replicate 65 "1", msg1)
, ("something", msg1)
, ("no-confidence", msg1)
, ("drep15k6929drl7xt0spvudgcxndryn4kmlzpk4meed0xhqe25nle07s",msg2) --28-byte payload without byte prefix correct hrp prefix
, ("drep1xhje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axc9fjca3",msg2) --28-byte payload with wrong byte prefix but correct hrp prefix
, ("drepp1ytje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcp60l06",msg1) --28-byte payload with key hash byte prefix but wrong hrp prefix
, (payloadWithoutCorrectBytePrefixCorrectHrp, msg2)
, (payloadWithWrongBytePrefixCorrectHrp, msg2)
, (payloadWithCorrectBytePrefixWrondHrp, msg1)
]
where
msg1 = "Invalid DRep key hash: expecting a Bech32 encoded value with human readable part of 'drep'."
msg2 = "Invalid DRep metadata: expecting a byte '00100010' value for key hash or a byte '0b00100011' value for script hash."
payloadWithoutCorrectBytePrefixCorrectHrp = "drep15k6929drl7xt0spvudgcxndryn4kmlzpk4meed0xhqe25nle07s"
payloadWithWrongBytePrefixCorrectHrp = "drep1xhje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axc9fjca3"
payloadWithCorrectBytePrefixWrondHrp = "drepp1ytje8qacj9dyua6esh86rdjqpdactf8wph05gdd72u46axcp60l06"

instance Wellformed (PathParam (ApiAddress ('Testnet 0))) where
wellformed = [PathParam
Expand Down
7 changes: 3 additions & 4 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,9 @@ x-drepScriptHash: &drepScriptHash
format: bech32
example: drep1wqaz0q0zhtxlgn0ewssevn2mrtm30fgh2g7hr7z9rj5856457mm
description: |
DRep's script hash according to CIP-0129. Note this is identical
to drepKeyHash but for unknown reasons we need to different
schema fragments here.
pattern: "^(drep)1[0-9a-z]*$"
DRep's script hash according to CIP-0129 uses also 'drep' bech32 prefix.
This one is deprecated and should not be used.
pattern: "^(drep_script)1[0-9a-z]*$"

x-walletAccountXPubkey: &walletAccountXPubkey
description: An extended account public key (public key + chain code)
Expand Down

0 comments on commit 8b5d36d

Please sign in to comment.