-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# LANGUAGE QuasiQuotes #-} | ||
|
||
module Cardano.Wallet.UI.Lib.Address | ||
where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.Deposit.Read | ||
( Address | ||
) | ||
import Cardano.Wallet.Read.Address | ||
( toShortByteString | ||
) | ||
import Codec.Binary.Bech32 | ||
( dataPartFromBytes | ||
) | ||
import Data.Text | ||
( Text | ||
) | ||
|
||
import qualified Codec.Binary.Bech32 as Bech32 | ||
import qualified Codec.Binary.Bech32.TH as Bech32 | ||
import qualified Data.ByteString.Short as B8 | ||
|
||
encodeMainnetAddress :: Address -> Text | ||
encodeMainnetAddress addr = bech32 | ||
where | ||
bytes = B8.fromShort $ toShortByteString addr | ||
bech32 = Bech32.encodeLenient hrp (dataPartFromBytes bytes) | ||
hrp = [Bech32.humanReadablePart|addr|] |