-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor x/evidence to ADR-031 (#7538)
* Refactor x/evidence to ADR-031 * Add hash in response * Update changelog * Update x/evidence/keeper/keeper.go * Update proto/cosmos/evidence/v1beta1/tx.proto Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * Use msgServer struct Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
- Loading branch information
1 parent
18ef33c
commit 58eabcb
Showing
10 changed files
with
376 additions
and
40 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/evidence/types" | ||
) | ||
|
||
type msgServer struct { | ||
Keeper | ||
} | ||
|
||
// NewMsgServerImpl returns an implementation of the bank MsgServer interface | ||
// for the provided Keeper. | ||
func NewMsgServerImpl(keeper Keeper) types.MsgServer { | ||
return &msgServer{Keeper: keeper} | ||
} | ||
|
||
var _ types.MsgServer = msgServer{} | ||
|
||
// SubmitEvidence implements the MsgServer.SubmitEvidence method. | ||
func (ms msgServer) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEvidence) (*types.MsgSubmitEvidenceResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
evidence := msg.GetEvidence() | ||
if err := ms.Keeper.SubmitEvidence(ctx, evidence); err != nil { | ||
return nil, err | ||
} | ||
|
||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSubmitter().String()), | ||
), | ||
) | ||
|
||
return &types.MsgSubmitEvidenceResponse{ | ||
Hash: evidence.Hash(), | ||
}, nil | ||
} |
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.