forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#4788: Query genesis transactions
- Loading branch information
1 parent
fd92504
commit 2e3c52b
Showing
27 changed files
with
158 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 3867 Allow querying for genesis transaction when height query param is set to zero. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package rest | ||
|
||
import ( | ||
"net/http" | ||
|
||
"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/genutil/types" | ||
) | ||
|
||
// QueryGenesisTxs writes the genesis transactions to the response if no error | ||
// occurs. | ||
func QueryGenesisTxs(cliCtx context.CLIContext, w http.ResponseWriter) { | ||
resultGenesis, err := cliCtx.Client.Genesis() | ||
if err != nil { | ||
rest.WriteErrorResponse(w, http.StatusInternalServerError, | ||
sdk.AppendMsgToErr("could not retrieve genesis from client", err.Error())) | ||
return | ||
} | ||
|
||
appState, err := types.GenesisStateFromGenDoc(cliCtx.Codec, *resultGenesis.Genesis) | ||
if err != nil { | ||
rest.WriteErrorResponse(w, http.StatusInternalServerError, | ||
sdk.AppendMsgToErr("could not decode genesis doc", err.Error())) | ||
return | ||
} | ||
|
||
genState := 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]) | ||
if err != nil { | ||
rest.WriteErrorResponse(w, http.StatusInternalServerError, | ||
sdk.AppendMsgToErr("could not decode genesis transaction", err.Error())) | ||
return | ||
} | ||
} | ||
|
||
rest.PostProcessResponse(w, cliCtx, genTxs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
package exported | ||
|
||
import "github.com/cosmos/cosmos-sdk/x/auth/exported" | ||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/auth/exported" | ||
) | ||
|
||
// ModuleAccountI defines an account interface for modules that hold tokens in an escrow | ||
type ModuleAccountI interface { | ||
exported.Account | ||
|
||
GetName() string | ||
GetPermissions() []string | ||
HasPermission(string) bool | ||
} | ||
|
||
// SupplyI defines an inflationary supply interface for modules that handle | ||
// token supply. | ||
type SupplyI interface { | ||
GetTotal() sdk.Coins | ||
SetTotal(total sdk.Coins) SupplyI | ||
|
||
Inflate(amount sdk.Coins) SupplyI | ||
Deflate(amount sdk.Coins) SupplyI | ||
|
||
String() string | ||
ValidateBasic() error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.