cosmos-sdk/server/rosetta.go
Andrea Giacobino 25ecec6c15
rosetta: upgrade to newest version (#9314)
* feat:  update rosetta sdk to v0.6.10 

embed from v1.0.0 release branch of the library: https://github.com/tendermint/cosmos-rosetta-gateway/tree/release/v1.0.0

closes:
https://github.com/cosmos/cosmos-sdk/issues/9300

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-05-15 00:18:59 +02:00

42 lines
958 B
Go

package server
import (
"fmt"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/rosetta"
)
// RosettaCommand builds the rosetta root command given
// a protocol buffers serializer/deserializer
func RosettaCommand(ir codectypes.InterfaceRegistry, cdc codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "rosetta",
Short: "spin up a rosetta server",
RunE: func(cmd *cobra.Command, args []string) error {
conf, err := rosetta.FromFlags(cmd.Flags())
if err != nil {
return err
}
protoCodec, ok := cdc.(*codec.ProtoCodec)
if !ok {
return fmt.Errorf("exoected *codec.ProtoMarshaler, got: %T", cdc)
}
conf.WithCodec(ir, protoCodec)
rosettaSrv, err := rosetta.ServerFromConfig(conf)
if err != nil {
return err
}
return rosettaSrv.Start()
},
}
rosetta.SetFlags(cmd.Flags())
return cmd
}