File tree Expand file tree Collapse file tree 5 files changed +8
-9
lines changed
Expand file tree Collapse file tree 5 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,9 @@ module Commands.WalletSign
77
88------------------------------------------------------------------------------
99import Control.Error
10- import Control.Lens
1110import Control.Monad
1211import Control.Monad.Trans
1312import Control.Monad.Except
14- import Data.Aeson.Lens
1513import Data.List
1614import qualified Data.Set as S
1715import Data.String.Conv
@@ -33,7 +31,6 @@ import Text.Printf
3331import Types.Encoding
3432import Types.Env
3533import Utils
36- import Pact.JSON.Legacy.Value (LegacyValue (_getLegacyValue ))
3734------------------------------------------------------------------------------
3835
3936walletSignCommand :: Env -> WalletSignArgs -> IO ()
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import Data.Aeson
1010import Data.Proxy
1111import Data.Text (Text )
1212import GHC.Generics
13- import Pact.Core.Command.SigData
1413import Pact.Core.Command.Types
1514import Pact.Core.Command.Client
1615
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ compactEncoding = defaultOptions
206206 }
207207 where
208208 -- As long as names are not empty or just underscores this head should be fine:
209- shortener = head . reverse . filter (/= " " ) . L. splitOn " _"
209+ shortener = fromMaybe " " . listToMaybe . reverse . filter (/= " " ) . L. splitOn " _"
210210
211211------------------- ORPHANS -------------------
212212-- We're defining these orphans here because Pact moved away from `ToJSON` to
Original file line number Diff line number Diff line change @@ -97,9 +97,11 @@ fromKeyIndex = fromIntegral . naturalToInteger . unKeyIndex
9797phraseToSeed :: MnemonicPhrase -> Crypto. Seed
9898phraseToSeed (MnemonicPhrase lst) =
9999 let phraseMap = wordsToPhraseMap lst
100- Right phrase = Crypto. mnemonicPhrase @ 12 $ textTo <$> Map. elems phraseMap
101- Right sentence = Crypto. mnemonicPhraseToMnemonicSentence Crypto. english phrase
100+ phrase = catchMnemonicError $ Crypto. mnemonicPhrase @ 12 $ textTo <$> Map. elems phraseMap
101+ sentence = catchMnemonicError $ Crypto. mnemonicPhraseToMnemonicSentence Crypto. english phrase
102102 in sentenceToSeed sentence
103+ where
104+ catchMnemonicError = either (error " Invalid Mnemonic" ) id
103105
104106phraseToEitherSeed :: MnemonicPhrase -> Either String Crypto. Seed
105107phraseToEitherSeed (MnemonicPhrase lst) = do
@@ -224,7 +226,9 @@ verify :: PublicKey -> Signature -> ByteString -> Bool
224226verify (PublicKey pub) (Signature sig) msg = Crypto. verify xpub msg sig
225227 where
226228 dummyChainCode = BS. replicate 32 minBound
227- Right xpub = Crypto. xpub $ pub <> dummyChainCode
229+ xpub = case Crypto. xpub $ pub <> dummyChainCode of
230+ Right x -> x
231+ Left _ -> error " Invalid Public key"
228232
229233baToText :: ByteArrayAccess b => b -> Text
230234baToText = T. decodeUtf8 . BA. pack . BA. unpack
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import qualified Data.Text.Encoding as T
1717import qualified Data.Text.IO as T
1818import Kadena.SigningTypes ()
1919import qualified Pact.JSON.Encode as J
20- import Pact.JSON.Legacy.Value
2120import Pact.Core.Command.RPC
2221import Pact.Core.Command.Client
2322import Pact.Core.Command.Types
You can’t perform that action at this time.
0 commit comments