core: remove NEP17BalanceState if balance is null [addTokens]

Affects states.
This commit is contained in:
Anna Shaleva 2021-02-12 23:23:24 +03:00
parent 0f1473897b
commit 4893faa374

View file

@ -258,13 +258,19 @@ func (c *nep17TokenNative) addTokens(ic *interop.Context, h util.Uint160, amount
if err := c.incBalance(ic, h, si, amount); err != nil { if err := c.incBalance(ic, h, si, amount); err != nil {
panic(err) panic(err)
} }
if err := ic.DAO.PutStorageItem(c.ID, key, si); err != nil { var err error
if si.Value == nil {
err = ic.DAO.DeleteStorageItem(c.ID, key)
} else {
err = ic.DAO.PutStorageItem(c.ID, key, si)
}
if err != nil {
panic(err) panic(err)
} }
supply := c.getTotalSupply(ic.DAO) supply := c.getTotalSupply(ic.DAO)
supply.Add(supply, amount) supply.Add(supply, amount)
err := c.saveTotalSupply(ic.DAO, supply) err = c.saveTotalSupply(ic.DAO, supply)
if err != nil { if err != nil {
panic(err) panic(err)
} }