MCPcopy Create free account
hub / github.com/akash-network/node / initGenFiles

Function initGenFiles

testutil/network/util.go:183–222  ·  view source on GitHub ↗
(cfg Config, genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string)

Source from the content-addressed store, hash-verified

181}
182
183func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string) error {
184 // set the accounts in the genesis state
185 var authGenState authtypes.GenesisState
186 cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[authtypes.ModuleName], &authGenState)
187
188 accounts, err := authtypes.PackAccounts(genAccounts)
189 if err != nil {
190 return err
191 }
192
193 authGenState.Accounts = append(authGenState.Accounts, accounts...)
194 cfg.GenesisState[authtypes.ModuleName] = cfg.Codec.MustMarshalJSON(&authGenState)
195
196 // set the balances in the genesis state
197 var bankGenState banktypes.GenesisState
198 cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[banktypes.ModuleName], &bankGenState)
199
200 bankGenState.Balances = append(bankGenState.Balances, genBalances...)
201 cfg.GenesisState[banktypes.ModuleName] = cfg.Codec.MustMarshalJSON(&bankGenState)
202
203 appGenStateJSON, err := json.MarshalIndent(cfg.GenesisState, "", " ")
204 if err != nil {
205 return err
206 }
207
208 genDoc := types.GenesisDoc{
209 ChainID: cfg.ChainID,
210 AppState: appGenStateJSON,
211 Validators: nil,
212 }
213
214 // generate empty genesis files for each validator and save
215 for i := 0; i < cfg.NumValidators; i++ {
216 if err := genDoc.SaveAs(genFiles[i]); err != nil {
217 return err
218 }
219 }
220
221 return nil
222}
223
224func writeFile(name string, dir string, contents []byte) error {
225 file := filepath.Join(dir, name)

Callers 1

NewFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected