Giter VIP home page Giter VIP logo

polkaj's Introduction

PolkaJ - Polkadot Java Client

Unit Tests Coverage License Gitter

Java client library to use and access API of Polkadot based networks.

Warning
UNDER DEVELOPMENT
  • Latest Stable Version: 0.3.0

  • Latest Snapshot Version: 0.5.0-SNAPSHOT

Modules

  • io.emeraldpay.polkaj:polkaj-scale:0.3.0 - SCALE codec implementation

  • io.emeraldpay.polkaj:polkaj-scale-types:0.3.0 - SCALE mapping for standard Polkadot types

  • io.emeraldpay.polkaj:polkaj-schnorrkel:0.3.0 - Schnorrkel for Java

  • io.emeraldpay.polkaj:polkaj-ss58:0.3.0 - SS58 codec to encode/decode addresses and pubkeys

  • io.emeraldpay.polkaj:polkaj-common-types:0.3.0 - common types (Address, DotAmount, Hash256, etc)

  • io.emeraldpay.polkaj:polkaj-json-types:0.3.0 - JSON RPC mapping to Java classes

  • io.emeraldpay.polkaj:polkaj-api-base:0.3.0 - RPC base classes

  • io.emeraldpay.polkaj:polkaj-api-http:0.3.0 - JSON RPC HTTP client

  • io.emeraldpay.polkaj:polkaj-api-ws:0.3.0 - JSON RPC WebSocket client

  • io.emeraldpay.polkaj:polkaj-tx:0.3.0 - Storage access and Extrinsics

Usage

To use development SNAPSHOT versions you need to install the library into the local Maven repository.

Install into local Maven
gradle install
Using with Gradle
repositories {
   // polkaj public repo
   maven { url  "https://dl.bintray.com/emerald/polkaj" }
   // required for com.github.multiformats:java-multibase library
   maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'io.emeraldpay.polkaj:polkaj-api-http:0.3.0'
}

Documentation

See Documentation in ./docs directory, and a demonstration in ./examples.

Example

Show current finalized block
PolkadotHttpApi client = PolkadotApi.newBuilder()
    .rpcCallAdapter(JavaHttpAdapter.newBuilder().build())
    .build();
Future<Hash256> hashFuture = client.execute(
        PolkadotApi.commands().getFinalizedHead()
);

Hash256 hash = hashFuture.get();
System.out.println("Current head: " + hash);

Future<BlockResponseJson> blockFuture = client.execute(
        PolkadotApi.commands().getBlock(hash)
);

BlockResponseJson block = blockFuture.get();
System.out.println("Current height: " + block.getBlock().getHeader().getNumber());
System.out.println("State hash: " + block.getBlock().getHeader().getStateRoot());


client.close();

License

The core project code is released under Apache 2.0 license.

Examples and docs are published under CC0 license + additionally Apache 2.0 for code parts in the examples.

polkaj's People

Contributors

alexey-n-chernyshov avatar crommvardek avatar gianinbasler avatar mmagician avatar nschwermann avatar pablojorge avatar paulvi avatar splix 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

polkaj's Issues

I am trying to run provided sample but its not running and giving dependency error

I am trying to run provided sample but its not running and giving dependency error , following are the error i am getting although all the required dependency are already added in build gradle but still getting following issue. kindly let me know whats the issue..
i am trying this
Run
cd encoding
./gradlew run

Could not resolve all files for configuration ':compileClasspath'.

Could not resolve io.emeraldpay.polkaj:polkaj-scale:0.5.0-SNAPSHOT.
Required by:
project :
> Could not resolve io.emeraldpay.polkaj:polkaj-scale:0.5.0-SNAPSHOT.
> Unable to load Maven meta-data from https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-scale/0.5.0-

SNAPSHOT/maven-metadata.xml.
> Could not get resource 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-scale/0.5.0-SNAPSHOT/maven-metadata.xml'.
> Could not GET 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-scale/0.5.0-SNAPSHOT/maven-metadata.xml'. Received status code 403 from server: Forbidden

Could not resolve io.emeraldpay.polkaj:polkaj-common-types:0.5.0-SNAPSHOT.
Required by:
project :
> Could not resolve io.emeraldpay.polkaj:polkaj-common-types:0.5.0-SNAPSHOT.
> Unable to load Maven meta-data from https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-common-types/0.5.0-SNAPSHOT/maven-metadata.xml.
> Could not get resource 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-common-types/0.5.0-SNAPSHOT/maven-metadata.xml'.
> Could not GET 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-common-types/0.5.0-SNAPSHOT/maven-metadata.xml'. Received status code 403 from server: Forbidden
Could not resolve io.emeraldpay.polkaj:polkaj-ss58:0.5.0-SNAPSHOT.
Required by:
project :
> Could not resolve io.emeraldpay.polkaj:polkaj-ss58:0.5.0-SNAPSHOT.
> Unable to load Maven meta-data from https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-ss58/0.5.0-SNAPSHOT/maven-metadata.xml.
> Could not get resource 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-ss58/0.5.0-SNAPSHOT/maven-metadata.xml'.
> Could not GET 'https://dl.bintray.com/emerald/polkaj/io/emeraldpay/polkaj/polkaj-ss58/0.5.0-SNAPSHOT/maven-metadata.xml'. Received status code 403 from server: Forbidden

Addede dependency
dependencies {
implementation "io.emeraldpay.polkaj:polkaj-scale:$polkajVersion"
implementation "io.emeraldpay.polkaj:polkaj-common-types:$polkajVersion"
implementation "io.emeraldpay.polkaj:polkaj-ss58:$polkajVersion"
implementation 'commons-codec:commons-codec:1.14'
}

Documentation on compatible versions

Hi,

I am running the latest (0.4.0) against the latest polkadot 0.8.27, I am seeing various errors, such as

io.emeraldpay.polkaj.api.RpcException: RPC Exception 1002: Verification Error: Runtime error: Execution failed: Wasmi(Trap(Trap { kind: Unreachable })) (RuntimeApi("Execution failed: Wasmi(Trap(Trap { kind: Unreachable }))"))

Is there a version I should use to ensure compatibility? Any recommendations?

BTW I am using --chain=westend

Thanks,
Niall

About pallet-contracts wrapper

Hi guys, we are https://github.com/patractlabs team, and we are focus on pallet-contracts part, trying to provide all develop tools for contracts developers.
Now we are planning to establish a project aim to compile wasm contracts and generate java code like what web3j do for Solidity. This java sdk would be an important part in our tools list, we would integrate different language sdk in to RedSpot(which like truffle in Ethereum) to be convenient for contracts developers.
So that this contracts java sdk depends on polkaj which provide codec system and rpc system.
Thus I come for ask whether we may have some cooperatation?
For example, our team just focus on pallet-contracts part, using polkaj as our previous dependent library, and we develop the part which need to use ink! to compile contracts and generate contracts java code, then use polkaj to connect to node. In this way, you guys do not need to waste time to develop the contracts part for polkaj which would cast a lot of time. you could just improve the core features for polkaj. On the other hand, we also could do some pr for polkaj to fix some bugs or other thing.

Or you guys just want to develop all parts by youself, include contracts part and other things?

Thank you very much!

Metadata exception

when getting metadata, it will appear "Unsupport metadata version : 12" , so I comment this check at MatadataReader.java 22~24 , then it will appear exception below :

Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Not a boolean value: 96
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
at TransferNoWs.main(TransferNoWs.java:58)
Caused by: java.lang.IllegalStateException: Not a boolean value: 96
at io.emeraldpay.polkaj.scale.reader.BoolReader.read(BoolReader.java:16)
at io.emeraldpay.polkaj.scale.ScaleCodecReader.readBoolean(ScaleCodecReader.java:108)
at io.emeraldpay.polkaj.scale.ScaleCodecReader.readOptional(ScaleCodecReader.java:122)
at io.emeraldpay.polkaj.scaletypes.MetadataReader$ModulesReader.read(MetadataReader.java:53)
at io.emeraldpay.polkaj.scaletypes.MetadataReader$ModulesReader.read(MetadataReader.java:41)
at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
at io.emeraldpay.polkaj.scale.reader.ListReader.read(ListReader.java:22)
at io.emeraldpay.polkaj.scaletypes.MetadataReader.read(MetadataReader.java:25)
at io.emeraldpay.polkaj.scaletypes.MetadataReader.read(MetadataReader.java:11)
at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
at io.emeraldpay.polkaj.scale.ScaleExtract.lambda$fromBytesData$1(ScaleExtract.java:42)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)

Transfer.java "java.lang.IllegalStateException: Unsupported metadata version: 13" for polkadot 0.9.7

I am running examples/balance/src/main/java/Transfer.java
against locally running Polkadot node 0.9.7

% ./polkadot --dev -dPolkadotData
2021-09-08 16:11:00 Running in --dev mode, RPC CORS has been disabled.    
2021-09-08 16:11:00 Parity Polkadot    
2021-09-08 16:11:00 ✌️  version 0.9.7-5d35bac74-x86_64-macos  

And get only this output in

16:10:02: Executing task ':balance:Transfer.main()'...

> Task :balance:compileJava UP-TO-DATE
> Task :balance:compileGroovy NO-SOURCE
> Task :balance:processResources NO-SOURCE
> Task :balance:classes UP-TO-DATE

> Task :balance:Transfer.main() FAILED
Connect to: ws://localhost:9944
Use standard accounts for Alice and Bob, expected to run against development network
Connected: true
Current height: 5873
Balance update. User: HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F, new balance: 10,000.00 KSM

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
2 actionable tasks: 1 executed, 1 up-to-date
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on io.emeraldpay.polkaj.schnorrkel.SchnorrkelNative (file:/Users/paul/.m2/repository/io/emeraldpay/polkaj/polkaj-schnorrkel/0.4.0-SNAPSHOT/polkaj-schnorrkel-0.4.0-SNAPSHOT.jar) to class java.lang.ClassLoader
WARNING: Please consider reporting this to the maintainers of io.emeraldpay.polkaj.schnorrkel.SchnorrkelNative
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
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Unsupported metadata version: 13
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
	at Transfer.main(Transfer.java:108)
Caused by: java.lang.IllegalStateException: Unsupported metadata version: 13
	at io.emeraldpay.polkaj.scaletypes.MetadataReader.read(MetadataReader.java:23)
	at io.emeraldpay.polkaj.scaletypes.MetadataReader.read(MetadataReader.java:11)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
	at io.emeraldpay.polkaj.scale.ScaleExtract.lambda$fromBytesData$1(ScaleExtract.java:42)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at io.emeraldpay.polkaj.apiws.PolkadotWsApi.accept(PolkadotWsApi.java:184)
	at io.emeraldpay.polkaj.apiws.PolkadotWsApi$3.onText(PolkadotWsApi.java:117)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.processText(WebSocketImpl.java:627)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.run(WebSocketImpl.java:435)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.tryChangeState(WebSocketImpl.java:853)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$SignallingMessageConsumer.onText(WebSocketImpl.java:786)
	at java.net.http/jdk.internal.net.http.websocket.MessageDecoder.payloadData(MessageDecoder.java:222)
	at java.net.http/jdk.internal.net.http.websocket.Frame$Reader.readFrame(Frame.java:465)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:665)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$TryEndDeferredCompleter.complete(SequentialScheduler.java:315)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReadEvent.handle(TransportImpl.java:762)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.checkEvents(RawChannelTube.java:174)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:204)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:157)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:844)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':balance:Transfer.main()'.
> Process 'command '/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
16:10:03: Task execution finished ':balance:Transfer.main()'.

Repository to use the library

Hello,

Bintray has been shutdown if I'm not mistaken. From now, is Polkaj accessible in a public maven repository ? The readme still shows this :

repositories {
   // polkaj public repo
   maven { url  "https://dl.bintray.com/emerald/polkaj" }
   // required for com.github.multiformats:java-multibase library
   maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'io.emeraldpay.polkaj:polkaj-api-http:0.3.0'
}

However when downloading the dependencies, it fails with the following error message :

Could not resolve io.emeraldpay.polkaj:polkaj-api-http:0.3.0.

Thanks

Schnorrkel.KeyPair was created by mistake using java. The similar code is as follows. Finally, the address is generated, but in the end I lost my key. Is there any way to help retrieve it?

String prvKey = "*****";
ECKey ecKey = ECKey.fromPrivate( Hex.decodeHex(prvKey) );
Schnorrkel.KeyPair rootKey = new Schnorrkel.KeyPair( Hex.decodeHex( ecKey.getPublicKeyAsHex().substring(2 )), ecKey.getPrivKeyBytes() );

Address address = new Address(SS58Type.Network.LIVE, rootKey.getPublicKey())

Where ECKey comes from bitcoinj's lib

Is it possible to use these in maven project

Hi , I try to use "gradle install" to build these jar to local maven repository, but in my maven project, i add a maven dependency like:

<dependency> <groupId>io.emeraldpay.polkaj</groupId> <artifactId>polkaj-api-http</artifactId> <version>0.4.0-SNAPSHOT</version> </dependency>

--

then the error will occur at maven dependency and the message is "omitted for duplicate"

how do I solve this problem? thanks a lot.

Java offline generation polkadot address

i use SCALE Codec for java generation offline address. but i generation address and polkadot.js generation address is not like;
i use bitcoinj 's MnemonicCode generation mnemonic,and i toseed the mnemonic get seed;
this is my code;

https://stackoverflow.com/questions/68092665/java-offline-generation-polkadot-address

polkadot.js generation'address is "12EgmkT6NHjTjtwcvfBFu1dkPEN9TLFo3ftA4L2ZcmkCfQCp";

i use my code generation'address is "12YTJRjPRsw34wBp2Ewfr9oBP9w47RpKKw4CPZF2zaCga1Hk"

help help help

how i do can generation like polkadot.js' address ?

[Security] Workflow publish.yaml is using vulnerable action eskatos/gradle-command-action

The workflow publish.yaml is referencing action eskatos/gradle-command-action using references v1. However this reference is missing the commit 6ff2065a1233a621be482a67cf97261047133d35 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Current master does not really compile with JDK 8

Current master b82f7f7 does not really compile with JDK 8

Parameter for @Deprecated(forRemoval = true) and List.of method appeared only in JDK 9.

Even with fix #69 ccef8ef (that actually makes pass for JDK 11)

So what is target JDK version?

polkaj2 % gradle -v

------------------------------------------------------------
Gradle 6.8.3
------------------------------------------------------------

Build time:   2021-02-22 16:13:28 UTC
Revision:     9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.12 (GraalVM Community 11.0.12+6-jvmci-21.2-b08)
OS:           Mac OS X 10.15.7 x86_64

polkaj2 % gradle properties 


> Task :properties

------------------------------------------------------------
Root project 'polkaj-root'
------------------------------------------------------------
...
org.gradle.java.home: /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
...
1 actionable task: 1 executed
polkaj2 % gradle compileJava

> Configure project :polkaj-api-base
The maven plugin has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the maven-publish plugin instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.8.3/userguide/upgrading_version_5.html#legacy_publication_system_is_deprecated_and_replaced_with_the_publish_plugins
        at common_java_app_cf9l7gcpkpadhwwlipjfex5gd.run(/Users/paul.verest/Workspaces/Polkadot/polkaj2/common_java_app.gradle:3)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Task :polkaj-api-base:compileJava FAILED
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:135: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:147: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:160: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:175: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:193: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:211: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:229: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:246: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:273: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:288: error: cannot find symbol
    @Deprecated(forRemoval = true)
                             ^
  symbol:   method forRemoval()
  location: @interface Deprecated
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:137: error: cannot find symbol
        List<Object> params = at == null ? List.of(key) : List.of(key, at);
                                               ^
  symbol:   method of(ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:137: error: cannot find symbol
        List<Object> params = at == null ? List.of(key) : List.of(key, at);
                                                              ^
  symbol:   method of(ByteData,Hash256)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:149: error: cannot find symbol
        List<Object> params = at == null ? List.of(key) : List.of(key, at);
                                               ^
  symbol:   method of(ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:149: error: cannot find symbol
        List<Object> params = at == null ? List.of(key) : List.of(key, at);
                                                              ^
  symbol:   method of(ByteData,Hash256)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:162: error: cannot find symbol
        List<Object> params = at == null ? List.of(method, data) : List.of(method, data, at);
                                               ^
  symbol:   method of(String,ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:162: error: cannot find symbol
        List<Object> params = at == null ? List.of(method, data) : List.of(method, data, at);
                                                                       ^
  symbol:   method of(String,ByteData,Hash256)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:177: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(childStorageKey, childDefinition, childType, key));
                                                  ^
  symbol:   method of(ByteData,ByteData,long,ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:195: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(childStorageKey, childDefinition, childType, key));
                                                  ^
  symbol:   method of(ByteData,ByteData,long,ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:213: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(childStorageKey, childDefinition, childType, key));
                                                  ^
  symbol:   method of(ByteData,ByteData,long,ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:231: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(childStorageKey, childDefinition, childType, key));
                                                  ^
  symbol:   method of(ByteData,ByteData,long,ByteData)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:248: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(key, count));
                                                  ^
  symbol:   method of(ByteData,int)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:259: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(keys));
                                                  ^
  symbol:   method of(List<ByteData>)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:275: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(keys, fromBlock));
                                                  ^
  symbol:   method of(List<ByteData>,Hash256)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardCommands.java:290: error: cannot find symbol
        List<Object> params = new ArrayList<>(List.of(keys));
                                                  ^
  symbol:   method of(List<ByteData>)
  location: interface List
/Users/paul.verest/Workspaces/Polkadot/polkaj2/polkaj-api-base/src/main/java/io/emeraldpay/polkaj/api/StandardSubscriptions.java:60: error: cannot find symbol
        return SubscribeCall.create(StorageChangeSetJson.class, PolkadotMethod.STATE_SUBSCRIBE_STORAGE, PolkadotMethod.STATE_UNSUBSCRIBE_STORAGE, List.of(keys));
                                                                                                                                                      ^
  symbol:   method of(List<ByteData>)
  location: interface List
25 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':polkaj-api-base:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
7 actionable tasks: 7 executed

About deploying polkaj_ The method of schnorkel native JNI

Library /native/windows/polkaj_schnorrkel.dll is not found in the classpath
Failed to load native library. Polkaj Schnorrkel methods are unavailable. Error: no polkaj_schnorrkel in java.library.path....
Exception in thread "main" java.lang.UnsatisfiedLinkError: common.utils.Schnorrkel.keypairFromSeed([B)[B

Hello!
When I run and call 'generatekeypair()', there is a lack of schnorkel JNI library. Can you provide me with the deployment method of schnorkel JNI? Thank you very much.

Cannot get balance and total issuance, account info

When im trying to run get account info got ArrayIndexOutOfBoundsException Exception.

Full code:

import io.emeraldpay.polkaj.api.PolkadotApi;
import io.emeraldpay.polkaj.api.StandardCommands;
import io.emeraldpay.polkaj.apihttp.JavaHttpAdapter;
import io.emeraldpay.polkaj.apiws.JavaHttpSubscriptionAdapter;
import io.emeraldpay.polkaj.scaletypes.AccountInfo;
import io.emeraldpay.polkaj.tx.AccountRequests;
import io.emeraldpay.polkaj.types.Address;
import io.emeraldpay.polkaj.types.ByteData;
import io.emeraldpay.polkaj.types.DotAmount;
import io.emeraldpay.polkaj.types.DotAmountFormatter;
import io.emeraldpay.polkaj.types.Units;

public class Balance {

    public static void main(String[] args) throws Exception {

        String node_url = "Node";

        try (PolkadotApi client = PolkadotApi.newBuilder().rpcCallAdapter(JavaHttpAdapter.newBuilder().connectTo(node_url).build()).build()) {
            DotAmountFormatter formatter = DotAmountFormatter.autoFormatter();
            AccountInfo accountInfo = AccountRequests.balanceOf(Address.from("Address")).execute(client).get();
            System.out.println(accountInfo.getNonce());
        }
    }
}

Exception: Caused by: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 69 out of bounds for byte[56]
	at java.base/java.lang.System.arraycopy(Native Method)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.readByteArray(ScaleCodecReader.java:141)
	at io.emeraldpay.polkaj.scale.reader.UInt128Reader.read(UInt128Reader.java:23)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.readUint128(ScaleCodecReader.java:100)
	at io.emeraldpay.polkaj.scaletypes.BalanceReader.read(BalanceReader.java:16)
	at io.emeraldpay.polkaj.scaletypes.BalanceReader.read(BalanceReader.java:10)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
	at io.emeraldpay.polkaj.scaletypes.AccountDataReader.read(AccountDataReader.java:14)
	at io.emeraldpay.polkaj.scaletypes.AccountDataReader.read(AccountDataReader.java:6)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
	at io.emeraldpay.polkaj.scaletypes.AccountInfoReader.read(AccountInfoReader.java:12)
	at io.emeraldpay.polkaj.scaletypes.AccountInfoReader.read(AccountInfoReader.java:6)
	at io.emeraldpay.polkaj.scale.ScaleCodecReader.read(ScaleCodecReader.java:84)
	at io.emeraldpay.polkaj.tx.AccountRequests$AddressBalance.apply(AccountRequests.java:91)
	at io.emeraldpay.polkaj.tx.AccountRequests$AddressBalance.apply(AccountRequests.java:65)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614)
	at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:844)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

The balance does not correspond to the blockchain

Thank you for sharing the project. When I was using it, I found that it might not match the current version of polkadot node. When I got the balance, I found that the balance did not correspond. So I modified the source code, and finally it was matched. , The following is where I modified.

AccountInfo.java

public class AccountInfo {

    private Long nonce;
    /**
     * Integer --> Long
     */
    private Long refcount;
    private AccountData data;
}

AccountInfoReader.java

public class AccountInfoReader implements ScaleReader<AccountInfo> {

    @Override
    public AccountInfo read(ScaleCodecReader rdr) {
        AccountInfo result = new AccountInfo();
        result.setNonce(rdr.readUint32());
        /**
         * rdr.readUByte()  --> rdr.readUint32()
         */
        result.setRefcount(rdr.readUint32());
        result.setData(rdr.read(new AccountDataReader()));
        return result;
    }
}

rewrite polkaj to java10, it appears some warnings in SchnorrkelNative

Hi,
Cause my environment is java10, so I try to rewrite your polkaj to jdk10.0.2
But I don't change anything at SchnorrkelNative, I use these libraries in my maven project, then it pops out warning below:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on io.emeraldpay.polkaj.schnorrkel.SchnorrkelNative (file:/Users/bomaxchen/.m2/repository/io/emeraldpay/polkaj/polkaj-schnorrkel/0.5.1/polkaj-schnorrkel-0.5.1.jar) to class java.lang.ClassLoader
WARNING: Please consider reporting this to the maintainers of io.emeraldpay.polkaj.schnorrkel.SchnorrkelNative
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

======

althought it doesn't happen error and it can run transfer using http-api , but i'm curious how to solve it. Thank you !

ModuleVersionNotFoundException Android

Hello, I tried to implement polkaj to android app and i have issues.

build.gradle:

implementation 'io.emeraldpay.polkaj:polkaj-api-http:0.3.0'

settings.gradle:


dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://jitpack.io' }
        // polkaj public repo
        maven { url  "https://dl.bintray.com/emerald/polkaj" }
    }
}

Error:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find io.emeraldpay.polkaj:polkaj-api-http:0.3.0.

Metadata version outdated

metadata version is now on version 13. Code still referencing version 12:

if (result.getVersion() != 12) {
throw new IllegalStateException("Unsupported metadata version: " + result.getVersion());
}

Example failed

E:\work\polkadot-java\polkaj\examples\balance\src\main\java\Balance.java:1: 错误: 无法访问PolkadotHttpApi
import io.emeraldpay.polkaj.apihttp.PolkadotHttpApi;
^
错误的类文件: C:\Users\zhoushuntong.m2\repository\io\emeraldpay\polkaj\polkaj-api-http\0.4.0-SNAPSHOT\polkaj-api-http-0.4.0-SNAPSHOT.jar(io/emeraldpay/polkaj/apihttp/PolkadotHttpApi.class)
类文件具有错误的版本 55.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。

FAILURE: Build failed with an exception.

Is this project still alive?

Tried to compile the snapshot version and run Transfer example (against mainnet and westend wss endpoints). Websocket connection is established, but none of the subscriptions seems to return nothing. Any ideas? Thanks!

Can't run examples

In order to run examples I had to edit gradle wrapper from version 6.1 to 6.3 and I also had to update polkaJ version from 0.4.0-snapshot to 0.3.0 because the snapshot is not being hosted in bintray.

How to check Tx success

I followed the example of Transfer and got Hash256 smoothly, but how do I confirm whether the transaction was successful?


            ByteData req = transfer.encodeRequest();
            System.out.println("RPC Request Payload: " + req);
            Hash256 txid = client.execute(
                    StandardCommands.getInstance().authorSubmitExtrinsic(req)
            ).get();
             // How can i check this tx hash is successfully to submit to chain 
            System.out.println("Tx Hash: " + txid);  

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.