add linters and format

linters and format
This commit is contained in:
Federico Kunze 2020-05-01 11:26:43 -04:00 committed by GitHub
commit 03717ad0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
169 changed files with 644 additions and 308 deletions

12
.github/.workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Lint
on: [pull_request]
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review

View File

@ -103,6 +103,21 @@ clean:
link-check: link-check:
@go run github.com/raviqqe/liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*" @go run github.com/raviqqe/liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*"
lint:
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
.PHONY: lint
format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/tendermint
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/kava-labs/kava
.PHONY: format
######################################## ########################################
### Testing ### Testing

View File

@ -4,10 +4,11 @@ import (
"io" "io"
"os" "os"
dbm "github.com/tendermint/tm-db"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os" tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db" db "github.com/tendermint/tm-db"

View File

@ -6,6 +6,8 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/simapp/helpers"
@ -20,6 +22,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
"github.com/kava-labs/kava/x/auction" "github.com/kava-labs/kava/x/auction"
"github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/bep3"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
@ -27,10 +34,6 @@ import (
"github.com/kava-labs/kava/x/kavadist" "github.com/kava-labs/kava/x/kavadist"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting" validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
) )
type StoreKeysPrefixes struct { type StoreKeysPrefixes struct {

View File

@ -6,12 +6,13 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
tmdb "github.com/tendermint/tm-db"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmdb "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -3,11 +3,12 @@ package main
import ( import (
"fmt" "fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/keys"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
) )

View File

@ -8,13 +8,13 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/lcd" "github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
@ -79,7 +79,7 @@ func main() {
} }
} }
func queryCmd(cdc *amino.Codec) *cobra.Command { func queryCmd(cdc *codec.Codec) *cobra.Command {
queryCmd := &cobra.Command{ queryCmd := &cobra.Command{
Use: "query", Use: "query",
Aliases: []string{"q"}, Aliases: []string{"q"},
@ -102,7 +102,7 @@ func queryCmd(cdc *amino.Codec) *cobra.Command {
return queryCmd return queryCmd
} }
func txCmd(cdc *amino.Codec) *cobra.Command { func txCmd(cdc *codec.Codec) *cobra.Command {
txCmd := &cobra.Command{ txCmd := &cobra.Command{
Use: "tx", Use: "tx",
Short: "Transactions subcommands", Short: "Transactions subcommands",

View File

@ -9,7 +9,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
@ -22,6 +21,7 @@ import (
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
) )
const ( const (

View File

@ -7,11 +7,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
dbm "github.com/tendermint/tm-db"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"

1
go.mod
View File

@ -5,6 +5,7 @@ go 1.13
require ( require (
github.com/btcsuite/btcd v0.20.1-beta // indirect github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/cosmos/cosmos-sdk v0.38.3 github.com/cosmos/cosmos-sdk v0.38.3
github.com/gogo/protobuf v1.3.1
github.com/gorilla/mux v1.7.3 github.com/gorilla/mux v1.7.3
github.com/spf13/cobra v0.0.6 github.com/spf13/cobra v0.0.6
github.com/spf13/viper v1.6.2 github.com/spf13/viper v1.6.2

52
golangci.yml Normal file
View File

@ -0,0 +1,52 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - errcheck
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- misspell
- wsl
issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "comment on exported var"
linters:
- golint
linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true

View File

@ -10,6 +10,7 @@ import (
"time" "time"
"github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/codec"
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys" crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkrest "github.com/cosmos/cosmos-sdk/types/rest" sdkrest "github.com/cosmos/cosmos-sdk/types/rest"
@ -21,11 +22,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
"github.com/tendermint/go-amino"
tmtime "github.com/tendermint/tendermint/types/time"
) )
func init() { func init() {
@ -394,7 +396,7 @@ func getKeybase() crkeys.Keybase {
} }
// sendMsgToBlockchain sends a message to the blockchain via the rest api // sendMsgToBlockchain sends a message to the blockchain via the rest api
func sendMsgToBlockchain(cdc *amino.Codec, address string, keyname string, func sendMsgToBlockchain(cdc *codec.Codec, address string, keyname string,
password string, msg []sdk.Msg, keybase crkeys.Keybase) { password string, msg []sdk.Msg, keybase crkeys.Keybase) {
// get the account number and sequence number // get the account number and sequence number
@ -450,7 +452,7 @@ func sendMsgToBlockchain(cdc *amino.Codec, address string, keyname string,
} }
// getAccountNumberAndSequenceNumber gets an account number and sequence number from the blockchain // getAccountNumberAndSequenceNumber gets an account number and sequence number from the blockchain
func getAccountNumberAndSequenceNumber(cdc *amino.Codec, address string) (accountNumber uint64, sequenceNumber uint64) { func getAccountNumberAndSequenceNumber(cdc *codec.Codec, address string) (accountNumber uint64, sequenceNumber uint64) {
// we need to setup the account number and sequence in order to have a valid transaction // we need to setup the account number and sequence in order to have a valid transaction
resp, err := http.Get("http://localhost:1317/auth/accounts/" + address) resp, err := http.Get("http://localhost:1317/auth/accounts/" + address)

View File

@ -3,11 +3,13 @@ package auction_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -12,29 +12,29 @@ import (
// ALIASGEN: github.com/kava-labs/kava/x/auction/types // ALIASGEN: github.com/kava-labs/kava/x/auction/types
const ( const (
EventTypeAuctionStart = types.EventTypeAuctionStart EventTypeAuctionStart = types.EventTypeAuctionStart
EventTypeAuctionBid = types.EventTypeAuctionBid EventTypeAuctionBid = types.EventTypeAuctionBid
EventTypeAuctionClose = types.EventTypeAuctionClose EventTypeAuctionClose = types.EventTypeAuctionClose
AttributeValueCategory = types.AttributeValueCategory AttributeValueCategory = types.AttributeValueCategory
AttributeKeyAuctionID = types.AttributeKeyAuctionID AttributeKeyAuctionID = types.AttributeKeyAuctionID
AttributeKeyAuctionType = types.AttributeKeyAuctionType AttributeKeyAuctionType = types.AttributeKeyAuctionType
AttributeKeyBidder = types.AttributeKeyBidder AttributeKeyBidder = types.AttributeKeyBidder
AttributeKeyBidDenom = types.AttributeKeyBidDenom AttributeKeyBidDenom = types.AttributeKeyBidDenom
AttributeKeyLotDenom = types.AttributeKeyLotDenom AttributeKeyLotDenom = types.AttributeKeyLotDenom
AttributeKeyBidAmount = types.AttributeKeyBidAmount AttributeKeyBidAmount = types.AttributeKeyBidAmount
AttributeKeyLotAmount = types.AttributeKeyLotAmount AttributeKeyLotAmount = types.AttributeKeyLotAmount
AttributeKeyEndTime = types.AttributeKeyEndTime AttributeKeyEndTime = types.AttributeKeyEndTime
DefaultNextAuctionID = types.DefaultNextAuctionID DefaultNextAuctionID = types.DefaultNextAuctionID
ModuleName = types.ModuleName ModuleName = types.ModuleName
StoreKey = types.StoreKey StoreKey = types.StoreKey
RouterKey = types.RouterKey RouterKey = types.RouterKey
DefaultParamspace = types.DefaultParamspace DefaultParamspace = types.DefaultParamspace
QuerierRoute = types.QuerierRoute QuerierRoute = types.QuerierRoute
DefaultMaxAuctionDuration = types.DefaultMaxAuctionDuration DefaultMaxAuctionDuration = types.DefaultMaxAuctionDuration
DefaultBidDuration = types.DefaultBidDuration DefaultBidDuration = types.DefaultBidDuration
QueryGetAuction = types.QueryGetAuction QueryGetAuction = types.QueryGetAuction
QueryGetAuctions = types.QueryGetAuctions QueryGetAuctions = types.QueryGetAuctions
QueryGetParams = types.QueryGetParams QueryGetParams = types.QueryGetParams
) )
var ( var (

View File

@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
"github.com/kava-labs/kava/x/auction/types" "github.com/kava-labs/kava/x/auction/types"
) )

View File

@ -4,11 +4,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -6,11 +6,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/subspace" "github.com/cosmos/cosmos-sdk/x/params/subspace"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/kava-labs/kava/x/auction/types" "github.com/kava-labs/kava/x/auction/types"

View File

@ -5,6 +5,7 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -3,8 +3,9 @@ package keeper
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestSplitIntIntoWeightedBuckets(t *testing.T) { func TestSplitIntIntoWeightedBuckets(t *testing.T) {

View File

@ -2,6 +2,7 @@ package keeper
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/types" "github.com/kava-labs/kava/x/auction/types"
) )

View File

@ -5,18 +5,21 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction/keeper" "github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types" "github.com/kava-labs/kava/x/auction/types"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
const ( const (

View File

@ -14,6 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
sim "github.com/cosmos/cosmos-sdk/x/simulation" sim "github.com/cosmos/cosmos-sdk/x/simulation"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/auction/client/cli" "github.com/kava-labs/kava/x/auction/client/cli"

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/kv" "github.com/tendermint/tendermint/libs/kv"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"

View File

@ -4,8 +4,9 @@ import (
"testing" "testing"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
const ( const (

View File

@ -3,8 +3,9 @@ package types
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
var testCoin = sdk.NewInt64Coin("test", 20) var testCoin = sdk.NewInt64Coin("test", 20)

View File

@ -3,8 +3,9 @@ package types
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestMsgPlaceBid_ValidateBasic(t *testing.T) { func TestMsgPlaceBid_ValidateBasic(t *testing.T) {

View File

@ -4,8 +4,9 @@ import (
"testing" "testing"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestParams_Validate(t *testing.T) { func TestParams_Validate(t *testing.T) {

View File

@ -6,11 +6,13 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"

View File

@ -7,6 +7,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
@ -14,9 +16,10 @@ import (
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/kava-labs/kava/x/bep3/types"
"github.com/spf13/cobra"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/x/bep3/types"
) )
// GetTxCmd returns the transaction commands for this module // GetTxCmd returns the transaction commands for this module

View File

@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
) )

View File

@ -4,11 +4,12 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/gorilla/mux"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
) )

View File

@ -3,8 +3,10 @@ package bep3_test
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"

View File

@ -4,6 +4,7 @@ import (
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -3,13 +3,16 @@ package keeper_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/keeper" "github.com/kava-labs/kava/x/bep3/keeper"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type AssetTestSuite struct { type AssetTestSuite struct {

View File

@ -4,11 +4,13 @@ import (
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/bep3"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/tendermint/tendermint/crypto"
tmtime "github.com/tendermint/tendermint/types/time"
) )
const ( const (

View File

@ -7,8 +7,10 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/subspace" "github.com/cosmos/cosmos-sdk/x/params/subspace"
"github.com/kava-labs/kava/x/bep3/types"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/kava-labs/kava/x/bep3/types"
) )
// Keeper of the bep3 store // Keeper of the bep3 store

View File

@ -4,13 +4,16 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/keeper" "github.com/kava-labs/kava/x/bep3/keeper"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
const LongtermStorageDuration = 86400 const LongtermStorageDuration = 86400

View File

@ -4,13 +4,16 @@ import (
"errors" "errors"
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/keeper" "github.com/kava-labs/kava/x/bep3/keeper"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type ParamsTestSuite struct { type ParamsTestSuite struct {

View File

@ -126,21 +126,23 @@ func (k Keeper) ClaimAtomicSwap(ctx sdk.Context, from sdk.AccAddress, swapID []b
case types.Incoming: case types.Incoming:
err := k.DecrementIncomingAssetSupply(ctx, atomicSwap.Amount[0]) err := k.DecrementIncomingAssetSupply(ctx, atomicSwap.Amount[0])
if err != nil { if err != nil {
break return err
} }
err = k.IncrementCurrentAssetSupply(ctx, atomicSwap.Amount[0]) err = k.IncrementCurrentAssetSupply(ctx, atomicSwap.Amount[0])
if err != nil {
return err
}
case types.Outgoing: case types.Outgoing:
err = k.DecrementOutgoingAssetSupply(ctx, atomicSwap.Amount[0]) err = k.DecrementOutgoingAssetSupply(ctx, atomicSwap.Amount[0])
if err != nil { if err != nil {
break return err
} }
err = k.DecrementCurrentAssetSupply(ctx, atomicSwap.Amount[0]) err = k.DecrementCurrentAssetSupply(ctx, atomicSwap.Amount[0])
if err != nil {
return err
}
default: default:
err = fmt.Errorf("invalid swap direction: %s", atomicSwap.Direction.String()) return fmt.Errorf("invalid swap direction: %s", atomicSwap.Direction.String())
}
if err != nil {
return err
} }
// Send intended recipient coins // Send intended recipient coins
@ -245,13 +247,13 @@ func (k Keeper) UpdateExpiredAtomicSwaps(ctx sdk.Context) error {
} }
// Emit 'swaps_expired' event // Emit 'swaps_expired' event
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeSwapsExpired, types.EventTypeSwapsExpired,
sdk.NewAttribute(types.AttributeKeyAtomicSwapIDs, fmt.Sprintf("%s", expiredSwapIDs)), sdk.NewAttribute(types.AttributeKeyAtomicSwapIDs, fmt.Sprintf("%s", expiredSwapIDs)),
sdk.NewAttribute(types.AttributeExpirationBlock, fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute(types.AttributeExpirationBlock, fmt.Sprintf("%d", ctx.BlockHeight())),
), ),
) )
return nil return nil
} }

View File

@ -4,14 +4,16 @@ import (
"encoding/json" "encoding/json"
"math/rand" "math/rand"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
sim "github.com/cosmos/cosmos-sdk/x/simulation" sim "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/bep3/client/cli" "github.com/kava-labs/kava/x/bep3/client/cli"

View File

@ -12,6 +12,7 @@ import (
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
) )

View File

@ -4,8 +4,10 @@ import (
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/bep3/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/x/bep3/types"
) )
func i(in int64) sdk.Int { return sdk.NewInt(in) } func i(in int64) sdk.Int { return sdk.NewInt(in) }

View File

@ -3,10 +3,12 @@ package types_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
) )
type GenesisTestSuite struct { type GenesisTestSuite struct {

View File

@ -8,6 +8,7 @@ import (
"strings" "strings"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto/tmhash" "github.com/tendermint/tendermint/crypto/tmhash"
) )

View File

@ -3,10 +3,12 @@ package types_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
) )
type HashTestSuite struct { type HashTestSuite struct {

View File

@ -3,10 +3,12 @@ package types_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/bep3/types" "github.com/kava-labs/kava/x/bep3/types"
"github.com/stretchr/testify/suite"
) )
type ParamsTestSuite struct { type ParamsTestSuite struct {

View File

@ -4,8 +4,10 @@ import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/cdp/types"
) )
// BeginBlocker compounds the debt in outstanding cdps and liquidates cdps that are below the required collateralization ratio // BeginBlocker compounds the debt in outstanding cdps and liquidates cdps that are below the required collateralization ratio

View File

@ -5,14 +5,17 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/simulation"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction" "github.com/kava-labs/kava/x/auction"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type ModuleTestSuite struct { type ModuleTestSuite struct {

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -5,10 +5,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/stretchr/testify/suite"
) )
type GenesisTestSuite struct { type GenesisTestSuite struct {

View File

@ -4,11 +4,13 @@ import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )

View File

@ -5,10 +5,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
tmtime "github.com/tendermint/tendermint/types/time"
) )
// Avoid cluttering test cases with long function names // Avoid cluttering test cases with long function names
@ -21,11 +22,11 @@ func NewPricefeedGenState(asset string, price sdk.Dec) app.GenesisState {
pfGenesis := pricefeed.GenesisState{ pfGenesis := pricefeed.GenesisState{
Params: pricefeed.Params{ Params: pricefeed.Params{
Markets: []pricefeed.Market{ Markets: []pricefeed.Market{
pricefeed.Market{MarketID: asset + ":usd", BaseAsset: asset, QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: asset + ":usd", BaseAsset: asset, QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
}, },
}, },
PostedPrices: []pricefeed.PostedPrice{ PostedPrices: []pricefeed.PostedPrice{
pricefeed.PostedPrice{ {
MarketID: asset + ":usd", MarketID: asset + ":usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: price, Price: price,
@ -77,18 +78,18 @@ func NewPricefeedGenStateMulti() app.GenesisState {
pfGenesis := pricefeed.GenesisState{ pfGenesis := pricefeed.GenesisState{
Params: pricefeed.Params{ Params: pricefeed.Params{
Markets: []pricefeed.Market{ Markets: []pricefeed.Market{
pricefeed.Market{MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
pricefeed.Market{MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
}, },
}, },
PostedPrices: []pricefeed.PostedPrice{ PostedPrices: []pricefeed.PostedPrice{
pricefeed.PostedPrice{ {
MarketID: "btc:usd", MarketID: "btc:usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: sdk.MustNewDecFromStr("8000.00"), Price: sdk.MustNewDecFromStr("8000.00"),
Expiry: time.Now().Add(1 * time.Hour), Expiry: time.Now().Add(1 * time.Hour),
}, },
pricefeed.PostedPrice{ {
MarketID: "xrp:usd", MarketID: "xrp:usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: sdk.MustNewDecFromStr("0.25"), Price: sdk.MustNewDecFromStr("0.25"),

View File

@ -2,6 +2,7 @@ package keeper
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )
@ -209,7 +210,9 @@ func (k Keeper) GetTotalDebt(ctx sdk.Context, accountName string) sdk.Int {
// RunSurplusAndDebtAuctions nets the surplus and debt balances and then creates surplus or debt auctions if the remaining balance is above the auction threshold parameter // RunSurplusAndDebtAuctions nets the surplus and debt balances and then creates surplus or debt auctions if the remaining balance is above the auction threshold parameter
func (k Keeper) RunSurplusAndDebtAuctions(ctx sdk.Context) error { func (k Keeper) RunSurplusAndDebtAuctions(ctx sdk.Context) error {
k.NetSurplusAndDebt(ctx) if err := k.NetSurplusAndDebt(ctx); err != nil {
return err
}
remainingDebt := k.GetTotalDebt(ctx, types.LiquidatorMacc) remainingDebt := k.GetTotalDebt(ctx, types.LiquidatorMacc)
params := k.GetParams(ctx) params := k.GetParams(ctx)
if remainingDebt.GTE(params.DebtAuctionThreshold) { if remainingDebt.GTE(params.DebtAuctionThreshold) {

View File

@ -4,12 +4,14 @@ import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction" "github.com/kava-labs/kava/x/auction"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
) )

View File

@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )
@ -198,7 +199,7 @@ func (k Keeper) SetCDP(ctx sdk.Context, cdp types.CDP) error {
store := prefix.NewStore(ctx.KVStore(k.key), types.CdpKeyPrefix) store := prefix.NewStore(ctx.KVStore(k.key), types.CdpKeyPrefix)
db, found := k.GetDenomPrefix(ctx, cdp.Collateral.Denom) db, found := k.GetDenomPrefix(ctx, cdp.Collateral.Denom)
if !found { if !found {
sdkerrors.Wrapf(types.ErrDenomPrefixNotFound, "%s", cdp.Collateral.Denom) return sdkerrors.Wrapf(types.ErrDenomPrefixNotFound, "%s", cdp.Collateral.Denom)
} }
bz := k.cdc.MustMarshalBinaryLengthPrefixed(cdp) bz := k.cdc.MustMarshalBinaryLengthPrefixed(cdp)
store.Set(types.CdpKey(db, cdp.ID), bz) store.Set(types.CdpKey(db, cdp.ID), bz)
@ -210,7 +211,7 @@ func (k Keeper) DeleteCDP(ctx sdk.Context, cdp types.CDP) error {
store := prefix.NewStore(ctx.KVStore(k.key), types.CdpKeyPrefix) store := prefix.NewStore(ctx.KVStore(k.key), types.CdpKeyPrefix)
db, found := k.GetDenomPrefix(ctx, cdp.Collateral.Denom) db, found := k.GetDenomPrefix(ctx, cdp.Collateral.Denom)
if !found { if !found {
sdkerrors.Wrapf(types.ErrDenomPrefixNotFound, "%s", cdp.Collateral.Denom) return sdkerrors.Wrapf(types.ErrDenomPrefixNotFound, "%s", cdp.Collateral.Denom)
} }
store.Delete(types.CdpKey(db, cdp.ID)) store.Delete(types.CdpKey(db, cdp.ID))
return nil return nil
@ -431,7 +432,7 @@ func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) (types.Augmente
return types.AugmentedCDP{}, err return types.AugmentedCDP{}, err
} }
// total debt is the sum of all oustanding principal and fees // total debt is the sum of all outstanding principal and fees
var totalDebt int64 var totalDebt int64
totalDebt += cdp.Principal.Amount.Int64() totalDebt += cdp.Principal.Amount.Int64()
totalDebt += cdp.AccumulatedFees.Amount.Int64() totalDebt += cdp.AccumulatedFees.Amount.Int64()

View File

@ -5,13 +5,16 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type CdpTestSuite struct { type CdpTestSuite struct {

View File

@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -4,13 +4,16 @@ import (
"errors" "errors"
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type DepositTestSuite struct { type DepositTestSuite struct {

View File

@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )
@ -141,7 +142,10 @@ func (k Keeper) RepayPrincipal(ctx sdk.Context, owner sdk.AccAddress, denom stri
// and remove the cdp and indexes from the store // and remove the cdp and indexes from the store
if cdp.Principal.IsZero() && cdp.AccumulatedFees.IsZero() { if cdp.Principal.IsZero() && cdp.AccumulatedFees.IsZero() {
k.ReturnCollateral(ctx, cdp) k.ReturnCollateral(ctx, cdp)
k.DeleteCDP(ctx, cdp) if err := k.DeleteCDP(ctx, cdp); err != nil {
return err
}
k.RemoveCdpOwnerIndex(ctx, cdp) k.RemoveCdpOwnerIndex(ctx, cdp)
// emit cdp close event // emit cdp close event

View File

@ -5,13 +5,16 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type DrawTestSuite struct { type DrawTestSuite struct {

View File

@ -3,6 +3,7 @@ package keeper
import ( import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )
@ -55,14 +56,27 @@ func (k Keeper) UpdateFeesForAllCdps(ctx sdk.Context, collateralDenom string) er
return false return false
} }
// mint debt coins to the cdp account // mint debt coins to the cdp account
k.MintDebtCoins(ctx, types.ModuleName, k.GetDebtDenom(ctx), newFees) err := k.MintDebtCoins(ctx, types.ModuleName, k.GetDebtDenom(ctx), newFees)
if err != nil {
iterationErr = err
return true
}
previousDebt := k.GetTotalPrincipal(ctx, collateralDenom, dp.Denom) previousDebt := k.GetTotalPrincipal(ctx, collateralDenom, dp.Denom)
newDebt := previousDebt.Add(newFees.Amount) newDebt := previousDebt.Add(newFees.Amount)
k.SetTotalPrincipal(ctx, collateralDenom, dp.Denom, newDebt) k.SetTotalPrincipal(ctx, collateralDenom, dp.Denom, newDebt)
// mint surplus coins divided between the liquidator and savings module accounts. // mint surplus coins divided between the liquidator and savings module accounts.
k.supplyKeeper.MintCoins(ctx, types.LiquidatorMacc, sdk.NewCoins(sdk.NewCoin(dp.Denom, newFeesSurplus))) err = k.supplyKeeper.MintCoins(ctx, types.LiquidatorMacc, sdk.NewCoins(sdk.NewCoin(dp.Denom, newFeesSurplus)))
k.supplyKeeper.MintCoins(ctx, types.SavingsRateMacc, sdk.NewCoins(sdk.NewCoin(dp.Denom, newFeesSavings))) if err != nil {
iterationErr = err
return true
}
err = k.supplyKeeper.MintCoins(ctx, types.SavingsRateMacc, sdk.NewCoins(sdk.NewCoin(dp.Denom, newFeesSavings)))
if err != nil {
iterationErr = err
return true
}
// now add the new fees fees to the accumulated fees for the cdp // now add the new fees fees to the accumulated fees for the cdp
cdp.AccumulatedFees = cdp.AccumulatedFees.Add(newFees) cdp.AccumulatedFees = cdp.AccumulatedFees.Add(newFees)
@ -71,7 +85,7 @@ func (k Keeper) UpdateFeesForAllCdps(ctx sdk.Context, collateralDenom string) er
cdp.FeesUpdated = ctx.BlockTime() cdp.FeesUpdated = ctx.BlockTime()
collateralToDebtRatio := k.CalculateCollateralToDebtRatio(ctx, cdp.Collateral, cdp.Principal.Add(cdp.AccumulatedFees)) collateralToDebtRatio := k.CalculateCollateralToDebtRatio(ctx, cdp.Collateral, cdp.Principal.Add(cdp.AccumulatedFees))
k.RemoveCdpCollateralRatioIndex(ctx, cdp.Collateral.Denom, cdp.ID, oldCollateralToDebtRatio) k.RemoveCdpCollateralRatioIndex(ctx, cdp.Collateral.Denom, cdp.ID, oldCollateralToDebtRatio)
err := k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio) err = k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
if err != nil { if err != nil {
iterationErr = err iterationErr = err
return true return true

View File

@ -6,11 +6,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper"
) )
type FeeTestSuite struct { type FeeTestSuite struct {

View File

@ -5,10 +5,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
tmtime "github.com/tendermint/tendermint/types/time"
) )
// Avoid cluttering test cases with long function names // Avoid cluttering test cases with long function names
@ -21,11 +22,11 @@ func NewPricefeedGenState(asset string, price sdk.Dec) app.GenesisState {
pfGenesis := pricefeed.GenesisState{ pfGenesis := pricefeed.GenesisState{
Params: pricefeed.Params{ Params: pricefeed.Params{
Markets: []pricefeed.Market{ Markets: []pricefeed.Market{
pricefeed.Market{MarketID: asset + ":usd", BaseAsset: asset, QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: asset + ":usd", BaseAsset: asset, QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
}, },
}, },
PostedPrices: []pricefeed.PostedPrice{ PostedPrices: []pricefeed.PostedPrice{
pricefeed.PostedPrice{ {
MarketID: asset + ":usd", MarketID: asset + ":usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: price, Price: price,
@ -77,18 +78,18 @@ func NewPricefeedGenStateMulti() app.GenesisState {
pfGenesis := pricefeed.GenesisState{ pfGenesis := pricefeed.GenesisState{
Params: pricefeed.Params{ Params: pricefeed.Params{
Markets: []pricefeed.Market{ Markets: []pricefeed.Market{
pricefeed.Market{MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
pricefeed.Market{MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
}, },
}, },
PostedPrices: []pricefeed.PostedPrice{ PostedPrices: []pricefeed.PostedPrice{
pricefeed.PostedPrice{ {
MarketID: "btc:usd", MarketID: "btc:usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: sdk.MustNewDecFromStr("8000.00"), Price: sdk.MustNewDecFromStr("8000.00"),
Expiry: time.Now().Add(1 * time.Hour), Expiry: time.Now().Add(1 * time.Hour),
}, },
pricefeed.PostedPrice{ {
MarketID: "xrp:usd", MarketID: "xrp:usd",
OracleAddress: sdk.AccAddress{}, OracleAddress: sdk.AccAddress{},
Price: sdk.MustNewDecFromStr("0.25"), Price: sdk.MustNewDecFromStr("0.25"),

View File

@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/subspace" "github.com/cosmos/cosmos-sdk/x/params/subspace"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -5,11 +5,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/exported" "github.com/cosmos/cosmos-sdk/x/auth/exported"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
// saving the result to a module level variable ensures the compiler doesn't optimize the test away // saving the result to a module level variable ensures the compiler doesn't optimize the test away

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -7,16 +7,19 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/simulation"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
pfkeeper "github.com/kava-labs/kava/x/pricefeed/keeper" pfkeeper "github.com/kava-labs/kava/x/pricefeed/keeper"
pftypes "github.com/kava-labs/kava/x/pricefeed/types" pftypes "github.com/kava-labs/kava/x/pricefeed/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
const ( const (

View File

@ -9,6 +9,7 @@ import (
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
auctiontypes "github.com/kava-labs/kava/x/auction/types" auctiontypes "github.com/kava-labs/kava/x/auction/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -3,13 +3,16 @@ package keeper_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time"
) )
type SavingsTestSuite struct { type SavingsTestSuite struct {

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )
@ -60,8 +61,7 @@ func (k Keeper) SeizeCollateral(ctx sdk.Context, cdp types.CDP) error {
// Delete CDP from state // Delete CDP from state
k.RemoveCdpOwnerIndex(ctx, cdp) k.RemoveCdpOwnerIndex(ctx, cdp)
k.RemoveCdpCollateralRatioIndex(ctx, cdp.Collateral.Denom, cdp.ID, oldCollateralToDebtRatio) k.RemoveCdpCollateralRatioIndex(ctx, cdp.Collateral.Denom, cdp.ID, oldCollateralToDebtRatio)
k.DeleteCDP(ctx, cdp) return k.DeleteCDP(ctx, cdp)
return nil
} }
// LiquidateCdps seizes collateral from all CDPs below the input liquidation ratio // LiquidateCdps seizes collateral from all CDPs below the input liquidation ratio

View File

@ -6,9 +6,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"

View File

@ -12,6 +12,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
sim "github.com/cosmos/cosmos-sdk/x/simulation" sim "github.com/cosmos/cosmos-sdk/x/simulation"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/cdp/client/cli" "github.com/kava-labs/kava/x/cdp/client/cli"

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/kv" "github.com/tendermint/tendermint/libs/kv"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"

View File

@ -10,6 +10,7 @@ import (
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/supply" "github.com/cosmos/cosmos-sdk/x/supply"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
"github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/cdp/types"
) )

View File

@ -3,9 +3,11 @@ package simulation_test
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/simulation"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/simulation"
) )
func TestShiftDec(t *testing.T) { func TestShiftDec(t *testing.T) {

View File

@ -6,6 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
pftypes "github.com/kava-labs/kava/x/pricefeed/types" pftypes "github.com/kava-labs/kava/x/pricefeed/types"
) )

View File

@ -140,7 +140,7 @@ func CollateralRatioKey(denomByte byte, cdpID uint64, ratio sdk.Dec) []byte {
// SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio // SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio
func SplitCollateralRatioKey(key []byte) (denom byte, cdpID uint64, ratio sdk.Dec) { func SplitCollateralRatioKey(key []byte) (denom byte, cdpID uint64, ratio sdk.Dec) {
cdpID = GetCdpIDFromBytes(key[len(key)-8 : len(key)]) cdpID = GetCdpIDFromBytes(key[len(key)-8:])
split := bytes.Split(key[:len(key)-8], sep) split := bytes.Split(key[:len(key)-8], sep)
denom = split[0][0] denom = split[0][0]

View File

@ -3,8 +3,10 @@ package types
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
) )

View File

@ -3,8 +3,9 @@ package types
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
var ( var (

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
) )

View File

@ -5,9 +5,11 @@ import (
"testing" "testing"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/cdp/types"
) )
type ParamsTestSuite struct { type ParamsTestSuite struct {

View File

@ -3,10 +3,10 @@ package types
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestSortableDecBytes(t *testing.T) { func TestSortableDecBytes(t *testing.T) {

View File

@ -2,6 +2,7 @@ package committee
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
) )

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -3,9 +3,10 @@ package cli_test
import ( import (
"testing" "testing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/committee/client/cli" "github.com/kava-labs/kava/x/committee/client/cli"
) )

View File

@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/kava-labs/kava/x/committee/types" "github.com/kava-labs/kava/x/committee/types"

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/committee/types" "github.com/kava-labs/kava/x/committee/types"
) )

View File

@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -4,10 +4,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -8,6 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -4,6 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/committee/types" "github.com/kava-labs/kava/x/committee/types"

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
sim "github.com/cosmos/cosmos-sdk/x/simulation" sim "github.com/cosmos/cosmos-sdk/x/simulation"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/committee/client/cli" "github.com/kava-labs/kava/x/committee/client/cli"

View File

@ -4,10 +4,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
@ -100,7 +102,7 @@ func (suite *ProposalHandlerTestSuite) TestProposalHandler_ChangeCommittee() {
{ {
name: "invalid title", name: "invalid title",
proposal: committee.NewCommitteeChangeProposal( proposal: committee.NewCommitteeChangeProposal(
"A Title That Is Much Too Long And Really Quite Unreasonable Given That It Is Trying To Fullfill The Roll Of An Acceptable Governance Proposal Title That Should Succinctly Communicate The Goal And Contents Of The Proposed Proposal To All Parties Involved", "A Title That Is Much Too Long And Really Quite Unreasonable Given That It Is Trying To Fulfill The Roll Of An Acceptable Governance Proposal Title That Should Succinctly Communicate The Goal And Contents Of The Proposed Proposal To All Parties Involved",
"A proposal description.", "A proposal description.",
suite.testGenesis.Committees[0], suite.testGenesis.Committees[0],
), ),
@ -177,7 +179,7 @@ func (suite *ProposalHandlerTestSuite) TestProposalHandler_DeleteCommittee() {
{ {
name: "invalid title", name: "invalid title",
proposal: committee.NewCommitteeDeleteProposal( proposal: committee.NewCommitteeDeleteProposal(
"A Title That Is Much Too Long And Really Quite Unreasonable Given That It Is Trying To Fullfill The Roll Of An Acceptable Governance Proposal Title That Should Succinctly Communicate The Goal And Contents Of The Proposed Proposal To All Parties Involved", "A Title That Is Much Too Long And Really Quite Unreasonable Given That It Is Trying To Fulfill The Roll Of An Acceptable Governance Proposal Title That Should Succinctly Communicate The Goal And Contents Of The Proposed Proposal To All Parties Involved",
"A proposal description.", "A proposal description.",
suite.testGenesis.Committees[1].ID, suite.testGenesis.Committees[1].ID,
), ),

View File

@ -2,6 +2,7 @@ package simulation
import ( import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/tendermint/tendermint/libs/kv" "github.com/tendermint/tendermint/libs/kv"
) )

View File

@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"time" "time"
yaml "gopkg.in/yaml.v2"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"gopkg.in/yaml.v2"
) )
const MaxCommitteeDescriptionLength int = 512 const MaxCommitteeDescriptionLength int = 512
@ -98,7 +99,7 @@ func (c Committee) Validate() error {
// PubProposal is the interface that all proposals must fulfill to be submitted to a committee. // PubProposal is the interface that all proposals must fulfill to be submitted to a committee.
// Proposal types can be created external to this module. For example a ParamChangeProposal, or CommunityPoolSpendProposal. // Proposal types can be created external to this module. For example a ParamChangeProposal, or CommunityPoolSpendProposal.
// It is pinned to the equivalent type in the gov module to create compatability between proposal types. // It is pinned to the equivalent type in the gov module to create compatibility between proposal types.
type PubProposal govtypes.Content type PubProposal govtypes.Content
// Proposal is an internal record of a governance proposal submitted to a committee. // Proposal is an internal record of a governance proposal submitted to a committee.

View File

@ -4,9 +4,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/suite"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/suite"
) )
var _ PubProposal = UnregisteredPubProposal{} var _ PubProposal = UnregisteredPubProposal{}
@ -161,7 +162,7 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
}, },
}}, }},
}, },
pubProposal: UnregisteredPubProposal{govtypes.TextProposal{"A Title", "A description."}}, pubProposal: UnregisteredPubProposal{govtypes.TextProposal{Title: "A Title", Description: "A description."}},
expectHasPermissions: false, expectHasPermissions: false,
}, },
} }

Some files were not shown because too many files have changed in this diff Show More