native: make mint/burn for 0 no-ops

Prevent emitting useless transfer events and doing useless gets/puts.
This commit is contained in:
Roman Khimov 2020-06-04 15:41:54 +03:00
parent fed95e0069
commit a9955719da

View file

@ -208,11 +208,17 @@ func (c *nep5TokenNative) balanceOf(ic *interop.Context, args []vm.StackItem) vm
}
func (c *nep5TokenNative) mint(ic *interop.Context, h util.Uint160, amount *big.Int) {
if amount.Sign() == 0 {
return
}
c.addTokens(ic, h, amount)
c.emitTransfer(ic, nil, &h, amount)
}
func (c *nep5TokenNative) burn(ic *interop.Context, h util.Uint160, amount *big.Int) {
if amount.Sign() == 0 {
return
}
amount = new(big.Int).Neg(amount)
c.addTokens(ic, h, amount)
c.emitTransfer(ic, &h, nil, amount)