mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
Savings module deposits (#1192)
* module files * proto types * types and generated proto types * keeper * client scaffold * add savings module to app * remove placeholder types file * implement rest and add to module * update proto types * validation for supported denoms * generate updates proto types * update comments * update comments * remove unused imports from proto files * regenerate proto files * update proto types * client * deposit type and generated proto types * deposit keeper methods + tests * update savings module file * update app.go + test common * remove abci * remove refs to other modules * remove endblocker call * genesis init test for module account * update genesis test with params * add get/set params test * fix up keeper test * use params getter * simplify if/else statement * fix: add msgServer to keeper * fix: register deposit message * update deposit test * wrap invalid deposit denom error msg Co-authored-by: karzak <kjydavis3@gmail.com>
This commit is contained in:
parent
451bc05f47
commit
a073238f34
@ -541,6 +541,8 @@ func NewApp(
|
||||
appCodec,
|
||||
keys[savingstypes.StoreKey],
|
||||
savingsSubspace,
|
||||
app.accountKeeper,
|
||||
app.bankKeeper,
|
||||
)
|
||||
// create committee keeper with router
|
||||
committeeGovRouter := govtypes.NewRouter()
|
||||
@ -600,10 +602,9 @@ func NewApp(
|
||||
hard.NewAppModule(app.hardKeeper, app.accountKeeper, app.bankKeeper, app.pricefeedKeeper),
|
||||
committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
|
||||
incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.bankKeeper, app.cdpKeeper),
|
||||
savings.NewAppModule(app.savingsKeeper, app.accountKeeper),
|
||||
savings.NewAppModule(app.savingsKeeper, app.accountKeeper, app.bankKeeper),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
app.mm.SetOrderBeginBlockers(
|
||||
// Upgrade begin blocker runs migrations on the first block after an upgrade. It should run before any other module.
|
||||
upgradetypes.ModuleName,
|
||||
|
@ -5,8 +5,6 @@ import "kava/savings/v1beta1/store.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.verbose_equal_all) = true;
|
||||
|
||||
// GenesisState defines the savings module's genesis state.
|
||||
message GenesisState {
|
||||
|
@ -6,8 +6,6 @@ import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.verbose_equal_all) = true;
|
||||
|
||||
// Query defines the gRPC querier service for savings module
|
||||
service Query {
|
||||
|
@ -2,12 +2,23 @@ syntax = "proto3";
|
||||
package kava.savings.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
|
||||
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.verbose_equal_all) = true;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Params defines the parameters for the savings module.
|
||||
message Params {
|
||||
repeated string supported_denoms = 1;
|
||||
}
|
||||
|
||||
// Deposit defines an amount of coins deposited into a savings module account.
|
||||
message Deposit {
|
||||
string depositor = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
|
||||
repeated cosmos.base.v1beta1.Coin amount = 2
|
||||
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
@ -2,10 +2,23 @@ syntax = "proto3";
|
||||
package kava.savings.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
|
||||
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.verbose_equal_all) = true;
|
||||
|
||||
// Msg defines the savings Msg service.
|
||||
service Msg {}
|
||||
service Msg {
|
||||
// Deposit defines a method for depositing funds to the savings module account
|
||||
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
|
||||
}
|
||||
|
||||
// MsgDeposit defines the Msg/Deposit request type.
|
||||
message MsgDeposit {
|
||||
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
repeated cosmos.base.v1beta1.Coin amount = 2
|
||||
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// MsgDepositResponse defines the Msg/Deposit response type.
|
||||
message MsgDepositResponse {}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
@ -19,7 +24,9 @@ func GetTxCmd() *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmds := []*cobra.Command{}
|
||||
cmds := []*cobra.Command{
|
||||
getCmdDeposit(),
|
||||
}
|
||||
|
||||
for _, cmd := range cmds {
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
@ -29,3 +36,29 @@ func GetTxCmd() *cobra.Command {
|
||||
|
||||
return savingsTxCmd
|
||||
}
|
||||
|
||||
func getCmdDeposit() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "deposit [amount]",
|
||||
Short: "deposit coins to savings",
|
||||
Example: fmt.Sprintf(
|
||||
`%s tx %s savings 10000000bnb --from <key>`, version.AppName, types.ModuleName,
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
amount, err := sdk.ParseCoinsNormalized(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := types.NewMsgDeposit(clientCtx.GetFromAddress(), amount)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
)
|
||||
|
||||
// RegisterRoutes - Central function to define routes that get registered by the main application
|
||||
@ -11,3 +13,10 @@ func RegisterRoutes(cliCtx client.Context, r *mux.Router) {
|
||||
registerQueryRoutes(cliCtx, r)
|
||||
registerTxRoutes(cliCtx, r)
|
||||
}
|
||||
|
||||
// PostCreateDepositReq defines the properties of a deposit create request's body
|
||||
type PostCreateDepositReq struct {
|
||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
||||
From sdk.AccAddress `json:"from" yaml:"from"`
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"`
|
||||
}
|
||||
|
@ -1,9 +1,38 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
|
||||
func registerTxRoutes(cliCtx client.Context, r *mux.Router) {
|
||||
r.HandleFunc(fmt.Sprintf("/%s/deposit", types.ModuleName), postDepositHandlerFn(cliCtx)).Methods("POST")
|
||||
}
|
||||
|
||||
func postDepositHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// Decode POST request body
|
||||
var req PostCreateDepositReq
|
||||
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
||||
return
|
||||
}
|
||||
req.BaseReq = req.BaseReq.Sanitize()
|
||||
if !req.BaseReq.ValidateBasic(w) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := types.NewMsgDeposit(req.From, req.Amount)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, &msg)
|
||||
}
|
||||
}
|
||||
|
58
x/savings/keeper/deposit.go
Normal file
58
x/savings/keeper/deposit.go
Normal file
@ -0,0 +1,58 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
|
||||
// Deposit deposit
|
||||
func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coins) error {
|
||||
|
||||
err := k.ValidateDeposit(ctx, coins)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, depositor, types.ModuleAccountName, coins)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
currDeposit, foundDeposit := k.GetDeposit(ctx, depositor)
|
||||
amount := coins
|
||||
if foundDeposit {
|
||||
amount = amount.Add(currDeposit.Amount...)
|
||||
}
|
||||
deposit := types.NewDeposit(depositor, amount)
|
||||
k.SetDeposit(ctx, deposit)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeSavingsDeposit,
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, coins.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyDepositor, deposit.Depositor.String()),
|
||||
),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateDeposit validates a deposit
|
||||
func (k Keeper) ValidateDeposit(ctx sdk.Context, coins sdk.Coins) error {
|
||||
for _, coin := range coins {
|
||||
supported := k.IsDenomSupported(ctx, coin.Denom)
|
||||
if supported == false {
|
||||
return sdkerrors.Wrapf(types.ErrInvalidDepositDenom, ": %s", coin.Denom)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTotalDeposited returns the total amount deposited for the deposit denom
|
||||
func (k Keeper) GetTotalDeposited(ctx sdk.Context, depositDenom string) (total sdk.Int) {
|
||||
macc := k.accountKeeper.GetModuleAccount(ctx, types.ModuleAccountName)
|
||||
return k.bankKeeper.GetBalance(ctx, macc.GetAddress(), depositDenom).Amount
|
||||
}
|
152
x/savings/keeper/deposit_test.go
Normal file
152
x/savings/keeper/deposit_test.go
Normal file
@ -0,0 +1,152 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestDeposit() {
|
||||
type args struct {
|
||||
allowedDenoms []string
|
||||
depositor sdk.AccAddress
|
||||
initialDepositorBalance sdk.Coins
|
||||
depositAmount sdk.Coins
|
||||
numberDeposits int
|
||||
expectedAccountBalance sdk.Coins
|
||||
expectedModAccountBalance sdk.Coins
|
||||
expectedDepositCoins sdk.Coins
|
||||
}
|
||||
type errArgs struct {
|
||||
expectPass bool
|
||||
contains string
|
||||
}
|
||||
type depositTest struct {
|
||||
name string
|
||||
args args
|
||||
errArgs errArgs
|
||||
}
|
||||
testCases := []depositTest{
|
||||
{
|
||||
"valid",
|
||||
args{
|
||||
allowedDenoms: []string{"bnb", "btcb", "ukava"},
|
||||
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
||||
initialDepositorBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
depositAmount: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))),
|
||||
numberDeposits: 1,
|
||||
expectedAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(900)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
expectedModAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))),
|
||||
expectedDepositCoins: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))),
|
||||
},
|
||||
errArgs{
|
||||
expectPass: true,
|
||||
contains: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid multi deposit",
|
||||
args{
|
||||
allowedDenoms: []string{"bnb", "btcb", "ukava"},
|
||||
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
||||
initialDepositorBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
depositAmount: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))),
|
||||
numberDeposits: 2,
|
||||
expectedAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(800)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
expectedModAccountBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(200))),
|
||||
expectedDepositCoins: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(200))),
|
||||
},
|
||||
errArgs{
|
||||
expectPass: true,
|
||||
contains: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
"invalid deposit denom",
|
||||
args{
|
||||
allowedDenoms: []string{"bnb", "btcb", "ukava"},
|
||||
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
||||
initialDepositorBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
depositAmount: sdk.NewCoins(sdk.NewCoin("fake", sdk.NewInt(100))),
|
||||
numberDeposits: 1,
|
||||
expectedAccountBalance: sdk.Coins{},
|
||||
expectedModAccountBalance: sdk.Coins{},
|
||||
expectedDepositCoins: sdk.Coins{},
|
||||
},
|
||||
errArgs{
|
||||
expectPass: false,
|
||||
contains: "invalid deposit denom",
|
||||
},
|
||||
},
|
||||
{
|
||||
"insufficient funds",
|
||||
args{
|
||||
allowedDenoms: []string{"bnb", "btcb", "ukava"},
|
||||
depositor: sdk.AccAddress(crypto.AddressHash([]byte("test"))),
|
||||
initialDepositorBalance: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
|
||||
depositAmount: sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(10000))),
|
||||
numberDeposits: 1,
|
||||
expectedAccountBalance: sdk.Coins{},
|
||||
expectedModAccountBalance: sdk.Coins{},
|
||||
expectedDepositCoins: sdk.Coins{},
|
||||
},
|
||||
errArgs{
|
||||
expectPass: false,
|
||||
contains: "insufficient funds",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.name, func() {
|
||||
// create new app with one funded account
|
||||
|
||||
// Initialize test app and set context
|
||||
tApp := app.NewTestApp()
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
authGS := app.NewFundedGenStateWithCoins(
|
||||
tApp.AppCodec(),
|
||||
[]sdk.Coins{tc.args.initialDepositorBalance},
|
||||
[]sdk.AccAddress{tc.args.depositor},
|
||||
)
|
||||
savingsGS := types.NewGenesisState(types.NewParams(tc.args.allowedDenoms))
|
||||
|
||||
tApp.InitializeFromGenesisStates(authGS,
|
||||
app.GenesisState{types.ModuleName: tApp.AppCodec().MustMarshalJSON(&savingsGS)},
|
||||
)
|
||||
keeper := tApp.GetSavingsKeeper()
|
||||
suite.app = tApp
|
||||
suite.ctx = ctx
|
||||
suite.keeper = keeper
|
||||
|
||||
// run the test
|
||||
var err error
|
||||
for i := 0; i < tc.args.numberDeposits; i++ {
|
||||
err = suite.keeper.Deposit(suite.ctx, tc.args.depositor, tc.args.depositAmount)
|
||||
}
|
||||
|
||||
// verify results
|
||||
if tc.errArgs.expectPass {
|
||||
suite.Require().NoError(err)
|
||||
acc := suite.getAccount(tc.args.depositor)
|
||||
suite.Require().Equal(tc.args.expectedAccountBalance, suite.getAccountCoins(acc))
|
||||
mAcc := suite.getModuleAccount(types.ModuleAccountName)
|
||||
suite.Require().Equal(tc.args.expectedModAccountBalance, suite.getAccountCoins(mAcc))
|
||||
dep, f := suite.keeper.GetDeposit(suite.ctx, tc.args.depositor)
|
||||
suite.Require().True(f)
|
||||
suite.Require().Equal(tc.args.expectedDepositCoins, dep.Amount)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
||||
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
@ -13,17 +14,17 @@ import (
|
||||
|
||||
// Keeper struct for savings module
|
||||
type Keeper struct {
|
||||
// key used to access the stores from Context
|
||||
key sdk.StoreKey
|
||||
// Codec for binary encoding/decoding
|
||||
cdc codec.Codec
|
||||
// The reference to the Paramstore to get and set savings specific params
|
||||
paramSubspace paramtypes.Subspace
|
||||
accountKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
}
|
||||
|
||||
// NewKeeper returns a new keeper for the savings module.
|
||||
func NewKeeper(
|
||||
cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace,
|
||||
ak types.AccountKeeper, bk types.BankKeeper,
|
||||
) Keeper {
|
||||
if !paramstore.HasKeyTable() {
|
||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||
@ -33,6 +34,47 @@ func NewKeeper(
|
||||
cdc: cdc,
|
||||
key: key,
|
||||
paramSubspace: paramstore,
|
||||
accountKeeper: ak,
|
||||
bankKeeper: bk,
|
||||
}
|
||||
}
|
||||
|
||||
// GetDeposit returns a deposit from the store for a particular depositor address, deposit denom
|
||||
func (k Keeper) GetDeposit(ctx sdk.Context, depositor sdk.AccAddress) (types.Deposit, bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.key), types.DepositsKeyPrefix)
|
||||
bz := store.Get(depositor.Bytes())
|
||||
if len(bz) == 0 {
|
||||
return types.Deposit{}, false
|
||||
}
|
||||
var deposit types.Deposit
|
||||
k.cdc.MustUnmarshal(bz, &deposit)
|
||||
return deposit, true
|
||||
}
|
||||
|
||||
// SetDeposit sets the input deposit in the store
|
||||
func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.key), types.DepositsKeyPrefix)
|
||||
bz := k.cdc.MustMarshal(&deposit)
|
||||
store.Set(deposit.Depositor.Bytes(), bz)
|
||||
}
|
||||
|
||||
// DeleteDeposit deletes a deposit from the store
|
||||
func (k Keeper) DeleteDeposit(ctx sdk.Context, deposit types.Deposit) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.key), types.DepositsKeyPrefix)
|
||||
store.Delete(deposit.Depositor.Bytes())
|
||||
}
|
||||
|
||||
// IterateDeposits iterates over all deposit objects in the store and performs a callback function
|
||||
func (k Keeper) IterateDeposits(ctx sdk.Context, cb func(deposit types.Deposit) (stop bool)) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.key), types.DepositsKeyPrefix)
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var deposit types.Deposit
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &deposit)
|
||||
if cb(deposit) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,19 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/x/savings/keeper"
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
|
||||
// Test suite used for all keeper tests
|
||||
@ -39,6 +41,61 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
suite.addrs = addrs
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGetSetDeleteDeposit() {
|
||||
dep := types.NewDeposit(sdk.AccAddress("test"), sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))))
|
||||
|
||||
_, f := suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
|
||||
suite.Require().False(f)
|
||||
|
||||
suite.keeper.SetDeposit(suite.ctx, dep)
|
||||
|
||||
testDeposit, f := suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
|
||||
suite.Require().True(f)
|
||||
suite.Require().Equal(dep, testDeposit)
|
||||
|
||||
suite.Require().NotPanics(func() { suite.keeper.DeleteDeposit(suite.ctx, dep) })
|
||||
_, f = suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
|
||||
suite.Require().False(f)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestIterateDeposits() {
|
||||
for i := 0; i < 5; i++ {
|
||||
dep := types.NewDeposit(sdk.AccAddress("test"+fmt.Sprint(i)), sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(100))))
|
||||
suite.Require().NotPanics(func() { suite.keeper.SetDeposit(suite.ctx, dep) })
|
||||
}
|
||||
var deposits []types.Deposit
|
||||
suite.keeper.IterateDeposits(suite.ctx, func(d types.Deposit) bool {
|
||||
deposits = append(deposits, d)
|
||||
return false
|
||||
})
|
||||
suite.Require().Equal(5, len(deposits))
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) getAccountCoins(acc authtypes.AccountI) sdk.Coins {
|
||||
bk := suite.app.GetBankKeeper()
|
||||
return bk.GetAllBalances(suite.ctx, acc.GetAddress())
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) getAccount(addr sdk.AccAddress) authtypes.AccountI {
|
||||
ak := suite.app.GetAccountKeeper()
|
||||
return ak.GetAccount(suite.ctx, addr)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) getAccountAtCtx(addr sdk.AccAddress, ctx sdk.Context) authtypes.AccountI {
|
||||
ak := suite.app.GetAccountKeeper()
|
||||
return ak.GetAccount(ctx, addr)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) getModuleAccount(name string) authtypes.ModuleAccountI {
|
||||
ak := suite.app.GetAccountKeeper()
|
||||
return ak.GetModuleAccount(suite.ctx, name)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) getModuleAccountAtCtx(name string, ctx sdk.Context) authtypes.ModuleAccountI {
|
||||
ak := suite.app.GetAccountKeeper()
|
||||
return ak.GetModuleAccount(ctx, name)
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(KeeperTestSuite))
|
||||
}
|
||||
|
44
x/savings/keeper/msg_server.go
Normal file
44
x/savings/keeper/msg_server.go
Normal file
@ -0,0 +1,44 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/kava-labs/kava/x/savings/types"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
keeper Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the hard MsgServer interface
|
||||
// for the provided Keeper.
|
||||
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types.MsgDepositResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
depositor, err := sdk.AccAddressFromBech32(msg.Depositor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = k.keeper.Deposit(ctx, depositor, msg.Amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
|
||||
),
|
||||
)
|
||||
return &types.MsgDepositResponse{}, nil
|
||||
}
|
@ -17,3 +17,14 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
k.paramSubspace.SetParamSet(ctx, ¶ms)
|
||||
}
|
||||
|
||||
// IsDenomSupported returns a boolean indicating if a denom is supported
|
||||
func (k Keeper) IsDenomSupported(ctx sdk.Context, denom string) bool {
|
||||
p := k.GetParams(ctx)
|
||||
for _, supportedDenom := range p.SupportedDenoms {
|
||||
if supportedDenom == denom {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -93,14 +93,16 @@ type AppModule struct {
|
||||
|
||||
keeper keeper.Keeper
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(keeper keeper.Keeper, accountKeeper authkeeper.AccountKeeper) AppModule {
|
||||
func NewAppModule(keeper keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper types.BankKeeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{},
|
||||
keeper: keeper,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +137,7 @@ func (AppModule) ConsensusVersion() uint64 {
|
||||
// RegisterServices registers module services.
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
// TODO:
|
||||
// types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||
// types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
|
||||
@ -15,7 +16,11 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil))
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgDeposit{},
|
||||
)
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
|
46
x/savings/types/deposit.go
Normal file
46
x/savings/types/deposit.go
Normal file
@ -0,0 +1,46 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// NewDeposit returns a new deposit
|
||||
func NewDeposit(depositor sdk.AccAddress, amount sdk.Coins) Deposit {
|
||||
return Deposit{
|
||||
Depositor: depositor,
|
||||
Amount: amount,
|
||||
}
|
||||
}
|
||||
|
||||
// Validate deposit validation
|
||||
func (d Deposit) Validate() error {
|
||||
if d.Depositor.Empty() {
|
||||
return fmt.Errorf("depositor cannot be empty")
|
||||
}
|
||||
if !d.Amount.IsValid() {
|
||||
return fmt.Errorf("invalid deposit coins: %s", d.Amount)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deposits is a slice of Deposit
|
||||
type Deposits []Deposit
|
||||
|
||||
// Validate validates Deposits
|
||||
func (ds Deposits) Validate() error {
|
||||
depositDupMap := make(map[string]Deposit)
|
||||
for _, d := range ds {
|
||||
if err := d.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
dup, ok := depositDupMap[d.Depositor.String()]
|
||||
if ok {
|
||||
return fmt.Errorf("duplicate depositor: %s\n%s", d, dup)
|
||||
}
|
||||
depositDupMap[d.Depositor.String()] = d
|
||||
}
|
||||
return nil
|
||||
}
|
@ -9,4 +9,6 @@ import (
|
||||
var (
|
||||
// ErrEmptyInput error for empty input
|
||||
ErrEmptyInput = sdkerrors.Register(ModuleName, 2, "input must not be empty")
|
||||
// ErrInvalidDepositDenom error for invalid deposit denoms
|
||||
ErrInvalidDepositDenom = sdkerrors.Register(ModuleName, 3, "invalid deposit denom")
|
||||
)
|
||||
|
@ -1,8 +1,9 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
EventTypePlaceholder = "placeholder"
|
||||
EventTypeSavingsDeposit = "deposit_savings"
|
||||
|
||||
AttributeValueCategory = ModuleName
|
||||
AttributePlaceholderID = "placeholder_id"
|
||||
AttributeKeyAmount = "amount"
|
||||
AttributeKeyDepositor = "depositor"
|
||||
)
|
||||
|
@ -5,6 +5,18 @@ import (
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// BankKeeper defines the expected bank keeper
|
||||
type BankKeeper interface {
|
||||
SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
|
||||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
|
||||
GetSupply(ctx sdk.Context, denom string) sdk.Coin
|
||||
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
||||
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
||||
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
||||
}
|
||||
|
||||
// AccountKeeper defines the expected keeper interface for interacting with account
|
||||
type AccountKeeper interface {
|
||||
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
|
||||
|
@ -78,7 +78,7 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_f5dcde4d417fcec8 = []byte{
|
||||
// 213 bytes of a gzipped FileDescriptorProto
|
||||
// 204 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0x4e, 0x2c, 0x4b,
|
||||
0xd4, 0x2f, 0x4e, 0x2c, 0xcb, 0xcc, 0x4b, 0x2f, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
|
||||
0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12,
|
||||
@ -87,68 +87,13 @@ var fileDescriptor_f5dcde4d417fcec8 = []byte{
|
||||
0x4a, 0x5e, 0x5c, 0x3c, 0xee, 0x10, 0xe3, 0x83, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xac, 0xb8, 0xd8,
|
||||
0x0a, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, 0xf4, 0xb0,
|
||||
0x59, 0xa7, 0x17, 0x00, 0x56, 0xe3, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x87, 0x93,
|
||||
0xf7, 0x83, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91,
|
||||
0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3,
|
||||
0xb1, 0x1c, 0x43, 0x94, 0x66, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e,
|
||||
0xc8, 0x5c, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x30, 0x4b, 0xbf, 0x02, 0xee, 0xf8, 0x92, 0xca, 0x82,
|
||||
0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xfb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x34, 0x4a, 0x83,
|
||||
0x71, 0x13, 0x01, 0x00, 0x00,
|
||||
0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1,
|
||||
0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa6, 0x67, 0x96, 0x64,
|
||||
0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0xcc, 0xd3, 0xcd, 0x49, 0x4c, 0x2a, 0x06, 0xb3,
|
||||
0xf4, 0x2b, 0xe0, 0x8e, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xbb, 0xcb, 0x18, 0x10,
|
||||
0x00, 0x00, 0xff, 0xff, 0x5d, 0xc8, 0xba, 0x5d, 0x0b, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *GenesisState) VerboseEqual(that interface{}) error {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that == nil && this != nil")
|
||||
}
|
||||
|
||||
that1, ok := that.(*GenesisState)
|
||||
if !ok {
|
||||
that2, ok := that.(GenesisState)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return fmt.Errorf("that is not of type *GenesisState")
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that is type *GenesisState but is nil && this != nil")
|
||||
} else if this == nil {
|
||||
return fmt.Errorf("that is type *GenesisState but is not nil && this == nil")
|
||||
}
|
||||
if !this.Params.Equal(&that1.Params) {
|
||||
return fmt.Errorf("Params this(%v) Not Equal that(%v)", this.Params, that1.Params)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GenesisState) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*GenesisState)
|
||||
if !ok {
|
||||
that2, ok := that.(GenesisState)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Params.Equal(&that1.Params) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
@ -21,6 +21,5 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// Add store prefixes here
|
||||
// IndexPrefix = []byte{0x00}
|
||||
DepositsKeyPrefix = []byte{0x01}
|
||||
)
|
||||
|
53
x/savings/types/msg.go
Normal file
53
x/savings/types/msg.go
Normal file
@ -0,0 +1,53 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// ensure Msg interface compliance at compile time
|
||||
var (
|
||||
_ sdk.Msg = &MsgDeposit{}
|
||||
)
|
||||
|
||||
// NewMsgDeposit returns a new MsgDeposit
|
||||
func NewMsgDeposit(depositor sdk.AccAddress, amount sdk.Coins) MsgDeposit {
|
||||
return MsgDeposit{
|
||||
Depositor: depositor.String(),
|
||||
Amount: amount,
|
||||
}
|
||||
}
|
||||
|
||||
// Route return the message type used for routing the message.
|
||||
func (msg MsgDeposit) Route() string { return RouterKey }
|
||||
|
||||
// Type returns a human-readable string for the message, intended for utilization within tags.
|
||||
func (msg MsgDeposit) Type() string { return "savings_deposit" }
|
||||
|
||||
// ValidateBasic does a simple validation check that doesn't require access to any other information.
|
||||
func (msg MsgDeposit) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Depositor)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, err.Error())
|
||||
}
|
||||
|
||||
if !msg.Amount.IsValid() || msg.Amount.IsZero() {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "deposit amount %s", msg.Amount)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes gets the canonical byte representation of the Msg.
|
||||
func (msg MsgDeposit) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(&msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners returns the addresses of signers that must sign.
|
||||
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
|
||||
depositor, err := sdk.AccAddressFromBech32(msg.Depositor)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{depositor}
|
||||
}
|
@ -114,7 +114,7 @@ func init() {
|
||||
func init() { proto.RegisterFile("kava/savings/v1beta1/query.proto", fileDescriptor_f78c91efc5db144f) }
|
||||
|
||||
var fileDescriptor_f78c91efc5db144f = []byte{
|
||||
// 299 bytes of a gzipped FileDescriptorProto
|
||||
// 290 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x4e, 0x2c, 0x4b,
|
||||
0xd4, 0x2f, 0x4e, 0x2c, 0xcb, 0xcc, 0x4b, 0x2f, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
|
||||
0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, 0xa9,
|
||||
@ -128,115 +128,12 @@ var fileDescriptor_f78c91efc5db144f = []byte{
|
||||
0x9e, 0x21, 0x08, 0xaa, 0xc3, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x51, 0x2f, 0x23, 0x17, 0x2b,
|
||||
0xd8, 0x64, 0xa1, 0x66, 0x46, 0x2e, 0x36, 0x88, 0x42, 0x21, 0x0d, 0xec, 0xc6, 0x60, 0xba, 0x4b,
|
||||
0x4a, 0x93, 0x08, 0x95, 0x10, 0xb7, 0x2a, 0xa9, 0x34, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x4e, 0x48,
|
||||
0x46, 0x1f, 0x6b, 0xb8, 0x41, 0x5c, 0xe5, 0xe4, 0xfd, 0xe0, 0xa1, 0x1c, 0xe3, 0x8a, 0x47, 0x72,
|
||||
0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7,
|
||||
0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x99, 0x9e, 0x59, 0x92,
|
||||
0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x36, 0x49, 0x37, 0x27, 0x31, 0xa9, 0x18, 0x62, 0x66,
|
||||
0x05, 0xdc, 0xd4, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x90, 0x1a, 0x03, 0x02, 0x00,
|
||||
0x00, 0xff, 0xff, 0xf2, 0xbe, 0x68, 0x26, 0xe2, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *QueryParamsRequest) VerboseEqual(that interface{}) error {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that == nil && this != nil")
|
||||
}
|
||||
|
||||
that1, ok := that.(*QueryParamsRequest)
|
||||
if !ok {
|
||||
that2, ok := that.(QueryParamsRequest)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return fmt.Errorf("that is not of type *QueryParamsRequest")
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that is type *QueryParamsRequest but is nil && this != nil")
|
||||
} else if this == nil {
|
||||
return fmt.Errorf("that is type *QueryParamsRequest but is not nil && this == nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *QueryParamsRequest) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*QueryParamsRequest)
|
||||
if !ok {
|
||||
that2, ok := that.(QueryParamsRequest)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *QueryParamsResponse) VerboseEqual(that interface{}) error {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that == nil && this != nil")
|
||||
}
|
||||
|
||||
that1, ok := that.(*QueryParamsResponse)
|
||||
if !ok {
|
||||
that2, ok := that.(QueryParamsResponse)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return fmt.Errorf("that is not of type *QueryParamsResponse")
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that is type *QueryParamsResponse but is nil && this != nil")
|
||||
} else if this == nil {
|
||||
return fmt.Errorf("that is type *QueryParamsResponse but is not nil && this == nil")
|
||||
}
|
||||
if !this.Params.Equal(&that1.Params) {
|
||||
return fmt.Errorf("Params this(%v) Not Equal that(%v)", this.Params, that1.Params)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *QueryParamsResponse) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*QueryParamsResponse)
|
||||
if !ok {
|
||||
that2, ok := that.(QueryParamsResponse)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Params.Equal(&that1.Params) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
0x46, 0x1f, 0x6b, 0xb8, 0x41, 0x5c, 0xe5, 0xe4, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72,
|
||||
0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7,
|
||||
0x72, 0x0c, 0x51, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0x60, 0x13,
|
||||
0x74, 0x73, 0x12, 0x93, 0x8a, 0x21, 0x66, 0x55, 0xc0, 0x4d, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e,
|
||||
0x62, 0x03, 0x07, 0xa5, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x6f, 0x18, 0xf9, 0xda, 0x01,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -5,6 +5,9 @@ package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
@ -61,100 +64,77 @@ func (m *Params) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Params proto.InternalMessageInfo
|
||||
|
||||
func (m *Params) GetSupportedDenoms() []string {
|
||||
if m != nil {
|
||||
return m.SupportedDenoms
|
||||
// Deposit defines an amount of coins deposited into a savings module account.
|
||||
type Deposit struct {
|
||||
Depositor github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=depositor,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"depositor,omitempty"`
|
||||
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
|
||||
}
|
||||
return nil
|
||||
|
||||
func (m *Deposit) Reset() { *m = Deposit{} }
|
||||
func (m *Deposit) String() string { return proto.CompactTextString(m) }
|
||||
func (*Deposit) ProtoMessage() {}
|
||||
func (*Deposit) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f7110366fa182786, []int{1}
|
||||
}
|
||||
func (m *Deposit) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Deposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Deposit.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 *Deposit) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Deposit.Merge(m, src)
|
||||
}
|
||||
func (m *Deposit) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Deposit) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Deposit.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Deposit proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Params)(nil), "kava.savings.v1beta1.Params")
|
||||
proto.RegisterType((*Deposit)(nil), "kava.savings.v1beta1.Deposit")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("kava/savings/v1beta1/store.proto", fileDescriptor_f7110366fa182786) }
|
||||
|
||||
var fileDescriptor_f7110366fa182786 = []byte{
|
||||
// 196 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x4e, 0x2c, 0x4b,
|
||||
0xd4, 0x2f, 0x4e, 0x2c, 0xcb, 0xcc, 0x4b, 0x2f, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
|
||||
0xd4, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, 0xa9,
|
||||
0xd0, 0x83, 0xaa, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07,
|
||||
0xb1, 0x20, 0x6a, 0x95, 0x8c, 0xb9, 0xd8, 0x02, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x85, 0x34, 0xb9,
|
||||
0x04, 0x8a, 0x4b, 0x0b, 0x0a, 0xf2, 0x8b, 0x4a, 0x52, 0x53, 0xe2, 0x53, 0x52, 0xf3, 0xf2, 0x73,
|
||||
0x8b, 0x25, 0x18, 0x15, 0x98, 0x35, 0x38, 0x83, 0xf8, 0xe1, 0xe2, 0x2e, 0x60, 0x61, 0x27, 0xef,
|
||||
0x07, 0x0f, 0xe5, 0x18, 0x57, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39,
|
||||
0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63,
|
||||
0x39, 0x86, 0x28, 0xcd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x90,
|
||||
0x6b, 0x74, 0x73, 0x12, 0x93, 0x8a, 0xc1, 0x2c, 0xfd, 0x0a, 0xb8, 0xdb, 0x4b, 0x2a, 0x0b, 0x52,
|
||||
0x8b, 0x93, 0xd8, 0xc0, 0x0e, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x0f, 0x9d, 0xba,
|
||||
0xd8, 0x00, 0x00, 0x00,
|
||||
// 334 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3f, 0x4f, 0xc2, 0x40,
|
||||
0x14, 0xef, 0x49, 0x82, 0xa1, 0x0e, 0x9a, 0xca, 0x00, 0x0c, 0x47, 0xc3, 0x54, 0x86, 0xde, 0x89,
|
||||
0x7c, 0x02, 0x2a, 0x89, 0x8e, 0x86, 0xd1, 0x85, 0x5c, 0xdb, 0xb3, 0x36, 0xd8, 0xbe, 0xa6, 0xef,
|
||||
0x20, 0xf2, 0x2d, 0xfc, 0x1c, 0xce, 0x7e, 0x08, 0x46, 0xe2, 0x60, 0x9c, 0x50, 0xe1, 0x5b, 0x38,
|
||||
0x99, 0xb6, 0x27, 0x3a, 0x3a, 0xdd, 0xbb, 0xdf, 0xbf, 0x7b, 0xf7, 0x9e, 0x69, 0xcf, 0xc4, 0x42,
|
||||
0x70, 0x14, 0x8b, 0x38, 0x8d, 0x90, 0x2f, 0x06, 0xbe, 0x54, 0x62, 0xc0, 0x51, 0x41, 0x2e, 0x59,
|
||||
0x96, 0x83, 0x02, 0xab, 0x59, 0x28, 0x98, 0x56, 0x30, 0xad, 0xe8, 0x34, 0x23, 0x88, 0xa0, 0x14,
|
||||
0xf0, 0xa2, 0xaa, 0xb4, 0x1d, 0x1a, 0x00, 0x26, 0x80, 0xdc, 0x17, 0x28, 0xf7, 0x61, 0x01, 0xc4,
|
||||
0xa9, 0xe6, 0xdb, 0x15, 0x3f, 0xad, 0x8c, 0xd5, 0xa5, 0xa2, 0x7a, 0x43, 0xb3, 0x7e, 0x2d, 0x72,
|
||||
0x91, 0xa0, 0xd5, 0x37, 0x4f, 0x70, 0x9e, 0x65, 0x90, 0x2b, 0x19, 0x4e, 0x43, 0x99, 0x42, 0x82,
|
||||
0x2d, 0x62, 0xd7, 0x9c, 0xc6, 0xe4, 0x78, 0x8f, 0x8f, 0x4b, 0xb8, 0xf7, 0x4a, 0xcc, 0xc3, 0xb1,
|
||||
0xcc, 0x00, 0x63, 0x65, 0xdd, 0x9a, 0x8d, 0xb0, 0x2a, 0x21, 0x6f, 0x11, 0x9b, 0x38, 0x0d, 0xef,
|
||||
0xea, 0x6b, 0xd3, 0x75, 0xa3, 0x58, 0xdd, 0xcd, 0x7d, 0x16, 0x40, 0xa2, 0x1f, 0xd4, 0x87, 0x8b,
|
||||
0xe1, 0x8c, 0xab, 0x65, 0x26, 0x91, 0x8d, 0x82, 0x60, 0x14, 0x86, 0xb9, 0x44, 0x7c, 0x79, 0x76,
|
||||
0x4f, 0x75, 0x5b, 0x1a, 0xf1, 0x96, 0x4a, 0xe2, 0xe4, 0x37, 0xda, 0x0a, 0xcc, 0xba, 0x48, 0x60,
|
||||
0x9e, 0xaa, 0xd6, 0x81, 0x5d, 0x73, 0x8e, 0xce, 0xdb, 0x4c, 0x1b, 0x8a, 0x4f, 0xff, 0xcc, 0x87,
|
||||
0x5d, 0x40, 0x9c, 0x7a, 0x67, 0xab, 0x4d, 0xd7, 0x78, 0x7a, 0xef, 0x3a, 0xff, 0xe8, 0xa1, 0x30,
|
||||
0xe0, 0x44, 0x47, 0x7b, 0x97, 0xab, 0x4f, 0x6a, 0xac, 0xb6, 0x94, 0xac, 0xb7, 0x94, 0x7c, 0x6c,
|
||||
0x29, 0x79, 0xdc, 0x51, 0x63, 0xbd, 0xa3, 0xc6, 0xdb, 0x8e, 0x1a, 0x37, 0xfd, 0x3f, 0x79, 0xc5,
|
||||
0x76, 0xdc, 0x7b, 0xe1, 0x63, 0x59, 0xf1, 0x87, 0xfd, 0x2e, 0xcb, 0x58, 0xbf, 0x5e, 0x4e, 0x77,
|
||||
0xf8, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x8f, 0xdc, 0x49, 0xe8, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Params) VerboseEqual(that interface{}) error {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that == nil && this != nil")
|
||||
}
|
||||
|
||||
that1, ok := that.(*Params)
|
||||
if !ok {
|
||||
that2, ok := that.(Params)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return fmt.Errorf("that is not of type *Params")
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("that is type *Params but is nil && this != nil")
|
||||
} else if this == nil {
|
||||
return fmt.Errorf("that is type *Params but is not nil && this == nil")
|
||||
}
|
||||
if len(this.SupportedDenoms) != len(that1.SupportedDenoms) {
|
||||
return fmt.Errorf("SupportedDenoms this(%v) Not Equal that(%v)", len(this.SupportedDenoms), len(that1.SupportedDenoms))
|
||||
}
|
||||
for i := range this.SupportedDenoms {
|
||||
if this.SupportedDenoms[i] != that1.SupportedDenoms[i] {
|
||||
return fmt.Errorf("SupportedDenoms this[%v](%v) Not Equal that[%v](%v)", i, this.SupportedDenoms[i], i, that1.SupportedDenoms[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *Params) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Params)
|
||||
if !ok {
|
||||
that2, ok := that.(Params)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.SupportedDenoms) != len(that1.SupportedDenoms) {
|
||||
return false
|
||||
}
|
||||
for i := range this.SupportedDenoms {
|
||||
if this.SupportedDenoms[i] != that1.SupportedDenoms[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -187,6 +167,50 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Deposit) 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 *Deposit) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Amount) > 0 {
|
||||
for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintStore(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Depositor) > 0 {
|
||||
i -= len(m.Depositor)
|
||||
copy(dAtA[i:], m.Depositor)
|
||||
i = encodeVarintStore(dAtA, i, uint64(len(m.Depositor)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintStore(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovStore(v)
|
||||
base := offset
|
||||
@ -213,6 +237,25 @@ func (m *Params) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Deposit) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Depositor)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovStore(uint64(l))
|
||||
}
|
||||
if len(m.Amount) > 0 {
|
||||
for _, e := range m.Amount {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovStore(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovStore(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@ -301,6 +344,122 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Deposit) 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 ErrIntOverflowStore
|
||||
}
|
||||
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: Deposit: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Deposit: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Depositor", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowStore
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthStore
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthStore
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Depositor = github_com_cosmos_cosmos_sdk_types.AccAddress(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowStore
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthStore
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthStore
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Amount = append(m.Amount, types.Coin{})
|
||||
if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipStore(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthStore
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipStore(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
@ -6,11 +6,18 @@ package types
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
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"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -24,20 +31,126 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// MsgDeposit defines the Msg/Deposit request type.
|
||||
type MsgDeposit struct {
|
||||
Depositor string `protobuf:"bytes,1,opt,name=depositor,proto3" json:"depositor,omitempty"`
|
||||
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
|
||||
func (m *MsgDeposit) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgDeposit) ProtoMessage() {}
|
||||
func (*MsgDeposit) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c0bf8679b144267a, []int{0}
|
||||
}
|
||||
func (m *MsgDeposit) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgDeposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgDeposit.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 *MsgDeposit) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgDeposit.Merge(m, src)
|
||||
}
|
||||
func (m *MsgDeposit) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgDeposit) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgDeposit.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgDeposit proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgDeposit) GetDepositor() string {
|
||||
if m != nil {
|
||||
return m.Depositor
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins {
|
||||
if m != nil {
|
||||
return m.Amount
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MsgDepositResponse defines the Msg/Deposit response type.
|
||||
type MsgDepositResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) Reset() { *m = MsgDepositResponse{} }
|
||||
func (m *MsgDepositResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgDepositResponse) ProtoMessage() {}
|
||||
func (*MsgDepositResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c0bf8679b144267a, []int{1}
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgDepositResponse.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 *MsgDepositResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgDepositResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgDepositResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgDepositResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgDeposit)(nil), "kava.savings.v1beta1.MsgDeposit")
|
||||
proto.RegisterType((*MsgDepositResponse)(nil), "kava.savings.v1beta1.MsgDepositResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("kava/savings/v1beta1/tx.proto", fileDescriptor_c0bf8679b144267a) }
|
||||
|
||||
var fileDescriptor_c0bf8679b144267a = []byte{
|
||||
// 157 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x4e, 0x2c, 0x4b,
|
||||
0xd4, 0x2f, 0x4e, 0x2c, 0xcb, 0xcc, 0x4b, 0x2f, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
|
||||
0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, 0x49, 0xeb, 0x41, 0xa5,
|
||||
0xf5, 0xa0, 0xd2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x05, 0xfa, 0x20, 0x16, 0x44, 0xad,
|
||||
0x11, 0x2b, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0x93, 0xf7, 0x83, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9,
|
||||
0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e,
|
||||
0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x66, 0x7a, 0x66, 0x49,
|
||||
0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x7c, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x30,
|
||||
0x4b, 0xbf, 0x02, 0xee, 0x94, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xd1, 0xc6, 0x80,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0x50, 0x1f, 0x14, 0xa7, 0x00, 0x00, 0x00,
|
||||
// 324 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4e, 0xf2, 0x40,
|
||||
0x14, 0x85, 0xdb, 0x9f, 0x84, 0x3f, 0x8c, 0xbb, 0xa6, 0x0b, 0x20, 0x71, 0x20, 0xac, 0xea, 0x82,
|
||||
0x19, 0xc1, 0xc4, 0xbd, 0xe0, 0x96, 0x0d, 0xc6, 0x8d, 0x31, 0x31, 0xd3, 0x76, 0x32, 0x36, 0x48,
|
||||
0x6f, 0xd3, 0x3b, 0x10, 0x7c, 0x0b, 0x5f, 0x43, 0xd7, 0x3e, 0x04, 0x4b, 0xe2, 0xca, 0x95, 0x1a,
|
||||
0x78, 0x11, 0xd3, 0xce, 0x40, 0x5d, 0x98, 0xb8, 0xea, 0x6d, 0xbe, 0x73, 0x4e, 0xce, 0xbd, 0x43,
|
||||
0x8e, 0x67, 0x62, 0x29, 0x38, 0x8a, 0x65, 0x92, 0x2a, 0xe4, 0xcb, 0x41, 0x28, 0xb5, 0x18, 0x70,
|
||||
0xbd, 0x62, 0x59, 0x0e, 0x1a, 0x3c, 0xbf, 0xc0, 0xcc, 0x62, 0x66, 0x71, 0xdb, 0x57, 0xa0, 0xa0,
|
||||
0x14, 0xf0, 0x62, 0x32, 0xda, 0x36, 0x8d, 0x00, 0xe7, 0x80, 0x3c, 0x14, 0x28, 0x0f, 0x49, 0x11,
|
||||
0x24, 0xa9, 0xe5, 0x2d, 0xc3, 0xef, 0x8c, 0xd1, 0xfc, 0x18, 0xd4, 0x7b, 0x76, 0x09, 0x99, 0xa0,
|
||||
0xba, 0x94, 0x19, 0x60, 0xa2, 0xbd, 0x73, 0xd2, 0x88, 0xcd, 0x08, 0x79, 0xd3, 0xed, 0xba, 0x41,
|
||||
0x63, 0xd4, 0x7c, 0x7b, 0xed, 0xfb, 0xd6, 0x73, 0x11, 0xc7, 0xb9, 0x44, 0xbc, 0xd2, 0x79, 0x92,
|
||||
0xaa, 0x69, 0x25, 0xf5, 0x22, 0x52, 0x17, 0x73, 0x58, 0xa4, 0xba, 0xf9, 0xaf, 0x5b, 0x0b, 0x8e,
|
||||
0x86, 0x2d, 0x66, 0x1d, 0x45, 0xa5, 0x7d, 0x7b, 0x36, 0x86, 0x24, 0x1d, 0x9d, 0xae, 0x3f, 0x3a,
|
||||
0xce, 0xcb, 0x67, 0x27, 0x50, 0x89, 0xbe, 0x5f, 0x84, 0x2c, 0x82, 0xb9, 0xad, 0x64, 0x3f, 0x7d,
|
||||
0x8c, 0x67, 0x5c, 0x3f, 0x66, 0x12, 0x4b, 0x03, 0x4e, 0x6d, 0x74, 0xcf, 0x27, 0x5e, 0x55, 0x75,
|
||||
0x2a, 0x31, 0x83, 0x14, 0xe5, 0xf0, 0x96, 0xd4, 0x26, 0xa8, 0xbc, 0x6b, 0xf2, 0x7f, 0xbf, 0x44,
|
||||
0x97, 0xfd, 0x76, 0x3b, 0x56, 0x79, 0xdb, 0xc1, 0x5f, 0x8a, 0x7d, 0xfa, 0x68, 0xbc, 0xde, 0x52,
|
||||
0x77, 0xb3, 0xa5, 0xee, 0xd7, 0x96, 0xba, 0x4f, 0x3b, 0xea, 0x6c, 0x76, 0xd4, 0x79, 0xdf, 0x51,
|
||||
0xe7, 0xe6, 0xe4, 0x47, 0xff, 0x22, 0xad, 0xff, 0x20, 0x42, 0x2c, 0x27, 0xbe, 0x3a, 0x3c, 0x6b,
|
||||
0xb9, 0x46, 0x58, 0x2f, 0x6f, 0x7d, 0xf6, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x4c, 0xbf, 0xbb,
|
||||
0xf3, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -52,6 +165,8 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
//
|
||||
// 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 {
|
||||
// Deposit defines a method for depositing funds to the savings module account
|
||||
Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@ -62,22 +177,423 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error) {
|
||||
out := new(MsgDepositResponse)
|
||||
err := c.cc.Invoke(ctx, "/kava.savings.v1beta1.Msg/Deposit", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
// Deposit defines a method for depositing funds to the savings module account
|
||||
Deposit(context.Context, *MsgDeposit) (*MsgDepositResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedMsgServer) Deposit(ctx context.Context, req *MsgDeposit) (*MsgDepositResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Deposit not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgDeposit)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).Deposit(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/kava.savings.v1beta1.Msg/Deposit",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).Deposit(ctx, req.(*MsgDeposit))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "kava.savings.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Deposit",
|
||||
Handler: _Msg_Deposit_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "kava/savings/v1beta1/tx.proto",
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) 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 *MsgDeposit) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Amount) > 0 {
|
||||
for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Depositor) > 0 {
|
||||
i -= len(m.Depositor)
|
||||
copy(dAtA[i:], m.Depositor)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Depositor)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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 *MsgDepositResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *MsgDeposit) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Depositor)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
if len(m.Amount) > 0 {
|
||||
for _, e := range m.Amount {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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
|
||||
}
|
||||
func sozTx(x uint64) (n int) {
|
||||
return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *MsgDeposit) 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: MsgDeposit: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgDeposit: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Depositor", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Depositor = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Amount = append(m.Amount, types.Coin{})
|
||||
if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgDepositResponse) 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: MsgDepositResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgDepositResponse: 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) || (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
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTx
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTx
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTx
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user