Search in sources :

Example 6 with TokenId

use of com.hedera.mirror.common.domain.token.TokenId in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTokenTest method nonEmptyCustomFees.

private static List<CustomFee> nonEmptyCustomFees(long consensusTimestamp, EntityId tokenId, TokenType tokenType) {
    List<CustomFee> customFees = new ArrayList<>();
    CustomFee.Id id = new CustomFee.Id(consensusTimestamp, tokenId);
    EntityId treasury = EntityId.of(PAYER);
    CustomFee fixedFee1 = new CustomFee();
    fixedFee1.setAmount(11L);
    fixedFee1.setCollectorAccountId(FEE_COLLECTOR_ACCOUNT_ID_1);
    fixedFee1.setId(id);
    customFees.add(fixedFee1);
    CustomFee fixedFee2 = new CustomFee();
    fixedFee2.setAmount(12L);
    fixedFee2.setCollectorAccountId(FEE_COLLECTOR_ACCOUNT_ID_2);
    fixedFee2.setDenominatingTokenId(FEE_DOMAIN_TOKEN_ID);
    fixedFee2.setId(id);
    customFees.add(fixedFee2);
    CustomFee fixedFee3 = new CustomFee();
    fixedFee3.setAmount(13L);
    fixedFee3.setCollectorAccountId(FEE_COLLECTOR_ACCOUNT_ID_2);
    fixedFee3.setDenominatingTokenId(tokenId);
    fixedFee3.setId(id);
    customFees.add(fixedFee3);
    if (tokenType == FUNGIBLE_COMMON) {
        // fractional fees only apply for fungible tokens
        CustomFee fractionalFee1 = new CustomFee();
        fractionalFee1.setAmount(14L);
        fractionalFee1.setAmountDenominator(31L);
        fractionalFee1.setCollectorAccountId(FEE_COLLECTOR_ACCOUNT_ID_3);
        fractionalFee1.setMaximumAmount(100L);
        fractionalFee1.setNetOfTransfers(true);
        fractionalFee1.setId(id);
        customFees.add(fractionalFee1);
        CustomFee fractionalFee2 = new CustomFee();
        fractionalFee2.setAmount(15L);
        fractionalFee2.setAmountDenominator(32L);
        fractionalFee2.setCollectorAccountId(treasury);
        fractionalFee2.setMaximumAmount(110L);
        fractionalFee2.setNetOfTransfers(false);
        fractionalFee2.setId(id);
        customFees.add(fractionalFee2);
    } else {
        // royalty fees only apply for non-fungible tokens
        CustomFee royaltyFee1 = new CustomFee();
        royaltyFee1.setRoyaltyNumerator(14L);
        royaltyFee1.setRoyaltyDenominator(31L);
        royaltyFee1.setCollectorAccountId(FEE_COLLECTOR_ACCOUNT_ID_3);
        royaltyFee1.setId(id);
        customFees.add(royaltyFee1);
        // with fallback fee
        CustomFee royaltyFee2 = new CustomFee();
        royaltyFee2.setRoyaltyNumerator(15L);
        royaltyFee2.setRoyaltyDenominator(32L);
        royaltyFee2.setCollectorAccountId(treasury);
        // fallback fee in form of fixed fee
        royaltyFee2.setAmount(103L);
        royaltyFee2.setDenominatingTokenId(FEE_DOMAIN_TOKEN_ID);
        royaltyFee2.setId(id);
        customFees.add(royaltyFee2);
    }
    return customFees;
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) CustomFee(com.hedera.mirror.common.domain.transaction.CustomFee) AssessedCustomFee(com.hedera.mirror.common.domain.transaction.AssessedCustomFee) ArrayList(java.util.ArrayList) EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenId(com.hedera.mirror.common.domain.token.TokenId) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) NftId(com.hedera.mirror.common.domain.token.NftId) TokenAccountId(com.hedera.mirror.common.domain.token.TokenAccountId)

Example 7 with TokenId

use of com.hedera.mirror.common.domain.token.TokenId in project hedera-mirror-node by hashgraph.

the class BatchUpserterTest method getToken.

