Search in sources :

Example 1 with HapiGetContractInfo

use of com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo in project hedera-services by hashgraph.

the class TxnUtils method currContractExpiry.

public static Timestamp currContractExpiry(String contract, HapiApiSpec spec) throws Throwable {
    HapiGetContractInfo subOp = getContractInfo(contract).noLogging();
    Optional<Throwable> error = subOp.execFor(spec);
    if (error.isPresent()) {
        log.error("Unable to look up current expiration timestamp of contract 0.0." + spec.registry().getContractId(contract).getContractNum());
        throw error.get();
    }
    return subOp.getResponse().getContractGetInfo().getContractInfo().getExpirationTime();
}
Also used : HapiGetContractInfo(com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo)

Example 2 with HapiGetContractInfo

use of com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo in project hedera-services by hashgraph.

the class HapiTokenAssociate method lookupExpiry.

private long lookupExpiry(HapiApiSpec spec) throws Throwable {
    if (!spec.registry().hasContractId(account)) {
        HapiGetAccountInfo subOp = getAccountInfo(account).noLogging();
        Optional<Throwable> error = subOp.execFor(spec);
        if (error.isPresent()) {
            if (!loggingOff) {
                log.warn("Unable to look up current info for " + HapiPropertySource.asAccountString(spec.registry().getAccountID(account)), error.get());
            }
            throw error.get();
        }
        return subOp.getResponse().getCryptoGetInfo().getAccountInfo().getExpirationTime().getSeconds();
    } else {
        HapiGetContractInfo subOp = getContractInfo(account).noLogging();
        Optional<Throwable> error = subOp.execFor(spec);
        if (error.isPresent()) {
            if (!loggingOff) {
                log.warn("Unable to look up current info for " + HapiPropertySource.asContractString(spec.registry().getContractId(account)), error.get());
            }
            throw error.get();
        }
        return subOp.getResponse().getContractGetInfo().getContractInfo().getExpirationTime().getSeconds();
    }
}
Also used : HapiGetContractInfo(com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo) HapiGetAccountInfo(com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo)

Aggregations

HapiGetContractInfo (com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo)2 HapiGetAccountInfo (com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo)1