Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactored the claim module #42

Merged
merged 36 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fe64bd7
feat: add claim module
Jan 27, 2022
bebe003
Merge master
Jan 27, 2022
84da076
chore: fix the lint issue
Jan 29, 2022
078b3db
fix: fix the proto issues
Jan 29, 2022
d0cdd49
trying to fix proto breaking ci cd
Jan 29, 2022
b65b11c
trying to fix proto breaking ci cd
Jan 29, 2022
95f91cc
trying to fix proto breaking ci cd
Jan 29, 2022
b78a423
trying to fix proto breaking ci cd
Jan 29, 2022
0de8aea
trying to fix proto breaking ci cd
Jan 29, 2022
bfc0f12
trying to fix proto breaking ci cd
Jan 29, 2022
4923978
trying to fix proto breaking ci cd
Jan 29, 2022
bb68c3b
fix: fix the app testing
Jan 29, 2022
28a1de6
chore: add claim module account on initGenesis time
Jan 30, 2022
8c45025
chore: address the pr comments
Jan 31, 2022
a289963
feat: add claim_records to claim module
Jan 31, 2022
3397e35
chore: removed `Actions` from proto enum
Jan 31, 2022
543ab8e
chore: fix the `swagger` api doc route
Jan 31, 2022
f14280d
chore: try to fix upload test coverage report
Feb 8, 2022
517d893
test: added genesis test for claim module
Feb 11, 2022
cae90ad
Merge branch 'main' into sai/claim_module
Feb 11, 2022
129ff40
chore: remove burner, staking permission for claim module
Feb 11, 2022
ae2a91e
test: add cli and grpc tests for claim module
Feb 14, 2022
c3279a3
fix: fix the test coverage upload
Feb 15, 2022
2959aa5
feat: add claim module actions and txns
Mar 4, 2022
f756e7d
fix: fix the build issue
Mar 4, 2022
c8313b2
test: fix the test issue
Mar 4, 2022
50710bf
feat: add antehandler
Mar 29, 2022
a65feee
fix: fix the staking hooks for airdrop
Mar 31, 2022
91e7a7b
feat: add airdrop for proposal vote
Mar 31, 2022
b1a90a8
fix: fix the gov hooks
Mar 31, 2022
2ecb419
Merge branch 'main' into sai/initial_airdrop
gsk967 May 4, 2022
a87411e
fix gomod
anilcse Jun 1, 2022
d7383e1
refactor: refactored the claim module
Jun 6, 2022
460144c
Merge branch 'main' into sai/refactor_claim
Jun 21, 2022
fc83c80
chore: removed ante handlers
Jun 21, 2022
1742dec
chore: removed ante handlers test and fee
Jun 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 6
steps:
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
Expand All @@ -20,9 +19,10 @@ jobs:
**/**.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@master
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.28
args: --timeout 10m
github-token: ${{ secrets.github_token }}
version: latest
args: --out-format=tab
skip-go-installation: true
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/proto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: check-breakage
run: make proto-check-breaking
run: make proto-check-breaking
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
**/**.go
go.mod
go.sum
- name: run tests and generate coverage
run: make test-cover
- name: run all tests and generate coverage
run: go test -v -mod=readonly -timeout 30m -coverprofile=coverage.txt -tags='norace' -covermode=atomic `go list ./... | grep -v simapp`
if: env.GIT_DIFF
- name: Upload codecov report
uses: codecov/[email protected]
Expand Down
24 changes: 13 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

linters:
disable-all: true
Expand All @@ -11,30 +11,27 @@ linters:
- depguard
- dogsled
- errcheck
- exportloopref
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- maligned
- misspell
- nakedret
- nolintlint
- prealloc
- scopelint
- revive
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- unparam
- misspell
# - wsl
- nolintlint
- unused

issues:
exclude-rules:
Expand All @@ -55,9 +52,14 @@ issues:
- text: "ST1016:"
linters:
- stylecheck
- path: "migrations"
text: "SA1019:"
linters:
- staticcheck

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
dogsled:
max-blank-identifiers: 3
Expand All @@ -68,4 +70,4 @@ linters-settings:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
require-specific: false
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APP = ./passage
MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/envadiv/Passage3D.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8

export GO111MODULE = on

Expand Down Expand Up @@ -384,9 +384,11 @@ devdoc-update:

containerProtoVer=v0.2
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
containerProtoGen=passage3d-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=passage3d-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=passage3d-proto-fmt-$(containerProtoVer)
containerProtoLint=passage3d-proto-lint-$(containerProtoVer)
containerProtoBreaking=passage3d-proto-break-$(containerProtoVer)

proto-all: proto-format proto-lint proto-gen

Expand All @@ -412,10 +414,14 @@ proto-format:


proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@echo "Checking Proto-Lint"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoLint}$$"; then docker start -a $(containerProtoLint); else docker run --name $(containerProtoLint) -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8 \
lint --error-format=json ; fi

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master
@echo "Checking Proto Breaking "
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoBreaking}$$"; then docker start -a $(containerProtoBreaking); else docker run --name $(containerProtoBreaking) -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8 \
breaking --against $(HTTPS_GIT)#branch=main ; fi


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint
Expand Down
7 changes: 5 additions & 2 deletions app/addr_prefixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)
Expand All @@ -23,6 +22,10 @@ const (
)

