use of com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody in project hedera-services by hashgraph.
the class TokenUpdateTransitionLogic method validate.
public ResponseCodeEnum validate(TransactionBody txnBody) {
TokenUpdateTransactionBody op = txnBody.getTokenUpdate();
if (!op.hasToken()) {
return INVALID_TOKEN_ID;
}
var validity = !op.hasMemo() ? OK : validator.memoCheck(op.getMemo().getValue());
if (validity != OK) {
return validity;
}
var hasNewSymbol = op.getSymbol().length() > 0;
if (hasNewSymbol) {
validity = validator.tokenSymbolCheck(op.getSymbol());
if (validity != OK) {
return validity;
}
}
var hasNewTokenName = op.getName().length() > 0;
if (hasNewTokenName) {
validity = validator.tokenNameCheck(op.getName());
if (validity != OK) {
return validity;
}
}
validity = checkKeys(op.hasAdminKey(), op.getAdminKey(), op.hasKycKey(), op.getKycKey(), op.hasWipeKey(), op.getWipeKey(), op.hasSupplyKey(), op.getSupplyKey(), op.hasFreezeKey(), op.getFreezeKey(), op.hasFeeScheduleKey(), op.getFeeScheduleKey(), op.hasPauseKey(), op.getPauseKey());
if (validity != OK) {
return validity;
}
return validity;
}
use of com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody in project hedera-services by hashgraph.
the class HapiTokenUpdate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
var id = TxnUtils.asTokenId(token, spec);
if (newSymbolFn.isPresent()) {
newSymbol = Optional.of(newSymbolFn.get().apply(spec));
}
if (newNameFn.isPresent()) {
newName = Optional.of(newNameFn.get().apply(spec));
}
TokenUpdateTransactionBody opBody = spec.txns().<TokenUpdateTransactionBody, TokenUpdateTransactionBody.Builder>body(TokenUpdateTransactionBody.class, b -> {
b.setToken(id);
newSymbol.ifPresent(b::setSymbol);
newName.ifPresent(b::setName);
newMemo.ifPresent(s -> b.setMemo(StringValue.newBuilder().setValue(s).build()));
if (useImproperEmptyKey) {
b.setAdminKey(TxnUtils.EMPTY_THRESHOLD_KEY);
} else if (useEmptyAdminKeyList) {
b.setAdminKey(TxnUtils.EMPTY_KEY_LIST);
} else {
newAdminKey.ifPresent(a -> b.setAdminKey(spec.registry().getKey(a)));
}
newTreasury.ifPresent(a -> b.setTreasury(spec.registry().getAccountID(a)));
newSupplyKey.ifPresent(k -> b.setSupplyKey(spec.registry().getKey(k)));
newSupplyKeySupplier.ifPresent(s -> b.setSupplyKey(s.get()));
newWipeKey.ifPresent(k -> b.setWipeKey(spec.registry().getKey(k)));
newKycKey.ifPresent(k -> b.setKycKey(spec.registry().getKey(k)));
if (useInvalidFeeScheduleKey) {
b.setFeeScheduleKey(TxnUtils.EMPTY_THRESHOLD_KEY);
} else {
newFeeScheduleKey.ifPresent(k -> b.setFeeScheduleKey(spec.registry().getKey(k)));
}
newFreezeKey.ifPresent(k -> b.setFreezeKey(spec.registry().getKey(k)));
newPauseKey.ifPresent(k -> b.setPauseKey(spec.registry().getKey(k)));
if (autoRenewAccount.isPresent()) {
var autoRenewId = TxnUtils.asId(autoRenewAccount.get(), spec);
b.setAutoRenewAccount(autoRenewId);
}
expiry.ifPresent(t -> b.setExpiry(Timestamp.newBuilder().setSeconds(t).build()));
autoRenewPeriod.ifPresent(secs -> b.setAutoRenewPeriod(Duration.newBuilder().setSeconds(secs).build()));
});
return b -> b.setTokenUpdate(opBody);
}
use of com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenUpdate.
private void insertTokenUpdate(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
long consensusTimestamp = recordItem.getConsensusTimestamp();
TokenUpdateTransactionBody tokenUpdateTransactionBody = recordItem.getTransactionBody().getTokenUpdate();
Token token = Token.of(EntityId.of(tokenUpdateTransactionBody.getToken()));
if (tokenUpdateTransactionBody.hasFeeScheduleKey()) {
token.setFeeScheduleKey(tokenUpdateTransactionBody.getFeeScheduleKey().toByteArray());
}
if (tokenUpdateTransactionBody.hasFreezeKey()) {
token.setFreezeKey(tokenUpdateTransactionBody.getFreezeKey().toByteArray());
}
if (tokenUpdateTransactionBody.hasKycKey()) {
token.setKycKey(tokenUpdateTransactionBody.getKycKey().toByteArray());
}
if (tokenUpdateTransactionBody.hasPauseKey()) {
token.setPauseKey(tokenUpdateTransactionBody.getPauseKey().toByteArray());
}
if (tokenUpdateTransactionBody.hasSupplyKey()) {
token.setSupplyKey(tokenUpdateTransactionBody.getSupplyKey().toByteArray());
}
if (tokenUpdateTransactionBody.hasTreasury()) {
token.setTreasuryAccountId(EntityId.of(tokenUpdateTransactionBody.getTreasury()));
}
if (tokenUpdateTransactionBody.hasWipeKey()) {
token.setWipeKey(tokenUpdateTransactionBody.getWipeKey().toByteArray());
}
if (!tokenUpdateTransactionBody.getName().isEmpty()) {
token.setName(tokenUpdateTransactionBody.getName());
}
if (!tokenUpdateTransactionBody.getSymbol().isEmpty()) {
token.setSymbol(tokenUpdateTransactionBody.getSymbol());
}
updateToken(token, consensusTimestamp);
}
}
Aggregations