diff --git a/docs/notifications.md b/docs/notifications.md index 140d2403e..9e8426ab7 100644 --- a/docs/notifications.md +++ b/docs/notifications.md @@ -293,21 +293,21 @@ Example: "value" : [ { "value" : "636f6e74726163742063616c6c", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "7472616e73666572", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : [ { "value" : "769162241eedf97c2481652adf1ba0f5bf57431b", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "316e851039019d39dfc2c37d6c3fee19fd580987", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "1000", @@ -351,20 +351,20 @@ Example: "value" : [ { "value" : "636f6e74726163742063616c6c", - "type" : "ByteArray" + "type" : "ByteString" }, { - "type" : "ByteArray", + "type" : "ByteString", "value" : "7472616e73666572" }, { "value" : [ { "value" : "769162241eedf97c2481652adf1ba0f5bf57431b", - "type" : "ByteArray" + "type" : "ByteString" }, { - "type" : "ByteArray", + "type" : "ByteString", "value" : "316e851039019d39dfc2c37d6c3fee19fd580987" }, { @@ -384,15 +384,15 @@ Example: "value" : [ { "value" : "7472616e73666572", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "769162241eedf97c2481652adf1ba0f5bf57431b", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "316e851039019d39dfc2c37d6c3fee19fd580987", - "type" : "ByteArray" + "type" : "ByteString" }, { "value" : "1000", diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 95bb7677b..d52e03221 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -206,7 +206,7 @@ func (c *codegen) scTypeFromExpr(typ ast.Expr) string { return "Struct" case *types.Slice: if isByte(t.Elem()) { - return "ByteArray" + return "ByteString" } return "Array" default: diff --git a/pkg/compiler/debug_test.go b/pkg/compiler/debug_test.go index 0a7f8cbb8..6c5a415cd 100644 --- a/pkg/compiler/debug_test.go +++ b/pkg/compiler/debug_test.go @@ -63,7 +63,7 @@ func unexportedMethod() int { return 1 } returnTypes := map[string]string{ "MethodInt": "Integer", "MethodConcat": "String", - "MethodString": "String", "MethodByteArray": "ByteArray", + "MethodString": "String", "MethodByteArray": "ByteString", "MethodArray": "Array", "MethodStruct": "Struct", "Main": "Boolean", "unexportedMethod": "Integer", @@ -272,7 +272,7 @@ func TestDebugInfo_MarshalJSON(t *testing.T) { {"param1", "Integer"}, {"ok", "Boolean"}, }, - ReturnType: "ByteArray", + ReturnType: "ByteString", Variables: []string{}, SeqPoints: []DebugSeqPoint{ { diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 20e35d979..00e17031f 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -638,7 +638,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ Account: util.Uint160{1, 2, 3}, }}) }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"1426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteArray","value":"JivsCEQy"}],"tx":"d101361426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf000000000000000000000000"}}`, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"1426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteString","value":"JivsCEQy"}],"tx":"d101361426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf000000000000000000000000"}}`, result: func(c *Client) interface{} { bytes, err := hex.DecodeString("262bec084432") if err != nil { @@ -670,7 +670,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ Account: util.Uint160{1, 2, 3}, }}) }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"00046e616d656724058e5e1b6008847cd662728549088a9ee82191","state":"HALT","gasconsumed":"16100000","stack":[{"type":"ByteArray","value":"TkVQNSBHQVM="}],"tx":"d1011b00046e616d656724058e5e1b6008847cd662728549088a9ee82191000000000000000000000000"}}`, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"00046e616d656724058e5e1b6008847cd662728549088a9ee82191","state":"HALT","gasconsumed":"16100000","stack":[{"type":"ByteString","value":"TkVQNSBHQVM="}],"tx":"d1011b00046e616d656724058e5e1b6008847cd662728549088a9ee82191000000000000000000000000"}}`, result: func(c *Client) interface{} { bytes, err := hex.DecodeString("4e45503520474153") if err != nil { diff --git a/pkg/rpc/client/wsclient_test.go b/pkg/rpc/client/wsclient_test.go index f48ce3d60..12ee495b0 100644 --- a/pkg/rpc/client/wsclient_test.go +++ b/pkg/rpc/client/wsclient_test.go @@ -116,9 +116,9 @@ func TestWSClientEvents(t *testing.T) { var ok bool // Events from RPC server test chain. var events = []string{ - `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`, - `{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`, - `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteArray","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteArray","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`, + `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`, + `{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`, + `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`, `{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x2d312f6379ead13cf62634c703091b750e7903728df2a3cf5bd96ce80b84a849","version":0,"previousblockhash":"0xb8237d34c156cac6be7b01578decf8ac8c99a62f0b6f774d622aad7be0fe189d","merkleroot":"0xf89169e89361692b71e671f13c088e84c5325015c413e8f89e7ba38efdb41287","time":1592472500006,"index":6,"nextconsensus":"Nbb1qkwcwNSBs9pAnrVVrnFbWnbWBk91U2","witnesses":[{"invocation":"DEDblVguNGXWbUswDvBfVJzBt76BJyJ0Ga6siquyjioGn4Dbr6zy1IvcLl3xN5akcejRy9e+Mr1qvpe/gkLgtW4QDEDRwPISZagMFjE/plXTnZ/gEU0IbBAAe23U29zVWteUmzRsPxF/MdzXvdffR9W0edkj17AmkWpn+5rqzH9aCOpLDECEvjgxZaRoAHEDNzp1REllLcGzMwrwSjudtzfgRglQL3g1BKerDx6cGHH73medRVkL9QVm4KzSxlywVtvhwBMrDEBuPKvzg5TtakFW2jr/bfmy1bn2FiLARlOySwaGdKRV93ozA5lVEIAvHbBlJtT4/5H8jHjbncXXMrP3OUHqebZz","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBMHOzuw=="}],"consensusdata":{"primary":0,"nonce":"0000000000000457"},"tx":[{"hash":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","size":265,"version":0,"nonce":9,"sender":"NQRLhCpAru9BjGsMwk67vdMwmzKMRgsnnN","sysfee":"0","netfee":"365210","validuntilblock":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":"CalledByEntry"}],"script":"AHsMFCBygnSvr8NvQ6Bx0yjPo+Yp2cuwDBQxboUQOQGdOd/Cw31sP+4Z/VgJhxPADAh0cmFuc2ZlcgwU2gHvYphOfQUnXEpYeyAtoLP3X+ZBYn1bUjg=","witnesses":[{"invocation":"DECwklSj3liZOJbktRtkVdUCu8U2LQlrU6Dv8NtMgd0xXbk5lXjc2p68xv6xtJXbJ4aoFMJZ9lkcNpGoeUCcaCet","verification":"DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQQqQatQ="}]}]}]}`, `{"jsonrpc":"2.0","method":"event_missed","params":[]}`, } diff --git a/pkg/smartcontract/parameter_test.go b/pkg/smartcontract/parameter_test.go index 818181834..8a9481f9e 100644 --- a/pkg/smartcontract/parameter_test.go +++ b/pkg/smartcontract/parameter_test.go @@ -32,11 +32,11 @@ var marshalJSONTestCases = []struct { }, { input: Parameter{Type: ByteArrayType, Value: []byte{0x01, 0x02, 0x03}}, - result: `{"type":"ByteArray","value":"` + hexToBase64("010203") + `"}`, + result: `{"type":"ByteString","value":"` + hexToBase64("010203") + `"}`, }, { input: Parameter{Type: ByteArrayType}, - result: `{"type":"ByteArray","value":null}`, + result: `{"type":"ByteString","value":null}`, }, { input: Parameter{ @@ -68,8 +68,8 @@ var marshalJSONTestCases = []struct { }}, }, }, - result: `{"type":"Array","value":[{"type":"ByteArray","value":"` + hexToBase64("0102") + `"},{"type":"Array","value":[` + - `{"type":"ByteArray","value":"` + hexToBase64("030201") + `"},{"type":"ByteArray","value":"` + hexToBase64("070809") + `"}]}]}`, + result: `{"type":"Array","value":[{"type":"ByteString","value":"` + hexToBase64("0102") + `"},{"type":"Array","value":[` + + `{"type":"ByteString","value":"` + hexToBase64("030201") + `"},{"type":"ByteString","value":"` + hexToBase64("070809") + `"}]}]}`, }, { input: Parameter{ @@ -185,7 +185,7 @@ var unmarshalJSONTestCases = []struct { result: Parameter{Type: IntegerType, Value: int64(12345)}, }, { - input: `{"type":"ByteArray","value":"` + hexToBase64("010203") + `"}`, + input: `{"type":"ByteString","value":"` + hexToBase64("010203") + `"}`, result: Parameter{Type: ByteArrayType, Value: []byte{0x01, 0x02, 0x03}}, }, { @@ -288,9 +288,9 @@ var unmarshalJSONTestCases = []struct { } var unmarshalJSONErrorCases = []string{ - `{"type": "ByteArray","value":`, // incorrect JSON - `{"type": "ByteArray","value":1}`, // incorrect Value - `{"type": "ByteArray","value":"12^"}`, // incorrect ByteArray value + `{"type": "ByteString","value":`, // incorrect JSON + `{"type": "ByteString","value":1}`, // incorrect Value + `{"type": "ByteString","value":"12^"}`, // incorrect ByteArray value `{"type": "String","value":`, // incorrect JSON `{"type": "String","value":1}`, // incorrect Value `{"type": "Integer","value": "nn"}`, // incorrect Integer value diff --git a/pkg/vm/stackitem/item.go b/pkg/vm/stackitem/item.go index 0d6c86851..d6ec55271 100644 --- a/pkg/vm/stackitem/item.go +++ b/pkg/vm/stackitem/item.go @@ -202,7 +202,7 @@ func (i *Struct) Bool() bool { return true } // TryBytes implements Item interface. func (i *Struct) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Struct to ByteArray") + return nil, errors.New("can't convert Struct to ByteString") } // TryInteger implements Item interface. @@ -288,7 +288,7 @@ func (i Null) Bool() bool { return false } // TryBytes implements Item interface. func (i Null) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Null to ByteArray") + return nil, errors.New("can't convert Null to ByteString") } // TryInteger implements Item interface. @@ -484,7 +484,7 @@ func (i *ByteArray) MarshalJSON() ([]byte, error) { } func (i *ByteArray) String() string { - return "ByteArray" + return "ByteString" } // Bool implements Item interface. @@ -593,7 +593,7 @@ func (i *Array) Bool() bool { return true } // TryBytes implements Item interface. func (i *Array) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Array to ByteArray") + return nil, errors.New("can't convert Array to ByteString") } // TryInteger implements Item interface. @@ -683,7 +683,7 @@ func (i *Map) Bool() bool { return true } // TryBytes implements Item interface. func (i *Map) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Map to ByteArray") + return nil, errors.New("can't convert Map to ByteString") } // TryInteger implements Item interface. @@ -799,7 +799,7 @@ func (i *Interop) Bool() bool { return true } // TryBytes implements Item interface. func (i *Interop) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Interop to ByteArray") + return nil, errors.New("can't convert Interop to ByteString") } // TryInteger implements Item interface. @@ -880,7 +880,7 @@ func (p *Pointer) Bool() bool { // TryBytes implements Item interface. func (p *Pointer) TryBytes() ([]byte, error) { - return nil, errors.New("can't convert Pointer to ByteArray") + return nil, errors.New("can't convert Pointer to ByteString") } // TryInteger implements Item interface. diff --git a/pkg/vm/stackitem/item_test.go b/pkg/vm/stackitem/item_test.go index 978024f49..723d0a489 100644 --- a/pkg/vm/stackitem/item_test.go +++ b/pkg/vm/stackitem/item_test.go @@ -112,7 +112,7 @@ var stringerTestCases = []struct { }, { input: NewByteArray([]byte{}), - result: "ByteArray", + result: "ByteString", }, { input: NewArray([]Item{}), diff --git a/pkg/vm/stackitem/type.go b/pkg/vm/stackitem/type.go index 303e28508..1c12ec35f 100644 --- a/pkg/vm/stackitem/type.go +++ b/pkg/vm/stackitem/type.go @@ -29,7 +29,7 @@ func (t Type) String() string { case IntegerT: return "Integer" case ByteArrayT: - return "ByteArray" + return "ByteString" case BufferT: return "Buffer" case ArrayT: