Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.spago2nix/
.spago/
output/
demo/dist/
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Cardano serialization library can be used to work with Cardano types on frontend
We can create TX and export them to the form which can then be submitted
over wallet or API to the node.

The main ide of the library is to provide thin layer of FFI bindings to the original CSL library.
It does not try to make any abstractions beyond what is provided with CSL.
The main idea of the library is to provide thin layer of FFI bindings to the original CSL library.
It does not try to make any abstractions beyond what is provided with CSL.
It gives you solid foundation to build your own abstractions.

## How to use the library
Expand Down Expand Up @@ -40,7 +40,7 @@ as external dependency. Provide this library with your JS code package manager
and also compile the purs code with it as external dep.

See the Makefile for example how to do it. We should build with spago
and use esbuild on packaging to js code bundle where we can set up the external
and use esbuild on packaging to js code bundle where we can set up the external
dependency on CSL:

```
Expand Down Expand Up @@ -77,5 +77,3 @@ or dirty. Submit an issue if you have found an effectful function
which is declared like pure and vise versa.

See the `code-gen` directory for the source code of the code parser and generator.


44 changes: 0 additions & 44 deletions app/Main.purs

This file was deleted.

1 change: 1 addition & 0 deletions code-gen/parse-csl/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*~
stack.yaml.lock
output/
dist/
3 changes: 2 additions & 1 deletion code-gen/parse-csl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ build:
stack build

run:
stack run
mkdir -p output
stack run -- output
47 changes: 41 additions & 6 deletions code-gen/parse-csl/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
module Main (main) where

import Csl
import Csl
import System.Directory (createDirectoryIfMissing)
import System.Environment (getArgs)
import System.FilePath (takeDirectory)

main :: IO ()
main = do
exportPursTypes
exportPursClasses
exportPursExportList
exportJsClasses

exportPath <- (<> "/") . head <$> getArgs
jsLibHeader <- readFile "./fixtures/Lib.js"
importsCode <- readFile "./fixtures/imports.purs"
pursInternalLib <- readFile "./fixtures/Internal.purs"
jsInternalLib <- readFile "./fixtures/Internal.js"
funs <- getFuns
classes <- getClasses
print funs
-- print classes
let
nonCommonFuns = filter (not . isCommon) funs
funsJsCode = unlines $ funJs <$> nonCommonFuns
funsPursCode = unlines $ funPurs <$> nonCommonFuns
classesPursCode = unlines $ classPurs <$> classes
classesJsCode = unlines $ classJs <$> classes
exportsPursCode = exportListPurs nonCommonFuns classes
createDirectoryIfMissing True $ takeDirectory $ exportPath <> "/"
createDirectoryIfMissing True $ takeDirectory $ exportPath <> "/Lib/"
writeFile (exportPath <> "Lib.purs") $ unlines
[ pursLibHeader ++ exportsPursCode ++ "\n ) where"
, importsCode
, ""
, "-- functions"
, funsPursCode
, ""
, "-- classes"
, ""
, classesPursCode
]
writeFile (exportPath <> "Lib.js") $ unlines
[ jsLibHeader
, classesJsCode
, funsJsCode
]
writeFile (exportPath <> "Lib/Internal.purs") pursInternalLib
writeFile (exportPath <> "Lib/Internal.js") jsInternalLib

pursLibHeader = "module Cardano.Serialization.Lib\n ( "
Loading