Skip to content

Commit c111ca2

Browse files
committed
Split pure WASI code into wasi-lib
1 parent 4d8ccf8 commit c111ca2

File tree

13 files changed

+87
-48
lines changed

13 files changed

+87
-48
lines changed

cardano-wasm/app/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Main where
22

3-
import Cardano.Wasm.Internal.Api.Info (apiInfo)
4-
import Cardano.Wasm.Internal.Api.InfoToTypeScript (apiInfoToTypeScriptFile)
5-
import Cardano.Wasm.Internal.Api.TypeScriptDefs (writeTypeScriptToDir)
3+
import Cardano.Wasm.Api.Info (apiInfo)
4+
import Cardano.Wasm.Api.InfoToTypeScript (apiInfoToTypeScriptFile)
5+
import Cardano.Wasm.Api.TypeScriptDefs (writeTypeScriptToDir)
66

77
import Options.Applicative
88

cardano-wasm/cardano-wasm.cabal

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,22 @@ common project-config
2424
-Wredundant-constraints
2525
-Wunused-packages
2626

27-
executable cardano-wasm
27+
library cardano-wasi-lib
2828
import: project-config
29-
main-is: Main.hs
3029
hs-source-dirs:
31-
app
32-
src
30+
src-lib
3331

34-
default-language: Haskell2010
32+
exposed-modules:
33+
Cardano.Wasm.Api.GRPC
34+
Cardano.Wasm.Api.Info
35+
Cardano.Wasm.Api.InfoToTypeScript
36+
Cardano.Wasm.Api.Tx
37+
Cardano.Wasm.Api.TypeScriptDefs
38+
Cardano.Wasm.Api.Wallet
39+
Cardano.Wasm.ExceptionHandling
3540

36-
if arch(wasm32)
37-
ghc-options:
38-
-no-hs-main
39-
-optl-mexec-model=reactor
40-
"-optl-Wl,--strip-all"
4141
other-modules:
42-
Cardano.Wasm.Internal.Api.GRPC
43-
Cardano.Wasm.Internal.Api.Info
44-
Cardano.Wasm.Internal.Api.InfoToTypeScript
4542
Cardano.Wasm.Internal.Api.Random
46-
Cardano.Wasm.Internal.Api.Tx
47-
Cardano.Wasm.Internal.Api.TypeScriptDefs
48-
Cardano.Wasm.Internal.Api.Wallet
49-
Cardano.Wasm.Internal.ExceptionHandling
50-
Cardano.Wasm.Internal.JavaScript.Bridge
51-
Cardano.Wasm.Internal.JavaScript.GRPC
52-
Cardano.Wasm.Internal.JavaScript.GRPCTypes
5343

5444
build-depends:
5545
aeson,
@@ -66,18 +56,67 @@ executable cardano-wasm
6656
exceptions,
6757
filepath,
6858
microlens,
69-
optparse-applicative,
7059
text,
7160

7261
if arch(wasm32)
7362
build-depends:
74-
base16-bytestring,
75-
ghc-experimental,
76-
utf8-string,
63+
base16-bytestring
7764
else
7865
build-depends:
7966
crypton
8067

68+
executable cardano-wasi
69+
import: project-config
70+
main-is: Main.hs
71+
hs-source-dirs:
72+
app
73+
src-wasi
74+
75+
default-language: Haskell2010
76+
77+
if arch(wasm32)
78+
ghc-options:
79+
-no-hs-main
80+
-optl-mexec-model=reactor
81+
"-optl-Wl,--strip-all"
82+
other-modules:
83+
build-depends:
84+
base,
85+
cardano-wasm:cardano-wasi-lib,
86+
optparse-applicative,
87+
88+
executable cardano-wasm
89+
import: project-config
90+
main-is: Main.hs
91+
hs-source-dirs:
92+
app
93+
src-wasm
94+
95+
default-language: Haskell2010
96+
97+
if arch(wasm32)
98+
ghc-options:
99+
-no-hs-main
100+
-optl-mexec-model=reactor
101+
"-optl-Wl,--strip-all"
102+
other-modules:
103+
Cardano.Wasm.Internal.JavaScript.Bridge
104+
Cardano.Wasm.Internal.JavaScript.GRPC
105+
Cardano.Wasm.Internal.JavaScript.GRPCTypes
106+
107+
build-depends:
108+
base,
109+
cardano-wasm:cardano-wasi-lib,
110+
optparse-applicative,
111+
112+
if arch(wasm32)
113+
build-depends:
114+
aeson,
115+
cardano-api,
116+
ghc-experimental,
117+
text,
118+
utf8-string,
119+
81120
test-suite cardano-wasm-golden
82121
type: exitcode-stdio-1.0
83122
main-is: cardano-wasm-golden.hs

cardano-wasm/src/Cardano/Wasm/Internal/Api/GRPC.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/GRPC.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module Cardano.Wasm.Internal.Api.GRPC where
1+
module Cardano.Wasm.Api.GRPC where
22

