From b760e46b8a2c167b5393ad2cbc0c83c99dec8e73 Mon Sep 17 00:00:00 2001 From: Aleksandr Penskoi Date: Thu, 23 Jun 2022 04:58:27 +0300 Subject: [PATCH 1/3] Add fd to nix develop (require for seabug build) --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index 6a68d70..7244214 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,9 @@ pkgs.purescriptProject { inherit pkgs src; projectName = "seabug-contracts"; + shell = { + packages = [ pkgs.fd ]; + }; }; in { From 027d871f40f037c7715bdd3df181219c307e81ab Mon Sep 17 00:00:00 2001 From: Aleksandr Penskoi Date: Tue, 28 Jun 2022 00:59:21 +0300 Subject: [PATCH 2/3] Fix warning --- src/Seabug/Seabug.purs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Seabug/Seabug.purs b/src/Seabug/Seabug.purs index 2a16e10..f10ce17 100644 --- a/src/Seabug/Seabug.purs +++ b/src/Seabug/Seabug.purs @@ -3,17 +3,17 @@ module Seabug , getWalletBalance ) where -import Prelude +import Prelude (bind, ($)) import Control.Promise (Promise, fromAff) import Data.Maybe (Maybe) import Effect (Effect) import QueryM (callNami) -import Seabug.CallContract +import Seabug.CallContract (callMarketPlaceBuy, callMarketPlaceBuyTest, callMarketPlaceListNft) import Serialization.Types (Value) import Wallet (Wallet(..), mkNamiWalletAff) getWalletBalance :: Effect (Promise (Maybe Value)) getWalletBalance = fromAff $ do (Nami nami) <- mkNamiWalletAff - callNami nami _.getBalance \ No newline at end of file + callNami nami _.getBalance From f6b18315502dec153870c4f95a6b3b07b41e81bd Mon Sep 17 00:00:00 2001 From: Aleksandr Penskoi Date: Tue, 28 Jun 2022 01:00:11 +0300 Subject: [PATCH 3/3] Fix logLevel configuration. --- spago.dhall | 1 + src/Seabug/CallContract.purs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/spago.dhall b/spago.dhall index af4dd4e..93f9b10 100644 --- a/spago.dhall +++ b/spago.dhall @@ -11,6 +11,7 @@ You can edit this file as you like. , "argonaut" , "argonaut-codecs" , "arrays" + , "monad-logger" , "bifunctors" , "bigints" , "cardano-transaction-lib" diff --git a/src/Seabug/CallContract.purs b/src/Seabug/CallContract.purs index 1e0f4e8..89d1bd4 100644 --- a/src/Seabug/CallContract.purs +++ b/src/Seabug/CallContract.purs @@ -11,7 +11,6 @@ import Contract.Address (Slot(Slot)) import Contract.Monad ( ConfigParams(ConfigParams) , ContractConfig - , LogLevel , mkContractConfig , runContract , runContract_ @@ -45,6 +44,7 @@ import Data.UInt as UInt import Effect (Effect) import Effect.Aff (error) import Effect.Class (liftEffect) +import Data.Log.Level (LogLevel(..)) import Effect.Exception (Error) import Metadata.Seabug (SeabugMetadata(SeabugMetadata)) import Metadata.Seabug.Share (unShare) @@ -102,7 +102,7 @@ type ContractConfiguration = , datumCacheSecureConn :: Boolean , networkId :: Int , projectId :: String - , logLevel :: LogLevel + , logLevel :: String -- Trace | Debug | Info | Warn | Error } type BuyNftArgs = @@ -159,6 +159,8 @@ buildContractConfig cfg = do $ UInt.fromInt' cfg.datumCachePort networkId <- liftM (error "Invalid network id") $ intToNetworkId cfg.networkId + logLevel <- liftM (error "Invalid log level") + $ stringToLogLevel cfg.logLevel wallet <- Just <$> mkNamiWalletAff mkContractConfig $ ConfigParams @@ -178,11 +180,19 @@ buildContractConfig cfg = do , secure: cfg.serverSecureConn } , networkId: networkId - , logLevel: cfg.logLevel + , logLevel: logLevel , extraConfig: { projectId: cfg.projectId } , wallet } +stringToLogLevel :: String -> Maybe LogLevel +stringToLogLevel "Trace" = Just Trace +stringToLogLevel "Debug" = Just Debug +stringToLogLevel "Info" = Just Info +stringToLogLevel "Warn" = Just Warn +stringToLogLevel "Error" = Just Error +stringToLogLevel _ = Nothing + buildNftList :: NetworkId -> ListNftResult -> ListNftResultOut buildNftList network