Skip to content

Commit e4ab611

Browse files
authored
Merge pull request #15 from zkFold/72-haskell-server
feat(#16): Haskell based server & off-chain to interact with smart-wallet
2 parents 1adf41d + 564a478 commit e4ab611

File tree

29 files changed

+2121
-0
lines changed

29 files changed

+2121
-0
lines changed

atlas/cabal.project

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
repository cardano-haskell-packages
2+
url: https://chap.intersectmbo.org/
3+
secure: True
4+
root-keys:
5+
3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
6+
443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1
7+
a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82
8+
bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413
9+
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
10+
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee
11+
12+
packages:
13+
zkfold-smart-wallet-api
14+
zkfold-smart-wallet-server-lib
15+
16+
tests: true
17+
18+
source-repository-package
19+
type: git
20+
location: https://github.com/geniusyield/atlas
21+
tag: cc48d63d33ca876a54c827edc34a0737c934fda2
22+
23+
-------- Begin contents from @atlas@'s @cabal.project@ file. --------
24+
25+
-- repeating the index-state for hackage to work around hackage.nix parsing limitation
26+
index-state: 2025-01-01T23:24:19Z
27+
28+
-- NOTE: Do not bump chap index beyond that used by target cardano-node version.
29+
index-state:
30+
, hackage.haskell.org 2025-01-01T23:24:19Z
31+
, cardano-haskell-packages 2025-02-11T21:18:23Z
32+
33+
-- TODO: Default value should be @direct@ in upcoming 3.10 version of cabal, omit this line then.
34+
test-show-details: direct
35+
36+
package cardano-crypto-praos
37+
flags: -external-libsodium-vrf
38+
39+
source-repository-package
40+
type: git
41+
location: https://github.com/maestro-org/haskell-sdk
42+
tag: 3e39a6d485d7c6f98222b1ca58aed2fb45e5ff27
43+
--sha256: sha256-plfrSgirKf7WGESYvEBqBkR1s673Qd0ZhGs0KzGfOig=
44+
45+
-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/mlabs-haskell/clb/pull/72)
46+
source-repository-package
47+
type: git
48+
location: https://github.com/sourabhxyz/clb
49+
tag: 1b084647dc9118520c1cc615cf2fa7c3dd8a394e
50+
--sha256: sha256-QliJng5PmJIRJd/l644T0zxBBOKhuMkIgeu1B5ymfVU=
51+
subdir:
52+
clb
53+
emulator
54+
55+
-- TODO: Temporary, remove once we are on 10.9 or above. Fix relates to issue: https://github.com/IntersectMBO/cardano-api/issues/714.
56+
source-repository-package
57+
type: git
58+
location: https://github.com/sourabhxyz/cardano-api
59+
tag: 14674d6b099e8fc36e5044e206bfc32164f75cee
60+
--sha256: sha256-Qr4rv9bLz+wJdICYjxDVnnzgsVwx+wsU+tSFwDYr/kE=
61+
subdir:
62+
cardano-api
63+
cardano-api-gen
64+
65+
-- Using latest version which is not on CHaP.
66+
source-repository-package
67+
type: git
68+
location: https://github.com/IntersectMBO/cardano-node
69+
tag: 36161c9e00850616bd64b8db0c06bd77eb1ec951
70+
--sha256: sha256-eaaj6kQb/TMGmxAhw355x4kBJfznKAem+rhC9SkmePs=
71+
subdir:
72+
cardano-node
73+
cardano-testnet
74+
trace-dispatcher
75+
trace-forward
76+
77+
-- Temporary until latest version is available on Hackage (or CHaP for that matter). Track https://github.com/IntersectMBO/cardano-addresses/issues/294.
78+
source-repository-package
79+
type: git
80+
location: https://github.com/IntersectMBO/cardano-addresses
81+
tag: d611632fc3d616d5b4038a70f864bf2613c125d0
82+
--sha256: sha256-vQ2XB95kw05IZuRkyK4cPQtaKZ1bZAoLtN9GrOOwQvM=
83+
84+
------ Following is mostly from @cardano-node@'s @cabal.project@ file. -------
85+
86+
allow-newer:
87+
katip:Win32
88+
, ekg-wai:time
89+
90+
-- Using RDRAND instead of /dev/urandom as an entropy source for key
91+
-- generation is dubious. Set the flag so we use /dev/urandom by default.
92+
package cryptonite
93+
flags: -support_rdrand
94+
95+
package cardano-node
96+
flags: -systemd
97+
98+
package bitvec
99+
flags: -simd
100+
101+
-------- End contents from @cardano-node@'s @cabal.project@ file. --------
102+
-------- Begin contents from @atlas@'s @cabal.project@ file. --------

