-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TCK): Implement Account Update/Delete (#1988)
Signed-off-by: Ivan Ivanov <[email protected]>
- Loading branch information
Showing
4 changed files
with
209 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/AccountDeleteParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.hedera.hashgraph.tck.methods.sdk.param; | ||
|
||
import com.hedera.hashgraph.tck.methods.JSONRPC2Param; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import net.minidev.json.JSONObject; | ||
|
||
/** | ||
* AccountDeleteParams for account delete method | ||
*/ | ||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AccountDeleteParams extends JSONRPC2Param { | ||
private Optional<String> deleteAccountId; | ||
private Optional<String> transferAccountId; | ||
private Optional<CommonTransactionParams> commonTransactionParams; | ||
|
||
@Override | ||
public AccountDeleteParams parse(Map<String, Object> jrpcParams) throws ClassCastException { | ||
var parsedDeleteAccountId = Optional.ofNullable((String) jrpcParams.get("deleteAccountId")); | ||
var parsedTransferAccountId = Optional.ofNullable((String) jrpcParams.get("transferAccountId")); | ||
|
||
Optional<CommonTransactionParams> parsedCommonTransactionParams = Optional.empty(); | ||
if (jrpcParams.containsKey("commonTransactionParams")) { | ||
JSONObject jsonObject = (JSONObject) jrpcParams.get("commonTransactionParams"); | ||
parsedCommonTransactionParams = Optional.of(CommonTransactionParams.parse(jsonObject)); | ||
} | ||
|
||
return new AccountDeleteParams(parsedDeleteAccountId, parsedTransferAccountId, parsedCommonTransactionParams); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/AccountUpdateParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.hedera.hashgraph.tck.methods.sdk.param; | ||
|
||
import com.hedera.hashgraph.tck.methods.JSONRPC2Param; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import net.minidev.json.JSONObject; | ||
|
||
/** | ||
* AccountUpdateParams for account update method | ||
*/ | ||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AccountUpdateParams extends JSONRPC2Param { | ||
private Optional<String> key; | ||
private Optional<Boolean> receiverSignatureRequired; | ||
private Optional<Long> autoRenewPeriod; | ||
private Optional<String> memo; | ||
private Optional<Long> expirationTime; | ||
private Optional<Long> maxAutoTokenAssociations; | ||
private Optional<String> stakedAccountId; | ||
private Optional<String> accountId; | ||
private Optional<Long> stakedNodeId; | ||
private Optional<Boolean> declineStakingReward; | ||
private Optional<CommonTransactionParams> commonTransactionParams; | ||
|
||
@Override | ||
public AccountUpdateParams parse(Map<String, Object> jrpcParams) throws ClassCastException { | ||
var parsedKey = Optional.ofNullable((String) jrpcParams.get("key")); | ||
var parsedReceiverSignatureRequired = | ||
Optional.ofNullable((Boolean) jrpcParams.get("receiverSignatureRequired")); | ||
var parsedAutoRenewPeriod = Optional.ofNullable((Long) jrpcParams.get("autoRenewPeriod")); | ||
var parsedMemo = Optional.ofNullable((String) jrpcParams.get("memo")); | ||
var parsedMaxAutoTokenAssociations = Optional.ofNullable((Long) jrpcParams.get("maxAutoTokenAssociations")); | ||
var parsedStakedAccountId = Optional.ofNullable((String) jrpcParams.get("stakedAccountId")); | ||
var parsedAccountId = Optional.ofNullable((String) jrpcParams.get("accountId")); | ||
var parsedStakedNodeId = Optional.ofNullable((Long) jrpcParams.get("stakedNodeId")); | ||
var parsedExpirationTime = Optional.ofNullable((Long) jrpcParams.get("expirationTime")); | ||
var parsedDeclineStakingReward = Optional.ofNullable((Boolean) jrpcParams.get("declineStakingReward")); | ||
Optional<CommonTransactionParams> parsedCommonTransactionParams = Optional.empty(); | ||
if (jrpcParams.containsKey("commonTransactionParams")) { | ||
JSONObject jsonObject = (JSONObject) jrpcParams.get("commonTransactionParams"); | ||
parsedCommonTransactionParams = Optional.of(CommonTransactionParams.parse(jsonObject)); | ||
} | ||
|
||
return new AccountUpdateParams( | ||
parsedKey, | ||
parsedReceiverSignatureRequired, | ||
parsedAutoRenewPeriod, | ||
parsedMemo, | ||
parsedExpirationTime, | ||
parsedMaxAutoTokenAssociations, | ||
parsedStakedAccountId, | ||
parsedAccountId, | ||
parsedStakedNodeId, | ||
parsedDeclineStakingReward, | ||
parsedCommonTransactionParams); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters