hyperledger / web3j

Lightweight Java and Android library for integration with Ethereum clients

Home Page:https://www.web3labs.com/web3j-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why not update Web3j CLI (Used: version 5.0.0 ,but Generated with web3j version 3.3.1.)

better-github-hub opened this issue · comments

Bug_title

1、org.web3j.abi.datatypes.Event
2、web3j.ethLogObservable

Steps To Reproduce

the web3 auto generate code like :
1、final Event event = new Event("Approval",
Arrays.<TypeReference>asList(new TypeReference

() {}, new TypeReference() {}), Arrays.>asList(new TypeReference() {}))
2、web3j.ethLogObservable:
return web3j.ethLogObservable(filter).map(new Func1<Log, ApprovalEventResponse>();

But I used org.web3j:core: 5.0.0

org.web3j core 5.0.0

1)now, the Event is :Event(String name, List<TypeReference<?>> parameters);
2)Don't find : web3j.ethLogObservable;

Expected behavior

I、 expected auto generate code use : Event(String name, List<TypeReference<?>> parameters);
2、web3j.ethLogObservable is use the lasted function;

Actual behavior

A description of the actual behavior occurring.

Environment

Windows 11

  • Web3j version 5.0.0
  • Java or Android version: java
  • Operating System: Windows 11

Additional context

I used for this :
1、
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/web3j/web3j-installer/master/installer.ps1'))
2、
.\web3j truffle generate C:\xxxx\solidity\build\contracts\xxEther.json -o C:\xx\src\main\solidity\java -p com.xx.solidity

In my project , the maven dependency is:

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>5.0.0</version>
    </dependency>

I had rewrite the function :
public Flowable approvalEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("Approval", Arrays.<TypeReference<?>>asList(new TypeReference() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ApprovalEventResponse>() {
@OverRide
public ApprovalEventResponse apply(Log log) {
Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(event, log);
ApprovalEventResponse typedResponse = new ApprovalEventResponse();
typedResponse.log = log;
typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue();
typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
return typedResponse;
}
});
}

@Qiwancy Web3J 5.0.0 has to be removed, it was wrong released. The latest web3j version is 4.10.1 and CLI is 1.5

I had solved the isssue: (web3j version is 4.10.1 and CLI is 1.5)
1、solcjs --bin --abi --include-path C:\Users\Administrator\node_modules --base-path . .\xxxEther.sol

2、web3j generate solidity -b .\xxx_sol_xxxEther.bin -a .\xxx_sol_xxxEther.abi -o . -p com.qi.solidity