mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
standard: export standard definitions
Make Comply* functions useful and expose standard definitions for some reuse.
This commit is contained in:
parent
396f56f792
commit
64b603b056
6 changed files with 25 additions and 18 deletions
|
@ -19,10 +19,10 @@ var (
|
|||
)
|
||||
|
||||
var checks = map[string][]*Standard{
|
||||
manifest.NEP11StandardName: {nep11NonDivisible, nep11Divisible},
|
||||
manifest.NEP17StandardName: {nep17},
|
||||
manifest.NEP11Payable: {nep11payable},
|
||||
manifest.NEP17Payable: {nep17payable},
|
||||
manifest.NEP11StandardName: {Nep11NonDivisible, Nep11Divisible},
|
||||
manifest.NEP17StandardName: {Nep17},
|
||||
manifest.NEP11Payable: {Nep11Payable},
|
||||
manifest.NEP17Payable: {Nep17Payable},
|
||||
}
|
||||
|
||||
// Check checks if the manifest complies with all provided standards.
|
||||
|
|
|
@ -135,9 +135,9 @@ func TestCheck(t *testing.T) {
|
|||
m := manifest.NewManifest("Test")
|
||||
require.Error(t, Check(m, manifest.NEP17StandardName))
|
||||
|
||||
m.ABI.Methods = append(m.ABI.Methods, decimalTokenBase.ABI.Methods...)
|
||||
m.ABI.Methods = append(m.ABI.Methods, nep17.ABI.Methods...)
|
||||
m.ABI.Events = append(m.ABI.Events, nep17.ABI.Events...)
|
||||
m.ABI.Methods = append(m.ABI.Methods, DecimalTokenBase.ABI.Methods...)
|
||||
m.ABI.Methods = append(m.ABI.Methods, Nep17.ABI.Methods...)
|
||||
m.ABI.Events = append(m.ABI.Events, Nep17.ABI.Events...)
|
||||
require.NoError(t, Check(m, manifest.NEP17StandardName))
|
||||
require.NoError(t, CheckABI(m, manifest.NEP17StandardName))
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
)
|
||||
|
||||
var nep11Base = &Standard{
|
||||
Base: decimalTokenBase,
|
||||
// Nep11Base is a Standard containing common NEP-11 methods.
|
||||
var Nep11Base = &Standard{
|
||||
Base: DecimalTokenBase,
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
|
@ -66,8 +67,9 @@ var nep11Base = &Standard{
|
|||
},
|
||||
}
|
||||
|
||||
var nep11NonDivisible = &Standard{
|
||||
Base: nep11Base,
|
||||
// Nep11NonDivisible is a NEP-11 non-divisible Standard.
|
||||
var Nep11NonDivisible = &Standard{
|
||||
Base: Nep11Base,
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
|
@ -84,8 +86,9 @@ var nep11NonDivisible = &Standard{
|
|||
},
|
||||
}
|
||||
|
||||
var nep11Divisible = &Standard{
|
||||
Base: nep11Base,
|
||||
// Nep11Divisible is a NEP-11 divisible Standard.
|
||||
var Nep11Divisible = &Standard{
|
||||
Base: Nep11Base,
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
|
|
|
@ -5,8 +5,9 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
)
|
||||
|
||||
var nep17 = &Standard{
|
||||
Base: decimalTokenBase,
|
||||
// Nep17 is a NEP-17 Standard.
|
||||
var Nep17 = &Standard{
|
||||
Base: DecimalTokenBase,
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
|
|
|
@ -5,7 +5,8 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
)
|
||||
|
||||
var nep11payable = &Standard{
|
||||
// Nep11Payable contains NEP-11's onNEP11Payment method definition.
|
||||
var Nep11Payable = &Standard{
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{{
|
||||
|
@ -22,7 +23,8 @@ var nep11payable = &Standard{
|
|||
},
|
||||
}
|
||||
|
||||
var nep17payable = &Standard{
|
||||
// Nep17Payable contains NEP-17's onNEP17Payment method definition.
|
||||
var Nep17Payable = &Standard{
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{{
|
||||
|
|
|
@ -5,7 +5,8 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
)
|
||||
|
||||
var decimalTokenBase = &Standard{
|
||||
// DecimalTokenBase contains methods common to NEP-11 and NEP-17 token standards.
|
||||
var DecimalTokenBase = &Standard{
|
||||
Manifest: manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
|
|
Loading…
Reference in a new issue