update x/genaccounts to match module spec (#4759)
This commit is contained in:
parent
bbb7113309
commit
e85a734a57
|
@ -0,0 +1 @@
|
||||||
|
#4758 update `x/genaccounts` to match module spec
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
bip39 "github.com/bartekn/go-bip39"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/client/input"
|
"github.com/cosmos/cosmos-sdk/client/input"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
|
@ -15,8 +17,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/cosmos/go-bip39"
|
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
"github.com/tendermint/tendermint/crypto/multisig"
|
"github.com/tendermint/tendermint/crypto/multisig"
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
|
@ -4,8 +4,9 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/input"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/input"
|
||||||
)
|
)
|
||||||
|
|
||||||
func importKeyCommand() *cobra.Command {
|
func importKeyCommand() *cobra.Command {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package keys
|
package keys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
func listKeysCmd() *cobra.Command {
|
func listKeysCmd() *cobra.Command {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/libs/bech32"
|
"github.com/tendermint/tendermint/libs/bech32"
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/client/input"
|
"github.com/cosmos/cosmos-sdk/client/input"
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -9,7 +9,6 @@ require (
|
||||||
github.com/fortytw2/leaktest v1.3.0 // indirect
|
github.com/fortytw2/leaktest v1.3.0 // indirect
|
||||||
github.com/gogo/protobuf v1.2.1
|
github.com/gogo/protobuf v1.2.1
|
||||||
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
|
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
|
||||||
github.com/golang/protobuf v1.3.0
|
|
||||||
github.com/gorilla/mux v1.7.0
|
github.com/gorilla/mux v1.7.0
|
||||||
github.com/gorilla/websocket v1.4.0 // indirect
|
github.com/gorilla/websocket v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.6
|
github.com/mattn/go-isatty v0.0.6
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
|
@ -14,10 +14,11 @@ import (
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,11 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||||
|
@ -52,37 +53,37 @@ func TestGetSimulationLog(t *testing.T) {
|
||||||
kvPairs []cmn.KVPair
|
kvPairs []cmn.KVPair
|
||||||
}{
|
}{
|
||||||
{auth.StoreKey, []cmn.KVPair{
|
{auth.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: auth.AddressStoreKey(delAddr1), Value: cdc.MustMarshalBinaryBare(auth.BaseAccount{})},
|
{Key: auth.AddressStoreKey(delAddr1), Value: cdc.MustMarshalBinaryBare(auth.BaseAccount{})},
|
||||||
cmn.KVPair{Key: auth.AddressStoreKey(delAddr1), Value: cdc.MustMarshalBinaryBare(auth.BaseAccount{})},
|
{Key: auth.AddressStoreKey(delAddr1), Value: cdc.MustMarshalBinaryBare(auth.BaseAccount{})},
|
||||||
}},
|
}},
|
||||||
{mint.StoreKey, []cmn.KVPair{
|
{mint.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: mint.MinterKey, Value: cdc.MustMarshalBinaryLengthPrefixed(mint.Minter{})},
|
{Key: mint.MinterKey, Value: cdc.MustMarshalBinaryLengthPrefixed(mint.Minter{})},
|
||||||
cmn.KVPair{Key: mint.MinterKey, Value: cdc.MustMarshalBinaryLengthPrefixed(mint.Minter{})},
|
{Key: mint.MinterKey, Value: cdc.MustMarshalBinaryLengthPrefixed(mint.Minter{})},
|
||||||
}},
|
}},
|
||||||
{staking.StoreKey, []cmn.KVPair{
|
{staking.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: staking.LastValidatorPowerKey, Value: valAddr1.Bytes()},
|
{Key: staking.LastValidatorPowerKey, Value: valAddr1.Bytes()},
|
||||||
cmn.KVPair{Key: staking.LastValidatorPowerKey, Value: valAddr1.Bytes()},
|
{Key: staking.LastValidatorPowerKey, Value: valAddr1.Bytes()},
|
||||||
}},
|
}},
|
||||||
{gov.StoreKey, []cmn.KVPair{
|
{gov.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: gov.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(gov.Vote{})},
|
{Key: gov.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(gov.Vote{})},
|
||||||
cmn.KVPair{Key: gov.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(gov.Vote{})},
|
{Key: gov.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(gov.Vote{})},
|
||||||
}},
|
}},
|
||||||
{distribution.StoreKey, []cmn.KVPair{
|
{distribution.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: distr.ProposerKey, Value: consAddr1.Bytes()},
|
{Key: distr.ProposerKey, Value: consAddr1.Bytes()},
|
||||||
cmn.KVPair{Key: distr.ProposerKey, Value: consAddr1.Bytes()},
|
{Key: distr.ProposerKey, Value: consAddr1.Bytes()},
|
||||||
}},
|
}},
|
||||||
{slashing.StoreKey, []cmn.KVPair{
|
{slashing.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: slashing.GetValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryLengthPrefixed(true)},
|
{Key: slashing.GetValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryLengthPrefixed(true)},
|
||||||
cmn.KVPair{Key: slashing.GetValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryLengthPrefixed(true)},
|
{Key: slashing.GetValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryLengthPrefixed(true)},
|
||||||
}},
|
}},
|
||||||
{supply.StoreKey, []cmn.KVPair{
|
{supply.StoreKey, []cmn.KVPair{
|
||||||
cmn.KVPair{Key: supply.SupplyKey, Value: cdc.MustMarshalBinaryLengthPrefixed(supply.NewSupply(sdk.Coins{}))},
|
{Key: supply.SupplyKey, Value: cdc.MustMarshalBinaryLengthPrefixed(supply.NewSupply(sdk.Coins{}))},
|
||||||
cmn.KVPair{Key: supply.SupplyKey, Value: cdc.MustMarshalBinaryLengthPrefixed(supply.NewSupply(sdk.Coins{}))},
|
{Key: supply.SupplyKey, Value: cdc.MustMarshalBinaryLengthPrefixed(supply.NewSupply(sdk.Coins{}))},
|
||||||
}},
|
}},
|
||||||
{"Empty", []cmn.KVPair{cmn.KVPair{}, cmn.KVPair{}}},
|
{"Empty", []cmn.KVPair{{}, {}}},
|
||||||
{"OtherStore", []cmn.KVPair{
|
{"OtherStore", []cmn.KVPair{
|
||||||
cmn.KVPair{Key: []byte("key"), Value: []byte("value")},
|
{Key: []byte("key"), Value: []byte("value")},
|
||||||
cmn.KVPair{Key: []byte("key"), Value: []byte("other_value")},
|
{Key: []byte("key"), Value: []byte("other_value")},
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockNodeQuerier struct {
|
type MockNodeQuerier struct {
|
||||||
|
|
|
@ -8,10 +8,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/libs/bech32"
|
"github.com/tendermint/tendermint/libs/bech32"
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||||
|
|
|
@ -4,9 +4,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package v0_36
|
package v0_36
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types"
|
"github.com/cosmos/cosmos-sdk/types"
|
||||||
v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_34"
|
v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_34"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,9 +4,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -123,8 +123,8 @@ func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64,
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
types.ModuleName: nil,
|
types.ModuleName: nil,
|
||||||
staking.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
staking.BondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package v0_36
|
package v0_36
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types"
|
"github.com/cosmos/cosmos-sdk/types"
|
||||||
v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34"
|
v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34"
|
||||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,9 +5,10 @@ import (
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
|
||||||
|
"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/distribution/types"
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
// nolint
|
||||||
|
// autogenerated code using github.com/rigelrozanski/multitool
|
||||||
|
// aliases generated for the following subdirectories:
|
||||||
|
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types
|
||||||
|
package genaccounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ModuleName = types.ModuleName
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// functions aliases
|
||||||
|
NewGenesisAccountRaw = types.NewGenesisAccountRaw
|
||||||
|
NewGenesisAccount = types.NewGenesisAccount
|
||||||
|
NewGenesisAccountI = types.NewGenesisAccountI
|
||||||
|
GetGenesisStateFromAppState = types.GetGenesisStateFromAppState
|
||||||
|
SetGenesisStateInAppState = types.SetGenesisStateInAppState
|
||||||
|
ValidateGenesis = types.ValidateGenesis
|
||||||
|
|
||||||
|
// variable aliases
|
||||||
|
ModuleCdc = types.ModuleCdc
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
GenesisAccount = types.GenesisAccount
|
||||||
|
GenesisAccounts = types.GenesisAccounts
|
||||||
|
GenesisState = types.GenesisState
|
||||||
|
)
|
|
@ -1,14 +0,0 @@
|
||||||
package genaccounts
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
)
|
|
||||||
|
|
||||||
// generic sealed codec to be used throughout this module
|
|
||||||
var moduleCdc *codec.Codec
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
moduleCdc = codec.New()
|
|
||||||
codec.RegisterCrypto(moduleCdc)
|
|
||||||
moduleCdc.Seal()
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package genaccounts
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
)
|
|
||||||
|
|
||||||
// expected account keeper
|
|
||||||
type AccountKeeper interface {
|
|
||||||
NewAccount(sdk.Context, auth.Account) auth.Account
|
|
||||||
SetAccount(sdk.Context, auth.Account)
|
|
||||||
IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool))
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package genaccounts
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
)
|
|
||||||
|
|
||||||
// export genesis for all accounts
|
|
||||||
func ExportGenesis(ctx sdk.Context, accountKeeper AccountKeeper) GenesisState {
|
|
||||||
|
|
||||||
// iterate to get the accounts
|
|
||||||
accounts := []GenesisAccount{}
|
|
||||||
accountKeeper.IterateAccounts(ctx,
|
|
||||||
func(acc auth.Account) (stop bool) {
|
|
||||||
account, err := NewGenesisAccountI(acc)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
accounts = append(accounts, account)
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return accounts
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package genaccounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
|
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitGenesis initializes accounts and deliver genesis transactions
|
||||||
|
func InitGenesis(ctx sdk.Context, _ *codec.Codec, accountKeeper types.AccountKeeper, genesisState GenesisState) {
|
||||||
|
genesisState.Sanitize()
|
||||||
|
|
||||||
|
// load the accounts
|
||||||
|
for _, gacc := range genesisState {
|
||||||
|
acc := gacc.ToAccount()
|
||||||
|
acc = accountKeeper.NewAccount(ctx, acc) // set account number
|
||||||
|
accountKeeper.SetAccount(ctx, acc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportGenesis exports genesis for all accounts
|
||||||
|
func ExportGenesis(ctx sdk.Context, accountKeeper types.AccountKeeper) GenesisState {
|
||||||
|
|
||||||
|
// iterate to get the accounts
|
||||||
|
accounts := []GenesisAccount{}
|
||||||
|
accountKeeper.IterateAccounts(ctx,
|
||||||
|
func(acc authexported.Account) (stop bool) {
|
||||||
|
account, err := NewGenesisAccountI(acc)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
accounts = append(accounts, account)
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return accounts
|
||||||
|
}
|
|
@ -1,18 +0,0 @@
|
||||||
package genaccounts
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// initialize accounts and deliver genesis transactions
|
|
||||||
func InitGenesis(ctx sdk.Context, _ *codec.Codec, accountKeeper AccountKeeper, genesisState GenesisState) {
|
|
||||||
genesisState.Sanitize()
|
|
||||||
|
|
||||||
// load the accounts
|
|
||||||
for _, gacc := range genesisState {
|
|
||||||
acc := gacc.ToAccount()
|
|
||||||
acc = accountKeeper.NewAccount(ctx, acc) // set account number
|
|
||||||
accountKeeper.SetAccount(ctx, acc)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package genaccounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ModuleName is "accounts"
|
||||||
|
const ModuleName = "accounts"
|
||||||
|
|
||||||
|
// ModuleCdc - generic sealed codec to be used throughout this module
|
||||||
|
var ModuleCdc *codec.Codec
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
ModuleCdc = codec.New()
|
||||||
|
codec.RegisterCrypto(ModuleCdc)
|
||||||
|
ModuleCdc.Seal()
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package genaccounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccountKeeper defines the expected account keeper (noalias)
|
||||||
|
type AccountKeeper interface {
|
||||||
|
NewAccount(sdk.Context, authexported.Account) authexported.Account
|
||||||
|
SetAccount(sdk.Context, authexported.Account)
|
||||||
|
IterateAccounts(ctx sdk.Context, process func(authexported.Account) (stop bool))
|
||||||
|
}
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"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"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -71,7 +71,7 @@ func NewGenesisAccountRaw(address sdk.AccAddress, coins,
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGenesisAccount creates a GenesisAccount instance from a BaseAccount.
|
// NewGenesisAccount creates a GenesisAccount instance from a BaseAccount.
|
||||||
func NewGenesisAccount(acc *auth.BaseAccount) GenesisAccount {
|
func NewGenesisAccount(acc *authtypes.BaseAccount) GenesisAccount {
|
||||||
return GenesisAccount{
|
return GenesisAccount{
|
||||||
Address: acc.Address,
|
Address: acc.Address,
|
||||||
Coins: acc.Coins,
|
Coins: acc.Coins,
|
||||||
|
@ -109,21 +109,21 @@ func NewGenesisAccountI(acc authexported.Account) (GenesisAccount, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToAccount converts a GenesisAccount to an Account interface
|
// ToAccount converts a GenesisAccount to an Account interface
|
||||||
func (ga *GenesisAccount) ToAccount() auth.Account {
|
func (ga *GenesisAccount) ToAccount() authexported.Account {
|
||||||
bacc := auth.NewBaseAccount(ga.Address, ga.Coins.Sort(), nil, ga.AccountNumber, ga.Sequence)
|
bacc := authtypes.NewBaseAccount(ga.Address, ga.Coins.Sort(), nil, ga.AccountNumber, ga.Sequence)
|
||||||
|
|
||||||
// vesting accounts
|
// vesting accounts
|
||||||
if !ga.OriginalVesting.IsZero() {
|
if !ga.OriginalVesting.IsZero() {
|
||||||
baseVestingAcc := auth.NewBaseVestingAccount(
|
baseVestingAcc := authtypes.NewBaseVestingAccount(
|
||||||
bacc, ga.OriginalVesting, ga.DelegatedFree,
|
bacc, ga.OriginalVesting, ga.DelegatedFree,
|
||||||
ga.DelegatedVesting, ga.EndTime,
|
ga.DelegatedVesting, ga.EndTime,
|
||||||
)
|
)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case ga.StartTime != 0 && ga.EndTime != 0:
|
case ga.StartTime != 0 && ga.EndTime != 0:
|
||||||
return auth.NewContinuousVestingAccountRaw(baseVestingAcc, ga.StartTime)
|
return authtypes.NewContinuousVestingAccountRaw(baseVestingAcc, ga.StartTime)
|
||||||
case ga.EndTime != 0:
|
case ga.EndTime != 0:
|
||||||
return auth.NewDelayedVestingAccountRaw(baseVestingAcc)
|
return authtypes.NewDelayedVestingAccountRaw(baseVestingAcc)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("invalid genesis vesting account: %+v", ga))
|
panic(fmt.Sprintf("invalid genesis vesting account: %+v", ga))
|
||||||
}
|
}
|
||||||
|
@ -137,10 +137,10 @@ func (ga *GenesisAccount) ToAccount() auth.Account {
|
||||||
return bacc
|
return bacc
|
||||||
}
|
}
|
||||||
|
|
||||||
//___________________________________
|
// GenesisAccounts defines a set of genesis account
|
||||||
type GenesisAccounts []GenesisAccount
|
type GenesisAccounts []GenesisAccount
|
||||||
|
|
||||||
// genesis accounts contain an address
|
// Contains checks if a set of genesis accounts contain an address
|
||||||
func (gaccs GenesisAccounts) Contains(acc sdk.AccAddress) bool {
|
func (gaccs GenesisAccounts) Contains(acc sdk.AccAddress) bool {
|
||||||
for _, gacc := range gaccs {
|
for _, gacc := range gaccs {
|
||||||
if gacc.Address.Equals(acc) {
|
if gacc.Address.Equals(acc) {
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,22 +70,22 @@ func TestToAccount(t *testing.T) {
|
||||||
addr := sdk.AccAddress(priv.PubKey().Address())
|
addr := sdk.AccAddress(priv.PubKey().Address())
|
||||||
|
|
||||||
// base account
|
// base account
|
||||||
authAcc := auth.NewBaseAccountWithAddress(addr)
|
authAcc := authtypes.NewBaseAccountWithAddress(addr)
|
||||||
authAcc.SetCoins(sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150)))
|
authAcc.SetCoins(sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150)))
|
||||||
genAcc := NewGenesisAccount(&authAcc)
|
genAcc := NewGenesisAccount(&authAcc)
|
||||||
acc := genAcc.ToAccount()
|
acc := genAcc.ToAccount()
|
||||||
require.IsType(t, &auth.BaseAccount{}, acc)
|
require.IsType(t, &authtypes.BaseAccount{}, acc)
|
||||||
require.Equal(t, &authAcc, acc.(*auth.BaseAccount))
|
require.Equal(t, &authAcc, acc.(*authtypes.BaseAccount))
|
||||||
|
|
||||||
// vesting account
|
// vesting account
|
||||||
vacc := auth.NewContinuousVestingAccount(
|
vacc := authtypes.NewContinuousVestingAccount(
|
||||||
&authAcc, time.Now().Unix(), time.Now().Add(24*time.Hour).Unix(),
|
&authAcc, time.Now().Unix(), time.Now().Add(24*time.Hour).Unix(),
|
||||||
)
|
)
|
||||||
genAcc, err := NewGenesisAccountI(vacc)
|
genAcc, err := NewGenesisAccountI(vacc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
acc = genAcc.ToAccount()
|
acc = genAcc.ToAccount()
|
||||||
require.IsType(t, &auth.ContinuousVestingAccount{}, acc)
|
require.IsType(t, &authtypes.ContinuousVestingAccount{}, acc)
|
||||||
require.Equal(t, vacc, acc.(*auth.ContinuousVestingAccount))
|
require.Equal(t, vacc, acc.(*authtypes.ContinuousVestingAccount))
|
||||||
|
|
||||||
// module account
|
// module account
|
||||||
macc := supply.NewEmptyModuleAccount("mint", supply.Minter)
|
macc := supply.NewEmptyModuleAccount("mint", supply.Minter)
|
|
@ -9,10 +9,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State to Unmarshal
|
// GenesisState is a wrapper for GenAccounts
|
||||||
type GenesisState GenesisAccounts
|
type GenesisState GenesisAccounts
|
||||||
|
|
||||||
// get the genesis state from the expected app state
|
// GetGenesisStateFromAppState gets the genesis state from the expected app state
|
||||||
func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState {
|
func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState {
|
||||||
var genesisState GenesisState
|
var genesisState GenesisState
|
||||||
if appState[ModuleName] != nil {
|
if appState[ModuleName] != nil {
|
||||||
|
@ -22,7 +22,7 @@ func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawM
|
||||||
return genesisState
|
return genesisState
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the genesis state within the expected app state
|
// SetGenesisStateInAppState sets the genesis state within the expected app state
|
||||||
func SetGenesisStateInAppState(cdc *codec.Codec,
|
func SetGenesisStateInAppState(cdc *codec.Codec,
|
||||||
appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage {
|
appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage {
|
||||||
|
|
|
@ -3,16 +3,17 @@ package genaccounts
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSanitize(t *testing.T) {
|
func TestSanitize(t *testing.T) {
|
||||||
|
|
||||||
addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
||||||
authAcc1 := auth.NewBaseAccountWithAddress(addr1)
|
authAcc1 := authtypes.NewBaseAccountWithAddress(addr1)
|
||||||
authAcc1.SetCoins(sdk.Coins{
|
authAcc1.SetCoins(sdk.Coins{
|
||||||
sdk.NewInt64Coin("bcoin", 150),
|
sdk.NewInt64Coin("bcoin", 150),
|
||||||
sdk.NewInt64Coin("acoin", 150),
|
sdk.NewInt64Coin("acoin", 150),
|
||||||
|
@ -21,7 +22,7 @@ func TestSanitize(t *testing.T) {
|
||||||
genAcc1 := NewGenesisAccount(&authAcc1)
|
genAcc1 := NewGenesisAccount(&authAcc1)
|
||||||
|
|
||||||
addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
||||||
authAcc2 := auth.NewBaseAccountWithAddress(addr2)
|
authAcc2 := authtypes.NewBaseAccountWithAddress(addr2)
|
||||||
authAcc2.SetCoins(sdk.Coins{
|
authAcc2.SetCoins(sdk.Coins{
|
||||||
sdk.NewInt64Coin("acoin", 150),
|
sdk.NewInt64Coin("acoin", 150),
|
||||||
sdk.NewInt64Coin("bcoin", 150),
|
sdk.NewInt64Coin("bcoin", 150),
|
||||||
|
@ -50,7 +51,7 @@ var (
|
||||||
|
|
||||||
// require duplicate accounts fails validation
|
// require duplicate accounts fails validation
|
||||||
func TestValidateGenesisDuplicateAccounts(t *testing.T) {
|
func TestValidateGenesisDuplicateAccounts(t *testing.T) {
|
||||||
acc1 := auth.NewBaseAccountWithAddress(sdk.AccAddress(addr1))
|
acc1 := authtypes.NewBaseAccountWithAddress(sdk.AccAddress(addr1))
|
||||||
acc1.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
acc1.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
||||||
|
|
||||||
genAccs := make([]GenesisAccount, 2)
|
genAccs := make([]GenesisAccount, 2)
|
||||||
|
@ -64,9 +65,9 @@ func TestValidateGenesisDuplicateAccounts(t *testing.T) {
|
||||||
|
|
||||||
// require invalid vesting account fails validation (invalid end time)
|
// require invalid vesting account fails validation (invalid end time)
|
||||||
func TestValidateGenesisInvalidAccounts(t *testing.T) {
|
func TestValidateGenesisInvalidAccounts(t *testing.T) {
|
||||||
acc1 := auth.NewBaseAccountWithAddress(sdk.AccAddress(addr1))
|
acc1 := authtypes.NewBaseAccountWithAddress(sdk.AccAddress(addr1))
|
||||||
acc1.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
acc1.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
||||||
acc2 := auth.NewBaseAccountWithAddress(sdk.AccAddress(addr2))
|
acc2 := authtypes.NewBaseAccountWithAddress(sdk.AccAddress(addr2))
|
||||||
acc2.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
acc2.Coins = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 150))
|
||||||
|
|
||||||
genAccs := make([]GenesisAccount, 2)
|
genAccs := make([]GenesisAccount, 2)
|
|
@ -1,14 +1,16 @@
|
||||||
package v0_36
|
package v0_36
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types"
|
"github.com/cosmos/cosmos-sdk/types"
|
||||||
v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34"
|
v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34"
|
||||||
v034accounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_34"
|
v034accounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_34"
|
||||||
v034gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v0_34"
|
v034gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v0_34"
|
||||||
v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_34"
|
v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_34"
|
||||||
"github.com/tendermint/tendermint/crypto"
|
|
||||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,8 @@ 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/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||||
|
types "github.com/cosmos/cosmos-sdk/x/genaccounts/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -20,9 +21,6 @@ var (
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// module name
|
|
||||||
const ModuleName = "accounts"
|
|
||||||
|
|
||||||
// app module basics object
|
// app module basics object
|
||||||
type AppModuleBasic struct{}
|
type AppModuleBasic struct{}
|
||||||
|
|
||||||
|
@ -36,13 +34,13 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {}
|
||||||
|
|
||||||
// default genesis state
|
// default genesis state
|
||||||
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
|
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
|
||||||
return moduleCdc.MustMarshalJSON(GenesisState{})
|
return ModuleCdc.MustMarshalJSON(GenesisState{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// module validate genesis
|
// module validate genesis
|
||||||
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
|
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
|
||||||
var data GenesisState
|
var data GenesisState
|
||||||
err := moduleCdc.UnmarshalJSON(bz, &data)
|
err := ModuleCdc.UnmarshalJSON(bz, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -62,7 +60,7 @@ func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command { return nil }
|
||||||
// iterate the genesis accounts and perform an operation at each of them
|
// iterate the genesis accounts and perform an operation at each of them
|
||||||
// - to used by other modules
|
// - to used by other modules
|
||||||
func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[string]json.RawMessage,
|
func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[string]json.RawMessage,
|
||||||
iterateFn func(auth.Account) (stop bool)) {
|
iterateFn func(exported.Account) (stop bool)) {
|
||||||
|
|
||||||
genesisState := GetGenesisStateFromAppState(cdc, appGenesis)
|
genesisState := GetGenesisStateFromAppState(cdc, appGenesis)
|
||||||
for _, genAcc := range genesisState {
|
for _, genAcc := range genesisState {
|
||||||
|
@ -77,11 +75,11 @@ func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[st
|
||||||
// app module
|
// app module
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
accountKeeper AccountKeeper
|
accountKeeper types.AccountKeeper
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAppModule creates a new AppModule object
|
// NewAppModule creates a new AppModule object
|
||||||
func NewAppModule(accountKeeper AccountKeeper) module.AppModule {
|
func NewAppModule(accountKeeper types.AccountKeeper) module.AppModule {
|
||||||
|
|
||||||
return module.NewGenesisOnlyAppModule(AppModule{
|
return module.NewGenesisOnlyAppModule(AppModule{
|
||||||
AppModuleBasic: AppModuleBasic{},
|
AppModuleBasic: AppModuleBasic{},
|
||||||
|
@ -92,13 +90,13 @@ func NewAppModule(accountKeeper AccountKeeper) module.AppModule {
|
||||||
// module init-genesis
|
// module init-genesis
|
||||||
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
|
||||||
var genesisState GenesisState
|
var genesisState GenesisState
|
||||||
moduleCdc.MustUnmarshalJSON(data, &genesisState)
|
ModuleCdc.MustUnmarshalJSON(data, &genesisState)
|
||||||
InitGenesis(ctx, moduleCdc, am.accountKeeper, genesisState)
|
InitGenesis(ctx, ModuleCdc, am.accountKeeper, genesisState)
|
||||||
return []abci.ValidatorUpdate{}
|
return []abci.ValidatorUpdate{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// module export genesis
|
// module export genesis
|
||||||
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
|
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
|
||||||
gs := ExportGenesis(ctx, am.accountKeeper)
|
gs := ExportGenesis(ctx, am.accountKeeper)
|
||||||
return moduleCdc.MustMarshalJSON(gs)
|
return ModuleCdc.MustMarshalJSON(gs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@ package genutil
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
|
||||||
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"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -4,9 +4,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ func getMockApp(t *testing.T, numGenAccs int, genState GenesisState, genAccs []a
|
||||||
bk := bank.NewBaseKeeper(mApp.AccountKeeper, mApp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
bk := bank.NewBaseKeeper(mApp.AccountKeeper, mApp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
||||||
|
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
types.ModuleName: []string{supply.Burner},
|
types.ModuleName: {supply.Burner},
|
||||||
staking.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
staking.BondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
||||||
sk := staking.NewKeeper(mApp.Cdc, keyStaking, tKeyStaking, supplyKeeper, pk.Subspace(staking.DefaultParamspace), staking.DefaultCodespace)
|
sk := staking.NewKeeper(mApp.Cdc, keyStaking, tKeyStaking, supplyKeeper, pk.Subspace(staking.DefaultParamspace), staking.DefaultCodespace)
|
||||||
|
|
|
@ -4,9 +4,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addr = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
var addr = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
|
||||||
|
|
|
@ -59,9 +59,9 @@ func newTestInput(t *testing.T) testInput {
|
||||||
bankKeeper := bank.NewBaseKeeper(accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
bankKeeper := bank.NewBaseKeeper(accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
types.ModuleName: []string{supply.Minter},
|
types.ModuleName: {supply.Minter},
|
||||||
staking.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
staking.BondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(types.ModuleCdc, keySupply, accountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(types.ModuleCdc, keySupply, accountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
||||||
supplyKeeper.SetSupply(ctx, supply.NewSupply(sdk.Coins{}))
|
supplyKeeper.SetSupply(ctx, supply.NewSupply(sdk.Coins{}))
|
||||||
|
|
|
@ -40,8 +40,8 @@ func getMockApp(t *testing.T) (*mock.App, staking.Keeper, Keeper) {
|
||||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountKeeper, mapp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
bankKeeper := bank.NewBaseKeeper(mapp.AccountKeeper, mapp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
staking.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
staking.BondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(mapp.Cdc, keySupply, mapp.AccountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(mapp.Cdc, keySupply, mapp.AccountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
||||||
stakingKeeper := staking.NewKeeper(mapp.Cdc, keyStaking, tkeyStaking, supplyKeeper, mapp.ParamsKeeper.Subspace(staking.DefaultParamspace), staking.DefaultCodespace)
|
stakingKeeper := staking.NewKeeper(mapp.Cdc, keyStaking, tkeyStaking, supplyKeeper, mapp.ParamsKeeper.Subspace(staking.DefaultParamspace), staking.DefaultCodespace)
|
||||||
|
|
|
@ -26,7 +26,6 @@ func (k Keeper) SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress
|
||||||
store.Set(types.GetValidatorSigningInfoKey(address), bz)
|
store.Set(types.GetValidatorSigningInfoKey(address), bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IterateValidatorSigningInfos iterates over the stored ValidatorSigningInfo
|
// IterateValidatorSigningInfos iterates over the stored ValidatorSigningInfo
|
||||||
func (k Keeper) IterateValidatorSigningInfos(ctx sdk.Context,
|
func (k Keeper) IterateValidatorSigningInfos(ctx sdk.Context,
|
||||||
handler func(address sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool)) {
|
handler func(address sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool)) {
|
||||||
|
|
|
@ -82,8 +82,8 @@ func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Kee
|
||||||
bk := bank.NewBaseKeeper(accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
bk := bank.NewBaseKeeper(accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
staking.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
staking.BondedPoolName: []string{supply.Burner, supply.Staking},
|
staking.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) {
|
||||||
bankKeeper := bank.NewBaseKeeper(mApp.AccountKeeper, mApp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
bankKeeper := bank.NewBaseKeeper(mApp.AccountKeeper, mApp.ParamsKeeper.Subspace(bank.DefaultParamspace), bank.DefaultCodespace)
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
types.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
types.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
types.BondedPoolName: []string{supply.Burner, supply.Staking},
|
types.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, bankKeeper, supply.DefaultCodespace, maccPerms)
|
||||||
keeper := NewKeeper(mApp.Cdc, keyStaking, tkeyStaking, supplyKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace)
|
keeper := NewKeeper(mApp.Cdc, keyStaking, tkeyStaking, supplyKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package exported
|
package exported
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DelegationI delegation bond for a delegated proof of stake system
|
// DelegationI delegation bond for a delegated proof of stake system
|
||||||
|
|
|
@ -126,8 +126,8 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context
|
||||||
|
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
auth.FeeCollectorName: nil,
|
auth.FeeCollectorName: nil,
|
||||||
types.NotBondedPoolName: []string{supply.Burner, supply.Staking},
|
types.NotBondedPoolName: {supply.Burner, supply.Staking},
|
||||||
types.BondedPoolName: []string{supply.Burner, supply.Staking},
|
types.BondedPoolName: {supply.Burner, supply.Staking},
|
||||||
}
|
}
|
||||||
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bk, supply.DefaultCodespace, maccPerms)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"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"
|
||||||
|
|
|
@ -4,13 +4,14 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"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/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/x/supply/internal/types"
|
"github.com/cosmos/cosmos-sdk/x/supply/internal/types"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetQueryCmd returns the cli query commands for this module
|
// GetQueryCmd returns the cli query commands for this module
|
||||||
|
|
|
@ -80,10 +80,10 @@ func createTestInput(t *testing.T, isCheckTx bool, initPower int64, nAccs int64)
|
||||||
|
|
||||||
maccPerms := map[string][]string{
|
maccPerms := map[string][]string{
|
||||||
holder: nil,
|
holder: nil,
|
||||||
types.Minter: []string{types.Minter},
|
types.Minter: {types.Minter},
|
||||||
types.Burner: []string{types.Burner},
|
types.Burner: {types.Burner},
|
||||||
multiPerm: []string{types.Minter, types.Burner, types.Staking},
|
multiPerm: {types.Minter, types.Burner, types.Staking},
|
||||||
randomPerm: []string{"random"},
|
randomPerm: {"random"},
|
||||||
}
|
}
|
||||||
keeper := NewKeeper(cdc, keySupply, ak, bk, DefaultCodespace, maccPerms)
|
keeper := NewKeeper(cdc, keySupply, ak, bk, DefaultCodespace, maccPerms)
|
||||||
totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, valTokens.MulRaw(nAccs)))
|
totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, valTokens.MulRaw(nAccs)))
|
||||||
|
|
|
@ -4,9 +4,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,9 @@ package types
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Supply represents a struct that passively keeps track of the total supply amounts in the network
|
// Supply represents a struct that passively keeps track of the total supply amounts in the network
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue