fedimint / fedimint-clientd

MIT License
13 stars 14 forks source link

Fedimint Kotlin Wrapper #35

Open ndungudedan opened 4 months ago

ndungudedan commented 4 months ago

This is a new kotlin implementation of a fedimint wrapper. Resolves #33

Kodylow commented 4 months ago

think you didn't commit the code for it, just has a markdown change

ndungudedan commented 4 months ago

@Kodylow This is ready for review. Thanks!

Kodylow commented 4 months ago

Can you add the tests and a test-kotlin command to the justfile.local.just like I have for the other wrappers?

test-ts:
  bun run wrappers/fedimint-ts/tests/test.ts

test-py:
  python3.11 wrappers/fedimint-py/test.py

test-py-async:
  python3.11 wrappers/fedimint-py/test_async.py

test-go:
  cd wrappers/fedimint-go && go run cmd/main.go

Then there's a lot of printlns you should remove before merge

ndungudedan commented 3 months ago

Hey @Kodylow I have updated the just file. The tests are in the Application.kt file which is the entry point for the app.

Kodylow commented 3 months ago
❯ just test-kotlin
cd wrappers/fedimint-kotlin && ./gradlew build && ./gradlew run

ERROR: JAVA_HOME is set to an invalid directory: /Applications/Android Studio.app/Contents/jbr/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

error: Recipe `test-kotlin` failed on line 20 with exit code 1

this fails in the nix environment, you have to add a java installation into the flake.nix and make sure this can run inside it

here's a reference from another java project's flake.nix, looks like it just needs gradle and the jdk in the devShell's packages:

{
  description = "secp2565k1-jdk Schnorr Signature demo using JBang";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    devshell = {
      url = "github:numtide/devshell";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    gitignore = {
      url = "github:hercules-ci/gitignore.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs @ { flake-parts, devshell , gitignore, ... }:
    flake-parts.lib.mkFlake {inherit inputs;} {
      systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

      perSystem = { config, self', inputs', pkgs, system, lib, ... }: let
        inherit (pkgs) stdenv;
      in {
        # define default devshell
        devShells.default = pkgs.mkShell {
          inputsFrom = with pkgs ; [ secp256k1 ];
          packages = with pkgs ; [
                jbang                # For running the JBang script version of Schnorr.Java
                jdk22                # JDK 22 will be in $JAVA_HOME (and in javaToolchains)
                jextract             # jextract (Nix package) contains a jlinked executable and bundles its own JDK 22
                (gradle.override {   # Gradle 8.7 (Nix package) depends-on and directly uses JDK 21 to launch Gradle itself
                    javaToolchains = [ jdk22 ];     # Put JDK 22 in Gradle's javaToolchain configuration
                })
            ];
        };

        # define flake output packages
        packages = let
          # useful for filtering src trees based on gitignore
          inherit (gitignore.lib) gitignoreSource;

          # common properties across the derivations
          version = "0.0.1";
          src = gitignoreSource ./.;
        in {
           # TBD
        };
      };
    };
}
ndungudedan commented 3 months ago

Hey @Kodylow I have updated the nix file and the test now passes.

Fixed the nits too.

Kodylow commented 3 months ago

Hey just tested this, needed some minor flake changes to get the javahome to set for it, see commit.

The logging for this should try to match the other ones where it prints the input/output. currently it just says like "string, string" it needs to print the whole body like it does in the other wrappers.

I intentionally made it fail against a gateway and even though the lightning payments failed it still said all the tests passed.

image image