Skip to content

Commit

Permalink
native: add NEP-27 to Neo's supported standards
Browse files Browse the repository at this point in the history
Port neo-project/neo#3643.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Jan 20, 2025
1 parent 01c2acd commit c800b2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/core/interop/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ type ContractMD struct {
mdCache map[config.Hardfork]*HFSpecificContractMD

// onManifestConstruction is a callback for manifest finalization.
onManifestConstruction func(*manifest.Manifest)
onManifestConstruction func(*manifest.Manifest, config.Hardfork)
}

// HFSpecificContractMD is a hardfork-specific native contract descriptor.
Expand All @@ -225,7 +225,7 @@ type HFSpecificContractMD struct {

// NewContractMD returns Contract with the specified fields set. onManifestConstruction callback every time
// after hardfork-specific manifest creation and aimed to finalize the manifest.
func NewContractMD(name string, id int32, onManifestConstruction ...func(*manifest.Manifest)) *ContractMD {
func NewContractMD(name string, id int32, onManifestConstruction ...func(*manifest.Manifest, config.Hardfork)) *ContractMD {
c := &ContractMD{Name: name}
if len(onManifestConstruction) != 0 {
c.onManifestConstruction = onManifestConstruction[0]
Expand Down Expand Up @@ -339,7 +339,7 @@ func (c *ContractMD) buildHFSpecificMD(hf config.Hardfork) {
m.ABI.Methods = abiMethods
m.ABI.Events = abiEvents
if c.onManifestConstruction != nil {
c.onManifestConstruction(m)
c.onManifestConstruction(m, hf)
}
md := &HFSpecificContractMD{
ContractBase: state.ContractBase{
Expand Down
6 changes: 5 additions & 1 deletion pkg/core/native/native_nep17.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package native
import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"math"
"math/big"

Expand Down Expand Up @@ -46,8 +47,11 @@ func (c *nep17TokenNative) Metadata() *interop.ContractMD {
}

func newNEP17Native(name string, id int32) *nep17TokenNative {
n := &nep17TokenNative{ContractMD: *interop.NewContractMD(name, id, func(m *manifest.Manifest) {
n := &nep17TokenNative{ContractMD: *interop.NewContractMD(name, id, func(m *manifest.Manifest, hf config.Hardfork) {
m.SupportedStandards = []string{manifest.NEP17StandardName}
if name == nativenames.Neo && hf.Cmp(config.HFEchidna) >= 0 {
m.SupportedStandards = append(m.SupportedStandards, manifest.NEP17Payable)
}
})}

desc := newDescriptor("symbol", smartcontract.StringType)
Expand Down

0 comments on commit c800b2b

Please sign in to comment.