Search in sources :

Example 26 with AccountID

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());
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID)

Example 27 with AccountID

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;
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) ArrayList(java.util.ArrayList)

Example 28 with AccountID

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;
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) AccountID(com.hederahashgraph.api.proto.java.AccountID) TopicID(com.hederahashgraph.api.proto.java.TopicID) RichInstant(com.hedera.services.state.submerkle.RichInstant)

Example 29 with AccountID

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);
}
Also used : CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) ReferenceType(com.hedera.services.bdd.spec.queries.crypto.ReferenceType) AccountID(com.hederahashgraph.api.proto.java.AccountID) LogManager(org.apache.logging.log4j.LogManager) HapiPropertySource.asAccount(com.hedera.services.bdd.spec.HapiPropertySource.asAccount) QueryUtils.lookUpAccountWithAlias(com.hedera.services.bdd.spec.queries.QueryUtils.lookUpAccountWithAlias) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody)

Example 30 with AccountID

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);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) BoolValue(com.google.protobuf.BoolValue) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) UInt64Value(com.google.protobuf.UInt64Value) StringValue(com.google.protobuf.StringValue) Duration(com.hederahashgraph.api.proto.java.Duration) Function(java.util.function.Function) TxnUtils.defaultUpdateSigners(com.hedera.services.bdd.spec.transactions.TxnUtils.defaultUpdateSigners) OptionalLong(java.util.OptionalLong) PropertySource.asAccountString(com.hedera.services.bdd.spec.PropertySource.asAccountString) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) CryptoUpdateMeta(com.hedera.services.usage.crypto.CryptoUpdateMeta) ReferenceType(com.hedera.services.bdd.spec.queries.crypto.ReferenceType) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) Int32Value(com.google.protobuf.Int32Value) MoreObjects(com.google.common.base.MoreObjects) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) ExtantCryptoContext(com.hedera.services.usage.crypto.ExtantCryptoContext) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) HapiGetAccountInfo(com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnUtils.asIdForKeyLookUp(com.hedera.services.bdd.spec.transactions.TxnUtils.asIdForKeyLookUp) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)71 Test (org.junit.jupiter.api.Test)24 List (java.util.List)21 ByteString (com.google.protobuf.ByteString)20 Assertions (org.junit.jupiter.api.Assertions)20 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)17 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)16 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)15 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)15 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)15 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)14 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)13 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)13 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)13 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)13 TxnVerbs.mintToken (com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken)13 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)12 QueryVerbs.getScheduleInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo)12