Add ADR 031 BaseApp and codec infrastructure (#7519)
* Refactor RegisterQueryServices -> RegisterServices * Cleaner proto files * Fix tests * Add MsgServer * Fix lint * Remove MsgServer from configurator for now * Remove useless file * Fix build * typo * Add router * Fix test * WIP * Add router * Remove test helper * Add beginning of test * Move test to simapp? * ServiceMsg implement sdk.Msg * Add handler by MsgServiceRouter * Correct signature * Add full test * use TxEncoder * Update baseapp/msg_service_router.go Co-authored-by: Aaron Craelius <aaron@regen.network> * Push changes * WIP on ServiceMsg unpacking * Make TestMsgService test pass * Fix tests * Tidying up * Tidying up * Tidying up * Add JSON test * Add comments * Tidying * Lint * Register MsgRequest interface * Rename * Fix tests * RegisterCustomTypeURL * Add changelog entries * Put in features * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Address review comments * Address nit * Fix lint * Update codec/types/interface_registry.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * godoc Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
This commit is contained in:
co-authored by
Aaron Craelius
Aleksandr Bezobchuk
Marie Gauthier
Aaron Craelius
parent
e6e4a94071
commit
55242a659c
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
type QueryImpl struct{}
|
||||
|
||||
var _ QueryServer = QueryImpl{}
|
||||
|
||||
func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) {
|
||||
animal, ok := request.AnyAnimal.GetCachedValue().(Animal)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected Animal")
|
||||
}
|
||||
|
||||
any, err := types.NewAnyWithValue(animal.(proto.Message))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TestAnyResponse{HasAnimal: &HasAnimal{
|
||||
Animal: any,
|
||||
X: 10,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
func (e QueryImpl) Echo(_ context.Context, req *EchoRequest) (*EchoResponse, error) {
|
||||
return &EchoResponse{Message: req.Message}, nil
|
||||
}
|
||||
|
||||
func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHelloResponse, error) {
|
||||
greeting := fmt.Sprintf("Hello %s!", request.Name)
|
||||
return &SayHelloResponse{Greeting: greeting}, nil
|
||||
}
|
||||
|
||||
var _ types.UnpackInterfacesMessage = &TestAnyRequest{}
|
||||
|
||||
func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
||||
var animal Animal
|
||||
return unpacker.UnpackAny(m.AnyAnimal, &animal)
|
||||
}
|
||||
|
||||
var _ types.UnpackInterfacesMessage = &TestAnyResponse{}
|
||||
|
||||
func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
||||
return m.HasAnimal.UnpackInterfaces(unpacker)
|
||||
}
|
||||
Reference in New Issue
Block a user