Skip to content

Commit

Permalink
feat(deonmetadata): enable testing for denom metadata creation with e…
Browse files Browse the repository at this point in the history
…rc20 hook (#343)
  • Loading branch information
zale144 authored Mar 26, 2024
1 parent f51ca65 commit 8e3dc66
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 166 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ jobs:
languages: "go"
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality

- name: Build
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
112 changes: 1 addition & 111 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,107 +1,8 @@
#!/usr/bin/make -f

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif

PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build

export GO111MODULE = on

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(DYMENSION_BUILD_OPTIONS)))
build_tags += gcc cleveldb
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
whitespace := $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk \
-X github.com/cosmos/cosmos-sdk/version.AppName=rollappd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(DYMENSION_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ifeq (,$(findstring nostrip,$(DYMENSION_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(DYMENSION_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

# ---------------------------------------------------------------------------- #
# Make targets #
# ---------------------------------------------------------------------------- #
.PHONY: install
install: go.sum ## Installs the rollappd binary
go install -mod=readonly $(BUILD_FLAGS) ./cmd/rollappd


.PHONY: build
build: ## Compiles the rollapd binary
go build -o build/rollappd $(BUILD_FLAGS) ./cmd/rollappd


.PHONY: clean
clean: ## Clean temporary files
Expand All @@ -117,17 +18,6 @@ vet: ## Run go vet
lint: ## Run linter
golangci-lint run


# ------------------------------------ EVM ----------------------------------- #
.PHONY: install_evm
install_evm: build_evm go.sum ## Install the rollapp_evm binary
mv build/rollapp_evm $(GOPATH)/bin/rollapp_evm

.PHONY: build_evm
build_evm: ## Compiles the rollapp_evm binary
$(eval BUILD_FLAGS+=-ldflags '-X github.com/cosmos/cosmos-sdk/version.AppName=rollapp_evm')
go build -o build/rollapp_evm $(BUILD_FLAGS) -tags evm ./cmd/evm

# ---------------------------------------------------------------------------- #
# testing #
# ---------------------------------------------------------------------------- #
Expand All @@ -151,7 +41,7 @@ containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
proto-gen: ## Generates protobuf files
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./proto/protocgen.sh; fi
sh ./scripts/protocgen.sh; fi

proto-format: ## Formats protobuf files
@echo "Formatting Protobuf files"
Expand Down
4 changes: 3 additions & 1 deletion testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ var (
ibctransfer.AppModuleBasic{},
vesting.AppModuleBasic{},
hubgenesis.AppModuleBasic{},
denommetadata.AppModuleBasic{},
)

// module account permissions
Expand All @@ -180,6 +181,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
hubgentypes.ModuleName: {authtypes.Burner},
denommetadatatypes.ModuleName: {authtypes.Minter},
}
)

Expand Down Expand Up @@ -456,7 +458,7 @@ func NewRollapp(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper),
denommetadata.NewAppModule(appCodec, app.DenommetadataKeeper, app.BankKeeper),
denommetadata.NewAppModule(app.DenommetadataKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
sequencers.NewAppModule(appCodec, app.SequencersKeeper),
Expand Down
4 changes: 2 additions & 2 deletions x/denommetadata/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

func TestParamsQuery(t *testing.T) {
k, ctx := testutils.NewTestDenommetadataKeeper(t)
app, ctx := testutils.NewTestDenommetadataKeeper(t)

q := keeper.Querier{Keeper: *k}
q := keeper.Querier{Keeper: app.DenommetadataKeeper}

wctx := sdk.WrapSDKContext(ctx)

Expand Down
3 changes: 2 additions & 1 deletion x/denommetadata/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

func TestParams(t *testing.T) {
// Setup the test environment
k, ctx := testutils.NewTestDenommetadataKeeper(t) // Assume you have a similar utility function for denommetadata keeper
app, ctx := testutils.NewTestDenommetadataKeeper(t) // Assume you have a similar utility function for denommetadata keeper
k := app.DenommetadataKeeper

// Set some initial parameters
initialParams := types.DefaultParams()
Expand Down
16 changes: 13 additions & 3 deletions x/denommetadata/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ import (
"github.com/dymensionxyz/dymension-rdk/x/denommetadata/types"
)

var _ types.MsgServer = &Keeper{}
type msgServer struct {
Keeper
}

// NewMsgServerImpl returns an implementation of the MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{Keeper: keeper}
}

var _ types.MsgServer = msgServer{}

// CreateDenomMetadata create the denom metadata in bank module
func (k Keeper) CreateDenomMetadata(
func (k msgServer) CreateDenomMetadata(
goCtx context.Context,
msg *types.MsgCreateDenomMetadata,
) (*types.MsgCreateDenomMetadataResponse, error) {
Expand Down Expand Up @@ -42,7 +52,7 @@ func (k Keeper) CreateDenomMetadata(
}

// UpdateDenomMetadata update the denom metadata in bank module
func (k Keeper) UpdateDenomMetadata(
func (k msgServer) UpdateDenomMetadata(
goCtx context.Context,
msg *types.MsgUpdateDenomMetadata,
) (*types.MsgUpdateDenomMetadataResponse, error) {
Expand Down
Loading

0 comments on commit 8e3dc66

Please sign in to comment.