Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #366 from klaytn/applyAPINamingConvention
Browse files Browse the repository at this point in the history
Apply api naming convention
  • Loading branch information
jack authored Mar 17, 2023
2 parents 9f7fa3d + 8dbcf15 commit 65905e6
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public static class StakingInfo {
@JsonProperty("KIRAddr")
private String kirAddr;

/**
* The contract address of PoC.
* PoC is the previous name of KGF.
*/
@JsonProperty("kffAddr")
private String kffAddr;

/**
* The contract address of KIR.
*/
@JsonProperty("kcfAddr")
private String kcfAddr;

/**
* Gini coefficient.
*/
Expand Down Expand Up @@ -95,6 +108,22 @@ public StakingInfo(boolean useGini, String pocAddr, String kirAddr, int gini, Li
this.councilRewardAddrs = councilRewardAddrs;
this.councilNodeAddrs = councilModeAddrs;
this.blockNum = blockNum;
}

public StakingInfo(boolean useGini, String pocAddr, String kirAddr, String kffAddr, String kcfAddr, int gini,
List<BigInteger> councilStakingAmounts, List<String> councilStakingAddrs,
List<String> councilRewardAddrs, List<String> councilNodeAddrs, BigInteger blockNum) {
this.useGini = useGini;
this.pocAddr = pocAddr;
this.kirAddr = kirAddr;
this.kffAddr = kffAddr;
this.kcfAddr = kcfAddr;
this.gini = gini;
this.councilStakingAmounts = councilStakingAmounts;
this.councilStakingAddrs = councilStakingAddrs;
this.councilRewardAddrs = councilRewardAddrs;
this.councilNodeAddrs = councilNodeAddrs;
this.blockNum = blockNum;
}

/**
Expand All @@ -112,21 +141,21 @@ public boolean isUseGini() {
public void setUseGini(boolean useGini) {
this.useGini = useGini;
}

/**
* Getter function for PocAddr.
* PoC is the previous name of KGF.
* Getter function for KGFAddr.
* @return String
*/
public String getPocAddr() {
public String getKGFAddr() {
return pocAddr;
}

/**
* Getter function for KGFAddr.
* Getter function for PocAddr.
* PoC is the previous name of KGF.
* @return String
*/
public String getKGFAddr() {
public String getPocAddr() {
return pocAddr;
}

Expand Down Expand Up @@ -155,6 +184,38 @@ public void setKirAddr(String kirAddr) {
this.kirAddr = kirAddr;
}

/**
* Getter function for kffAddr.
* @return String
*/
public String getKffAddr() {
return kffAddr;
}

/**
* Setter function for kffAddr
* @param kffAddr The contract address of KFF.
*/
public void setKffAddr(String kffAddr) {
this.kffAddr = kffAddr;
}

/**
* Getter function for kcfAddr.
* @return String
*/
public String getKcfAddr() {
return kcfAddr;
}

/**
* Setter function for kcfAddr
* @param kcfAddr The contract address of KCF.
*/
public void setKcfAddr(String kcfAddr) {
this.kcfAddr = kcfAddr;
}

/**
* Getter function for Gini
* @return int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public static class BlockRewards {
/**
* the amount allocated to KGF
*/
@JsonProperty("kgf")
private String kgf;
@JsonProperty("kff")
private String kff;
/**
* the amount allocated to KIR
*/
@JsonProperty("kir")
private String kir;
@JsonProperty("kcf")
private String kcf;
/**
* mapping from reward recipient to amounts
*/
Expand All @@ -67,13 +67,14 @@ public static class BlockRewards {

public BlockRewards() {}
public BlockRewards(String Minted, String TotalFee, String BurntFee, String Proposer,
String Stakers, String Kgf, String Kir, Map<String,String> Rewards) {
String Stakers, String Kff, String Kcf, Map<String,String> Rewards) {
this.minted = Minted;
this.totalFee = TotalFee;
this.burntFee = BurntFee;
this.proposer = Proposer;
this.stakers = Stakers;
this.kgf = Kgf;
this.kff = Kff;
this.kcf = Kcf;
this.rewards = Rewards;
}

Expand All @@ -93,11 +94,11 @@ public String getProposer() {
public String getStakers() {
return this.stakers;
}
public String getKgf() {
return this.kgf;
public String getKff() {
return this.kff;
}
public String getKir() {
return this.kir;
public String getKcf() {
return this.kcf;
}
public Map<String,String> getRewards() {
return this.rewards;
Expand All @@ -111,8 +112,8 @@ public int hashCode() {
result = prime * result + ((burntFee == null) ? 0 : burntFee.hashCode());
result = prime * result + ((proposer == null) ? 0 : proposer.hashCode());
result = prime * result + ((stakers == null) ? 0 : stakers.hashCode());
result = prime * result + ((kgf == null) ? 0 : kgf.hashCode());
result = prime * result + ((kir == null) ? 0 : kir.hashCode());
result = prime * result + ((kff == null) ? 0 : kff.hashCode());
result = prime * result + ((kcf == null) ? 0 : kcf.hashCode());
result = prime * result + ((rewards == null) ? 0 : rewards.hashCode());
return result;
}
Expand Down Expand Up @@ -150,15 +151,15 @@ public boolean equals(Object obj) {
return false;
} else if (!stakers.equals(other.stakers))
return false;
if (kgf == null) {
if (other.kgf != null)
if (kff == null) {
if (other.kff != null)
return false;
} else if (!kgf.equals(other.kgf))
} else if (!kff.equals(other.kff))
return false;
if (kir == null) {
if (other.kir != null)
if (kcf == null) {
if (other.kcf != null)
return false;
} else if (!kir.equals(other.kir))
} else if (!kcf.equals(other.kcf))
return false;
if (rewards == null) {
if (other.rewards != null)
Expand Down
129 changes: 129 additions & 0 deletions core/src/main/java/com/klaytn/caver/rpc/Governance.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,55 @@ public Request<?, GovernanceChainConfig> getChainConfig() {
return getChainConfigAt(DefaultBlockParameterName.LATEST);
}

/**
* Provides the chain configuration at the specified block number
* <pre>Example :
* {@code
* GovernanceChainConfig response = caver.rpc.governance.getChainConfig(BigInteger.ZERO).send();
* }
* </pre>
* @return Request&lt;?, GovernanceChainConfig&gt;
*/
public Request<?, GovernanceChainConfig> getChainConfig(BigInteger blockNumber) {
return getChainConfig(DefaultBlockParameter.valueOf(blockNumber));
}

/**
* Provides the chain configuration by block tag (latest, earliest, pending)
* <pre>Example :
* {@code
* GovernanceChainConfig response = caver.rpc.governance.getChainConfig("latest").send();
* }
* </pre>
* @return Request&lt;?, GovernanceChainConfig&gt;
*/
public Request<?, GovernanceChainConfig> getChainConfig(String blockTag) {
return getChainConfig(DefaultBlockParameterName.fromString(blockTag));
}

/**
* Provides the chain configuration by block tag (latest, earliest, pending)
* <pre>Example :
* {@code
* GovernanceChainConfig response = caver.rpc.governance.getChainConfig(DefaultBlockParameterName.LATEST).send();
*
* String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
* }
* </pre>
* @return Request&lt;?, GovernanceChainConfig&gt;
*/
public Request<?, GovernanceChainConfig> getChainConfig(DefaultBlockParameterName blockTag) {
return getChainConfig((DefaultBlockParameter)blockTag);
}
public Request<?, GovernanceChainConfig> getChainConfig(DefaultBlockParameter blockNumberOrTag) {
return new Request<>(
"governance_getChainConfig",
Arrays.asList(blockNumberOrTag),
provider,
GovernanceChainConfig.class
);
}

/**
* Provides the chain configuration at the specified block number
* <pre>Example :
Expand Down Expand Up @@ -338,6 +387,86 @@ public Request<?, Bytes20> getNodeAddress() {
);
}

/**
* Returns governance items at specific block.<p>
* It is the result of previous voting of the block and used as configuration for chain at the given block number.<p>
* It pass the latest block tag as a parameter.
* <pre>Example :
* {@code
* GovernanceItems response = caver.rpc.governance.getParams().send();
* Map<String, Object> governanceItem = response.getResult();
*
* String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
* }</pre>
* @return Request&lt;?, Bytes20&gt;
*/
public Request<?, GovernanceItems> getParams() {
return getParams(DefaultBlockParameterName.LATEST);
}

/**
* Returns governance items at specific block.<p>
* It is the result of previous voting of the block and used as configuration for chain at the given block number.
* <pre>Example :
* {@code
* GovernanceItems response = caver.rpc.governance.getParams(BigInteger.ZERO).send();
* Map<String, Object> governanceItem = response.getResult();
*
* String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
* }</pre>
* @param blockNumber The block number to query.
* @return Request&lt;?, GovernanceItems&gt;
*/
public Request<?, GovernanceItems> getParams(BigInteger blockNumber) {
return getParams(DefaultBlockParameter.valueOf(blockNumber));
}

/**
* Returns governance items at specific block.<p>
* It is the result of previous voting of the block and used as configuration for chain at the given block number.
* <pre>Example :
* {@code
* GovernanceItems response = caver.rpc.governance.getParams("latest").send();
* Map<String, Object> governanceItem = response.getResult();
*
* String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
* }
* </pre>
* @param blockTag The block tag to query
* @return Request&lt;?, GovernanceItems&gt;
*/
public Request<?, GovernanceItems> getParams(String blockTag) {
DefaultBlockParameterName blockTagName = DefaultBlockParameterName.fromString(blockTag);
return getParams(blockTagName);
}

/**
* Returns governance items at specific block.<p>
* It is the result of previous voting of the block and used as configuration for chain at the given block number.
* <pre>Example :
* {@code
* GovernanceItems response = caver.rpc.governance.getParams(DefaultBlockParameterName.LATEST).send();
* Map<String, Object> governanceItem = response.getResult();
*
* String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
* }
* </pre>
* @param blockTag The block tag to query
* @return Request&lt;?, GovernanceItems&gt;
*/
public Request<?, GovernanceItems> getParams(DefaultBlockParameterName blockTag) {
return getParams((DefaultBlockParameter)blockTag);
}

Request<?, GovernanceItems> getParams(DefaultBlockParameter blockParameter) {
return new Request<>(
"governance_getParams",
Arrays.asList(blockParameter.getValue()),
provider,
GovernanceItems.class
);
}

/**
* Returns governance items at specific block.<p>
* It is the result of previous voting of the block and used as configuration for chain at the given block number.<p>
Expand Down
Loading

0 comments on commit 65905e6

Please sign in to comment.