From 1542e825fe52026f9f4baaaa10e11a29eec5bf86 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 24 Oct 2023 13:17:48 +0300 Subject: [PATCH] [#45] nns: Fix inconsistent fee of register operations Signed-off-by: Alex Vanin --- nns/nns_contract.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 8b739c3..2b4b898 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -458,13 +458,13 @@ func updateBalance(ctx storage.Context, tokenId []byte, acc interop.Hash160, dif balanceKey := append([]byte{prefixBalance}, acc...) var balance int if b := storage.Get(ctx, balanceKey); b != nil { - balance = b.(int) + balance = common.FromFixedWidth64(b.([]byte)) } balance += diff if balance == 0 { storage.Delete(ctx, balanceKey) } else { - storage.Put(ctx, balanceKey, balance) + storage.Put(ctx, balanceKey, common.ToFixedWidth64(balance)) } tokenKey := getTokenKey(tokenId) @@ -488,14 +488,14 @@ func postTransfer(from, to interop.Hash160, tokenID []byte, data interface{}) { // getTotalSupply returns total supply from storage. func getTotalSupply(ctx storage.Context) int { val := storage.Get(ctx, []byte{prefixTotalSupply}) - return val.(int) + return common.FromFixedWidth64(val.([]byte)) } // updateTotalSupply adds the specified diff to the total supply. func updateTotalSupply(ctx storage.Context, diff int) { tsKey := []byte{prefixTotalSupply} ts := getTotalSupply(ctx) - storage.Put(ctx, tsKey, ts+diff) + storage.Put(ctx, tsKey, common.ToFixedWidth64(ts+diff)) } // getTokenKey computes hash160 from the given tokenID.