use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class CryptoApproveAllowanceTransitionLogic method validate.
private ResponseCodeEnum validate(TransactionBody cryptoAllowanceTxn) {
final AccountID payer = cryptoAllowanceTxn.getTransactionID().getAccountID();
final var op = cryptoAllowanceTxn.getCryptoApproveAllowance();
final var payerAccount = accountStore.loadAccount(Id.fromGrpcAccount(payer));
return allowanceChecks.allowancesValidation(op.getCryptoAllowancesList(), op.getTokenAllowancesList(), op.getNftAllowancesList(), payerAccount, dynamicProperties.maxAllowanceLimitPerTransaction());
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class DecodingFacade method bindFungibleTransfersFrom.
private List<SyntheticTxnFactory.FungibleTokenTransfer> bindFungibleTransfersFrom(final TokenID tokenType, final Tuple[] abiTransfers, final UnaryOperator<byte[]> aliasResolver) {
final List<SyntheticTxnFactory.FungibleTokenTransfer> fungibleTransfers = new ArrayList<>();
for (final var transfer : abiTransfers) {
final AccountID accountID = convertLeftPaddedAddressToAccountId((byte[]) transfer.get(0), aliasResolver);
final long amount = (long) transfer.get(1);
addAdjustmentAsTransfer(fungibleTransfers, tokenType, accountID, amount);
}
return fungibleTransfers;
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class MerkleTopicTest method topicFrom.
private MerkleTopic topicFrom(int s) throws IOException {
long v = 1_234_567L + s * 1_000_000L;
long t = s + 1;
AccountID payer = AccountID.newBuilder().setAccountNum(123).build();
TopicID id = TopicID.newBuilder().setTopicNum(s).build();
var topic = new MerkleTopic(memos[s], adminKeys[s], submitKeys[s], v, new EntityId(t, t * 2, t * 3), new RichInstant(v, s));
for (int i = 0; i < s; i++) {
topic.updateRunningHashAndSequenceNumber(payer, "Hello world!".getBytes(), id, Instant.ofEpochSecond(v, i));
}
topic.setKey(EntityNum.fromInt(s));
return topic;
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class HapiCryptoDelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
AccountID target;
if (referenceType == ReferenceType.REGISTRY_NAME) {
target = TxnUtils.asId(account, spec);
} else {
account = lookUpAccountWithAlias(spec, aliasKeySource);
target = asAccount(account);
}
CryptoDeleteTransactionBody opBody = spec.txns().<CryptoDeleteTransactionBody, CryptoDeleteTransactionBody.Builder>body(CryptoDeleteTransactionBody.class, b -> {
transferAccount.ifPresent(a -> b.setTransferAccountID(spec.registry().getAccountID(a)));
b.setDeleteAccountID(target);
});
return b -> b.setCryptoDelete(opBody);
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class HapiCryptoUpdate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
try {
updKey = updKeyName.map(spec.registry()::getKey);
} catch (Exception ignore) {
}
AccountID id;
if (referenceType == ReferenceType.REGISTRY_NAME) {
id = TxnUtils.asId(account, spec);
} else {
id = asIdForKeyLookUp(aliasKeySource, spec);
account = asAccountString(id);
}
CryptoUpdateTransactionBody opBody = spec.txns().<CryptoUpdateTransactionBody, CryptoUpdateTransactionBody.Builder>body(CryptoUpdateTransactionBody.class, builder -> {
builder.setAccountIDToUpdate(id);
newProxy.ifPresent(p -> {
var proxyId = TxnUtils.asId(p, spec);
builder.setProxyAccountID(proxyId);
});
updSigRequired.ifPresent(u -> builder.setReceiverSigRequiredWrapper(BoolValue.of(u)));
if (useContractKey) {
builder.setKey(Key.newBuilder().setContractID(HapiPropertySource.asContract("0.0.1234")));
} else {
updKey.ifPresent(builder::setKey);
}
newAutoRenewPeriod.ifPresent(p -> builder.setAutoRenewPeriod(Duration.newBuilder().setSeconds(p)));
entityMemo.ifPresent(m -> builder.setMemo(StringValue.newBuilder().setValue(m).build()));
sendThreshold.ifPresent(v -> builder.setSendRecordThresholdWrapper(UInt64Value.newBuilder().setValue(v).build()));
newExpiry.ifPresent(l -> builder.setExpirationTime(Timestamp.newBuilder().setSeconds(l).build()));
newMaxAutomaticAssociations.ifPresent(p -> builder.setMaxAutomaticTokenAssociations(Int32Value.of(p)));
});
return builder -> builder.setCryptoUpdateAccount(opBody);
}
Aggregations