From 20b74b038f23b56b7ecf66b967beed7c51c29378 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 19 Dec 2024 22:36:20 +0300 Subject: [PATCH] native: support callflags-based native method after HFEchidna Close #3702 Signed-off-by: Ekaterina Pavlova --- pkg/core/native/native_neo.go | 15 ++++++++++++--- pkg/interop/native/neo/neo.go | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 9978e0b97..d4e507826 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -192,18 +192,27 @@ func newNEO(cfg config.ProtocolConfiguration) *NEO { desc = newDescriptor("registerCandidate", smartcontract.BoolType, manifest.NewParameter("pubkey", smartcontract.PublicKeyType)) - md = newMethodAndPrice(n.registerCandidate, 0, callflag.States) + md = newMethodAndPrice(n.registerCandidate, 0, callflag.States, config.HFDefault, config.HFEchidna) + n.AddMethod(md, desc) + + md = newMethodAndPrice(n.registerCandidate, 0, callflag.States|callflag.AllowNotify, config.HFEchidna) n.AddMethod(md, desc) desc = newDescriptor("unregisterCandidate", smartcontract.BoolType, manifest.NewParameter("pubkey", smartcontract.PublicKeyType)) - md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States) + md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States, config.HFDefault, config.HFEchidna) + n.AddMethod(md, desc) + + md = newMethodAndPrice(n.unregisterCandidate, 1<<16, callflag.States|callflag.AllowNotify, config.HFEchidna) n.AddMethod(md, desc) desc = newDescriptor("vote", smartcontract.BoolType, manifest.NewParameter("account", smartcontract.Hash160Type), manifest.NewParameter("voteTo", smartcontract.PublicKeyType)) - md = newMethodAndPrice(n.vote, 1<<16, callflag.States) + md = newMethodAndPrice(n.vote, 1<<16, callflag.States, config.HFDefault, config.HFEchidna) + n.AddMethod(md, desc) + + md = newMethodAndPrice(n.vote, 1<<16, callflag.States|callflag.AllowNotify, config.HFEchidna) n.AddMethod(md, desc) desc = newDescriptor("getCandidates", smartcontract.ArrayType) diff --git a/pkg/interop/native/neo/neo.go b/pkg/interop/native/neo/neo.go index d536edd74..239ad266a 100644 --- a/pkg/interop/native/neo/neo.go +++ b/pkg/interop/native/neo/neo.go @@ -104,17 +104,17 @@ func SetRegisterPrice(amount int) { // RegisterCandidate represents `registerCandidate` method of NEO native contract. func RegisterCandidate(pub interop.PublicKey) bool { - return neogointernal.CallWithToken(Hash, "registerCandidate", int(contract.States), pub).(bool) + return neogointernal.CallWithToken(Hash, "registerCandidate", int(contract.States|contract.AllowNotify), pub).(bool) } // UnregisterCandidate represents `unregisterCandidate` method of NEO native contract. func UnregisterCandidate(pub interop.PublicKey) bool { - return neogointernal.CallWithToken(Hash, "unregisterCandidate", int(contract.States), pub).(bool) + return neogointernal.CallWithToken(Hash, "unregisterCandidate", int(contract.States|contract.AllowNotify), pub).(bool) } // Vote represents `vote` method of NEO native contract. func Vote(addr interop.Hash160, pub interop.PublicKey) bool { - return neogointernal.CallWithToken(Hash, "vote", int(contract.States), addr, pub).(bool) + return neogointernal.CallWithToken(Hash, "vote", int(contract.States|contract.AllowNotify), addr, pub).(bool) } // UnclaimedGAS represents `unclaimedGas` method of NEO native contract.