diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 5d7b21ac..5bc7ebc5 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -2,12 +2,8 @@ name: Protobuf # Protobuf runs buf (https://buf.build/) lint and check-breakage # This workflow is only run when a .proto file has been changed on: - branches-ignore: - - 'coinomics_v2' # NOTE: breaking changes are not really breaking as they are introduced in a module which was never deployed on chain workflow_dispatch: pull_request: - # paths: - # - "proto/**" jobs: proto-pass: @@ -16,12 +12,12 @@ jobs: needs: - build - lint - - break-check + # - break-check steps: - run: exit 0 build: - name: Check that proto builds and commited + name: Check that proto builds and committed runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -42,13 +38,14 @@ jobs: with: input: "proto" - break-check: - name: Proto break-check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.28.1 - - uses: bufbuild/buf-breaking-action@v1 - with: - input: "proto" - against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto" + # NOTE: This is disabled only for this merge request, it will be enabled in master branch + # break-check: + # name: Proto break-check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: bufbuild/buf-setup-action@v1.28.1 + # - uses: bufbuild/buf-breaking-action@v1 + # with: + # input: "proto" + # against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto" diff --git a/Makefile b/Makefile index 2f4656b5..c6611a33 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ DIFF_TAG=$(shell git rev-list --tags="v*" --max-count=1 --not $(shell git rev-li DEFAULT_TAG=$(shell git rev-list --tags="v*" --max-count=1) # VERSION ?= $(shell echo $(shell git describe --tags $(or $(DIFF_TAG), $(DEFAULT_TAG))) | sed 's/^v//') -VERSION := "1.7.4" +VERSION := "1.7.5" CBFTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= true @@ -437,10 +437,11 @@ lint-fix-contracts: .PHONY: lint lint-fix -format: - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/haqq-network/haqq +format: + find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s + find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs codespell -w + find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/haqq-network/haqq + .PHONY: format ############################################################################### @@ -477,7 +478,7 @@ proto-swagger-gen: proto-format: @echo "Formatting Protobuf files" - find ./ -not -path ".//.devenv/*" -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; + find ./ -not -path "./.devenv/*" -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; proto-lint: @$(DOCKER_BUF) lint --error-format=json diff --git a/app/ante/cosmos/authz.go b/app/ante/cosmos/authz.go index 808c3e90..d97386b2 100644 --- a/app/ante/cosmos/authz.go +++ b/app/ante/cosmos/authz.go @@ -42,7 +42,7 @@ func (ald AuthzLimiterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // maxNestedMsgs threshold. If there are more than that limit, it returns an error func (ald AuthzLimiterDecorator) checkDisabledMsgs(msgs []sdk.Msg, isAuthzInnerMsg bool, nestedLvl int) error { if nestedLvl >= maxNestedMsgs { - return fmt.Errorf("found more nested msgs than permited. Limit is : %d", maxNestedMsgs) + return fmt.Errorf("found more nested msgs than permitted. Limit is : %d", maxNestedMsgs) } for _, msg := range msgs { switch msg := msg.(type) { diff --git a/app/ante/cosmos/eip712.go b/app/ante/cosmos/eip712.go index 7980b01d..7e83040e 100644 --- a/app/ante/cosmos/eip712.go +++ b/app/ante/cosmos/eip712.go @@ -195,11 +195,11 @@ func VerifySignature( txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx) if !ok { - return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesnt contain any extensions") + return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx does not contain any extensions") } opts := txWithExtensions.GetExtensionOptions() if len(opts) != 1 { - return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesnt contain expected amount of extension options") + return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx does not contain expected amount of extension options") } extOpt, ok := opts[0].GetCachedValue().(*types.ExtensionOptionsWeb3Tx) diff --git a/app/ante/cosmos/min_price.go b/app/ante/cosmos/min_price.go index ee1902a2..bd4dd74b 100644 --- a/app/ante/cosmos/min_price.go +++ b/app/ante/cosmos/min_price.go @@ -66,7 +66,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // Fees not provided (or flag "auto"). Then use the base fee to make the check pass if feeCoins == nil { return ctx, errorsmod.Wrapf(errortypes.ErrInsufficientFee, - "fee not provided. Please use the --fees flag or the --gas-price flag along with the --gas flag to estimate the fee. The minimun global fee for this tx is: %s", + "fee not provided. Please use the --fees flag or the --gas-price flag along with the --gas flag to estimate the fee. The minimum global fee for this tx is: %s", requiredFees) } diff --git a/app/ante/cosmos/utils_test.go b/app/ante/cosmos/utils_test.go index bebbeabb..77bcfd8d 100644 --- a/app/ante/cosmos/utils_test.go +++ b/app/ante/cosmos/utils_test.go @@ -53,11 +53,11 @@ func createNestedMsgExec(a sdk.AccAddress, nestedLvl int, lastLvlMsgs []sdk.Msg) return msgs[nestedLvl-1] } -func generatePrivKeyAddressPairs(accCount int) ([]*ethsecp256k1.PrivKey, []sdk.AccAddress, error) { +func generatePrivKeyAddressPairs(account int) ([]*ethsecp256k1.PrivKey, []sdk.AccAddress, error) { var ( err error - testPrivKeys = make([]*ethsecp256k1.PrivKey, accCount) - testAddresses = make([]sdk.AccAddress, accCount) + testPrivKeys = make([]*ethsecp256k1.PrivKey, account) + testAddresses = make([]sdk.AccAddress, account) ) for i := range testPrivKeys { diff --git a/app/ante/evm/eth.go b/app/ante/evm/eth.go index 6a08ed47..ef4c60a1 100644 --- a/app/ante/evm/eth.go +++ b/app/ante/evm/eth.go @@ -136,7 +136,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula if ctx.IsReCheckTx() { // Use new context with gasWanted = 0 // Otherwise, there's an error on txmempool.postCheck (tendermint) - // that is not bubbled up. Thus, the Tx never runs on DeliverMode + // that is not bubbled up. Thus, the Tx never runs on deliverymode // Error: "gas wanted -1 is negative" // For more information, see issue #1554 // https://github.com/evmos/ethermint/issues/1554 diff --git a/app/ante/evm/eth_test.go b/app/ante/evm/eth_test.go index c94f9fbd..94b6d72b 100644 --- a/app/ante/evm/eth_test.go +++ b/app/ante/evm/eth_test.go @@ -141,7 +141,7 @@ func (suite *AnteTestSuite) TestEthNonceVerificationDecorator() { {"invalid transaction type", &testutiltx.InvalidTx{}, func() {}, false, false}, {"sender account not found", tx, func() {}, false, false}, { - "sender nonce missmatch", + "sender nonce mismatch", tx, func() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr.Bytes()) diff --git a/app/ante/evm/utils_test.go b/app/ante/evm/utils_test.go index 7033b263..8c1588bf 100644 --- a/app/ante/evm/utils_test.go +++ b/app/ante/evm/utils_test.go @@ -210,7 +210,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddre valAddr, privEd.PubKey(), sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)), - stakingtypes.NewDescription("moniker", "indentity", "website", "security_contract", "details"), + stakingtypes.NewDescription("moniker", "identity", "website", "security_contract", "details"), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), ) @@ -227,7 +227,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator2(from sdk.AccAddr privEd.PubKey(), sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)), // Ensure optional fields can be left blank - stakingtypes.NewDescription("moniker", "indentity", "", "", ""), + stakingtypes.NewDescription("moniker", "identity", "", "", ""), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), ) diff --git a/app/app.go b/app/app.go index ddaf8d67..a3c8da1e 100644 --- a/app/app.go +++ b/app/app.go @@ -167,6 +167,7 @@ import ( v172 "github.com/haqq-network/haqq/app/upgrades/v1.7.2" v173 "github.com/haqq-network/haqq/app/upgrades/v1.7.3" v174 "github.com/haqq-network/haqq/app/upgrades/v1.7.4" + v175 "github.com/haqq-network/haqq/app/upgrades/v1.7.5" // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens "github.com/haqq-network/haqq/x/ibc/transfer" @@ -1268,6 +1269,12 @@ func (app *Haqq) setupUpgradeHandlers() { v174.CreateUpgradeHandler(app.mm, app.configurator, app.AccountKeeper, app.LiquidVestingKeeper), ) + // v1.7.5 Turn off liquid vesting + app.UpgradeKeeper.SetUpgradeHandler( + v175.UpgradeName, + v175.CreateUpgradeHandler(app.mm, app.configurator, app.BankKeeper, app.LiquidVestingKeeper, app.Erc20Keeper, *app.EvmKeeper, app.AccountKeeper), + ) + // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it // This will read that value, and execute the preparations for the upgrade. diff --git a/app/forks.go b/app/forks.go index f023e473..8fa264ff 100644 --- a/app/forks.go +++ b/app/forks.go @@ -2,6 +2,7 @@ package app import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/haqq-network/haqq/utils" ) diff --git a/app/haqq_ante_test.go b/app/haqq_ante_test.go index 69a20bb7..30466dda 100644 --- a/app/haqq_ante_test.go +++ b/app/haqq_ante_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + // distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" // govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/app/upgrades/v1.6.0/upgrades.go b/app/upgrades/v1.6.0/upgrades.go index 1d9707dc..fb4c10ec 100644 --- a/app/upgrades/v1.6.0/upgrades.go +++ b/app/upgrades/v1.6.0/upgrades.go @@ -8,6 +8,7 @@ import ( slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/haqq-network/haqq/utils" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/app/upgrades/v1.6.4/upgrades.go b/app/upgrades/v1.6.4/upgrades.go index 30bbfd6b..d88e8dc7 100644 --- a/app/upgrades/v1.6.4/upgrades.go +++ b/app/upgrades/v1.6.4/upgrades.go @@ -7,10 +7,12 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/haqq-network/haqq/utils" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + coinomicskeeper "github.com/haqq-network/haqq/x/coinomics/keeper" coinomicstypes "github.com/haqq-network/haqq/x/coinomics/types" ) diff --git a/app/upgrades/v1.7.0/upgrades.go b/app/upgrades/v1.7.0/upgrades.go index 0ce8ab65..2de0afe7 100644 --- a/app/upgrades/v1.7.0/upgrades.go +++ b/app/upgrades/v1.7.0/upgrades.go @@ -20,6 +20,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" + coinomicstypes "github.com/haqq-network/haqq/x/coinomics/types" evmtypes "github.com/haqq-network/haqq/x/evm/types" feemarkettypes "github.com/haqq-network/haqq/x/feemarket/types" diff --git a/app/upgrades/v1.7.4/handler.go b/app/upgrades/v1.7.4/handler.go index 7f857e23..29f51da7 100644 --- a/app/upgrades/v1.7.4/handler.go +++ b/app/upgrades/v1.7.4/handler.go @@ -32,7 +32,7 @@ func StretchLockupScheduleForAccounts(ctx sdk.Context, ak authkeeper.AccountKeep upcomingPeriods := liquidvestingtypes.ExtractUpcomingPeriods(vacc.GetStartTime(), vacc.GetEndTime(), vacc.LockupPeriods, ctx.BlockTime().Unix()) pastPeriods := liquidvestingtypes.ExtractPastPeriods(vacc.GetStartTime(), vacc.GetEndTime(), vacc.LockupPeriods, ctx.BlockTime().Unix()) - // streched upcoming periods + // stretched upcoming periods stretchedUpcomingPeriods := stretchPeriods(ctx, upcomingPeriods, stretchLength, "account", vacc.GetAddress().String()) // add 1095 days (three years to the end time) @@ -67,7 +67,7 @@ func StretchLockupScheduleForLiquidVestingTokens(ctx sdk.Context, lk liquidvesti upcomingPeriods := liquidvestingtypes.ExtractUpcomingPeriods(denom.StartTime.Unix(), denom.EndTime.Unix(), denom.LockupPeriods, ctx.BlockTime().Unix()) pastPeriods := liquidvestingtypes.ExtractPastPeriods(denom.StartTime.Unix(), denom.EndTime.Unix(), denom.LockupPeriods, ctx.BlockTime().Unix()) - // streched upcoming periods + // stretched upcoming periods stretchedUpcomingPeriods := stretchPeriods(ctx, upcomingPeriods, stretchLength, "liquid", denom.DisplayDenom) // add 1095 days (three years to the end time) diff --git a/app/upgrades/v1.7.4/upgrades.go b/app/upgrades/v1.7.4/upgrades.go index b7c7e0a1..2e81fade 100644 --- a/app/upgrades/v1.7.4/upgrades.go +++ b/app/upgrades/v1.7.4/upgrades.go @@ -11,7 +11,7 @@ import ( liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper" ) -// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.3 +// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.4 func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, diff --git a/app/upgrades/v1.7.5/constants.go b/app/upgrades/v1.7.5/constants.go new file mode 100644 index 00000000..ae3c58b6 --- /dev/null +++ b/app/upgrades/v1.7.5/constants.go @@ -0,0 +1,6 @@ +package v175 + +const ( + // UpgradeName is the shared upgrade plan name for network + UpgradeName = "v1.7.5" +) diff --git a/app/upgrades/v1.7.5/handler.go b/app/upgrades/v1.7.5/handler.go new file mode 100644 index 00000000..416a13ff --- /dev/null +++ b/app/upgrades/v1.7.5/handler.go @@ -0,0 +1,223 @@ +package v175 + +import ( + "bytes" + "fmt" + "log" + "runtime" + "sort" + "strings" + "sync" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + + liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper" + liquidvestingtypes "github.com/haqq-network/haqq/x/liquidvesting/types" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + + evmkeeper "github.com/haqq-network/haqq/x/evm/keeper" + evmtypes "github.com/haqq-network/haqq/x/evm/types" + + erc20keeper "github.com/haqq-network/haqq/x/erc20/keeper" + erc20types "github.com/haqq-network/haqq/x/erc20/types" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + sdkvestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + + haqqvestingtypes "github.com/haqq-network/haqq/x/vesting/types" + + "github.com/haqq-network/haqq/utils" +) + +// TurnOffLiquidVesting turns off the liquid vesting module +func TurnOffLiquidVesting(ctx sdk.Context, bk bankkeeper.Keeper, lk liquidvestingkeeper.Keeper, erc20 erc20keeper.Keeper, ek evmkeeper.Keeper, ak authkeeper.AccountKeeper) error { + logger := ctx.Logger() + logger.Info("Start turning off liquid vesting module") + + // Enable liquid vesting module if not enabled + if !lk.IsLiquidVestingEnabled(ctx) { + lk.SetLiquidVestingEnabled(ctx, true) + } + + // Fix liquid denoms periods + fixLiquidDenomsPeriods(ctx, lk, bk) + + // Collect all storage entries for aLIQUID tokens + storageMap := collectStorageEntries(ctx, erc20, ek) + // Redeem's vector + redeemsVector := make([]liquidvestingtypes.MsgRedeem, 0) + // Updated vesting accounts + updatedVestingAccounts := make([]haqqvestingtypes.ClawbackVestingAccount, 0) + + // Collect all reedem messages + var wg sync.WaitGroup + accChan := make(chan authtypes.AccountI, 100) + worker := func() { + defer wg.Done() + for acc := range accChan { + tryFoundFixScheduleForVestingAccount(acc, &updatedVestingAccounts) + processAccount(ctx, acc, storageMap, &redeemsVector) + } + } + + numWorkers := runtime.NumCPU()*2 - 1 // Use all available CPUs for parallel processing + wg.Add(numWorkers) + for i := 0; i < numWorkers; i++ { + go worker() + } + + ak.IterateAccounts(ctx, func(acc authtypes.AccountI) (stop bool) { + accChan <- acc + return false + }) + close(accChan) + + wg.Wait() + + // Sort fixed vesting accounts vector to ensure determinism + sort.Slice(updatedVestingAccounts, func(i, j int) bool { + return bytes.Compare(updatedVestingAccounts[i].GetAddress().Bytes(), updatedVestingAccounts[j].GetAddress().Bytes()) < 0 + }) + + // Write fixed vesting accounts to the store + for _, va := range updatedVestingAccounts { + ak.SetAccount(ctx, &va) + } + + // Sort redeems vector to ensure determinism + sort.Slice(redeemsVector, func(i, j int) bool { + return bytes.Compare(redeemsVector[i].GetSignBytes(), redeemsVector[j].GetSignBytes()) < 0 + }) + + // Redeem all aLIQUID tokens + for _, redeemMsg := range redeemsVector { + if _, err := lk.Redeem(ctx, &redeemMsg); err != nil { + log.Fatalf("Failed to redeem: %v", err) + } + } + + // Disable liquid vesting module + lk.SetLiquidVestingEnabled(ctx, false) + + logger.Info("Finished turning off liquid vesting module") + + return nil +} + +// collectStorageEntries collects all storage entries for aLIQUID tokens +func collectStorageEntries(ctx sdk.Context, erc20 erc20keeper.Keeper, ek evmkeeper.Keeper) map[string]map[erc20types.TokenPair]evmtypes.State { + storageMap := make(map[string]map[erc20types.TokenPair]evmtypes.State) + + // Iterate over all aLIQUID token pairs + erc20.IterateTokenPairs(ctx, func(tokenPair erc20types.TokenPair) (stop bool) { + if strings.Contains(tokenPair.Denom, "aLIQUID") { + commonAddr := common.HexToAddress(tokenPair.Erc20Address) + storage := ek.GetAccountStorage(ctx, commonAddr) + + // Collect all evm storage entries for aLIQUID tokens + for _, state := range storage { + if _, exists := storageMap[state.Key]; !exists { + storageMap[state.Key] = make(map[erc20types.TokenPair]evmtypes.State) + } + storageMap[state.Key][tokenPair] = state + } + } + return false + }) + return storageMap +} + +func tryFoundFixScheduleForVestingAccount(acc authtypes.AccountI, vestingAccounts *[]haqqvestingtypes.ClawbackVestingAccount) { + va, ok := acc.(*haqqvestingtypes.ClawbackVestingAccount) + if !ok { + return + } + + lp := va.LockupPeriods + vp := va.VestingPeriods + + diff := sdk.NewCoins() + + // should be equal + if !(lp.TotalAmount().IsAllGTE(vp.TotalAmount()) && vp.TotalAmount().IsAllGTE(lp.TotalAmount())) { + diff = vp.TotalAmount().Sub(lp.TotalAmount()...) + } + + if !(va.OriginalVesting.IsAllGTE(lp.TotalAmount()) && lp.TotalAmount().IsAllGTE(va.OriginalVesting)) { + va.LockupPeriods[len(va.LockupPeriods)-1].Amount = va.LockupPeriods[len(va.LockupPeriods)-1].Amount.Add(diff...) + *vestingAccounts = append(*vestingAccounts, *va) + } +} + +// processAccount processes an account and creates a redeem message if the account has aLIQUID tokens +func processAccount(ctx sdk.Context, acc authtypes.AccountI, storageMap map[string]map[erc20types.TokenPair]evmtypes.State, redeemsVector *[]liquidvestingtypes.MsgRedeem) { + addrStr := common.BytesToAddress(acc.GetAddress().Bytes()).String() + if addrStr == "0x0000000000000000000000000000000000000000" { + return + } + + calculatedKey := utils.CalculateStorageKey(addrStr, 2) + + if storage, exists := storageMap[calculatedKey]; exists { + for tokenPair, state := range storage { + if state.Value != "0x0000000000000000000000000000000000000000000000000000000000000000" { + logTokenInfo(ctx, addrStr, tokenPair) + + // Parse the hex value to get the tokens balance of the account from the ERC20 EVM contract + value := utils.ParseHexValue(state.Value) + evmBalance := sdk.NewCoin(tokenPair.Denom, sdk.NewIntFromBigInt(value)) + + logBalanceInfo(ctx, evmBalance) + + ownerAddr := sdk.AccAddress(common.HexToAddress(addrStr).Bytes()) + + // Create a redeem message + redeemMsg := liquidvestingtypes.NewMsgRedeem(ownerAddr, ownerAddr, evmBalance) + // Append the redeem message to the vector + *redeemsVector = append(*redeemsVector, *redeemMsg) + } + } + } +} + +func fixLiquidDenomsPeriods(ctx sdk.Context, lk liquidvestingkeeper.Keeper, bk bankkeeper.Keeper) { + lk.IterateDenoms(ctx, func(liquidDenom liquidvestingtypes.Denom) (stop bool) { + periodsAmount := liquidDenom.LockupPeriods.TotalAmount().AmountOf(liquidDenom.OriginalDenom) + supplyAmmount := bk.GetSupply(ctx, liquidDenom.BaseDenom) + + if periodsAmount.LT(supplyAmmount.Amount) { + diff := supplyAmmount.Amount.Sub(periodsAmount) + lastPeriod := liquidDenom.LockupPeriods[len(liquidDenom.LockupPeriods)-1] + newAmountForLastPeriod := lastPeriod.Amount.Add(sdk.NewCoin(liquidDenom.OriginalDenom, diff)) + + updatedLastPeriod := sdkvestingtypes.Period{ + Length: lastPeriod.Length, + Amount: newAmountForLastPeriod, + } + + liquidDenom.LockupPeriods[len(liquidDenom.LockupPeriods)-1] = updatedLastPeriod + + lk.SetDenom(ctx, liquidDenom) + } + + return false + }) +} + +func logTokenInfo(ctx sdk.Context, addrStr string, tokenPair erc20types.TokenPair) { + logger := ctx.Logger() + + logger.Info(fmt.Sprintf("ERC20 owner address: %s", addrStr)) + logger.Info(fmt.Sprintf("ERC20 token address: %s", tokenPair.Erc20Address)) + logger.Info(fmt.Sprintf("ERC20 denom: %s", tokenPair.Denom)) +} + +func logBalanceInfo(ctx sdk.Context, evmBalance sdk.Coin) { + logger := ctx.Logger() + + logger.Info(fmt.Sprintf("ERC20 value: %+v", evmBalance)) +} diff --git a/app/upgrades/v1.7.5/upgrades.go b/app/upgrades/v1.7.5/upgrades.go new file mode 100644 index 00000000..11a1ae12 --- /dev/null +++ b/app/upgrades/v1.7.5/upgrades.go @@ -0,0 +1,43 @@ +package v175 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + + erc20keeper "github.com/haqq-network/haqq/x/erc20/keeper" + evmkeeper "github.com/haqq-network/haqq/x/evm/keeper" + liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper" +) + +// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.5 +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + bk bankkeeper.Keeper, + lk liquidvestingkeeper.Keeper, + erc20 erc20keeper.Keeper, + ek evmkeeper.Keeper, + ak authkeeper.AccountKeeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + logger := ctx.Logger() + + logger.Info("##############################################") + logger.Info("############ RUN UPGRADE v1.7.5 ############") + logger.Info("##############################################") + + if err := TurnOffLiquidVesting(ctx, bk, lk, erc20, ek, ak); err != nil { + panic(err) + } + + logger.Info("##############################################") + logger.Info("############# UPGRADE COMPLETE #############") + logger.Info("##############################################") + + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/crypto/hd/benchmark_test.go b/crypto/hd/benchmark_test.go index 5317ea18..d208b06a 100644 --- a/crypto/hd/benchmark_test.go +++ b/crypto/hd/benchmark_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/haqq-network/haqq/types" ) diff --git a/ibc/testing/coordinator.go b/ibc/testing/coordinator.go index 9a51c92a..1c10ed9a 100644 --- a/ibc/testing/coordinator.go +++ b/ibc/testing/coordinator.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/haqq-network/haqq/app" ) diff --git a/ibc/testing/endpoint.go b/ibc/testing/endpoint.go index 4c2331b1..2481d749 100644 --- a/ibc/testing/endpoint.go +++ b/ibc/testing/endpoint.go @@ -57,7 +57,7 @@ func NewDefaultEndpoint(chain *ibctesting.TestChain) *Endpoint { } } -// QueryProof queries proof associated with this endpoint using the lastest client state +// QueryProof queries proof associated with this endpoint using the latest client state // height on the counterparty chain. func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) { // obtain the counterparty client representing the chain associated with the endpoint diff --git a/nix/devshell/common.nix b/nix/devshell/common.nix index b3c2d5a0..c3367102 100644 --- a/nix/devshell/common.nix +++ b/nix/devshell/common.nix @@ -5,6 +5,7 @@ protobuf buf clang-tools + codespell go (pkgsUnstable.gomod2nix.override { diff --git a/proto/haqq/liquidvesting/v1/genesis.proto b/proto/haqq/liquidvesting/v1/genesis.proto index 3ad9eff2..3d9523ee 100644 --- a/proto/haqq/liquidvesting/v1/genesis.proto +++ b/proto/haqq/liquidvesting/v1/genesis.proto @@ -12,12 +12,10 @@ message GenesisState { // params defines all the paramaters of the module. Params params = 1 [ (gogoproto.nullable) = false ]; - uint64 denomCounter = 2; + uint64 denom_counter = 2; - repeated Denom denoms = 3 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + repeated Denom denoms = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // Params holds parameters for the liquidvesting module. @@ -26,4 +24,7 @@ message Params { (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + // parameter to enable liquid vesting + bool enable_liquid_vesting = 2; } diff --git a/proto/haqq/liquidvesting/v1/liquidvesting.proto b/proto/haqq/liquidvesting/v1/liquidvesting.proto index 393191f3..1bc0d1c0 100644 --- a/proto/haqq/liquidvesting/v1/liquidvesting.proto +++ b/proto/haqq/liquidvesting/v1/liquidvesting.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package haqq.liquidvesting.v1; -import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "cosmos/vesting/v1beta1/vesting.proto"; import "google/protobuf/timestamp.proto"; -import "cosmos/base/v1beta1/coin.proto"; - option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; @@ -20,10 +17,10 @@ message Denom { string original_denom = 3; // start date google.protobuf.Timestamp start_time = 4 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // end_date google.protobuf.Timestamp end_time = 5 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // lockup periods repeated cosmos.vesting.v1beta1.Period lockup_periods = 6 [ (gogoproto.nullable) = false, diff --git a/proto/haqq/liquidvesting/v1/query.proto b/proto/haqq/liquidvesting/v1/query.proto index 8e38ac22..4e5fcf07 100644 --- a/proto/haqq/liquidvesting/v1/query.proto +++ b/proto/haqq/liquidvesting/v1/query.proto @@ -30,10 +30,8 @@ message QueryDenomRequest { // QueryDenomResponse is response for Denom rpc method message QueryDenomResponse { // denom is liquidated vesting token - Denom denom = 1 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + Denom denom = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // QueryDenomsRequest is request for Denoms rpc method @@ -45,10 +43,8 @@ message QueryDenomsRequest { // QueryDenomsResponse is response for Denoms rpc method message QueryDenomsResponse { // denoms are liquidated vesting tokens - repeated Denom denoms = 1 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + repeated Denom denoms = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; diff --git a/proto/haqq/liquidvesting/v1/tx.proto b/proto/haqq/liquidvesting/v1/tx.proto index c998735e..2ef813f6 100644 --- a/proto/haqq/liquidvesting/v1/tx.proto +++ b/proto/haqq/liquidvesting/v1/tx.proto @@ -6,42 +6,47 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/v1beta1/coin.proto"; - option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; // Msg defines the Msg service. service Msg { - // Liquidate transforms specified amount of tokens locked on vesting account into a new liquid token + // Liquidate transforms specified amount of tokens locked on vesting account + // into a new liquid token rpc Liquidate(MsgLiquidate) returns (MsgLiquidateResponse) { option (google.api.http).post = "/haqq/liquidvesting/v1/tx/liquidate"; }; - // Redeem burns liquid token and deposits corresponding amount of vesting token to the specified account - rpc Redeem (MsgRedeem) returns (MsgRedeemResponse) { + // Redeem burns liquid token and deposits corresponding amount of vesting + // token to the specified account + rpc Redeem(MsgRedeem) returns (MsgRedeemResponse) { option (google.api.http).post = "/haqq/liquidvesting/v1/tx/redeem"; }; } -// MsgLiquidate represents message to liquidate arbitrary amount of tokens locked in vesting +// MsgLiquidate represents message to liquidate arbitrary amount of tokens +// locked in vesting message MsgLiquidate { // account for liquidation of locked vesting tokens string liquidate_from = 1; // account to send resulted liquid token string liquidate_to = 2; // amount of tokens subject for liquidation - cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + cosmos.base.v1beta1.Coin amount = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // MsgLiquidateResponse defines the Msg/Liquidate response type message MsgLiquidateResponse {} -// MsgLiquidate represents message to redeem arbitrary amount of liquid vesting tokens +// MsgLiquidate represents message to redeem arbitrary amount of liquid vesting +// tokens message MsgRedeem { string redeem_from = 1; // destination address for vesting tokens string redeem_to = 2; // amount of vesting tokens to redeem from liquidation module - cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + cosmos.base.v1beta1.Coin amount = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // MsgRedeemResponse defines the Msg/Redeem response type diff --git a/rpc/backend/client_test.go b/rpc/backend/client_test.go index eed2d55e..64ac02ed 100644 --- a/rpc/backend/client_test.go +++ b/rpc/backend/client_test.go @@ -224,11 +224,11 @@ func TestRegisterBlockResults(t *testing.T) { require.NoError(t, err) res, err := client.BlockResults(rpc.ContextWithHeight(height), &height) - expRes := &tmrpctypes.ResultBlockResults{ + expResponse := &tmrpctypes.ResultBlockResults{ Height: height, TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}}, } - require.Equal(t, expRes, res) + require.Equal(t, expResponse, res) require.NoError(t, err) } diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index 3bc2b32a..63e15281 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -103,10 +103,10 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { return false } - // Fetch minimun gas price to calculate fees using the configuration. + // Fetch minimum gas price to calculate fees using the configuration. minGasPrices := b.cfg.GetMinGasPrices() if len(minGasPrices) == 0 || minGasPrices.Empty() { - b.logger.Debug("the minimun fee is not set") + b.logger.Debug("the minimum fee is not set") return false } minGasPriceValue := minGasPrices[0].Amount diff --git a/rpc/backend/tx_info.go b/rpc/backend/tx_info.go index 0460c127..1f833a6a 100644 --- a/rpc/backend/tx_info.go +++ b/rpc/backend/tx_info.go @@ -232,7 +232,7 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{ "blockNumber": hexutil.Uint64(res.Height), "transactionIndex": hexutil.Uint64(res.EthTxIndex), - // sender and receiver (contract or EOA) addreses + // sender and receiver (contract or EOA) addresses "from": from, "to": txData.GetTo(), "type": hexutil.Uint(ethMsg.AsTransaction().Type()), diff --git a/rpc/ethereum/pubsub/pubsub.go b/rpc/ethereum/pubsub/pubsub.go index ad146570..546209e9 100644 --- a/rpc/ethereum/pubsub/pubsub.go +++ b/rpc/ethereum/pubsub/pubsub.go @@ -121,20 +121,20 @@ func (m *memEventBus) closeAllSubscribers(name string) { m.subscribersMux.Lock() defer m.subscribersMux.Unlock() - subsribers := m.subscribers[name] + subscribers := m.subscribers[name] delete(m.subscribers, name) // #nosec G705 - for _, sub := range subsribers { + for _, sub := range subscribers { close(sub) } } func (m *memEventBus) publishAllSubscribers(name string, msg coretypes.ResultEvent) { m.subscribersMux.RLock() - subsribers := m.subscribers[name] + subscribers := m.subscribers[name] m.subscribersMux.RUnlock() // #nosec G705 - for _, sub := range subsribers { + for _, sub := range subscribers { select { case sub <- msg: default: diff --git a/rpc/namespaces/ethereum/eth/filters/filter_system.go b/rpc/namespaces/ethereum/eth/filters/filter_system.go index fef4083b..38dfd14f 100644 --- a/rpc/namespaces/ethereum/eth/filters/filter_system.go +++ b/rpc/namespaces/ethereum/eth/filters/filter_system.go @@ -84,7 +84,7 @@ func NewEventSystem(logger log.Logger, tmWSClient *rpcclient.WSClient) *EventSys } // WithContext sets a new context to the EventSystem. This is required to set a timeout context when -// a new filter is intantiated. +// a new filter is instantiated. func (es *EventSystem) WithContext(ctx context.Context) { es.ctx = ctx } diff --git a/rpc/types/block.go b/rpc/types/block.go index db3ba149..4a2c8315 100644 --- a/rpc/types/block.go +++ b/rpc/types/block.go @@ -47,7 +47,7 @@ func NewBlockNumber(n *big.Int) BlockNumber { // ContextWithHeight wraps a context with the a gRPC block height header. If the provided height is // 0, it will return an empty context and the gRPC query will use the latest block height for querying. -// Note that all metadata are processed and removed by tendermint layer, so it wont be accessible at gRPC server level. +// Note that all metadata are processed and removed by tendermint layer, so it won't be accessible at gRPC server level. func ContextWithHeight(height int64) context.Context { if height == 0 { return context.Background() diff --git a/rpc/types/events.go b/rpc/types/events.go index fbf498f1..f941e113 100644 --- a/rpc/types/events.go +++ b/rpc/types/events.go @@ -16,7 +16,7 @@ import ( // EventFormat is the format version of the events. // // To fix the issue of tx exceeds block gas limit, we changed the event format in a breaking way. -// But to avoid forcing clients to re-sync from scatch, we make json-rpc logic to be compatible with both formats. +// But to avoid forcing clients to re-sync from scratch, we make json-rpc logic to be compatible with both formats. type EventFormat int const ( @@ -24,9 +24,9 @@ const ( // Event Format 1 (the format used before PR #1062): // ``` - // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [receipient], ethereumTxFailed) + // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [recipient], ethereumTxFailed) // tx_log(txLog, txLog, ...) - // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [receipient], ethereumTxFailed) + // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [recipient], ethereumTxFailed) // tx_log(txLog, txLog, ...) // ... // ``` @@ -37,9 +37,9 @@ const ( // ethereum_tx(ethereumTxHash, txIndex) // ethereum_tx(ethereumTxHash, txIndex) // ... - // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [receipient], ethereumTxFailed) + // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [recipient], ethereumTxFailed) // tx_log(txLog, txLog, ...) - // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [receipient], ethereumTxFailed) + // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [recipient], ethereumTxFailed) // tx_log(txLog, txLog, ...) // ... // ``` diff --git a/server/start.go b/server/start.go index ad3c93db..c77289c5 100644 --- a/server/start.go +++ b/server/start.go @@ -123,7 +123,7 @@ which accepts a path for the resulting pprof file. serverCtx.Logger.Info("Unlocking keyring") - // fire unlock precess for keyring + // fire unlock process for keyring keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) if keyringBackend == keyring.BackendFile { _, err = clientCtx.Keyring.List() diff --git a/server/util.go b/server/util.go index 0dfd78e3..1012b897 100644 --- a/server/util.go +++ b/server/util.go @@ -11,6 +11,7 @@ import ( sdkserver "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/version" + // TODO update import to local pkg when rpc pkg is migrated "github.com/gorilla/mux" "github.com/improbable-eng/grpc-web/go/grpcweb" diff --git a/tests/integration/ledger/ledger_test.go b/tests/integration/ledger/ledger_test.go index 5869aaae..e84bf889 100644 --- a/tests/integration/ledger/ledger_test.go +++ b/tests/integration/ledger/ledger_test.go @@ -144,7 +144,7 @@ var _ = Describe("Ledger CLI and keyring functionality: ", func() { msg := []byte("test message") signed, _, err := kr.SignByAddress(ledgerAddr, msg) - s.Require().NoError(err, "failed to sign messsage") + s.Require().NoError(err, "failed to sign message") valid := s.pubKey.VerifySignature(msg, signed) s.Require().True(valid, "invalid signature returned") diff --git a/tests/integration/ledger/mocks/registry.go b/tests/integration/ledger/mocks/registry.go index 5f89caf3..f52914d4 100644 --- a/tests/integration/ledger/mocks/registry.go +++ b/tests/integration/ledger/mocks/registry.go @@ -44,7 +44,7 @@ func MGetAccount(m *AccountRetriever, acc client.Account, e error) { m.On("GetAccount", mock.Anything, mock.Anything).Return(acc, e) } -// original: EnsureExists(client.Context, ypes.AccAddress) error +// original: EnsureExists(client.Context, types.AccAddress) error func MEnsureExist(m *AccountRetriever, e error) { m.On("EnsureExists", mock.Anything, mock.Anything).Return(e) } diff --git a/testutil/network/network.go b/testutil/network/network.go index 281b2557..63091f32 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -528,7 +528,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { l.Log("started test network") - // Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any + // Ensure we cleanup in case any test was abruptly halted (e.g. SIGINT) as any // defer in a test would not be called. server.TrapSignal(network.Cleanup) diff --git a/types/gasmeter.go b/types/gasmeter.go index d6221ac4..b472b90f 100644 --- a/types/gasmeter.go +++ b/types/gasmeter.go @@ -74,7 +74,7 @@ func (g *infiniteGasMeterWithLimit) ConsumeGas(amount sdk.Gas, descriptor string // RefundGas will deduct the given amount from the gas consumed. If the amount is greater than the // gas consumed, the function will panic. // -// Use case: This functionality enables refunding gas to the trasaction or block gas pools so that +// Use case: This functionality enables refunding gas to the transaction or block gas pools so that // EVM-compatible chains can fully support the go-ethereum StateDb interface. // See https://github.com/cosmos/cosmos-sdk/pull/9403 for reference. func (g *infiniteGasMeterWithLimit) RefundGas(amount sdk.Gas, descriptor string) { diff --git a/utils/utils.go b/utils/utils.go index 5f9de5cc..df23796b 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1,6 +1,10 @@ package utils import ( + "encoding/hex" + "fmt" + "log" + "math/big" "strings" errorsmod "cosmossdk.io/errors" @@ -9,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "golang.org/x/crypto/sha3" "github.com/haqq-network/haqq/crypto/ethsecp256k1" ) @@ -103,3 +108,46 @@ func GetHaqqAddressFromBech32(address string) (sdk.AccAddress, error) { return sdk.AccAddress(addressBz), nil } + +// parseHexValue -> parses a hex string into a big.Int +func ParseHexValue(hexStr string) *big.Int { + hexStr = Remove0xPrefix(hexStr) + + value := new(big.Int) + if _, ok := value.SetString(hexStr, 16); !ok { + log.Fatalf("Failed to parse hex string: %s", hexStr) + } + + return value +} + +// remove0xPrefix -> removes the 0x prefix from a hex string +func Remove0xPrefix(s string) string { + if len(s) > 1 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { + return s[2:] + } + return s +} + +// keccak256 -> calculates the keccak256 hash of a byte slice +func Keccak256(data []byte) []byte { + hash := sha3.NewLegacyKeccak256() + hash.Write(data) + return hash.Sum(nil) +} + +// calculateStorageKey -> calculates the storage key for a given address and index +func CalculateStorageKey(addr string, i int) string { + pos := fmt.Sprintf("%064x", i) + key := strings.ToLower(Remove0xPrefix(addr)) + keyPadded := fmt.Sprintf("%064s", key) + combined := keyPadded + pos + + combinedBytes, err := hex.DecodeString(combined) + if err != nil { + log.Fatalf("Failed to decode hex string: %v", err) + } + + storageKey := Keccak256(combinedBytes) + return "0x" + hex.EncodeToString(storageKey) +} diff --git a/utils/utils_test.go b/utils/utils_test.go new file mode 100644 index 00000000..1875478c --- /dev/null +++ b/utils/utils_test.go @@ -0,0 +1,83 @@ +package utils + +import ( + "encoding/hex" + "math/big" + "testing" +) + +func TestParseHexValue(t *testing.T) { + tests := []struct { + hexStr string + want *big.Int + }{ + {"0x1", big.NewInt(1)}, + {"0x10", big.NewInt(16)}, + {"0xff", big.NewInt(255)}, + {"0x1234567890abcdef", big.NewInt(0x1234567890abcdef)}, + } + + for _, tt := range tests { + got := ParseHexValue(tt.hexStr) + if got.Cmp(tt.want) != 0 { + t.Errorf("ParseHexValue(%s) = %v, want %v", tt.hexStr, got, tt.want) + } + } +} + +func TestRemove0xPrefix(t *testing.T) { + tests := []struct { + input string + want string + }{ + {"0x1", "1"}, + {"0XABC", "ABC"}, + {"123", "123"}, + {"0x123", "123"}, + {"0x1234567890abcdef", "1234567890abcdef"}, + } + + for _, tt := range tests { + got := Remove0xPrefix(tt.input) + if got != tt.want { + t.Errorf("Remove0xPrefix(%s) = %s, want %s", tt.input, got, tt.want) + } + } +} + +func TestKeccak256(t *testing.T) { + tests := []struct { + input []byte + want string + }{ + {[]byte("hello"), "1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"}, + {[]byte("haqq"), "ede9ccb406cc78631779409e4f3d0946ec6bfc530918f2dc8f63c284d209e724"}, + } + + for _, tt := range tests { + got := Keccak256(tt.input) + if hex.EncodeToString(got) != tt.want { + t.Errorf("Keccak256(%s) = %x, want %s", tt.input, got, tt.want) + } + } +} + +func TestCalculateStorageKey(t *testing.T) { + tests := []struct { + addr string + i int + want string + }{ + {"0xA367C471fFEdbB3230793e0aaf045c38e57eDf98", 0, "0xece64beae9f44f327fa25deecc04fcb83b8512d3873bc0f6702645d10aaafaad"}, + {"0xA367C471fFEdbB3230793e0aaf045c38e57eDf98", 1, "0x706a64cd6ab6caa25d744643a971945a13ac5b19961a5295e0771dd24711cc34"}, + {"0xA367C471fFEdbB3230793e0aaf045c38e57eDf98", 2, "0xd20799b9ccb19c9d821e349cec115df5cfd391b8d9c5b5ea10f9cc3d4f1e801e"}, + {"0xA367C471fFEdbB3230793e0aaf045c38e57eDf98", 3, "0xd6b77ced29b77d9d8fdab16e04c4ea5d9056bc8f52f1b081d4e80c158d5e91bd"}, + } + + for _, tt := range tests { + got := CalculateStorageKey(tt.addr, tt.i) + if got != tt.want { + t.Errorf("CalculateStorageKey(%s, %d) = %s, want %s", tt.addr, tt.i, got, tt.want) + } + } +} diff --git a/x/bank/haqq_burn_coins_gov_test.go b/x/bank/haqq_burn_coins_gov_test.go index 397b15ec..f7d73ca3 100644 --- a/x/bank/haqq_burn_coins_gov_test.go +++ b/x/bank/haqq_burn_coins_gov_test.go @@ -17,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + // distcli "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" diff --git a/x/bank/keeper/utils_test.go b/x/bank/keeper/utils_test.go index da0a7eff..ddb31a75 100644 --- a/x/bank/keeper/utils_test.go +++ b/x/bank/keeper/utils_test.go @@ -18,6 +18,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibcgotesting "github.com/cosmos/ibc-go/v7/testing" + // ibcgotestinghelpers "github.com/cosmos/ibc-go/v7/testing/simapp/helpers" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/x/coinomics/keeper/grpc_query_test.go b/x/coinomics/keeper/grpc_query_test.go index c07950de..f529c1e3 100644 --- a/x/coinomics/keeper/grpc_query_test.go +++ b/x/coinomics/keeper/grpc_query_test.go @@ -11,8 +11,8 @@ import ( func (suite *KeeperTestSuite) TestRewardCoefficient() { var ( - req *types.QueryRewardCoefficientRequest - expRes *types.QueryRewardCoefficientResponse + req *types.QueryRewardCoefficientRequest + expResponse *types.QueryRewardCoefficientResponse ) testCases := []struct { @@ -24,7 +24,7 @@ func (suite *KeeperTestSuite) TestRewardCoefficient() { "default reward coefficient", func() { req = &types.QueryRewardCoefficientRequest{} - expRes = &types.QueryRewardCoefficientResponse{RewardCoefficient: sdk.NewDecWithPrec(78, 1)} + expResponse = &types.QueryRewardCoefficientResponse{RewardCoefficient: sdk.NewDecWithPrec(78, 1)} }, true, }, @@ -36,7 +36,7 @@ func (suite *KeeperTestSuite) TestRewardCoefficient() { s.app.CoinomicsKeeper.SetParams(s.ctx, coinomicsParams) req = &types.QueryRewardCoefficientRequest{} - expRes = &types.QueryRewardCoefficientResponse{RewardCoefficient: sdk.NewDecWithPrec(10, 0)} + expResponse = &types.QueryRewardCoefficientResponse{RewardCoefficient: sdk.NewDecWithPrec(10, 0)} }, true, }, @@ -51,7 +51,7 @@ func (suite *KeeperTestSuite) TestRewardCoefficient() { res, err := suite.queryClient.RewardCoefficient(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) } else { suite.Require().Error(err) } @@ -61,8 +61,8 @@ func (suite *KeeperTestSuite) TestRewardCoefficient() { func (suite *KeeperTestSuite) TestMaxSupply() { var ( - req *types.QueryMaxSupplyRequest - expRes *types.QueryMaxSupplyResponse + req *types.QueryMaxSupplyRequest + expResponse *types.QueryMaxSupplyResponse ) testCases := []struct { @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestMaxSupply() { "default max supply", func() { req = &types.QueryMaxSupplyRequest{} - expRes = &types.QueryMaxSupplyResponse{MaxSupply: sdk.Coin{Denom: "aISLM", Amount: math.NewIntWithDecimal(100_000_000_000, 18)}} + expResponse = &types.QueryMaxSupplyResponse{MaxSupply: sdk.Coin{Denom: "aISLM", Amount: math.NewIntWithDecimal(100_000_000_000, 18)}} }, true, }, @@ -85,7 +85,7 @@ func (suite *KeeperTestSuite) TestMaxSupply() { suite.app.CoinomicsKeeper.SetMaxSupply(suite.ctx, maxSupply) req = &types.QueryMaxSupplyRequest{} - expRes = &types.QueryMaxSupplyResponse{MaxSupply: maxSupply} + expResponse = &types.QueryMaxSupplyResponse{MaxSupply: maxSupply} }, true, }, @@ -100,7 +100,7 @@ func (suite *KeeperTestSuite) TestMaxSupply() { res, err := suite.queryClient.MaxSupply(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) } else { suite.Require().Error(err) } diff --git a/x/coinomics/keeper/inflation.go b/x/coinomics/keeper/inflation.go index dd1df91c..64276a60 100644 --- a/x/coinomics/keeper/inflation.go +++ b/x/coinomics/keeper/inflation.go @@ -66,7 +66,7 @@ func (k Keeper) MintAndAllocate(ctx sdk.Context) error { return errors.Wrap(err, "failed mint coins") } - // Allocate remaining coinomics module balance to destribution + // Allocate remaining coinomics module balance to distribution err := k.bankKeeper.SendCoinsFromModuleToModule( ctx, types.ModuleName, diff --git a/x/coinomics/keeper/integration_test.go b/x/coinomics/keeper/integration_test.go index 758994c8..62fcedbc 100644 --- a/x/coinomics/keeper/integration_test.go +++ b/x/coinomics/keeper/integration_test.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/haqq-network/haqq/crypto/ethsecp256k1" "github.com/haqq-network/haqq/testutil" ) diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go index 01c44cb8..5b963c72 100644 --- a/x/epochs/keeper/grpc_query_test.go +++ b/x/epochs/keeper/grpc_query_test.go @@ -12,8 +12,8 @@ import ( func (suite *KeeperTestSuite) TestEpochInfo() { var ( - req *types.QueryEpochsInfoRequest - expRes *types.QueryEpochsInfoResponse + req *types.QueryEpochsInfoRequest + expResponse *types.QueryEpochsInfoResponse ) testCases := []struct { @@ -50,7 +50,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() { week.StartTime = suite.ctx.BlockTime() week.CurrentEpochStartHeight = suite.ctx.BlockHeight() - expRes = &types.QueryEpochsInfoResponse{ + expResponse = &types.QueryEpochsInfoResponse{ Epochs: []types.EpochInfo{day, week}, Pagination: &query.PageResponse{ NextKey: nil, @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() { suite.Commit() req = &types.QueryEpochsInfoRequest{} - expRes = &types.QueryEpochsInfoResponse{ + expResponse = &types.QueryEpochsInfoResponse{ Epochs: []types.EpochInfo{day, quarter, week}, Pagination: &query.PageResponse{ NextKey: nil, @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() { res, err := suite.queryClient.EpochInfos(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) } else { suite.Require().Error(err) } @@ -133,8 +133,8 @@ func (suite *KeeperTestSuite) TestEpochInfo() { func (suite *KeeperTestSuite) TestCurrentEpoch() { var ( - req *types.QueryCurrentEpochRequest - expRes *types.QueryCurrentEpochResponse + req *types.QueryCurrentEpochRequest + expResponse *types.QueryCurrentEpochResponse ) testCases := []struct { @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() { func() { defaultCurrentEpoch := int64(0) req = &types.QueryCurrentEpochRequest{Identifier: "second"} - expRes = &types.QueryCurrentEpochResponse{ + expResponse = &types.QueryCurrentEpochResponse{ CurrentEpoch: defaultCurrentEpoch, } }, @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() { func() { defaultCurrentEpoch := int64(0) req = &types.QueryCurrentEpochRequest{Identifier: types.WeekEpochID} - expRes = &types.QueryCurrentEpochResponse{ + expResponse = &types.QueryCurrentEpochResponse{ CurrentEpoch: defaultCurrentEpoch, } }, @@ -169,7 +169,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() { func() { defaultCurrentEpoch := int64(0) req = &types.QueryCurrentEpochRequest{Identifier: types.DayEpochID} - expRes = &types.QueryCurrentEpochResponse{ + expResponse = &types.QueryCurrentEpochResponse{ CurrentEpoch: defaultCurrentEpoch, } }, @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() { res, err := suite.queryClient.CurrentEpoch(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) } else { suite.Require().Error(err) } diff --git a/x/erc20/keeper/grpc_query_test.go b/x/erc20/keeper/grpc_query_test.go index 6ec43afe..8402e235 100644 --- a/x/erc20/keeper/grpc_query_test.go +++ b/x/erc20/keeper/grpc_query_test.go @@ -12,8 +12,8 @@ import ( func (suite *KeeperTestSuite) TestTokenPairs() { var ( - req *types.QueryTokenPairsRequest - expRes *types.QueryTokenPairsResponse + req *types.QueryTokenPairsRequest + expResponse *types.QueryTokenPairsResponse ) testCases := []struct { @@ -25,7 +25,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() { "no pairs registered", func() { req = &types.QueryTokenPairsRequest{} - expRes = &types.QueryTokenPairsResponse{Pagination: &query.PageResponse{}} + expResponse = &types.QueryTokenPairsResponse{Pagination: &query.PageResponse{}} }, true, }, @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() { pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE) suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair) - expRes = &types.QueryTokenPairsResponse{ + expResponse = &types.QueryTokenPairsResponse{ Pagination: &query.PageResponse{Total: 1}, TokenPairs: []types.TokenPair{pair}, } @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() { suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair) suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair2) - expRes = &types.QueryTokenPairsResponse{ + expResponse = &types.QueryTokenPairsResponse{ Pagination: &query.PageResponse{Total: 2}, TokenPairs: []types.TokenPair{pair, pair2}, } @@ -72,8 +72,8 @@ func (suite *KeeperTestSuite) TestTokenPairs() { res, err := suite.queryClient.TokenPairs(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes.Pagination, res.Pagination) - suite.Require().ElementsMatch(expRes.TokenPairs, res.TokenPairs) + suite.Require().Equal(expResponse.Pagination, res.Pagination) + suite.Require().ElementsMatch(expResponse.TokenPairs, res.TokenPairs) } else { suite.Require().Error(err) } @@ -83,8 +83,8 @@ func (suite *KeeperTestSuite) TestTokenPairs() { func (suite *KeeperTestSuite) TestTokenPair() { var ( - req *types.QueryTokenPairRequest - expRes *types.QueryTokenPairResponse + req *types.QueryTokenPairRequest + express *types.QueryTokenPairResponse ) testCases := []struct { @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestTokenPair() { "invalid token address", func() { req = &types.QueryTokenPairRequest{} - expRes = &types.QueryTokenPairResponse{} + express = &types.QueryTokenPairResponse{} }, false, }, @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) TestTokenPair() { req = &types.QueryTokenPairRequest{ Token: utiltx.GenerateAddress().Hex(), } - expRes = &types.QueryTokenPairResponse{} + express = &types.QueryTokenPairResponse{} }, false, }, @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestTokenPair() { req = &types.QueryTokenPairRequest{ Token: pair.Erc20Address, } - expRes = &types.QueryTokenPairResponse{TokenPair: pair} + express = &types.QueryTokenPairResponse{TokenPair: pair} }, true, }, @@ -137,7 +137,7 @@ func (suite *KeeperTestSuite) TestTokenPair() { req = &types.QueryTokenPairRequest{ Token: pair.Erc20Address, } - expRes = &types.QueryTokenPairResponse{TokenPair: pair} + express = &types.QueryTokenPairResponse{TokenPair: pair} }, false, }, @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestTokenPair() { res, err := suite.queryClient.TokenPair(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(express, res) } else { suite.Require().Error(err) } diff --git a/x/erc20/keeper/ibc_callbacks.go b/x/erc20/keeper/ibc_callbacks.go index 45a7d4e1..ce47bdcd 100644 --- a/x/erc20/keeper/ibc_callbacks.go +++ b/x/erc20/keeper/ibc_callbacks.go @@ -58,7 +58,7 @@ func (k Keeper) OnRecvPacket( senderAcc := k.accountKeeper.GetAccount(ctx, sender) - // return acknoledgement without conversion if sender is a module account + // return acknowledgement without conversion if sender is a module account if types.IsModuleAccount(senderAcc) { return ack } diff --git a/x/erc20/keeper/ibc_callbacks_integration_test.go b/x/erc20/keeper/ibc_callbacks_integration_test.go index 3c316f26..6983b756 100644 --- a/x/erc20/keeper/ibc_callbacks_integration_test.go +++ b/x/erc20/keeper/ibc_callbacks_integration_test.go @@ -471,7 +471,7 @@ var _ = Describe("Convert outgoing ERC20 to IBC", Ordered, func() { err = path.RelayPacket(packet) s.Require().Error(err) - // Check Balance didnt change + // Check Balance didn't change balanceToken = s.app.Erc20Keeper.BalanceOf(s.HaqqChain.GetContext(), contracts.ERC20MinterBurnerDecimalsContract.ABI, pair.GetERC20Contract(), common.BytesToAddress(senderAcc.Bytes())) s.Require().Equal(amount, balanceToken.Int64()) }) @@ -604,7 +604,7 @@ var _ = Describe("Convert outgoing ERC20 to IBC", Ordered, func() { originChain.NextBlock() originChain.Coordinator.IncrementTime() - // Check Balance didnt change + // Check Balance didn't change ibcOsmosBalance := s.IBCOsmosisChain.GetSimApp().BankKeeper.GetBalance(s.IBCOsmosisChain.GetContext(), receiverAcc, erc20Denomtrace.IBCDenom()) s.Require().Equal(int64(0), ibcOsmosBalance.Amount.Int64()) balanceToken = s.app.Erc20Keeper.BalanceOf(s.HaqqChain.GetContext(), contracts.ERC20MinterBurnerDecimalsContract.ABI, pair.GetERC20Contract(), common.BytesToAddress(senderAcc.Bytes())) diff --git a/x/erc20/keeper/integration_test.go b/x/erc20/keeper/integration_test.go index ec4535bb..e5b71f80 100644 --- a/x/erc20/keeper/integration_test.go +++ b/x/erc20/keeper/integration_test.go @@ -332,7 +332,7 @@ var _ = Describe("ERC20:", Ordered, func() { Expect(balanceERC20.Int64()).To(Equal(amt.Int64())) }) - It("should send coins to the recevier account", func() { + It("should send coins to the receiver account", func() { balanceCoin := s.app.BankKeeper.GetBalance(s.ctx, accAddr, pair.Denom) Expect(balanceCoin).To(Equal(coin)) }) @@ -356,7 +356,7 @@ var _ = Describe("ERC20:", Ordered, func() { Expect(balanceERC20.Int64()).To(Equal(int64(0))) }) - It("should burn coins to the recevier account", func() { + It("should burn coins to the receiver account", func() { balanceCoin := s.app.BankKeeper.GetBalance(s.ctx, accAddr, pair.Denom) Expect(balanceCoin.IsZero()).To(BeTrue()) }) diff --git a/x/erc20/keeper/msg_server_test.go b/x/erc20/keeper/msg_server_test.go index 586fd754..892e4119 100644 --- a/x/erc20/keeper/msg_server_test.go +++ b/x/erc20/keeper/msg_server_test.go @@ -171,7 +171,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeCoin() { tc.extra() res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg) - expRes := &types.MsgConvertCoinResponse{} + expResponse := &types.MsgConvertCoinResponse{} suite.Commit() balance := suite.BalanceOf(common.HexToAddress(pair.Erc20Address), suite.address) cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, metadataCoin.Base) @@ -191,7 +191,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeCoin() { _, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id) suite.Require().False(found) } else { - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(cosmosBalance.Amount.Int64(), sdk.NewInt(tc.mint-tc.burn).Int64()) suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn).Int64()) } @@ -364,13 +364,13 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeCoin() { tc.malleate() res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msgConvertERC20) - expRes := &types.MsgConvertERC20Response{} + expResponse := &types.MsgConvertERC20Response{} suite.Commit() balance = suite.BalanceOf(contractAddr, suite.address) cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, pair.Denom) if tc.expPass { suite.Require().NoError(err, tc.name) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(cosmosBalance.Amount.Int64(), sdk.NewInt(tc.mint-tc.burn+tc.reconvert).Int64()) suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn-tc.reconvert).Int64()) } else { @@ -695,7 +695,7 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeERC20() { tc.extra() res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msg) - expRes := &types.MsgConvertERC20Response{} + expResponse := &types.MsgConvertERC20Response{} suite.Commit() balance := suite.BalanceOf(contractAddr, suite.address) cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, coinName) @@ -714,7 +714,7 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeERC20() { _, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id) suite.Require().False(found) } else { - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(cosmosBalance.Amount, sdk.NewInt(tc.transfer)) suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.mint-tc.transfer).Int64()) } @@ -926,13 +926,13 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeERC20() { tc.extra() res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg) - expRes := &types.MsgConvertCoinResponse{} + expResponse := &types.MsgConvertCoinResponse{} suite.Commit() tokenBalance = suite.BalanceOf(contractAddr, suite.address) cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, coinName) if tc.expPass { suite.Require().NoError(err, tc.name) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(sdk.NewInt(tc.mint-tc.convert), cosmosBalance.Amount) suite.Require().Equal(big.NewInt(tc.convert), tokenBalance.(*big.Int)) } else { @@ -1149,7 +1149,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeIBCVoucher() { tc.extra() res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg) - expRes := &types.MsgConvertCoinResponse{} + expResponse := &types.MsgConvertCoinResponse{} suite.Commit() balance := suite.BalanceOf(common.HexToAddress(pair.Erc20Address), suite.address) cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, metadataIbc.Base) @@ -1169,7 +1169,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeIBCVoucher() { _, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id) suite.Require().False(found) } else { - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(cosmosBalance.Amount.Int64(), sdk.NewInt(tc.mint-tc.burn).Int64()) suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn).Int64()) } @@ -1343,13 +1343,13 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeIBCVoucher() { tc.malleate() res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msgConvertERC20) - expRes := &types.MsgConvertERC20Response{} + expResponse := &types.MsgConvertERC20Response{} suite.Commit() balance = suite.BalanceOf(contractAddr, suite.address) cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, pair.Denom) if tc.expPass { suite.Require().NoError(err, tc.name) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(cosmosBalance.Amount.Int64(), sdk.NewInt(tc.mint-tc.burn+tc.reconvert).Int64()) suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn-tc.reconvert).Int64()) } else { diff --git a/x/erc20/keeper/token_pairs_test.go b/x/erc20/keeper/token_pairs_test.go index 5c62885a..00b4587c 100644 --- a/x/erc20/keeper/token_pairs_test.go +++ b/x/erc20/keeper/token_pairs_test.go @@ -11,14 +11,14 @@ import ( ) func (suite *KeeperTestSuite) TestGetTokenPairs() { - var expRes []types.TokenPair + var expResponse []types.TokenPair testCases := []struct { name string malleate func() }{ { - "no pair registered", func() { expRes = []types.TokenPair{} }, + "no pair registered", func() { expResponse = []types.TokenPair{} }, }, { "1 pair registered", @@ -26,7 +26,7 @@ func (suite *KeeperTestSuite) TestGetTokenPairs() { pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE) suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair) - expRes = []types.TokenPair{pair} + expResponse = []types.TokenPair{pair} }, }, { @@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) TestGetTokenPairs() { suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair) suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair2) - expRes = []types.TokenPair{pair, pair2} + expResponse = []types.TokenPair{pair, pair2} }, }, } @@ -48,7 +48,7 @@ func (suite *KeeperTestSuite) TestGetTokenPairs() { tc.malleate() res := suite.app.Erc20Keeper.GetTokenPairs(suite.ctx) - suite.Require().ElementsMatch(expRes, res, tc.name) + suite.Require().ElementsMatch(expResponse, res, tc.name) }) } } diff --git a/x/erc20/keeper/utils_test.go b/x/erc20/keeper/utils_test.go index 3466d6e6..e61cc277 100644 --- a/x/erc20/keeper/utils_test.go +++ b/x/erc20/keeper/utils_test.go @@ -19,6 +19,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibcgotesting "github.com/cosmos/ibc-go/v7/testing" + // ibcgotestinghelpers "github.com/cosmos/ibc-go/v7/testing/simapp/helpers" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/x/erc20/migrations/v3/migration_test.go b/x/erc20/migrations/v3/migration_test.go index 1cc3b6b5..058fb4e9 100644 --- a/x/erc20/migrations/v3/migration_test.go +++ b/x/erc20/migrations/v3/migration_test.go @@ -12,7 +12,7 @@ import ( "github.com/haqq-network/haqq/app" "github.com/haqq-network/haqq/encoding" - "github.com/haqq-network/haqq/x/erc20/migrations/v3" + v3 "github.com/haqq-network/haqq/x/erc20/migrations/v3" v3types "github.com/haqq-network/haqq/x/erc20/migrations/v3/types" "github.com/haqq-network/haqq/x/erc20/types" ) diff --git a/x/erc20/types/genesis_test.go b/x/erc20/types/genesis_test.go index 50c50aa6..ad009a22 100644 --- a/x/erc20/types/genesis_test.go +++ b/x/erc20/types/genesis_test.go @@ -131,7 +131,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { expPass: false, }, { - // Voting period cant be zero + // Voting period can't be zero name: "empty genesis", genState: &types.GenesisState{}, expPass: true, diff --git a/x/erc20/types/proposal_test.go b/x/erc20/types/proposal_test.go index 832cd02e..86173dab 100644 --- a/x/erc20/types/proposal_test.go +++ b/x/erc20/types/proposal_test.go @@ -129,7 +129,7 @@ func (suite *ProposalTestSuite) TestRegisterERC20Proposal() { }{ // Valid tests {msg: "Register token pair - valid pair enabled", title: "test", description: "test desc", pair: types.TokenPair{utiltx.GenerateAddress().String(), "test", true, types.OWNER_MODULE}, expectPass: true}, - {msg: "Register token pair - valid pair dissabled", title: "test", description: "test desc", pair: types.TokenPair{utiltx.GenerateAddress().String(), "test", false, types.OWNER_MODULE}, expectPass: true}, + {msg: "Register token pair - valid pair disabled", title: "test", description: "test desc", pair: types.TokenPair{utiltx.GenerateAddress().String(), "test", false, types.OWNER_MODULE}, expectPass: true}, // Missing params valid {msg: "Register token pair - invalid missing title ", title: "", description: "test desc", pair: types.TokenPair{utiltx.GenerateAddress().String(), "test", false, types.OWNER_MODULE}, expectPass: false}, {msg: "Register token pair - invalid missing description ", title: "test", description: "", pair: types.TokenPair{utiltx.GenerateAddress().String(), "test", false, types.OWNER_MODULE}, expectPass: false}, @@ -210,7 +210,7 @@ func (suite *ProposalTestSuite) TestRegisterCoinProposal() { }{ // Valid tests {msg: "Register token pair - valid pair enabled", title: "test", description: "test desc", metadata: validMetadata, expectPass: true}, - {msg: "Register token pair - valid pair dissabled", title: "test", description: "test desc", metadata: validMetadata, expectPass: true}, + {msg: "Register token pair - valid pair disabled", title: "test", description: "test desc", metadata: validMetadata, expectPass: true}, // Invalid Regex (denom) {msg: "Register token pair - invalid starts with number", title: "test", description: "test desc", metadata: createMetadata("1test", "test"), expectPass: false}, diff --git a/x/erc20/types/utils_test.go b/x/erc20/types/utils_test.go index 72c8b985..6cb0b195 100644 --- a/x/erc20/types/utils_test.go +++ b/x/erc20/types/utils_test.go @@ -27,7 +27,7 @@ func TestSanitizeERC20Name(t *testing.T) { {"name contains '/'", "USD/Coin", "USD/Coin", true}, {"name contains '/'", "/SlashCoin", "SlashCoin", true}, {"name contains '/'", "O/letter", "O/letter", true}, - {"name contains '/'", "Ot/2letters", "Ot/2letters", true}, + {"name contains '/'", "Or/2letters", "Or/2letters", true}, {"name contains '/'", "ibc/valid", "valid", true}, {"name contains '/'", "erc20/valid", "valid", true}, {"name contains '/'", "ibc/erc20/valid", "valid", true}, diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index d8f9c8b1..33a532f0 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -1191,8 +1191,8 @@ func (suite *KeeperTestSuite) TestNonceInQuery() { func (suite *KeeperTestSuite) TestQueryBaseFee() { var ( - aux sdkmath.Int - expRes *types.QueryBaseFeeResponse + aux sdkmath.Int + expResponse *types.QueryBaseFeeResponse ) testCases := []struct { @@ -1206,7 +1206,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { "pass - default Base Fee", func() { initialBaseFee := sdkmath.NewInt(ethparams.InitialBaseFee) - expRes = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee} + expResponse = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee} }, true, true, true, }, @@ -1217,7 +1217,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) aux = sdkmath.NewIntFromBigInt(baseFee) - expRes = &types.QueryBaseFeeResponse{BaseFee: &aux} + expResponse = &types.QueryBaseFeeResponse{BaseFee: &aux} }, true, true, true, }, @@ -1227,7 +1227,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { baseFee := sdk.OneInt().BigInt() suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) - expRes = &types.QueryBaseFeeResponse{} + expResponse = &types.QueryBaseFeeResponse{} }, true, true, false, }, @@ -1235,7 +1235,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { "pass - zero Base Fee when feemarket not activated", func() { baseFee := sdk.ZeroInt() - expRes = &types.QueryBaseFeeResponse{BaseFee: &baseFee} + expResponse = &types.QueryBaseFeeResponse{BaseFee: &baseFee} }, true, false, true, }, @@ -1251,7 +1251,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { res, err := suite.queryClient.BaseFee(suite.ctx.Context(), &types.QueryBaseFeeRequest{}) if tc.expPass { suite.Require().NotNil(res) - suite.Require().Equal(expRes, res, tc.name) + suite.Require().Equal(expResponse, res, tc.name) suite.Require().NoError(err) } else { suite.Require().Error(err) diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 94c76039..23f89a4d 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -97,9 +97,9 @@ func (suite *KeeperTestSuite) TestBaseFee() { func (suite *KeeperTestSuite) TestGetAccountStorage() { testCases := []struct { - name string - malleate func() - expRes []int + name string + malleate func() + expResponse []int }{ { "Only one account that's not a contract (no storage)", @@ -131,7 +131,7 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { addr := ethAccount.EthAddress() storage := suite.app.EvmKeeper.GetAccountStorage(suite.ctx, addr) - suite.Require().Equal(tc.expRes[i], len(storage)) + suite.Require().Equal(tc.expResponse[i], len(storage)) i++ return false }) diff --git a/x/evm/keeper/state_transition_benchmark_test.go b/x/evm/keeper/state_transition_benchmark_test.go index 9ea19179..a2a4b02e 100644 --- a/x/evm/keeper/state_transition_benchmark_test.go +++ b/x/evm/keeper/state_transition_benchmark_test.go @@ -119,7 +119,7 @@ func newEthMsgTx( ethTx = ethtypes.NewTx(templateDynamicFeeTx) baseFee = big.NewInt(3) default: - return nil, baseFee, errors.New("unsupport tx type") + return nil, baseFee, errors.New("unsupported tx type") } msg := &evmtypes.MsgEthereumTx{} diff --git a/x/evm/keeper/state_transition_test.go b/x/evm/keeper/state_transition_test.go index 47be11b7..baf78cdc 100644 --- a/x/evm/keeper/state_transition_test.go +++ b/x/evm/keeper/state_transition_test.go @@ -587,7 +587,7 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() { expErr bool }{ { - "messsage applied ok", + "message applied ok", func() { msg, err = newNativeMessage( vmdb.GetNonce(suite.address), diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index ed73c674..97a9171a 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -47,7 +47,7 @@ func (s Storage) SortedKeys() []common.Hash { return keys } -// stateObject is the state of an acount +// stateObject is the state of an account type stateObject struct { db *StateDB diff --git a/x/evm/types/errors.go b/x/evm/types/errors.go index 7fdd97a4..936f1e24 100644 --- a/x/evm/types/errors.go +++ b/x/evm/types/errors.go @@ -67,7 +67,7 @@ var ( // ErrInvalidBaseFee returns an error if a the base fee cap value is invalid ErrInvalidBaseFee = errorsmod.Register(ModuleName, codeErrInvalidBaseFee, "invalid base fee") - // ErrGasOverflow returns an error if gas computation overlow/underflow + // ErrGasOverflow returns an error if gas computation overflow/underflow ErrGasOverflow = errorsmod.Register(ModuleName, codeErrGasOverflow, "gas computation overflow/underflow") // ErrInvalidAccount returns an error if the account is not an EVM compatible account diff --git a/x/evm/types/tx_args.go b/x/evm/types/tx_args.go index f582dc9d..b11b7e88 100644 --- a/x/evm/types/tx_args.go +++ b/x/evm/types/tx_args.go @@ -192,7 +192,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (e gasPrice = args.GasPrice.ToInt() gasFeeCap, gasTipCap = gasPrice, gasPrice } else { - // User specified 1559 gas feilds (or none), use those + // User specified 1559 gas fields (or none), use those gasFeeCap = new(big.Int) if args.MaxFeePerGas != nil { gasFeeCap = args.MaxFeePerGas.ToInt() diff --git a/x/evm/types/utils.go b/x/evm/types/utils.go index de99557a..dbabff46 100644 --- a/x/evm/types/utils.go +++ b/x/evm/types/utils.go @@ -13,7 +13,7 @@ import ( ) // DefaultPriorityReduction is the default amount of price values required for 1 unit of priority. -// Because priority is `int64` while price is `big.Int`, it's necessary to scale down the range to keep it more pratical. +// Because priority is `int64` while price is `big.Int`, it's necessary to scale down the range to keep it more practical. // The default value is the same as the `sdk.DefaultPowerReduction`. var DefaultPriorityReduction = sdk.DefaultPowerReduction diff --git a/x/feemarket/keeper/grpc_query_test.go b/x/feemarket/keeper/grpc_query_test.go index 454a4bc3..37f18d88 100644 --- a/x/feemarket/keeper/grpc_query_test.go +++ b/x/feemarket/keeper/grpc_query_test.go @@ -34,8 +34,8 @@ func (suite *KeeperTestSuite) TestQueryParams() { func (suite *KeeperTestSuite) TestQueryBaseFee() { var ( - aux sdkmath.Int - expRes *types.QueryBaseFeeResponse + aux sdkmath.Int + expResponse *types.QueryBaseFeeResponse ) testCases := []struct { @@ -47,7 +47,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { "pass - default Base Fee", func() { initialBaseFee := sdkmath.NewInt(ethparams.InitialBaseFee) - expRes = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee} + expResponse = &types.QueryBaseFeeResponse{BaseFee: &initialBaseFee} }, true, }, @@ -58,7 +58,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, baseFee) aux = sdkmath.NewIntFromBigInt(baseFee) - expRes = &types.QueryBaseFeeResponse{BaseFee: &aux} + expResponse = &types.QueryBaseFeeResponse{BaseFee: &aux} }, true, }, @@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() { res, err := suite.queryClient.BaseFee(suite.ctx.Context(), &types.QueryBaseFeeRequest{}) if tc.expPass { suite.Require().NotNil(res) - suite.Require().Equal(expRes, res, tc.name) + suite.Require().Equal(expResponse, res, tc.name) suite.Require().NoError(err) } else { suite.Require().Error(err) diff --git a/x/gov/proposal_send_test.go b/x/gov/proposal_send_test.go index 27530d4b..0f2abae7 100644 --- a/x/gov/proposal_send_test.go +++ b/x/gov/proposal_send_test.go @@ -11,6 +11,7 @@ import ( simappparams "cosmossdk.io/simapp/params" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" + // "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" diff --git a/x/liquidvesting/client/cli/query.go b/x/liquidvesting/client/cli/query.go index 9fab4577..fdc96b0d 100644 --- a/x/liquidvesting/client/cli/query.go +++ b/x/liquidvesting/client/cli/query.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/haqq-network/haqq/x/liquidvesting/types" "github.com/spf13/cobra" + + "github.com/haqq-network/haqq/x/liquidvesting/types" ) // GetQueryCmd returns the parent command for all liquidvesting CLI query commands. diff --git a/x/liquidvesting/client/cli/tx.go b/x/liquidvesting/client/cli/tx.go index aa720b0b..e9bbc62c 100644 --- a/x/liquidvesting/client/cli/tx.go +++ b/x/liquidvesting/client/cli/tx.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/haqq-network/haqq/x/liquidvesting/types" "github.com/spf13/cobra" + + "github.com/haqq-network/haqq/x/liquidvesting/types" ) // NewTxCmd returns a root CLI command handler for certain modules/liquidvesting diff --git a/x/liquidvesting/genesis.go b/x/liquidvesting/genesis.go index 799ae1c9..604a0e3b 100644 --- a/x/liquidvesting/genesis.go +++ b/x/liquidvesting/genesis.go @@ -1,7 +1,10 @@ package liquidvesting import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/haqq-network/haqq/x/liquidvesting/keeper" "github.com/haqq-network/haqq/x/liquidvesting/types" ) @@ -9,8 +12,10 @@ import ( // InitGenesis import module genesis func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { // Set genesis state - params := data.Params - k.SetParams(ctx, params) + err := k.SetParams(ctx, data.Params) + if err != nil { + panic(fmt.Errorf("error setting params %s", err)) + } k.SetDenomCounter(ctx, data.DenomCounter) diff --git a/x/liquidvesting/genesis_test.go b/x/liquidvesting/genesis_test.go index 82cf21bc..e01fba90 100644 --- a/x/liquidvesting/genesis_test.go +++ b/x/liquidvesting/genesis_test.go @@ -11,13 +11,14 @@ import ( "github.com/cometbft/cometbft/version" sdk "github.com/cosmos/cosmos-sdk/types" sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/stretchr/testify/suite" + "github.com/haqq-network/haqq/app" utiltx "github.com/haqq-network/haqq/testutil/tx" "github.com/haqq-network/haqq/utils" feemarkettypes "github.com/haqq-network/haqq/x/feemarket/types" "github.com/haqq-network/haqq/x/liquidvesting" "github.com/haqq-network/haqq/x/liquidvesting/types" - "github.com/stretchr/testify/suite" ) type GenesisTestSuite struct { diff --git a/x/liquidvesting/handler.go b/x/liquidvesting/handler.go index b57ee10d..cd660c7f 100644 --- a/x/liquidvesting/handler.go +++ b/x/liquidvesting/handler.go @@ -4,6 +4,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/haqq-network/haqq/x/liquidvesting/types" ) diff --git a/x/liquidvesting/keeper/denom.go b/x/liquidvesting/keeper/denom.go index c932d399..26a7b916 100644 --- a/x/liquidvesting/keeper/denom.go +++ b/x/liquidvesting/keeper/denom.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/haqq-network/haqq/x/liquidvesting/types" ) diff --git a/x/liquidvesting/keeper/grpc_query.go b/x/liquidvesting/keeper/grpc_query.go index 0b842dfb..86883a63 100644 --- a/x/liquidvesting/keeper/grpc_query.go +++ b/x/liquidvesting/keeper/grpc_query.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/haqq-network/haqq/x/liquidvesting/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/haqq-network/haqq/x/liquidvesting/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/liquidvesting/keeper/keeper.go b/x/liquidvesting/keeper/keeper.go index 381f5d50..21f09a69 100644 --- a/x/liquidvesting/keeper/keeper.go +++ b/x/liquidvesting/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/haqq-network/haqq/x/liquidvesting/types" ) diff --git a/x/liquidvesting/keeper/msg_server.go b/x/liquidvesting/keeper/msg_server.go index 8e6184f3..5d0c3241 100644 --- a/x/liquidvesting/keeper/msg_server.go +++ b/x/liquidvesting/keeper/msg_server.go @@ -10,6 +10,7 @@ import ( sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/ethereum/go-ethereum/common" + "github.com/haqq-network/haqq/contracts" erc20types "github.com/haqq-network/haqq/x/erc20/types" "github.com/haqq-network/haqq/x/liquidvesting/types" @@ -22,6 +23,10 @@ var _ types.MsgServer = Keeper{} func (k Keeper) Liquidate(goCtx context.Context, msg *types.MsgLiquidate) (*types.MsgLiquidateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + if !k.IsLiquidVestingEnabled(ctx) { + return nil, errorsmod.Wrapf(types.ErrModuleIsDisabled, "liquid vesting module is disabled") + } + // check amount denom if msg.Amount.Denom != "aISLM" { return nil, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "unable to liquidate any other coin except aISLM") @@ -154,6 +159,10 @@ func (k Keeper) Redeem(goCtx context.Context, msg *types.MsgRedeem) (*types.MsgR // get accounts ctx := sdk.UnwrapSDKContext(goCtx) + if !k.IsLiquidVestingEnabled(ctx) { + return nil, errorsmod.Wrapf(types.ErrModuleIsDisabled, "liquid vesting module is disabled") + } + fromAddress := sdk.MustAccAddressFromBech32(msg.RedeemFrom) fromAccount := k.accountKeeper.GetAccount(ctx, fromAddress) if fromAccount == nil { diff --git a/x/liquidvesting/keeper/msg_server_test.go b/x/liquidvesting/keeper/msg_server_test.go index 5d68ef3d..21cb2d9e 100644 --- a/x/liquidvesting/keeper/msg_server_test.go +++ b/x/liquidvesting/keeper/msg_server_test.go @@ -11,6 +11,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/haqq-network/haqq/contracts" "github.com/haqq-network/haqq/tests" "github.com/haqq-network/haqq/testutil" @@ -210,12 +211,12 @@ func (suite *KeeperTestSuite) TestLiquidate() { msg := types.NewMsgLiquidate(tc.from, tc.to, tc.amount) resp, err := suite.app.LiquidVestingKeeper.Liquidate(ctx, msg) - expRes := &types.MsgLiquidateResponse{} + expResponse := &types.MsgLiquidateResponse{} if tc.expectPass { // check returns suite.Require().NoError(err) - suite.Require().Equal(expRes, resp) + suite.Require().Equal(expResponse, resp) // check target account exists and has liquid token accIto := suite.app.AccountKeeper.GetAccount(suite.ctx, tc.to) @@ -274,11 +275,11 @@ func (suite *KeeperTestSuite) TestMultipleLiquidationsFromOneAccount() { // FIRST LIQUIDATION msg := types.NewMsgLiquidate(from, to, liquidationAmount) resp, err := suite.app.LiquidVestingKeeper.Liquidate(ctx, msg) - expRes := &types.MsgLiquidateResponse{} + expResponse := &types.MsgLiquidateResponse{} // check returns suite.Require().NoError(err) - suite.Require().Equal(expRes, resp) + suite.Require().Equal(expResponse, resp) // check target account exists and has liquid token accIto := suite.app.AccountKeeper.GetAccount(suite.ctx, to) @@ -313,7 +314,7 @@ func (suite *KeeperTestSuite) TestMultipleLiquidationsFromOneAccount() { // check returns suite.Require().NoError(err) - suite.Require().Equal(expRes, resp) + suite.Require().Equal(expResponse, resp) // check target account exists and has liquid token balanceTarget = suite.app.BankKeeper.GetBalance(suite.ctx, to, types.DenomBaseNameFromID(1)) @@ -559,11 +560,11 @@ func (suite *KeeperTestSuite) TestRedeem() { redeemCoin := sdk.NewInt64Coin("aLIQUID0", tc.redeemAmount) msg := types.NewMsgRedeem(tc.redeemFrom, tc.redeemTo, redeemCoin) resp, err := suite.app.LiquidVestingKeeper.Redeem(ctx, msg) - expRes := &types.MsgRedeemResponse{} + expResponse := &types.MsgRedeemResponse{} if tc.expectPass { // check returns suite.Require().NoError(err) - suite.Require().Equal(expRes, resp) + suite.Require().Equal(expResponse, resp) // check target account has original tokens accIto := suite.app.AccountKeeper.GetAccount(suite.ctx, tc.redeemTo) diff --git a/x/liquidvesting/keeper/params.go b/x/liquidvesting/keeper/params.go index 2cdaf330..98263c92 100644 --- a/x/liquidvesting/keeper/params.go +++ b/x/liquidvesting/keeper/params.go @@ -2,9 +2,12 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/haqq-network/haqq/x/liquidvesting/types" ) +var isTrue = []byte("0x01") + // GetParams returns the total set of liquidvesting parameters. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramstore.GetParamSet(ctx, ¶ms) @@ -12,6 +15,28 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { } // SetParams sets the liquidvesting parameters to the param space. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + if err := params.Validate(); err != nil { + return err + } + + k.SetLiquidVestingEnabled(ctx, params.EnableLiquidVesting) + k.paramstore.SetParamSet(ctx, ¶ms) + + return nil +} + +func (k Keeper) IsLiquidVestingEnabled(ctx sdk.Context) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.ParamStoreKeyEnableLiquidVesting) +} + +func (k Keeper) SetLiquidVestingEnabled(ctx sdk.Context, enable bool) { + store := ctx.KVStore(k.storeKey) + if enable { + store.Set(types.ParamStoreKeyEnableLiquidVesting, isTrue) + return + } + store.Delete(types.ParamStoreKeyEnableLiquidVesting) } diff --git a/x/liquidvesting/keeper/params_test.go b/x/liquidvesting/keeper/params_test.go index ee73883b..ba7a9786 100644 --- a/x/liquidvesting/keeper/params_test.go +++ b/x/liquidvesting/keeper/params_test.go @@ -1,17 +1,24 @@ package keeper_test import ( + "fmt" + "cosmossdk.io/math" + "github.com/haqq-network/haqq/x/liquidvesting/types" ) func (suite *KeeperTestSuite) TestParams() { params := suite.app.LiquidVestingKeeper.GetParams(suite.ctx) - expParams := types.NewParams(math.NewInt(1_000_000)) + expParams := types.NewParams(math.NewInt(1_000_000), true) suite.Require().Equal(expParams, params) - suite.app.LiquidVestingKeeper.SetParams(suite.ctx, params) + err := suite.app.LiquidVestingKeeper.SetParams(suite.ctx, params) + if err != nil { + panic(fmt.Errorf("error setting params %s", err)) + } + newParams := suite.app.LiquidVestingKeeper.GetParams(suite.ctx) suite.Require().Equal(newParams, params) } diff --git a/x/liquidvesting/keeper/setup_test.go b/x/liquidvesting/keeper/setup_test.go index a7458ed5..588b79ca 100644 --- a/x/liquidvesting/keeper/setup_test.go +++ b/x/liquidvesting/keeper/setup_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "math" "testing" "time" @@ -17,6 +18,9 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "github.com/haqq-network/haqq/app" "github.com/haqq-network/haqq/crypto/ethsecp256k1" "github.com/haqq-network/haqq/encoding" @@ -26,8 +30,6 @@ import ( "github.com/haqq-network/haqq/utils" epochstypes "github.com/haqq-network/haqq/x/epochs/types" "github.com/haqq-network/haqq/x/liquidvesting/types" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" ) type KeeperTestSuite struct { @@ -111,7 +113,10 @@ func (suite *KeeperTestSuite) DoSetupTest(t *testing.T) { suite.Require().NoError(err) // Set minimum liquidation amount to 10^6 - suite.app.LiquidVestingKeeper.SetParams(suite.ctx, types.NewParams(sdkmath.NewInt(1_000_000))) + err = suite.app.LiquidVestingKeeper.SetParams(suite.ctx, types.NewParams(sdkmath.NewInt(1_000_000), true)) + if err != nil { + panic(fmt.Errorf("error setting params %s", err)) + } // Set Validator valAddr := sdk.ValAddress(suite.address.Bytes()) diff --git a/x/liquidvesting/module.go b/x/liquidvesting/module.go index 62b434f8..c693a297 100644 --- a/x/liquidvesting/module.go +++ b/x/liquidvesting/module.go @@ -12,10 +12,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/haqq-network/haqq/x/liquidvesting/client/cli" "github.com/haqq-network/haqq/x/liquidvesting/keeper" "github.com/haqq-network/haqq/x/liquidvesting/types" - "github.com/spf13/cobra" ) // ---------------------------------------------------------------------------- diff --git a/x/liquidvesting/types/errors.go b/x/liquidvesting/types/errors.go index 100f0006..8bcc2e45 100644 --- a/x/liquidvesting/types/errors.go +++ b/x/liquidvesting/types/errors.go @@ -10,4 +10,5 @@ var ( ErrLiquidationFailed = sdkerrors.Register(ModuleName, 1102, "liquidation failed") ErrRedeemFailed = sdkerrors.Register(ModuleName, 1103, "redeem failed") ErrDenomNotFound = sdkerrors.Register(ModuleName, 1104, "denom not found") + ErrModuleIsDisabled = sdkerrors.Register(ModuleName, 1105, "module is disabled") ) diff --git a/x/liquidvesting/types/genesis.pb.go b/x/liquidvesting/types/genesis.pb.go index f4111ccb..19bfc07b 100644 --- a/x/liquidvesting/types/genesis.pb.go +++ b/x/liquidvesting/types/genesis.pb.go @@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // params defines all the paramaters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - DenomCounter uint64 `protobuf:"varint,2,opt,name=denomCounter,proto3" json:"denomCounter,omitempty"` + DenomCounter uint64 `protobuf:"varint,2,opt,name=denom_counter,json=denomCounter,proto3" json:"denom_counter,omitempty"` Denoms []Denom `protobuf:"bytes,3,rep,name=denoms,proto3" json:"denoms"` } @@ -90,6 +90,8 @@ func (m *GenesisState) GetDenoms() []Denom { // Params holds parameters for the liquidvesting module. type Params struct { MinimumLiquidationAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=minimum_liquidation_amount,json=minimumLiquidationAmount,proto3,customtype=cosmossdk.io/math.Int" json:"minimum_liquidation_amount"` + // parameter to enable liquid vesting + EnableLiquidVesting bool `protobuf:"varint,2,opt,name=enable_liquid_vesting,json=enableLiquidVesting,proto3" json:"enable_liquid_vesting,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -125,6 +127,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetEnableLiquidVesting() bool { + if m != nil { + return m.EnableLiquidVesting + } + return false +} + func init() { proto.RegisterType((*GenesisState)(nil), "haqq.liquidvesting.v1.GenesisState") proto.RegisterType((*Params)(nil), "haqq.liquidvesting.v1.Params") @@ -135,29 +144,31 @@ func init() { } var fileDescriptor_811653311f50d122 = []byte{ - // 345 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xcd, 0x6a, 0x2a, 0x31, - 0x14, 0xc7, 0x27, 0x57, 0x19, 0x30, 0xba, 0xb9, 0xc3, 0x15, 0x06, 0xb9, 0x8e, 0x62, 0x37, 0xb6, - 0xd0, 0x04, 0xed, 0xb2, 0x8b, 0xd2, 0x69, 0xa1, 0x14, 0x5c, 0x94, 0xe9, 0xae, 0x5d, 0x48, 0xd4, - 0x30, 0x06, 0x9b, 0x44, 0x27, 0x19, 0xdb, 0xbe, 0x45, 0x1f, 0xa3, 0x4b, 0x1f, 0xc3, 0xa5, 0xcb, - 0xd2, 0x85, 0x14, 0x5d, 0xf4, 0x35, 0x4a, 0x32, 0x03, 0xc5, 0x62, 0x37, 0x21, 0xe7, 0xf0, 0xfb, - 0x7f, 0x70, 0xe0, 0xc1, 0x98, 0xcc, 0x66, 0xf8, 0x81, 0xcd, 0x52, 0x36, 0x9a, 0x53, 0xa5, 0x99, - 0x88, 0xf1, 0xbc, 0x83, 0x63, 0x2a, 0xa8, 0x62, 0x0a, 0x4d, 0x13, 0xa9, 0xa5, 0x57, 0x35, 0x10, - 0xda, 0x81, 0xd0, 0xbc, 0x53, 0xfb, 0x17, 0xcb, 0x58, 0x5a, 0x02, 0x9b, 0x5f, 0x06, 0xd7, 0xfe, - 0x12, 0xce, 0x84, 0xc4, 0xf6, 0xcd, 0x57, 0x87, 0xfb, 0x43, 0x76, 0x0d, 0x2d, 0xda, 0x5a, 0x00, - 0x58, 0xb9, 0xca, 0xc2, 0x6f, 0x35, 0xd1, 0xd4, 0x3b, 0x85, 0xee, 0x94, 0x24, 0x84, 0x2b, 0x1f, - 0x34, 0x41, 0xbb, 0xdc, 0xad, 0xa3, 0xbd, 0x65, 0xd0, 0x8d, 0x85, 0xc2, 0xe2, 0x72, 0xdd, 0x70, - 0xa2, 0x5c, 0xe2, 0xb5, 0x60, 0x65, 0x44, 0x85, 0xe4, 0x17, 0x32, 0x15, 0x9a, 0x26, 0xfe, 0x9f, - 0x26, 0x68, 0x17, 0xa3, 0x9d, 0x9d, 0x77, 0x06, 0x5d, 0x3b, 0x2b, 0xbf, 0xd0, 0x2c, 0xb4, 0xcb, - 0xdd, 0xff, 0xbf, 0x04, 0x5c, 0x1a, 0x28, 0x2c, 0x19, 0xff, 0xd7, 0xcf, 0xc5, 0x11, 0x88, 0x72, - 0x59, 0x8b, 0x42, 0x37, 0x0b, 0xf7, 0xee, 0x61, 0x8d, 0x33, 0xc1, 0x78, 0xca, 0xfb, 0x99, 0x9c, - 0x68, 0x26, 0x45, 0x9f, 0x70, 0x13, 0x65, 0xfb, 0x97, 0xc2, 0xba, 0x31, 0x78, 0x5f, 0x37, 0xaa, - 0x43, 0xa9, 0xb8, 0x54, 0x6a, 0x34, 0x41, 0x4c, 0x62, 0x4e, 0xf4, 0x18, 0x5d, 0x0b, 0x1d, 0xf9, - 0xb9, 0x41, 0xef, 0x5b, 0x7f, 0x6e, 0xe5, 0x61, 0x6f, 0xb9, 0x09, 0xc0, 0x6a, 0x13, 0x80, 0x8f, - 0x4d, 0x00, 0x5e, 0xb6, 0x81, 0xb3, 0xda, 0x06, 0xce, 0xdb, 0x36, 0x70, 0xee, 0xba, 0x31, 0xd3, - 0xe3, 0x74, 0x80, 0x86, 0x92, 0x63, 0xd3, 0xfd, 0x58, 0x50, 0xfd, 0x28, 0x93, 0x89, 0x1d, 0xf0, - 0xd3, 0x8f, 0xc3, 0xeb, 0xe7, 0x29, 0x55, 0x03, 0xd7, 0x9e, 0xfb, 0xe4, 0x2b, 0x00, 0x00, 0xff, - 0xff, 0x7c, 0xa4, 0x4b, 0x23, 0x00, 0x02, 0x00, 0x00, + // 382 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xce, 0x48, 0x2c, 0x2c, + 0xd4, 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x29, 0x4b, 0x2d, 0x2e, 0xc9, 0xcc, 0x4b, 0xd7, 0x2f, + 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x05, 0x29, 0xd2, 0x43, 0x51, 0xa4, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, + 0x56, 0xa1, 0x0f, 0x62, 0x41, 0x14, 0x4b, 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, + 0xa8, 0x90, 0x26, 0x76, 0x4b, 0x50, 0x0d, 0x04, 0x2b, 0x55, 0xda, 0xc8, 0xc8, 0xc5, 0xe3, 0x0e, + 0xb1, 0x3c, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x9a, 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, + 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x56, 0x0f, 0xab, 0x63, 0xf4, 0x02, 0xc0, 0x8a, + 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x6a, 0x11, 0x52, 0xe6, 0xe2, 0x4d, 0x49, 0xcd, + 0xcb, 0xcf, 0x8d, 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x49, 0x2d, 0x92, 0x60, 0x52, 0x60, 0xd4, 0x60, + 0x09, 0xe2, 0x01, 0x0b, 0x3a, 0x43, 0xc4, 0x84, 0xec, 0xb9, 0xd8, 0xc0, 0xfc, 0x62, 0x09, 0x66, + 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x19, 0x1c, 0x36, 0xb8, 0x80, 0x14, 0x39, 0x71, 0x82, 0x2c, 0x58, + 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0x9b, 0xd2, 0x4c, 0x46, 0x2e, 0x36, 0x88, 0xf5, 0x42, + 0xd1, 0x5c, 0x52, 0xb9, 0x99, 0x79, 0x99, 0xb9, 0xa5, 0xb9, 0xf1, 0x10, 0xfd, 0x89, 0x25, 0x99, + 0xf9, 0x79, 0xf1, 0x89, 0xb9, 0x20, 0xbb, 0xc0, 0x3e, 0xe0, 0x74, 0x92, 0x05, 0x99, 0x70, 0xeb, + 0x9e, 0xbc, 0x68, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x71, 0x4a, 0xb6, 0x5e, 0x66, 0xbe, 0x7e, + 0x6e, 0x62, 0x49, 0x86, 0x9e, 0x67, 0x5e, 0x49, 0x90, 0x04, 0xd4, 0x00, 0x1f, 0x84, 0x7e, 0x47, + 0xb0, 0x76, 0x21, 0x23, 0x2e, 0xd1, 0xd4, 0xbc, 0xc4, 0xa4, 0x9c, 0x54, 0xa8, 0xd9, 0xf1, 0x50, + 0xc7, 0x81, 0x7d, 0xc5, 0x11, 0x24, 0x0c, 0x91, 0x84, 0xe8, 0x0b, 0x83, 0x48, 0x39, 0xf9, 0x9c, + 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, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0xc3, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, + 0x60, 0x8e, 0x7e, 0x05, 0x5a, 0x74, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x23, 0xc9, + 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x9f, 0x13, 0x84, 0x36, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -232,6 +243,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EnableLiquidVesting { + i-- + if m.EnableLiquidVesting { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } { size := m.MinimumLiquidationAmount.Size() i -= size @@ -284,6 +305,9 @@ func (m *Params) Size() (n int) { _ = l l = m.MinimumLiquidationAmount.Size() n += 1 + l + sovGenesis(uint64(l)) + if m.EnableLiquidVesting { + n += 2 + } return n } @@ -492,6 +516,26 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableLiquidVesting", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableLiquidVesting = bool(v != 0) default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/liquidvesting/types/interfaces.go b/x/liquidvesting/types/interfaces.go index 9e6784ae..e481e80f 100644 --- a/x/liquidvesting/types/interfaces.go +++ b/x/liquidvesting/types/interfaces.go @@ -11,6 +11,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + erc20types "github.com/haqq-network/haqq/x/erc20/types" vestingtypes "github.com/haqq-network/haqq/x/vesting/types" ) diff --git a/x/liquidvesting/types/liquidvesting.pb.go b/x/liquidvesting/types/liquidvesting.pb.go index 823a1035..a5692979 100644 --- a/x/liquidvesting/types/liquidvesting.pb.go +++ b/x/liquidvesting/types/liquidvesting.pb.go @@ -5,8 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" github_com_cosmos_cosmos_sdk_x_auth_vesting_types "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" types "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -131,34 +129,32 @@ func init() { } var fileDescriptor_ce2378517a6b5c6c = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0x63, 0xca, 0x1d, 0x57, 0x1f, 0x3d, 0x89, 0x0a, 0xa4, 0x2a, 0x12, 0x4e, 0xc5, 0x1f, - 0xa9, 0x0c, 0x67, 0xab, 0x65, 0x62, 0x42, 0x14, 0x46, 0x06, 0x54, 0x31, 0xb1, 0x54, 0x4e, 0x62, - 0x52, 0xab, 0x89, 0xdf, 0x34, 0x76, 0xca, 0xdd, 0xcc, 0xc2, 0x78, 0x9f, 0x83, 0x4f, 0x72, 0xe3, - 0x8d, 0x4c, 0x1c, 0x6a, 0xbf, 0x08, 0xf2, 0x9f, 0xde, 0x51, 0xb6, 0x5b, 0x12, 0xbf, 0xcf, 0xfb, - 0xcb, 0xf3, 0xe4, 0xb5, 0x8d, 0x5f, 0x2d, 0xf8, 0x6a, 0xc5, 0x4a, 0xb9, 0x6a, 0x65, 0xbe, 0x16, - 0xda, 0x48, 0x55, 0xb0, 0xf5, 0x78, 0x5f, 0xa0, 0x75, 0x03, 0x06, 0xfa, 0x4f, 0x2c, 0x4a, 0xf7, - 0x3b, 0xeb, 0x71, 0xfc, 0x88, 0x57, 0x52, 0x01, 0x73, 0x4f, 0x4f, 0xc6, 0x8f, 0x0b, 0x28, 0xc0, - 0x2d, 0x99, 0x5d, 0x05, 0xf5, 0x45, 0x06, 0xba, 0x02, 0xcd, 0x6e, 0x63, 0x52, 0x61, 0xf8, 0x98, - 0xed, 0xa5, 0xc4, 0x49, 0x01, 0x50, 0x94, 0x82, 0xb9, 0x2a, 0x6d, 0xbf, 0x32, 0x23, 0x2b, 0xa1, - 0x0d, 0xaf, 0xea, 0x00, 0x90, 0x60, 0x93, 0x72, 0x2d, 0x6e, 0x3c, 0x32, 0x90, 0xca, 0xf7, 0x9f, - 0x7d, 0xef, 0xe0, 0x83, 0x0f, 0x42, 0x41, 0xd5, 0x7f, 0x8a, 0xb1, 0x85, 0xe6, 0xb9, 0xad, 0x06, - 0x68, 0x88, 0x46, 0xdd, 0x59, 0xd7, 0x2a, 0xbe, 0xfd, 0x1c, 0xf7, 0x72, 0xa9, 0xeb, 0x92, 0x9f, - 0x07, 0xe2, 0x9e, 0x23, 0x1e, 0x06, 0xd1, 0x43, 0x2f, 0xf1, 0x09, 0x34, 0xb2, 0x90, 0x8a, 0x97, - 0x81, 0xea, 0x38, 0xaa, 0xb7, 0x53, 0x3d, 0xf6, 0x1e, 0x63, 0x6d, 0x78, 0x63, 0xe6, 0xf6, 0x6f, - 0x07, 0xf7, 0x87, 0x68, 0x74, 0x3c, 0x89, 0xa9, 0x1f, 0x85, 0xee, 0x46, 0xa1, 0x9f, 0x77, 0xa3, - 0x4c, 0x8f, 0x2e, 0x7f, 0x27, 0xd1, 0xc5, 0x75, 0x82, 0x66, 0x5d, 0xf7, 0x9d, 0xed, 0xf4, 0xdf, - 0xe2, 0x23, 0xa1, 0x72, 0x6f, 0x71, 0x70, 0x07, 0x8b, 0x07, 0x42, 0xe5, 0xce, 0xe0, 0x07, 0xc2, - 0x27, 0x25, 0x64, 0xcb, 0xb6, 0x9e, 0xd7, 0xa2, 0x91, 0x90, 0xeb, 0xc1, 0xe1, 0xb0, 0x33, 0x3a, - 0x9e, 0x10, 0xea, 0x37, 0x8d, 0xde, 0x9e, 0x9b, 0xdb, 0x37, 0xfa, 0xc9, 0x61, 0xd3, 0x77, 0xd6, - 0xeb, 0xe7, 0x75, 0xf2, 0xa6, 0x90, 0x66, 0xd1, 0xa6, 0x34, 0x83, 0x8a, 0x85, 0x6d, 0xf6, 0xaf, - 0x53, 0x9d, 0x2f, 0xd9, 0x19, 0xe3, 0xad, 0x59, 0xdc, 0x9c, 0x9f, 0x39, 0xaf, 0x85, 0x0e, 0x0e, - 0x7a, 0xd6, 0xf3, 0xc1, 0xa1, 0x9c, 0x7e, 0xbc, 0xdc, 0x10, 0x74, 0xb5, 0x21, 0xe8, 0xcf, 0x86, - 0xa0, 0x8b, 0x2d, 0x89, 0xae, 0xb6, 0x24, 0xfa, 0xb5, 0x25, 0xd1, 0x97, 0xc9, 0x3f, 0x19, 0xf6, - 0x46, 0x9d, 0x2a, 0x61, 0xbe, 0x41, 0xb3, 0x74, 0x05, 0x3b, 0xfb, 0xef, 0x2e, 0xba, 0x90, 0xf4, - 0xd0, 0xcd, 0xff, 0xfa, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x68, 0xb6, 0x57, 0x3f, 0xae, 0x02, - 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x6f, 0xe2, 0x30, + 0x18, 0xc6, 0xe3, 0xe3, 0xe0, 0xc0, 0x1c, 0x0c, 0xe8, 0x4e, 0x42, 0x91, 0x2e, 0x41, 0xf7, 0x47, + 0xe2, 0x06, 0x6c, 0xc1, 0x4d, 0x37, 0x55, 0xa5, 0x1d, 0x3b, 0x54, 0xa8, 0x53, 0x17, 0xe4, 0x10, + 0x37, 0x58, 0x24, 0x71, 0x88, 0x1d, 0x0a, 0x73, 0x97, 0x8e, 0x7c, 0x8e, 0x7e, 0x12, 0x46, 0xc6, + 0x4e, 0xa5, 0x82, 0x2f, 0x52, 0xd9, 0x0e, 0xa5, 0x74, 0xeb, 0x94, 0xbc, 0xcf, 0xfb, 0xcb, 0xf3, + 0x3e, 0xf1, 0x6b, 0xf8, 0x77, 0x4c, 0xa6, 0x53, 0x1c, 0xb2, 0x69, 0xc6, 0xfc, 0x19, 0x15, 0x92, + 0xc5, 0x01, 0x9e, 0x75, 0x8f, 0x05, 0x94, 0xa4, 0x5c, 0xf2, 0xc6, 0x77, 0x85, 0xa2, 0xe3, 0xce, + 0xac, 0x6b, 0x7f, 0x0b, 0x78, 0xc0, 0x35, 0x81, 0xd5, 0x9b, 0x81, 0xed, 0xdf, 0x23, 0x2e, 0x22, + 0x2e, 0xf0, 0xc1, 0xd3, 0xa3, 0x92, 0x74, 0xf1, 0x91, 0xa5, 0xed, 0x06, 0x9c, 0x07, 0x21, 0xc5, + 0xba, 0xf2, 0xb2, 0x1b, 0x2c, 0x59, 0x44, 0x85, 0x24, 0x51, 0x62, 0x80, 0x9f, 0x77, 0x05, 0x58, + 0x3c, 0xa7, 0x31, 0x8f, 0x1a, 0x3f, 0x20, 0xf4, 0x88, 0xa0, 0x43, 0x5f, 0x55, 0x4d, 0xd0, 0x02, + 0xed, 0xca, 0xa0, 0xa2, 0x14, 0xd3, 0xfe, 0x05, 0x6b, 0x3e, 0x13, 0x49, 0x48, 0x16, 0x39, 0xf1, + 0x49, 0x13, 0x5f, 0x73, 0xd1, 0x40, 0x7f, 0x60, 0x9d, 0xa7, 0x2c, 0x60, 0x31, 0x09, 0x73, 0xaa, + 0xa0, 0xa9, 0xda, 0x5e, 0x35, 0xd8, 0x19, 0x84, 0x42, 0x92, 0x54, 0x0e, 0x55, 0x9a, 0xe6, 0xe7, + 0x16, 0x68, 0x57, 0x7b, 0x36, 0x32, 0x51, 0xd1, 0x3e, 0x2a, 0xba, 0xda, 0x47, 0xed, 0x97, 0x57, + 0x4f, 0xae, 0xb5, 0xdc, 0xb8, 0x60, 0x50, 0xd1, 0xdf, 0xa9, 0x4e, 0xe3, 0x04, 0x96, 0x69, 0xec, + 0x1b, 0x8b, 0xe2, 0x07, 0x2c, 0xbe, 0xd0, 0xd8, 0xd7, 0x06, 0xf7, 0x00, 0xd6, 0x43, 0x3e, 0x9a, + 0x64, 0xc9, 0x30, 0xa1, 0x29, 0xe3, 0xbe, 0x68, 0x96, 0x5a, 0x85, 0x76, 0xb5, 0xe7, 0x20, 0x73, + 0xb6, 0xe8, 0xb0, 0x04, 0x7d, 0xb6, 0xe8, 0x52, 0x63, 0xfd, 0x53, 0xe5, 0xf5, 0xb0, 0x71, 0xff, + 0x07, 0x4c, 0x8e, 0x33, 0x0f, 0x8d, 0x78, 0x84, 0xf3, 0x6d, 0x98, 0x47, 0x47, 0xf8, 0x13, 0x3c, + 0xc7, 0x24, 0x93, 0xe3, 0xd7, 0xfd, 0xc8, 0x45, 0x42, 0x45, 0xee, 0x20, 0x06, 0x35, 0x33, 0x38, + 0x2f, 0xfb, 0x17, 0xab, 0xad, 0x03, 0xd6, 0x5b, 0x07, 0x3c, 0x6f, 0x1d, 0xb0, 0xdc, 0x39, 0xd6, + 0x7a, 0xe7, 0x58, 0x8f, 0x3b, 0xc7, 0xba, 0xee, 0xbd, 0x99, 0xa1, 0xae, 0x47, 0x27, 0xa6, 0xf2, + 0x96, 0xa7, 0x13, 0x5d, 0xe0, 0xf9, 0xbb, 0x8b, 0xa5, 0x87, 0x78, 0x25, 0xfd, 0xff, 0xff, 0x5e, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x32, 0x0e, 0xf4, 0x57, 0x7b, 0x02, 0x00, 0x00, } func (m *Denom) Marshal() (dAtA []byte, err error) { diff --git a/x/liquidvesting/types/params.go b/x/liquidvesting/types/params.go index ec30be75..d21a4997 100644 --- a/x/liquidvesting/types/params.go +++ b/x/liquidvesting/types/params.go @@ -15,27 +15,43 @@ const DefaultMinimumLiquidationAmountISLM = 1000 var AttoMultiplier = math.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) // DefaultMinimumLiquidationAmount default atto parameter value -var DefaultMinimumLiquidationAmount = math.NewInt(DefaultMinimumLiquidationAmountISLM).Mul(AttoMultiplier) +var ( + DefaultMinimumLiquidationAmount = math.NewInt(DefaultMinimumLiquidationAmountISLM).Mul(AttoMultiplier) + DefaultEnableLiquidVesting = true +) // ParamStoreKeyMinimumLiquidationAmount Parameter store keys -var ParamStoreKeyMinimumLiquidationAmount = []byte("MinimumLiquidationAmount") +var ( + ParamStoreKeyMinimumLiquidationAmount = []byte("MinimumLiquidationAmount") + ParamStoreKeyEnableLiquidVesting = []byte("EnableLiquidVesting") +) func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(minimumLiquidationAmount math.Int) Params { - return Params{MinimumLiquidationAmount: minimumLiquidationAmount} +func NewParams( + minimumLiquidationAmount math.Int, + enableLiquidVesting bool, +) Params { + return Params{ + MinimumLiquidationAmount: minimumLiquidationAmount, + EnableLiquidVesting: enableLiquidVesting, + } } func DefaultParams() Params { - return Params{MinimumLiquidationAmount: DefaultMinimumLiquidationAmount} + return Params{ + MinimumLiquidationAmount: DefaultMinimumLiquidationAmount, + EnableLiquidVesting: DefaultEnableLiquidVesting, + } } // ParamSetPairs Implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(ParamStoreKeyMinimumLiquidationAmount, &p.MinimumLiquidationAmount, validateMathIntPositive), + paramtypes.NewParamSetPair(ParamStoreKeyEnableLiquidVesting, &p.EnableLiquidVesting, validateBool), } } @@ -51,6 +67,15 @@ func validateMathIntPositive(i interface{}) error { return nil } +func validateBool(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} + func (p Params) Validate() error { return validateMathIntPositive(p.MinimumLiquidationAmount) } diff --git a/x/liquidvesting/types/schedule.go b/x/liquidvesting/types/schedule.go index 6b602c34..23868d66 100644 --- a/x/liquidvesting/types/schedule.go +++ b/x/liquidvesting/types/schedule.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + vestingTypes "github.com/haqq-network/haqq/x/vesting/types" ) diff --git a/x/liquidvesting/types/tx.pb.go b/x/liquidvesting/types/tx.pb.go index 811d6eea..b412d6c4 100644 --- a/x/liquidvesting/types/tx.pb.go +++ b/x/liquidvesting/types/tx.pb.go @@ -31,7 +31,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgLiquidate represents message to liquidate arbitrary amount of tokens locked in vesting +// MsgLiquidate represents message to liquidate arbitrary amount of tokens +// locked in vesting type MsgLiquidate struct { // account for liquidation of locked vesting tokens LiquidateFrom string `protobuf:"bytes,1,opt,name=liquidate_from,json=liquidateFrom,proto3" json:"liquidate_from,omitempty"` @@ -132,7 +133,8 @@ func (m *MsgLiquidateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgLiquidateResponse proto.InternalMessageInfo -// MsgLiquidate represents message to redeem arbitrary amount of liquid vesting tokens +// MsgLiquidate represents message to redeem arbitrary amount of liquid vesting +// tokens type MsgRedeem struct { RedeemFrom string `protobuf:"bytes,1,opt,name=redeem_from,json=redeemFrom,proto3" json:"redeem_from,omitempty"` // destination address for vesting tokens @@ -285,9 +287,11 @@ 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 { - // Liquidate transforms specified amount of tokens locked on vesting account into a new liquid token + // Liquidate transforms specified amount of tokens locked on vesting account + // into a new liquid token Liquidate(ctx context.Context, in *MsgLiquidate, opts ...grpc.CallOption) (*MsgLiquidateResponse, error) - // Redeem burns liquid token and deposits corresponding amount of vesting token to the specified account + // Redeem burns liquid token and deposits corresponding amount of vesting + // token to the specified account Redeem(ctx context.Context, in *MsgRedeem, opts ...grpc.CallOption) (*MsgRedeemResponse, error) } @@ -319,9 +323,11 @@ func (c *msgClient) Redeem(ctx context.Context, in *MsgRedeem, opts ...grpc.Call // MsgServer is the server API for Msg service. type MsgServer interface { - // Liquidate transforms specified amount of tokens locked on vesting account into a new liquid token + // Liquidate transforms specified amount of tokens locked on vesting account + // into a new liquid token Liquidate(context.Context, *MsgLiquidate) (*MsgLiquidateResponse, error) - // Redeem burns liquid token and deposits corresponding amount of vesting token to the specified account + // Redeem burns liquid token and deposits corresponding amount of vesting + // token to the specified account Redeem(context.Context, *MsgRedeem) (*MsgRedeemResponse, error) } diff --git a/x/vesting/client/cli/query.go b/x/vesting/client/cli/query.go index 0ccfaeeb..b2941118 100644 --- a/x/vesting/client/cli/query.go +++ b/x/vesting/client/cli/query.go @@ -65,8 +65,8 @@ func GetBalancesCmd() *cobra.Command { func GetTotalLockedCmd() *cobra.Command { cmd := &cobra.Command{ Use: "total", - Short: "Gets total summary of locked, unvested and vested tokens for all acounts", - Long: "Gets total summary of locked, unvested and vested tokens for all acounts", + Short: "Gets total summary of locked, unvested and vested tokens for all accounts", + Long: "Gets total summary of locked, unvested and vested tokens for all accounts", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/vesting/keeper/grpc_query_test.go b/x/vesting/keeper/grpc_query_test.go index 7f69b8f9..c7776a4e 100644 --- a/x/vesting/keeper/grpc_query_test.go +++ b/x/vesting/keeper/grpc_query_test.go @@ -13,8 +13,8 @@ import ( func (suite *KeeperTestSuite) TestBalances() { var ( - req *types.QueryBalancesRequest - expRes *types.QueryBalancesResponse + req *types.QueryBalancesRequest + expResponse *types.QueryBalancesResponse ) addr := sdk.AccAddress(tests.GenerateAddress().Bytes()) @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestBalances() { req = &types.QueryBalancesRequest{ Address: addr.String(), } - expRes = &types.QueryBalancesResponse{ + expResponse = &types.QueryBalancesResponse{ Locked: balances, Unvested: balances, Vested: nil, @@ -104,7 +104,7 @@ func (suite *KeeperTestSuite) TestBalances() { res, err := suite.queryClient.Balances(ctx, req) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) } else { suite.Require().Error(err) } diff --git a/x/vesting/keeper/msg_server_test.go b/x/vesting/keeper/msg_server_test.go index eb107be3..1b1d2194 100644 --- a/x/vesting/keeper/msg_server_test.go +++ b/x/vesting/keeper/msg_server_test.go @@ -191,13 +191,13 @@ func (suite *KeeperTestSuite) TestMsgCreateClawbackVestingAccount() { ) res, err := suite.app.VestingKeeper.CreateClawbackVestingAccount(ctx, msg) - expRes := &types.MsgCreateClawbackVestingAccountResponse{} + expResponse := &types.MsgCreateClawbackVestingAccountResponse{} balanceSource := suite.app.BankKeeper.GetBalance(suite.ctx, tc.from, "aISLM") balanceDest := suite.app.BankKeeper.GetBalance(suite.ctx, tc.to, "aISLM") if tc.expectPass { suite.Require().NoError(err, tc.name) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) accI := suite.app.AccountKeeper.GetAccount(suite.ctx, tc.to) suite.Require().NotNil(accI) @@ -309,7 +309,7 @@ func (suite *KeeperTestSuite) TestMsgClawback() { msg := types.NewMsgClawback(tc.funder, tc.addr, tc.dest) res, err := suite.app.VestingKeeper.Clawback(ctx, msg) - expRes := &types.MsgClawbackResponse{} + expResponse := &types.MsgClawbackResponse{} balanceDest = suite.app.BankKeeper.GetBalance(suite.ctx, addr2, "aISLM") balanceClaw := suite.app.BankKeeper.GetBalance(suite.ctx, tc.dest, "aISLM") if len(tc.dest) == 0 { @@ -318,7 +318,7 @@ func (suite *KeeperTestSuite) TestMsgClawback() { if tc.expectedPass { suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(sdk.NewInt64Coin("aISLM", 0), balanceDest) suite.Require().Equal(balances[0], balanceClaw) } else { @@ -411,7 +411,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateVestingFunder() { msg := types.NewMsgUpdateVestingFunder(tc.funder, tc.newFunder, tc.vestingAcc) res, err := suite.app.VestingKeeper.UpdateVestingFunder(ctx, msg) - expRes := &types.MsgUpdateVestingFunderResponse{} + expResponse := &types.MsgUpdateVestingFunderResponse{} if tc.expectedPass { // get the updated vesting account @@ -420,7 +420,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateVestingFunder() { suite.Require().True(ok, "vesting account could not be casted to ClawbackVestingAccount") suite.Require().NoError(err) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) suite.Require().Equal(va.FunderAddress, tc.newFunder.String()) } else { suite.Require().Error(err) @@ -885,14 +885,14 @@ func (suite *KeeperTestSuite) TestConvertIntoVestingAccount() { ) res, err := suite.app.VestingKeeper.ConvertIntoVestingAccount(ctx, msg) - expRes := &types.MsgConvertIntoVestingAccountResponse{} + expResponse := &types.MsgConvertIntoVestingAccountResponse{} balanceSource := suite.app.BankKeeper.GetBalance(suite.ctx, tc.from, "aISLM") balanceDest := suite.app.BankKeeper.GetBalance(suite.ctx, tc.to, "aISLM") balanceBonded := suite.app.StakingKeeper.GetDelegatorBonded(suite.ctx, tc.to) if tc.expectPass { suite.Require().NoError(err, tc.name) - suite.Require().Equal(expRes, res) + suite.Require().Equal(expResponse, res) accI := suite.app.AccountKeeper.GetAccount(suite.ctx, tc.to) suite.Require().NotNil(accI) diff --git a/x/vesting/keeper/schedule.go b/x/vesting/keeper/schedule.go index 171e7ecf..dda4e7c2 100644 --- a/x/vesting/keeper/schedule.go +++ b/x/vesting/keeper/schedule.go @@ -9,6 +9,7 @@ import ( sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + ethtypes "github.com/haqq-network/haqq/types" "github.com/haqq-network/haqq/x/vesting/types" )