From 469458ab5a815c2501436864d222f65841e24e68 Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 13:07:17 +0200 Subject: [PATCH 01/20] Create struct protobuf type --- protobuf/types/struct.pb.go | 324 ++++++++++++++++++++++++++++++++++++ protobuf/types/struct.proto | 89 ++++++++++ scripts/build-proto.sh | 2 + 3 files changed, 415 insertions(+) create mode 100644 protobuf/types/struct.pb.go create mode 100644 protobuf/types/struct.proto diff --git a/protobuf/types/struct.pb.go b/protobuf/types/struct.pb.go new file mode 100644 index 000000000..5ee742c3b --- /dev/null +++ b/protobuf/types/struct.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protobuf/types/struct.proto + +package types + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +type NullValue int32 + +const ( + // Null value. + NullValue_NULL_VALUE NullValue = 0 +) + +var NullValue_name = map[int32]string{ + 0: "NULL_VALUE", +} + +var NullValue_value = map[string]int32{ + "NULL_VALUE": 0, +} + +func (x NullValue) String() string { + return proto.EnumName(NullValue_name, int32(x)) +} + +func (NullValue) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_84428fcddb6debf8, []int{0} +} + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +type Struct struct { + // Unordered map of dynamically typed values. + Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Struct) Reset() { *m = Struct{} } +func (m *Struct) String() string { return proto.CompactTextString(m) } +func (*Struct) ProtoMessage() {} +func (*Struct) Descriptor() ([]byte, []int) { + return fileDescriptor_84428fcddb6debf8, []int{0} +} + +func (m *Struct) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Struct.Unmarshal(m, b) +} +func (m *Struct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Struct.Marshal(b, m, deterministic) +} +func (m *Struct) XXX_Merge(src proto.Message) { + xxx_messageInfo_Struct.Merge(m, src) +} +func (m *Struct) XXX_Size() int { + return xxx_messageInfo_Struct.Size(m) +} +func (m *Struct) XXX_DiscardUnknown() { + xxx_messageInfo_Struct.DiscardUnknown(m) +} + +var xxx_messageInfo_Struct proto.InternalMessageInfo + +func (m *Struct) GetFields() map[string]*Value { + if m != nil { + return m.Fields + } + return nil +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of that +// variants, absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +type Value struct { + // The kind of value. + // + // Types that are valid to be assigned to Kind: + // *Value_NullValue + // *Value_NumberValue + // *Value_StringValue + // *Value_BoolValue + // *Value_StructValue + // *Value_ListValue + Kind isValue_Kind `protobuf_oneof:"kind"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Value) Reset() { *m = Value{} } +func (m *Value) String() string { return proto.CompactTextString(m) } +func (*Value) ProtoMessage() {} +func (*Value) Descriptor() ([]byte, []int) { + return fileDescriptor_84428fcddb6debf8, []int{1} +} + +func (m *Value) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Value.Unmarshal(m, b) +} +func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Value.Marshal(b, m, deterministic) +} +func (m *Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_Value.Merge(m, src) +} +func (m *Value) XXX_Size() int { + return xxx_messageInfo_Value.Size(m) +} +func (m *Value) XXX_DiscardUnknown() { + xxx_messageInfo_Value.DiscardUnknown(m) +} + +var xxx_messageInfo_Value proto.InternalMessageInfo + +type isValue_Kind interface { + isValue_Kind() +} + +type Value_NullValue struct { + NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=types.NullValue,oneof"` +} + +type Value_NumberValue struct { + NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"` +} + +type Value_StringValue struct { + StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` +} + +type Value_BoolValue struct { + BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` +} + +type Value_StructValue struct { + StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"` +} + +type Value_ListValue struct { + ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` +} + +func (*Value_NullValue) isValue_Kind() {} + +func (*Value_NumberValue) isValue_Kind() {} + +func (*Value_StringValue) isValue_Kind() {} + +func (*Value_BoolValue) isValue_Kind() {} + +func (*Value_StructValue) isValue_Kind() {} + +func (*Value_ListValue) isValue_Kind() {} + +func (m *Value) GetKind() isValue_Kind { + if m != nil { + return m.Kind + } + return nil +} + +func (m *Value) GetNullValue() NullValue { + if x, ok := m.GetKind().(*Value_NullValue); ok { + return x.NullValue + } + return NullValue_NULL_VALUE +} + +func (m *Value) GetNumberValue() float64 { + if x, ok := m.GetKind().(*Value_NumberValue); ok { + return x.NumberValue + } + return 0 +} + +func (m *Value) GetStringValue() string { + if x, ok := m.GetKind().(*Value_StringValue); ok { + return x.StringValue + } + return "" +} + +func (m *Value) GetBoolValue() bool { + if x, ok := m.GetKind().(*Value_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (m *Value) GetStructValue() *Struct { + if x, ok := m.GetKind().(*Value_StructValue); ok { + return x.StructValue + } + return nil +} + +func (m *Value) GetListValue() *ListValue { + if x, ok := m.GetKind().(*Value_ListValue); ok { + return x.ListValue + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Value) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Value_NullValue)(nil), + (*Value_NumberValue)(nil), + (*Value_StringValue)(nil), + (*Value_BoolValue)(nil), + (*Value_StructValue)(nil), + (*Value_ListValue)(nil), + } +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +type ListValue struct { + // Repeated field of dynamically typed values. + Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListValue) Reset() { *m = ListValue{} } +func (m *ListValue) String() string { return proto.CompactTextString(m) } +func (*ListValue) ProtoMessage() {} +func (*ListValue) Descriptor() ([]byte, []int) { + return fileDescriptor_84428fcddb6debf8, []int{2} +} + +func (m *ListValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListValue.Unmarshal(m, b) +} +func (m *ListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListValue.Marshal(b, m, deterministic) +} +func (m *ListValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListValue.Merge(m, src) +} +func (m *ListValue) XXX_Size() int { + return xxx_messageInfo_ListValue.Size(m) +} +func (m *ListValue) XXX_DiscardUnknown() { + xxx_messageInfo_ListValue.DiscardUnknown(m) +} + +var xxx_messageInfo_ListValue proto.InternalMessageInfo + +func (m *ListValue) GetValues() []*Value { + if m != nil { + return m.Values + } + return nil +} + +func init() { + proto.RegisterEnum("types.NullValue", NullValue_name, NullValue_value) + proto.RegisterType((*Struct)(nil), "types.Struct") + proto.RegisterMapType((map[string]*Value)(nil), "types.Struct.FieldsEntry") + proto.RegisterType((*Value)(nil), "types.Value") + proto.RegisterType((*ListValue)(nil), "types.ListValue") +} + +func init() { proto.RegisterFile("protobuf/types/struct.proto", fileDescriptor_84428fcddb6debf8) } + +var fileDescriptor_84428fcddb6debf8 = []byte{ + // 361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0x41, 0x6f, 0xaa, 0x40, + 0x10, 0x80, 0x5d, 0x15, 0xf2, 0x18, 0x7c, 0xc6, 0xec, 0xc9, 0xf7, 0x3c, 0x3c, 0xc2, 0xeb, 0x81, + 0x34, 0x29, 0x54, 0x7a, 0x69, 0x7a, 0xab, 0x89, 0xad, 0x07, 0xe2, 0x81, 0x46, 0x0f, 0xbd, 0x18, + 0xc1, 0x95, 0x6e, 0x5c, 0x17, 0x03, 0xbb, 0x4d, 0xbc, 0xf7, 0x27, 0xf4, 0x07, 0x37, 0x2c, 0x0b, + 0xad, 0x37, 0xe6, 0x9b, 0x6f, 0x66, 0x98, 0x01, 0x98, 0x9c, 0x8a, 0x5c, 0xe4, 0x89, 0xdc, 0x07, + 0xe2, 0x7c, 0x22, 0x65, 0x50, 0x8a, 0x42, 0xa6, 0xc2, 0x57, 0x14, 0x1b, 0x8a, 0xb9, 0x1f, 0x08, + 0xcc, 0x17, 0xc5, 0xf1, 0x14, 0xcc, 0x3d, 0x25, 0x6c, 0x57, 0x8e, 0x91, 0xd3, 0xf3, 0xec, 0xf0, + 0x8f, 0xaf, 0x14, 0xbf, 0x4e, 0xfb, 0x4f, 0x2a, 0x37, 0xe7, 0xa2, 0x38, 0xc7, 0x5a, 0xfc, 0xfb, + 0x0c, 0xf6, 0x0f, 0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 0xbe, 0xde, 0x66, 0x54, 0xbc, 0xc9, 0xc4, + 0x4f, 0xf3, 0x63, 0x70, 0x24, 0x65, 0x76, 0xb3, 0xcf, 0x25, 0xdf, 0x6d, 0x05, 0xcd, 0x79, 0x40, + 0x78, 0x46, 0x39, 0x09, 0x2e, 0xff, 0x9a, 0xc4, 0x54, 0xf1, 0xdd, 0x57, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x86, 0x01, 0xa2, 0xce, 0x4e, 0x02, 0x00, 0x00, +} diff --git a/protobuf/types/struct.proto b/protobuf/types/struct.proto new file mode 100644 index 000000000..d63e247a2 --- /dev/null +++ b/protobuf/types/struct.proto @@ -0,0 +1,89 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package types; + +option go_package = "github.com/mesg-foundation/engine/protobuf/types"; + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +message Struct { + // Unordered map of dynamically typed values. + map fields = 1; +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of that +// variants, absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +message Value { + // The kind of value. + oneof kind { + // Represents a null value. + NullValue null_value = 1; + // Represents a double value. + double number_value = 2; + // Represents a string value. + string string_value = 3; + // Represents a boolean value. + bool bool_value = 4; + // Represents a structured value. + Struct struct_value = 5; + // Represents a repeated `Value`. + ListValue list_value = 6; + } +} + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +enum NullValue { + // Null value. + NULL_VALUE = 0; +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +message ListValue { + // Repeated field of dynamically typed values. + repeated Value values = 1; +} diff --git a/scripts/build-proto.sh b/scripts/build-proto.sh index c6f5c9454..2c8bc444f 100755 --- a/scripts/build-proto.sh +++ b/scripts/build-proto.sh @@ -7,6 +7,8 @@ PROJECT=/project GRPC=$PROJECT/protobuf GRPC_PLUGIN="--go_out=plugins=grpc,paths=source_relative:." +protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/struct.proto + protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/event.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/execution.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/instance.proto From c47645dcabb748446cd0d616ee3140a25aac9f1b Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 13:07:42 +0200 Subject: [PATCH 02/20] Use types.Struct in event type --- protobuf/types/event.pb.go | 31 ++++++++++++++++--------------- protobuf/types/event.proto | 4 +++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/protobuf/types/event.pb.go b/protobuf/types/event.pb.go index 6224f5220..752517257 100644 --- a/protobuf/types/event.pb.go +++ b/protobuf/types/event.pb.go @@ -29,7 +29,7 @@ type Event struct { // key is the key of the event. Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // data is the data for the event. - Data string `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` + Data *Struct `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -81,11 +81,11 @@ func (m *Event) GetKey() string { return "" } -func (m *Event) GetData() string { +func (m *Event) GetData() *Struct { if m != nil { return m.Data } - return "" + return nil } func init() { @@ -95,16 +95,17 @@ func init() { func init() { proto.RegisterFile("protobuf/types/event.proto", fileDescriptor_118d36ccf50c3798) } var fileDescriptor_118d36ccf50c3798 = []byte{ - // 165 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x8e, 0x31, 0x0b, 0xc2, 0x30, - 0x10, 0x46, 0xa9, 0x6d, 0x05, 0x83, 0x83, 0x64, 0x2a, 0x4e, 0xd2, 0xc9, 0xc5, 0x46, 0xf4, 0x1f, - 0x08, 0x82, 0xb3, 0xa3, 0x5b, 0xda, 0x5e, 0x93, 0x20, 0xbd, 0x14, 0x73, 0x11, 0xfa, 0xef, 0x25, - 0xe7, 0xd4, 0xed, 0xdd, 0x7b, 0xf0, 0x71, 0x62, 0x3f, 0x7d, 0x3c, 0xf9, 0x36, 0x0e, 0x8a, 0xe6, - 0x09, 0x82, 0x82, 0x2f, 0x20, 0x35, 0x2c, 0x65, 0xc9, 0xaa, 0x06, 0x51, 0xde, 0x93, 0x95, 0x52, - 0x14, 0x56, 0x07, 0x5b, 0x65, 0x87, 0xec, 0xb8, 0x79, 0x32, 0xcb, 0x5a, 0x6c, 0x1d, 0x06, 0xd2, - 0xd8, 0xc1, 0x23, 0xb5, 0x15, 0xb7, 0x85, 0x93, 0x3b, 0x91, 0xbf, 0x61, 0xae, 0x72, 0x4e, 0x09, - 0xd3, 0x52, 0xaf, 0x49, 0x57, 0xc5, 0x7f, 0x29, 0xf1, 0xed, 0xf2, 0x3a, 0x1b, 0x47, 0x36, 0xb6, - 0x4d, 0xe7, 0x47, 0x35, 0x42, 0x30, 0xa7, 0xc1, 0x47, 0xec, 0x35, 0x39, 0x8f, 0x0a, 0xd0, 0x38, - 0x04, 0xb5, 0xfc, 0xb6, 0x5d, 0xf3, 0x7d, 0xfd, 0x05, 0x00, 0x00, 0xff, 0xff, 0x90, 0xf8, 0x6a, - 0x46, 0xc6, 0x00, 0x00, 0x00, + // 191 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x8e, 0x41, 0x8b, 0x83, 0x30, + 0x10, 0x85, 0x71, 0xd5, 0x85, 0xcd, 0xee, 0xc2, 0x92, 0x93, 0xb8, 0x17, 0xeb, 0xc9, 0x4b, 0x93, + 0x62, 0xff, 0x41, 0xa1, 0xd0, 0xb3, 0xbd, 0xf5, 0x16, 0x75, 0xd4, 0x50, 0x4c, 0xc4, 0x4c, 0x0a, + 0xfe, 0xfb, 0xe2, 0xd0, 0x8b, 0xbd, 0xbd, 0x7c, 0xdf, 0x0b, 0x6f, 0x58, 0x3a, 0xcd, 0x16, 0x6d, + 0xed, 0x3b, 0x89, 0xcb, 0x04, 0x4e, 0xc2, 0x03, 0x0c, 0x0a, 0x82, 0x3c, 0x26, 0x94, 0xfe, 0xbf, + 0x55, 0x1c, 0xce, 0xbe, 0x79, 0x75, 0x72, 0x64, 0xf1, 0x79, 0xfd, 0xc2, 0x39, 0x8b, 0x06, 0xe5, + 0x86, 0x24, 0xc8, 0x82, 0xe2, 0xab, 0xa2, 0xcc, 0x73, 0xf6, 0xa3, 0x8d, 0x43, 0x65, 0x1a, 0xb8, + 0xac, 0xee, 0x83, 0xdc, 0x86, 0xf1, 0x3f, 0x16, 0xde, 0x61, 0x49, 0x42, 0x52, 0x6b, 0xe4, 0x3b, + 0x16, 0xb5, 0x0a, 0x55, 0x12, 0x65, 0x41, 0xf1, 0x5d, 0xfe, 0x0a, 0x5a, 0x15, 0x57, 0x5a, 0xad, + 0x48, 0x9d, 0xca, 0xdb, 0xa1, 0xd7, 0x38, 0xf8, 0x5a, 0x34, 0x76, 0x94, 0x23, 0xb8, 0x7e, 0xdf, + 0x59, 0x6f, 0x5a, 0x85, 0xda, 0x1a, 0x09, 0xa6, 0xd7, 0x06, 0xe4, 0xf6, 0xec, 0xfa, 0x93, 0xde, + 0xc7, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x27, 0xd4, 0xa8, 0x93, 0xf2, 0x00, 0x00, 0x00, } diff --git a/protobuf/types/event.proto b/protobuf/types/event.proto index 882393b0b..a6dbe7ce7 100644 --- a/protobuf/types/event.proto +++ b/protobuf/types/event.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "protobuf/types/struct.proto"; + package types; option go_package = "github.com/mesg-foundation/engine/protobuf/types"; @@ -15,5 +17,5 @@ message Event { string key = 3; // data is the data for the event. - string data = 4; + types.Struct data = 4; } From 9331b65017551205c3c5ef62ed09a7390ca68d84 Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 13:07:50 +0200 Subject: [PATCH 03/20] Use types.Struct in execution type --- protobuf/types/execution.pb.go | 56 ++++++++++++++++++---------------- protobuf/types/execution.proto | 6 ++-- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/protobuf/types/execution.pb.go b/protobuf/types/execution.pb.go index e55018042..1d9ea2d5e 100644 --- a/protobuf/types/execution.pb.go +++ b/protobuf/types/execution.pb.go @@ -77,9 +77,9 @@ type Execution struct { // taskKey is the key of the task of this execution. TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty"` // inputs data of the execution. - Inputs string `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty"` + Inputs *Struct `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty"` // outputs are the returned data of successful execution. - Outputs string `protobuf:"bytes,8,opt,name=outputs,proto3" json:"outputs,omitempty"` + Outputs *Struct `protobuf:"bytes,8,opt,name=outputs,proto3" json:"outputs,omitempty"` // error message of a failed execution. Error string `protobuf:"bytes,9,opt,name=error,proto3" json:"error,omitempty"` // tags are optionally associated with execution by the user. @@ -156,18 +156,18 @@ func (m *Execution) GetTaskKey() string { return "" } -func (m *Execution) GetInputs() string { +func (m *Execution) GetInputs() *Struct { if m != nil { return m.Inputs } - return "" + return nil } -func (m *Execution) GetOutputs() string { +func (m *Execution) GetOutputs() *Struct { if m != nil { return m.Outputs } - return "" + return nil } func (m *Execution) GetError() string { @@ -192,25 +192,27 @@ func init() { func init() { proto.RegisterFile("protobuf/types/execution.proto", fileDescriptor_42e00237fcad5e7f) } var fileDescriptor_42e00237fcad5e7f = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0x6d, 0x4b, 0x02, 0x41, - 0x10, 0xc7, 0x3b, 0x1f, 0xce, 0x6e, 0x4a, 0x39, 0x86, 0x88, 0x7d, 0x11, 0x22, 0x42, 0x20, 0x41, - 0x77, 0x61, 0xdf, 0x20, 0x29, 0x8a,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ed, 0x5d, 0xf1, 0x04, 0x5a, - 0xef, 0x6a, 0xa9, 0xf4, 0x97, 0x4a, 0x8f, 0x42, 0x18, 0x19, 0x92, 0x8e, 0x66, 0x69, 0x84, 0x1d, - 0x80, 0x27, 0xf5, 0x6a, 0x74, 0x61, 0xc8, 0xda, 0xb4, 0x86, 0x6d, 0x48, 0x46, 0x7a, 0x5d, 0xad, - 0x28, 0xe8, 0x3a, 0x02, 0xc4, 0x0f, 0xb2, 0x5c, 0xd1, 0x2c, 0x6d, 0xdc, 0x0d, 0x3f, 0x6e, 0x8a, - 0xd2, 0x2d, 0xfc, 0x24, 0x9b, 0xea, 0x75, 0xbe, 0x26, 0x5b, 0x5c, 0xcf, 0xb5, 0x57, 0x33, 0x19, - 0xde, 0x3f, 0x27, 0x55, 0x94, 0x8a, 0xf2, 0xc3, 0xaf, 0x9b, 0xc4, 0x9c, 0x6f, 0x7f, 0x03, 0x00, - 0x00, 0xff, 0xff, 0x7e, 0xb5, 0xfe, 0x7d, 0xd3, 0x01, 0x00, 0x00, + // 339 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xdf, 0x4a, 0xeb, 0x40, + 0x10, 0xc6, 0x4f, 0xfa, 0x27, 0x39, 0x99, 0x9e, 0x96, 0xb0, 0x9c, 0x8b, 0xa0, 0x52, 0x42, 0x41, + 0x2c, 0x82, 0x89, 0xd4, 0x37, 0xb0, 0x28, 0x8a, 0x08, 0x52, 0xf1, 0xc6, 0xbb, 0x6d, 0x3a, 0x4d, + 0x43, 0xdb, 0xdd, 0xb0, 0x3b, 0xab, 0xf6, 0xdd, 0x7c, 0x38, 0xd9, 0x6d, 0x83, 0xad, 0x78, 0xb7, + 0xdf, 0xf7, 0xfb, 0x32, 0x93, 0x99, 0x81, 0x7e, 0xa5, 0x24, 0xc9, 0xa9, 0x99, 0x67, 0xb4, 0xa9, + 0x50, 0x67, 0xf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b8, 0x17, 0x4f, 0x4a, 0x16, 0x0a, 0xb5, + 0x8e, 0x1a, 0xac, 0x0b, 0xe1, 0x58, 0xae, 0xab, 0x15, 0x5a, 0xdc, 0x64, 0x00, 0xfe, 0x2d, 0x2f, + 0x57, 0x38, 0x8b, 0x5a, 0xd7, 0xa3, 0xd7, 0xcb, 0xa2, 0xa4, 0x85, 0x99, 0xa6, 0xb9, 0x5c, 0x67, + 0x6b, 0xd4, 0xc5, 0xc5, 0x5c, 0x1a, 0x31, 0xe3, 0xf6, 0x3a, 0x19, 0x8a, 0xa2, 0x14, 0x98, 0x1d, + 0x9e, 0x73, 0xea, 0x3b, 0x7d, 0xf5, 0x15, 0x00, 0x00, 0xff, 0xff, 0x14, 0x7b, 0x62, 0x8d, 0x0e, + 0x02, 0x00, 0x00, } diff --git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index e06934a5d..24550211e 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "protobuf/types/struct.proto"; + package types; option go_package = "github.com/mesg-foundation/engine/protobuf/types"; @@ -44,10 +46,10 @@ message Execution { string taskKey = 6; // inputs data of the execution. - string inputs = 7; + types.Struct inputs = 7; // outputs are the returned data of successful execution. - string outputs = 8; + types.Struct outputs = 8; // error message of a failed execution. string error = 9; From 2e1b2156ab111bb142f8fbf42ee7603aed2d7e9c Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 16:25:23 +0200 Subject: [PATCH 04/20] Map protobuf Struct --- server/grpc/api/event.go | 20 +-- server/grpc/api/execution.go | 27 +--- server/grpc/api/execution_test.go | 3 +- server/grpc/api/mapping.go | 210 ++++++++++++++++++++++++++++++ 4 files changed, 222 insertions(+), 38 deletions(-) diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go index 0af0c200a..a168a239e 100644 --- a/server/grpc/api/event.go +++ b/server/grpc/api/event.go @@ -74,13 +74,8 @@ func (s *EventServer) Stream(req *api.StreamEventRequest, resp api.Event_StreamS return err } - for exec := range stream.C { - pexec, err := toProtoEvent(exec) - if err != nil { - return err - } - - if err := resp.Send(pexec); err != nil { + for event := range stream.C { + if err := resp.Send(toProtoEvent(event)); err != nil { return err } } @@ -88,16 +83,11 @@ func (s *EventServer) Stream(req *api.StreamEventRequest, resp api.Event_StreamS return nil } -func toProtoEvent(e *event.Event) (*types.Event, error) { - data, err := json.Marshal(e.Data) - if err != nil { - return nil, err - } - +func toProtoEvent(e *event.Event) *types.Event { return &types.Event{ Hash: e.Hash.String(), InstanceHash: e.InstanceHash.String(), Key: e.Key, - Data: string(data), - }, nil + Data: toProtoStruct(e.Data), + } } diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go index 4616ca420..c96378939 100644 --- a/server/grpc/api/execution.go +++ b/server/grpc/api/execution.go @@ -65,7 +65,7 @@ func (s *ExecutionServer) Get(ctx context.Context, req *api.GetExecutionRequest) if err != nil { return nil, err } - return toProtoExecution(exec) + return toProtoExecution(exec), nil } // Stream returns stream of executions. @@ -100,12 +100,7 @@ func (s *ExecutionServer) Stream(req *api.StreamExecutionRequest, resp api.Execu } for exec := range stream.C { - pexec, err := toProtoExecution(exec) - if err != nil { - return err - } - - if err := resp.Send(pexec); err != nil { + if err := resp.Send(toProtoExecution(exec)); err != nil { return err } } @@ -135,17 +130,7 @@ func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRe } -func toProtoExecution(exec *execution.Execution) (*types.Execution, error) { - inputs, err := json.Marshal(exec.Inputs) - if err != nil { - return nil, err - } - - outputs, err := json.Marshal(exec.Outputs) - if err != nil { - return nil, err - } - +func toProtoExecution(exec *execution.Execution) *types.Execution { return &types.Execution{ Hash: exec.Hash.String(), ParentHash: exec.ParentHash.String(), @@ -153,9 +138,9 @@ func toProtoExecution(exec *execution.Execution) (*types.Execution, error) { Status: types.Status(exec.Status), InstanceHash: exec.InstanceHash.String(), TaskKey: exec.TaskKey, - Inputs: string(inputs), - Outputs: string(outputs), + Inputs: toProtoStruct(exec.Inputs), + Outputs: toProtoStruct(exec.Outputs), Tags: exec.Tags, Error: exec.Error, - }, nil + } } diff --git a/server/grpc/api/execution_test.go b/server/grpc/api/execution_test.go index 115242055..2be2957e7 100644 --- a/server/grpc/api/execution_test.go +++ b/server/grpc/api/execution_test.go @@ -23,8 +23,7 @@ func TestGet(t *testing.T) { exec := execution.New(nil, nil, nil, "", nil, nil) require.NoError(t, db.Save(exec)) - want, err := toProtoExecution(exec) - require.NoError(t, err) + want := toProtoExecution(exec) sdk := sdk.New(nil, nil, nil, db, "", "") s := NewExecutionServer(sdk) diff --git a/server/grpc/api/mapping.go b/server/grpc/api/mapping.go index 22cef4b41..2a43c9a2e 100644 --- a/server/grpc/api/mapping.go +++ b/server/grpc/api/mapping.go @@ -1,6 +1,8 @@ package api import ( + "reflect" + "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/service" @@ -304,3 +306,211 @@ func toProtoWorkflows(workflows []*service.Workflow) []*types.Service_Workflow { } return wfs } + +func fromProtoStruct(s *types.Struct) map[string]interface{} { + m := make(map[string]interface{}) + for k, v := range s.Fields { + m[k] = fromProtoValue(v) + } + return m +} + +func fromProtoValue(v *types.Value) interface{} { + switch v.Kind.(type) { + case *types.Value_NullValue: + return nil + case *types.Value_NumberValue: + return v.GetNumberValue() + case *types.Value_StringValue: + return v.GetStringValue() + case *types.Value_BoolValue: + return v.GetBoolValue() + case *types.Value_StructValue: + return fromProtoStruct(v.GetStructValue()) + case *types.Value_ListValue: + lv := v.GetListValue() + if len(lv.Values) == 0 { + return nil + } + a := make([]interface{}, len(lv.Values)) + for i, v := range lv.Values { + a[i] = fromProtoValue(v) + } + return a + } + return nil +} + +func toProtoStruct(m map[string]interface{}) *types.Struct { + if len(m) == 0 { + return nil + } + + s := &types.Struct{ + Fields: make(map[string]*types.Value, len(m)), + } + + for k, v := range m { + s.Fields[k] = toProtoValue(v) + } + return s +} + +func toProtoValue(v interface{}) *types.Value { + switch v := v.(type) { + case nil: + return nil + case bool: + return &types.Value{ + Kind: &types.Value_BoolValue{ + BoolValue: v, + }, + } + case int: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int8: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint8: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case float32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case float64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case string: + return &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: v, + }, + } + case error: + return &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: v.Error(), + }, + } + default: + return toProtoValueRef(reflect.ValueOf(v)) + } +} + +func toProtoValueRef(v reflect.Value) *types.Value { + switch v.Kind() { + case reflect.Ptr: + if v.IsNil() { + return nil + } + return toProtoValueRef(reflect.Indirect(v)) + case reflect.Array, reflect.Slice: + if v.Len() == 0 { + return nil + } + values := make([]*types.Value, v.Len()) + for i := 0; i < v.Len(); i++ { + values[i] = toProtoValueRef(v.Index(i)) + } + return &types.Value{ + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: values, + }, + }, + } + case reflect.Struct: + t := v.Type() + size := v.NumField() + if size == 0 { + return nil + } + fields := make(map[string]*types.Value, size) + for i := 0; i < size; i++ { + name := t.Field(i).Name + // Better way? + if len(name) > 0 && 'A' <= name[0] && name[0] <= 'Z' { + fields[name] = toProtoValueRef(v.Field(i)) + } + } + if len(fields) == 0 { + return nil + } + return &types.Value{ + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: fields, + }, + }, + } + case reflect.Map: + keys := v.MapKeys() + if len(keys) == 0 { + return nil + } + fields := make(map[string]*types.Value, len(keys)) + for _, k := range keys { + if k.Kind() == reflect.String { + fields[k.String()] = toProtoValueRef(v.MapIndex(k)) + } + } + if len(fields) == 0 { + return nil + } + return &types.Value{ + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: fields, + }, + }, + } + default: + return nil + } +} From 5d6b4f56de4539d271bf783aefa187725cd5ce3a Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 16:45:07 +0200 Subject: [PATCH 05/20] Use types.Struct for inputs in outputs in api services --- protobuf/api/event.pb.go | 49 +++++++++++----------- protobuf/api/event.proto | 3 +- protobuf/api/execution.pb.go | 79 ++++++++++++++++++------------------ protobuf/api/execution.proto | 5 ++- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/protobuf/api/event.pb.go b/protobuf/api/event.pb.go index 0f2ede966..8d82fff8a 100644 --- a/protobuf/api/event.pb.go +++ b/protobuf/api/event.pb.go @@ -130,10 +130,10 @@ type CreateEventRequest struct { // key is the key of the event. Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` // data is the data for the event. - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Data *types.Struct `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateEventRequest) Reset() { *m = CreateEventRequest{} } @@ -175,11 +175,11 @@ func (m *CreateEventRequest) GetKey() string { return "" } -func (m *CreateEventRequest) GetData() string { +func (m *CreateEventRequest) GetData() *types.Struct { if m != nil { return m.Data } - return "" + return nil } // CreateEventResponse defines response for execution update. @@ -233,24 +233,25 @@ func init() { func init() { proto.RegisterFile("protobuf/api/event.proto", fileDescriptor_c0ad091fa003d2ac) } var fileDescriptor_c0ad091fa003d2ac = []byte{ - // 260 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x4b, 0xc3, 0x40, - 0x10, 0x85, 0xbb, 0x8d, 0x2e, 0x38, 0xf6, 0x20, 0xe3, 0xc1, 0xb0, 0x07, 0x91, 0x3d, 0xe9, 0x65, - 0x2b, 0x2d, 0x78, 0xf3, 0x24, 0x8a, 0xe7, 0x78, 0x17, 0xb6, 0x3a, 0xa5, 0x8b, 0x9a, 0xac, 0xd9, - 0xa9, 0x50, 0xfc, 0x33, 0xfe, 0x54, 0xc9, 0x24, 0x04, 0x63, 0xf4, 0x36, 0xbc, 0xf7, 0xe6, 0x63, - 0xf6, 0x2d, 0xe4, 0xb1, 0xae, 0xb8, 0x5a, 0x6d, 0xd7, 0x73, 0x1f, 0xc3, 0x9c, 0x3e, 0xa8, 0x64, - 0x27, 0x12, 0x66, 0x3e, 0x06, 0x63, 0x7a, 0x9b, 0x77, 0x91, 0xd2, 0xcf, 0x80, 0xfd, 0x52, 0x80, - 0x0f, 0x5c, 0x93, 0x7f, 0xbb, 0x6d, 0xd4, 0x82, 0xde, 0xb7, 0x94, 0x18, 0xaf, 0x40, 0xaf, 0xc3, - 0x2b, 0x53, 0x9d, 0xab, 0x33, 0x75, 0x7e, 0xb8, 0x38, 0x75, 0x3e, 0x06, 0x37, 0x0e, 0xba, 0x3b, - 0x49, 0x15, 0x5d, 0xda, 0x14, 0xa0, 0x5b, 0x05, 0x11, 0xf6, 0x36, 0x3e, 0x6d, 0x64, 0xff, 0xa0, - 0x90, 0x19, 0x2d, 0xcc, 0x42, 0x99, 0xd8, 0x97, 0x4f, 0x74, 0xdf, 0x78, 0x53, 0xf1, 0x06, 0x1a, - 0x1e, 0x41, 0xf6, 0x42, 0xbb, 0x3c, 0x13, 0xab, 0x19, 0xed, 0x23, 0xe0, 0x4d, 0x4d, 0x9e, 0x69, - 0x70, 0xe1, 0x6f, 0x96, 0xfa, 0x9f, 0x35, 0xed, 0x59, 0xcd, 0x55, 0xcf, 0x9e, 0x7d, 0x87, 0x97, - 0xd9, 0x5e, 0xc0, 0xf1, 0x80, 0x9f, 0x62, 0x55, 0x26, 0xfa, 0xeb, 0x01, 0x8b, 0x4f, 0xd8, 0x97, - 0x10, 0x5e, 0x83, 0x6e, 0x77, 0xf0, 0x44, 0x9a, 0x19, 0x1f, 0x68, 0xf2, 0xb1, 0xd1, 0x92, 0xed, - 0x04, 0x97, 0xa0, 0xdb, 0x2e, 0xbb, 0xf5, 0x71, 0xb1, 0x66, 0xe6, 0xe4, 0xb3, 0x9c, 0x88, 0x76, - 0x72, 0xa9, 0x56, 0x5a, 0x7e, 0x6c, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x58, 0x6b, 0x0c, 0x12, - 0xee, 0x01, 0x00, 0x00, + // 279 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0xcf, 0x4a, 0xf3, 0x40, + 0x10, 0x6f, 0x9a, 0x7e, 0x81, 0x6f, 0x5a, 0x41, 0xc6, 0x83, 0x61, 0x05, 0xd1, 0x3d, 0xe9, 0x25, + 0x91, 0x14, 0xbc, 0x79, 0x12, 0xc5, 0x73, 0x7c, 0x82, 0x6d, 0x9c, 0xd2, 0xa0, 0x4d, 0xd6, 0xdd, + 0x89, 0x50, 0x7c, 0x19, 0x1f, 0x55, 0x32, 0x09, 0xc5, 0x34, 0x7a, 0x1b, 0x7e, 0xff, 0x76, 0xe6, + 0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x5d, 0xb5, 0xbd, 0x7d, 0xdc, 0xb3, 0x5a, 0xf4, 0xab, + 0x0a, 0xa8, 0x27, 0x37, 0xc1, 0x2a, 0x92, 0x0f, 0x5c, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x96, + 0x4f, 0xca, 0xaf, 0x1a, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/event.proto b/protobuf/api/event.proto index fddb0d8bb..d96803c4f 100644 --- a/protobuf/api/event.proto +++ b/protobuf/api/event.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +import "protobuf/types/struct.proto"; import "protobuf/types/event.proto"; package api; @@ -45,7 +46,7 @@ message CreateEventRequest { string key = 2; // data is the data for the event. - string data = 3; + types.Struct data = 3; } // CreateEventResponse defines response for execution update. diff --git a/protobuf/api/execution.pb.go b/protobuf/api/execution.pb.go index 97185b4d2..a4256ba6a 100644 --- a/protobuf/api/execution.pb.go +++ b/protobuf/api/execution.pb.go @@ -25,13 +25,13 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // CreateExecutionRequest defines request to create a single execution. type CreateExecutionRequest struct { - InstanceHash string `protobuf:"bytes,1,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` - TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty"` - Inputs string `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` - Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + InstanceHash string `protobuf:"bytes,1,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty"` + Inputs *types.Struct `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` + Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateExecutionRequest) Reset() { *m = CreateExecutionRequest{} } @@ -73,11 +73,11 @@ func (m *CreateExecutionRequest) GetTaskKey() string { return "" } -func (m *CreateExecutionRequest) GetInputs() string { +func (m *CreateExecutionRequest) GetInputs() *types.Struct { if m != nil { return m.Inputs } - return "" + return nil } func (m *CreateExecutionRequest) GetTags() []string { @@ -330,7 +330,7 @@ type isUpdateExecutionRequest_Result interface { } type UpdateExecutionRequest_Outputs struct { - Outputs string `protobuf:"bytes,2,opt,name=outputs,proto3,oneof"` + Outputs *types.Struct `protobuf:"bytes,2,opt,name=outputs,proto3,oneof"` } type UpdateExecutionRequest_Error struct { @@ -348,11 +348,11 @@ func (m *UpdateExecutionRequest) GetResult() isUpdateExecutionRequest_Result { return nil } -func (m *UpdateExecutionRequest) GetOutputs() string { +func (m *UpdateExecutionRequest) GetOutputs() *types.Struct { if x, ok := m.GetResult().(*UpdateExecutionRequest_Outputs); ok { return x.Outputs } - return "" + return nil } func (m *UpdateExecutionRequest) GetError() string { @@ -415,33 +415,34 @@ func init() { func init() { proto.RegisterFile("protobuf/api/execution.proto", fileDescriptor_96e2c86581f82f05) } var fileDescriptor_96e2c86581f82f05 = []byte{ - // 401 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x4d, 0xaf, 0xd2, 0x40, - 0x14, 0x6d, 0x29, 0x16, 0xb8, 0x7e, 0xc4, 0x8c, 0x49, 0xa9, 0x95, 0x18, 0x32, 0x2b, 0x58, 0x58, - 0x0c, 0xec, 0x74, 0xa7, 0x41, 0x48, 0xdc, 0x95, 0xf8, 0x03, 0x06, 0xbc, 0x48, 0x15, 0xdb, 0x71, - 0xe6, 0x36, 0x91, 0xad, 0x89, 0x2b, 0xff, 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6b, 0x12, - 0x54, 0x69, 0xd4, 0xb1, 0x3f, 0x0e, 0x26, 0xcf, 0xe6, 0x4f, 0x53, 0x13, 0x75, 0xba, 0x31, 0x70, - 0xd6, 0xd0, 0xad, 0x40, 0x3b, 0x0f, 0x07, 0x1a, 0x5c, 0x07, 0xea, 0x0a, 0xee, 0x3b, 0x44, 0x5f, - 0xe4, 0x57, 0x57, 0x79, 0x8e, 0x30, 0x58, 0x02, 0xbd, 0xb2, 0x22, 0xd3, 0x89, 0xb1, 0x5e, 0x7b, - 0xd9, 0x05, 0x60, 0x11, 0x3c, 0x42, 0xa5, 0x4a, 0x65, 0x5d, 0xd7, 0x5e, 0x66, 0xaf, 0x1f, 0xfa, - 0x10, 0x2a, 0xd4, 0xd5, 0x91, 0xf8, 0x4b, 0x18, 0xb6, 0xbc, 0x6c, 0x49, 0xf3, 0x7f, 0x1d, 0x18, - 0x34, 0x28, 0x5b, 0x42, 0x68, 0xdb, 0x64, 0xaf, 0x4c, 0xa4, 0xee, 0xcf, 0x2b, 0x19, 0xb9, 0x49, - 0xfb, 0x48, 0xee, 0xb1, 0x05, 0x04, 0x2b, 0x24, 0x16, 0x1b, 0x99, 0xa3, 0xef, 0xe4, 0x79, 0x9d, - 0x73, 0x43, 0x70, 0x8f, 0xbd, 0x87, 0xd0, 0x36, 0x58, 0x7b, 0xbb, 0xeb, 0x74, 0x8d, 0xbe, 0xf5, - 0xcf, 0x8b, 0xdb, 0x37, 0xac, 0x87, 0xdd, 0xd1, 0xd6, 0x8b, 0xdf, 0x93, 0x05, 0xf7, 0xb6, 0xa1, - 0xf9, 0xb3, 0x16, 0x37, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xb1, 0xcc, 0x21, 0x9e, 0x03, 0x00, - 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xc1, 0x6e, 0xd4, 0x30, + 0x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da, 0xdf, 0x1d, + 0x6f, 0x37, 0x36, 0xfa, 0x8a, 0x6d, 0x8d, 0x87, 0x17, 0xf6, 0xc3, 0xf1, 0xa4, 0x7b, 0xe3, 0xff, + 0xc9, 0x42, 0x24, 0x97, 0x99, 0xff, 0xef, 0x4e, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x93, 0xdb, + 0xad, 0x1e, 0xd9, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/execution.proto b/protobuf/api/execution.proto index d1a593f07..e56f7b7c5 100644 --- a/protobuf/api/execution.proto +++ b/protobuf/api/execution.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +import "protobuf/types/struct.proto"; import "protobuf/types/execution.proto"; package api; @@ -29,7 +30,7 @@ service Execution { message CreateExecutionRequest { string instanceHash = 1; string taskKey = 2; - string inputs = 3; + types.Struct inputs = 3; repeated string tags = 4; } @@ -74,7 +75,7 @@ message UpdateExecutionRequest { // result pass to execution oneof result { // outputs is a success result. - string outputs = 2; + types.Struct outputs = 2; // error is an error result. string error = 3; From 847933f339a600f999089554bb1eb853ca733e13 Mon Sep 17 00:00:00 2001 From: krhubert Date: Mon, 22 Jul 2019 16:45:22 +0200 Subject: [PATCH 06/20] Use protobuf Struct in sdk --- sdk/execution/execution.go | 25 ++++++++----------------- server/grpc/api/event.go | 6 +----- server/grpc/api/execution.go | 10 ++-------- server/grpc/api/mapping.go | 2 +- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/sdk/execution/execution.go b/sdk/execution/execution.go index 9481d26ca..dfd42dc4e 100644 --- a/sdk/execution/execution.go +++ b/sdk/execution/execution.go @@ -1,7 +1,6 @@ package executionsdk import ( - "encoding/json" "fmt" "github.com/cskr/pubsub" @@ -49,7 +48,7 @@ func (e *Execution) GetStream(f *Filter) *Listener { } // Update updates execution that matches given hash. -func (e *Execution) Update(executionHash hash.Hash, outputs []byte, reterr error) error { +func (e *Execution) Update(executionHash hash.Hash, outputs map[string]interface{}, reterr error) error { exec, err := e.processExecution(executionHash, outputs, reterr) if err != nil { return err @@ -61,7 +60,7 @@ func (e *Execution) Update(executionHash hash.Hash, outputs []byte, reterr error } // processExecution processes execution and marks it as complated or failed. -func (e *Execution) processExecution(executionHash hash.Hash, outputData []byte, reterr error) (*execution.Execution, error) { +func (e *Execution) processExecution(executionHash hash.Hash, outputs map[string]interface{}, reterr error) (*execution.Execution, error) { tx, err := e.execDB.OpenTransaction() if err != nil { return nil, err @@ -79,13 +78,13 @@ func (e *Execution) processExecution(executionHash hash.Hash, outputData []byte, return nil, err } } else { - o, err := e.validateExecutionOutput(exec.InstanceHash, exec.TaskKey, outputData) + err := e.validateExecutionOutput(exec.InstanceHash, exec.TaskKey, outputs) if err != nil { tx.Discard() return nil, err } - if err := exec.Complete(o); err != nil { + if err := exec.Complete(outputs); err != nil { tx.Discard() return nil, err } @@ -104,26 +103,18 @@ func (e *Execution) processExecution(executionHash hash.Hash, outputData []byte, return exec, nil } -func (e *Execution) validateExecutionOutput(instanceHash hash.Hash, taskKey string, jsonout []byte) (map[string]interface{}, error) { - var output map[string]interface{} - if err := json.Unmarshal(jsonout, &output); err != nil { - return nil, fmt.Errorf("invalid output: %s", err) - } - +func (e *Execution) validateExecutionOutput(instanceHash hash.Hash, taskKey string, outputs map[string]interface{}) error { i, err := e.instance.Get(instanceHash) if err != nil { - return nil, err + return err } s, err := e.service.Get(i.ServiceHash) if err != nil { - return nil, err + return err } - if err := s.RequireTaskOutputs(taskKey, output); err != nil { - return nil, err - } - return output, nil + return s.RequireTaskOutputs(taskKey, outputs) } // Execute executes a task tasKey with inputData and tags for service serviceID. diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go index a168a239e..6cf81d331 100644 --- a/server/grpc/api/event.go +++ b/server/grpc/api/event.go @@ -2,7 +2,6 @@ package api import ( "context" - "encoding/json" "errors" "fmt" @@ -36,10 +35,7 @@ func (s *EventServer) Create(ctx context.Context, req *api.CreateEventRequest) ( return nil, errors.New("create event: key missing") } - var data map[string]interface{} - if err := json.Unmarshal([]byte(req.Data), &data); err != nil { - return nil, fmt.Errorf("create event: data %s", err) - } + data := fromProtoStruct(req.Data) event, err := s.sdk.Event.Create(instanceHash, req.Key, data) if err != nil { return nil, fmt.Errorf("create event: data %s", err) diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go index c96378939..f108acf93 100644 --- a/server/grpc/api/execution.go +++ b/server/grpc/api/execution.go @@ -2,9 +2,7 @@ package api import ( "context" - "encoding/json" "errors" - "fmt" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" @@ -35,11 +33,7 @@ func (s *ExecutionServer) Create(ctx context.Context, req *api.CreateExecutionRe return nil, err } - var inputs map[string]interface{} - if err := json.Unmarshal([]byte(req.Inputs), &inputs); err != nil { - return nil, fmt.Errorf("cannot parse execution's inputs (JSON format): %s", err) - } - + inputs := fromProtoStruct(req.Inputs) eventHash, err := hash.Random() if err != nil { return nil, err @@ -116,7 +110,7 @@ func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRe } switch res := req.Result.(type) { case *api.UpdateExecutionRequest_Outputs: - err = s.sdk.Execution.Update(hash, []byte(res.Outputs), nil) + err = s.sdk.Execution.Update(hash, fromProtoStruct(res.Outputs), nil) case *api.UpdateExecutionRequest_Error: err = s.sdk.Execution.Update(hash, nil, errors.New(res.Error)) default: diff --git a/server/grpc/api/mapping.go b/server/grpc/api/mapping.go index 2a43c9a2e..ecf1e0f1e 100644 --- a/server/grpc/api/mapping.go +++ b/server/grpc/api/mapping.go @@ -423,7 +423,7 @@ func toProtoValue(v interface{}) *types.Value { case float64: return &types.Value{ Kind: &types.Value_NumberValue{ - NumberValue: float64(v), + NumberValue: v, }, } case string: From 1f96efe67b8f95b819329e949ce2465697560337 Mon Sep 17 00:00:00 2001 From: krhubert Date: Tue, 23 Jul 2019 15:46:54 +0200 Subject: [PATCH 07/20] Move protobuf mappings to convert package --- protobuf/convert/pbstruct.go | 232 +++++++++++++++++++++++++++++++++++ protobuf/types/event.proto | 4 +- server/grpc/api/event.go | 5 +- server/grpc/api/execution.go | 9 +- server/grpc/api/mapping.go | 210 ------------------------------- 5 files changed, 242 insertions(+), 218 deletions(-) create mode 100644 protobuf/convert/pbstruct.go diff --git a/protobuf/convert/pbstruct.go b/protobuf/convert/pbstruct.go new file mode 100644 index 000000000..57def81e8 --- /dev/null +++ b/protobuf/convert/pbstruct.go @@ -0,0 +1,232 @@ +package convert + +import ( + "reflect" + + "github.com/mesg-foundation/engine/protobuf/types" +) + +// PbStructToMap converts protobuf struct to map[string]interface{}. +func PbStructToMap(s *types.Struct) map[string]interface{} { + m := make(map[string]interface{}) + for k, v := range s.Fields { + m[k] = PbValueToInterface(v) + } + return m +} + +// PbValueToInterface converts protobuf value to interface{}. +func PbValueToInterface(v *types.Value) interface{} { + switch v.Kind.(type) { + case *types.Value_NullValue: + return nil + case *types.Value_NumberValue: + return v.GetNumberValue() + case *types.Value_StringValue: + return v.GetStringValue() + case *types.Value_BoolValue: + return v.GetBoolValue() + case *types.Value_StructValue: + return PbStructToMap(v.GetStructValue()) + case *types.Value_ListValue: + lv := v.GetListValue() + if len(lv.Values) == 0 { + return nil + } + a := make([]interface{}, len(lv.Values)) + for i, v := range lv.Values { + a[i] = PbValueToInterface(v) + } + return a + } + return nil +} + +// MapToPbStruct converts map[string]interface{} to protobuf struct. +func MapToPbStruct(m map[string]interface{}) *types.Struct { + if len(m) == 0 { + return nil + } + + s := &types.Struct{ + Fields: make(map[string]*types.Value, len(m)), + } + + for k, v := range m { + s.Fields[k] = InterfaceToPbValue(v) + } + return s +} + +// InterfaceToPbValue converts interface{} to protobuf value. +func InterfaceToPbValue(v interface{}) *types.Value { + switch v := v.(type) { + case nil: + return nil + case bool: + return &types.Value{ + Kind: &types.Value_BoolValue{ + BoolValue: v, + }, + } + case int: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int8: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int16: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case int64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint8: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint16: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case uint64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case float32: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: float64(v), + }, + } + case float64: + return &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: v, + }, + } + case string: + return &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: v, + }, + } + case error: + return &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: v.Error(), + }, + } + default: + return reflectValueToPbValue(reflect.ValueOf(v)) + } +} + +// reflectValueToPbValue converts reflect.Value to protobuf value. +func reflectValueToPbValue(v reflect.Value) *types.Value { + switch v.Kind() { + case reflect.Ptr: + if v.IsNil() { + return nil + } + return reflectValueToPbValue(reflect.Indirect(v)) + case reflect.Array, reflect.Slice: + if v.Len() == 0 { + return nil + } + values := make([]*types.Value, v.Len()) + for i := 0; i < v.Len(); i++ { + values[i] = reflectValueToPbValue(v.Index(i)) + } + return &types.Value{ + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: values, + }, + }, + } + case reflect.Struct: + t := v.Type() + size := v.NumField() + if size == 0 { + return nil + } + fields := make(map[string]*types.Value, size) + for i := 0; i < size; i++ { + name := t.Field(i).Name + // Better way? + if len(name) > 0 && 'A' <= name[0] && name[0] <= 'Z' { + fields[name] = reflectValueToPbValue(v.Field(i)) + } + } + if len(fields) == 0 { + return nil + } + return &types.Value{ + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: fields, + }, + }, + } + case reflect.Map: + keys := v.MapKeys() + if len(keys) == 0 { + return nil + } + fields := make(map[string]*types.Value, len(keys)) + for _, k := range keys { + if k.Kind() == reflect.String { + fields[k.String()] = reflectValueToPbValue(v.MapIndex(k)) + } + } + if len(fields) == 0 { + return nil + } + return &types.Value{ + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: fields, + }, + }, + } + default: + return nil + } +} diff --git a/protobuf/types/event.proto b/protobuf/types/event.proto index a6dbe7ce7..19a569da1 100644 --- a/protobuf/types/event.proto +++ b/protobuf/types/event.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "protobuf/types/struct.proto"; +import "google/protobuf/struct.proto"; package types; option go_package = "github.com/mesg-foundation/engine/protobuf/types"; @@ -17,5 +17,5 @@ message Event { string key = 3; // data is the data for the event. - types.Struct data = 4; + struct.Struct data = 4; } diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go index 6cf81d331..94ab719f0 100644 --- a/server/grpc/api/event.go +++ b/server/grpc/api/event.go @@ -9,6 +9,7 @@ import ( "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/protobuf/convert" "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/sdk" eventsdk "github.com/mesg-foundation/engine/sdk/event" @@ -35,7 +36,7 @@ func (s *EventServer) Create(ctx context.Context, req *api.CreateEventRequest) ( return nil, errors.New("create event: key missing") } - data := fromProtoStruct(req.Data) + data := convert.PbStructToMap(req.Data) event, err := s.sdk.Event.Create(instanceHash, req.Key, data) if err != nil { return nil, fmt.Errorf("create event: data %s", err) @@ -84,6 +85,6 @@ func toProtoEvent(e *event.Event) *types.Event { Hash: e.Hash.String(), InstanceHash: e.InstanceHash.String(), Key: e.Key, - Data: toProtoStruct(e.Data), + Data: convert.MapToPbStruct(e.Data), } } diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go index f108acf93..5c174c1b2 100644 --- a/server/grpc/api/execution.go +++ b/server/grpc/api/execution.go @@ -8,6 +8,7 @@ import ( "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/protobuf/convert" "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/sdk" executionsdk "github.com/mesg-foundation/engine/sdk/execution" @@ -33,7 +34,7 @@ func (s *ExecutionServer) Create(ctx context.Context, req *api.CreateExecutionRe return nil, err } - inputs := fromProtoStruct(req.Inputs) + inputs := convert.PbStructToMap(req.Inputs) eventHash, err := hash.Random() if err != nil { return nil, err @@ -110,7 +111,7 @@ func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRe } switch res := req.Result.(type) { case *api.UpdateExecutionRequest_Outputs: - err = s.sdk.Execution.Update(hash, fromProtoStruct(res.Outputs), nil) + err = s.sdk.Execution.Update(hash, convert.PbStructToMap(res.Outputs), nil) case *api.UpdateExecutionRequest_Error: err = s.sdk.Execution.Update(hash, nil, errors.New(res.Error)) default: @@ -132,8 +133,8 @@ func toProtoExecution(exec *execution.Execution) *types.Execution { Status: types.Status(exec.Status), InstanceHash: exec.InstanceHash.String(), TaskKey: exec.TaskKey, - Inputs: toProtoStruct(exec.Inputs), - Outputs: toProtoStruct(exec.Outputs), + Inputs: convert.MapToPbStruct(exec.Inputs), + Outputs: convert.MapToPbStruct(exec.Outputs), Tags: exec.Tags, Error: exec.Error, } diff --git a/server/grpc/api/mapping.go b/server/grpc/api/mapping.go index ecf1e0f1e..22cef4b41 100644 --- a/server/grpc/api/mapping.go +++ b/server/grpc/api/mapping.go @@ -1,8 +1,6 @@ package api import ( - "reflect" - "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/service" @@ -306,211 +304,3 @@ func toProtoWorkflows(workflows []*service.Workflow) []*types.Service_Workflow { } return wfs } - -func fromProtoStruct(s *types.Struct) map[string]interface{} { - m := make(map[string]interface{}) - for k, v := range s.Fields { - m[k] = fromProtoValue(v) - } - return m -} - -func fromProtoValue(v *types.Value) interface{} { - switch v.Kind.(type) { - case *types.Value_NullValue: - return nil - case *types.Value_NumberValue: - return v.GetNumberValue() - case *types.Value_StringValue: - return v.GetStringValue() - case *types.Value_BoolValue: - return v.GetBoolValue() - case *types.Value_StructValue: - return fromProtoStruct(v.GetStructValue()) - case *types.Value_ListValue: - lv := v.GetListValue() - if len(lv.Values) == 0 { - return nil - } - a := make([]interface{}, len(lv.Values)) - for i, v := range lv.Values { - a[i] = fromProtoValue(v) - } - return a - } - return nil -} - -func toProtoStruct(m map[string]interface{}) *types.Struct { - if len(m) == 0 { - return nil - } - - s := &types.Struct{ - Fields: make(map[string]*types.Value, len(m)), - } - - for k, v := range m { - s.Fields[k] = toProtoValue(v) - } - return s -} - -func toProtoValue(v interface{}) *types.Value { - switch v := v.(type) { - case nil: - return nil - case bool: - return &types.Value{ - Kind: &types.Value_BoolValue{ - BoolValue: v, - }, - } - case int: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int8: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int32: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int64: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint8: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint32: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint64: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case float32: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case float64: - return &types.Value{ - Kind: &types.Value_NumberValue{ - NumberValue: v, - }, - } - case string: - return &types.Value{ - Kind: &types.Value_StringValue{ - StringValue: v, - }, - } - case error: - return &types.Value{ - Kind: &types.Value_StringValue{ - StringValue: v.Error(), - }, - } - default: - return toProtoValueRef(reflect.ValueOf(v)) - } -} - -func toProtoValueRef(v reflect.Value) *types.Value { - switch v.Kind() { - case reflect.Ptr: - if v.IsNil() { - return nil - } - return toProtoValueRef(reflect.Indirect(v)) - case reflect.Array, reflect.Slice: - if v.Len() == 0 { - return nil - } - values := make([]*types.Value, v.Len()) - for i := 0; i < v.Len(); i++ { - values[i] = toProtoValueRef(v.Index(i)) - } - return &types.Value{ - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{ - Values: values, - }, - }, - } - case reflect.Struct: - t := v.Type() - size := v.NumField() - if size == 0 { - return nil - } - fields := make(map[string]*types.Value, size) - for i := 0; i < size; i++ { - name := t.Field(i).Name - // Better way? - if len(name) > 0 && 'A' <= name[0] && name[0] <= 'Z' { - fields[name] = toProtoValueRef(v.Field(i)) - } - } - if len(fields) == 0 { - return nil - } - return &types.Value{ - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: fields, - }, - }, - } - case reflect.Map: - keys := v.MapKeys() - if len(keys) == 0 { - return nil - } - fields := make(map[string]*types.Value, len(keys)) - for _, k := range keys { - if k.Kind() == reflect.String { - fields[k.String()] = toProtoValueRef(v.MapIndex(k)) - } - } - if len(fields) == 0 { - return nil - } - return &types.Value{ - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: fields, - }, - }, - } - default: - return nil - } -} From 480e4f2738098f0b6d087560979f20d4b93c14f4 Mon Sep 17 00:00:00 2001 From: krhubert Date: Tue, 23 Jul 2019 16:38:54 +0200 Subject: [PATCH 08/20] Update ethwallet client --- systemservices/ethwallet/client/encoding.go | 24 +++++++++++++++---- .../ethwallet/client/task_runner.go | 7 +++--- systemservices/ethwallet/ethwallet/create.go | 2 +- systemservices/ethwallet/ethwallet/delete.go | 2 +- systemservices/ethwallet/ethwallet/export.go | 2 +- systemservices/ethwallet/ethwallet/import.go | 2 +- .../ethwallet/importFromPrivateKey.go | 2 +- systemservices/ethwallet/ethwallet/list.go | 2 +- systemservices/ethwallet/ethwallet/sign.go | 2 +- systemservices/ethwallet/go.mod | 4 +++- systemservices/ethwallet/go.sum | 5 ++++ 11 files changed, 38 insertions(+), 16 deletions(-) diff --git a/systemservices/ethwallet/client/encoding.go b/systemservices/ethwallet/client/encoding.go index 54a43cdb7..e9f412fa4 100644 --- a/systemservices/ethwallet/client/encoding.go +++ b/systemservices/ethwallet/client/encoding.go @@ -1,13 +1,27 @@ package client -import "encoding/json" +import ( + "encoding/json" + + "github.com/mitchellh/mapstructure" +) // Marshal returns the MESG format encoding of v. -func Marshal(v interface{}) ([]byte, error) { - return json.Marshal(v) +func Marshal(input interface{}) (map[string]interface{}, error) { + b, err := json.Marshal(input) + if err != nil { + return nil, err + } + + var output map[string]interface{} + if err := json.Unmarshal(b, &output); err != nil { + return nil, err + } + + return output, nil } // Unmarshal parses the MESG-encoded data input and stores the result in the value pointed to by v. -func Unmarshal(input []byte, v interface{}) error { - return json.Unmarshal(input, v) +func Unmarshal(input map[string]interface{}, output interface{}) error { + return mapstructure.Decode(input, output) } diff --git a/systemservices/ethwallet/client/task_runner.go b/systemservices/ethwallet/client/task_runner.go index 392094910..12fcc87f6 100644 --- a/systemservices/ethwallet/client/task_runner.go +++ b/systemservices/ethwallet/client/task_runner.go @@ -4,11 +4,12 @@ import ( "context" pb "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/protobuf/convert" "github.com/mesg-foundation/engine/protobuf/types" ) // TaskFn is a task function handler prototype. -type TaskFn func(inputs []byte) ([]byte, error) +type TaskFn func(inputs map[string]interface{}) (map[string]interface{}, error) // TaskRunner handles running task in a loop. type TaskRunner struct { @@ -43,11 +44,11 @@ func (r *TaskRunner) Run() error { return err } - output, err := r.defs[exec.TaskKey]([]byte(exec.Inputs)) + output, err := r.defs[exec.TaskKey](convert.PbStructToMap(exec.Inputs)) req := &pb.UpdateExecutionRequest{ Hash: exec.Hash, Result: &pb.UpdateExecutionRequest_Outputs{ - Outputs: string(output), + Outputs: convert.MapToPbStruct(output), }, } if err != nil { diff --git a/systemservices/ethwallet/ethwallet/create.go b/systemservices/ethwallet/ethwallet/create.go index d55bbf1b1..b6040d2e4 100644 --- a/systemservices/ethwallet/ethwallet/create.go +++ b/systemservices/ethwallet/ethwallet/create.go @@ -13,7 +13,7 @@ type createOutputSuccess struct { Address common.Address `json:"address"` } -func (s *Ethwallet) create(input []byte) ([]byte, error) { +func (s *Ethwallet) create(input map[string]interface{}) (map[string]interface{}, error) { var inputs createInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/ethwallet/delete.go b/systemservices/ethwallet/ethwallet/delete.go index d8d862495..41198cdae 100644 --- a/systemservices/ethwallet/ethwallet/delete.go +++ b/systemservices/ethwallet/ethwallet/delete.go @@ -15,7 +15,7 @@ type deleteOutputSuccess struct { Address common.Address `json:"address"` } -func (s *Ethwallet) delete(input []byte) ([]byte, error) { +func (s *Ethwallet) delete(input map[string]interface{}) (map[string]interface{}, error) { var inputs deleteInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/ethwallet/export.go b/systemservices/ethwallet/ethwallet/export.go index ddf526968..f3405a0ba 100644 --- a/systemservices/ethwallet/ethwallet/export.go +++ b/systemservices/ethwallet/ethwallet/export.go @@ -13,7 +13,7 @@ type exportInputs struct { Passphrase string `json:"passphrase"` } -func (s *Ethwallet) export(input []byte) ([]byte, error) { +func (s *Ethwallet) export(input map[string]interface{}) (map[string]interface{}, error) { var inputs exportInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/ethwallet/import.go b/systemservices/ethwallet/ethwallet/import.go index 9d2336c57..5c458413d 100644 --- a/systemservices/ethwallet/ethwallet/import.go +++ b/systemservices/ethwallet/ethwallet/import.go @@ -16,7 +16,7 @@ type importOutputSuccess struct { Address common.Address `json:"address"` } -func (s *Ethwallet) importA(input []byte) ([]byte, error) { +func (s *Ethwallet) importA(input map[string]interface{}) (map[string]interface{}, error) { var inputs importInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/ethwallet/importFromPrivateKey.go b/systemservices/ethwallet/ethwallet/importFromPrivateKey.go index 039ff545e..0d65b06d9 100644 --- a/systemservices/ethwallet/ethwallet/importFromPrivateKey.go +++ b/systemservices/ethwallet/ethwallet/importFromPrivateKey.go @@ -17,7 +17,7 @@ type importFromPrivateKeyOutputSuccess struct { Address common.Address `json:"address"` } -func (s *Ethwallet) importFromPrivateKey(input []byte) ([]byte, error) { +func (s *Ethwallet) importFromPrivateKey(input map[string]interface{}) (map[string]interface{}, error) { var inputs importFromPrivateKeyInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/ethwallet/list.go b/systemservices/ethwallet/ethwallet/list.go index 4ee3bd3c6..7e83092c7 100644 --- a/systemservices/ethwallet/ethwallet/list.go +++ b/systemservices/ethwallet/ethwallet/list.go @@ -9,7 +9,7 @@ type listOutputSuccess struct { Addresses []common.Address `json:"addresses"` } -func (s *Ethwallet) list(input []byte) ([]byte, error) { +func (s *Ethwallet) list(input map[string]interface{}) (map[string]interface{}, error) { addresses := make([]common.Address, 0) for _, account := range s.keystore.Accounts() { addresses = append(addresses, account.Address) diff --git a/systemservices/ethwallet/ethwallet/sign.go b/systemservices/ethwallet/ethwallet/sign.go index 4db7857d7..e8a86f17e 100644 --- a/systemservices/ethwallet/ethwallet/sign.go +++ b/systemservices/ethwallet/ethwallet/sign.go @@ -32,7 +32,7 @@ type signOutputSuccess struct { SignedTransaction string `json:"signedTransaction"` } -func (s *Ethwallet) sign(input []byte) ([]byte, error) { +func (s *Ethwallet) sign(input map[string]interface{}) (map[string]interface{}, error) { var inputs signInputs if err := client.Unmarshal(input, &inputs); err != nil { return nil, err diff --git a/systemservices/ethwallet/go.mod b/systemservices/ethwallet/go.mod index 23c7fd292..506ea71ad 100644 --- a/systemservices/ethwallet/go.mod +++ b/systemservices/ethwallet/go.mod @@ -8,7 +8,9 @@ require ( github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.8.27 github.com/go-stack/stack v1.8.0 // indirect - github.com/mesg-foundation/engine v0.5.1-0.20190702155243-a2826b3949a7 + github.com/mesg-foundation/core v0.10.1 // indirect + github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f + github.com/mitchellh/mapstructure v1.1.2 github.com/pborman/uuid v1.2.0 // indirect github.com/rjeczalik/notify v0.9.2 // indirect github.com/stretchr/testify v1.3.0 diff --git a/systemservices/ethwallet/go.sum b/systemservices/ethwallet/go.sum index 30a3e2cb6..292e30f10 100644 --- a/systemservices/ethwallet/go.sum +++ b/systemservices/ethwallet/go.sum @@ -102,11 +102,16 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mesg-foundation/core v0.10.1/go.mod h1:a4k0tzvuWQqBLSY+ZIotQ/vOvaIiIOLJ8Epy3tyeV28= github.com/mesg-foundation/engine v0.5.1-0.20190702155243-a2826b3949a7 h1:A6jV3DT1SIBjENtXKFIxhxIMAFyTDD1TlEk0zKfWaIk= github.com/mesg-foundation/engine v0.5.1-0.20190702155243-a2826b3949a7/go.mod h1:uS6KCuIBNSCHmsaQuuYXZkJTJJV66e4EVduRFBeiLFg= +github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f h1:vlWi61rxeJWpgFKDefOfp12EYx6FERSfQGx99XSRDKc= +github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= github.com/mesg-foundation/engine v0.10.1 h1:67/IaXbY4H/Wm551l8epfGZMMRKoM4AKrwo7qnkzcUM= +github.com/mesg-foundation/engine v0.11.0 h1:Fmdy+3Gqa4XyVQcRbf0wE8pk/CtYpW8xop6VWECV10E= github.com/mesg-foundation/prefixer v0.0.0-20180907095533-d7dbe41616bd/go.mod h1:jwBCFVsOhfmt8FwMtfOVWeWWzBIBH7xKKm7DTUluf6Y= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mr-tron/base58 v1.1.1 h1:OJIdWOWYe2l5PQNgimGtuwHY8nDskvJ5vvs//YnzRLs= github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mwitkow/go-proto-validators v0.0.0-20190212092829-1f388280e944/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= From 6a899a1aa56f07e615eef752345123ba64fcbd56 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 13:42:02 +0200 Subject: [PATCH 09/20] Tidy ethwallet go.mod --- systemservices/ethwallet/go.mod | 3 +- systemservices/ethwallet/go.sum | 89 +++++++++++++++------------------ 2 files changed, 41 insertions(+), 51 deletions(-) diff --git a/systemservices/ethwallet/go.mod b/systemservices/ethwallet/go.mod index 506ea71ad..b88e9d7bc 100644 --- a/systemservices/ethwallet/go.mod +++ b/systemservices/ethwallet/go.mod @@ -5,10 +5,11 @@ go 1.12 require ( github.com/allegro/bigcache v1.2.1 // indirect github.com/aristanetworks/goarista v0.0.0-20190628180533-8e7d5b18fe7a // indirect + github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8 // indirect + github.com/cespare/cp v1.1.1 // indirect github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.8.27 github.com/go-stack/stack v1.8.0 // indirect - github.com/mesg-foundation/core v0.10.1 // indirect github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f github.com/mitchellh/mapstructure v1.1.2 github.com/pborman/uuid v1.2.0 // indirect diff --git a/systemservices/ethwallet/go.sum b/systemservices/ethwallet/go.sum index 292e30f10..e517fda51 100644 --- a/systemservices/ethwallet/go.sum +++ b/systemservices/ethwallet/go.sum @@ -1,53 +1,59 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/Microsoft/go-winio v0.4.9/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= +github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc= github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc= github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/aristanetworks/goarista v0.0.0-20190628180533-8e7d5b18fe7a h1:AtHySZzzzJyE9NDlY3MNxkR12HsSxE1QmntYzuc0uEw= github.com/aristanetworks/goarista v0.0.0-20190628180533-8e7d5b18fe7a/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= -github.com/briandowns/spinner v0.0.0-20180822135157-9f016caa1359/go.mod h1:hw/JEQBIE+c/BLI4aKM8UU8v+ZqrD3h7HC27kKt8JQU= +github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8 h1:mOg8/RgDSHTQ1R0IR+LMDuW4TDShPv+JzYHuR4GLoNA= +github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= +github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224 h1:rnCKRrdSBqc061l0CDuYB+7X3w6w8IK/VCSChJXv62g= github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4= -github.com/containerd/continuity v0.0.0-20180712174259-0377f7d76720/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/docker/cli v0.0.0-20190129171106-b258f458cc8d/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v0.0.0-20180720172123-0dae0957e5fe/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v0.0.0-20180803200506-eeea12db7a65 h1:WeqSIzsb30/sarqEph9RS+6xw8rmRpCACwV8+cJ1Rkc= github.com/docker/docker v0.0.0-20180803200506-eeea12db7a65/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.0.0-20180212134524-7beb39f0b969/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/emirpasic/gods v0.0.0-20180618112450-bba54c718c4e/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/ethereum/go-ethereum v1.8.27 h1:d+gkiLaBDk5fn3Pe/xNVaMrB/ozI+AUB2IlVBp29IrY= github.com/ethereum/go-ethereum v1.8.27/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= -github.com/fatih/color v0.0.0-20170926111411-5df930a27be2/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= @@ -56,58 +62,47 @@ github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rm github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.2 h1:zoNxOV7WjqXptQOVngLmcSQgXmgk4NMz1HibBchjl/I= github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/goware/prefixer v0.0.0-20160118172347-395022866408/go.mod h1:PE1ycukgRPJ7bJ9a1fdfQ9j8i/cEcRAoLZzbxYpNB/s= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20180522105215-e9c5d9645c43/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= -github.com/hokaccha/go-prettyjson v0.0.0-20180920040306-f579f869bbfe/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= -github.com/kevinburke/ssh_config v0.0.0-20180711164746-82cf3f926438/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/lyft/protoc-gen-validate v0.1.0/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/mattn/go-colorable v0.0.0-20180310133214-efa589957cd0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mesg-foundation/core v0.10.1/go.mod h1:a4k0tzvuWQqBLSY+ZIotQ/vOvaIiIOLJ8Epy3tyeV28= -github.com/mesg-foundation/engine v0.5.1-0.20190702155243-a2826b3949a7 h1:A6jV3DT1SIBjENtXKFIxhxIMAFyTDD1TlEk0zKfWaIk= -github.com/mesg-foundation/engine v0.5.1-0.20190702155243-a2826b3949a7/go.mod h1:uS6KCuIBNSCHmsaQuuYXZkJTJJV66e4EVduRFBeiLFg= github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f h1:vlWi61rxeJWpgFKDefOfp12EYx6FERSfQGx99XSRDKc= github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= -github.com/mesg-foundation/engine v0.10.1 h1:67/IaXbY4H/Wm551l8epfGZMMRKoM4AKrwo7qnkzcUM= -github.com/mesg-foundation/engine v0.11.0 h1:Fmdy+3Gqa4XyVQcRbf0wE8pk/CtYpW8xop6VWECV10E= -github.com/mesg-foundation/prefixer v0.0.0-20180907095533-d7dbe41616bd/go.mod h1:jwBCFVsOhfmt8FwMtfOVWeWWzBIBH7xKKm7DTUluf6Y= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= @@ -117,8 +112,10 @@ github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVq github.com/mwitkow/go-proto-validators v0.0.0-20190212092829-1f388280e944/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -128,29 +125,21 @@ github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJ github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-buffruneio v0.0.0-20180119162133-e2f66f8164ca/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pseudomuto/protoc-gen-doc v1.1.0/go.mod h1:fwtQAY9erXp3mC92O8OTECnDlJT2r0Ff4KSEKbGEmy0= github.com/pseudomuto/protoc-gen-doc v1.3.0/go.mod h1:fwtQAY9erXp3mC92O8OTECnDlJT2r0Ff4KSEKbGEmy0= -github.com/pseudomuto/protokit v0.1.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sergi/go-diff v0.0.0-20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/spf13/cobra v0.0.0-20171207074935-ccaecb155a21/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v0.0.0-20180601132542-3ebe029320b2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/src-d/gcfg v1.3.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= @@ -158,9 +147,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3 h1:sAlSBRDl4psFR3ysKXRSE8ss6Mt90+ma1zRTroTNBJA= github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5/go.mod h1:ppEjwdhyy7Y31EnHRDm1JkChoC7LXIJ7Ex0VYLWtZtQ= -github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= -golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A= @@ -178,7 +166,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -191,39 +178,41 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181112210238-4b1f3b6b1646/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190111214448-fc1d57b08d7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180709204101-e92b11657268/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601 h1:9VBRTdmgQxbs6HE0sUnMrSWNePppAJU07NYvX5dIB04= google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/grpc v0.0.0-20180710012024-c491b25057c8/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -gopkg.in/AlecAivazis/survey.v1 v1.6.1/go.mod h1:2Ehl7OqkBl3Xb8VmC4oFW2bItAhnUfzIjrOzwRxCrOU= +gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.26.0 h1:2NPPsBpD0ZoxshmLWewQru8rWmbT5JqSzz9D1ZrAjYQ= gopkg.in/go-playground/validator.v9 v9.26.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/src-d/go-billy.v4 v4.2.0/go.mod h1:ZHSF0JP+7oD97194otDUCD7Ofbk63+xFcfWP5bT6h+Q= gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= -gopkg.in/src-d/go-git-fixtures.v3 v3.3.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= gopkg.in/src-d/go-git.v4 v4.5.0/go.mod h1:CzbUWqMn4pvmvndg3gnh5iZFmSsbhyhUWdI0IQ60AQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From eacfda562a643ae9dd964511b578145cafb40316 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 17:28:34 +0200 Subject: [PATCH 10/20] Remove protobuf struct from build --- scripts/build-proto.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/build-proto.sh b/scripts/build-proto.sh index 2c8bc444f..c6f5c9454 100755 --- a/scripts/build-proto.sh +++ b/scripts/build-proto.sh @@ -7,8 +7,6 @@ PROJECT=/project GRPC=$PROJECT/protobuf GRPC_PLUGIN="--go_out=plugins=grpc,paths=source_relative:." -protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/struct.proto - protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/event.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/execution.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/instance.proto From 32fb8b05440a9d9bf057ec128bfc688074628b53 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 17:29:00 +0200 Subject: [PATCH 11/20] Extract include files from protoc --- Dockerfile.tools | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.tools b/Dockerfile.tools index cfed215a1..ccac4ba96 100644 --- a/Dockerfile.tools +++ b/Dockerfile.tools @@ -21,7 +21,8 @@ ARG protobuf=3.8.0 RUN wget -q https://github.com/protocolbuffers/protobuf/releases/download/v$protobuf/protoc-$protobuf-linux-x86_64.zip -O /tmp/protobuf.zip && \ mkdir /tmp/protobuf && \ unzip /tmp/protobuf.zip -d /tmp/protobuf && \ - mv /tmp/protobuf/bin/protoc /usr/local/bin/protoc && \ + mv /tmp/protobuf/bin/* /usr/local/bin/ && \ + mv /tmp/protobuf/include/* /usr/local/include/ && \ rm -rf /tmp/* RUN go install github.com/go-bindata/go-bindata/go-bindata From 1bbb8e46ee37377dc76f0526ad7f2f2a1ff995af Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 17:29:17 +0200 Subject: [PATCH 12/20] Use google.protobuf.Struct --- protobuf/api/event.pb.go | 49 ++--- protobuf/api/event.proto | 4 +- protobuf/api/execution.pb.go | 78 ++++---- protobuf/api/execution.proto | 6 +- protobuf/convert/pbstruct.go | 113 ++++++------ protobuf/types/event.pb.go | 38 ++-- protobuf/types/event.proto | 2 +- protobuf/types/execution.pb.go | 55 +++--- protobuf/types/execution.proto | 6 +- protobuf/types/struct.pb.go | 324 --------------------------------- protobuf/types/struct.proto | 89 --------- 11 files changed, 178 insertions(+), 586 deletions(-) delete mode 100644 protobuf/types/struct.pb.go delete mode 100644 protobuf/types/struct.proto diff --git a/protobuf/api/event.pb.go b/protobuf/api/event.pb.go index 8d82fff8a..a94fec8a7 100644 --- a/protobuf/api/event.pb.go +++ b/protobuf/api/event.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + _struct "github.com/golang/protobuf/ptypes/struct" types "github.com/mesg-foundation/engine/protobuf/types" grpc "google.golang.org/grpc" math "math" @@ -130,10 +131,10 @@ type CreateEventRequest struct { // key is the key of the event. Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` // data is the data for the event. - Data *types.Struct `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Data *_struct.Struct `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateEventRequest) Reset() { *m = CreateEventRequest{} } @@ -175,7 +176,7 @@ func (m *CreateEventRequest) GetKey() string { return "" } -func (m *CreateEventRequest) GetData() *types.Struct { +func (m *CreateEventRequest) GetData() *_struct.Struct { if m != nil { return m.Data } @@ -233,25 +234,25 @@ func init() { func init() { proto.RegisterFile("protobuf/api/event.proto", fileDescriptor_c0ad091fa003d2ac) } var fileDescriptor_c0ad091fa003d2ac = []byte{ - // 279 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0xcf, 0x4a, 0xf3, 0x40, - 0x10, 0x6f, 0x9a, 0x7e, 0x81, 0x6f, 0x5a, 0x41, 0xc6, 0x83, 0x61, 0x05, 0xd1, 0x3d, 0xe9, 0x25, - 0x91, 0x14, 0xbc, 0x79, 0x12, 0xc5, 0x73, 0x7c, 0x82, 0x6d, 0x9c, 0xd2, 0xa0, 0x4d, 0xd6, 0xdd, - 0x89, 0x50, 0x7c, 0x19, 0x1f, 0x55, 0x32, 0x09, 0xc5, 0x34, 0x7a, 0x1b, 0x7e, 0xff, 0x76, 0xe6, - 0xb7, 0x10, 0x5b, 0x57, 0x73, 0xbd, 0x6a, 0xd6, 0xa9, 0xb1, 0x65, 0x4a, 0x1f, 0x54, 0x71, 0x22, - 0x10, 0x86, 0xc6, 0x96, 0xea, 0x6c, 0x4f, 0xf3, 0xce, 0x92, 0x4f, 0x3d, 0xbb, 0xa6, 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, 0x00, 0x00, + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0xcd, 0x4a, 0xc3, 0x40, + 0x10, 0x6e, 0xda, 0x1a, 0x70, 0xda, 0x83, 0x8c, 0x87, 0x86, 0x45, 0x44, 0xf6, 0xa4, 0x08, 0x5b, + 0x69, 0xc1, 0x9b, 0x27, 0x51, 0x3c, 0xc7, 0x27, 0xd8, 0xc6, 0x69, 0x1b, 0xac, 0xc9, 0x9a, 0x9d, + 0x28, 0xc5, 0x97, 0xf1, 0x51, 0x25, 0x93, 0x18, 0x8c, 0xd1, 0xdb, 0xf0, 0xfd, 0xed, 0xcc, 0xb7, + 0x10, 0xb9, 0x22, 0xe7, 0x7c, 0x55, 0xae, 0xe7, 0xd6, 0xa5, 0x73, 0x7a, 0xa3, 0x8c, 0x8d, 0x40, + 0x38, 0xb2, 0x2e, 0x55, 0x27, 0x9b, 0x3c, 0xdf, 0xec, 0x68, 0xde, 0xaa, 0x3c, 0x17, 0x65, 0xd2, + 0x48, 0x94, 0x6a, 0x61, 0xde, 0x3b, 0xf2, 0x3f, 0xed, 0xfa, 0x33, 0x00, 0x7c, 0xe4, 0x82, 0xec, + 0xcb, 0x5d, 0x85, 0xc6, 0xf4, 0x5a, 0x92, 0x67, 0xbc, 0x86, 0x70, 0x9d, 0xee, 0x98, 0x8a, 0x28, + 0x38, 0x0b, 0xce, 0x27, 0x8b, 0x53, 0x63, 0x5d, 0x6a, 0xfa, 0x42, 0x73, 0x2f, 0xaa, 0xb8, 0x51, + 0xab, 0x18, 0xc2, 0x1a, 0x41, 0x84, 0xf1, 0xd6, 0xfa, 0xad, 0xf8, 0x0f, 0x63, 0x99, 0x51, 0xc3, + 0x34, 0xcd, 0x3c, 0xdb, 0x2c, 0xa1, 0x87, 0x8a, 0x1b, 0x0a, 0xd7, 0xc1, 0xf0, 0x08, 0x46, 0xcf, + 0xb4, 0x8f, 0x46, 0x42, 0x55, 0xa3, 0x7e, 0x07, 0xbc, 0x2d, 0xc8, 0x32, 0x75, 0x36, 0xfc, 0x9d, + 0x15, 0xfc, 0x9f, 0x35, 0x6c, 0xb3, 0xf0, 0x12, 0xc6, 0x4f, 0x96, 0xad, 0xc4, 0x4f, 0x16, 0x33, + 0x53, 0xf7, 0x66, 0xbe, 0x0b, 0xaa, 0x2e, 0x2c, 0x13, 0x8e, 0x45, 0xa4, 0x2f, 0xe0, 0xb8, 0xf3, + 0xb0, 0x77, 0x79, 0xe6, 0xe9, 0xaf, 0xcb, 0x16, 0x1f, 0x70, 0x20, 0x22, 0xbc, 0x81, 0xb0, 0xf6, + 0xe0, 0x4c, 0x2a, 0xeb, 0x6f, 0xae, 0xa2, 0x3e, 0x51, 0x27, 0xeb, 0x01, 0x2e, 0x21, 0xac, 0x4b, + 0x6e, 0xec, 0xfd, 0xc6, 0xd5, 0xd4, 0xc8, 0x2f, 0x1a, 0x01, 0xf5, 0xe0, 0x2a, 0x58, 0x85, 0xb2, + 0xfe, 0xf2, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x68, 0x3c, 0x8a, 0x99, 0x25, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/event.proto b/protobuf/api/event.proto index d96803c4f..e8920bf0e 100644 --- a/protobuf/api/event.proto +++ b/protobuf/api/event.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "protobuf/types/struct.proto"; +import "google/protobuf/struct.proto"; import "protobuf/types/event.proto"; package api; @@ -46,7 +46,7 @@ message CreateEventRequest { string key = 2; // data is the data for the event. - types.Struct data = 3; + google.protobuf.Struct data = 3; } // CreateEventResponse defines response for execution update. diff --git a/protobuf/api/execution.pb.go b/protobuf/api/execution.pb.go index a4256ba6a..25ed7fa9f 100644 --- a/protobuf/api/execution.pb.go +++ b/protobuf/api/execution.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + _struct "github.com/golang/protobuf/ptypes/struct" types "github.com/mesg-foundation/engine/protobuf/types" grpc "google.golang.org/grpc" math "math" @@ -25,13 +26,13 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // CreateExecutionRequest defines request to create a single execution. type CreateExecutionRequest struct { - InstanceHash string `protobuf:"bytes,1,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` - TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty"` - Inputs *types.Struct `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` - Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + InstanceHash string `protobuf:"bytes,1,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty"` + Inputs *_struct.Struct `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` + Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateExecutionRequest) Reset() { *m = CreateExecutionRequest{} } @@ -73,7 +74,7 @@ func (m *CreateExecutionRequest) GetTaskKey() string { return "" } -func (m *CreateExecutionRequest) GetInputs() *types.Struct { +func (m *CreateExecutionRequest) GetInputs() *_struct.Struct { if m != nil { return m.Inputs } @@ -330,7 +331,7 @@ type isUpdateExecutionRequest_Result interface { } type UpdateExecutionRequest_Outputs struct { - Outputs *types.Struct `protobuf:"bytes,2,opt,name=outputs,proto3,oneof"` + Outputs *_struct.Struct `protobuf:"bytes,2,opt,name=outputs,proto3,oneof"` } type UpdateExecutionRequest_Error struct { @@ -348,7 +349,7 @@ func (m *UpdateExecutionRequest) GetResult() isUpdateExecutionRequest_Result { return nil } -func (m *UpdateExecutionRequest) GetOutputs() *types.Struct { +func (m *UpdateExecutionRequest) GetOutputs() *_struct.Struct { if x, ok := m.GetResult().(*UpdateExecutionRequest_Outputs); ok { return x.Outputs } @@ -415,34 +416,35 @@ func init() { func init() { proto.RegisterFile("protobuf/api/execution.proto", fileDescriptor_96e2c86581f82f05) } var fileDescriptor_96e2c86581f82f05 = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xc1, 0x6e, 0xd4, 0x30, - 0x14, 0x8c, 0x37, 0x25, 0xed, 0xbe, 0x02, 0x42, 0x46, 0xda, 0x86, 0xb4, 0x42, 0x91, 0x25, 0xa4, - 0xec, 0x81, 0x2c, 0xda, 0xde, 0xe0, 0x06, 0x2a, 0x5d, 0x89, 0x9b, 0x2b, 0x3e, 0xc0, 0x5d, 0x5e, - 0x69, 0x44, 0x49, 0x8c, 0xfd, 0x2c, 0xb1, 0x1f, 0xc0, 0x89, 0x13, 0xff, 0xc7, 0xc7, 0xa0, 0xb5, - 0xb3, 0x81, 0x36, 0xa6, 0x37, 0x7b, 0x66, 0x9e, 0x3d, 0x9e, 0x49, 0xe0, 0x44, 0x9b, 0x8e, 0xba, - 0x4b, 0x77, 0xb5, 0x50, 0xba, 0x59, 0xe0, 0x77, 0x5c, 0x3b, 0x6a, 0xba, 0xb6, 0xf6, 0x30, 0x4f, - 0x95, 0x6e, 0x8a, 0xe3, 0x41, 0x42, 0x1b, 0x8d, 0x76, 0x61, 0xc9, 0xb8, 0x35, 0x05, 0x45, 0xf1, - 0xfc, 0x0e, 0x79, 0xe7, 0x04, 0xf1, 0x8b, 0xc1, 0xec, 0x9d, 0x41, 0x45, 0x78, 0xb6, 0x63, 0x24, - 0x7e, 0x73, 0x68, 0x89, 0x0b, 0x78, 0xd8, 0xb4, 0x96, 0x54, 0xbb, 0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x32, 0x6c, 0xdf, 0x1e, 0x40, 0x66, 0xd0, 0xba, 0x1b, 0x12, 0xcf, 0xe0, 0x68, 0x74, 0x75, 0xe8, - 0x6c, 0xf9, 0x73, 0x02, 0xd3, 0x01, 0xe5, 0x67, 0x90, 0x85, 0x72, 0xf9, 0xb1, 0x4f, 0x38, 0xfe, - 0xf1, 0x15, 0x27, 0x71, 0x32, 0x1c, 0x29, 0x12, 0x7e, 0x0a, 0xe9, 0x39, 0x12, 0xcf, 0xbd, 0x2c, - 0x52, 0x7f, 0xf1, 0xa4, 0x7f, 0xcc, 0x40, 0x88, 0x84, 0xbf, 0x81, 0x2c, 0x14, 0xda, 0xdf, 0x1d, - 0x6f, 0x37, 0x36, 0xfa, 0x8a, 0x6d, 0x8d, 0x87, 0x17, 0xf6, 0xc3, 0xf1, 0xa4, 0x7b, 0xe3, 0xff, - 0xc9, 0x42, 0x24, 0x97, 0x99, 0xff, 0xef, 0x4e, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x93, 0xdb, - 0xad, 0x1e, 0xd9, 0x03, 0x00, 0x00, + // 433 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xc1, 0x6e, 0x13, 0x31, + 0x14, 0x5c, 0x67, 0xcb, 0xb6, 0x79, 0x05, 0x84, 0x8c, 0x94, 0x2c, 0x4b, 0x84, 0x22, 0x9f, 0xd2, + 0x03, 0x0e, 0x4a, 0x6e, 0x70, 0x03, 0x95, 0x46, 0xe2, 0xb6, 0x11, 0x1f, 0xe0, 0x86, 0xd7, 0x74, + 0x45, 0xd8, 0x35, 0xf6, 0xb3, 0x44, 0xcf, 0x88, 0x13, 0x9f, 0xc0, 0xaf, 0xf1, 0x31, 0xa8, 0xf6, + 0xee, 0xa2, 0xb2, 0xa6, 0x37, 0x7b, 0x66, 0x9e, 0x3d, 0x9e, 0x31, 0xcc, 0xb4, 0x69, 0x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06, 0x59, 0x80, 0xf8, 0x19, 0x9c, 0x58, 0x52, 0xe4, 0x2c, 0xda, + 0x9c, 0xcd, 0xd3, 0xc5, 0xe3, 0xd5, 0x23, 0xe9, 0x3b, 0x90, 0x5b, 0x0f, 0x97, 0x3d, 0x3d, 0x48, + 0x7a, 0x74, 0x7f, 0xd2, 0xe9, 0xdd, 0xa4, 0x63, 0xc1, 0x7d, 0x67, 0x30, 0xf9, 0xa8, 0x3f, 0xc5, + 0x6a, 0x8d, 0xa4, 0xc1, 0xd7, 0x70, 0xdc, 0x38, 0xf2, 0x6d, 0x8d, 0xee, 0x6d, 0x6b, 0x93, 0x94, + 0x9d, 0x92, 0x4f, 0xe0, 0x01, 0x1a, 0xd3, 0x98, 0xe0, 0x67, 0x93, 0x94, 0x61, 0xfb, 0xf6, 0x04, + 0x32, 0x83, 0xd6, 0x1d, 0x48, 0x3c, 0x83, 0xe9, 0xc0, 0x44, 0xa8, 0x6f, 0xf5, 0x73, 0x04, 0xe3, + 0x1e, 0xe5, 0xe7, 0x90, 0x85, 0x9e, 0xf9, 0x73, 0x1f, 0x76, 0xfc, 0x47, 0x16, 0xb3, 0x38, 0x19, + 0x8e, 0x14, 0x09, 0x5f, 0x43, 0x7a, 0x81, 0xc4, 0x73, 0x2f, 0x8b, 0xfc, 0x84, 0xe2, 0x49, 0xdb, + 0x40, 0x4f, 0x88, 0x84, 0xbf, 0x81, 0x2c, 0x74, 0xdb, 0xde, 0x1d, 0x2f, 0x3a, 0x36, 0xfa, 0x8a, + 0xdd, 0x1a, 0x0f, 0x2f, 0x6c, 0x87, 0xe3, 0x99, 0xb7, 0xc6, 0xff, 0x93, 0x85, 0x48, 0x2e, 0x33, + 0x1f, 0xf3, 0xfa, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x97, 0x21, 0x44, 0x6d, 0xef, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/execution.proto b/protobuf/api/execution.proto index e56f7b7c5..b9e1e6ecc 100644 --- a/protobuf/api/execution.proto +++ b/protobuf/api/execution.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "protobuf/types/struct.proto"; +import "google/protobuf/struct.proto"; import "protobuf/types/execution.proto"; package api; @@ -30,7 +30,7 @@ service Execution { message CreateExecutionRequest { string instanceHash = 1; string taskKey = 2; - types.Struct inputs = 3; + google.protobuf.Struct inputs = 3; repeated string tags = 4; } @@ -75,7 +75,7 @@ message UpdateExecutionRequest { // result pass to execution oneof result { // outputs is a success result. - types.Struct outputs = 2; + google.protobuf.Struct outputs = 2; // error is an error result. string error = 3; diff --git a/protobuf/convert/pbstruct.go b/protobuf/convert/pbstruct.go index 57def81e8..06849e95a 100644 --- a/protobuf/convert/pbstruct.go +++ b/protobuf/convert/pbstruct.go @@ -3,11 +3,11 @@ package convert import ( "reflect" - "github.com/mesg-foundation/engine/protobuf/types" + structpb "github.com/golang/protobuf/ptypes/struct" ) // PbStructToMap converts protobuf struct to map[string]interface{}. -func PbStructToMap(s *types.Struct) map[string]interface{} { +func PbStructToMap(s *structpb.Struct) map[string]interface{} { m := make(map[string]interface{}) for k, v := range s.Fields { m[k] = PbValueToInterface(v) @@ -16,19 +16,19 @@ func PbStructToMap(s *types.Struct) map[string]interface{} { } // PbValueToInterface converts protobuf value to interface{}. -func PbValueToInterface(v *types.Value) interface{} { +func PbValueToInterface(v *structpb.Value) interface{} { switch v.Kind.(type) { - case *types.Value_NullValue: + case *structpb.Value_NullValue: return nil - case *types.Value_NumberValue: + case *structpb.Value_NumberValue: return v.GetNumberValue() - case *types.Value_StringValue: + case *structpb.Value_StringValue: return v.GetStringValue() - case *types.Value_BoolValue: + case *structpb.Value_BoolValue: return v.GetBoolValue() - case *types.Value_StructValue: + case *structpb.Value_StructValue: return PbStructToMap(v.GetStructValue()) - case *types.Value_ListValue: + case *structpb.Value_ListValue: lv := v.GetListValue() if len(lv.Values) == 0 { return nil @@ -43,13 +43,13 @@ func PbValueToInterface(v *types.Value) interface{} { } // MapToPbStruct converts map[string]interface{} to protobuf struct. -func MapToPbStruct(m map[string]interface{}) *types.Struct { +func MapToPbStruct(m map[string]interface{}) *structpb.Struct { if len(m) == 0 { return nil } - s := &types.Struct{ - Fields: make(map[string]*types.Value, len(m)), + s := &structpb.Struct{ + Fields: make(map[string]*structpb.Value, len(m)), } for k, v := range m { @@ -59,97 +59,97 @@ func MapToPbStruct(m map[string]interface{}) *types.Struct { } // InterfaceToPbValue converts interface{} to protobuf value. -func InterfaceToPbValue(v interface{}) *types.Value { +func InterfaceToPbValue(v interface{}) *structpb.Value { switch v := v.(type) { case nil: return nil case bool: - return &types.Value{ - Kind: &types.Value_BoolValue{ + return &structpb.Value{ + Kind: &structpb.Value_BoolValue{ BoolValue: v, }, } case int: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case int8: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case int16: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case int32: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case int64: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case uint: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case uint8: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case uint16: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case uint32: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case uint64: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case float32: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: float64(v), }, } case float64: - return &types.Value{ - Kind: &types.Value_NumberValue{ + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ NumberValue: v, }, } case string: - return &types.Value{ - Kind: &types.Value_StringValue{ + return &structpb.Value{ + Kind: &structpb.Value_StringValue{ StringValue: v, }, } case error: - return &types.Value{ - Kind: &types.Value_StringValue{ + return &structpb.Value{ + Kind: &structpb.Value_StringValue{ StringValue: v.Error(), }, } @@ -159,7 +159,7 @@ func InterfaceToPbValue(v interface{}) *types.Value { } // reflectValueToPbValue converts reflect.Value to protobuf value. -func reflectValueToPbValue(v reflect.Value) *types.Value { +func reflectValueToPbValue(v reflect.Value) *structpb.Value { switch v.Kind() { case reflect.Ptr: if v.IsNil() { @@ -170,13 +170,13 @@ func reflectValueToPbValue(v reflect.Value) *types.Value { if v.Len() == 0 { return nil } - values := make([]*types.Value, v.Len()) + values := make([]*structpb.Value, v.Len()) for i := 0; i < v.Len(); i++ { values[i] = reflectValueToPbValue(v.Index(i)) } - return &types.Value{ - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{ + return &structpb.Value{ + Kind: &structpb.Value_ListValue{ + ListValue: &structpb.ListValue{ Values: values, }, }, @@ -187,10 +187,9 @@ func reflectValueToPbValue(v reflect.Value) *types.Value { if size == 0 { return nil } - fields := make(map[string]*types.Value, size) + fields := make(map[string]*structpb.Value, size) for i := 0; i < size; i++ { name := t.Field(i).Name - // Better way? if len(name) > 0 && 'A' <= name[0] && name[0] <= 'Z' { fields[name] = reflectValueToPbValue(v.Field(i)) } @@ -198,9 +197,9 @@ func reflectValueToPbValue(v reflect.Value) *types.Value { if len(fields) == 0 { return nil } - return &types.Value{ - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ + return &structpb.Value{ + Kind: &structpb.Value_StructValue{ + StructValue: &structpb.Struct{ Fields: fields, }, }, @@ -210,7 +209,7 @@ func reflectValueToPbValue(v reflect.Value) *types.Value { if len(keys) == 0 { return nil } - fields := make(map[string]*types.Value, len(keys)) + fields := make(map[string]*structpb.Value, len(keys)) for _, k := range keys { if k.Kind() == reflect.String { fields[k.String()] = reflectValueToPbValue(v.MapIndex(k)) @@ -219,9 +218,9 @@ func reflectValueToPbValue(v reflect.Value) *types.Value { if len(fields) == 0 { return nil } - return &types.Value{ - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ + return &structpb.Value{ + Kind: &structpb.Value_StructValue{ + StructValue: &structpb.Struct{ Fields: fields, }, }, diff --git a/protobuf/types/event.pb.go b/protobuf/types/event.pb.go index 752517257..14a172128 100644 --- a/protobuf/types/event.pb.go +++ b/protobuf/types/event.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" proto "github.com/golang/protobuf/proto" + _struct "github.com/golang/protobuf/ptypes/struct" math "math" ) @@ -29,10 +30,10 @@ type Event struct { // key is the key of the event. Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // data is the data for the event. - Data *Struct `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Data *_struct.Struct `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Event) Reset() { *m = Event{} } @@ -81,7 +82,7 @@ func (m *Event) GetKey() string { return "" } -func (m *Event) GetData() *Struct { +func (m *Event) GetData() *_struct.Struct { if m != nil { return m.Data } @@ -95,17 +96,18 @@ func init() { func init() { proto.RegisterFile("protobuf/types/event.proto", fileDescriptor_118d36ccf50c3798) } var fileDescriptor_118d36ccf50c3798 = []byte{ - // 191 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x8e, 0x41, 0x8b, 0x83, 0x30, - 0x10, 0x85, 0x71, 0xd5, 0x85, 0xcd, 0xee, 0xc2, 0x92, 0x93, 0xb8, 0x17, 0xeb, 0xc9, 0x4b, 0x93, - 0x62, 0xff, 0x41, 0xa1, 0xd0, 0xb3, 0xbd, 0xf5, 0x16, 0x75, 0xd4, 0x50, 0x4c, 0xc4, 0x4c, 0x0a, - 0xfe, 0xfb, 0xe2, 0xd0, 0x8b, 0xbd, 0xbd, 0x7c, 0xdf, 0x0b, 0x6f, 0x58, 0x3a, 0xcd, 0x16, 0x6d, - 0xed, 0x3b, 0x89, 0xcb, 0x04, 0x4e, 0xc2, 0x03, 0x0c, 0x0a, 0x82, 0x3c, 0x26, 0x94, 0xfe, 0xbf, - 0x55, 0x1c, 0xce, 0xbe, 0x79, 0x75, 0x72, 0x64, 0xf1, 0x79, 0xfd, 0xc2, 0x39, 0x8b, 0x06, 0xe5, - 0x86, 0x24, 0xc8, 0x82, 0xe2, 0xab, 0xa2, 0xcc, 0x73, 0xf6, 0xa3, 0x8d, 0x43, 0x65, 0x1a, 0xb8, - 0xac, 0xee, 0x83, 0xdc, 0x86, 0xf1, 0x3f, 0x16, 0xde, 0x61, 0x49, 0x42, 0x52, 0x6b, 0xe4, 0x3b, - 0x16, 0xb5, 0x0a, 0x55, 0x12, 0x65, 0x41, 0xf1, 0x5d, 0xfe, 0x0a, 0x5a, 0x15, 0x57, 0x5a, 0xad, - 0x48, 0x9d, 0xca, 0xdb, 0xa1, 0xd7, 0x38, 0xf8, 0x5a, 0x34, 0x76, 0x94, 0x23, 0xb8, 0x7e, 0xdf, - 0x59, 0x6f, 0x5a, 0x85, 0xda, 0x1a, 0x09, 0xa6, 0xd7, 0x06, 0xe4, 0xf6, 0xec, 0xfa, 0x93, 0xde, - 0xc7, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x27, 0xd4, 0xa8, 0x93, 0xf2, 0x00, 0x00, 0x00, + // 202 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x28, 0xca, 0x2f, + 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, + 0xd1, 0x03, 0x0b, 0x0a, 0xb1, 0x82, 0x85, 0xa4, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, + 0xe1, 0x2a, 0x8b, 0x4b, 0x8a, 0x4a, 0x93, 0xa1, 0x8a, 0x94, 0xea, 0xb8, 0x58, 0x5d, 0x41, 0x7a, + 0x84, 0x84, 0xb8, 0x58, 0x32, 0x12, 0x8b, 0x33, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, + 0x6c, 0x21, 0x25, 0x2e, 0x9e, 0xcc, 0xbc, 0xe2, 0x92, 0xc4, 0xbc, 0xe4, 0x54, 0x0f, 0x90, 0x1c, + 0x13, 0x58, 0x0e, 0x45, 0x4c, 0x48, 0x80, 0x8b, 0x39, 0x3b, 0xb5, 0x52, 0x82, 0x19, 0x2c, 0x05, + 0x62, 0x0a, 0x69, 0x73, 0xb1, 0xa4, 0x24, 0x96, 0x24, 0x4a, 0xb0, 0x28, 0x30, 0x6a, 0x70, 0x1b, + 0x89, 0xeb, 0x41, 0xec, 0xd7, 0x83, 0xd9, 0xaf, 0x17, 0x0c, 0xb6, 0x3f, 0x08, 0xac, 0xc8, 0xc9, + 0x28, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x37, 0xb5, + 0x38, 0x5d, 0x37, 0x2d, 0xbf, 0x34, 0x2f, 0x25, 0xb1, 0x24, 0x33, 0x3f, 0x4f, 0x3f, 0x35, 0x2f, + 0x3d, 0x33, 0x0f, 0xc9, 0xe9, 0x60, 0x1f, 0x25, 0xb1, 0x81, 0xf9, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xb4, 0x6b, 0x0b, 0x88, 0xfd, 0x00, 0x00, 0x00, } diff --git a/protobuf/types/event.proto b/protobuf/types/event.proto index 19a569da1..d93ef0adf 100644 --- a/protobuf/types/event.proto +++ b/protobuf/types/event.proto @@ -17,5 +17,5 @@ message Event { string key = 3; // data is the data for the event. - struct.Struct data = 4; + google.protobuf.Struct data = 4; } diff --git a/protobuf/types/execution.pb.go b/protobuf/types/execution.pb.go index 1d9ea2d5e..942596fe7 100644 --- a/protobuf/types/execution.pb.go +++ b/protobuf/types/execution.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" proto "github.com/golang/protobuf/proto" + _struct "github.com/golang/protobuf/ptypes/struct" math "math" ) @@ -77,9 +78,9 @@ type Execution struct { // taskKey is the key of the task of this execution. TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty"` // inputs data of the execution. - Inputs *Struct `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty"` + Inputs *_struct.Struct `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty"` // outputs are the returned data of successful execution. - Outputs *Struct `protobuf:"bytes,8,opt,name=outputs,proto3" json:"outputs,omitempty"` + Outputs *_struct.Struct `protobuf:"bytes,8,opt,name=outputs,proto3" json:"outputs,omitempty"` // error message of a failed execution. Error string `protobuf:"bytes,9,opt,name=error,proto3" json:"error,omitempty"` // tags are optionally associated with execution by the user. @@ -156,14 +157,14 @@ func (m *Execution) GetTaskKey() string { return "" } -func (m *Execution) GetInputs() *Struct { +func (m *Execution) GetInputs() *_struct.Struct { if m != nil { return m.Inputs } return nil } -func (m *Execution) GetOutputs() *Struct { +func (m *Execution) GetOutputs() *_struct.Struct { if m != nil { return m.Outputs } @@ -192,27 +193,27 @@ func init() { func init() { proto.RegisterFile("protobuf/types/execution.proto", fileDescriptor_42e00237fcad5e7f) } var fileDescriptor_42e00237fcad5e7f = []byte{ - // 339 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xdf, 0x4a, 0xeb, 0x40, - 0x10, 0xc6, 0x4f, 0xfa, 0x27, 0x39, 0x99, 0x9e, 0x96, 0xb0, 0x9c, 0x8b, 0xa0, 0x52, 0x42, 0x41, - 0x2c, 0x82, 0x89, 0xd4, 0x37, 0xb0, 0x28, 0x8a, 0x08, 0x52, 0xf1, 0xc6, 0xbb, 0x6d, 0x3a, 0x4d, - 0x43, 0xdb, 0xdd, 0xb0, 0x3b, 0xab, 0xf6, 0xdd, 0x7c, 0x38, 0xd9, 0x6d, 0x83, 0xad, 0x78, 0xb7, - 0xdf, 0xf7, 0xfb, 0x32, 0x93, 0x99, 0x81, 0x7e, 0xa5, 0x24, 0xc9, 0xa9, 0x99, 0x67, 0xb4, 0xa9, - 0x50, 0x67, 0xf8, 0x81, 0xb9, 0xa1, 0x52, 0x8a, 0xd4, 0x01, 0xd6, 0x76, 0xf6, 0xd1, 0xf1, 0x8f, - 0x98, 0x26, 0x65, 0x72, 0xda, 0x66, 0x06, 0x9f, 0x0d, 0x08, 0x6f, 0xea, 0xef, 0x18, 0x83, 0xd6, - 0x82, 0xeb, 0x45, 0xec, 0x25, 0xde, 0x30, 0x9c, 0xb8, 0x37, 0xeb, 0x03, 0x54, 0x5c, 0xa1, 0xa0, - 0x3b, 0x4b, 0x1a, 0x8e, 0xec, 0x39, 0xec, 0x04, 0x42, 0x7c, 0xab, 0x71, 0xd3, 0xe1, 0x6f, 0x83, - 0x9d, 0x82, 0xaf, 0x89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00, 0xff, 0xff, 0x14, 0x7b, 0x62, 0x8d, 0x0e, - 0x02, 0x00, 0x00, + // 352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xdd, 0x4a, 0xfb, 0x40, + 0x10, 0xc5, 0xff, 0xe9, 0x47, 0xf2, 0xcf, 0xd4, 0x96, 0xb0, 0x08, 0x06, 0x29, 0x25, 0x14, 0x84, + 0x22, 0x98, 0x68, 0x7d, 0x03, 0x8b, 0xa2, 0x88, 0x20, 0x2d, 0xde, 0x78, 0xb7, 0x4d, 0xa7, 0x69, + 0x68, 0xbb, 0x1b, 0xf6, 0x43, 0xed, 0x5b, 0xfa, 0x48, 0x92, 0x49, 0xa3, 0xf5, 0xc6, 0xbb, 0x3d, + 0xe7, 0x77, 0x66, 0x93, 0x33, 0x0b, 0x83, 0x42, 0x49, 0x23, 0xe7, 0x76, 0x99, 0x98, 0x5d, 0x81, + 0x3a, 0xc1, 0x0f, 0x4c, 0xad, 0xc9, 0xa5, 0x88, 0x09, 0xb0, 0x36, 0xd9, 0xa7, 0xfd, 0x4c, 0xca, + 0x6c, 0x83, 0xc9, 0x77, 0x5a, 0x1b, 0x65, 0x53, 0x53, 0x85, 0x86, 0x9f, 0x0d, 0xf0, 0x6f, 0xeb, + 0x41, 0xc6, 0xa0, 0xb5, 0xe2, 0x7a, 0x15, 0x3a, 0x91, 0x33, 0xf2, 0xa7, 0x74, 0x66, 0x03, 0x80, + 0x82, 0x2b, 0x14, 0xe6, 0xbe, 0x24, 0x0d, 0x22, 0x07, 0x0e, 0xeb, 0x83, 0x8f, 0x6f, 0x35, 0x6e, + 0x12, 0xfe, 0x31, 0xd8, 0x19, 0xb8, 0xda, 0x70, 0x63, 0x75, 0xd8, 0x8a, 0x9c, 0x51, 0x6f, 0xdc, + 0x8d, 0xe9, 0xaf, 0xe2, 0x19, 0x99, 0xd3, 0x3d, 0x64, 0x43,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--git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index 24550211e..a0fe00f57 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "protobuf/types/struct.proto"; +import "google/protobuf/struct.proto"; package types; option go_package = "github.com/mesg-foundation/engine/protobuf/types"; @@ -46,10 +46,10 @@ message Execution { string taskKey = 6; // inputs data of the execution. - types.Struct inputs = 7; + google.protobuf.Struct inputs = 7; // outputs are the returned data of successful execution. - types.Struct outputs = 8; + google.protobuf.Struct outputs = 8; // error message of a failed execution. string error = 9; diff --git a/protobuf/types/struct.pb.go b/protobuf/types/struct.pb.go deleted file mode 100644 index 5ee742c3b..000000000 --- a/protobuf/types/struct.pb.go +++ /dev/null @@ -1,324 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: protobuf/types/struct.proto - -package types - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -type NullValue int32 - -const ( - // Null value. - NullValue_NULL_VALUE NullValue = 0 -) - -var NullValue_name = map[int32]string{ - 0: "NULL_VALUE", -} - -var NullValue_value = map[string]int32{ - "NULL_VALUE": 0, -} - -func (x NullValue) String() string { - return proto.EnumName(NullValue_name, int32(x)) -} - -func (NullValue) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_84428fcddb6debf8, []int{0} -} - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -type Struct struct { - // Unordered map of dynamically typed values. - Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Struct) Reset() { *m = Struct{} } -func (m *Struct) String() string { return proto.CompactTextString(m) } -func (*Struct) ProtoMessage() {} -func (*Struct) Descriptor() ([]byte, []int) { - return fileDescriptor_84428fcddb6debf8, []int{0} -} - -func (m *Struct) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Struct.Unmarshal(m, b) -} -func (m *Struct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Struct.Marshal(b, m, deterministic) -} -func (m *Struct) XXX_Merge(src proto.Message) { - xxx_messageInfo_Struct.Merge(m, src) -} -func (m *Struct) XXX_Size() int { - return xxx_messageInfo_Struct.Size(m) -} -func (m *Struct) XXX_DiscardUnknown() { - xxx_messageInfo_Struct.DiscardUnknown(m) -} - -var xxx_messageInfo_Struct proto.InternalMessageInfo - -func (m *Struct) GetFields() map[string]*Value { - if m != nil { - return m.Fields - } - return nil -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -type Value struct { - // The kind of value. - // - // Types that are valid to be assigned to Kind: - // *Value_NullValue - // *Value_NumberValue - // *Value_StringValue - // *Value_BoolValue - // *Value_StructValue - // *Value_ListValue - Kind isValue_Kind `protobuf_oneof:"kind"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Value) Reset() { *m = Value{} } -func (m *Value) String() string { return proto.CompactTextString(m) } -func (*Value) ProtoMessage() {} -func (*Value) Descriptor() ([]byte, []int) { - return fileDescriptor_84428fcddb6debf8, []int{1} -} - -func (m *Value) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Value.Unmarshal(m, b) -} -func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Value.Marshal(b, m, deterministic) -} -func (m *Value) XXX_Merge(src proto.Message) { - xxx_messageInfo_Value.Merge(m, src) -} -func (m *Value) XXX_Size() int { - return xxx_messageInfo_Value.Size(m) -} -func (m *Value) XXX_DiscardUnknown() { - xxx_messageInfo_Value.DiscardUnknown(m) -} - -var xxx_messageInfo_Value proto.InternalMessageInfo - -type isValue_Kind interface { - isValue_Kind() -} - -type Value_NullValue struct { - NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=types.NullValue,oneof"` -} - -type Value_NumberValue struct { - NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"` -} - -type Value_StringValue struct { - StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` -} - -type Value_BoolValue struct { - BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` -} - -type Value_StructValue struct { - StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"` -} - -type Value_ListValue struct { - ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` -} - -func (*Value_NullValue) isValue_Kind() {} - -func (*Value_NumberValue) isValue_Kind() {} - -func (*Value_StringValue) isValue_Kind() {} - -func (*Value_BoolValue) isValue_Kind() {} - -func (*Value_StructValue) isValue_Kind() {} - -func (*Value_ListValue) isValue_Kind() {} - -func (m *Value) GetKind() isValue_Kind { - if m != nil { - return m.Kind - } - return nil -} - -func (m *Value) GetNullValue() NullValue { - if x, ok := m.GetKind().(*Value_NullValue); ok { - return x.NullValue - } - return NullValue_NULL_VALUE -} - -func (m *Value) GetNumberValue() float64 { - if x, ok := m.GetKind().(*Value_NumberValue); ok { - return x.NumberValue - } - return 0 -} - -func (m *Value) GetStringValue() string { - if x, ok := m.GetKind().(*Value_StringValue); ok { - return x.StringValue - } - return "" -} - -func (m *Value) GetBoolValue() bool { - if x, ok := m.GetKind().(*Value_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (m *Value) GetStructValue() *Struct { - if x, ok := m.GetKind().(*Value_StructValue); ok { - return x.StructValue - } - return nil -} - -func (m *Value) GetListValue() *ListValue { - if x, ok := m.GetKind().(*Value_ListValue); ok { - return x.ListValue - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Value) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Value_NullValue)(nil), - (*Value_NumberValue)(nil), - (*Value_StringValue)(nil), - (*Value_BoolValue)(nil), - (*Value_StructValue)(nil), - (*Value_ListValue)(nil), - } -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -type ListValue struct { - // Repeated field of dynamically typed values. - Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListValue) Reset() { *m = ListValue{} } -func (m *ListValue) String() string { return proto.CompactTextString(m) } -func (*ListValue) ProtoMessage() {} -func (*ListValue) Descriptor() ([]byte, []int) { - return fileDescriptor_84428fcddb6debf8, []int{2} -} - -func (m *ListValue) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListValue.Unmarshal(m, b) -} -func (m *ListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListValue.Marshal(b, m, deterministic) -} -func (m *ListValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListValue.Merge(m, src) -} -func (m *ListValue) XXX_Size() int { - return xxx_messageInfo_ListValue.Size(m) -} -func (m *ListValue) XXX_DiscardUnknown() { - xxx_messageInfo_ListValue.DiscardUnknown(m) -} - -var xxx_messageInfo_ListValue proto.InternalMessageInfo - -func (m *ListValue) GetValues() []*Value { - if m != nil { - return m.Values - } - return nil -} - -func init() { - proto.RegisterEnum("types.NullValue", NullValue_name, NullValue_value) - proto.RegisterType((*Struct)(nil), "types.Struct") - proto.RegisterMapType((map[string]*Value)(nil), "types.Struct.FieldsEntry") - proto.RegisterType((*Value)(nil), "types.Value") - proto.RegisterType((*ListValue)(nil), "types.ListValue") -} - -func init() { proto.RegisterFile("protobuf/types/struct.proto", fileDescriptor_84428fcddb6debf8) } - -var fileDescriptor_84428fcddb6debf8 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0x41, 0x6f, 0xaa, 0x40, - 0x10, 0x80, 0x5d, 0x15, 0xf2, 0x18, 0x7c, 0xc6, 0xec, 0xc9, 0xf7, 0x3c, 0x3c, 0xc2, 0xeb, 0x81, - 0x34, 0x29, 0x54, 0x7a, 0x69, 0x7a, 0xab, 0x89, 0xad, 0x07, 0xe2, 0x81, 0x46, 0x0f, 0xbd, 0x18, - 0xc1, 0x95, 0x6e, 0x5c, 0x17, 0x03, 0xbb, 0x4d, 0xbc, 0xf7, 0x27, 0xf4, 0x07, 0x37, 0x2c, 0x0b, - 0xad, 0x37, 0xe6, 0x9b, 0x6f, 0x66, 0x98, 0x01, 0x98, 0x9c, 0x8a, 0x5c, 0xe4, 0x89, 0xdc, 0x07, - 0xe2, 0x7c, 0x22, 0x65, 0x50, 0x8a, 0x42, 0xa6, 0xc2, 0x57, 0x14, 0x1b, 0x8a, 0xb9, 0x1f, 0x08, - 0xcc, 0x17, 0xc5, 0xf1, 0x14, 0xcc, 0x3d, 0x25, 0x6c, 0x57, 0x8e, 0x91, 0xd3, 0xf3, 0xec, 0xf0, - 0x8f, 0xaf, 0x14, 0xbf, 0x4e, 0xfb, 0x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0x3c, 0x04, 0x58, 0xae, 0xa2, - 0x68, 0xb3, 0x7e, 0x8c, 0x56, 0xf3, 0x51, 0x67, 0x16, 0xbe, 0xde, 0x66, 0x54, 0xbc, 0xc9, 0xc4, - 0x4f, 0xf3, 0x63, 0x70, 0x24, 0x65, 0x76, 0xb3, 0xcf, 0x25, 0xdf, 0x6d, 0x05, 0xcd, 0x79, 0x40, - 0x78, 0x46, 0x39, 0x09, 0x2e, 0xff, 0x9a, 0xc4, 0x54, 0xf1, 0xdd, 0x57, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x86, 0x01, 0xa2, 0xce, 0x4e, 0x02, 0x00, 0x00, -} diff --git a/protobuf/types/struct.proto b/protobuf/types/struct.proto deleted file mode 100644 index d63e247a2..000000000 --- a/protobuf/types/struct.proto +++ /dev/null @@ -1,89 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package types; - -option go_package = "github.com/mesg-foundation/engine/protobuf/types"; - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -message Struct { - // Unordered map of dynamically typed values. - map fields = 1; -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -message Value { - // The kind of value. - oneof kind { - // Represents a null value. - NullValue null_value = 1; - // Represents a double value. - double number_value = 2; - // Represents a string value. - string string_value = 3; - // Represents a boolean value. - bool bool_value = 4; - // Represents a structured value. - Struct struct_value = 5; - // Represents a repeated `Value`. - ListValue list_value = 6; - } -} - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -enum NullValue { - // Null value. - NULL_VALUE = 0; -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -message ListValue { - // Repeated field of dynamically typed values. - repeated Value values = 1; -} From ca83914685bb310d1981f7f00aa934c9a007fc8d Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 18:35:52 +0200 Subject: [PATCH 13/20] Add tests for protobuf convert functions --- protobuf/convert/pbstruct.go | 43 +++++++++++- protobuf/convert/pbstruct_test.go | 111 ++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 protobuf/convert/pbstruct_test.go diff --git a/protobuf/convert/pbstruct.go b/protobuf/convert/pbstruct.go index 06849e95a..c6458f43f 100644 --- a/protobuf/convert/pbstruct.go +++ b/protobuf/convert/pbstruct.go @@ -1,6 +1,7 @@ package convert import ( + "fmt" "reflect" structpb "github.com/golang/protobuf/ptypes/struct" @@ -17,6 +18,9 @@ func PbStructToMap(s *structpb.Struct) map[string]interface{} { // PbValueToInterface converts protobuf value to interface{}. func PbValueToInterface(v *structpb.Value) interface{} { + if v == nil { + return nil + } switch v.Kind.(type) { case *structpb.Value_NullValue: return nil @@ -33,6 +37,7 @@ func PbValueToInterface(v *structpb.Value) interface{} { if len(lv.Values) == 0 { return nil } + a := make([]interface{}, len(lv.Values)) for i, v := range lv.Values { a[i] = PbValueToInterface(v) @@ -166,6 +171,38 @@ func reflectValueToPbValue(v reflect.Value) *structpb.Value { return nil } return reflectValueToPbValue(reflect.Indirect(v)) + case reflect.Interface: + return InterfaceToPbValue(v.Interface()) + case reflect.Bool: + return &structpb.Value{ + Kind: &structpb.Value_BoolValue{ + BoolValue: v.Bool(), + }, + } + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ + NumberValue: float64(v.Int()), + }, + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ + NumberValue: float64(v.Uint()), + }, + } + case reflect.Float32, reflect.Float64: + return &structpb.Value{ + Kind: &structpb.Value_NumberValue{ + NumberValue: v.Float(), + }, + } + case reflect.String: + return &structpb.Value{ + Kind: &structpb.Value_StringValue{ + StringValue: v.String(), + }, + } case reflect.Array, reflect.Slice: if v.Len() == 0 { return nil @@ -226,6 +263,10 @@ func reflectValueToPbValue(v reflect.Value) *structpb.Value { }, } default: - return nil + return &structpb.Value{ + Kind: &structpb.Value_StringValue{ + StringValue: fmt.Sprint(v), + }, + } } } diff --git a/protobuf/convert/pbstruct_test.go b/protobuf/convert/pbstruct_test.go new file mode 100644 index 000000000..0956f169b --- /dev/null +++ b/protobuf/convert/pbstruct_test.go @@ -0,0 +1,111 @@ +package convert + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestConvertPbStruct(t *testing.T) { + got := map[string]interface{}{ + "nil": nil, + "bool": true, + "int": int(1), + "int8": int8(1), + "int16": int16(1), + "int32": int32(1), + "int64": int64(1), + "uint": uint(1), + "uint8": uint8(1), + "uint16": uint16(1), + "uint32": uint32(1), + "uint64": uint64(1), + "float32": float32(1), + "float64": float64(1), + "string": "string", + "error": errors.New("err"), + "intslice": []int{1}, + "stringslice": []string{"string"}, + "intarray": [1]int{1}, + "stringarray": [1]string{"string"}, + "map": map[string]interface{}{ + "nil": nil, + "bool": true, + "int": int(1), + "uint": uint(1), + "float64": float64(1), + "string": "string", + "error": errors.New("err"), + "intslice": []int{1}, + "stringslice": []string{"string"}, + }, + "struct": struct { + Nil *bool + Bool bool + Int int + Uint uint + Float64 float64 + String string + Error error + IntSlice []int + StringSlice []string + }{ + nil, + true, + int(1), + uint(1), + float64(1), + "string", + errors.New("err"), + []int{1}, + []string{"string"}, + }, + } + + want := map[string]interface{}{ + "nil": nil, + "bool": true, + "int": float64(1), + "int8": float64(1), + "int16": float64(1), + "int32": float64(1), + "int64": float64(1), + "uint": float64(1), + "uint8": float64(1), + "uint16": float64(1), + "uint32": float64(1), + "uint64": float64(1), + "float32": float64(1), + "float64": float64(1), + "string": "string", + "error": "err", + "intslice": []interface{}{float64(1)}, + "stringslice": []interface{}{"string"}, + "intarray": []interface{}{float64(1)}, + "stringarray": []interface{}{"string"}, + "map": map[string]interface{}{ + "nil": nil, + "bool": interface{}(true), + "int": float64(1), + "uint": float64(1), + "float64": float64(1), + "string": "string", + "error": "err", + "intslice": []interface{}{float64(1)}, + "stringslice": []interface{}{"string"}, + }, + "struct": map[string]interface{}{ + "Nil": nil, + "Bool": true, + "Int": float64(1), + "Uint": float64(1), + "Float64": float64(1), + "String": "string", + "Error": "err", + "IntSlice": []interface{}{float64(1)}, + "StringSlice": []interface{}{"string"}, + }, + } + require.Equal(t, want, PbStructToMap(MapToPbStruct(got))) +} From aba8fbc6658b3df73a02c660cb05fec3a503a9b9 Mon Sep 17 00:00:00 2001 From: krhubert Date: Wed, 24 Jul 2019 18:38:26 +0200 Subject: [PATCH 14/20] Update ethwallet go mod --- systemservices/ethwallet/go.mod | 2 +- systemservices/ethwallet/go.sum | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/systemservices/ethwallet/go.mod b/systemservices/ethwallet/go.mod index b88e9d7bc..daafea772 100644 --- a/systemservices/ethwallet/go.mod +++ b/systemservices/ethwallet/go.mod @@ -10,7 +10,7 @@ require ( github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.8.27 github.com/go-stack/stack v1.8.0 // indirect - github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f + github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb github.com/mitchellh/mapstructure v1.1.2 github.com/pborman/uuid v1.2.0 // indirect github.com/rjeczalik/notify v0.9.2 // indirect diff --git a/systemservices/ethwallet/go.sum b/systemservices/ethwallet/go.sum index e517fda51..3604578a6 100644 --- a/systemservices/ethwallet/go.sum +++ b/systemservices/ethwallet/go.sum @@ -103,6 +103,9 @@ github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdA github.com/lyft/protoc-gen-validate v0.1.0/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f h1:vlWi61rxeJWpgFKDefOfp12EYx6FERSfQGx99XSRDKc= github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= +github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb h1:S/CY8lw1DiHgCZx7NRXbC+2HzncVQQAXdocviaxOElg= +github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= +github.com/mesg-foundation/engine v0.11.0 h1:Fmdy+3Gqa4XyVQcRbf0wE8pk/CtYpW8xop6VWECV10E= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= From 3e817175f412e7bc924967510d7b694fcc36d7c2 Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 13:04:42 +0200 Subject: [PATCH 15/20] Use jsonpb to conver types --- protobuf/convert/pbstruct.go | 284 +++--------------------------- protobuf/convert/pbstruct_test.go | 111 ------------ server/grpc/api/event.go | 25 ++- server/grpc/api/execution.go | 40 ++++- 4 files changed, 80 insertions(+), 380 deletions(-) delete mode 100644 protobuf/convert/pbstruct_test.go diff --git a/protobuf/convert/pbstruct.go b/protobuf/convert/pbstruct.go index c6458f43f..f06e6e395 100644 --- a/protobuf/convert/pbstruct.go +++ b/protobuf/convert/pbstruct.go @@ -1,272 +1,44 @@ package convert import ( - "fmt" - "reflect" + "bytes" + "encoding/json" + "sync" - structpb "github.com/golang/protobuf/ptypes/struct" + "github.com/golang/protobuf/jsonpb" + "github.com/golang/protobuf/proto" ) -// PbStructToMap converts protobuf struct to map[string]interface{}. -func PbStructToMap(s *structpb.Struct) map[string]interface{} { - m := make(map[string]interface{}) - for k, v := range s.Fields { - m[k] = PbValueToInterface(v) - } - return m -} +var marshaler = jsonpb.Marshaler{EmitDefaults: true} -// PbValueToInterface converts protobuf value to interface{}. -func PbValueToInterface(v *structpb.Value) interface{} { - if v == nil { - return nil - } - switch v.Kind.(type) { - case *structpb.Value_NullValue: - return nil - case *structpb.Value_NumberValue: - return v.GetNumberValue() - case *structpb.Value_StringValue: - return v.GetStringValue() - case *structpb.Value_BoolValue: - return v.GetBoolValue() - case *structpb.Value_StructValue: - return PbStructToMap(v.GetStructValue()) - case *structpb.Value_ListValue: - lv := v.GetListValue() - if len(lv.Values) == 0 { - return nil - } - - a := make([]interface{}, len(lv.Values)) - for i, v := range lv.Values { - a[i] = PbValueToInterface(v) - } - return a - } - return nil +var bufPool = sync.Pool{ + New: func() interface{} { + return &bytes.Buffer{} + }, } -// MapToPbStruct converts map[string]interface{} to protobuf struct. -func MapToPbStruct(m map[string]interface{}) *structpb.Struct { - if len(m) == 0 { - return nil - } - - s := &structpb.Struct{ - Fields: make(map[string]*structpb.Value, len(m)), - } +// Marshal converts protobuf struct to map[string]interface{}. +func Marshal(in proto.Message, out interface{}) error { + buf := bufPool.Get().(*bytes.Buffer) + buf.Reset() + defer bufPool.Put(buf) - for k, v := range m { - s.Fields[k] = InterfaceToPbValue(v) + dec := json.NewDecoder(buf) + if err := marshaler.Marshal(buf, in); err != nil { + return err } - return s + return dec.Decode(out) } -// InterfaceToPbValue converts interface{} to protobuf value. -func InterfaceToPbValue(v interface{}) *structpb.Value { - switch v := v.(type) { - case nil: - return nil - case bool: - return &structpb.Value{ - Kind: &structpb.Value_BoolValue{ - BoolValue: v, - }, - } - case int: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int8: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int16: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int32: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case int64: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint8: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint16: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint32: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case uint64: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case float32: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v), - }, - } - case float64: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: v, - }, - } - case string: - return &structpb.Value{ - Kind: &structpb.Value_StringValue{ - StringValue: v, - }, - } - case error: - return &structpb.Value{ - Kind: &structpb.Value_StringValue{ - StringValue: v.Error(), - }, - } - default: - return reflectValueToPbValue(reflect.ValueOf(v)) - } -} +// Unmarshal converts map[string]interface{} to protobuf struct. +func Unmarshal(in interface{}, out proto.Message) error { + buf := bufPool.Get().(*bytes.Buffer) + buf.Reset() + defer bufPool.Put(buf) -// reflectValueToPbValue converts reflect.Value to protobuf value. -func reflectValueToPbValue(v reflect.Value) *structpb.Value { - switch v.Kind() { - case reflect.Ptr: - if v.IsNil() { - return nil - } - return reflectValueToPbValue(reflect.Indirect(v)) - case reflect.Interface: - return InterfaceToPbValue(v.Interface()) - case reflect.Bool: - return &structpb.Value{ - Kind: &structpb.Value_BoolValue{ - BoolValue: v.Bool(), - }, - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v.Int()), - }, - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: float64(v.Uint()), - }, - } - case reflect.Float32, reflect.Float64: - return &structpb.Value{ - Kind: &structpb.Value_NumberValue{ - NumberValue: v.Float(), - }, - } - case reflect.String: - return &structpb.Value{ - Kind: &structpb.Value_StringValue{ - StringValue: v.String(), - }, - } - case reflect.Array, reflect.Slice: - if v.Len() == 0 { - return nil - } - values := make([]*structpb.Value, v.Len()) - for i := 0; i < v.Len(); i++ { - values[i] = reflectValueToPbValue(v.Index(i)) - } - return &structpb.Value{ - Kind: &structpb.Value_ListValue{ - ListValue: &structpb.ListValue{ - Values: values, - }, - }, - } - case reflect.Struct: - t := v.Type() - size := v.NumField() - if size == 0 { - return nil - } - fields := make(map[string]*structpb.Value, size) - for i := 0; i < size; i++ { - name := t.Field(i).Name - if len(name) > 0 && 'A' <= name[0] && name[0] <= 'Z' { - fields[name] = reflectValueToPbValue(v.Field(i)) - } - } - if len(fields) == 0 { - return nil - } - return &structpb.Value{ - Kind: &structpb.Value_StructValue{ - StructValue: &structpb.Struct{ - Fields: fields, - }, - }, - } - case reflect.Map: - keys := v.MapKeys() - if len(keys) == 0 { - return nil - } - fields := make(map[string]*structpb.Value, len(keys)) - for _, k := range keys { - if k.Kind() == reflect.String { - fields[k.String()] = reflectValueToPbValue(v.MapIndex(k)) - } - } - if len(fields) == 0 { - return nil - } - return &structpb.Value{ - Kind: &structpb.Value_StructValue{ - StructValue: &structpb.Struct{ - Fields: fields, - }, - }, - } - default: - return &structpb.Value{ - Kind: &structpb.Value_StringValue{ - StringValue: fmt.Sprint(v), - }, - } + enc := json.NewEncoder(buf) + if err := enc.Encode(in); err != nil { + return err } + return jsonpb.Unmarshal(buf, out) } diff --git a/protobuf/convert/pbstruct_test.go b/protobuf/convert/pbstruct_test.go deleted file mode 100644 index 0956f169b..000000000 --- a/protobuf/convert/pbstruct_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package convert - -import ( - "errors" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestConvertPbStruct(t *testing.T) { - got := map[string]interface{}{ - "nil": nil, - "bool": true, - "int": int(1), - "int8": int8(1), - "int16": int16(1), - "int32": int32(1), - "int64": int64(1), - "uint": uint(1), - "uint8": uint8(1), - "uint16": uint16(1), - "uint32": uint32(1), - "uint64": uint64(1), - "float32": float32(1), - "float64": float64(1), - "string": "string", - "error": errors.New("err"), - "intslice": []int{1}, - "stringslice": []string{"string"}, - "intarray": [1]int{1}, - "stringarray": [1]string{"string"}, - "map": map[string]interface{}{ - "nil": nil, - "bool": true, - "int": int(1), - "uint": uint(1), - "float64": float64(1), - "string": "string", - "error": errors.New("err"), - "intslice": []int{1}, - "stringslice": []string{"string"}, - }, - "struct": struct { - Nil *bool - Bool bool - Int int - Uint uint - Float64 float64 - String string - Error error - IntSlice []int - StringSlice []string - }{ - nil, - true, - int(1), - uint(1), - float64(1), - "string", - errors.New("err"), - []int{1}, - []string{"string"}, - }, - } - - want := map[string]interface{}{ - "nil": nil, - "bool": true, - "int": float64(1), - "int8": float64(1), - "int16": float64(1), - "int32": float64(1), - "int64": float64(1), - "uint": float64(1), - "uint8": float64(1), - "uint16": float64(1), - "uint32": float64(1), - "uint64": float64(1), - "float32": float64(1), - "float64": float64(1), - "string": "string", - "error": "err", - "intslice": []interface{}{float64(1)}, - "stringslice": []interface{}{"string"}, - "intarray": []interface{}{float64(1)}, - "stringarray": []interface{}{"string"}, - "map": map[string]interface{}{ - "nil": nil, - "bool": interface{}(true), - "int": float64(1), - "uint": float64(1), - "float64": float64(1), - "string": "string", - "error": "err", - "intslice": []interface{}{float64(1)}, - "stringslice": []interface{}{"string"}, - }, - "struct": map[string]interface{}{ - "Nil": nil, - "Bool": true, - "Int": float64(1), - "Uint": float64(1), - "Float64": float64(1), - "String": "string", - "Error": "err", - "IntSlice": []interface{}{float64(1)}, - "StringSlice": []interface{}{"string"}, - }, - } - require.Equal(t, want, PbStructToMap(MapToPbStruct(got))) -} diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go index 94ab719f0..1f45cef46 100644 --- a/server/grpc/api/event.go +++ b/server/grpc/api/event.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + structpb "github.com/golang/protobuf/ptypes/struct" "github.com/mesg-foundation/engine/event" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" @@ -36,7 +37,11 @@ func (s *EventServer) Create(ctx context.Context, req *api.CreateEventRequest) ( return nil, errors.New("create event: key missing") } - data := convert.PbStructToMap(req.Data) + data := make(map[string]interface{}) + if err := convert.Marshal(req.Data, &data); err != nil { + return nil, err + } + event, err := s.sdk.Event.Create(instanceHash, req.Key, data) if err != nil { return nil, fmt.Errorf("create event: data %s", err) @@ -72,7 +77,12 @@ func (s *EventServer) Stream(req *api.StreamEventRequest, resp api.Event_StreamS } for event := range stream.C { - if err := resp.Send(toProtoEvent(event)); err != nil { + e, err := toProtoEvent(event) + if err != nil { + return err + } + + if err := resp.Send(e); err != nil { return err } } @@ -80,11 +90,16 @@ func (s *EventServer) Stream(req *api.StreamEventRequest, resp api.Event_StreamS return nil } -func toProtoEvent(e *event.Event) *types.Event { +func toProtoEvent(e *event.Event) (*types.Event, error) { + data := &structpb.Struct{} + if err := convert.Unmarshal(e.Data, data); err != nil { + return nil, err + } + return &types.Event{ Hash: e.Hash.String(), InstanceHash: e.InstanceHash.String(), Key: e.Key, - Data: convert.MapToPbStruct(e.Data), - } + Data: data, + }, nil } diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go index 5c174c1b2..ffd5a3027 100644 --- a/server/grpc/api/execution.go +++ b/server/grpc/api/execution.go @@ -4,6 +4,7 @@ import ( "context" "errors" + structpb "github.com/golang/protobuf/ptypes/struct" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" @@ -34,7 +35,10 @@ func (s *ExecutionServer) Create(ctx context.Context, req *api.CreateExecutionRe return nil, err } - inputs := convert.PbStructToMap(req.Inputs) + inputs := make(map[string]interface{}) + if err := convert.Marshal(req.Inputs, &inputs); err != nil { + return nil, err + } eventHash, err := hash.Random() if err != nil { return nil, err @@ -60,7 +64,7 @@ func (s *ExecutionServer) Get(ctx context.Context, req *api.GetExecutionRequest) if err != nil { return nil, err } - return toProtoExecution(exec), nil + return toProtoExecution(exec) } // Stream returns stream of executions. @@ -95,7 +99,12 @@ func (s *ExecutionServer) Stream(req *api.StreamExecutionRequest, resp api.Execu } for exec := range stream.C { - if err := resp.Send(toProtoExecution(exec)); err != nil { + e, err := toProtoExecution(exec) + if err != nil { + return err + } + + if err := resp.Send(e); err != nil { return err } } @@ -111,7 +120,12 @@ func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRe } switch res := req.Result.(type) { case *api.UpdateExecutionRequest_Outputs: - err = s.sdk.Execution.Update(hash, convert.PbStructToMap(res.Outputs), nil) + outputs := make(map[string]interface{}) + if err := convert.Marshal(res.Outputs, &outputs); err != nil { + return nil, err + } + + err = s.sdk.Execution.Update(hash, outputs, nil) case *api.UpdateExecutionRequest_Error: err = s.sdk.Execution.Update(hash, nil, errors.New(res.Error)) default: @@ -125,7 +139,17 @@ func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRe } -func toProtoExecution(exec *execution.Execution) *types.Execution { +func toProtoExecution(exec *execution.Execution) (*types.Execution, error) { + inputs := &structpb.Struct{} + if err := convert.Unmarshal(exec.Inputs, inputs); err != nil { + return nil, err + } + + outputs := &structpb.Struct{} + if err := convert.Unmarshal(exec.Outputs, outputs); err != nil { + return nil, err + } + return &types.Execution{ Hash: exec.Hash.String(), ParentHash: exec.ParentHash.String(), @@ -133,9 +157,9 @@ func toProtoExecution(exec *execution.Execution) *types.Execution { Status: types.Status(exec.Status), InstanceHash: exec.InstanceHash.String(), TaskKey: exec.TaskKey, - Inputs: convert.MapToPbStruct(exec.Inputs), - Outputs: convert.MapToPbStruct(exec.Outputs), + Inputs: inputs, + Outputs: outputs, Tags: exec.Tags, Error: exec.Error, - } + }, nil } From a2b25e8db242804e213f6d0959048f3e1c319d0a Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 13:47:02 +0200 Subject: [PATCH 16/20] Update ethwallet service to use new convert functions --- .../ethwallet/client/task_runner.go | 21 ++++++++++++++----- systemservices/ethwallet/go.mod | 2 +- systemservices/ethwallet/go.sum | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/systemservices/ethwallet/client/task_runner.go b/systemservices/ethwallet/client/task_runner.go index 12fcc87f6..fc4aaf73a 100644 --- a/systemservices/ethwallet/client/task_runner.go +++ b/systemservices/ethwallet/client/task_runner.go @@ -2,6 +2,7 @@ package client import ( "context" + "fmt" pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/convert" @@ -41,17 +42,27 @@ func (r *TaskRunner) Run() error { } if _, ok := r.defs[exec.TaskKey]; !ok { + return fmt.Errorf("servic has no %s task", exec.TaskKey) + } + + inputs := make(map[string]interface{}) + if err := convert.Marshal(exec.Inputs, &inputs); err != nil { return err } - output, err := r.defs[exec.TaskKey](convert.PbStructToMap(exec.Inputs)) + output, err := r.defs[exec.TaskKey](inputs) req := &pb.UpdateExecutionRequest{ Hash: exec.Hash, - Result: &pb.UpdateExecutionRequest_Outputs{ - Outputs: convert.MapToPbStruct(output), - }, } - if err != nil { + if err == nil { + outputs := &structpb.Struct{} + if err := convert.Unmarshal(output, outputs); err != nil { + return nil, err + } + req.Result = &pb.UpdateExecutionRequest_Outputs{ + Outputs: outputs, + } + } else { req.Result = &pb.UpdateExecutionRequest_Error{ Error: err.Error(), } diff --git a/systemservices/ethwallet/go.mod b/systemservices/ethwallet/go.mod index daafea772..393969b55 100644 --- a/systemservices/ethwallet/go.mod +++ b/systemservices/ethwallet/go.mod @@ -10,7 +10,7 @@ require ( github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.8.27 github.com/go-stack/stack v1.8.0 // indirect - github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb + github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412 github.com/mitchellh/mapstructure v1.1.2 github.com/pborman/uuid v1.2.0 // indirect github.com/rjeczalik/notify v0.9.2 // indirect diff --git a/systemservices/ethwallet/go.sum b/systemservices/ethwallet/go.sum index 3604578a6..c68808952 100644 --- a/systemservices/ethwallet/go.sum +++ b/systemservices/ethwallet/go.sum @@ -105,6 +105,8 @@ github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f h1:vlWi61 github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb h1:S/CY8lw1DiHgCZx7NRXbC+2HzncVQQAXdocviaxOElg= github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= +github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412 h1:pltHBuy2yeuf83rg2QsbB7YXk1dCnxTXll1mbmTk47w= +github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= github.com/mesg-foundation/engine v0.11.0 h1:Fmdy+3Gqa4XyVQcRbf0wE8pk/CtYpW8xop6VWECV10E= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= From 79b73fa1f3531a4ba2d3af669516dc5a77c55bb9 Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 13:51:01 +0200 Subject: [PATCH 17/20] Fix tests --- server/grpc/api/execution_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/grpc/api/execution_test.go b/server/grpc/api/execution_test.go index 2be2957e7..115242055 100644 --- a/server/grpc/api/execution_test.go +++ b/server/grpc/api/execution_test.go @@ -23,7 +23,8 @@ func TestGet(t *testing.T) { exec := execution.New(nil, nil, nil, "", nil, nil) require.NoError(t, db.Save(exec)) - want := toProtoExecution(exec) + want, err := toProtoExecution(exec) + require.NoError(t, err) sdk := sdk.New(nil, nil, nil, db, "", "") s := NewExecutionServer(sdk) From 622a24f0d4b25c200e75093afaef3e45c6308ebb Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 13:55:22 +0200 Subject: [PATCH 18/20] Fix build --- sdk/execution/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/execution/execution.go b/sdk/execution/execution.go index bd5ec628e..62c68f2be 100644 --- a/sdk/execution/execution.go +++ b/sdk/execution/execution.go @@ -84,7 +84,7 @@ func (e *Execution) processExecution(executionHash hash.Hash, outputs map[string tx.Discard() return nil, err1 } - } else if err := exec.Complete(o); err != nil { + } else if err := exec.Complete(outputs); err != nil { tx.Discard() return nil, err } From c8021d4622600c18ed74c2f275dd2493ec9aaea1 Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 17:15:39 +0200 Subject: [PATCH 19/20] Fix & compile ethwallet service --- systemservices/ethwallet/client/task_runner.go | 3 ++- systemservices/ethwallet/compiled.json | 2 +- systemservices/ethwallet/go.mod | 1 + systemservices/ethwallet/go.sum | 5 ----- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/systemservices/ethwallet/client/task_runner.go b/systemservices/ethwallet/client/task_runner.go index fc4aaf73a..036ed703b 100644 --- a/systemservices/ethwallet/client/task_runner.go +++ b/systemservices/ethwallet/client/task_runner.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + structpb "github.com/golang/protobuf/ptypes/struct" pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/convert" "github.com/mesg-foundation/engine/protobuf/types" @@ -57,7 +58,7 @@ func (r *TaskRunner) Run() error { if err == nil { outputs := &structpb.Struct{} if err := convert.Unmarshal(output, outputs); err != nil { - return nil, err + return err } req.Result = &pb.UpdateExecutionRequest_Outputs{ Outputs: outputs, diff --git a/systemservices/ethwallet/compiled.json b/systemservices/ethwallet/compiled.json index a07ea1b4e..8bff59aea 100644 --- a/systemservices/ethwallet/compiled.json +++ b/systemservices/ethwallet/compiled.json @@ -1 +1 @@ -{"sid":"ethwallet","name":"Ethereum Wallet","description":"Manage Ethereum accounts and sign transactions.","tasks":[{"key":"list","name":"List accounts","description":"Return the addresses of existing account.","inputs":[],"outputs":[{"key":"addresses","name":"Addresses","description":"List of addresses.","type":"String","repeated":true,"object":[]}]},{"key":"create","name":"Create a new account","description":"Create a new account with a passphrase. Make sure to backup the passphrase.","inputs":[{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"delete","name":"Delete an account","description":"Delete an account from the wallet. Need the address and its associated passphrase.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"export","name":"Export an account","description":"Export an existing account in order to backup it and import it in an other wallet. Respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"import","name":"Import an account","description":"Import an account. The account have to respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"account","name":"Account","description":"The JSON encoded account.","type":"Object","object":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"sign","name":"Sign transaction","description":"Sign a transaction with the specified account.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]},{"key":"transaction","name":"Transaction","description":"The transaction to sign.","type":"Object","object":[{"key":"chainID","name":"Chain ID","description":"The ID of the chain the transaction is for. See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids.","type":"Number","object":[]},{"key":"nonce","name":"Nonce","description":"Nonce to use.","type":"Number","object":[]},{"key":"to","name":"To","description":"The to address.","type":"String","object":[]},{"key":"value","name":"Value","description":"The value in Wei.","type":"String","object":[]},{"key":"gas","name":"Gas","description":"The maximum gas to use to execute this transaction","type":"Number","object":[]},{"key":"gasPrice","name":"Gas price","description":"The gas price in Wei.","type":"String","object":[]},{"key":"data","name":"Data","description":"The data of the transaction.","type":"String","object":[]}]}],"outputs":[{"key":"signedTransaction","name":"Signed transaction","description":"The signed transaction.","type":"String","object":[]}]},{"key":"importFromPrivateKey","name":"Import an account from a private key","description":"Import an account from a private key.","inputs":[{"key":"privateKey","name":"Private key","description":"The private key to import.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]}],"events":[],"dependencies":[],"configuration":{"env":["MESG_KEYSTORE=/keystore"],"volumes":["/keystore"]},"source":"QmQvFGZiTN2yEUMgBq6bjcrLGL95jegjNdTd9zeYf6gzke"} +{"sid":"ethwallet","name":"Ethereum Wallet","description":"Manage Ethereum accounts and sign transactions.","tasks":[{"key":"list","name":"List accounts","description":"Return the addresses of existing account.","inputs":[],"outputs":[{"key":"addresses","name":"Addresses","description":"List of addresses.","type":"String","repeated":true,"object":[]}]},{"key":"create","name":"Create a new account","description":"Create a new account with a passphrase. Make sure to backup the passphrase.","inputs":[{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"delete","name":"Delete an account","description":"Delete an account from the wallet. Need the address and its associated passphrase.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"export","name":"Export an account","description":"Export an existing account in order to backup it and import it in an other wallet. Respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"import","name":"Import an account","description":"Import an account. The account have to respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"account","name":"Account","description":"The JSON encoded account.","type":"Object","object":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"sign","name":"Sign transaction","description":"Sign a transaction with the specified account.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]},{"key":"transaction","name":"Transaction","description":"The transaction to sign.","type":"Object","object":[{"key":"chainID","name":"Chain ID","description":"The ID of the chain the transaction is for. See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids.","type":"Number","object":[]},{"key":"nonce","name":"Nonce","description":"Nonce to use.","type":"Number","object":[]},{"key":"to","name":"To","description":"The to address.","type":"String","object":[]},{"key":"value","name":"Value","description":"The value in Wei.","type":"String","object":[]},{"key":"gas","name":"Gas","description":"The maximum gas to use to execute this transaction","type":"Number","object":[]},{"key":"gasPrice","name":"Gas price","description":"The gas price in Wei.","type":"String","object":[]},{"key":"data","name":"Data","description":"The data of the transaction.","type":"String","object":[]}]}],"outputs":[{"key":"signedTransaction","name":"Signed transaction","description":"The signed transaction.","type":"String","object":[]}]},{"key":"importFromPrivateKey","name":"Import an account from a private key","description":"Import an account from a private key.","inputs":[{"key":"privateKey","name":"Private key","description":"The private key to import.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]}],"events":[],"dependencies":[],"configuration":{"env":["MESG_KEYSTORE=/keystore"],"volumes":["/keystore"]},"source":"QmTZ4uU4kysCHwbPtHZCvfK2UvwYjzf4bok5jNuRRf6N6v"} diff --git a/systemservices/ethwallet/go.mod b/systemservices/ethwallet/go.mod index 393969b55..4c3cde734 100644 --- a/systemservices/ethwallet/go.mod +++ b/systemservices/ethwallet/go.mod @@ -10,6 +10,7 @@ require ( github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.8.27 github.com/go-stack/stack v1.8.0 // indirect + github.com/golang/protobuf v1.3.1 github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412 github.com/mitchellh/mapstructure v1.1.2 github.com/pborman/uuid v1.2.0 // indirect diff --git a/systemservices/ethwallet/go.sum b/systemservices/ethwallet/go.sum index c68808952..e25e7b4a1 100644 --- a/systemservices/ethwallet/go.sum +++ b/systemservices/ethwallet/go.sum @@ -101,13 +101,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/lyft/protoc-gen-validate v0.1.0/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f h1:vlWi61rxeJWpgFKDefOfp12EYx6FERSfQGx99XSRDKc= -github.com/mesg-foundation/engine v0.5.1-0.20190723134654-1f96efe67b8f/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= -github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb h1:S/CY8lw1DiHgCZx7NRXbC+2HzncVQQAXdocviaxOElg= -github.com/mesg-foundation/engine v0.5.1-0.20190724163552-ca83914685bb/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412 h1:pltHBuy2yeuf83rg2QsbB7YXk1dCnxTXll1mbmTk47w= github.com/mesg-foundation/engine v0.5.1-0.20190725113935-3e817175f412/go.mod h1:KiMM6s34FwClc1niXN9NO/QG7VKPh4bS/PxBO0b0H48= -github.com/mesg-foundation/engine v0.11.0 h1:Fmdy+3Gqa4XyVQcRbf0wE8pk/CtYpW8xop6VWECV10E= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= From 1e982c7c1a68855e085cbe04c8134f9c32e14abe Mon Sep 17 00:00:00 2001 From: krhubert Date: Thu, 25 Jul 2019 17:26:01 +0200 Subject: [PATCH 20/20] Fix ethwallet client encoding --- systemservices/ethwallet/client/encoding.go | 9 ++++++--- systemservices/ethwallet/compiled.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/systemservices/ethwallet/client/encoding.go b/systemservices/ethwallet/client/encoding.go index e9f412fa4..b09efe1f0 100644 --- a/systemservices/ethwallet/client/encoding.go +++ b/systemservices/ethwallet/client/encoding.go @@ -2,8 +2,6 @@ package client import ( "encoding/json" - - "github.com/mitchellh/mapstructure" ) // Marshal returns the MESG format encoding of v. @@ -23,5 +21,10 @@ func Marshal(input interface{}) (map[string]interface{}, error) { // Unmarshal parses the MESG-encoded data input and stores the result in the value pointed to by v. func Unmarshal(input map[string]interface{}, output interface{}) error { - return mapstructure.Decode(input, output) + b, err := json.Marshal(input) + if err != nil { + return err + } + + return json.Unmarshal(b, output) } diff --git a/systemservices/ethwallet/compiled.json b/systemservices/ethwallet/compiled.json index 8bff59aea..7e65ae1e8 100644 --- a/systemservices/ethwallet/compiled.json +++ b/systemservices/ethwallet/compiled.json @@ -1 +1 @@ -{"sid":"ethwallet","name":"Ethereum Wallet","description":"Manage Ethereum accounts and sign transactions.","tasks":[{"key":"list","name":"List accounts","description":"Return the addresses of existing account.","inputs":[],"outputs":[{"key":"addresses","name":"Addresses","description":"List of addresses.","type":"String","repeated":true,"object":[]}]},{"key":"create","name":"Create a new account","description":"Create a new account with a passphrase. Make sure to backup the passphrase.","inputs":[{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"delete","name":"Delete an account","description":"Delete an account from the wallet. Need the address and its associated passphrase.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"export","name":"Export an account","description":"Export an existing account in order to backup it and import it in an other wallet. Respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"import","name":"Import an account","description":"Import an account. The account have to respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"account","name":"Account","description":"The JSON encoded account.","type":"Object","object":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"sign","name":"Sign transaction","description":"Sign a transaction with the specified account.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]},{"key":"transaction","name":"Transaction","description":"The transaction to sign.","type":"Object","object":[{"key":"chainID","name":"Chain ID","description":"The ID of the chain the transaction is for. See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids.","type":"Number","object":[]},{"key":"nonce","name":"Nonce","description":"Nonce to use.","type":"Number","object":[]},{"key":"to","name":"To","description":"The to address.","type":"String","object":[]},{"key":"value","name":"Value","description":"The value in Wei.","type":"String","object":[]},{"key":"gas","name":"Gas","description":"The maximum gas to use to execute this transaction","type":"Number","object":[]},{"key":"gasPrice","name":"Gas price","description":"The gas price in Wei.","type":"String","object":[]},{"key":"data","name":"Data","description":"The data of the transaction.","type":"String","object":[]}]}],"outputs":[{"key":"signedTransaction","name":"Signed transaction","description":"The signed transaction.","type":"String","object":[]}]},{"key":"importFromPrivateKey","name":"Import an account from a private key","description":"Import an account from a private key.","inputs":[{"key":"privateKey","name":"Private key","description":"The private key to import.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]}],"events":[],"dependencies":[],"configuration":{"env":["MESG_KEYSTORE=/keystore"],"volumes":["/keystore"]},"source":"QmTZ4uU4kysCHwbPtHZCvfK2UvwYjzf4bok5jNuRRf6N6v"} +{"sid":"ethwallet","name":"Ethereum Wallet","description":"Manage Ethereum accounts and sign transactions.","tasks":[{"key":"list","name":"List accounts","description":"Return the addresses of existing account.","inputs":[],"outputs":[{"key":"addresses","name":"Addresses","description":"List of addresses.","type":"String","repeated":true,"object":[]}]},{"key":"create","name":"Create a new account","description":"Create a new account with a passphrase. Make sure to backup the passphrase.","inputs":[{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"delete","name":"Delete an account","description":"Delete an account from the wallet. Need the address and its associated passphrase.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"export","name":"Export an account","description":"Export an existing account in order to backup it and import it in an other wallet. Respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"import","name":"Import an account","description":"Import an account. The account have to respect the Web3 Secret Storage specification. See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.","inputs":[{"key":"account","name":"Account","description":"The JSON encoded account.","type":"Object","object":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"id","name":"ID","description":"The id of the account.","type":"String","object":[]},{"key":"version","name":"Version","description":"The version used to export the account.","type":"Number","object":[]},{"key":"crypto","name":"Crypto","description":"The encrypted account.","type":"Object","object":[]}]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]},{"key":"sign","name":"Sign transaction","description":"Sign a transaction with the specified account.","inputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]},{"key":"transaction","name":"Transaction","description":"The transaction to sign.","type":"Object","object":[{"key":"chainID","name":"Chain ID","description":"The ID of the chain the transaction is for. See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids.","type":"Number","object":[]},{"key":"nonce","name":"Nonce","description":"Nonce to use.","type":"Number","object":[]},{"key":"to","name":"To","description":"The to address.","type":"String","object":[]},{"key":"value","name":"Value","description":"The value in Wei.","type":"String","object":[]},{"key":"gas","name":"Gas","description":"The maximum gas to use to execute this transaction","type":"Number","object":[]},{"key":"gasPrice","name":"Gas price","description":"The gas price in Wei.","type":"String","object":[]},{"key":"data","name":"Data","description":"The data of the transaction.","type":"String","object":[]}]}],"outputs":[{"key":"signedTransaction","name":"Signed transaction","description":"The signed transaction.","type":"String","object":[]}]},{"key":"importFromPrivateKey","name":"Import an account from a private key","description":"Import an account from a private key.","inputs":[{"key":"privateKey","name":"Private key","description":"The private key to import.","type":"String","object":[]},{"key":"passphrase","name":"Passphrase","description":"Passphrase to use with the account.","type":"String","object":[]}],"outputs":[{"key":"address","name":"Address","description":"The public address of the account.","type":"String","object":[]}]}],"events":[],"dependencies":[],"configuration":{"env":["MESG_KEYSTORE=/keystore"],"volumes":["/keystore"]},"source":"QmWJMCurpAQiAgSDW6dMpUH8Xktbvo4DyVd5jSrAQazDFG"}