cleveland-0.1.2: Testing framework for Morley.
Safe HaskellNone
LanguageHaskell2010

Test.Cleveland.Lorentz.Import

Description

Functions to import contracts to be used in tests.

Synopsis

Read, parse, typecheck contracts

importContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd) Source #

Import contract from a given FilePath.

In this and similar functions, parameter and storage types must exactly match the ones in the contract, while for views this is not necessary. Only make sure that all views beyond vd type are present in the contract; () always works as views descriptor of the contract.

importContractExt :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd) Source #

Deprecated: Morley extensions are deprecated

Import contract from a given FilePath, with deprecated Morley extensions.

In this and similar functions, parameter and storage types must exactly match the ones in the contract, while for views this is not necessary. Only make sure that all views beyond vd type are present in the contract; () always works as views descriptor of the contract.

embedContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> TExpQ (Contract cp st vd) Source #

Import a contract at compile time assuming its expected type is known.

Use it like:

myContract :: Contract Parameter Storage
myContract = $$(embedContract "my_contract.tz")

or

let myContract = $$(embedContract @Parameter @Storage "my_contract.tz")

See also the note in Test.Cleveland.Lorentz.Import

embedContractM :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => IO FilePath -> TExpQ (Contract cp st vd) Source #

Version of embedContract that accepts a filepath constructor in IO.

Useful when the path should depend on environmental variables or other user input.

See also the note in Test.Cleveland.Lorentz.Import

Read, parse, typecheck values

importValue :: forall a. IsoValue a => FilePath -> IO a Source #

Import a value from a given FilePath

embedValue :: forall a. IsoValue a => FilePath -> TExpQ a Source #

Import a value from a given FilePath at compile time and embed it as a value using Template Haskell, f. ex.

let someAddress = $$(embedValue @Address "/path/to/addressFile.tz")

See also the note in Test.Cleveland.Lorentz.Import

embedValueM :: forall a. IsoValue a => IO FilePath -> TExpQ a Source #

A variant of embedValue that accepts FilePath in IO.

Can be useful when FilePath depends on the environment.

See also the note in Test.Cleveland.Lorentz.Import

Notes

On FilePath argument with embedContract, embedValue and variants

The FilePath argument is specified relative to the project root (if using cabal-install or stack, the directory containing the Cabal file and/or package.yaml).

As an additional caveat, any files embedded this way are essentially compile-time dependencies. However, build systems can't track these automatically. In general, it's advisable to add the files used with embedContract, embedValue and variants to the extra-source-files section of the Cabal file or package.yaml, if possible.