From 2ea27f3a7b6ef5dd6c211ef2b1d6218c4e1f42d5 Mon Sep 17 00:00:00 2001 From: "yumiel.ko" Date: Mon, 24 Jun 2024 08:34:41 +0800 Subject: [PATCH 1/2] set kairos testnet burnt amount correctly for totalSupply api --- reward/supply_manager.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/reward/supply_manager.go b/reward/supply_manager.go index 7f16e4753..300e37d66 100644 --- a/reward/supply_manager.go +++ b/reward/supply_manager.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "math/big" + "strings" "sync" "sync/atomic" @@ -212,11 +213,17 @@ func (sm *supplyManager) GetRebalanceBurn(num uint64, forkNum *big.Int, addr com result := struct { // See system.rebalanceResult struct Burnt *big.Int `json:"burnt"` }{} - if err := json.Unmarshal([]byte(memo), &result); err != nil { - // 4. memo is malformed - return nil, errNoRebalanceBurn(err) - } + if sm.chain.Config().ChainID.Uint64() == 1001 && strings.Contains(memo, "before") { + // correctly set burnt amount for kairos testnet + result.Burnt = new(big.Int) + result.Burnt.SetString("-3704329462904320084000000000", 10) + } else { + if err := json.Unmarshal([]byte(memo), &result); err != nil { + // memo is malformed + return nil, errNoRebalanceBurn(err) + } + } // 2. found the memo sm.memoCache.Add(addr, result.Burnt) return result.Burnt, nil From f1b34a59b4a16902861337f8542e7382b3e102f6 Mon Sep 17 00:00:00 2001 From: "yumiel.ko" Date: Wed, 26 Jun 2024 09:55:00 +0800 Subject: [PATCH 2/2] check memo if it has before prefix at chainid==1001 --- reward/supply_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reward/supply_manager.go b/reward/supply_manager.go index 300e37d66..266a32a37 100644 --- a/reward/supply_manager.go +++ b/reward/supply_manager.go @@ -214,7 +214,7 @@ func (sm *supplyManager) GetRebalanceBurn(num uint64, forkNum *big.Int, addr com Burnt *big.Int `json:"burnt"` }{} - if sm.chain.Config().ChainID.Uint64() == 1001 && strings.Contains(memo, "before") { + if sm.chain.Config().ChainID.Uint64() == 1001 && strings.HasPrefix(memo, "before") { // correctly set burnt amount for kairos testnet result.Burnt = new(big.Int) result.Burnt.SetString("-3704329462904320084000000000", 10)