Search in sources :

Example 1 with NetVersion

use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.

the class EnsResolver method lookupResolver.

private PublicResolver lookupResolver(String ensName) throws Exception {
    NetVersion netVersion = web3j.netVersion().send();
    String registryContract = Contracts.resolveRegistryContract(netVersion.getNetVersion());
    ENS ensRegistry = ENS.load(registryContract, web3j, transactionManager, new DefaultGasProvider());
    byte[] nameHash = NameHash.nameHashAsBytes(ensName);
    String resolverAddress = ensRegistry.resolver(nameHash).send();
    return PublicResolver.load(resolverAddress, web3j, transactionManager, new DefaultGasProvider());
}
Also used : ENS(org.web3j.ens.contracts.generated.ENS) NetVersion(org.web3j.protocol.core.methods.response.NetVersion) DefaultGasProvider(org.web3j.tx.gas.DefaultGasProvider)

Example 2 with NetVersion

use of org.web3j.protocol.core.methods.response.NetVersion in project besu by hyperledger.

the class Web3JSupportAcceptanceTest method netVersionCall.

@Test
public void netVersionCall() {
    final String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
    assumeTrue(osName.contains("mac") || osName.contains("linux"));
    final Web3j web3 = Web3j.build(new UnixIpcService(socketPath.toString()));
    final Request<?, NetVersion> ethBlockNumberRequest = web3.netVersion();
    node.verify(node -> {
        try {
            assertThat(ethBlockNumberRequest.send().getNetVersion()).isEqualTo(String.valueOf(2018));
        } catch (IOException e) {
            fail("Web3J net_version call failed", e);
        }
    });
}
Also used : Web3j(org.web3j.protocol.Web3j) UnixIpcService(org.web3j.protocol.ipc.UnixIpcService) IOException(java.io.IOException) NetVersion(org.web3j.protocol.core.methods.response.NetVersion) Test(org.junit.Test)

Example 3 with NetVersion

use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.

the class CoreIT method testNetVersion.

@Test
public void testNetVersion() throws Exception {
    NetVersion netVersion = web3j.netVersion().send();
    assertFalse(netVersion.getNetVersion().isEmpty());
}
Also used : NetVersion(org.web3j.protocol.core.methods.response.NetVersion) EVMTest(org.web3j.EVMTest) Test(org.junit.jupiter.api.Test)

Example 4 with NetVersion

use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.

the class EnsResolver method getResolverAddress.

private String getResolverAddress(String ensName) throws Exception {
    NetVersion netVersion = web3j.netVersion().send();
    String registryContract = Contracts.resolveRegistryContract(netVersion.getNetVersion());
    ENS ensRegistry = ENS.load(registryContract, web3j, transactionManager, new DefaultGasProvider());
    byte[] nameHash = NameHash.nameHashAsBytes(ensName);
    String address = ensRegistry.resolver(nameHash).send();
    if (EnsUtils.isAddressEmpty(address)) {
        address = getResolverAddress(EnsUtils.getParent(ensName));
    }
    return address;
}
Also used : ENS(org.web3j.ens.contracts.generated.ENS) NetVersion(org.web3j.protocol.core.methods.response.NetVersion) DefaultGasProvider(org.web3j.tx.gas.DefaultGasProvider)

Example 5 with NetVersion

use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.

the class ResponseTest method testNetVersion.

@Test
public void testNetVersion() throws IOException {
    buildResponse("{\n" + "  \"id\":67,\n" + "  \"jsonrpc\": \"2.0\",\n" + "  \"result\": \"59\"\n" + "}");
    NetVersion netVersion = deserialiseResponse(NetVersion.class);
    assertEquals(netVersion.getNetVersion(), ("59"));
}
Also used : NetVersion(org.web3j.protocol.core.methods.response.NetVersion) Test(org.junit.jupiter.api.Test)

Aggregations

NetVersion (org.web3j.protocol.core.methods.response.NetVersion)12 Test (org.junit.jupiter.api.Test)6 Utf8String (org.web3j.abi.datatypes.Utf8String)4 Request (org.web3j.protocol.core.Request)3 TokenscriptFunction (com.alphawallet.app.entity.tokenscript.TokenscriptFunction)2 Function (org.web3j.abi.datatypes.Function)2 ENS (org.web3j.ens.contracts.generated.ENS)2 EthCall (org.web3j.protocol.core.methods.response.EthCall)2 Web3ClientVersion (org.web3j.protocol.core.methods.response.Web3ClientVersion)2 DefaultGasProvider (org.web3j.tx.gas.DefaultGasProvider)2 IOException (java.io.IOException)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 EVMTest (org.web3j.EVMTest)1 Web3j (org.web3j.protocol.Web3j)1 BatchRequest (org.web3j.protocol.core.BatchRequest)1 BatchResponse (org.web3j.protocol.core.BatchResponse)1 Web3Sha3 (org.web3j.protocol.core.methods.response.Web3Sha3)1 UnixIpcService (org.web3j.protocol.ipc.UnixIpcService)1