Refactor x/bank according to ADR 031 (#7520)
* Refactor x/bank according to ADR 031 * Add comment * Update comment * Add comment * Add tests, address edge cases * Imports Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
45f5df7ea5
commit
9be15a42b9
1
buf.yaml
1
buf.yaml
|
@ -14,6 +14,7 @@ lint:
|
|||
- COMMENT_FIELD
|
||||
- SERVICE_SUFFIX
|
||||
- PACKAGE_VERSION_SUFFIX
|
||||
- RPC_REQUEST_STANDARD_NAME
|
||||
ignore:
|
||||
- tendermint
|
||||
- gogoproto
|
||||
|
|
|
@ -7,6 +7,15 @@ import "cosmos/bank/v1beta1/bank.proto";
|
|||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";
|
||||
|
||||
// Msg defines the bank Msg service.
|
||||
service Msg {
|
||||
// Send defines a method for sending coins from one account to another account.
|
||||
rpc Send(MsgSend) returns (MsgSendResponse);
|
||||
|
||||
// MultiSend defines a method for sending coins from some accounts to other accounts.
|
||||
rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse);
|
||||
}
|
||||
|
||||
// MsgSend represents a message to send coins from one account to another.
|
||||
message MsgSend {
|
||||
option (gogoproto.equal) = false;
|
||||
|
@ -18,6 +27,9 @@ message MsgSend {
|
|||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// MsgSendResponse defines the Msg/Send response type.
|
||||
message MsgSendResponse { }
|
||||
|
||||
// MsgMultiSend represents an arbitrary multi-in, multi-out send message.
|
||||
message MsgMultiSend {
|
||||
option (gogoproto.equal) = false;
|
||||
|
@ -25,3 +37,6 @@ message MsgMultiSend {
|
|||
repeated Input inputs = 1 [(gogoproto.nullable) = false];
|
||||
repeated Output outputs = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// MsgMultiSendResponse defines the Msg/MultiSend response type.
|
||||
message MsgMultiSendResponse { }
|
||||
|
|
|
@ -7,8 +7,11 @@ import (
|
|||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
@ -263,3 +266,30 @@ func (r TxResponse) GetTx() Tx {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WrapServiceResult wraps a result from a protobuf RPC service method call in
|
||||
// a Result object or error. This method takes care of marshaling the res param to
|
||||
// protobuf and attaching any events on the ctx.EventManager() to the Result.
|
||||
func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var data []byte
|
||||
if res != nil {
|
||||
data, err = proto.Marshal(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var events []abci.Event
|
||||
if evtMgr := ctx.EventManager(); evtMgr != nil {
|
||||
events = evtMgr.ABCIEvents()
|
||||
}
|
||||
|
||||
return &Result{
|
||||
Data: data,
|
||||
Events: events,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,13 @@ package types_test
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
@ -12,6 +16,7 @@ import (
|
|||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -180,3 +185,33 @@ func (s *resultTestSuite) TestResponseFormatBroadcastTxCommit() {
|
|||
s.Require().Equal(want, sdk.NewResponseFormatBroadcastTxCommit(checkTxResult))
|
||||
s.Require().Equal(want, sdk.NewResponseFormatBroadcastTxCommit(deliverTxResult))
|
||||
}
|
||||
|
||||
func TestWrapServiceResult(t *testing.T) {
|
||||
ctx := sdk.Context{}
|
||||
|
||||
res, err := sdk.WrapServiceResult(ctx, nil, fmt.Errorf("test"))
|
||||
require.Nil(t, res)
|
||||
require.NotNil(t, err)
|
||||
|
||||
res, err = sdk.WrapServiceResult(ctx, nil, nil)
|
||||
require.NotNil(t, res)
|
||||
require.Nil(t, err)
|
||||
require.Empty(t, res.Events)
|
||||
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
ctx.EventManager().EmitEvent(sdk.NewEvent("test"))
|
||||
res, err = sdk.WrapServiceResult(ctx, nil, nil)
|
||||
require.NotNil(t, res)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, res.Events, 1)
|
||||
|
||||
spot := testdata.Dog{Name: "spot"}
|
||||
res, err = sdk.WrapServiceResult(ctx, &spot, nil)
|
||||
require.NotNil(t, res)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, res.Events, 1)
|
||||
var spot2 testdata.Dog
|
||||
err = proto.Unmarshal(res.Data, &spot2)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, spot, spot2)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package bank
|
||||
|
||||
import (
|
||||
metrics "github.com/armon/go-metrics"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
|
@ -15,93 +12,19 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
|
|||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
msgServer := keeper.NewMsgServerImpl(k)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.MsgSend:
|
||||
return handleMsgSend(ctx, k, msg)
|
||||
res, err := msgServer.Send(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
case *types.MsgMultiSend:
|
||||
return handleMsgMultiSend(ctx, k, msg)
|
||||
res, err := msgServer.MultiSend(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
default:
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized bank message type: %T", msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle MsgSend.
|
||||
func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgSend) (*sdk.Result, error) {
|
||||
if err := k.SendEnabledCoins(ctx, msg.Amount...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
from, err := sdk.AccAddressFromBech32(msg.FromAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
to, err := sdk.AccAddressFromBech32(msg.ToAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if k.BlockedAddr(to) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
|
||||
}
|
||||
|
||||
err = k.SendCoins(ctx, from, to, msg.Amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
for _, a := range msg.Amount {
|
||||
telemetry.SetGaugeWithLabels(
|
||||
[]string{"tx", "msg", "send"},
|
||||
float32(a.Amount.Int64()),
|
||||
[]metrics.Label{telemetry.NewLabel("denom", a.Denom)},
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
||||
// Handle MsgMultiSend.
|
||||
func handleMsgMultiSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgMultiSend) (*sdk.Result, error) {
|
||||
// NOTE: totalIn == totalOut should already have been checked
|
||||
for _, in := range msg.Inputs {
|
||||
if err := k.SendEnabledCoins(ctx, in.Coins...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, out := range msg.Outputs {
|
||||
accAddr, err := sdk.AccAddressFromBech32(out.Address)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if k.BlockedAddr(accAddr) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive transactions", out.Address)
|
||||
}
|
||||
}
|
||||
|
||||
err := k.InputOutputCoins(ctx, msg.Inputs, msg.Outputs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/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{}
|
||||
|
||||
func (k msgServer) Send(goCtx context.Context, msg *types.MsgSend) (*types.MsgSendResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
if err := k.SendEnabledCoins(ctx, msg.Amount...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
from, err := sdk.AccAddressFromBech32(msg.FromAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
to, err := sdk.AccAddressFromBech32(msg.ToAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if k.BlockedAddr(to) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
|
||||
}
|
||||
|
||||
err = k.SendCoins(ctx, from, to, msg.Amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
for _, a := range msg.Amount {
|
||||
telemetry.SetGaugeWithLabels(
|
||||
[]string{"tx", "msg", "send"},
|
||||
float32(a.Amount.Int64()),
|
||||
[]metrics.Label{telemetry.NewLabel("denom", a.Denom)},
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgSendResponse{}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*types.MsgMultiSendResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
// NOTE: totalIn == totalOut should already have been checked
|
||||
for _, in := range msg.Inputs {
|
||||
if err := k.SendEnabledCoins(ctx, in.Coins...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, out := range msg.Outputs {
|
||||
accAddr, err := sdk.AccAddressFromBech32(out.Address)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if k.BlockedAddr(accAddr) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive transactions", out.Address)
|
||||
}
|
||||
}
|
||||
|
||||
err := k.InputOutputCoins(ctx, msg.Inputs, msg.Outputs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgMultiSendResponse{}, nil
|
||||
}
|
|
@ -4,11 +4,16 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
|
@ -65,6 +70,42 @@ func (m *MsgSend) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_MsgSend proto.InternalMessageInfo
|
||||
|
||||
type MsgSendResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgSendResponse) Reset() { *m = MsgSendResponse{} }
|
||||
func (m *MsgSendResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgSendResponse) ProtoMessage() {}
|
||||
func (*MsgSendResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1d8cb1613481f5b7, []int{1}
|
||||
}
|
||||
func (m *MsgSendResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgSendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgSendResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgSendResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSendResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgSendResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgSendResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSendResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgSendResponse proto.InternalMessageInfo
|
||||
|
||||
// MsgMultiSend represents an arbitrary multi-in, multi-out send message.
|
||||
type MsgMultiSend struct {
|
||||
Inputs []Input `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs"`
|
||||
|
@ -75,7 +116,7 @@ func (m *MsgMultiSend) Reset() { *m = MsgMultiSend{} }
|
|||
func (m *MsgMultiSend) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgMultiSend) ProtoMessage() {}
|
||||
func (*MsgMultiSend) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1d8cb1613481f5b7, []int{1}
|
||||
return fileDescriptor_1d8cb1613481f5b7, []int{2}
|
||||
}
|
||||
func (m *MsgMultiSend) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -118,39 +159,197 @@ func (m *MsgMultiSend) GetOutputs() []Output {
|
|||
return nil
|
||||
}
|
||||
|
||||
type MsgMultiSendResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgMultiSendResponse) Reset() { *m = MsgMultiSendResponse{} }
|
||||
func (m *MsgMultiSendResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgMultiSendResponse) ProtoMessage() {}
|
||||
func (*MsgMultiSendResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_1d8cb1613481f5b7, []int{3}
|
||||
}
|
||||
func (m *MsgMultiSendResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgMultiSendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgMultiSendResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgMultiSendResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgMultiSendResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgMultiSendResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgMultiSendResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgMultiSendResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgMultiSendResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgSend)(nil), "cosmos.bank.v1beta1.MsgSend")
|
||||
proto.RegisterType((*MsgSendResponse)(nil), "cosmos.bank.v1beta1.MsgSendResponse")
|
||||
proto.RegisterType((*MsgMultiSend)(nil), "cosmos.bank.v1beta1.MsgMultiSend")
|
||||
proto.RegisterType((*MsgMultiSendResponse)(nil), "cosmos.bank.v1beta1.MsgMultiSendResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/bank/v1beta1/tx.proto", fileDescriptor_1d8cb1613481f5b7) }
|
||||
|
||||
var fileDescriptor_1d8cb1613481f5b7 = []byte{
|
||||
// 374 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4,
|
||||
0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x81, 0x64, 0xf5,
|
||||
0xa0, 0xb2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x79, 0x7d, 0x10, 0x0b, 0xa2, 0x54, 0x4a,
|
||||
0x0e, 0x6e, 0x50, 0x71, 0x2a, 0xdc, 0xa0, 0xe4, 0xfc, 0xcc, 0x3c, 0x0c, 0x79, 0x24, 0x8b, 0xc0,
|
||||
0xe6, 0x82, 0xe5, 0x95, 0x5e, 0x31, 0x72, 0xb1, 0xfb, 0x16, 0xa7, 0x07, 0xa7, 0xe6, 0xa5, 0x08,
|
||||
0x59, 0x71, 0xf1, 0xa4, 0x15, 0xe5, 0xe7, 0xc6, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b,
|
||||
0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0x89, 0x7f, 0xba, 0x27, 0x2f, 0x5c, 0x99, 0x98, 0x9b, 0x63,
|
||||
0xa5, 0x84, 0x2c, 0xab, 0x14, 0xc4, 0x0d, 0xe2, 0x3a, 0x42, 0x78, 0x42, 0x26, 0x5c, 0x5c, 0x25,
|
||||
0xf9, 0x70, 0x9d, 0x4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1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7,
|
||||
0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x9a, 0x78, 0xfd, 0x58, 0x01, 0x89,
|
||||
0x4c, 0xb0, 0x57, 0x93, 0xd8, 0xc0, 0xd1, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x84,
|
||||
0x52, 0xaa, 0x51, 0x02, 0x00, 0x00,
|
||||
// 436 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x3f, 0xef, 0xd2, 0x40,
|
||||
0x1c, 0xc6, 0x7b, 0x3f, 0x08, 0x3f, 0x39, 0x48, 0x0c, 0x05, 0x15, 0x2b, 0x69, 0xb1, 0x71, 0x80,
|
||||
0xc1, 0xab, 0xa0, 0x83, 0xa9, 0x93, 0x65, 0xd2, 0xa4, 0x31, 0xa9, 0x93, 0x2e, 0xa6, 0x7f, 0xce,
|
||||
0xda, 0x40, 0x7b, 0x0d, 0x77, 0x35, 0xf0, 0x0e, 0x4c, 0x5c, 0x7c, 0x09, 0xcc, 0xc6, 0x17, 0xc2,
|
||||
0xc8, 0xe8, 0x84, 0x06, 0x16, 0xe3, 0xc8, 0x2b, 0x30, 0xbd, 0xfe, 0x81, 0x44, 0xc4, 0xa9, 0xbd,
|
||||
0x3c, 0xdf, 0xcf, 0xd3, 0xe7, 0xe9, 0xf7, 0x60, 0xcf, 0x25, 0x34, 0x24, 0x54, 0x73, 0xec, 0x68,
|
||||
0xaa, 0x7d, 0x1c, 0x39, 0x98, 0xd9, 0x23, 0x8d, 0x2d, 0x50, 0x3c, 0x27, 0x8c, 0x88, 0xed, 0x4c,
|
||||
0x45, 0xa9, 0x8a, 0x72, 0x55, 0xea, 0xf8, 0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, 0x80, 0xff, 0x84, 0xa7, 0xb0, 0x16, 0x44, 0x71, 0xc2, 0xd2,
|
||||
0xfa, 0x69, 0x24, 0x09, 0x9d, 0x59, 0x06, 0x7a, 0x91, 0x8e, 0x18, 0xd5, 0x34, 0x93, 0x95, 0xcf,
|
||||
0x8b, 0xcf, 0xe0, 0x35, 0x49, 0x18, 0x47, 0xaf, 0x38, 0x7a, 0xef, 0x2c, 0xfa, 0x8a, 0xcf, 0xe4,
|
||||
0x6c, 0x41, 0xe8, 0x55, 0x1e, 0xf0, 0x36, 0xec, 0x9c, 0x86, 0x29, 0x52, 0x8e, 0xbf, 0x01, 0x58,
|
||||
0x31, 0xa9, 0x2f, 0xbe, 0x84, 0x55, 0x1e, 0xb2, 0x77, 0xd6, 0x39, 0xef, 0x26, 0x3d, 0xb8, 0xa4,
|
||||
0x16, 0x9e, 0xe2, 0x1b, 0x58, 0x3f, 0xb6, 0xbe, 0xff, 0x2f, 0xa4, 0x1c, 0x91, 0x86, 0xff, 0x1d,
|
||||
0x29, 0xac, 0x8d, 0xc9, 0x7a, 0x27, 0x83, 0xcd, 0x4e, 0x06, 0x3f, 0x77, 0x32, 0xf8, 0xb2, 0x97,
|
||||
0x85, 0xcd, 0x5e, 0x16, 0xbe, 0xef, 0x65, 0xe1, 0xed, 0xf0, 0xe2, 0xf6, 0x16, 0xd9, 0x35, 0xe5,
|
||||
0x4b, 0x74, 0x6a, 0xfc, 0x82, 0x3e, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x78, 0xdc, 0x7c, 0x0b,
|
||||
0x2b, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// MsgClient is the client API for Msg service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type MsgClient interface {
|
||||
Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error)
|
||||
MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grpc.CallOption) (*MsgMultiSendResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) {
|
||||
out := new(MsgSendResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Msg/Send", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grpc.CallOption) (*MsgMultiSendResponse, error) {
|
||||
out := new(MsgMultiSendResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Msg/MultiSend", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
Send(context.Context, *MsgSend) (*MsgSendResponse, error)
|
||||
MultiSend(context.Context, *MsgMultiSend) (*MsgMultiSendResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedMsgServer) Send(ctx context.Context, req *MsgSend) (*MsgSendResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
|
||||
}
|
||||
func (*UnimplementedMsgServer) MultiSend(ctx context.Context, req *MsgMultiSend) (*MsgMultiSendResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method MultiSend not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgSend)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).Send(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.bank.v1beta1.Msg/Send",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).Send(ctx, req.(*MsgSend))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_MultiSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgMultiSend)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).MultiSend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.bank.v1beta1.Msg/MultiSend",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).MultiSend(ctx, req.(*MsgMultiSend))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.bank.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Send",
|
||||
Handler: _Msg_Send_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "MultiSend",
|
||||
Handler: _Msg_MultiSend_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/bank/v1beta1/tx.proto",
|
||||
}
|
||||
|
||||
func (m *MsgSend) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -204,6 +403,29 @@ func (m *MsgSend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgSendResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgSendResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgMultiSend) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
@ -255,6 +477,29 @@ func (m *MsgMultiSend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgMultiSendResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgMultiSendResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgMultiSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTx(v)
|
||||
base := offset
|
||||
|
@ -289,6 +534,15 @@ func (m *MsgSend) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *MsgSendResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgMultiSend) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
|
@ -310,6 +564,15 @@ func (m *MsgMultiSend) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *MsgMultiSendResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTx(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
|
@ -467,6 +730,59 @@ func (m *MsgSend) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgSendResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgSendResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgSendResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgMultiSend) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
@ -588,6 +904,59 @@ func (m *MsgMultiSend) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgMultiSendResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgMultiSendResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgMultiSendResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTx(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
Loading…
Reference in New Issue