core: add missing onPersist and postPersist methods to natives

Although not every contract is persisted (see
https://github.com/neo-project/neo/blob/master/src/neo/Ledger/Blockchain.cs#L94)
we have to add `onPersist` and `postPersist` methods to every
native contract in order to display them in manifest for users and
follow C# behaviour. In C# there are `onPersist` and `postPersist`
methods in base native contract class, see
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L141
and
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L148
This commit is contained in:
Anna Shaleva 2020-11-19 18:40:36 +03:00
parent 97069a05d5
commit 2fee69f26f
6 changed files with 22 additions and 11 deletions

View file

@ -133,3 +133,10 @@ func postPersistBase(ic *interop.Context) error {
}
return nil
}
func onPersistBase(ic *interop.Context) error {
if ic.Trigger != trigger.OnPersist {
return errors.New("onPersist must be trigered by system")
}
return nil
}