From 2d56bb702515c1db902682766ba6e09f36e42458 Mon Sep 17 00:00:00 2001 From: Jiri Vestfal <45360788+MissingNO57@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:59:19 +0200 Subject: [PATCH] Fix: Cudos account movements same address fix (#409) --- app/upgrade_cudos.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/upgrade_cudos.go b/app/upgrade_cudos.go index d1095e7f..711d6596 100644 --- a/app/upgrade_cudos.go +++ b/app/upgrade_cudos.go @@ -2249,16 +2249,22 @@ func MigrateGenesisAccounts(genesisData *GenesisData, ctx sdk.Context, app *App, func DoGenesisAccountMovements(genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { for _, accountMovement := range cudosCfg.Config.MovedAccounts { + // Skip if source and destination address is the same + if accountMovement.SourceAddress == accountMovement.DestinationAddress { + registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "movement_to_itself_skipping", manifest) + continue + } + fromAcc, exists := genesisData.Accounts.Get(accountMovement.SourceAddress) if !exists { - registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "non_existing_from_account", manifest) - return nil + registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "non_existing_from_account_skipping", manifest) + continue } if fromAcc.Balance.IsZero() { - registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "nothing_to_move_err", manifest) - return nil + registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "no_source_balance_to_move_skipping", manifest) + continue } fromAccTokensAmount := fromAcc.Balance.AmountOfNoDenomValidation(genesisData.BondDenom)