Skip to content

Commit

Permalink
native: call onNEP11Transfer for NEP-11 transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov committed Feb 5, 2021
1 parent a442e15 commit 44a848f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/core/native/nonfungible.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/nspcc-dev/neo-go/pkg/core/dao"
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/interop/contract"
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
istorage "github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
"github.com/nspcc-dev/neo-go/pkg/core/state"
Expand Down Expand Up @@ -277,6 +278,26 @@ func (n *nonfungible) postTransfer(ic *interop.Context, from, to *util.Uint160,
}),
}
ic.Notifications = append(ic.Notifications, ne)
if to == nil {
return
}
cs, err := ic.GetContract(*to)
if err != nil {
return
}

fromArg := stackitem.Item(stackitem.Null{})
if from != nil {
fromArg = stackitem.NewByteArray((*from).BytesBE())
}
args := []stackitem.Item{
fromArg,
stackitem.NewBigInteger(intOne),
stackitem.NewByteArray(tokenID),
}
if err := contract.CallFromNative(ic, n.Hash, cs, manifest.MethodOnNEP11Payment, args, false); err != nil {
panic(err)
}
}

func (n *nonfungible) burn(ic *interop.Context, tokenID []byte) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/smartcontract/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
// MethodOnNEP17Payment is name of the method which is called when contract receives NEP-17 tokens.
MethodOnNEP17Payment = "onNEP17Payment"

// MethodOnNEP11Payment is the name of the method which is called when contract receives NEP-11 tokens.
MethodOnNEP11Payment = "onNEP11Payment"

// NEP10StandardName represents the name of NEP10 smartcontract standard.
NEP10StandardName = "NEP-10"
// NEP17StandardName represents the name of NEP17 smartcontract standard.
Expand Down

0 comments on commit 44a848f

Please sign in to comment.