Skip to content

Commit

Permalink
loan first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
smartdev0328 committed Aug 7, 2022
1 parent f07f2cd commit 04d88fd
Show file tree
Hide file tree
Showing 53 changed files with 9,445 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ import (
monitoringptypes "github.com/tendermint/spn/x/monitoringp/types"

"loan/docs"
loanmodule "loan/x/loan"
loanmodulekeeper "loan/x/loan/keeper"
loanmoduletypes "loan/x/loan/types"
// this line is used by starport scaffolding # stargate/app/moduleImport
)

Expand Down Expand Up @@ -153,6 +156,7 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
monitoringp.AppModuleBasic{},
loanmodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand All @@ -165,6 +169,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
loanmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -225,6 +230,7 @@ type App struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedMonitoringKeeper capabilitykeeper.ScopedKeeper

LoanKeeper loanmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -261,6 +267,7 @@ func New(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, monitoringptypes.StoreKey,
loanmoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -382,6 +389,16 @@ func New(
)
monitoringModule := monitoringp.NewAppModule(appCodec, app.MonitoringKeeper)

app.LoanKeeper = *loanmodulekeeper.NewKeeper(
appCodec,
keys[loanmoduletypes.StoreKey],
keys[loanmoduletypes.MemStoreKey],
app.GetSubspace(loanmoduletypes.ModuleName),

app.BankKeeper,
)
loanModule := loanmodule.NewAppModule(appCodec, app.LoanKeeper, app.AccountKeeper, app.BankKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

// Create static IBC router, add transfer route, then set and seal it
Expand Down Expand Up @@ -423,6 +440,7 @@ func New(
params.NewAppModule(app.ParamsKeeper),
transferModule,
monitoringModule,
loanModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -450,6 +468,7 @@ func New(
feegrant.ModuleName,
paramstypes.ModuleName,
monitoringptypes.ModuleName,
loanmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand All @@ -473,6 +492,7 @@ func New(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
monitoringptypes.ModuleName,
loanmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -501,6 +521,7 @@ func New(
ibctransfertypes.ModuleName,
feegrant.ModuleName,
monitoringptypes.ModuleName,
loanmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand All @@ -525,6 +546,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
transferModule,
monitoringModule,
loanModule,
// this line is used by starport scaffolding # stargate/app/appModule
)
app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -714,6 +736,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(monitoringptypes.ModuleName)
paramsKeeper.Subspace(loanmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
46 changes: 46 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29809,6 +29809,42 @@ paths:
format: uint64
tags:
- Query
/loan/loan/params:
get:
summary: Parameters queries the parameters of the module.
operationId: LoanLoanParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/tendermint/spn/claim/airdrop_supply:
get:
summary: Queries a AirdropSupply by index.
Expand Down Expand Up @@ -51516,6 +51552,16 @@ definitions:
description: |-
Version defines the versioning scheme used to negotiate the IBC verison in
the connection handshake.
loan.loan.Params:
type: object
description: Params defines the parameters for the module.
loan.loan.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
tendermint.spn.claim.ClaimRecord:
type: object
properties:
Expand Down
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ go 1.16
require (
github.com/cosmos/cosmos-sdk v0.45.4
github.com/cosmos/ibc-go/v3 v3.0.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/ignite/cli v0.22.2
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.1
github.com/tendermint/spn v0.2.1-0.20220610090138-44b136f042c4
github.com/tendermint/tendermint v0.34.19
Expand All @@ -15,8 +20,10 @@ require (
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58 // indirect
google.golang.org/genproto v0.0.0-20220805133916-01dd62135a58
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0
)

replace (
Expand Down
14 changes: 14 additions & 0 deletions proto/loan/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package loan.loan;

import "gogoproto/gogo.proto";
import "loan/params.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "loan/x/loan/types";

// GenesisState defines the loan module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
12 changes: 12 additions & 0 deletions proto/loan/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package loan.loan;

import "gogoproto/gogo.proto";

option go_package = "loan/x/loan/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;

}
30 changes: 30 additions & 0 deletions proto/loan/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";
package loan.loan;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "loan/params.proto";
// this line is used by starport scaffolding # 1

option go_package = "loan/x/loan/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/loan/loan/params";
}
// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

// this line is used by starport scaffolding # 3
13 changes: 13 additions & 0 deletions proto/loan/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package loan.loan;

// this line is used by starport scaffolding # proto/tx/import

option go_package = "loan/x/loan/types";

// Msg defines the Msg service.
service Msg {
// this line is used by starport scaffolding # proto/tx/rpc
}

// this line is used by starport scaffolding # proto/tx/message
53 changes: 53 additions & 0 deletions testutil/keeper/loan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package keeper

import (
"testing"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
"loan/x/loan/keeper"
"loan/x/loan/types"
)

func LoanKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"LoanParams",
)
k := keeper.NewKeeper(
cdc,
storeKey,
memStoreKey,
paramsSubspace,
nil,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

// Initialize params
k.SetParams(ctx, types.DefaultParams())

return k, ctx
}
2 changes: 2 additions & 0 deletions vue/src/store/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import CosmosIbcGoIbcCoreChannelV1 from './cosmos/ibc-go/ibc.core.channel.v1'
import CosmosIbcGoIbcCoreClientV1 from './cosmos/ibc-go/ibc.core.client.v1'
import CosmosIbcGoIbcCoreConnectionV1 from './cosmos/ibc-go/ibc.core.connection.v1'
import CosmosIbcGoIbcCorePortV1 from './cosmos/ibc-go/ibc.core.port.v1'
import LoanLoanLoan from './loan/loan.loan'


export default {
Expand All @@ -43,6 +44,7 @@ export default {
CosmosIbcGoIbcCoreClientV1: load(CosmosIbcGoIbcCoreClientV1, 'ibc.core.client.v1'),
CosmosIbcGoIbcCoreConnectionV1: load(CosmosIbcGoIbcCoreConnectionV1, 'ibc.core.connection.v1'),
CosmosIbcGoIbcCorePortV1: load(CosmosIbcGoIbcCorePortV1, 'ibc.core.port.v1'),
LoanLoanLoan: load(LoanLoanLoan, 'loan.loan'),

}

Expand Down
Loading

0 comments on commit 04d88fd

Please sign in to comment.