commit
ccd92358db
|
@ -305,6 +305,7 @@
|
||||||
version = "v0.7.0"
|
version = "v0.7.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "bucky/aminoify"
|
||||||
name = "github.com/tendermint/tendermint"
|
name = "github.com/tendermint/tendermint"
|
||||||
packages = [
|
packages = [
|
||||||
"blockchain",
|
"blockchain",
|
||||||
|
@ -342,8 +343,7 @@
|
||||||
"types/priv_validator",
|
"types/priv_validator",
|
||||||
"version"
|
"version"
|
||||||
]
|
]
|
||||||
revision = "7afe74a963b5222bbc063545f4a9261d27b188de"
|
revision = "466c3ab1c79c1e9856aeea80c9e11c31219d11f0"
|
||||||
version = "0.19.0-rc2"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/tendermint/tmlibs"
|
name = "github.com/tendermint/tmlibs"
|
||||||
|
@ -448,6 +448,7 @@
|
||||||
"transport"
|
"transport"
|
||||||
]
|
]
|
||||||
revision = "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e"
|
revision = "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e"
|
||||||
|
source = "github.com/grpc/grpc-go"
|
||||||
version = "v1.7.5"
|
version = "v1.7.5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
@ -459,6 +460,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "ad719da6da7632d7fd405a696e66e36d5616142a499358189d88312dc1946d34"
|
inputs-digest = "d81bbe5d23b9bc1e1829c207a57857c40957c4c0dac6c70f5af04e0930cbd652"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -70,7 +70,8 @@
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/tendermint/tendermint"
|
name = "github.com/tendermint/tendermint"
|
||||||
version = "0.19.0-rc2"
|
#version = "0.19.0-rc2"
|
||||||
|
branch = "bucky/aminoify"
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/tendermint/tmlibs"
|
name = "github.com/tendermint/tmlibs"
|
||||||
|
|
|
@ -35,8 +35,6 @@ import (
|
||||||
bapp "github.com/cosmos/cosmos-sdk/examples/basecoin/app"
|
bapp "github.com/cosmos/cosmos-sdk/examples/basecoin/app"
|
||||||
btypes "github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
btypes "github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -90,7 +88,7 @@ func TestKeys(t *testing.T) {
|
||||||
res, body = request(t, port, "GET", "/keys", nil)
|
res, body = request(t, port, "GET", "/keys", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var m [2]keys.KeyOutput
|
var m [2]keys.KeyOutput
|
||||||
err = json.Unmarshal([]byte(body), &m)
|
err = cdc.UnmarshalJSON([]byte(body), &m)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, m[0].Name, name, "Did not serve keys name correctly")
|
assert.Equal(t, m[0].Name, name, "Did not serve keys name correctly")
|
||||||
|
@ -103,7 +101,7 @@ func TestKeys(t *testing.T) {
|
||||||
res, body = request(t, port, "GET", keyEndpoint, nil)
|
res, body = request(t, port, "GET", keyEndpoint, nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var m2 keys.KeyOutput
|
var m2 keys.KeyOutput
|
||||||
err = json.Unmarshal([]byte(body), &m2)
|
err = cdc.UnmarshalJSON([]byte(body), &m2)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, newName, m2.Name, "Did not serve keys name correctly")
|
assert.Equal(t, newName, m2.Name, "Did not serve keys name correctly")
|
||||||
|
@ -143,7 +141,7 @@ func TestNodeStatus(t *testing.T) {
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var nodeInfo p2p.NodeInfo
|
var nodeInfo p2p.NodeInfo
|
||||||
err := json.Unmarshal([]byte(body), &nodeInfo)
|
err := cdc.UnmarshalJSON([]byte(body), &nodeInfo)
|
||||||
require.Nil(t, err, "Couldn't parse node info")
|
require.Nil(t, err, "Couldn't parse node info")
|
||||||
|
|
||||||
assert.NotEqual(t, p2p.NodeInfo{}, nodeInfo, "res: %v", res)
|
assert.NotEqual(t, p2p.NodeInfo{}, nodeInfo, "res: %v", res)
|
||||||
|
@ -166,7 +164,7 @@ func TestBlock(t *testing.T) {
|
||||||
res, body := request(t, port, "GET", "/blocks/latest", nil)
|
res, body := request(t, port, "GET", "/blocks/latest", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(body), &resultBlock)
|
err := cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
||||||
require.Nil(t, err, "Couldn't parse block")
|
require.Nil(t, err, "Couldn't parse block")
|
||||||
|
|
||||||
assert.NotEqual(t, ctypes.ResultBlock{}, resultBlock)
|
assert.NotEqual(t, ctypes.ResultBlock{}, resultBlock)
|
||||||
|
@ -194,7 +192,7 @@ func TestValidators(t *testing.T) {
|
||||||
res, body := request(t, port, "GET", "/validatorsets/latest", nil)
|
res, body := request(t, port, "GET", "/validatorsets/latest", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(body), &resultVals)
|
err := cdc.UnmarshalJSON([]byte(body), &resultVals)
|
||||||
require.Nil(t, err, "Couldn't parse validatorset")
|
require.Nil(t, err, "Couldn't parse validatorset")
|
||||||
|
|
||||||
assert.NotEqual(t, ctypes.ResultValidators{}, resultVals)
|
assert.NotEqual(t, ctypes.ResultValidators{}, resultVals)
|
||||||
|
@ -204,7 +202,7 @@ func TestValidators(t *testing.T) {
|
||||||
res, body = request(t, port, "GET", "/validatorsets/1", nil)
|
res, body = request(t, port, "GET", "/validatorsets/1", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &resultVals)
|
err = cdc.UnmarshalJSON([]byte(body), &resultVals)
|
||||||
require.Nil(t, err, "Couldn't parse validatorset")
|
require.Nil(t, err, "Couldn't parse validatorset")
|
||||||
|
|
||||||
assert.NotEqual(t, ctypes.ResultValidators{}, resultVals)
|
assert.NotEqual(t, ctypes.ResultValidators{}, resultVals)
|
||||||
|
@ -221,6 +219,9 @@ func TestCoinSend(t *testing.T) {
|
||||||
res, body := request(t, port, "GET", "/accounts/8FA6AB57AD6870F6B5B2E57735F38F2F30E73CB6", nil)
|
res, body := request(t, port, "GET", "/accounts/8FA6AB57AD6870F6B5B2E57735F38F2F30E73CB6", nil)
|
||||||
require.Equal(t, http.StatusNoContent, res.StatusCode, body)
|
require.Equal(t, http.StatusNoContent, res.StatusCode, body)
|
||||||
|
|
||||||
|
acc := getAccount(t, sendAddr)
|
||||||
|
initialBalance := acc.GetCoins()
|
||||||
|
|
||||||
// create TX
|
// create TX
|
||||||
receiveAddr, resultTx := doSend(t, port, seed)
|
receiveAddr, resultTx := doSend(t, port, seed)
|
||||||
waitForHeight(resultTx.Height + 1)
|
waitForHeight(resultTx.Height + 1)
|
||||||
|
@ -230,24 +231,15 @@ func TestCoinSend(t *testing.T) {
|
||||||
assert.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
assert.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
||||||
|
|
||||||
// query sender
|
// query sender
|
||||||
res, body = request(t, port, "GET", "/accounts/"+sendAddr, nil)
|
acc = getAccount(t, sendAddr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
coins := acc.GetCoins()
|
||||||
|
|
||||||
var m auth.BaseAccount
|
|
||||||
err := json.Unmarshal([]byte(body), &m)
|
|
||||||
require.Nil(t, err)
|
|
||||||
coins := m.Coins
|
|
||||||
mycoins := coins[0]
|
mycoins := coins[0]
|
||||||
assert.Equal(t, coinDenom, mycoins.Denom)
|
assert.Equal(t, coinDenom, mycoins.Denom)
|
||||||
assert.Equal(t, coinAmount-1, mycoins.Amount)
|
assert.Equal(t, initialBalance[0].Amount-1, mycoins.Amount)
|
||||||
|
|
||||||
// query receiver
|
// query receiver
|
||||||
res, body = request(t, port, "GET", "/accounts/"+receiveAddr, nil)
|
acc = getAccount(t, receiveAddr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
coins = acc.GetCoins()
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &m)
|
|
||||||
require.Nil(t, err)
|
|
||||||
coins = m.Coins
|
|
||||||
mycoins = coins[0]
|
mycoins = coins[0]
|
||||||
assert.Equal(t, coinDenom, mycoins.Denom)
|
assert.Equal(t, coinDenom, mycoins.Denom)
|
||||||
assert.Equal(t, int64(1), mycoins.Amount)
|
assert.Equal(t, int64(1), mycoins.Amount)
|
||||||
|
@ -255,6 +247,9 @@ func TestCoinSend(t *testing.T) {
|
||||||
|
|
||||||
func TestIBCTransfer(t *testing.T) {
|
func TestIBCTransfer(t *testing.T) {
|
||||||
|
|
||||||
|
acc := getAccount(t, sendAddr)
|
||||||
|
initialBalance := acc.GetCoins()
|
||||||
|
|
||||||
// create TX
|
// create TX
|
||||||
resultTx := doIBCTransfer(t, port, seed)
|
resultTx := doIBCTransfer(t, port, seed)
|
||||||
|
|
||||||
|
@ -265,16 +260,11 @@ func TestIBCTransfer(t *testing.T) {
|
||||||
assert.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
assert.Equal(t, uint32(0), resultTx.DeliverTx.Code)
|
||||||
|
|
||||||
// query sender
|
// query sender
|
||||||
res, body := request(t, port, "GET", "/accounts/"+sendAddr, nil)
|
acc = getAccount(t, sendAddr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
coins := acc.GetCoins()
|
||||||
|
|
||||||
var m auth.BaseAccount
|
|
||||||
err := json.Unmarshal([]byte(body), &m)
|
|
||||||
require.Nil(t, err)
|
|
||||||
coins := m.Coins
|
|
||||||
mycoins := coins[0]
|
mycoins := coins[0]
|
||||||
assert.Equal(t, coinDenom, mycoins.Denom)
|
assert.Equal(t, coinDenom, mycoins.Denom)
|
||||||
assert.Equal(t, coinAmount-2, mycoins.Amount)
|
assert.Equal(t, initialBalance[0].Amount-1, mycoins.Amount)
|
||||||
|
|
||||||
// TODO: query ibc egress packet state
|
// TODO: query ibc egress packet state
|
||||||
}
|
}
|
||||||
|
@ -350,6 +340,7 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
|
||||||
"staking": dbm.NewMemDB(),
|
"staking": dbm.NewMemDB(),
|
||||||
}
|
}
|
||||||
app := bapp.NewBasecoinApp(logger, dbs)
|
app := bapp.NewBasecoinApp(logger, dbs)
|
||||||
|
cdc = bapp.MakeCodec() // XXX
|
||||||
|
|
||||||
genesisFile := config.GenesisFile()
|
genesisFile := config.GenesisFile()
|
||||||
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
|
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
|
||||||
|
@ -371,10 +362,7 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
genDoc.AppState = stateBytes
|
genDoc.AppStateJSON = stateBytes
|
||||||
|
|
||||||
cdc := wire.NewCodec()
|
|
||||||
wire.RegisterCrypto(cdc)
|
|
||||||
|
|
||||||
// LCD listen address
|
// LCD listen address
|
||||||
port = fmt.Sprintf("%d", 17377) // XXX
|
port = fmt.Sprintf("%d", 17377) // XXX
|
||||||
|
@ -388,12 +376,12 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
lcd, err := startLCD(cdc, logger, listenAddr)
|
lcd, err := startLCD(logger, listenAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForStart(cdc)
|
waitForStart()
|
||||||
|
|
||||||
return node, lcd, nil
|
return node, lcd, nil
|
||||||
}
|
}
|
||||||
|
@ -427,7 +415,7 @@ func startTM(cfg *tmcfg.Config, logger log.Logger, genDoc *tmtypes.GenesisDoc, p
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the LCD. note this blocks!
|
// start the LCD. note this blocks!
|
||||||
func startLCD(cdc *wire.Codec, logger log.Logger, listenAddr string) (net.Listener, error) {
|
func startLCD(logger log.Logger, listenAddr string) (net.Listener, error) {
|
||||||
handler := createHandler(cdc)
|
handler := createHandler(cdc)
|
||||||
return tmrpc.StartHTTPServer(listenAddr, handler, logger)
|
return tmrpc.StartHTTPServer(listenAddr, handler, logger)
|
||||||
}
|
}
|
||||||
|
@ -449,6 +437,16 @@ func request(t *testing.T, port, method, path string, payload []byte) (*http.Res
|
||||||
return res, string(output)
|
return res, string(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getAccount(t *testing.T, sendAddr string) sdk.Account {
|
||||||
|
// get the account to get the sequence
|
||||||
|
res, body := request(t, port, "GET", "/accounts/"+sendAddr, nil)
|
||||||
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
var acc sdk.Account
|
||||||
|
err := cdc.UnmarshalJSON([]byte(body), &acc)
|
||||||
|
require.Nil(t, err)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
func doSend(t *testing.T, port, seed string) (receiveAddr string, resultTx ctypes.ResultBroadcastTxCommit) {
|
func doSend(t *testing.T, port, seed string) (receiveAddr string, resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
|
|
||||||
// create receive address
|
// create receive address
|
||||||
|
@ -457,20 +455,15 @@ func doSend(t *testing.T, port, seed string) (receiveAddr string, resultTx ctype
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
receiveAddr = receiveInfo.PubKey.Address().String()
|
receiveAddr = receiveInfo.PubKey.Address().String()
|
||||||
|
|
||||||
// get the account to get the sequence
|
acc := getAccount(t, sendAddr)
|
||||||
res, body := request(t, port, "GET", "/accounts/"+sendAddr, nil)
|
sequence := acc.GetSequence()
|
||||||
// require.Equal(t, http.StatusOK, res.StatusCode, body)
|
|
||||||
acc := auth.BaseAccount{}
|
|
||||||
err = json.Unmarshal([]byte(body), &acc)
|
|
||||||
require.Nil(t, err)
|
|
||||||
sequence := acc.Sequence
|
|
||||||
|
|
||||||
// send
|
// send
|
||||||
jsonStr := []byte(fmt.Sprintf(`{ "name":"%s", "password":"%s", "sequence":%d, "amount":[{ "denom": "%s", "amount": 1 }] }`, name, password, sequence, coinDenom))
|
jsonStr := []byte(fmt.Sprintf(`{ "name":"%s", "password":"%s", "sequence":%d, "amount":[{ "denom": "%s", "amount": 1 }] }`, name, password, sequence, coinDenom))
|
||||||
res, body = request(t, port, "POST", "/accounts/"+receiveAddr+"/send", jsonStr)
|
res, body := request(t, port, "POST", "/accounts/"+receiveAddr+"/send", jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &resultTx)
|
err = cdc.UnmarshalJSON([]byte(body), &resultTx)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return receiveAddr, resultTx
|
return receiveAddr, resultTx
|
||||||
|
@ -485,19 +478,15 @@ func doIBCTransfer(t *testing.T, port, seed string) (resultTx ctypes.ResultBroad
|
||||||
receiveAddr := receiveInfo.PubKey.Address().String()
|
receiveAddr := receiveInfo.PubKey.Address().String()
|
||||||
|
|
||||||
// get the account to get the sequence
|
// get the account to get the sequence
|
||||||
res, body := request(t, port, "GET", "/accounts/"+sendAddr, nil)
|
acc := getAccount(t, sendAddr)
|
||||||
// require.Equal(t, http.StatusOK, res.StatusCode, body)
|
sequence := acc.GetSequence()
|
||||||
acc := auth.BaseAccount{}
|
|
||||||
err = json.Unmarshal([]byte(body), &acc)
|
|
||||||
require.Nil(t, err)
|
|
||||||
sequence := acc.Sequence
|
|
||||||
|
|
||||||
// send
|
// send
|
||||||
jsonStr := []byte(fmt.Sprintf(`{ "name":"%s", "password":"%s", "sequence":%d, "amount":[{ "denom": "%s", "amount": 1 }] }`, name, password, sequence, coinDenom))
|
jsonStr := []byte(fmt.Sprintf(`{ "name":"%s", "password":"%s", "sequence":%d, "amount":[{ "denom": "%s", "amount": 1 }] }`, name, password, sequence, coinDenom))
|
||||||
res, body = request(t, port, "POST", "/ibc/testchain/"+receiveAddr+"/send", jsonStr)
|
res, body := request(t, port, "POST", "/ibc/testchain/"+receiveAddr+"/send", jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &resultTx)
|
err = cdc.UnmarshalJSON([]byte(body), &resultTx)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
return resultTx
|
return resultTx
|
||||||
|
@ -519,7 +508,7 @@ func waitForHeight(height int64) {
|
||||||
}
|
}
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(body), &resultBlock)
|
err = cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("RES", res)
|
fmt.Println("RES", res)
|
||||||
fmt.Println("BODY", string(body))
|
fmt.Println("BODY", string(body))
|
||||||
|
@ -534,13 +523,11 @@ func waitForHeight(height int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for 2 blocks
|
// wait for 2 blocks
|
||||||
func waitForStart(cdc *wire.Codec) {
|
func waitForStart() {
|
||||||
waitHeight := int64(2)
|
waitHeight := int64(2)
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
var resultBlock ctypes.ResultBlock
|
|
||||||
|
|
||||||
url := fmt.Sprintf("http://localhost:%v%v", port, "/blocks/latest")
|
url := fmt.Sprintf("http://localhost:%v%v", port, "/blocks/latest")
|
||||||
res, err := http.Get(url)
|
res, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -559,6 +546,7 @@ func waitForStart(cdc *wire.Codec) {
|
||||||
}
|
}
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
|
||||||
|
resultBlock := new(ctypes.ResultBlock)
|
||||||
err = cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
err = cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("RES", res)
|
fmt.Println("RES", res)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package lcd
|
||||||
|
|
||||||
|
import (
|
||||||
|
amino "github.com/tendermint/go-amino"
|
||||||
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var cdc = amino.NewCodec()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
ctypes.RegisterAmino(cdc)
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -49,7 +48,7 @@ func getBlock(height *int64) ([]byte, error) {
|
||||||
|
|
||||||
// TODO move maarshalling into cmd/rest functions
|
// TODO move maarshalling into cmd/rest functions
|
||||||
// output, err := tmwire.MarshalJSON(res)
|
// output, err := tmwire.MarshalJSON(res)
|
||||||
output, err := json.MarshalIndent(res, "", " ")
|
output, err := cdc.MarshalJSON(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -61,7 +60,7 @@ func NodeInfoRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeInfo := status.NodeInfo
|
nodeInfo := status.NodeInfo
|
||||||
output, err := json.MarshalIndent(nodeInfo, "", " ")
|
output, err := cdc.MarshalJSON(nodeInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -37,7 +36,7 @@ func GetValidators(height *int64) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := json.MarshalIndent(res, "", " ")
|
output, err := cdc.MarshalJSON(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
amino "github.com/tendermint/go-amino"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc *wire.Codec
|
var cdc = amino.NewCodec()
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdc = wire.NewCodec()
|
|
||||||
RegisterWire(cdc)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
|
||||||
ctypes.RegisterAmino(cdc)
|
ctypes.RegisterAmino(cdc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/wire"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetAccountCmd for the auth.BaseAccount type
|
// GetAccountCmd for the auth.BaseAccount type
|
||||||
|
@ -20,9 +19,9 @@ func GetAccountCmdDefault(storeName string, cdc *wire.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
|
func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
|
||||||
return func(accBytes []byte) (sdk.Account, error) {
|
return func(accBytes []byte) (acct sdk.Account, err error) {
|
||||||
acct := new(auth.BaseAccount)
|
// acct := new(auth.BaseAccount)
|
||||||
err := cdc.UnmarshalBinary(accBytes, &acct)
|
err = cdc.UnmarshalBinaryBare(accBytes, &acct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, decoder sdk.A
|
||||||
}
|
}
|
||||||
|
|
||||||
// print out whole account
|
// print out whole account
|
||||||
output, err := json.MarshalIndent(account, "", " ")
|
output, err := cdc.MarshalJSON(account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte(fmt.Sprintf("Could't marshall query result. Error: %s", err.Error())))
|
w.Write([]byte(fmt.Sprintf("Could't marshall query result. Error: %s", err.Error())))
|
||||||
|
|
|
@ -2,7 +2,6 @@ package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ func TransferRequestHandler(cdc *wire.Codec, kb keys.Keybase) func(http.Response
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(body, &m)
|
err = cdc.UnmarshalJSON(body, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
@ -86,7 +85,7 @@ func TransferRequestHandler(cdc *wire.Codec, kb keys.Keybase) func(http.Response
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := json.MarshalIndent(res, "", " ")
|
output, err := cdc.MarshalJSON(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
|
Loading…
Reference in New Issue