Skip to content

Commit

Permalink
added linea_getProof
Browse files Browse the repository at this point in the history
Signed-off-by: Nischal Sharma <nischal@web3labs.com>
  • Loading branch information
NickSneo committed Feb 14, 2025
1 parent d814e4f commit ce6dba9
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/src/main/java/org/web3j/protocol/core/Ethereum.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.EthUninstallFilter;
import org.web3j.protocol.core.methods.response.LineaEstimateGas;
import org.web3j.protocol.core.methods.response.LineaGetProof;
import org.web3j.protocol.core.methods.response.NetListening;
import org.web3j.protocol.core.methods.response.NetPeerCount;
import org.web3j.protocol.core.methods.response.NetVersion;
Expand Down Expand Up @@ -212,6 +213,9 @@ Request<?, EthBlock> ethGetUncleByBlockNumberAndIndex(

Request<?, EthGetProof> ethGetProof(String address, List<String> storageKeys, String quantity);

Request<?, LineaGetProof> lineaGetProof(
String address, List<String> storageKeys, String quantity);

Request<?, EthGetWork> ethGetWork();

Request<?, EthSubmitWork> ethSubmitWork(String nonce, String headerPowHash, String mixDigest);
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.web3j.protocol.core.methods.response.EthTransaction;
import org.web3j.protocol.core.methods.response.EthUninstallFilter;
import org.web3j.protocol.core.methods.response.LineaEstimateGas;
import org.web3j.protocol.core.methods.response.LineaGetProof;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.NetListening;
import org.web3j.protocol.core.methods.response.NetPeerCount;
Expand Down Expand Up @@ -598,6 +599,16 @@ public Request<?, EthGetProof> ethGetProof(
EthGetProof.class);
}

@Override
public Request<?, LineaGetProof> lineaGetProof(
String address, List<String> storageKeys, String quantity) {
return new Request<>(
"linea_getProof",
Arrays.asList(address, storageKeys, quantity),
web3jService,
LineaGetProof.class);
}

@Override
public Request<?, EthGetWork> ethGetWork() {
return new Request<>(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2025 Web3 Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.web3j.protocol.core.methods.response;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import org.web3j.protocol.core.Response;

public class LineaGetProof extends Response<EthGetProof.Proof> {

@Override
@JsonDeserialize(using = EthGetProof.ResponseDeserializer.class)
public void setResult(EthGetProof.Proof result) {
super.setResult(result);
}

/**
* linea get proof result.
*
* @return proof result
*/
public EthGetProof.Proof getProof() {
return getResult();
}
}
16 changes: 16 additions & 0 deletions core/src/test/java/org/web3j/protocol/core/RequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -859,4 +859,20 @@ void testLineaEstimateGas() throws Exception {
+ "\"to\":\"0x52b93c80364dc2dd4444c146d73b9836bbbb2b3f\",\"data\":\"0x0\"}],"
+ "\"id\":1}");
}

@Test
void testLineaGetProof() throws Exception {
web3j.lineaGetProof(
"0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842",
Arrays.asList(
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
"latest")
.send();
verifyResult(
"{\"jsonrpc\":\"2.0\",\"method\":\"linea_getProof\","
+ "\"params\":[\"0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842\","
+ "[\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\"],"
+ "\"latest\"],"
+ "\"id\":0}");
}
}
Loading

0 comments on commit ce6dba9

Please sign in to comment.