native: implement HF-based update

A part of #3213.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-03-27 20:48:14 +03:00
parent 83fdcc8568
commit d62fad1268
19 changed files with 416 additions and 105 deletions

View file

@ -172,7 +172,6 @@ func makeValidatorKey(key *keys.PublicKey) []byte {
// newNEO returns NEO native contract.
func newNEO(cfg config.ProtocolConfiguration) *NEO {
n := &NEO{}
defer n.UpdateHash()
nep17 := newNEP17Native(nativenames.Neo, neoContractID)
nep17.symbol = "NEO"
@ -258,27 +257,39 @@ func newNEO(cfg config.ProtocolConfiguration) *NEO {
md = newMethodAndPrice(n.setRegisterPrice, 1<<15, callflag.States)
n.AddMethod(md, desc)
n.AddEvent("CandidateStateChanged",
eDesc := newEventDescriptor("CandidateStateChanged",
manifest.NewParameter("pubkey", smartcontract.PublicKeyType),
manifest.NewParameter("registered", smartcontract.BoolType),
manifest.NewParameter("votes", smartcontract.IntegerType),
)
n.AddEvent("Vote",
eMD := newEvent(eDesc)
n.AddEvent(eMD)
eDesc = newEventDescriptor("Vote",
manifest.NewParameter("account", smartcontract.Hash160Type),
manifest.NewParameter("from", smartcontract.PublicKeyType),
manifest.NewParameter("to", smartcontract.PublicKeyType),
manifest.NewParameter("amount", smartcontract.IntegerType),
)
n.AddEvent("CommitteeChanged",
eMD = newEvent(eDesc)
n.AddEvent(eMD)
eDesc = newEventDescriptor("CommitteeChanged",
manifest.NewParameter("old", smartcontract.ArrayType),
manifest.NewParameter("new", smartcontract.ArrayType),
)
eMD = newEvent(eDesc)
n.AddEvent(eMD)
return n
}
// Initialize initializes a NEO contract.
func (n *NEO) Initialize(ic *interop.Context) error {
func (n *NEO) Initialize(ic *interop.Context, hf *config.Hardfork) error {
if hf != n.ActiveIn() {
return nil
}
if err := n.nep17TokenNative.Initialize(ic); err != nil {
return err
}