forked from TrueCloudLab/neoneo-go
examples: add defer/recover to OnNEP17Payment handlers
Transaction must be ABORTed, exceptions are not sufficient.
This commit is contained in:
parent
e557da70a4
commit
a5979f6d64
2 changed files with 12 additions and 0 deletions
|
@ -351,6 +351,12 @@ func removeOwner(ctx storage.Context, token []byte, holder interop.Hash160) {
|
|||
// this method directly, instead it's called by GAS contract when you transfer
|
||||
// GAS from your address to the address of this NFT contract.
|
||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
runtime.Log(r.(string))
|
||||
util.Abort()
|
||||
}
|
||||
}()
|
||||
if string(runtime.GetCallingScriptHash()) != gas.Hash {
|
||||
panic("only GAS is accepted")
|
||||
}
|
||||
|
|
|
@ -210,6 +210,12 @@ func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, data i
|
|||
// this method directly, instead it's called by GAS contract when you transfer
|
||||
// GAS from your address to the address of this NFT contract.
|
||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
runtime.Log(r.(string))
|
||||
util.Abort()
|
||||
}
|
||||
}()
|
||||
if string(runtime.GetCallingScriptHash()) != gas.Hash {
|
||||
panic("only GAS is accepted")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue