refactor(types,client,simapp): remove some address String() calls (#21455)
This commit is contained in:
+34
-16
@@ -18,6 +18,7 @@ import (
|
||||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
clienthelpers "cosmossdk.io/client/v2/helpers"
|
||||
coreaddress "cosmossdk.io/core/address"
|
||||
corestore "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
@@ -214,6 +215,11 @@ func NewSimApp(
|
||||
signingCtx := interfaceRegistry.SigningContext()
|
||||
txConfig := authtx.NewTxConfig(appCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes)
|
||||
|
||||
govModuleAddr, err := signingCtx.AddressCodec().BytesToString(authtypes.NewModuleAddress(govtypes.ModuleName))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := signingCtx.Validate(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -287,7 +293,7 @@ func NewSimApp(
|
||||
cometService := runtime.NewContextAwareCometInfoService()
|
||||
|
||||
// set the BaseApp's parameter store
|
||||
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), logger.With(log.ModuleKey, "x/consensus")), authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), logger.With(log.ModuleKey, "x/consensus")), govModuleAddr)
|
||||
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
|
||||
|
||||
// add keepers
|
||||
@@ -312,14 +318,18 @@ func NewSimApp(
|
||||
}
|
||||
app.AccountsKeeper = accountsKeeper
|
||||
|
||||
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger.With(log.ModuleKey, "x/auth")), appCodec, authtypes.ProtoBaseAccount, accountsKeeper, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger.With(log.ModuleKey, "x/auth")), appCodec, authtypes.ProtoBaseAccount, accountsKeeper, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, govModuleAddr)
|
||||
|
||||
blockedAddrs, err := BlockedAddresses(signingCtx.AddressCodec())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger.With(log.ModuleKey, "x/bank")),
|
||||
appCodec,
|
||||
app.AuthKeeper,
|
||||
BlockedAddresses(),
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
blockedAddrs,
|
||||
govModuleAddr,
|
||||
)
|
||||
|
||||
// optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper)
|
||||
@@ -350,20 +360,20 @@ func NewSimApp(
|
||||
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
|
||||
app.AuthKeeper,
|
||||
app.BankKeeper,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
govModuleAddr,
|
||||
signingCtx.ValidatorAddressCodec(),
|
||||
authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
|
||||
cometService,
|
||||
)
|
||||
|
||||
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger.With(log.ModuleKey, "x/mint")), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger.With(log.ModuleKey, "x/mint")), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, govModuleAddr)
|
||||
|
||||
app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, govModuleAddr)
|
||||
|
||||
app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, govModuleAddr)
|
||||
|
||||
app.SlashingKeeper = slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")),
|
||||
appCodec, legacyAmino, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
appCodec, legacyAmino, app.StakingKeeper, govModuleAddr,
|
||||
)
|
||||
|
||||
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant")), appCodec, app.AuthKeeper)
|
||||
@@ -374,7 +384,7 @@ func NewSimApp(
|
||||
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
|
||||
)
|
||||
|
||||
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[circuittypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit")), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
|
||||
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[circuittypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit")), appCodec, govModuleAddr, app.AuthKeeper.AddressCodec())
|
||||
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
|
||||
|
||||
app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), appCodec, app.AuthKeeper)
|
||||
@@ -396,7 +406,7 @@ func NewSimApp(
|
||||
}
|
||||
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
||||
// set the governance module account as the authority for conducting upgrades
|
||||
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr)
|
||||
|
||||
// Register the proposal types
|
||||
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
|
||||
@@ -408,7 +418,7 @@ func NewSimApp(
|
||||
Example of setting gov params:
|
||||
govConfig.MaxMetadataLen = 10000
|
||||
*/
|
||||
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, govModuleAddr)
|
||||
|
||||
// Set legacy router for backwards compatibility with gov v1beta1
|
||||
govKeeper.SetLegacyRouter(govRouter)
|
||||
@@ -823,14 +833,22 @@ func GetMaccPerms() map[string][]string {
|
||||
}
|
||||
|
||||
// BlockedAddresses returns all the app's blocked account addresses.
|
||||
func BlockedAddresses() map[string]bool {
|
||||
func BlockedAddresses(ac coreaddress.Codec) (map[string]bool, error) {
|
||||
modAccAddrs := make(map[string]bool)
|
||||
for acc := range GetMaccPerms() {
|
||||
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
|
||||
addr, err := ac.BytesToString(authtypes.NewModuleAddress(acc))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
modAccAddrs[addr] = true
|
||||
}
|
||||
|
||||
// allow the following addresses to receive funds
|
||||
delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
addr, err := ac.BytesToString(authtypes.NewModuleAddress(govtypes.ModuleName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
delete(modAccAddrs, addr)
|
||||
|
||||
return modAccAddrs
|
||||
return modAccAddrs, nil
|
||||
}
|
||||
|
||||
+5
-2
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
|
||||
clienthelpers "cosmossdk.io/client/v2/helpers"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/legacy"
|
||||
corestore "cosmossdk.io/core/store"
|
||||
@@ -370,7 +371,9 @@ func GetMaccPerms() map[string][]string {
|
||||
}
|
||||
|
||||
// BlockedAddresses returns all the app's blocked account addresses.
|
||||
func BlockedAddresses() map[string]bool {
|
||||
// This function takes an address.Codec parameter to maintain compatibility
|
||||
// with the signature of the same function in appV1.
|
||||
func BlockedAddresses(_ address.Codec) (map[string]bool, error) {
|
||||
result := make(map[string]bool)
|
||||
|
||||
if len(blockAccAddrs) > 0 {
|
||||
@@ -383,5 +386,5 @@ func BlockedAddresses() map[string]bool {
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
return result, nil
|
||||
}
|
||||
|
||||
+6
-4
@@ -51,10 +51,12 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
|
||||
AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()),
|
||||
})
|
||||
|
||||
// BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app di.
|
||||
for acc := range BlockedAddresses() {
|
||||
// BlockedAddresses returns a map of addresses in app v1 and a map of modules names in app di.
|
||||
blockedAddrs, err := BlockedAddresses(app.interfaceRegistry.SigningContext().AddressCodec())
|
||||
require.NoError(t, err)
|
||||
for acc := range blockedAddrs {
|
||||
var addr sdk.AccAddress
|
||||
if modAddr, err := sdk.AccAddressFromBech32(acc); err == nil {
|
||||
if modAddr, err := app.InterfaceRegistry().SigningContext().AddressCodec().StringToBytes(acc); err == nil {
|
||||
addr = modAddr
|
||||
} else {
|
||||
addr = app.AuthKeeper.GetModuleAddress(acc)
|
||||
@@ -68,7 +70,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
|
||||
}
|
||||
|
||||
// finalize block so we have CheckTx state set
|
||||
_, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Height: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
+24
-6
@@ -64,7 +64,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
allowedAddrsMap := make(map[string]bool)
|
||||
|
||||
for _, addr := range jailAllowedAddrs {
|
||||
_, err := sdk.ValAddressFromBech32(addr)
|
||||
_, err := app.InterfaceRegistry().SigningContext().ValidatorAddressCodec().StringToBytes(addr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -93,8 +93,15 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
}
|
||||
|
||||
for _, delegation := range dels {
|
||||
valAddr:= sdk.MustValAddressFromBech32(delegation.ValidatorAddress)
|
||||
delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress)
|
||||
valAddr, err := app.InterfaceRegistry().SigningContext().ValidatorAddressCodec().StringToBytes(delegation.ValidatorAddress)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
delAddr, err := app.InterfaceRegistry().SigningContext().AddressCodec().StringToBytes(delegation.DelegatorAddress)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr)
|
||||
}
|
||||
@@ -146,8 +153,14 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
|
||||
// reinitialize all delegations
|
||||
for _, del := range dels {
|
||||
valAddr := sdk.MustValAddressFromBech32(del.ValidatorAddress)
|
||||
delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress)
|
||||
valAddr, err := app.InterfaceRegistry().SigningContext().ValidatorAddressCodec().StringToBytes(del.ValidatorAddress)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
delAddr, err := app.InterfaceRegistry().SigningContext().AddressCodec().StringToBytes(del.DelegatorAddress)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil {
|
||||
// never called as BeforeDelegationCreated always returns nil
|
||||
@@ -211,8 +224,13 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
panic("expected validator, not found")
|
||||
}
|
||||
|
||||
valAddr, err := app.StakingKeeper.ValidatorAddressCodec().BytesToString(addr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
validator.UnbondingHeight = 0
|
||||
if applyAllowedAddrs && !allowedAddrsMap[addr.String()] {
|
||||
if applyAllowedAddrs && !allowedAddrsMap[valAddr] {
|
||||
validator.Jailed = true
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ func BenchmarkFullAppSimulation(b *testing.B) {
|
||||
|
||||
app := NewSimApp(logger, db, nil, true, appOptions, interBlockCacheOpt(), baseapp.SetChainID(sims.SimAppChainID))
|
||||
|
||||
blockedAddrs, err := BlockedAddresses(app.InterfaceRegistry().SigningContext().AddressCodec())
|
||||
require.NoError(b, err)
|
||||
|
||||
// run randomized simulation
|
||||
simParams, simErr := simulation.SimulateFromSeedX(
|
||||
b,
|
||||
@@ -67,7 +70,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
|
||||
simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
||||
simtypes.RandomAccounts,
|
||||
simtestutil.SimulationOperations(app, app.AppCodec(), config, app.txConfig),
|
||||
BlockedAddresses(),
|
||||
blockedAddrs,
|
||||
config,
|
||||
app.AppCodec(),
|
||||
app.txConfig.SigningContext().AddressCodec(),
|
||||
|
||||
+2
-1
@@ -55,10 +55,11 @@ func TestFullAppSimulation(t *testing.T) {
|
||||
}
|
||||
|
||||
func setupStateFactory(app *SimApp) sims.SimStateFactory {
|
||||
blockedAddre, _ := BlockedAddresses(app.interfaceRegistry.SigningContext().AddressCodec())
|
||||
return sims.SimStateFactory{
|
||||
Codec: app.AppCodec(),
|
||||
AppStateFn: simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
||||
BlockedAddr: BlockedAddresses(),
|
||||
BlockedAddr: blockedAddre,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,12 @@ func initTestnetFiles(
|
||||
sdk.NewCoin(args.bondTokenDenom, accStakingTokens),
|
||||
}
|
||||
|
||||
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
|
||||
addrStr, err := clientCtx.AddressCodec.BytesToString(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
genBalances = append(genBalances, banktypes.Balance{Address: addrStr, Coins: coins.Sort()})
|
||||
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))
|
||||
|
||||
valStr, err := clientCtx.ValidatorAddressCodec.BytesToString(addr)
|
||||
|
||||
+13
-4
@@ -64,15 +64,19 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio
|
||||
validator := cmttypes.NewValidator(pubKey, 1)
|
||||
valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator})
|
||||
|
||||
app := NewSimApp(options.Logger, options.DB, nil, true, options.AppOpts)
|
||||
|
||||
// generate genesis account
|
||||
senderPrivKey := secp256k1.GenPrivKey()
|
||||
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
|
||||
accAddr, err := app.InterfaceRegistry().SigningContext().AddressCodec().BytesToString(acc.GetAddress())
|
||||
require.NoError(t, err)
|
||||
|
||||
balance := banktypes.Balance{
|
||||
Address: acc.GetAddress().String(),
|
||||
Address: accAddr,
|
||||
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))),
|
||||
}
|
||||
|
||||
app := NewSimApp(options.Logger, options.DB, nil, true, options.AppOpts)
|
||||
genesisState := app.DefaultGenesis()
|
||||
genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
|
||||
require.NoError(t, err)
|
||||
@@ -106,11 +110,14 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp {
|
||||
validator := cmttypes.NewValidator(pubKey, 1)
|
||||
valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator})
|
||||
|
||||
sApp, _ := setup(true, 0)
|
||||
// generate genesis account
|
||||
senderPrivKey := secp256k1.GenPrivKey()
|
||||
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
|
||||
accAddr, err := sApp.interfaceRegistry.SigningContext().AddressCodec().BytesToString(acc.GetAddress())
|
||||
require.NoError(t, err)
|
||||
balance := banktypes.Balance{
|
||||
Address: acc.GetAddress().String(),
|
||||
Address: accAddr,
|
||||
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))),
|
||||
}
|
||||
|
||||
@@ -169,9 +176,11 @@ func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState {
|
||||
// generate genesis account
|
||||
senderPrivKey := secp256k1.GenPrivKey()
|
||||
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
|
||||
accAddr, err := app.interfaceRegistry.SigningContext().AddressCodec().BytesToString(acc.GetAddress())
|
||||
require.NoError(t, err)
|
||||
balances := []banktypes.Balance{
|
||||
{
|
||||
Address: acc.GetAddress().String(),
|
||||
Address: accAddr,
|
||||
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -53,8 +53,10 @@ func NewTestApp(t *testing.T) (*SimApp[transaction.Tx], context.Context) {
|
||||
// generate genesis account
|
||||
senderPrivKey := secp256k1.GenPrivKey()
|
||||
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
|
||||
accAddr, err := app.txConfig.SigningContext().AddressCodec().BytesToString(acc.GetAddress())
|
||||
require.NoError(t, err)
|
||||
balance := banktypes.Balance{
|
||||
Address: acc.GetAddress().String(),
|
||||
Address: accAddr,
|
||||
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))),
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,11 @@ func initTestnetFiles[T transaction.Tx](
|
||||
sdk.NewCoin(args.bondTokenDenom, accStakingTokens),
|
||||
}
|
||||
|
||||
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
|
||||
addrStr, err := clientCtx.AddressCodec.BytesToString(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
genBalances = append(genBalances, banktypes.Balance{Address: addrStr, Coins: coins.Sort()})
|
||||
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))
|
||||
|
||||
valStr, err := clientCtx.ValidatorAddressCodec.BytesToString(addr)
|
||||
|
||||
Reference in New Issue
Block a user