From eb742da0c85a6d8b57621ea26d5e78d98dcbdc85 Mon Sep 17 00:00:00 2001 From: MD Aleem <72057206+aleem1314@users.noreply.github.com> Date: Wed, 15 Jun 2022 03:36:50 +0530 Subject: [PATCH] chore: fix balance migrations (#1185) Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> --- x/ecocredit/migrations/v3/core.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/x/ecocredit/migrations/v3/core.go b/x/ecocredit/migrations/v3/core.go index d4c118ddff..8c51808dd6 100644 --- a/x/ecocredit/migrations/v3/core.go +++ b/x/ecocredit/migrations/v3/core.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 }