From a79df9f2348f7629f59e1f5601eae88872ad3265 Mon Sep 17 00:00:00 2001 From: Georgi Lazarov Date: Wed, 20 Sep 2023 15:36:20 +0300 Subject: [PATCH] Fix fee calculation for TokenWipe and TokenBurn (#8761) This PR adds logic to the fee calculation for TokenWipe and TokenBurn to check for token type, which will be then used for selection from the feeDataMap Signed-off-by: georgi-l95 --- .../token/impl/handlers/TokenAccountWipeHandler.java | 8 +++++++- .../app/service/token/impl/handlers/TokenBurnHandler.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAccountWipeHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAccountWipeHandler.java index b80c5e76de10..157d1cfd6fc3 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAccountWipeHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAccountWipeHandler.java @@ -194,9 +194,15 @@ public void handle(@NonNull final HandleContext context) throws HandleException @Override public Fees calculateFees(@NonNull final FeeContext feeContext) { final var op = feeContext.body(); + final var readableTokenStore = feeContext.readableStore(ReadableTokenStore.class); + final var tokenType = + readableTokenStore.get(op.tokenWipeOrThrow().tokenOrThrow()).tokenType(); final var meta = TOKEN_OPS_USAGE_UTILS.tokenWipeUsageFrom(fromPbj(op)); return feeContext - .feeCalculator(SubType.DEFAULT) + .feeCalculator( + tokenType.equals(TokenType.FUNGIBLE_COMMON) + ? SubType.TOKEN_FUNGIBLE_COMMON + : SubType.TOKEN_NON_FUNGIBLE_UNIQUE) .addBytesPerTransaction(meta.getBpt()) .addNetworkRamByteSeconds(meta.getTransferRecordDb() * USAGE_PROPERTIES.legacyReceiptStorageSecs()) .calculate(); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenBurnHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenBurnHandler.java index 46388412dcf9..2d8d9513eb21 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenBurnHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenBurnHandler.java @@ -158,9 +158,15 @@ public void handle(@NonNull final HandleContext context) throws HandleException @Override public Fees calculateFees(@NonNull final FeeContext feeContext) { final var op = feeContext.body(); + final var readableTokenStore = feeContext.readableStore(ReadableTokenStore.class); + final var tokenType = + readableTokenStore.get(op.tokenBurnOrThrow().tokenOrThrow()).tokenType(); final var meta = TOKEN_OPS_USAGE_UTILS.tokenBurnUsageFrom(fromPbj(op)); return feeContext - .feeCalculator(SubType.DEFAULT) + .feeCalculator( + tokenType.equals(TokenType.FUNGIBLE_COMMON) + ? SubType.TOKEN_FUNGIBLE_COMMON + : SubType.TOKEN_NON_FUNGIBLE_UNIQUE) .addBytesPerTransaction(meta.getBpt()) .addNetworkRamByteSeconds(meta.getTransferRecordDb() * USAGE_PROPERTIES.legacyReceiptStorageSecs()) .calculate();