atlas/readme.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# zkFold Smart Wallet API
2+
3+
This repository houses off-chain code and server endpoints to interact with zk based smart wallet by [zkFold](https://zkfold.io/).
4+
5+
## Table of Contents
6+
7+
- [zkFold Smart Wallet API](#zkfold-smart-wallet-api)
8+
- [Table of Contents](#table-of-contents)
9+
- [Structure of repository](#structure-of-repository)
10+
- [zkFold Smart Wallet API Server](#zkfold-smart-wallet-api-server)
11+
- [Building locally from source using the Haskell Toolchain](#building-locally-from-source-using-the-haskell-toolchain)
12+
- [OpenApi documentation](#openapi-documentation)
13+
14+
## Structure of repository
15+
16+
- [`zkfold-smart-wallet-api`](./zkfold-smart-wallet-api/) provides off-chain code to interact with the wallet.
17+
- [`zkfold-smart-wallet-server-lib`](./zkfold-smart-wallet-server-lib/) serves endpoints using our off-chain code to easily interact with the wallet.
18+
19+
## zkFold Smart Wallet API Server
20+
21+
### Building locally from source using the Haskell Toolchain
22+
23+
1. Make sure your environment is configured properly, consult ["How to build?"](https://atlas-app.io/getting-started/how-to-build) section of Atlas documentation for it.
24+
2. Prepare a configuration, which can be stored either in file or in `SERVER_CONFIG` environment variable. Structure of it is as follows:
25+
26+
```yaml
27+
# Blockchain provider used by Atlas, our off-chain transaction building tool.
28+
# Head over to https://atlas-app.io/getting-started/endpoints#providing-data-provider section to know how to configure `coreProvider` and what all options are available for it.
29+
coreProvider:
30+
maestroToken: YOUR_MAESTRO_TOKEN
31+
turboSubmit: false
32+
# Network id, only `mainnet` and `preprod` are supported for at the moment.
33+
networkId: mainnet
34+
# Logging configuration. It's an array to cater for potentially multiple scribes.
35+
# See it's description mentioned at https://atlas-app.io/getting-started/endpoints#providing-data-provider for more information.
36+
logging:
37+
- type:
38+
tag: stderr
39+
# Possible values of `severity` are `Debug`, `Info`, `Warning` and `Error`.
40+
severity: Debug
41+
# Possible values of `verbosity` are `V0`, `V1`, `V2`, `V3` and `V4`. Consult https://hackage.haskell.org/package/katip-0.8.8.0/docs/Katip.html#t:Verbosity for more information about it.
42+
verbosity: V2
43+
# Port to serve endpoints at.
44+
port: 8082
45+
# API key to protect server endpoints with. It's value must be provided under `api-key` header of request.
46+
serverApiKey: YOUR_SECRET_KEY
47+
# UTxO to be used as collateral.
48+
collateral: tx-id#tx-ix
49+
# Wallet that provides UTxO to be used as collateral.
50+
collateralWallet:
51+
tag: mnemonicWallet
52+
contents:
53+
mnemonic:
54+
- health
55+
- unable
56+
- dog
57+
- lend
58+
- artefact
59+
- arctic
60+
- dinner
61+
- energy
62+
- silent
63+
- wealth
64+
- shock
65+
- safe
66+
- glad
67+
- mail
68+
- gas
69+
- flag
70+
- beauty
71+
- penalty
72+
- mixed
73+
- garbage
74+
- erupt
75+
- wonder
76+
- magnet
77+
- around
78+
# Account index.
79+
accIx: 0
80+
# Payment address index.
81+
addrIx: 0
82+
```
83+
3. Run the server with command `cabal run zkfold-smart-wallet-server -- serve -c my-config.yaml`.
84+
85+
Call: `cabal run zkfold-smart-wallet-server -- -h` for help. 😉
86+
87+
4. Test if server is running successfully by calling, say, `/settings` endpoint. Example `curl` request: `curl -H 'api-key: YOUR_SECRET_KEY' -X GET http://localhost:8082/v0/settings | jq`, assuming port was specified as `8082`. On success, it should return something akin to:
88+
89+
```json
90+
{
91+
"network":"mainnet",
92+
"version":"0.1.0",
93+
"collateral":"tx-id#tx-ix",
94+
"collateral_address":"addr1qx...w60mw"
95+
}
96+
```
97+
98+
### OpenApi documentation
99+
100+
Endpoints made available by server are specified [here](./web/openapi/api.yaml).

0 commit comments

Comments
 (0)