Skip to content

Commit

Permalink
rename params to arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje committed Sep 2, 2024
1 parent e94c749 commit f4e91f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/core/dao/dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func TestStoreAsTransaction(t *testing.T) {
Invocations: []state.ContractInvocation{{
Hash: util.Uint160{},
Method: "fakeMethodCall",
Params: stackitem.NewArray([]stackitem.Item{
Arguments: stackitem.NewArray([]stackitem.Item{
stackitem.NewBool(false),
}),
}},
Expand Down
6 changes: 3 additions & 3 deletions pkg/core/interop/contract/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func Call(ic *interop.Context) error {
hasReturn := md.ReturnType != smartcontract.VoidType

ic.InvocationCalls = append(ic.InvocationCalls, state.ContractInvocation{
Hash: u,
Method: method,
Params: stackitem.NewArray(args),
Hash: u,
Method: method,
Arguments: stackitem.NewArray(args),
})
return callInternal(ic, cs, method, fs, hasReturn, args, true)
}
Expand Down
35 changes: 18 additions & 17 deletions pkg/core/state/notification_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"

"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util"
Expand All @@ -20,30 +21,30 @@ type NotificationEvent struct {
}

type ContractInvocation struct {
Hash util.Uint160 `json:"contract_hash"`
Method string `json:"method"`
Params *stackitem.Array `json:"parameters"`
Hash util.Uint160 `json:"contract_hash"`
Method string `json:"method"`
Arguments *stackitem.Array `json:"arguments"`
}

func (ci *ContractInvocation) DecodeBinary(r *io.BinReader) {
ci.Hash.DecodeBinary(r)
ci.Method = r.ReadString()
params := stackitem.DecodeBinary(r)
args := stackitem.DecodeBinary(r)
if r.Err != nil {
return
}
arr, ok := params.Value().([]stackitem.Item)
arr, ok := args.Value().([]stackitem.Item)
if !ok {
r.Err = errors.New("Array or Struct expected")
r.Err = errors.New("array or Struct expected")
return
}
ci.Params = stackitem.NewArray(arr)
ci.Arguments = stackitem.NewArray(arr)
}

func (ci *ContractInvocation) EncodeBinaryWithContext(w *io.BinWriter, sc *stackitem.SerializationContext) {
ci.Hash.EncodeBinary(w)
w.WriteString(ci.Method)
b, err := sc.Serialize(ci.Params, false)
b, err := sc.Serialize(ci.Arguments, false)
if err != nil {
w.Err = err
return
Expand All @@ -53,14 +54,14 @@ func (ci *ContractInvocation) EncodeBinaryWithContext(w *io.BinWriter, sc *stack

// MarshalJSON implements the json.Marshaler interface.
func (ci ContractInvocation) MarshalJSON() ([]byte, error) {
item, err := stackitem.ToJSONWithTypes(ci.Params)
item, err := stackitem.ToJSONWithTypes(ci.Arguments)
if err != nil {
item = []byte(fmt.Sprintf(`"error: %v"`, err))
}
return json.Marshal(ContractInvocationAux{
Hash: ci.Hash,
Method: ci.Method,
Params: item,
Hash: ci.Hash,
Method: ci.Method,
Arguments: item,
})
}

Expand All @@ -70,14 +71,14 @@ func (ci *ContractInvocation) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, aux); err != nil {
return err
}
params, err := stackitem.FromJSONWithTypes(aux.Params)
params, err := stackitem.FromJSONWithTypes(aux.Arguments)
if err != nil {
return err
}
if t := params.Type(); t != stackitem.ArrayT {
return fmt.Errorf("failed to convert invocation state of type %s to array", t.String())
}
ci.Params = params.(*stackitem.Array)
ci.Arguments = params.(*stackitem.Array)
ci.Method = aux.Method
ci.Hash = aux.Hash
return nil
Expand Down Expand Up @@ -285,9 +286,9 @@ type Execution struct {
}

type ContractInvocationAux struct {
Hash util.Uint160 `json:"contract_hash"`
Method string `json:"method"`
Params json.RawMessage `json:"parameters"`
Hash util.Uint160 `json:"contract_hash"`
Method string `json:"method"`
Arguments json.RawMessage `json:"arguments"`
}

// executionAux represents an auxiliary struct for Execution JSON marshalling.
Expand Down

0 comments on commit f4e91f5

Please sign in to comment.