Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add admin init to a genesis setup #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/neutron-test-tube/libntrntesttube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package main
import "C"

import (
sdkmath "cosmossdk.io/math"
"encoding/base64"
"encoding/json"
"fmt"
"os"
"sync"
"time"

sdkmath "cosmossdk.io/math"

abci "github.com/cometbft/cometbft/abci/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
Expand Down Expand Up @@ -89,7 +90,7 @@ func CleanUp(envId uint64) {
}

//export InitAccount
func InitAccount(envId uint64, coinsJson string) *C.char {
func InitAccount(envId uint64, coinsJson string, isAdmin bool) *C.char {
env := loadEnv(envId)
var coins sdk.Coins

Expand Down Expand Up @@ -121,6 +122,11 @@ func InitAccount(envId uint64, coinsJson string) *C.char {
panic(errors.Wrapf(err, "Failed to fund account"))
}

// if we want this addr to be a network admin
if isAdmin {
env.App.AdminmoduleKeeper.SetAdmin(env.Ctx, accAddr.String())
}

base64Priv := base64.StdEncoding.EncodeToString(priv.Bytes())

envRegister.Store(envId, env)
Expand Down
2 changes: 2 additions & 0 deletions packages/neutron-test-tube/libntrntesttube/testenv/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func InitChain(appInstance *app.App) (sdk.Context, secp256k1.PrivKey) {

stateBytes, err := json.MarshalIndent(genesisState, "", " ")

admintypes.GenesisState

requireNoErr(err)

consensusParams := simtestutil.DefaultConsensusParams
Expand Down
Loading