Skip to content

Commit

Permalink
Fix total atom balance airdrop (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
padi-dev-hoangpa authored Oct 8, 2021
1 parent c08e018 commit ee42ef5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/nibirud/cmd/airdrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func exportSnapShotFromGenesisFile(clientCtx client.Context, genesisFile string,

// Produce the map of address to total atom balance, both staked and unstaked

totalAtomBalance := sdk.NewInt(0)
for _, account := range bankGenState.Balances {

acc, ok := snapshotAccs[account.Address]
Expand All @@ -174,7 +173,6 @@ func exportSnapShotFromGenesisFile(clientCtx client.Context, genesisFile string,
continue
}
balance := account.Coins.AmountOf(denom)
totalAtomBalance = totalAtomBalance.Add(balance)

acc.AtomBalance = acc.AtomBalance.Add(balance)
acc.AtomUnstakedBalance = acc.AtomUnstakedBalance.Add(balance)
Expand Down Expand Up @@ -228,6 +226,7 @@ func exportSnapShotFromGenesisFile(clientCtx client.Context, genesisFile string,

denominator := getDenominator(snapshotAccs)
totalBalance := sdk.ZeroInt()
totalAtomBalance := sdk.NewInt(0)
for address, acc := range snapshotAccs {
allAtoms := acc.AtomBalance.ToDec()

Expand Down Expand Up @@ -256,6 +255,7 @@ func exportSnapShotFromGenesisFile(clientCtx client.Context, genesisFile string,
snapshotAccount, ok := snapshot.Accounts[address]
if !ok {
snapshot.Accounts[address] = acc
totalAtomBalance = totalAtomBalance.Add(acc.AtomBalance)
} else {
if snapshotAccount.GameBalance.IsNil() {
snapshotAccount.GameBalance = sdk.ZeroInt()
Expand All @@ -264,6 +264,8 @@ func exportSnapShotFromGenesisFile(clientCtx client.Context, genesisFile string,
snapshotAccount.AtomBalance = snapshotAccount.AtomBalance.Add(acc.AtomBalance)
snapshotAccount.AtomUnstakedBalance = snapshotAccount.AtomUnstakedBalance.Add(acc.AtomUnstakedBalance)
snapshot.Accounts[address] = snapshotAccount

totalAtomBalance = totalAtomBalance.Add(acc.AtomBalance)
}
}
snapshot.TotalAtomAmount = totalAtomBalance
Expand Down

0 comments on commit ee42ef5

Please sign in to comment.