Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KMP support #3

Open
kirillzh opened this issue Jun 25, 2024 · 2 comments
Open

KMP support #3

kirillzh opened this issue Jun 25, 2024 · 2 comments

Comments

@kirillzh
Copy link
Contributor

kirillzh commented Jun 25, 2024

@thunderbiscuit, the library is great! @jmateoac and I are starting to look at Cashu and would love to use the lib for a hackweek app. Is there any interest in migrating the library to KMP?

Going through dependencies, looks like we are halfway there.

Deps that are already KMP:

  • org.jetbrains.kotlinx:kotlinx-serialization-json
  • fr.acinq.bitcoin:bitcoin-kmp
  • fr.acinq.lightning:lightning-kmp
  • io.ktor:ktor-client-core

Deps that will need replacement:

We could migrate in small phases:

  1. Replace JVM-only deps with KMP alternatives
  2. Migrate lib to use KMP Gradle plugin, with JVM target to begin with
  3. Add other targets, Android and Native would be a good start
@thunderbiscuit
Copy link
Owner

Hey that's awesome! I'm happy to migrate the JVM-only dependencies to KMP ones for sure, particularly if you're familiar with them and think they'd be a good replacement (I haven't worked with Kermit for example).

A few more thoughts:

  • I'm super flexible on the architecture and happy to hear other developers thoughts. As this was developed one step at a time as I was reading the spec it's a bit all over the place. It's great if the lib can be looked at from fresh eyes.
  • Just an FYI: you will find that the Cashu spec is moving super fast, and has accelerated over the past 6 months. I haven't touched the library much in that timeframe (the release of BDK 1.0 being my focus at the moment), and so it's now fairly outdated. If you're interested in bringing it up to spec go wild! I can try to review and merge fairly quickly if that's part of your hack week and you want to put time into updating it.

@kirillzh
Copy link
Contributor Author

Branch with progress so far: kirillzh#3

thunderbiscuit pushed a commit that referenced this issue Jun 26, 2024
Use kotlinx.serialization instead of GSON to deserialize Keyset from JSON.

Work towards resolving issue #3.
thunderbiscuit pushed a commit that referenced this issue Jun 26, 2024
slf4j is JVM only and blocks the lib from migrating to KMP.

This change migrates to use [Kermit](https://github.com/touchlab/Kermit), developed by touchlab. Kermit is a very simple logger implementation that supports many KMP targets.

Kermit is also very lightweight and has no additional dependencies:
```kotlin
\--- co.touchlab:kermit:2.0.4
     \--- co.touchlab:kermit-jvm:2.0.4
          +--- co.touchlab:kermit-core:2.0.4
          |    \--- co.touchlab:kermit-core-jvm:2.0.4
          |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
```

With slf4j (before, jvm only):
```
2024-06-25 15:36:41 [Test worker @kotlinx.coroutines.test runner#17] INFO  me.tb.cashuclient.Wallet - Wallet initialized with mint url https://testnut.cashu.space and unit 'sat'.
```

With Kermit (now, kmp):
```
Info: (me.tb.cashuclient.Wallet) Wallet initialized with mint url https://testnut.cashu.space and unit 'sat'.
````

Main difference is that `slf4j` by default prints out timestamp of the log along with a thread name, whereas kermit does not.

If needed, implementing a more custom log formatting is easy by providing a custom [LogWriter](https://kermit.touchlab.co/docs/details/LOG_WRITER/).

Work towards resolving issue #3.
thunderbiscuit pushed a commit that referenced this issue Jun 29, 2024
Expose is a JVM only lib. SqlDelight provides KMP support out of the box.

This migrates the internal db implementation to SqlDelight.

Work towards resolving issue #3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants