Java Code Examples for org.web3j.protocol.core.methods.response.EthLog#getLogs()

The following examples show how to use org.web3j.protocol.core.methods.response.EthLog#getLogs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrivGetLogsTransaction.java    From besu with Apache License 2.0 5 votes vote down vote up
@Override
public List<LogResult> execute(final NodeRequests node) {
  try {
    final EthLog response = node.privacy().privGetLogs(privacyGroupId, filterParameter).send();

    assertThat(response).as("check response is not null").isNotNull();
    assertThat(response.getResult()).as("check result in response isn't null").isNotNull();

    return response.getLogs();
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 2
Source File: PrivGetFilterChangesTransaction.java    From besu with Apache License 2.0 5 votes vote down vote up
@Override
public List<LogResult> execute(final NodeRequests node) {
  try {
    final EthLog response = node.privacy().privGetFilterChanges(privacyGroupId, filterId).send();

    assertThat(response).as("check response is not null").isNotNull();
    assertThat(response.getResult()).as("check result in response isn't null").isNotNull();
    assertThat(response.getLogs()).isNotNull();

    return response.getLogs();
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 3
Source File: PrivGetFilterLogsTransaction.java    From besu with Apache License 2.0 5 votes vote down vote up
@Override
public List<LogResult> execute(final NodeRequests node) {
  try {
    final EthLog response = node.privacy().privGetFilterLogs(privacyGroupId, filterId).send();

    assertThat(response).as("check response is not null").isNotNull();
    assertThat(response.getResult()).as("check result in response isn't null").isNotNull();
    assertThat(response.getLogs()).isNotNull();

    return response.getLogs();
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 4
Source File: EventFilterIT.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
private List<EthLog.LogResult> createFilterForEvent(
        String encodedEventSignature, String contractAddress) throws Exception {
    EthFilter ethFilter = new EthFilter(
            DefaultBlockParameterName.EARLIEST,
            DefaultBlockParameterName.LATEST,
            contractAddress
    );

    ethFilter.addSingleTopic(encodedEventSignature);

    EthLog ethLog = web3j.ethGetLogs(ethFilter).send();
    return ethLog.getLogs();
}
 
Example 5
Source File: CoreIT.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFiltersByFilterId() throws Exception {
    org.web3j.protocol.core.methods.request.EthFilter ethFilter =
            new org.web3j.protocol.core.methods.request.EthFilter(
            DefaultBlockParameterName.EARLIEST,
            DefaultBlockParameterName.LATEST,
            config.validContractAddress());

    String eventSignature = config.encodedEvent();
    ethFilter.addSingleTopic(eventSignature);

    // eth_newFilter
    EthFilter ethNewFilter = web3j.ethNewFilter(ethFilter).send();
    BigInteger filterId = ethNewFilter.getFilterId();

    // eth_getFilterLogs
    EthLog ethFilterLogs = web3j.ethGetFilterLogs(filterId).send();
    List<EthLog.LogResult> filterLogs = ethFilterLogs.getLogs();
    assertFalse(filterLogs.isEmpty());

    // eth_getFilterChanges - nothing will have changed in this interval
    EthLog ethLog = web3j.ethGetFilterChanges(filterId).send();
    assertTrue(ethLog.getLogs().isEmpty());

    // eth_uninstallFilter
    EthUninstallFilter ethUninstallFilter = web3j.ethUninstallFilter(filterId).send();
    assertTrue(ethUninstallFilter.isUninstalled());
}
 
Example 6
Source File: CoreIT.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testEthGetLogs() throws Exception {
    org.web3j.protocol.core.methods.request.EthFilter ethFilter =
            new org.web3j.protocol.core.methods.request.EthFilter(
            DefaultBlockParameterName.EARLIEST,
            DefaultBlockParameterName.LATEST,
            config.validContractAddress()
    );

    ethFilter.addSingleTopic(config.encodedEvent());

    EthLog ethLog = web3j.ethGetLogs(ethFilter).send();
    List<EthLog.LogResult> logs = ethLog.getLogs();
    assertFalse(logs.isEmpty());
}
 
Example 7
Source File: FilterTester.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
List createExpected(EthLog ethLog) {
    List<EthLog.LogResult> logResults = ethLog.getLogs();
    if (logResults.isEmpty()) {
        fail("Results cannot be empty");
    }

    return ethLog.getLogs().stream()
            .map(t -> t.get()).collect(Collectors.toList());
}
 
Example 8
Source File: EventFilterIT.java    From web3j with Apache License 2.0 5 votes vote down vote up
private List<EthLog.LogResult> createFilterForEvent(
        String encodedEventSignature, String contractAddress) throws Exception {
    EthFilter ethFilter =
            new EthFilter(
                    DefaultBlockParameterName.EARLIEST,
                    DefaultBlockParameterName.LATEST,
                    contractAddress);

    ethFilter.addSingleTopic(encodedEventSignature);

    EthLog ethLog = web3j.ethGetLogs(ethFilter).send();
    return ethLog.getLogs();
}
 
Example 9
Source File: CoreIT.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testFiltersByFilterId() throws Exception {
    org.web3j.protocol.core.methods.request.EthFilter ethFilter =
            new org.web3j.protocol.core.methods.request.EthFilter(
                    DefaultBlockParameterName.EARLIEST,
                    DefaultBlockParameterName.LATEST,
                    config.validContractAddress());

    String eventSignature = config.encodedEvent();
    ethFilter.addSingleTopic(eventSignature);

    // eth_newFilter
    EthFilter ethNewFilter = web3j.ethNewFilter(ethFilter).send();
    BigInteger filterId = ethNewFilter.getFilterId();

    // eth_getFilterLogs
    EthLog ethFilterLogs = web3j.ethGetFilterLogs(filterId).send();
    List<EthLog.LogResult> filterLogs = ethFilterLogs.getLogs();
    assertFalse(filterLogs.isEmpty());

    // eth_getFilterChanges - nothing will have changed in this interval
    EthLog ethLog = web3j.ethGetFilterChanges(filterId).send();
    assertTrue(ethLog.getLogs().isEmpty());

    // eth_uninstallFilter
    EthUninstallFilter ethUninstallFilter = web3j.ethUninstallFilter(filterId).send();
    assertTrue(ethUninstallFilter.isUninstalled());
}
 
Example 10
Source File: CoreIT.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testEthGetLogs() throws Exception {
    org.web3j.protocol.core.methods.request.EthFilter ethFilter =
            new org.web3j.protocol.core.methods.request.EthFilter(
                    DefaultBlockParameterName.EARLIEST,
                    DefaultBlockParameterName.LATEST,
                    config.validContractAddress());

    ethFilter.addSingleTopic(config.encodedEvent());

    EthLog ethLog = web3j.ethGetLogs(ethFilter).send();
    List<EthLog.LogResult> logs = ethLog.getLogs();
    assertFalse(logs.isEmpty());
}
 
Example 11
Source File: FilterTester.java    From web3j with Apache License 2.0 5 votes vote down vote up
List createExpected(EthLog ethLog) {
    List<EthLog.LogResult> logResults = ethLog.getLogs();
    if (logResults.isEmpty()) {
        fail("Results cannot be empty");
    }

    return ethLog.getLogs().stream().map(t -> t.get()).collect(Collectors.toList());
}