Skip to content

Commit

Permalink
fix(genaccounts): check if genesis accounts are present (#1824)
Browse files Browse the repository at this point in the history
fresh genesis may not have accounts yet

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored May 23, 2023
1 parent 38a184d commit a354fe4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/akash/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
return errors.Errorf("failed to get accounts from any: %v", err)
}

if accs.Contains(addr) {
return errors.Errorf("cannot add account at existing address %s", addr)
lAccountNumber := uint64(0)
if len(accs) > 0 {
if accs.Contains(addr) {
return errors.Errorf("cannot add account at existing address %s", addr)
}
accs = authtypes.SanitizeGenesisAccounts(accs)
lAccountNumber = accs[len(accs)-1].GetAccountNumber() + 1
}

accs = authtypes.SanitizeGenesisAccounts(accs)
lAccountNumber := accs[len(accs)-1].GetAccountNumber()
// sdk always returns nil
_ = genAccount.SetAccountNumber(lAccountNumber + 1)
_ = genAccount.SetAccountNumber(lAccountNumber)

accs = append(accs, genAccount)

Expand Down

0 comments on commit a354fe4

Please sign in to comment.