From a31c16428d3966cec5c971a638c60d1d625cb6ca Mon Sep 17 00:00:00 2001 From: Andrii Selivanov Date: Sat, 11 Aug 2018 22:58:27 +0300 Subject: [PATCH 1/3] [api] Added base64 encoding around protobuf to prevent losing information between mobile and go. --- mobile_interface.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile_interface.go b/mobile_interface.go index c76b315..dd5d22c 100644 --- a/mobile_interface.go +++ b/mobile_interface.go @@ -193,8 +193,13 @@ func SendResponse(id string, data string, responseError string, timeout int) err return errors.New("you have to start panthalassa") } + dataBytes, decodingError := base64.StdEncoding.DecodeString(data) + if decodingError != nil { + return decodingError + } + resp := &apiPB.Response{} - if err := proto.Unmarshal([]byte(data), resp); err != nil { + if err := proto.Unmarshal(dataBytes, resp); err != nil { return err } From f77ce602a56a006ab9b6e9570c391eb6bc067ef0 Mon Sep 17 00:00:00 2001 From: Andrii Selivanov Date: Sat, 11 Aug 2018 23:13:02 +0300 Subject: [PATCH 2/3] [api] Fixed sendEthereumTransaction request always failing by timeout. --- api/dapp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/dapp.go b/api/dapp.go index db8e9b7..1b82fd2 100644 --- a/api/dapp.go +++ b/api/dapp.go @@ -83,6 +83,8 @@ func (a *DAppApi) SendEthereumTransaction(value, to, data string) (string, error return "", err } + // Since closer is not passed further, we need to close it here to prevent timeout. + resp.Closer <- nil return string(raw), nil } From 9bdc9d81dd24633f921cd2e34332344b549bc0bc Mon Sep 17 00:00:00 2001 From: Andrii Selivanov Date: Sat, 11 Aug 2018 23:33:35 +0300 Subject: [PATCH 3/3] [dapp] Returned from SendEthereumTransaction handler in case there is no transaction provided. --- api/dapp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/dapp.go b/api/dapp.go index 1b82fd2..5f48b18 100644 --- a/api/dapp.go +++ b/api/dapp.go @@ -59,7 +59,8 @@ func (a *DAppApi) SendEthereumTransaction(value, to, data string) (string, error ethTx := resp.Msg.SendEthereumTransaction if ethTx == nil { - resp.Closer <- errors.New("got nil response") + resp.Closer <- errors.New("got nil ethTx response") + return "", errors.New("got nil ethTx response") } objTx := map[string]interface{}{