manifest: remove EntryPoint from manifest
This commit is contained in:
parent
d2c823daa6
commit
e52c39ae7e
11 changed files with 23 additions and 93 deletions
|
@ -341,26 +341,21 @@ func parsePairJSON(data []byte, sep string) (string, string, error) {
|
|||
// Note: manifest is taken from the external source, however it can be generated ad-hoc. See #1038.
|
||||
func (di *DebugInfo) convertToManifest(fs smartcontract.PropertyState) (*manifest.Manifest, error) {
|
||||
var (
|
||||
entryPoint manifest.Method
|
||||
mainNamespace string
|
||||
err error
|
||||
)
|
||||
for _, method := range di.Methods {
|
||||
if method.Name.Name == mainIdent {
|
||||
entryPoint, err = method.ToManifestMethod()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mainNamespace = method.Name.Namespace
|
||||
break
|
||||
}
|
||||
}
|
||||
if entryPoint.Name == "" {
|
||||
if mainNamespace == "" {
|
||||
return nil, errors.New("no Main method was found")
|
||||
}
|
||||
methods := make([]manifest.Method, 0)
|
||||
for _, method := range di.Methods {
|
||||
if method.Name.Name != mainIdent && method.IsExported && method.Name.Namespace == mainNamespace {
|
||||
if method.IsExported && method.Name.Namespace == mainNamespace {
|
||||
mMethod, err := method.ToManifestMethod()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -379,10 +374,9 @@ func (di *DebugInfo) convertToManifest(fs smartcontract.PropertyState) (*manifes
|
|||
result := manifest.NewManifest(di.Hash)
|
||||
result.Features = fs
|
||||
result.ABI = manifest.ABI{
|
||||
Hash: di.Hash,
|
||||
EntryPoint: entryPoint,
|
||||
Methods: methods,
|
||||
Events: events,
|
||||
Hash: di.Hash,
|
||||
Methods: methods,
|
||||
Events: events,
|
||||
}
|
||||
result.Permissions = []manifest.Permission{
|
||||
{
|
||||
|
|
|
@ -132,17 +132,14 @@ func unexportedMethod() int { return 1 }
|
|||
expected := &manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Hash: hash.Hash160(buf),
|
||||
EntryPoint: manifest.Method{
|
||||
Name: "main",
|
||||
Parameters: []manifest.Parameter{
|
||||
{
|
||||
Name: "op",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
ReturnType: smartcontract.BoolType,
|
||||
},
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
Name: "main",
|
||||
Parameters: []manifest.Parameter{
|
||||
manifest.NewParameter("op", smartcontract.StringType),
|
||||
},
|
||||
ReturnType: smartcontract.BoolType,
|
||||
},
|
||||
{
|
||||
Name: "methodInt",
|
||||
Parameters: []manifest.Parameter{
|
||||
|
@ -214,7 +211,6 @@ func unexportedMethod() int { return 1 }
|
|||
}
|
||||
require.True(t, expected.ABI.Hash.Equals(actual.ABI.Hash))
|
||||
require.ElementsMatch(t, expected.ABI.Methods, actual.ABI.Methods)
|
||||
require.Equal(t, expected.ABI.EntryPoint, actual.ABI.EntryPoint)
|
||||
require.Equal(t, expected.ABI.Events, actual.ABI.Events)
|
||||
require.Equal(t, expected.Groups, actual.Groups)
|
||||
require.Equal(t, expected.Features, actual.Features)
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -62,12 +61,6 @@ func TestCachedDaoContracts(t *testing.T) {
|
|||
require.NotNil(t, err)
|
||||
|
||||
m := manifest.NewManifest(hash.Hash160(script))
|
||||
m.ABI.EntryPoint.Name = "somename"
|
||||
m.ABI.EntryPoint.Parameters = []manifest.Parameter{
|
||||
manifest.NewParameter("first", smartcontract.IntegerType),
|
||||
manifest.NewParameter("second", smartcontract.StringType),
|
||||
}
|
||||
m.ABI.EntryPoint.ReturnType = smartcontract.BoolType
|
||||
|
||||
cs := &state.Contract{
|
||||
ID: 123,
|
||||
|
|
|
@ -229,12 +229,6 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
|
||||
script := io.NewBufBinWriter()
|
||||
m := manifest.NewManifest(hash.Hash160(avm))
|
||||
m.ABI.EntryPoint.Name = "Main"
|
||||
m.ABI.EntryPoint.Parameters = []manifest.Parameter{
|
||||
manifest.NewParameter("method", smartcontract.StringType),
|
||||
manifest.NewParameter("params", smartcontract.ArrayType),
|
||||
}
|
||||
m.ABI.EntryPoint.ReturnType = smartcontract.BoolType
|
||||
m.Features = smartcontract.HasStorage
|
||||
bs, err := m.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -288,12 +288,6 @@ func createVMAndContractState(t *testing.T) (*vm.VM, *state.Contract, *interop.C
|
|||
v := vm.New()
|
||||
script := []byte("testscript")
|
||||
m := manifest.NewManifest(hash.Hash160(script))
|
||||
m.ABI.EntryPoint.Parameters = []manifest.Parameter{
|
||||
manifest.NewParameter("Name", smartcontract.StringType),
|
||||
manifest.NewParameter("Amount", smartcontract.IntegerType),
|
||||
manifest.NewParameter("Hash", smartcontract.Hash160Type),
|
||||
}
|
||||
m.ABI.EntryPoint.ReturnType = smartcontract.ArrayType
|
||||
m.Features = smartcontract.HasStorage
|
||||
contractState := &state.Contract{
|
||||
Script: script,
|
||||
|
|
|
@ -520,13 +520,6 @@ func TestContractUpdate(t *testing.T) {
|
|||
manifest := &manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Hash: cs.ScriptHash(),
|
||||
EntryPoint: manifest.Method{
|
||||
Name: "Main",
|
||||
Parameters: []manifest.Parameter{
|
||||
manifest.NewParameter("NewParameter", smartcontract.IntegerType),
|
||||
},
|
||||
ReturnType: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
Features: smartcontract.HasStorage,
|
||||
}
|
||||
|
@ -554,13 +547,6 @@ func TestContractUpdate(t *testing.T) {
|
|||
newManifest := manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Hash: hash.Hash160(newScript),
|
||||
EntryPoint: manifest.Method{
|
||||
Name: "Main",
|
||||
Parameters: []manifest.Parameter{
|
||||
manifest.NewParameter("VeryNewParameter", smartcontract.IntegerType),
|
||||
},
|
||||
ReturnType: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
Features: smartcontract.HasStorage,
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
)
|
||||
|
||||
|
@ -19,12 +18,6 @@ func Deploy(ic *interop.Context, _ *vm.VM) error {
|
|||
for _, native := range ic.Natives {
|
||||
md := native.Metadata()
|
||||
|
||||
ps := md.Manifest.ABI.EntryPoint.Parameters
|
||||
params := make([]smartcontract.ParamType, len(ps))
|
||||
for i := range ps {
|
||||
params[i] = ps[i].Type
|
||||
}
|
||||
|
||||
cs := &state.Contract{
|
||||
ID: md.ContractID,
|
||||
Script: md.Script,
|
||||
|
|
|
@ -298,19 +298,13 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
}
|
||||
return c.GetContractState(hash)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":0,"script":"VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==","manifest":{"abi":{"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","entryPoint":{"name":"Main","parameters":[{"name":"method","type":"String"},{"name":"params","type":"Array"}],"returntype":"Boolean"},"methods":[],"events":[]},"groups":[],"features":{"payable":false,"storage":true},"permissions":null,"trusts":[],"safemethods":[],"extra":null},"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176"}}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":0,"script":"VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==","manifest":{"abi":{"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","methods":[],"events":[]},"groups":[],"features":{"payable":false,"storage":true},"permissions":null,"trusts":[],"safemethods":[],"extra":null},"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176"}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
script, err := base64.StdEncoding.DecodeString("VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
m := manifest.NewManifest(hash.Hash160(script))
|
||||
m.ABI.EntryPoint.Name = "Main"
|
||||
m.ABI.EntryPoint.Parameters = []manifest.Parameter{
|
||||
manifest.NewParameter("method", smartcontract.StringType),
|
||||
manifest.NewParameter("params", smartcontract.ArrayType),
|
||||
}
|
||||
m.ABI.EntryPoint.ReturnType = smartcontract.BoolType
|
||||
m.Features = smartcontract.HasStorage
|
||||
cs := &state.Contract{
|
||||
ID: 0,
|
||||
|
|
|
@ -13,10 +13,9 @@ const MaxManifestSize = 2048
|
|||
|
||||
// ABI represents a contract application binary interface.
|
||||
type ABI struct {
|
||||
Hash util.Uint160 `json:"hash"`
|
||||
EntryPoint Method `json:"entryPoint"`
|
||||
Methods []Method `json:"methods"`
|
||||
Events []Event `json:"events"`
|
||||
Hash util.Uint160 `json:"hash"`
|
||||
Methods []Method `json:"methods"`
|
||||
Events []Event `json:"events"`
|
||||
}
|
||||
|
||||
// Manifest represens contract metadata.
|
||||
|
@ -65,7 +64,6 @@ func NewManifest(h util.Uint160) *Manifest {
|
|||
// DefaultManifest returns default contract manifest.
|
||||
func DefaultManifest(h util.Uint160) *Manifest {
|
||||
m := NewManifest(h)
|
||||
m.ABI.EntryPoint = *DefaultEntryPoint()
|
||||
m.Permissions = []Permission{*NewPermission(PermissionWildcard)}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -13,39 +13,39 @@ import (
|
|||
// https://github.com/neo-project/neo/blob/master/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs#L10
|
||||
func TestManifest_MarshalJSON(t *testing.T) {
|
||||
t.Run("default", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
m := testUnmarshalMarshalManifest(t, s)
|
||||
require.Equal(t, DefaultManifest(util.Uint160{}), m)
|
||||
})
|
||||
|
||||
// this vector is missing from original repo
|
||||
t.Run("features", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":true,"payable":true},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
s := `{"groups":[],"features":{"storage":true,"payable":true},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
|
||||
t.Run("permissions", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"0x0000000000000000000000000000000000000000","methods":["method1","method2"]}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"0x0000000000000000000000000000000000000000","methods":["method1","method2"]}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
|
||||
t.Run("safe methods", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":["balanceOf"],"extra":null}`
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":["balanceOf"],"extra":null}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
|
||||
t.Run("trust", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":["0x0000000000000000000000000000000000000001"],"safemethods":[],"extra":null}`
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":["0x0000000000000000000000000000000000000001"],"safemethods":[],"extra":null}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
|
||||
t.Run("groups", func(t *testing.T) {
|
||||
s := `{"groups":[{"pubkey":"03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c","signature":"QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ=="}],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
s := `{"groups":[{"pubkey":"03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c","signature":"QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ=="}],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":null}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
|
||||
t.Run("extra", func(t *testing.T) {
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","entryPoint":{"name":"Main","parameters":[{"name":"operation","type":"String"},{"name":"args","type":"Array"}],"returntype":"Any"},"methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":{"key":"value"}}`
|
||||
s := `{"groups":[],"features":{"storage":false,"payable":false},"abi":{"hash":"0x0000000000000000000000000000000000000000","methods":[],"events":[]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"safemethods":[],"extra":{"key":"value"}}`
|
||||
testUnmarshalMarshalManifest(t, s)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,18 +50,6 @@ func NewParameter(name string, typ smartcontract.ParamType) Parameter {
|
|||
}
|
||||
}
|
||||
|
||||
// DefaultEntryPoint represents default entrypoint to a contract.
|
||||
func DefaultEntryPoint() *Method {
|
||||
return &Method{
|
||||
Name: "Main",
|
||||
Parameters: []Parameter{
|
||||
NewParameter("operation", smartcontract.StringType),
|
||||
NewParameter("args", smartcontract.ArrayType),
|
||||
},
|
||||
ReturnType: smartcontract.AnyType,
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid checks whether group's signature corresponds to the given hash.
|
||||
func (g *Group) IsValid(h util.Uint160) bool {
|
||||
return g.PublicKey.Verify(g.Signature, hash.Sha256(h.BytesBE()).BytesBE())
|
||||
|
|
Loading…
Reference in a new issue