Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Split pure WASI code into wasi-lib
  • Loading branch information
palas committed Nov 3, 2025
commit c111ca2f17195747744ce2f0209e9e67c65fb2fa
6 changes: 3 additions & 3 deletions cardano-wasm/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Main where

import Cardano.Wasm.Internal.Api.Info (apiInfo)
import Cardano.Wasm.Internal.Api.InfoToTypeScript (apiInfoToTypeScriptFile)
import Cardano.Wasm.Internal.Api.TypeScriptDefs (writeTypeScriptToDir)
import Cardano.Wasm.Api.Info (apiInfo)
import Cardano.Wasm.Api.InfoToTypeScript (apiInfoToTypeScriptFile)
import Cardano.Wasm.Api.TypeScriptDefs (writeTypeScriptToDir)

import Options.Applicative

Expand Down
87 changes: 63 additions & 24 deletions cardano-wasm/cardano-wasm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,22 @@ common project-config
-Wredundant-constraints
-Wunused-packages

executable cardano-wasm
library cardano-wasi-lib
import: project-config
main-is: Main.hs
hs-source-dirs:
app
src
src-lib

default-language: Haskell2010
exposed-modules:
Cardano.Wasm.Api.GRPC
Cardano.Wasm.Api.Info
Cardano.Wasm.Api.InfoToTypeScript
Cardano.Wasm.Api.Tx
Cardano.Wasm.Api.TypeScriptDefs
Cardano.Wasm.Api.Wallet
Cardano.Wasm.ExceptionHandling

if arch(wasm32)
ghc-options:
-no-hs-main
-optl-mexec-model=reactor
"-optl-Wl,--strip-all"
other-modules:
Cardano.Wasm.Internal.Api.GRPC
Cardano.Wasm.Internal.Api.Info
Cardano.Wasm.Internal.Api.InfoToTypeScript
Cardano.Wasm.Internal.Api.Random
Cardano.Wasm.Internal.Api.Tx
Cardano.Wasm.Internal.Api.TypeScriptDefs
Cardano.Wasm.Internal.Api.Wallet
Cardano.Wasm.Internal.ExceptionHandling
Cardano.Wasm.Internal.JavaScript.Bridge
Cardano.Wasm.Internal.JavaScript.GRPC
Cardano.Wasm.Internal.JavaScript.GRPCTypes

build-depends:
aeson,
Expand All @@ -66,18 +56,67 @@ executable cardano-wasm
exceptions,
filepath,
microlens,
optparse-applicative,
text,

if arch(wasm32)
build-depends:
base16-bytestring,
ghc-experimental,
utf8-string,
base16-bytestring
else
build-depends:
crypton

executable cardano-wasi
import: project-config
main-is: Main.hs
hs-source-dirs:
app
src-wasi

default-language: Haskell2010

if arch(wasm32)
ghc-options:
-no-hs-main
-optl-mexec-model=reactor
"-optl-Wl,--strip-all"
other-modules:
build-depends:
base,
cardano-wasm:cardano-wasi-lib,
optparse-applicative,

executable cardano-wasm
import: project-config
main-is: Main.hs
hs-source-dirs:
app
src-wasm

default-language: Haskell2010

if arch(wasm32)
ghc-options:
-no-hs-main
-optl-mexec-model=reactor
"-optl-Wl,--strip-all"
other-modules:
Cardano.Wasm.Internal.JavaScript.Bridge
Cardano.Wasm.Internal.JavaScript.GRPC
Cardano.Wasm.Internal.JavaScript.GRPCTypes

build-depends:
base,
cardano-wasm:cardano-wasi-lib,
optparse-applicative,

if arch(wasm32)
build-depends:
aeson,
cardano-api,
ghc-experimental,
text,
utf8-string,

test-suite cardano-wasm-golden
type: exitcode-stdio-1.0
main-is: cardano-wasm-golden.hs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Cardano.Wasm.Internal.Api.GRPC where
module Cardano.Wasm.Api.GRPC where

import Cardano.Wasm.Internal.Api.Tx qualified as Wasm
import Cardano.Wasm.Internal.ExceptionHandling (rightOrError, toMonadFail)
import Cardano.Wasm.Api.Tx qualified as Wasm
import Cardano.Wasm.ExceptionHandling (rightOrError, toMonadFail)

import Data.ByteString.Base16 qualified as Base16
import Data.ByteString.Base64 qualified as Base64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE InstanceSigs #-}

