Skip to content

Commit

Permalink
add validation helpter to Types and export from Chanterlle.Deploy (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Apr 24, 2018
1 parent 70865cb commit 661d957
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Chanterelle/Deploy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Prelude
import Chanterelle.Internal.Deploy (deployContract, readDeployAddress) as Exports
import Chanterelle.Internal.Logging (logDeployError)
import Chanterelle.Internal.Types.Deploy (DeployM, runDeployM)
import Chanterelle.Internal.Types.Deploy ((??)) as Exports
import Chanterelle.Internal.Types (runDeployM) as Exports
import Chanterelle.Internal.Utils (makeDeployConfig)
import Control.Monad.Aff (launchAff, throwError)
Expand Down
4 changes: 2 additions & 2 deletions src/Chanterelle/Internal/Types.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Chanterelle.Internal.Types
module Chanterelle.Internal.Types
( module Compile
, module Deploy
, module Genesis
Expand All @@ -10,4 +10,4 @@ import Chanterelle.Internal.Types.Compile as Compile
import Chanterelle.Internal.Types.Deploy as Deploy
import Chanterelle.Internal.Types.Genesis as Genesis
import Chanterelle.Internal.Types.Project as Project
import Chanterelle.Internal.Logging (logCompileError, logDeployError, logGenesisGenerationError) as Logging
import Chanterelle.Internal.Logging (logCompileError, logDeployError, logGenesisGenerationError) as Logging
12 changes: 11 additions & 1 deletion src/Chanterelle/Internal/Types/Deploy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import Control.Monad.Reader (ReaderT, runReaderT)
import Control.Monad.Reader.Class (class MonadAsk)
import Data.Either (Either)
import Data.Lens ((?~))
import Data.Validation.Semigroup (V)
import Data.Maybe (Maybe(..))
import Data.Validation.Semigroup (V, invalid)
import Network.Ethereum.Web3 (Address, BigNumber, ETH, HexString, TransactionOptions, Web3, _data, _value, fromWei)
import Network.Ethereum.Web3.Api (eth_sendTransaction)
import Network.Ethereum.Web3.Types (NoPay)
import Network.Ethereum.Web3.Types.Provider (Provider)
import Node.FS (FS)
import Node.Path (FilePath)

--------------------------------------------------------------------------------
-- | DeployM Deployment monad
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -98,3 +100,11 @@ type ConfigR args =

-- | Configuration for deployment of a single contract
type ContractConfig args = Record (ConfigR args)

-- | Validation helpers
validateWithError :: forall a. Maybe a -> String -> V (Array String) a
validateWithError mres msg = case mres of
Nothing -> invalid [msg]
Just res -> pure res

infixl 9 validateWithError as ??

0 comments on commit 661d957

Please sign in to comment.