Merge pull request #2466 from nspcc-dev/rules-fixes

Rules scope fixes
This commit is contained in:
Roman Khimov 2022-05-06 11:09:39 +03:00 committed by GitHub
commit 75d06d18c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 8 deletions

View file

@ -549,7 +549,7 @@ func unmarshalArrayOfConditionJSONs(arr []json.RawMessage, maxDepth int) ([]Witn
if l == 0 {
return nil, errors.New("empty array of conditions")
}
if l >= maxSubitems {
if l > maxSubitems {
return nil, errors.New("too many elements")
}
res := make([]WitnessCondition, l)

View file

@ -1,6 +1,6 @@
package transaction
//go:generate stringer -type=WitnessScope -output=witness_scope_string.go
//go:generate stringer -type=WitnessScope -linecomment -output=witness_scope_string.go
import (
"encoding/json"
"fmt"
@ -23,7 +23,7 @@ const (
// CustomGroups define custom pubkey for group members.
CustomGroups WitnessScope = 0x20
// Rules is a set of conditions with boolean operators.
Rules WitnessScope = 0x40
Rules WitnessScope = 0x40 // WitnessRules
// Global allows this witness in all contexts (default Neo2 behavior).
// This cannot be combined with other flags.
Global WitnessScope = 0x80

View file

@ -1,4 +1,4 @@
// Code generated by "stringer -type=WitnessScope -output=witness_scope_string.go"; DO NOT EDIT.
// Code generated by "stringer -type=WitnessScope -linecomment -output=witness_scope_string.go"; DO NOT EDIT.
package transaction
@ -20,7 +20,7 @@ const (
_WitnessScope_name_0 = "NoneCalledByEntry"
_WitnessScope_name_1 = "CustomContracts"
_WitnessScope_name_2 = "CustomGroups"
_WitnessScope_name_3 = "Rules"
_WitnessScope_name_3 = "WitnessRules"
_WitnessScope_name_4 = "Global"
)

View file

@ -62,7 +62,7 @@ var (
func (i CommandType) String() string {
switch {
case i <= 1:
case 0 <= i && i <= 1:
return _CommandType_name_0[_CommandType_index_0[i]:_CommandType_index_0[i+1]]
case 16 <= i && i <= 17:
i -= 16

View file

@ -1675,7 +1675,7 @@ func (s *Server) getInvokeScriptParams(reqParams request.Params) (*transaction.T
if len(reqParams) > 1 {
signers, witnesses, err := reqParams[1].GetSignersWithWitnesses()
if err != nil {
return nil, false, response.ErrInvalidParams
return nil, false, response.WrapErrorWithData(response.ErrInvalidParams, err)
}
tx.Signers = signers
tx.Scripts = witnesses
@ -1684,7 +1684,7 @@ func (s *Server) getInvokeScriptParams(reqParams request.Params) (*transaction.T
if len(reqParams) > 2 {
verbose, err = reqParams[2].GetBoolean()
if err != nil {
return nil, false, response.ErrInvalidParams
return nil, false, response.WrapErrorWithData(response.ErrInvalidParams, err)
}
}
if len(tx.Signers) == 0 {