substrate-client-kotlin icon indicating copy to clipboard operation
substrate-client-kotlin copied to clipboard

Use in Java - wallet1.getAccountInfo(provider) cannot find symbol method getAccountInfo(SubstrateProvider)

Open paulvi opened this issue 4 years ago • 1 comments

Similar to #5 get compilation for wallet1.getAccountInfo(provider)

package bcd.java;

import io.nodle.substratesdk.account.InvalidAccount;
import io.nodle.substratesdk.rpc.SubstrateProvider;
import io.nodle.substratesdk.account.Wallet;
//@Slf4j
public class UsingSubstrateClientKotlin {
    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(UsingSubstrateClientKotlin.class);

    public static void main(String[] args) {
        String rpcUrl = "ws://127.0.0.1:9944";
        var provider = new SubstrateProvider(rpcUrl);
        var specVersion = provider.getTransactionVersion().blockingGet();
        log.info("getTransactionVersion specVersion={}", specVersion); //OK

        String mnemonic = "";
        Wallet wallet1 = null;
        try {
            wallet1 = new Wallet(mnemonic);
        } catch (InvalidAccount e) {
            e.printStackTrace();
        }
        var balance1 = wallet1.getAccountInfo(provider).blockingGet();
    }
}

and get error

bcd-java/src/main/java/bcd/java/UsingSubstrateClientKotlin.java:34: error: cannot find symbol
        var balance1 = wallet1.getAccountInfo(provider).blockingGet();
                              ^
  symbol:   method getAccountInfo(SubstrateProvider)
  location: variable wallet1 of type Wallet

paulvi avatar Sep 10 '21 09:09 paulvi

It is clearly over Kotlin (Go-style) method definition

fun Account.getAccountInfo(provider: SubstrateProvider): Single<AccountInfo> {

in https://github.com/NodleCode/substrate-client-kotlin/blob/master/substrate-client/src/main/java/io/nodle/substratesdk/SubstrateApi.kt#L25

paulvi avatar Sep 10 '21 09:09 paulvi