Skip to content

Commit

Permalink
fix(genaccounts): check if genesis accounts are present
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jul 6, 2023
1 parent 53e8be2 commit 4a7574d
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 4a7574d

Please sign in to comment.