From a0db77247e90992095996204845f7fc38ffb00d1 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 21 Jul 2021 13:44:59 +0300 Subject: [PATCH] [#109] alphabet: Do not emit GAS to `proxy` if notary disabled Signed-off-by: Pavel Karpy --- alphabet/alphabet_contract.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/alphabet/alphabet_contract.go b/alphabet/alphabet_contract.go index e4bf04c..33ae079 100644 --- a/alphabet/alphabet_contract.go +++ b/alphabet/alphabet_contract.go @@ -135,16 +135,21 @@ func Emit() { neo.Transfer(contractHash, contractHash, neo.BalanceOf(contractHash), nil) gasBalance := gas.BalanceOf(contractHash) - proxyAddr := storage.Get(ctx, proxyKey).(interop.Hash160) - proxyGas := gasBalance / 2 - if proxyGas == 0 { - panic("no gas to emit") + if !notaryDisabled { + proxyAddr := storage.Get(ctx, proxyKey).(interop.Hash160) + + proxyGas := gasBalance / 2 + if proxyGas == 0 { + panic("no gas to emit") + } + + gas.Transfer(contractHash, proxyAddr, proxyGas, nil) + gasBalance -= proxyGas + + runtime.Log("utility token has been emitted to proxy contract") } - gas.Transfer(contractHash, proxyAddr, proxyGas, nil) - runtime.Log("utility token has been emitted to proxy contract") - var innerRing []common.IRNode if notaryDisabled { @@ -154,7 +159,7 @@ func Emit() { innerRing = common.InnerRingNodes() } - gasPerNode := gasBalance / 2 * 7 / 8 / len(innerRing) + gasPerNode := gasBalance * 7 / 8 / len(innerRing) if gasPerNode != 0 { for _, node := range innerRing {