Giter VIP home page Giter VIP logo

enjin-java-sdk's Introduction

Blockchain SDK by Enjin for Java

Tests Maven Central

Create blockchain video games and applications using the Java programming language.

Learn more about the Enjin blockchain platform.

Sign up to Enjin Cloud: Goerli (Testnet), Mainnet (Production) or JumpNet.

Resources

Table of Contents

Compatibility

The Enjin Java SDK requires at a minimum Java 8.

Installation

Maven

<dependency>
    <groupId>com.enjin</groupId>
    <artifactId>blockchain-sdk</artifactId>
    <version>2.0.0-beta.4</version>
</dependency>

Gradle

dependencies {
    implementation 'com.enjin:blockchain-sdk:2.0.0-beta.4'
}

Git

For those that do not use Maven or Gradle, the SDK may be built manually and added to your project's classpath.

  1. Clone the Java SDK repository using git.
  2. Build the Java SDK:
    • ./gradlew sdk:build (Linux)
    • ./gradlew.bat sdk:build (Windows)
  3. Navigate to the build/libs folder in the sdk module.
  4. Add the jar ending in -all to your project's classpath.

Quick Start

This example showcases how to quickly create and authenticate a client on the project schema which will then allow us to make further requests to the platform.

import com.enjin.sdk.EnjinHosts;
import com.enjin.sdk.ProjectClient;
import com.enjin.sdk.graphql.GraphQLResponse;
import com.enjin.sdk.models.AccessToken;
import com.enjin.sdk.schemas.project.queries.AuthProject;

public class Main {

    public static void main(String... args) {
        // Builds the project client to run on the Goerli test network.
        // See: https://goerli.cloud.enjin.io to sign up for the test network.
        ProjectClient client = ProjectClient.builder()
                                            .BaseUri(EnjinHosts.GOERLI)
                                            .build();

        // Creates the request to authenticate the client.
        // Replace the appropriate strings with the project's UUID and secret.
        AuthProject req = new AuthProject()
                .uuid("<the-project's-uuid>")
                .secret("<the-project's-secret>");

        // Sends the request to the platform and gets the response.
        GraphQLResponse<AccessToken> res = client.authProject(req).get();

        // Checks if the request was successful.
        if (!res.isSuccess()) {
            System.out.println("AuthProject request failed");
            client.close();
            return;
        }

        // Authenticates the client with the access token in the response.
        client.auth(res.getData().getToken());

        // Checks if the client was authenticated.
        if (client.isAuthenticated()) {
            System.out.println("Client is now authenticated");
        } else {
            System.out.println("Client was not authenticated");
        }

        // Closes client as part of cleanup and free any resources.
        client.close();
    }

}

Contributing

Contributions to the SDK are appreciated!

Issues

You can open issues for bugs and enhancement requests.

Pull Requests

If you make any changes or improvements to the SDK, which you believe are beneficial to others, consider making a pull request to merge your changes to be included in the next release.

Ensure that tests under the sdk module are passing and add any necessary test classes or test cases for your code.

Be sure to include your name in the list of contributors.

Deploying

To deploy to maven central you should set the following in your local.properties.

deployment.username=<username>
deployment.password=<password>

GPG signing is required to publish release builds to Maven Central. You must configure the following in local.properties.

signing.gnupg.keyName=<last 8 characters of key>
signing.gnupg.passphrase=<key passphrase>

Copyright and Licensing

The license summary below may be copied.

Copyright 2021 Enjin Pte. Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

enjin-java-sdk's People

Contributors

bishopjohnson avatar damogallagher avatar tdrewry avatar yukitty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enjin-java-sdk's Issues

Unable to get balance

Trying to make a GetBalances request, the fields have been set properly. This issue refers to using 2.0.0-alpha.2 version. The 2.0.0-alpha.4 master branch currently does not authenticate my project properly, so I can't seem to use that - but that's seperate to what this issue is about.

        GetBalances req = new GetBalances()
                .filter(new BalanceFilter()
                        .projectUuid(<uuid>)
                        .valueIs(Operator.GREATER_THAN)
                        .value(0)
                        .wallet(ethAddress));

To explain the issue a bit more, whenever .projectUuid(String) or .projectUuidIn(String...) are used, the following error gets thrown
When I exclude the projectUuid, the request gets sent fine, but I apparently have 0 balance even though I have 2 of the same type of asset (an NFT minted) in my wallet, and it should be showing a balance here I would assume. All fields parsed in are accurate, so the request as far as I can tell on my end is fine, but the error still occurs.

So there are 2 issues, 1. is the balance projectUuid and projectUuidIn fields not being able to be set, and 2. I am getting 0 balance from any variation of the request I try to make (that is successful), so I can't tell how many of an NFT someone has.

(Note GraphQLError is a custom error - you guys have implemented it though in EnjinCraft, error should explain the issue)

GraphQLError(message=Variable "$filter" got invalid value {"projectUuid":"<uuid>","wallet":"<wallet>","value":0,"value_is":"GREATER_THAN"}; Field "projectUuid" is not defined by type BalanceFilter., code=400, locations=null, details=null)
	at enjin.schemas.BaseSchema$1.onResponse(BaseSchema.java:150) 
	at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161) 
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504) 
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) 
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) 
	at java.lang.Thread.run(Thread.java:831) 

Illegal reflective with JAVA 11

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/C:/Users/admin/.m2/repository/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.