From a9955719da79ae1154adc019cf9c9c9d1eb0d479 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 4 Jun 2020 15:41:54 +0300 Subject: [PATCH] native: make mint/burn for 0 no-ops Prevent emitting useless transfer events and doing useless gets/puts. --- pkg/core/native/native_nep5.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/core/native/native_nep5.go b/pkg/core/native/native_nep5.go index e969805cb..eb8c0ef23 100644 --- a/pkg/core/native/native_nep5.go +++ b/pkg/core/native/native_nep5.go @@ -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)