diff --git a/changelog.d/20231027_140636_hrajchert_fix_addr_show.md b/changelog.d/20231027_140636_hrajchert_fix_addr_show.md new file mode 100644 index 000000000..05d7b7723 --- /dev/null +++ b/changelog.d/20231027_140636_hrajchert_fix_addr_show.md @@ -0,0 +1,40 @@ + + + +### Added + +- Change the way addresses are summarised to make testnet ones easy to tell apart by showing both prefix and suffix. + + + + + diff --git a/marlowe-playground-client/src/Page/Simulation/View.purs b/marlowe-playground-client/src/Page/Simulation/View.purs index 4a1890fa4..8c78d9aef 100644 --- a/marlowe-playground-client/src/Page/Simulation/View.purs +++ b/marlowe-playground-client/src/Page/Simulation/View.purs @@ -687,16 +687,12 @@ participant metadata state party actionInputs = [ h6_ [ em [ classNames [ "mr-1" ] ] [ text "Participant " - , strong_ [ text partyName ] + , strong_ [ renderPrettyParty metadata party ] ] , partyHint ] ] - partyName = case party of - (Address name) -> name - (Role name) -> name - choiceRef :: String -> ChoiceId -> String choiceRef prefix (ChoiceId choiceName choiceOwner) = intercalate "-" [ prefix, choiceName, choiceOwnerStr ] diff --git a/marlowe-playground-client/src/Pretty.purs b/marlowe-playground-client/src/Pretty.purs index 6a0693074..34ba6ac69 100644 --- a/marlowe-playground-client/src/Pretty.purs +++ b/marlowe-playground-client/src/Pretty.purs @@ -14,13 +14,18 @@ import Data.Numbers.Natural as N import Data.String as String import Halogen.HTML (HTML, abbr, text) import Halogen.HTML.Properties (title) -import Language.Marlowe.Core.V1.Semantics.Types (Party(..), Payee(..)) +import Language.Marlowe.Core.V1.Semantics.Types (Address, Party(..), Payee(..)) import Language.Marlowe.Extended.V1.Metadata.Types (MetaData, NumberFormat(..)) +prettyAddress :: Address -> String +prettyAddress addr = String.take 9 addr <> "..." <> takeEnd 5 addr + where + takeEnd n str = String.drop (String.length str - n) str + renderPrettyParty :: forall p i. MetaData -> Party -> HTML p i renderPrettyParty _ (Address addr) = if String.length addr > 10 then abbr [ title $ "address " <> addr ] - [ text $ String.take 10 addr ] + [ text $ prettyAddress addr ] else text addr renderPrettyParty metadata (Role role) = abbr