compiler/interop: add Manifest to Contract struct

This commit is contained in:
Evgeniy Stratonikov 2021-02-08 13:09:28 +03:00
parent 6cf40749a9
commit 18b7584cb4
2 changed files with 87 additions and 0 deletions

View file

@ -48,6 +48,22 @@ func testPrintHash(u util.Uint160) {
fmt.Println(`"`) fmt.Println(`"`)
} }
func TestContractParameterTypes(t *testing.T) {
require.EqualValues(t, management.AnyType, smartcontract.AnyType)
require.EqualValues(t, management.BoolType, smartcontract.BoolType)
require.EqualValues(t, management.IntegerType, smartcontract.IntegerType)
require.EqualValues(t, management.ByteArrayType, smartcontract.ByteArrayType)
require.EqualValues(t, management.StringType, smartcontract.StringType)
require.EqualValues(t, management.Hash160Type, smartcontract.Hash160Type)
require.EqualValues(t, management.Hash256Type, smartcontract.Hash256Type)
require.EqualValues(t, management.PublicKeyType, smartcontract.PublicKeyType)
require.EqualValues(t, management.SignatureType, smartcontract.SignatureType)
require.EqualValues(t, management.ArrayType, smartcontract.ArrayType)
require.EqualValues(t, management.MapType, smartcontract.MapType)
require.EqualValues(t, management.InteropInterfaceType, smartcontract.InteropInterfaceType)
require.EqualValues(t, management.VoidType, smartcontract.VoidType)
}
func TestRoleManagementRole(t *testing.T) { func TestRoleManagementRole(t *testing.T) {
require.EqualValues(t, native.RoleOracle, roles.Oracle) require.EqualValues(t, native.RoleOracle, roles.Oracle)
require.EqualValues(t, native.RoleStateValidator, roles.StateValidator) require.EqualValues(t, native.RoleStateValidator, roles.StateValidator)

View file

@ -8,4 +8,75 @@ type Contract struct {
UpdateCounter int UpdateCounter int
Hash interop.Hash160 Hash interop.Hash160
NEF []byte NEF []byte
Manifest Manifest
}
// ParameterType represents smartcontract parameter type.
type ParameterType byte
// Various parameter types.
const (
AnyType ParameterType = 0x00
BoolType ParameterType = 0x10
IntegerType ParameterType = 0x11
ByteArrayType ParameterType = 0x12
StringType ParameterType = 0x13
Hash160Type ParameterType = 0x14
Hash256Type ParameterType = 0x15
PublicKeyType ParameterType = 0x16
SignatureType ParameterType = 0x17
ArrayType ParameterType = 0x20
MapType ParameterType = 0x22
InteropInterfaceType ParameterType = 0x30
VoidType ParameterType = 0xff
)
// Manifest represents contract's manifest.
type Manifest struct {
Name string
Groups []Group
SupportedStandards []string
ABI ABI
Permissions []Permission
Trusts []interop.Hash160
Extra interface{}
}
// ABI represents contract's ABI.
type ABI struct {
Methods []Method
Events []Event
}
// Method represents contract method.
type Method struct {
Name string
Params []Parameter
ReturnType ParameterType
Offset int
Safe bool
}
// Event represents contract event.
type Event struct {
Name string
Params []Parameter
}
// Parameter represents method parameter.
type Parameter struct {
Name string
Type ParameterType
}
// Permission represents contract permission.
type Permission struct {
Contract interop.Hash160
Methods []string
}
// Group represents manifest group.
type Group struct {
PublicKey interop.PublicKey
Signature interop.Signature
} }