mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-29 09:27:36 +00:00
2611e9ab5c
Wrong bits were used to represent flags which is important for contracts created via interop. Fixes contracts failing to store things: WARN[16278] contract invocation failed block=3773025 err="error encountered at instruction 3435 (SYSCALL): failed to invoke syscall: contract c9d870d7857e956d82290d5df19de3133c107815 can't have storage" tx=fa695eea240b7b4dbb6f42ea6335447a764d8b629c40b7812ea3bca16b1f098d WARN[16278] contract invocation failed block=3773025 err="error encountered at instruction 1279 (SYSCALL): failed to invoke syscall: contract 97210e7c98582151ceb37f9748c9a1d27d9ae6fd can't have storage" tx=0144d84038149fa0cf1f7912f7d5854fa5f3670f5b4217789c1441f9fd52d27b
93 lines
1.8 KiB
Go
93 lines
1.8 KiB
Go
package smartcontract
|
|
|
|
import "github.com/CityOfZion/neo-go/pkg/util"
|
|
|
|
// ParamType represents the Type of the contract parameter.
|
|
type ParamType byte
|
|
|
|
// A list of supported smart contract parameter types.
|
|
const (
|
|
SignatureType ParamType = iota
|
|
BoolType
|
|
IntegerType
|
|
Hash160Type
|
|
Hash256Type
|
|
ByteArrayType
|
|
PublicKeyType
|
|
StringType
|
|
ArrayType
|
|
)
|
|
|
|
// PropertyState represents contract properties (flags).
|
|
type PropertyState byte
|
|
|
|
// List of supported properties.
|
|
const (
|
|
HasStorage PropertyState = 1 << iota
|
|
HasDynamicInvoke
|
|
IsPayable
|
|
NoProperties = 0
|
|
)
|
|
|
|
// Parameter represents a smart contract parameter.
|
|
type Parameter struct {
|
|
// Type of the parameter.
|
|
Type ParamType `json:"type"`
|
|
// The actual value of the parameter.
|
|
Value interface{} `json:"value"`
|
|
}
|
|
|
|
func (pt ParamType) String() string {
|
|
switch pt {
|
|
case SignatureType:
|
|
return "Signature"
|
|
case BoolType:
|
|
return "Boolean"
|
|
case IntegerType:
|
|
return "Integer"
|
|
case Hash160Type:
|
|
return "Hash160"
|
|
case Hash256Type:
|
|
return "Hash256"
|
|
case ByteArrayType:
|
|
return "ByteArray"
|
|
case PublicKeyType:
|
|
return "PublicKey"
|
|
case StringType:
|
|
return "String"
|
|
case ArrayType:
|
|
return "Array"
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
// MarshalJSON implements the json.Marshaler interface.
|
|
func (pt ParamType) MarshalJSON() ([]byte, error) {
|
|
return []byte(`"` + pt.String() + `"`), nil
|
|
}
|
|
|
|
// NewParameter returns a Parameter with proper initialized Value
|
|
// of the given ParamType.
|
|
func NewParameter(t ParamType) Parameter {
|
|
return Parameter{
|
|
Type: t,
|
|
Value: nil,
|
|
}
|
|
}
|
|
|
|
// ContextItem represents a transaction context item.
|
|
type ContextItem struct {
|
|
Script util.Uint160
|
|
Parameters []Parameter
|
|
Signatures []Signature
|
|
}
|
|
|
|
// Signature represents a transaction signature.
|
|
type Signature struct {
|
|
Data []byte
|
|
PublicKey []byte
|
|
}
|
|
|
|
// ParameterContext holds the parameter context.
|
|
type ParameterContext struct{}
|