Skip to content

Commit

Permalink
chore: fix balance migrations (#1185)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
aleem1314 and ryanchristo authored Jun 14, 2022
1 parent f219544 commit eb742da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions x/ecocredit/migrations/v3/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ func migrateBalances(store storetypes.KVStore, ss api.StateStore, ctx context.Co
BatchKey: batchDenomToBatchMap[denom].Id,
Address: addr,
TradableAmount: balance,
RetiredAmount: "0",
EscrowedAmount: "0",
}); err != nil {
return true, err
}
Expand All @@ -367,9 +369,11 @@ func migrateBalances(store storetypes.KVStore, ss api.StateStore, ctx context.Co
if err != nil {
if ormerrors.IsNotFound(err) {
if err := ss.BatchBalanceTable().Save(ctx, &api.BatchBalance{
BatchKey: batchDenomToBatchMap[denom].Id,
Address: addr,
RetiredAmount: balance,
BatchKey: batchDenomToBatchMap[denom].Id,
Address: addr,
RetiredAmount: balance,
TradableAmount: "0",
EscrowedAmount: "0",
}); err != nil {
return true, err
}
Expand All @@ -384,6 +388,7 @@ func migrateBalances(store storetypes.KVStore, ss api.StateStore, ctx context.Co
Address: addr,
TradableAmount: b.TradableAmount,
RetiredAmount: balance,
EscrowedAmount: "0",
}); err != nil {
return true, err
}
Expand All @@ -405,6 +410,7 @@ func migrateSupply(store storetypes.KVStore, ss api.StateStore, ctx context.Cont
BatchKey: batchDenomToBatchMap[denom].Id,
CancelledAmount: batchDenomToBatchMap[denom].AmountCancelled,
TradableAmount: supply,
RetiredAmount: "0",
}); err != nil {
return false, err
}
Expand All @@ -426,6 +432,7 @@ func migrateSupply(store storetypes.KVStore, ss api.StateStore, ctx context.Cont
BatchKey: batchDenomToBatchMap[denom].Id,
CancelledAmount: batchDenomToBatchMap[denom].AmountCancelled,
RetiredAmount: supply,
TradableAmount: "0",
}); err != nil {
return false, err
}
Expand Down

0 comments on commit eb742da

Please sign in to comment.