@SneakyThrows
private Token getToken(String tokenId, String treasuryAccountId, Long createdTimestamp, Boolean freezeDefault, Key freezeKey, Key kycKey, Key pauseKey) {
    var instr = "0011223344556677889900aabbccddeeff0011223344556677889900aabbccddeeff";
    var hexKey = Key.newBuilder().setEd25519(ByteString.copyFrom(Hex.decodeHex(instr))).build().toByteArray();
    Token token = new Token();
    token.setCreatedTimestamp(createdTimestamp);
    token.setDecimals(1000);
    token.setFreezeDefault(freezeDefault);
    token.setFreezeKey(freezeKey != null ? freezeKey.toByteArray() : null);
    token.setInitialSupply(1_000_000_000L);
    token.setKycKey(kycKey != null ? kycKey.toByteArray() : null);
    token.setPauseKey(pauseKey != null ? pauseKey.toByteArray() : null);
    token.setPauseStatus(pauseKey != null ? TokenPauseStatusEnum.UNPAUSED : TokenPauseStatusEnum.NOT_APPLICABLE);
    token.setMaxSupply(1_000_000_000L);
    token.setModifiedTimestamp(3L);
    token.setName("FOO COIN TOKEN" + tokenId);
    token.setSupplyKey(hexKey);
    token.setSupplyType(TokenSupplyTypeEnum.INFINITE);
    token.setSymbol("FOOTOK" + tokenId);
    token.setTokenId(new TokenId(EntityId.of(tokenId, TOKEN)));
    token.setTreasuryAccountId(EntityId.of(treasuryAccountId, ACCOUNT));
    token.setType(TokenTypeEnum.FUNGIBLE_COMMON);
    token.setWipeKey(hexKey);
    return token;
}
Also used : Token(com.hedera.mirror.common.domain.token.Token) TokenId(com.hedera.mirror.common.domain.token.TokenId) SneakyThrows(lombok.SneakyThrows)

Example 8 with TokenId

use of com.hedera.mirror.common.domain.token.TokenId in project hedera-mirror-node by hashgraph.

the class SqlEntityListenerTest method getToken.

private Token getToken(EntityId tokenId, EntityId accountId, Long createdTimestamp, long modifiedTimestamp, Integer decimals, Boolean freezeDefault, Key freezeKey, Long initialSupply, Key kycKey, String name, Key supplyKey, String symbol, Key wipeKey, Key pauseKey, TokenPauseStatusEnum pauseStatus) {
    Token token = new Token();
    token.setCreatedTimestamp(createdTimestamp);
    token.setDecimals(decimals);
    token.setFreezeDefault(freezeDefault);
    token.setFreezeKey(freezeKey != null ? freezeKey.toByteArray() : null);
    token.setInitialSupply(initialSupply);
    token.setKycKey(kycKey != null ? kycKey.toByteArray() : null);
    token.setMaxSupply(0L);
    token.setModifiedTimestamp(modifiedTimestamp);
    token.setName(name);
    token.setPauseKey(pauseKey != null ? pauseKey.toByteArray() : null);
    token.setPauseStatus(pauseStatus);
    token.setSupplyKey(supplyKey != null ? supplyKey.toByteArray() : null);
    token.setSupplyType(TokenSupplyTypeEnum.INFINITE);
    token.setSymbol(symbol);
    token.setTokenId(new TokenId(tokenId));
    token.setType(TokenTypeEnum.FUNGIBLE_COMMON);
    token.setTreasuryAccountId(accountId);
    token.setWipeKey(wipeKey != null ? wipeKey.toByteArray() : null);
    return token;
}
Also used : Token(com.hedera.mirror.common.domain.token.Token) TokenId(com.hedera.mirror.common.domain.token.TokenId)

Aggregations

TokenId (com.hedera.mirror.common.domain.token.TokenId)8 Token (com.hedera.mirror.common.domain.token.Token)5 EntityId (com.hedera.mirror.common.domain.entity.EntityId)3 NftTransferId (com.hedera.mirror.common.domain.token.NftTransferId)2 AssessedCustomFee (com.hedera.mirror.common.domain.transaction.AssessedCustomFee)2 CustomFee (com.hedera.mirror.common.domain.transaction.CustomFee)2 SneakyThrows (lombok.SneakyThrows)2 NftId (com.hedera.mirror.common.domain.token.NftId)1 TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)1 TokenAccountId (com.hedera.mirror.common.domain.token.TokenAccountId)1 TokenFreezeStatusEnum (com.hedera.mirror.common.domain.token.TokenFreezeStatusEnum)1 TokenKycStatusEnum (com.hedera.mirror.common.domain.token.TokenKycStatusEnum)1 InvalidDatasetException (com.hedera.mirror.importer.exception.InvalidDatasetException)1 TokenAssociation (com.hederahashgraph.api.proto.java.TokenAssociation)1 TokenCreateTransactionBody (com.hederahashgraph.api.proto.java.TokenCreateTransactionBody)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1