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

Fedimint Kotlin Wrapper #35

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

ndungudedan
Copy link

@ndungudedan ndungudedan commented Apr 27, 2024

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

@ndungudedan ndungudedan changed the title Add Readme Fedimint Kotlin Wrapper Apr 27, 2024
@Kodylow
Copy link
Member

Kodylow commented May 4, 2024

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

@ndungudedan ndungudedan marked this pull request as ready for review May 9, 2024 18:53
@ndungudedan
Copy link
Author

@Kodylow This is ready for review.
Thanks!

@Kodylow
Copy link
Member

Kodylow commented May 9, 2024

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
Copy link
Author

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
Copy link
Member

Kodylow commented May 16, 2024

❯ 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
        };
      };
    };
}

Copy link
Member

@Kodylow Kodylow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits, will have a bigger review after you add the java stuff to the nix flake so I can test it

@ndungudedan
Copy link
Author

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

Fixed the nits too.

@Kodylow
Copy link
Member

Kodylow commented May 25, 2024

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

@ndungudedan ndungudedan requested a review from Kodylow May 31, 2024 23:18
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

Successfully merging this pull request may close these issues.

Make a fedimint-kotlin wrapper
2 participants