This is an automated email from the ASF dual-hosted git repository.

cmorris pushed a commit to branch tendermint
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git

commit 726863453d48e88d0ed377c4ac1df7dd72337c01
Author: Christopher Morris <[email protected]>
AuthorDate: Wed Oct 9 09:06:43 2019 +0100

    in progress
---
 pkg/tendermint/cmd/{tmget => fishhook} | Bin 28468644 -> 24169060 bytes
 pkg/tendermint/cmd/fishhook.go         |  19 ++++++-----
 pkg/tendermint/cmd/transactions.go     |  60 ---------------------------------
 3 files changed, 10 insertions(+), 69 deletions(-)

diff --git a/pkg/tendermint/cmd/tmget b/pkg/tendermint/cmd/fishhook
similarity index 68%
rename from pkg/tendermint/cmd/tmget
rename to pkg/tendermint/cmd/fishhook
index 27ede0c..854a652 100755
Binary files a/pkg/tendermint/cmd/tmget and b/pkg/tendermint/cmd/fishhook differ
diff --git a/pkg/tendermint/cmd/fishhook.go b/pkg/tendermint/cmd/fishhook.go
index 7971666..b3344a1 100644
--- a/pkg/tendermint/cmd/fishhook.go
+++ b/pkg/tendermint/cmd/fishhook.go
@@ -12,6 +12,7 @@ import (
        "time"
 
        "github.com/TylerBrock/colorjson"
+       "github.com/apache/incubator-milagro-dta/pkg/tendermint"
        "github.com/urfave/cli"
 )
 
@@ -52,10 +53,10 @@ Qredo DT-A uses:
                if url == "" {
                        url = "localhost:26657"
                }
-               if len(c.Args()) == 0 {
-                       print(app.UsageText)
-                       return nil
-               }
+               // if len(c.Args()) == 0 {
+               //      print(app.UsageText)
+               //      return nil
+               // }
 
                fullUrl := "http://"; + url + "/tx_search?query=\"" + tag + "=" 
+ lookup + "\""
                print(fullUrl)
@@ -67,19 +68,19 @@ Qredo DT-A uses:
                defer resp.Body.Close()
                body, err := ioutil.ReadAll(resp.Body)
 
-               txResponse, err := UnmarshalFetchTxResponse([]byte(body))
+               txResponse, err := 
tendermint.UnmarshalFetchTxResponse([]byte(body))
 
-               txs := txResponse.Result.Txs
+               txs := txResponse.TResult.Txs
                for r1, v := range txs {
                        for r2, v1 := range v.TxResult.Events {
                                for r3, v2 := range v1.Attributes {
                                        newkey, _ := 
base64.StdEncoding.DecodeString(v2.Key)
-                                       
txResponse.Result.Txs[r1].TxResult.Events[r2].Attributes[r3].Key = 
string(newkey)
+                                       
txResponse.TResult.Txs[r1].TxResult.Events[r2].Attributes[r3].Key = 
string(newkey)
                                        newval, _ := 
base64.StdEncoding.DecodeString(v2.Value)
-                                       
txResponse.Result.Txs[r1].TxResult.Events[r2].Attributes[r3].Value = 
string(newval)
+                                       
txResponse.TResult.Txs[r1].TxResult.Events[r2].Attributes[r3].Value = 
string(newval)
 
                                        if string(newkey) == "key" {
-                                               
txResponse.Result.Txs[r1].TxResult.Events[r2].Attributes[r3].Value = 
hex.EncodeToString(newval)
+                                               
txResponse.TResult.Txs[r1].TxResult.Events[r2].Attributes[r3].Value = 
hex.EncodeToString(newval)
                                        }
                                }
                        }
diff --git a/pkg/tendermint/cmd/transactions.go 
b/pkg/tendermint/cmd/transactions.go
deleted file mode 100644
index 2b68658..0000000
--- a/pkg/tendermint/cmd/transactions.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package main
-
-import "encoding/json"
-
-func UnmarshalFetchTxResponse(data []byte) (FetchTxResponse, error) {
-       var r FetchTxResponse
-       err := json.Unmarshal(data, &r)
-       return r, err
-}
-
-func (r *FetchTxResponse) Marshal() ([]byte, error) {
-       return json.Marshal(r)
-}
-
-func UnmarshalAttribute(data []byte) (Attribute, error) {
-       var r Attribute
-       print("hello")
-       err := json.Unmarshal(data, &r)
-       return r, err
-}
-
-type FetchTxResponse struct {
-       ID      string `json:"id"`
-       Jsonrpc string `json:"jsonrpc"`
-       Result  Result `json:"result"`
-}
-
-type Result struct {
-       TotalCount string `json:"total_count"`
-       Txs        []Tx   `json:"txs"`
-}
-
-type Tx struct {
-       Hash     string   `json:"hash"`
-       Height   string   `json:"height"`
-       Index    int64    `json:"index"`
-       Tx       string   `json:"tx"`
-       TxResult TxResult `json:"tx_result"`
-}
-
-type TxResult struct {
-       Code      int64       `json:"code"`
-       Codespace string      `json:"codespace"`
-       Data      interface{} `json:"data"`
-       Events    []Event     `json:"events"`
-       GasUsed   string      `json:"gasUsed"`
-       GasWanted string      `json:"gasWanted"`
-       Info      string      `json:"info"`
-       Log       string      `json:"log"`
-}
-
-type Event struct {
-       Attributes []Attribute `json:"attributes"`
-       Type       string      `json:"type"`
-}
-
-type Attribute struct {
-       Key   string `json:"key"`
-       Value string `json:"value"`
-}

Reply via email to