3-
import Cardano.Wasm.Internal.Api.Tx qualified as Wasm
4-
import Cardano.Wasm.Internal.ExceptionHandling (rightOrError, toMonadFail)
3+
import Cardano.Wasm.Api.Tx qualified as Wasm
4+
import Cardano.Wasm.ExceptionHandling (rightOrError, toMonadFail)
55

66
import Data.ByteString.Base16 qualified as Base16
77
import Data.ByteString.Base64 qualified as Base64

cardano-wasm/src/Cardano/Wasm/Internal/Api/Info.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/Info.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE InstanceSigs #-}
22

3-
module Cardano.Wasm.Internal.Api.Info
3+
module Cardano.Wasm.Api.Info
44
( apiInfo
55
, ApiInfo (..)
66
, VirtualObjectInfo (..)
@@ -14,7 +14,7 @@ where
1414

1515
import Cardano.Api (pretty)
1616

17-
import Cardano.Wasm.Internal.Api.Tx (UnsignedTxObject (..), newExperimentalEraTxImpl, newTxImpl)
17+
import Cardano.Wasm.Api.Tx (UnsignedTxObject (..), newExperimentalEraTxImpl, newTxImpl)
1818

1919
import Data.Aeson qualified as Aeson
2020
import Data.Text qualified as Text

cardano-wasm/src/Cardano/Wasm/Internal/Api/InfoToTypeScript.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/InfoToTypeScript.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
module Cardano.Wasm.Internal.Api.InfoToTypeScript where
1+
module Cardano.Wasm.Api.InfoToTypeScript where
22

3-
import Cardano.Wasm.Internal.Api.Info (tsTypeAsString)
4-
import Cardano.Wasm.Internal.Api.Info qualified as Info
5-
import Cardano.Wasm.Internal.Api.TypeScriptDefs qualified as TypeScript
3+
import Cardano.Wasm.Api.Info (tsTypeAsString)
4+
import Cardano.Wasm.Api.Info qualified as Info
5+
import Cardano.Wasm.Api.TypeScriptDefs qualified as TypeScript
66

77
import Data.List (nub)
88
import Data.Map (Map)

cardano-wasm/src/Cardano/Wasm/Internal/Api/Tx.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/Tx.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{-# LANGUAGE StandaloneDeriving #-}
88
{-# LANGUAGE TypeFamilies #-}
99

10-
module Cardano.Wasm.Internal.Api.Tx
10+
module Cardano.Wasm.Api.Tx
1111
( UnsignedTxObject (..)
1212
, ProtocolParamsJSON (..)
1313
, newTxImpl
@@ -32,7 +32,7 @@ import Cardano.Api.Plutus qualified as Shelley
3232
import Cardano.Api.Tx qualified as TxBody
3333

3434
import Cardano.Ledger.Api qualified as Ledger
35-
import Cardano.Wasm.Internal.ExceptionHandling (justOrError, rightOrError, throwError, toMonadFail)
35+
import Cardano.Wasm.ExceptionHandling (justOrError, rightOrError, throwError, toMonadFail)
3636

3737
import Control.Monad.Catch (MonadThrow)
3838
import Data.Aeson (ToJSON (toJSON), (.=))

cardano-wasm/src/Cardano/Wasm/Internal/Api/TypeScriptDefs.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/TypeScriptDefs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
-- data types and servant HTTP APIs respectively. And other libraries
1212
-- that align with our needs, like `language-typescript`, are not
1313
-- actively maintained.
14-
module Cardano.Wasm.Internal.Api.TypeScriptDefs where
14+
module Cardano.Wasm.Api.TypeScriptDefs where
1515

1616
import Data.List.NonEmpty qualified as LNE
1717
import Data.Text.Lazy qualified as TL

cardano-wasm/src/Cardano/Wasm/Internal/Api/Wallet.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/Api/Wallet.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{-# LANGUAGE ScopedTypeVariables #-}
44
{-# LANGUAGE StandaloneDeriving #-}
55

6-
module Cardano.Wasm.Internal.Api.Wallet
6+
module Cardano.Wasm.Api.Wallet
77
( WalletObject (..)
88
, generatePaymentWalletImpl
99
, restorePaymentWalletFromSigningKeyBech32Impl
@@ -38,8 +38,8 @@ import Cardano.Api
3838
)
3939

4040
import Cardano.Crypto.Seed (mkSeedFromBytes)
41+
import Cardano.Wasm.ExceptionHandling (rightOrError, toMonadFail)
4142
import Cardano.Wasm.Internal.Api.Random (getRandomBytes)
42-
import Cardano.Wasm.Internal.ExceptionHandling (rightOrError, toMonadFail)
4343

4444
import Data.Aeson ((.=))
4545
import Data.Aeson qualified as Aeson

cardano-wasm/src/Cardano/Wasm/Internal/ExceptionHandling.hs renamed to cardano-wasm/src-lib/Cardano/Wasm/ExceptionHandling.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE ExistentialQuantification #-}
22
{-# LANGUAGE InstanceSigs #-}
33

4-
module Cardano.Wasm.Internal.ExceptionHandling where
4+
module Cardano.Wasm.ExceptionHandling where
55

66
import Control.Exception (Exception, displayException)
77
import Control.Monad.Catch (MonadThrow (..))

0 commit comments

Comments
 (0)