module Cardano.Wasm.Internal.Api.Info
module Cardano.Wasm.Api.Info
( apiInfo
, ApiInfo (..)
, VirtualObjectInfo (..)
Expand All @@ -14,7 +14,7 @@ where

import Cardano.Api (pretty)

import Cardano.Wasm.Internal.Api.Tx (UnsignedTxObject (..), newExperimentalEraTxImpl, newTxImpl)
import Cardano.Wasm.Api.Tx (UnsignedTxObject (..), newExperimentalEraTxImpl, newTxImpl)

import Data.Aeson qualified as Aeson
import Data.Text qualified as Text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Cardano.Wasm.Internal.Api.InfoToTypeScript where
module Cardano.Wasm.Api.InfoToTypeScript where

import Cardano.Wasm.Internal.Api.Info (tsTypeAsString)
import Cardano.Wasm.Internal.Api.Info qualified as Info
import Cardano.Wasm.Internal.Api.TypeScriptDefs qualified as TypeScript
import Cardano.Wasm.Api.Info (tsTypeAsString)
import Cardano.Wasm.Api.Info qualified as Info
import Cardano.Wasm.Api.TypeScriptDefs qualified as TypeScript

import Data.List (nub)
import Data.Map (Map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}

module Cardano.Wasm.Internal.Api.Tx
module Cardano.Wasm.Api.Tx
( UnsignedTxObject (..)
, ProtocolParamsJSON (..)
, newTxImpl
Expand All @@ -32,7 +32,7 @@ import Cardano.Api.Plutus qualified as Shelley
import Cardano.Api.Tx qualified as TxBody

import Cardano.Ledger.Api qualified as Ledger
import Cardano.Wasm.Internal.ExceptionHandling (justOrError, rightOrError, throwError, toMonadFail)
import Cardano.Wasm.ExceptionHandling (justOrError, rightOrError, throwError, toMonadFail)

import Control.Monad.Catch (MonadThrow)
import Data.Aeson (ToJSON (toJSON), (.=))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- data types and servant HTTP APIs respectively. And other libraries
-- that align with our needs, like `language-typescript`, are not
-- actively maintained.
module Cardano.Wasm.Internal.Api.TypeScriptDefs where
module Cardano.Wasm.Api.TypeScriptDefs where

import Data.List.NonEmpty qualified as LNE
import Data.Text.Lazy qualified as TL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}

module Cardano.Wasm.Internal.Api.Wallet
module Cardano.Wasm.Api.Wallet
( WalletObject (..)
, generatePaymentWalletImpl
, restorePaymentWalletFromSigningKeyBech32Impl
Expand Down Expand Up @@ -38,8 +38,8 @@ import Cardano.Api
)

import Cardano.Crypto.Seed (mkSeedFromBytes)
import Cardano.Wasm.ExceptionHandling (rightOrError, toMonadFail)
import Cardano.Wasm.Internal.Api.Random (getRandomBytes)
import Cardano.Wasm.Internal.ExceptionHandling (rightOrError, toMonadFail)

import Data.Aeson ((.=))
import Data.Aeson qualified as Aeson
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE InstanceSigs #-}

module Cardano.Wasm.Internal.ExceptionHandling where
module Cardano.Wasm.ExceptionHandling where

import Control.Exception (Exception, displayException)
import Control.Monad.Catch (MonadThrow (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ module Cardano.Wasm.Internal.JavaScript.Bridge where
import Cardano.Api qualified as Api
import Cardano.Api.Ledger qualified as Ledger

import Cardano.Wasm.Internal.Api.GRPC qualified as Wasm
import Cardano.Wasm.Internal.Api.Info (apiInfo)
import Cardano.Wasm.Internal.Api.Tx qualified as Wasm
import Cardano.Wasm.Internal.Api.Wallet qualified as Wasm
import Cardano.Wasm.Internal.ExceptionHandling (rightOrError)
import Cardano.Wasm.Api.GRPC qualified as Wasm
import Cardano.Wasm.Api.Info (apiInfo)
import Cardano.Wasm.Api.Tx qualified as Wasm
import Cardano.Wasm.Api.Wallet qualified as Wasm
import Cardano.Wasm.ExceptionHandling (rightOrError)
import Cardano.Wasm.Internal.JavaScript.GRPC
( js_getEra
, js_getProtocolParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Cardano.Wasm.Internal.JavaScript.GRPC where
module Cardano.Wasm.Internal.JavaScript.GRPC (js_newWebGrpcClient, js_getEra, js_submitTx, js_getProtocolParams, js_readAllUtxos, js_readUtxosForAddress) where

import GHC.Wasm.Prim
import Cardano.Wasm.Internal.Api.Tx (ProtocolParamsJSON(..))
import Cardano.Wasm.Api.Tx (ProtocolParamsJSON(..))

-- | Create a GRPC-web client for the Cardano API.
foreign import javascript safe "globalThis.createClient($1)"
Expand Down
Loading