func init() {
SetAddressPrefixes()
}

func SetAddressPrefixes() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
Expand All @@ -34,5 +37,5 @@ func init() {
}
return fmt.Errorf("unexpected address length %d", n)
})
config.Seal()
//config.Seal()
}
26 changes: 23 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"os"
"path/filepath"

appparams "github.com/envadiv/Passage3D/app/params"

"github.com/envadiv/Passage3D/x/claim"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand All @@ -25,7 +29,6 @@ import (
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -92,6 +95,9 @@ import (
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper"

claimkeeper "github.com/envadiv/Passage3D/x/claim/keeper"
claimtypes "github.com/envadiv/Passage3D/x/claim/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down Expand Up @@ -126,6 +132,9 @@ var (
vesting.AppModuleBasic{},
ibc.AppModuleBasic{},
transfer.AppModuleBasic{}, // i.e ibc-transfer module

// passage3d claim module
claim.AppModuleBasic{},
)

// module account permissions
Expand All @@ -137,6 +146,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
claimtypes.ModuleName: {authtypes.Minter},
}
)

Expand Down Expand Up @@ -184,6 +194,8 @@ type PassageApp struct {
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

ClaimKeeper claimkeeper.Keeper

// the module manager
mm *module.Manager

Expand All @@ -206,7 +218,7 @@ func init() {
// NewPassageApp returns a reference to an initialized PassageApp.
func NewPassageApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig,
homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig,
appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
) *PassageApp {

Expand All @@ -224,7 +236,7 @@ func NewPassageApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey,
authzkeeper.StoreKey, claimtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
Expand Down Expand Up @@ -285,6 +297,9 @@ func NewPassageApp(
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

// airdorp module keeper
app.ClaimKeeper = claimkeeper.NewKeeper(appCodec, keys[claimtypes.StoreKey], app.AccountKeeper, app.BankKeeper, &stakingKeeper, app.DistrKeeper, app.GetSubspace(claimtypes.ModuleName))

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
Expand Down Expand Up @@ -377,6 +392,7 @@ func NewPassageApp(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
claim.NewAppModule(appCodec, app.ClaimKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -401,6 +417,7 @@ func NewPassageApp(
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
claimtypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
)
Expand All @@ -420,6 +437,7 @@ func NewPassageApp(
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
claimtypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
Expand Down Expand Up @@ -449,6 +467,7 @@ func NewPassageApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
claimtypes.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
Expand Down Expand Up @@ -685,6 +704,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(claimtypes.ModuleName)

return paramsKeeper
}
10 changes: 6 additions & 4 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"encoding/json"
"github.com/envadiv/Passage3D/x/claim"
"os"
"testing"

Expand Down Expand Up @@ -38,7 +39,7 @@ import (
)

func TestSimAppExportAndBlockedAddrs(t *testing.T) {
encCfg := MakeTestEncodingConfig()
encCfg := MakeEncodingConfig()
db := dbm.NewMemDB()
app := NewPassageApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})

Expand Down Expand Up @@ -76,7 +77,7 @@ func TestGetMaccPerms(t *testing.T) {

func TestRunMigrations(t *testing.T) {
db := dbm.NewMemDB()
encCfg := MakeTestEncodingConfig()
encCfg := MakeEncodingConfig()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
app := NewPassageApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})

Expand Down Expand Up @@ -186,6 +187,7 @@ func TestRunMigrations(t *testing.T) {
"capability": capability.AppModule{}.ConsensusVersion(),
"ibc": ibc.AppModule{}.ConsensusVersion(),
"transfer": transfer.AppModule{}.ConsensusVersion(),
"claim": claim.AppModule{}.ConsensusVersion(),
},
)
if tc.expRunErr {
Expand All @@ -201,7 +203,7 @@ func TestRunMigrations(t *testing.T) {

func TestInitGenesisOnMigration(t *testing.T) {
db := dbm.NewMemDB()
encCfg := MakeTestEncodingConfig()
encCfg := MakeEncodingConfig()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
app := NewPassageApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
Expand Down Expand Up @@ -244,7 +246,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
}

func TestUpgradeStateOnGenesis(t *testing.T) {
encCfg := MakeTestEncodingConfig()
encCfg := MakeEncodingConfig()
db := dbm.NewMemDB()
app := NewPassageApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})
genesisState := NewDefaultGenesisState(encCfg.Marshaler)
Expand Down
11 changes: 4 additions & 7 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package app

import (
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/envadiv/Passage3D/app/params"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
// should be used only in tests or when creating a new app instance (NewApp*()).
// App user shouldn't create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() simappparams.EncodingConfig {
encodingConfig := simappparams.MakeTestEncodingConfig()
// MakeEncodingConfig creates an EncodingConfig for testing.
func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
Expand Down
7 changes: 3 additions & 4 deletions app/params/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
// NOTE: this field will be renamed to Codec
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
Loading