Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query genesis transactions #4788

Merged
merged 18 commits into from
Aug 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update query gen txs rest func
  • Loading branch information
colin-axner committed Jul 24, 2019
commit 55f424d4df13faf12401f98866fc24394d3f1389
9 changes: 5 additions & 4 deletions x/genutil/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)

// QueryGenesisTxs implements a REST handler that returns genesis transactions.
Expand All @@ -20,14 +20,14 @@ func QueryGenesisTxs(cliCtx context.CLIContext) http.HandlerFunc {
return
}

var appState map[string]json.RawMessage
if err := cliCtx.Codec.UnmarshalJSON(genDoc.AppState, &appState); err != nil {
appState, err := types.GenesisStateFromGenDoc(cliCtx.Codec, genDoc)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError,
sdk.AppendMsgToErr("could not decode genesis doc", err.Error()))
return
}

err := cliCtx.Codec.UnmarshalJSON(appState)
genState, err := types.GetGenesisStateFromAppState(cliCtx.Codec, appState)
genTxs := make([]sdk.Tx, len(genState.GenTxs))
for i, tx := range genState.GenTxs {
err := cliCtx.Codec.UnmarshalJSON(tx, &genTxs[i])
Expand All @@ -37,6 +37,7 @@ func QueryGenesisTxs(cliCtx context.CLIContext) http.HandlerFunc {
return
}
}

rest.PostProcessResponse(w, cliCtx, genTxs)
}
}