Skip to content

Commit

Permalink
Update to latest pact (v4.11)
Browse files Browse the repository at this point in the history
  • Loading branch information
enobayram committed Apr 26, 2024
1 parent 7bb4a44 commit c5e81b1
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 98 deletions.
48 changes: 21 additions & 27 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ package pact

source-repository-package
type: git
location: https://github.com/mightybyte/HsYAML.git
tag: 2ad3cbd1c84f8ab362cf1f5fd4bb3e869dfcc102
--sha256: 1cmwavqz7vdpjvfybxbjphnw7448xy0353wmy9h29ix24lv8w7rr
location: https://github.com/kadena-io/HsYAML.git
tag: b3c49dbceb39733dfc07c22f2097d3c74fc86e74
--sha256: 1cmwavqz7vdpjvfybxbjphnw7448xy0353wmy9h29ix24lv8w6rr

source-repository-package
type: git
location: https://github.com/mightybyte/HsYAML-aeson.git
tag: 077110e5e52dc91d593c546dd1baaafd3066558d
--sha256: 1r91ldq4sb49wqg1agvbjj21z6nwiyk3yx4r80arz0fhcv083czv
location: https://github.com/kadena-io/HsYAML-aeson.git
tag: 84292468200166b96ff4e8c7324ee01e6ab6d181
--sha256: 1r91ldq4sb49wqg1agvbjj21z6nwiyk3yx4r80arz0fhcv082czv

source-repository-package
type: git
Expand All @@ -26,29 +26,23 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/kadena-io/chainweb-api.git
tag: b3e28d62c622ebda0d84e136ea6c995d5f97e46f
--sha256: 1m9x9n5mwmv97fkv2z3hvlhlj59xm2mpsc816hzriw28pv1jb9zh
tag: 1b2de025cfdc09698bfb1ec3807cd85405d6a339
--sha256: 1m9x9n5mwmv97fkv2z3hvlhlj59xm2mpsc816hzriw28pv1jb8zh

source-repository-package
type: git
location: https://github.com/pcapriotti/optparse-applicative
tag: 9399fd0f745e4d4d71e8bba03d402648b767363c
--sha256: 0gkgccix898mafrs25fajqwxbb7zmg30livrj7b79knd6a5sqj76
location: https://github.com/kadena-io/pact.git
tag: a1c7906efbf32095883e71594a53a21162fbe5a7
--sha256: sha256-Mtgz/ilxa81TDUoBKQv5x3BlOftFjNV1Ak0uYzSguNQ=

source-repository-package
type: git
location: https://github.com/kadena-io/pact.git
tag: 83c5944991d6edcd34d79f9fbf8e537d060689c6
--sha256: 0l59xi2by6l6gi10r8c437m7ics29215zr0zl1syyr3039vgmv0x

allow-newer: hashable:base
allow-newer: chainweb-api:aeson

-- bounds from pact
constraints: aeson <2
constraints: base16-bytestring <1
constraints: base64-bytestring <1.1
constraints: hashable <1.3.1
constraints: prettyprinter <1.6.1
constraints: unordered-containers <0.2.16
constraints: tls <1.7.0
type: git
location: https://github.com/kadena-io/pact-json.git
tag: 1d260bfaa48312b54851057885de4c43c420e35f
--sha256: 0fzq4mzaszj5clvixx9mn1x6r4dcrnwvbl2znd0p5mmy5h2jr0hh

source-repository-package
type: git
location: https://github.com/kadena-io/kadena-ethereum-bridge.git
tag: a32d901e4a79be62af9c27c01152c9a4c3912a62
--sha256: sha256-xdawv/tdjh61MbJKcBqm9Fje36+gVljuZsAxOTX1gP0=
82 changes: 58 additions & 24 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
kdaToolProject =
final.haskell-nix.project' {
src = ./.;
compiler-nix-name = "ghc8107";
compiler-nix-name = "ghc964";
shell.tools = {
cabal = {};
};
Expand Down
3 changes: 2 additions & 1 deletion kda-tool.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
Decimal
, HsYAML
, HsYAML-aeson
, aeson < 2
, aeson
, async
, attoparsec
, base >= 4.13 && < 5
Expand Down Expand Up @@ -80,6 +80,7 @@ library
, network-uri
, optparse-applicative
, pact
, pact-json
, process
, resource-pool
, retry
Expand Down
4 changes: 2 additions & 2 deletions src/AppMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module AppMain where
import Control.Monad.IO.Class
import Data.Aeson
import Data.Default
import Data.String (fromString)
import Katip
import Network.HTTP.Client hiding (withConnection)
import Network.HTTP.Client.TLS
import Options.Applicative
import Options.Applicative.Help.Pretty hiding ((</>))
import System.Directory
import System.FilePath
import System.IO
Expand Down Expand Up @@ -81,7 +81,7 @@ appMain = do
, header "kda - Command line tool for interacting with the Kadena blockchain"
, footerDoc (Just theFooter)
]
theFooter = string $ unlines
theFooter = fromString $ unlines
[ "Run the following command to enable tab completion:"
, ""
, "source <(kda --bash-completion-script `which kda`)"
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/GenTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Network.HTTP.Client.TLS
import Network.HTTP.Types.Status
--import Pact.ApiReq
import qualified Pact.ApiReq as Pact
import qualified Pact.JSON.Encode as J
import Pact.Types.Command
import Pact.Types.SigData
import System.IO
Expand Down Expand Up @@ -100,7 +101,7 @@ genFromContents op tplContents useOldOutput = do
cmds :: [Command Text] <- mapM (fmap snd . lift . Pact.mkApiReqCmd True "") apiReqs
let chooseFormat i =
if useOldOutput
then pure $ encodeText i
then pure $ encodeText $ J.toJsonViaEncode i
else fmap encodeText $ sdToCsd i
let outs :: [Text] = catMaybes $ map (chooseFormat <=< hush . commandToSigData) cmds
let outPat = maybe (defaultOutPat augmentedVars) T.pack $ _genData_outFilePat gd
Expand Down
7 changes: 4 additions & 3 deletions src/Commands/Keygen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ import Pact.Types.Crypto
import Keys
import Types.KeyType
import Utils
import Data.Base16.Types (extractBase16)
------------------------------------------------------------------------------

keygenCommand :: KeyType -> IO ()
keygenCommand kt = do
case kt of
Plain -> do
kp <- genKeyPair defaultScheme
putStrLn $ "public: " ++ T.unpack (encodeBase16 $ getPublic kp)
putStrLn $ "secret: " ++ T.unpack (encodeBase16 $ getPrivate kp)
kp <- genKeyPair
putStrLn $ "public: " ++ T.unpack (extractBase16 $ encodeBase16 $ getPublic kp)
putStrLn $ "secret: " ++ T.unpack (extractBase16 $ encodeBase16 $ getPrivate kp)
HD -> do
let toPhrase = T.unwords . M.elems . mkPhraseMapFromMnemonic
let prettyErr err = "ERROR generating menmonic: " <> tshow err
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Local.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Control.Lens hiding ((.=))
import Control.Monad
import Control.Monad.Trans
import Data.Aeson
import Data.Aeson.Key
import Data.Aeson.Lens
import Data.Bifunctor
import qualified Data.ByteString.Lazy as LB
Expand Down Expand Up @@ -47,7 +48,7 @@ localCommand e (LocalCmdArgs args verifySigs shortOutput) = do
printf "%s: testing %d commands on %d chains\n"
(schemeHostPortToText shp) (length txs) (length groups)
responses <- lift $ mapM (localNodeQuery le verifySigs n) txs
pure $ schemeHostPortToText shp .= map responseToValue responses
pure $ fromText (schemeHostPortToText shp) .= map responseToValue responses
case res of
Left er -> putStrLn er >> exitFailure
Right results -> do
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Poll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Control.Error
import Control.Monad
import Control.Monad.Trans
import Data.Aeson
import Data.Aeson.Key
import Data.Bifunctor
import qualified Data.ByteString.Lazy as LB
import Data.Function
Expand Down Expand Up @@ -46,7 +47,7 @@ pollCommand e args = do
printf "%s: polling %d commands to %d chains\n"
(schemeHostPortToText shp) (length txs) (length groups)
responses <- lift $ mapM (\ts -> pollNode le n (txChain $ NE.head ts) (_transaction_hash <$> ts)) groups
pure $ schemeHostPortToText shp .= map responseToValue responses
pure $ fromText (schemeHostPortToText shp) .= map responseToValue responses
case res of
Left er -> putStrLn er >> exitFailure
Right results -> T.putStrLn $ toS $ encode $ Object $ mconcat results
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Send.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Control.Error
import Control.Monad
import Control.Monad.Trans
import Data.Aeson
import Data.Aeson.Key
import Data.Bifunctor
import qualified Data.ByteString.Lazy as LB
import Data.Function
Expand Down Expand Up @@ -48,7 +49,7 @@ sendCommand e args = do
printf "%s: sending %d commands to %d chains\n"
(schemeHostPortToText shp) (length txs) (length groups)
responses <- lift $ mapM (sendToNode le n) groups
pure $ schemeHostPortToText shp .= map responseToValue responses
pure $ fromText (schemeHostPortToText shp) .= map responseToValue responses
case res of
Left er -> putStrLn er >> exitFailure
Right results -> T.putStrLn $ toS $ encode $ Object $ mconcat results
Loading

0 comments on commit c5e81b1

Please sign in to comment.