diff --git a/core/src/main/java/com/klaytn/caver/methods/response/ForkStatusResult.java b/core/src/main/java/com/klaytn/caver/methods/response/ForkStatusResult.java new file mode 100644 index 00000000..f4e4dad7 --- /dev/null +++ b/core/src/main/java/com/klaytn/caver/methods/response/ForkStatusResult.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 The caver-java Authors + * + * 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 com.klaytn.caver.methods.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; +import org.web3j.protocol.core.Response; + +public class ForkStatusResult + extends Response { + + public static class ForkStatusData { + + @JsonProperty("EthTxType") + private Boolean EthTxType; + + @JsonProperty("Istanbul") + private Boolean Istanbul; + + @JsonProperty("KIP103") + private Boolean KIP103; + + @JsonProperty("Kore") + private Boolean Kore; + + @JsonProperty("London") + private Boolean London; + + @JsonProperty("Magma") + private Boolean Magma; + + @JsonProperty("Mantle") + private Boolean Mantle; + + public ForkStatusData() {} + public ForkStatusData ( + Boolean EthTxType, + Boolean Istanbul, + Boolean KIP103, + Boolean Kore, + Boolean London, + Boolean Magma, + Boolean Mantle + ) { + this.EthTxType = EthTxType; + this.Istanbul = Istanbul; + this.KIP103 = KIP103; + this.Kore = Kore; + this.London = London; + this.Magma = Magma; + this.Mantle = Mantle; + } + } +} diff --git a/core/src/main/java/com/klaytn/caver/methods/response/RewardsAccumulated.java b/core/src/main/java/com/klaytn/caver/methods/response/RewardsAccumulated.java new file mode 100644 index 00000000..a02535fe --- /dev/null +++ b/core/src/main/java/com/klaytn/caver/methods/response/RewardsAccumulated.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 The caver-java Authors + * + * 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 com.klaytn.caver.methods.response; + +import java.util.Map; + +import org.web3j.protocol.core.Response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class RewardsAccumulated extends Response { + public static class RewardsAccumulatedData { + + @JsonProperty("firstBlockTime") + private String firstBlockTime; + + @JsonProperty("lastBlockTime") + private String lastBlockTime; + + @JsonProperty("firstBlock") + private String firstBlock; + + @JsonProperty("lastBlock") + private String lastBlock; + + @JsonProperty("totalMinted") + private String totalMinted; + + @JsonProperty("totalTxFee") + private String totalTxFee; + + @JsonProperty("totalBurntTxFee") + private String totalBurntTxFee; + + @JsonProperty("totalProposerRewards") + private String totalProposerRewards; + + @JsonProperty("totalStakingRewards") + private String totalStakingRewards; + + @JsonProperty("totalKFFRewards") + private String totalKFFRewards; + + @JsonProperty("totalKCFRewards") + private String totalKCFRewards; + + /** + * mapping from reward recipient to amounts + */ + @JsonProperty("rewards") + private Map rewards; + + public RewardsAccumulatedData() {} + public RewardsAccumulatedData( + String firstBlockTime, + String lastBlockTime, + String firstBlock, + String lastBlock, + String totalMinted, + String totalTxFee, + String totalBurntTxFee, + String totalProposerRewards, + String totalStakingRewards, + String totalKFFRewards, + String totalKCFRewards, + Map Rewards + ) { + this.firstBlockTime = firstBlockTime; + this.lastBlockTime = lastBlockTime; + this.firstBlock = firstBlock; + this.lastBlock = lastBlock; + this.totalMinted = totalMinted; + this.totalTxFee = totalTxFee; + this.totalBurntTxFee = totalBurntTxFee; + this.totalProposerRewards = totalProposerRewards; + this.totalStakingRewards = totalStakingRewards; + this.totalKFFRewards = totalKFFRewards; + this.totalKCFRewards = totalKCFRewards; + this.rewards = rewards; + } + } +} \ No newline at end of file diff --git a/core/src/main/java/com/klaytn/caver/rpc/Governance.java b/core/src/main/java/com/klaytn/caver/rpc/Governance.java index a7f2df35..aa37bd19 100644 --- a/core/src/main/java/com/klaytn/caver/rpc/Governance.java +++ b/core/src/main/java/com/klaytn/caver/rpc/Governance.java @@ -278,7 +278,7 @@ public Request getMyVotes() { * @return Request<?, GovernanceChainConfig> */ public Request getChainConfig() { - return getChainConfigAt(DefaultBlockParameterName.LATEST); + return getChainConfig(DefaultBlockParameterName.LATEST); } /** @@ -330,44 +330,6 @@ public Request getChainConfig(DefaultBlockParameter bl ); } - /** - * Provides the chain configuration at the specified block number - *
Example :
-     * {@code
-     * GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt(BigInteger.ZERO).send();
-     * }
-     * 
- * @return Request<?, GovernanceChainConfig> - */ - public Request getChainConfigAt(BigInteger blockNumber) { - return getChainConfigAt(DefaultBlockParameter.valueOf(blockNumber)); - } - - /** - * Provides the chain configuration by block tag (latest, earliest, pending) - *
Example :
-     * {@code
-     * GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt("latest").send();
-     * }
-     * 
- * @return Request<?, GovernanceChainConfig> - */ - public Request getChainConfigAt(String blockTag) { - return getChainConfigAt(DefaultBlockParameterName.fromString(blockTag)); - } - - /** - * return chain configuration - */ - public Request getChainConfigAt(DefaultBlockParameter blockNumberOrTag) { - return new Request<>( - "governance_chainConfigAt", - Arrays.asList(blockNumberOrTag), - provider, - GovernanceChainConfig.class - ); - } - /** * Provides the address of the node that a user is using.

* It is derived from the nodekey and used to sign consensus messages. And the value of "governingnode" has to be one of validator's node address. @@ -467,59 +429,6 @@ Request getParams(DefaultBlockParameter blockParameter) { ); } - /** - * Returns governance items at specific block.

- * It is the result of previous voting of the block and used as configuration for chain at the given block number.

- * It pass the latest block tag as a parameter. - *

Example :
-     * {@code
-     * GovernanceItems response = caver.rpc.governance.getItemsAt().send();
-     * Map governanceItem = response.getResult();
-     *
-     * String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
-     * }
- * @return Request<?, Bytes20> - */ - public Request getItemsAt() { - return getItemsAt(DefaultBlockParameterName.LATEST); - } - - /** - * Returns governance items at specific block.

- * It is the result of previous voting of the block and used as configuration for chain at the given block number. - *

Example :
-     * {@code
-     * GovernanceItems response = caver.rpc.governance.getItemsAt(BigInteger.ZERO).send();
-     * Map governanceItem = response.getResult();
-     *
-     * String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
-     * }
- * @param blockNumber The block number to query. - * @return Request<?, GovernanceItems> - */ - public Request getItemsAt(BigInteger blockNumber) { - return getItemsAt(DefaultBlockParameter.valueOf(blockNumber)); - } - - /** - * Returns governance items at specific block.

- * It is the result of previous voting of the block and used as configuration for chain at the given block number. - *

Example :
-     * {@code
-     * GovernanceItems response = caver.rpc.governance.getItemsAt("latest").send();
-     * Map governanceItem = response.getResult();
-     *
-     * String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
-     * }
-     * 
- * @param blockTag The block tag to query - * @return Request<?, GovernanceItems> - */ - public Request getItemsAt(String blockTag) { - DefaultBlockParameterName blockTagName = DefaultBlockParameterName.fromString(blockTag); - return getItemsAt(blockTagName); - } - /** * Returns governance items at specific block.

* It is the result of previous voting of the block and used as configuration for chain at the given block number. @@ -534,18 +443,18 @@ public Request getItemsAt(String blockTag) { * @param blockTag The block tag to query * @return Request<?, GovernanceItems> */ - public Request getItemsAt(DefaultBlockParameterName blockTag) { - return getItemsAt((DefaultBlockParameter)blockTag); - } + // public Request getItemsAt(DefaultBlockParameterName blockTag) { + // return getItemsAt((DefaultBlockParameter)blockTag); + // } - Request getItemsAt(DefaultBlockParameter blockParameter) { - return new Request<>( - "governance_itemsAt", - Arrays.asList(blockParameter.getValue()), - provider, - GovernanceItems.class - ); - } + // Request getItemsAt(DefaultBlockParameter blockParameter) { + // return new Request<>( + // "governance_itemsAt", + // Arrays.asList(blockParameter.getValue()), + // provider, + // GovernanceItems.class + // ); + // } /** * Returns the list of items that have received enough number of votes but not yet finalized.

@@ -713,4 +622,28 @@ Request getStakingInfo(DefaultBlockParameter blockPara GovernanceStakingInfo.class ); } -} + + public Request getRewardsAccumulated(String fromBlock, String toBlock) { + DefaultBlockParameterName fromBlockTagName = DefaultBlockParameterName.fromString(fromBlock); + DefaultBlockParameterName toBlockTagName = DefaultBlockParameterName.fromString(toBlock); + + return getRewardsAccumulated(fromBlockTagName, toBlockTagName); + } + + public Request getRewardsAccumulated(BigInteger fromBlock, BigInteger toBlock) { + return getRewardsAccumulated(fromBlock, toBlock); + } + + public Request getRewardsAccumulated(DefaultBlockParameterName fromBlock, DefaultBlockParameterName toBlock) { + return getRewardsAccumulated((DefaultBlockParameter)fromBlock, (DefaultBlockParameter)toBlock); + } + + Request getRewardsAccumulated(DefaultBlockParameter fromBlock, DefaultBlockParameter toBlock) { + return new Request<>( + "governance_getRewardsAccumulated", + Arrays.asList(fromBlock, toBlock), + provider, + RewardsAccumulated.class + ); + } +} \ No newline at end of file diff --git a/core/src/main/java/com/klaytn/caver/rpc/Klay.java b/core/src/main/java/com/klaytn/caver/rpc/Klay.java index 6fb96553..a5c6ab99 100644 --- a/core/src/main/java/com/klaytn/caver/rpc/Klay.java +++ b/core/src/main/java/com/klaytn/caver/rpc/Klay.java @@ -22,6 +22,7 @@ import com.klaytn.caver.methods.request.KlayLogFilter; import com.klaytn.caver.methods.response.Boolean; import com.klaytn.caver.methods.response.KlayRewards.BlockRewards; +import com.klaytn.caver.methods.response.ForkStatusResult.ForkStatusData; import com.klaytn.caver.methods.response.*; import com.klaytn.caver.transaction.AbstractFeeDelegatedTransaction; import com.klaytn.caver.transaction.AbstractTransaction; @@ -1259,7 +1260,7 @@ public Request getClientVersion() { * @return Request<?, GovernanceChainConfig> */ public Request getChainConfig() { - return getChainConfigAt(DefaultBlockParameterName.LATEST); + return getChainConfig(DefaultBlockParameterName.LATEST); } /** @@ -1272,7 +1273,7 @@ public Request getChainConfig() { * @return Request<?, GovernanceChainConfig> */ public Request getChainConfig(BigInteger blockNumber) { - return getChainConfigAt(DefaultBlockParameter.valueOf(blockNumber)); + return getChainConfig(DefaultBlockParameter.valueOf(blockNumber)); } /** @@ -1285,7 +1286,7 @@ public Request getChainConfig(BigInteger blockNumber) * @return Request<?, GovernanceChainConfig> */ public Request getChainConfig(String blockTag) { - return getChainConfigAt(DefaultBlockParameterName.fromString(blockTag)); + return getChainConfig(DefaultBlockParameterName.fromString(blockTag)); } /** @@ -1341,7 +1342,7 @@ public Request getChainConfigAt(String blockTag) { * Provides the chain configuration by block tag (latest, earliest, pending) *

Example :
      * {@code
-     * GovernanceChainConfig response = caver.rpc.klay.getChainConfigAt(DefaultBlockParameterName.LATEST).send();
+     * GovernanceChainConfig response = caver.rpc.klay.getChainConfig(DefaultBlockParameterName.LATEST).send();
      *
      * String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
      * }
@@ -1353,7 +1354,7 @@ public Request getChainConfigAt(DefaultBlockParameterN
     }
     public Request getChainConfigAt(DefaultBlockParameter blockNumberOrTag) {
         return new Request<>(
-                "klay_chainConfigAt",
+                "klay_getChainConfig",
                 Arrays.asList(blockNumberOrTag),
                 web3jService,
                 GovernanceChainConfig.class
@@ -2240,4 +2241,57 @@ private Request subscribe(String type, KlayFilter options) {
                 web3jService,
                 Quantity.class);
     }
-}
+
+    public Request forkStatus(Integer param) {
+        return new Request<>(
+                "klay_forkStatus",
+                Arrays.asList(param),
+                web3jService,
+                ForkStatusResult.class
+        );
+    }
+
+    public Request recoverFromMessage(String address, String message, String signature, String blockTag) {
+        DefaultBlockParameterName blockTagName = DefaultBlockParameterName.fromString(blockTag);
+        return recoverFromMessage(address, message, signature, blockTagName);
+    }
+
+    public Request recoverFromMessage(String address, String message, String signature, BigInteger blockNumber) {
+        return recoverFromMessage(address, message, signature, blockNumber);
+    }
+
+    public Request recoverFromMessage(String address, String message, String signature, DefaultBlockParameterName blockTag) {
+        return recoverFromMessage(address, message, signature, (DefaultBlockParameter)blockTag);
+    }
+
+    Request recoverFromMessage(String address, String message, String signature, DefaultBlockParameter blockNumber) {
+        return new Request<>(
+                "klay_recoverFromMessage",
+                Arrays.asList(address, message, signature, blockNumber),
+                web3jService,
+                Bytes.class
+        );
+    }
+
+    public Request recoverFromTransaction(String txHash, String blockTag) {
+        DefaultBlockParameterName blockTagName = DefaultBlockParameterName.fromString(blockTag);
+        return recoverFromTransaction(txHash, blockTagName);
+    }
+
+    public Request recoverFromTransaction(String txHash, BigInteger blockNumber) {
+        return recoverFromTransaction(txHash, blockNumber);
+    }
+
+    public Request recoverFromTransaction(String txHash, DefaultBlockParameterName blockTag) {
+        return recoverFromTransaction(txHash, (DefaultBlockParameter)blockTag);
+    }
+
+    public Request recoverFromTransaction(String txHash, DefaultBlockParameter blockTag) {
+        return new Request<>(
+                "klay_recoverFromTransaction",
+                Arrays.asList(txHash, blockTag),
+                web3jService,
+                Bytes.class
+        );
+    }
+}
\ No newline at end of file
diff --git a/core/src/test/java/com/klaytn/caver/common/rpc/RpcTest.java b/core/src/test/java/com/klaytn/caver/common/rpc/RpcTest.java
index 4f6281d8..1a3c0c3a 100644
--- a/core/src/test/java/com/klaytn/caver/common/rpc/RpcTest.java
+++ b/core/src/test/java/com/klaytn/caver/common/rpc/RpcTest.java
@@ -1540,19 +1540,19 @@ public void getKlayChainConfigAtBlockTag() throws IOException {
             assertFalse(response.hasError());
         }
 
-        @Test
-        public void getGovernanceChainConfigAtWithBlockNumber() throws IOException {
-            GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt(BigInteger.valueOf(0)).send();
-            assertNotNull(response.getResult());
-            assertFalse(response.hasError());
-        }
+        // @Test
+        // public void getGovernanceChainConfigAtWithBlockNumber() throws IOException {
+        //     GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt(BigInteger.valueOf(0)).send();
+        //     assertNotNull(response.getResult());
+        //     assertFalse(response.hasError());
+        // }
 
-        @Test
-        public void getGovernanceChainConfigAtBlockTag() throws IOException {
-            GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt("latest").send();
-            assertNotNull(response.getResult());
-            assertFalse(response.hasError());
-        }
+        // @Test
+        // public void getGovernanceChainConfigAtBlockTag() throws IOException {
+        //     GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt("latest").send();
+        //     assertNotNull(response.getResult());
+        //     assertFalse(response.hasError());
+        // }
 
         @Test
         public void getKlayNodeAddress() throws IOException {
@@ -1589,26 +1589,26 @@ public void getParams() throws IOException {
 
         }
 
-        @Test
-        public void getItemsAt() throws IOException {
-            GovernanceItems response = caver.rpc.governance.getItemsAt().send();
-            assertNotNull(response);
-            assertFalse(response.hasError());
+        // @Test
+        // public void getItemsAt() throws IOException {
+        //     GovernanceItems response = caver.rpc.governance.getItemsAt().send();
+        //     assertNotNull(response);
+        //     assertFalse(response.hasError());
 
-            Map gov_item = response.getResult();
+        //     Map gov_item = response.getResult();
 
-            response = caver.rpc.governance.getItemsAt(DefaultBlockParameterName.LATEST).send();
-            assertNotNull(response);
-            assertFalse(response.hasError());
+        //     response = caver.rpc.governance.getItemsAt(DefaultBlockParameterName.LATEST).send();
+        //     assertNotNull(response);
+        //     assertFalse(response.hasError());
 
-            response = caver.rpc.governance.getItemsAt(BigInteger.ZERO).send();
-            assertNotNull(response);
-            assertFalse(response.hasError());
+        //     response = caver.rpc.governance.getItemsAt(BigInteger.ZERO).send();
+        //     assertNotNull(response);
+        //     assertFalse(response.hasError());
 
-            String mode = IVote.VoteItem.getGovernanceMode(response.getResult());
-            System.out.println(mode);
+        //     String mode = IVote.VoteItem.getGovernanceMode(response.getResult());
+        //     System.out.println(mode);
 
-        }
+        // }
 
         @Test
         public void getPendingChanges() throws IOException {
@@ -1685,6 +1685,13 @@ public void getGovernanceStakingInfo() throws IOException {
             assertFalse(response.hasError());
         }
 
+        @Test
+        public void getRewardsAccumulated () throws IOException {
+            RewardsAccumulated response = caver.rpc.governance.getRewardsAccumulated("123400489", "123416489").send();
+            assertNotNull(response);
+            assertFalse(response.hasError());
+        }
+
         @Test
         public void parseGovernanceItem() throws IOException {
             String json = "{\n" +
@@ -1919,5 +1926,34 @@ public void removePeer() throws IOException {
             assertNotNull(response);
             assertFalse(response.hasError());
         }
+
+        @Test
+        public void forkStatus() throws IOException {
+            ForkStatusResult response = caver.rpc.klay.forkStatus(20).send();
+            assertNotNull(response);
+            assertFalse(response.hasError());
+        }
+
+        @Test
+        public void recoverFromMessage() throws IOException {
+            Bytes response = caver.rpc.klay.recoverFromMessage(
+                "0xA2a8854b1802D8Cd5De631E690817c253d6a9153",
+                "0xdeadbeef", 
+                "0x1e6338d6e4a8d688a25de78cf2a92efec9a92e52eb8425acaaee8c3957e68cdb3f91bdc483f0ed05a0da26eca3be4c566d087d90dc2ca293be23b2a9de0bcafc1c", 
+                "latest"
+            ).send();
+            assertNotNull(response);
+            assertFalse(response.hasError());
+        }
+
+        @Test
+        public void recoverFromTransaction() throws IOException {
+            Bytes response = caver.rpc.klay.recoverFromTransaction(
+                "0x08f88608850ba43b7400827b0c94c40b6909eb7085590e1c26cb3becc25368e249e9880de0b6b3a764000094e15cd70a41dfb05e7214004d7d054801b2a2f06bf847f845820fe9a090421871e8fd77e08b6a72760006a15184a96cfc39c7486ea948d11fd830ae8aa05876248aa8dc0783d782e584e6f8d9bf977c698210a0eab3e754192d0954de65",
+                "latest"
+            ).send();
+            assertNotNull(response);
+            assertFalse(response.hasError());
+        }
     }
 }