Skip to content

Commit

Permalink
Fix fee calculation for TokenWipe and TokenBurn (#8761)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
georgi-l95 authored Sep 20, 2023
1 parent bb0e078 commit a79df9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a79df9f

Please sign in to comment.