From 287d5892a2d080c4e70814b3061d8cd97b956e85 Mon Sep 17 00:00:00 2001 From: Jiri Date: Thu, 10 Oct 2024 15:18:53 +0200 Subject: [PATCH] Private fields in GenesisData made public --- app/upgrade_cudos.go | 158 +++++++++++++++--------------- app/upgrade_cudos_distribution.go | 6 +- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/app/upgrade_cudos.go b/app/upgrade_cudos.go index 54b44d1d..5d5b7d2d 100644 --- a/app/upgrade_cudos.go +++ b/app/upgrade_cudos.go @@ -108,22 +108,22 @@ type GenesisData struct { BlockHeight int64 chainId string Prefix string - bondDenom string + BondDenom string - accounts *OrderedMap[string, *AccountInfo] - contracts *OrderedMap[string, *ContractInfo] - ibcAccounts *OrderedMap[string, *IBCInfo] - delegations *OrderedMap[string, *OrderedMap[string, sdk.Int]] + Accounts *OrderedMap[string, *AccountInfo] + Contracts *OrderedMap[string, *ContractInfo] + IbcAccounts *OrderedMap[string, *IBCInfo] + Delegations *OrderedMap[string, *OrderedMap[string, sdk.Int]] - validators *OrderedMap[string, *ValidatorInfo] - bondedPoolAddress string - notBondedPoolAddress string + Validators *OrderedMap[string, *ValidatorInfo] + BondedPoolAddress string + NotBondedPoolAddress string distributionInfo *DistributionInfo - gravityModuleAccountAddress string + GravityModuleAccountAddress string - collisionMap *OrderedMap[string, string] + CollisionMap *OrderedMap[string, string] } func LoadCudosGenesis(app *App, manifest *UpgradeManifest) (*map[string]interface{}, *tmtypes.GenesisDoc, error) { @@ -285,62 +285,62 @@ func ParseGenesisData(jsonData map[string]interface{}, genDoc *tmtypes.GenesisDo return nil, fmt.Errorf("failed to get prefix: %w", err) } - genesisData.bondDenom, err = GetBondDenom(jsonData) + genesisData.BondDenom, err = GetBondDenom(jsonData) if err != nil { return nil, fmt.Errorf("failed to get staking denom: %w", err) } - genesisData.contracts, err = parseGenesisWasmContracts(jsonData) + genesisData.Contracts, err = parseGenesisWasmContracts(jsonData) if err != nil { return nil, fmt.Errorf("failed to get contracts: %w", err) } - genesisData.ibcAccounts, err = parseGenesisIBCAccounts(jsonData, cudosCfg, genesisData.Prefix) + genesisData.IbcAccounts, err = parseGenesisIBCAccounts(jsonData, cudosCfg, genesisData.Prefix) if err != nil { return nil, fmt.Errorf("failed to get ibc accounts: %w", err) } // Get all accounts and balances into map - genesisData.accounts, err = parseGenesisAccounts(jsonData, genesisData.contracts, genesisData.ibcAccounts, cudosCfg, manifest) + genesisData.Accounts, err = parseGenesisAccounts(jsonData, genesisData.Contracts, genesisData.IbcAccounts, cudosCfg, manifest) if err != nil { return nil, fmt.Errorf("failed to get accounts map: %w", err) } // Staking module - bondedPoolAddress, err := GetAddressByName(genesisData.accounts, BondedPoolAccName) + bondedPoolAddress, err := GetAddressByName(genesisData.Accounts, BondedPoolAccName) if err != nil { return nil, fmt.Errorf("failed to get bonded pool account: %w", err) } - genesisData.bondedPoolAddress = bondedPoolAddress + genesisData.BondedPoolAddress = bondedPoolAddress - genesisData.notBondedPoolAddress, err = GetAddressByName(genesisData.accounts, NotBondedPoolAccName) + genesisData.NotBondedPoolAddress, err = GetAddressByName(genesisData.Accounts, NotBondedPoolAccName) if err != nil { return nil, fmt.Errorf("failed to get not-bonded pool account: %w", err) } - genesisData.validators, err = parseGenesisValidators(jsonData) + genesisData.Validators, err = parseGenesisValidators(jsonData) if err != nil { return nil, fmt.Errorf("failed to get validators map: %w", err) } - genesisData.delegations, err = parseGenesisDelegations(genesisData.validators, genesisData.contracts, cudosCfg) + genesisData.Delegations, err = parseGenesisDelegations(genesisData.Validators, genesisData.Contracts, cudosCfg) if err != nil { return nil, fmt.Errorf("failed to get delegations map: %w", err) } - distributionInfo, err := parseGenesisDistribution(jsonData, genesisData.accounts) + distributionInfo, err := parseGenesisDistribution(jsonData, genesisData.Accounts) if err != nil { return nil, fmt.Errorf("failed to get distribution module map: %w", err) } genesisData.distributionInfo = distributionInfo - gravityModuleAccountAddress, err := GetAddressByName(genesisData.accounts, GravityAccName) + gravityModuleAccountAddress, err := GetAddressByName(genesisData.Accounts, GravityAccName) if err != nil { return nil, fmt.Errorf("failed to get gravity module account: %w", err) } - genesisData.gravityModuleAccountAddress = gravityModuleAccountAddress + genesisData.GravityModuleAccountAddress = gravityModuleAccountAddress - genesisData.collisionMap = NewOrderedMap[string, string]() + genesisData.CollisionMap = NewOrderedMap[string, string]() return &genesisData, nil } @@ -738,22 +738,22 @@ func parseGenesisValidators(jsonData map[string]interface{}) (*OrderedMap[string func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { // Handle delegations - for i := range genesisData.validators.Iterate() { + for i := range genesisData.Validators.Iterate() { validatorOperatorAddress, validator := i.Key, i.Value for j := range validator.delegations.Iterate() { delegatorAddress, delegation := j.Key, j.Value - resolvedDelegatorAddress, err := resolveIfContractAddressWithFallback(delegatorAddress, genesisData.contracts, cudosCfg) + resolvedDelegatorAddress, err := resolveIfContractAddressWithFallback(delegatorAddress, genesisData.Contracts, cudosCfg) if err != nil { return err } - currentValidatorInfo := genesisData.validators.MustGet(validatorOperatorAddress) + currentValidatorInfo := genesisData.Validators.MustGet(validatorOperatorAddress) delegatorTokens := currentValidatorInfo.TokensFromShares(delegation.shares).TruncateInt() // Move balance to delegator address - delegatorBalance := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, delegatorTokens)) + delegatorBalance := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, delegatorTokens)) if delegatorTokens.IsZero() { // This happens when number of shares is less than 1 @@ -763,7 +763,7 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos // Subtract balance from bonded or not-bonded pool if currentValidatorInfo.status == BondedStatus { // Move balance from bonded pool to delegator - err := moveGenesisBalance(genesisData, genesisData.bondedPoolAddress, resolvedDelegatorAddress, delegatorBalance, "bonded_delegation", manifest, cudosCfg) + err := moveGenesisBalance(genesisData, genesisData.BondedPoolAddress, resolvedDelegatorAddress, delegatorBalance, "bonded_delegation", manifest, cudosCfg) if err != nil { return err } @@ -772,7 +772,7 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos // Delegations to unbonded/jailed/tombstoned validators are not re-delegated // Move balance from not-bonded pool to delegator - err := moveGenesisBalance(genesisData, genesisData.notBondedPoolAddress, resolvedDelegatorAddress, delegatorBalance, "not_bonded_delegation", manifest, cudosCfg) + err := moveGenesisBalance(genesisData, genesisData.NotBondedPoolAddress, resolvedDelegatorAddress, delegatorBalance, "not_bonded_delegation", manifest, cudosCfg) if err != nil { return err } @@ -784,16 +784,16 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos for j := range validator.unbondingDelegations.Iterate() { delegatorAddress, unbondingDelegation := j.Key, j.Value - resolvedDelegatorAddress, err := resolveIfContractAddressWithFallback(delegatorAddress, genesisData.contracts, cudosCfg) + resolvedDelegatorAddress, err := resolveIfContractAddressWithFallback(delegatorAddress, genesisData.Contracts, cudosCfg) if err != nil { return err } for _, entry := range unbondingDelegation.entries { - unbondingDelegationBalance := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, entry.balance)) + unbondingDelegationBalance := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, entry.balance)) // Move unbonding balance from not-bonded pool to delegator address - err := moveGenesisBalance(genesisData, genesisData.notBondedPoolAddress, resolvedDelegatorAddress, unbondingDelegationBalance, "unbonding_delegation", manifest, cudosCfg) + err := moveGenesisBalance(genesisData, genesisData.NotBondedPoolAddress, resolvedDelegatorAddress, unbondingDelegationBalance, "unbonding_delegation", manifest, cudosCfg) if err != nil { return err } @@ -805,7 +805,7 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos // Handle remaining pool balances // Handle remaining bonded pool balance - bondedPool := genesisData.accounts.MustGet(genesisData.bondedPoolAddress) + bondedPool := genesisData.Accounts.MustGet(genesisData.BondedPoolAddress) // TODO: Write to manifest? err := checkTolerance(bondedPool.balance, maxToleratedRemainingStakingBalance) @@ -814,13 +814,13 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos } app.Logger().Info("cudos merge: remaining bonded pool balance", "amount", bondedPool.balance.String()) - err = moveGenesisBalance(genesisData, genesisData.bondedPoolAddress, cudosCfg.config.RemainingStakingBalanceAddr, bondedPool.balance, "remaining_bonded_pool_balance", manifest, cudosCfg) + err = moveGenesisBalance(genesisData, genesisData.BondedPoolAddress, cudosCfg.config.RemainingStakingBalanceAddr, bondedPool.balance, "remaining_bonded_pool_balance", manifest, cudosCfg) if err != nil { return err } // Handle remaining not-bonded pool balance - notBondedPool := genesisData.accounts.MustGet(genesisData.notBondedPoolAddress) + notBondedPool := genesisData.Accounts.MustGet(genesisData.NotBondedPoolAddress) // TODO: Write to manifest? err = checkTolerance(notBondedPool.balance, maxToleratedRemainingStakingBalance) @@ -829,7 +829,7 @@ func withdrawGenesisStakingDelegations(app *App, genesisData *GenesisData, cudos } app.Logger().Info("cudos merge: remaining not-bonded pool balance", "amount", notBondedPool.balance.String()) - err = moveGenesisBalance(genesisData, genesisData.notBondedPoolAddress, cudosCfg.config.RemainingStakingBalanceAddr, notBondedPool.balance, "remaining_not_bonded_pool_balance", manifest, cudosCfg) + err = moveGenesisBalance(genesisData, genesisData.NotBondedPoolAddress, cudosCfg.config.RemainingStakingBalanceAddr, notBondedPool.balance, "remaining_not_bonded_pool_balance", manifest, cudosCfg) if err != nil { return err } @@ -911,7 +911,7 @@ func createDelegation(ctx sdk.Context, app *App, originalValidator string, newDe func handleCommunityPoolBalance(ctx sdk.Context, app *App, genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { // Get addresses and amounts - RemainingDistributionBalanceAccount := genesisData.accounts.MustGet(cudosCfg.config.RemainingDistributionBalanceAddr) + RemainingDistributionBalanceAccount := genesisData.Accounts.MustGet(cudosCfg.config.RemainingDistributionBalanceAddr) communityPoolBalance, _ := genesisData.distributionInfo.feePool.communityPool.TruncateDecimal() convertedCommunityPoolBalance, err := convertBalance(app.StakingKeeper.BondDenom(ctx), communityPoolBalance, cudosCfg) if err != nil { @@ -953,8 +953,8 @@ func handleCommunityPoolBalance(ctx sdk.Context, app *App, genesisData *GenesisD func createGenesisDelegations(ctx sdk.Context, app *App, genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { - for _, delegatorAddr := range genesisData.delegations.Keys() { - delegatorAddrMap := genesisData.delegations.MustGet(delegatorAddr) + for _, delegatorAddr := range genesisData.Delegations.Keys() { + delegatorAddrMap := genesisData.Delegations.MustGet(delegatorAddr) // Skip accounts that shouldn't be delegated if cudosCfg.notDelegatedAccounts.Has(delegatorAddr) { @@ -976,7 +976,7 @@ func createGenesisDelegations(ctx sdk.Context, app *App, genesisData *GenesisDat } var delegatorRawAddr []byte - if remappedDelegatorAddr, exists := genesisData.collisionMap.Get(delegatorAddr); exists { + if remappedDelegatorAddr, exists := genesisData.CollisionMap.Get(delegatorAddr); exists { // Vesting collision _, delegatorRawAddr, err = bech32.DecodeAndConvert(remappedDelegatorAddr) if err != nil { @@ -1056,13 +1056,13 @@ func getInterfaceSliceFromCoins(coins sdk.Coins) []interface{} { func withdrawGenesisContractBalances(genesisData *GenesisData, manifest *UpgradeManifest, cudosCfg *CudosMergeConfig) error { - for _, contractAddress := range genesisData.contracts.Keys() { - resolvedAddress, err := resolveIfContractAddressWithFallback(contractAddress, genesisData.contracts, cudosCfg) + for _, contractAddress := range genesisData.Contracts.Keys() { + resolvedAddress, err := resolveIfContractAddressWithFallback(contractAddress, genesisData.Contracts, cudosCfg) if err != nil { return err } - contractBalance, contractBalancePresent := genesisData.accounts.Get(contractAddress) + contractBalance, contractBalancePresent := genesisData.Accounts.Get(contractAddress) if contractBalancePresent { err := moveGenesisBalance(genesisData, contractAddress, resolvedAddress, contractBalance.balance, "contract_balance", manifest, cudosCfg) if err != nil { @@ -1075,7 +1075,7 @@ func withdrawGenesisContractBalances(genesisData *GenesisData, manifest *Upgrade } func convertAmount(outputDenom string, genesisData *GenesisData, amount sdk.Int, cudosCfg *CudosMergeConfig) (sdk.Int, error) { - balance := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, amount)) + balance := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, amount)) convertedBalance, err := convertBalance(outputDenom, balance, cudosCfg) if err != nil { return sdk.ZeroInt(), err @@ -1180,10 +1180,10 @@ func genesisUpgradeWithdrawIBCChannelsBalances(genesisData *GenesisData, cudosCf To: ibcWithdrawalAddress, } - for _, IBCaccountAddress := range genesisData.ibcAccounts.Keys() { + for _, IBCaccountAddress := range genesisData.IbcAccounts.Keys() { - IBCaccount, IBCAccountExists := genesisData.accounts.Get(IBCaccountAddress) - IBCinfo := genesisData.ibcAccounts.MustGet(IBCaccountAddress) + IBCaccount, IBCAccountExists := genesisData.Accounts.Get(IBCaccountAddress) + IBCinfo := genesisData.IbcAccounts.MustGet(IBCaccountAddress) var channelBalance sdk.Coins if IBCAccountExists { @@ -1472,7 +1472,7 @@ func migrateToAccount(ctx sdk.Context, app *App, fromAddress string, toAddress s } func markAccountAsMigrated(genesisData *GenesisData, accountAddress string) error { - AccountInfoRecord, exists := genesisData.accounts.Get(accountAddress) + AccountInfoRecord, exists := genesisData.Accounts.Get(accountAddress) if !exists { return fmt.Errorf("genesis account %s not found", accountAddress) } @@ -1483,7 +1483,7 @@ func markAccountAsMigrated(genesisData *GenesisData, accountAddress string) erro AccountInfoRecord.migrated = true - genesisData.accounts.Set(accountAddress, AccountInfoRecord) + genesisData.Accounts.Set(accountAddress, AccountInfoRecord) return nil } @@ -1521,7 +1521,7 @@ func registerManifestMoveDelegations(fromAddress, toAddress, validatorAddress st } func getDelegationData(genesisData *GenesisData, DelegatorAddress string, validatorAddress string) (*OrderedMap[string, sdk.Int], *sdk.Int) { - sourceDelegations, exists := genesisData.delegations.Get(DelegatorAddress) + sourceDelegations, exists := genesisData.Delegations.Get(DelegatorAddress) if !exists { return nil, nil } @@ -1558,7 +1558,7 @@ func moveGenesisDelegation(genesisData *GenesisData, fromDelegatorAddress, toDel // No destination delegations newMap := NewOrderedMap[string, sdk.Int]() newMap.Set(toDelegatorAddress, amount) - genesisData.delegations.Set(toDelegatorAddress, newMap) + genesisData.Delegations.Set(toDelegatorAddress, newMap) } else if destinationDelegatedAmount == nil { // No delegations to validator @@ -1599,31 +1599,31 @@ func registerManifestBalanceMovement(fromAddress, toAddress string, amount sdk.C func moveGenesisBalance(genesisData *GenesisData, fromAddress, toAddress string, amount sdk.Coins, memo string, manifest *UpgradeManifest, cudosCfg *CudosMergeConfig) error { // Check if fromAddress exists - if _, ok := genesisData.accounts.Get(fromAddress); !ok { + if _, ok := genesisData.Accounts.Get(fromAddress); !ok { return fmt.Errorf("fromAddress %s does not exist in genesis balances", fromAddress) } // Create to account if it doesn't exist - err := ensureAccount(toAddress, genesisData.accounts, "balance_movement_destination", manifest) + err := ensureAccount(toAddress, genesisData.Accounts, "balance_movement_destination", manifest) if err != nil { return err } - if toAcc := genesisData.accounts.MustGet(toAddress); toAcc.migrated { + if toAcc := genesisData.Accounts.MustGet(toAddress); toAcc.migrated { return fmt.Errorf("genesis account %s already migrated", toAddress) } - if fromAcc := genesisData.accounts.MustGet(fromAddress); fromAcc.migrated { + if fromAcc := genesisData.Accounts.MustGet(fromAddress); fromAcc.migrated { return fmt.Errorf("genesis account %s already migrated", fromAddress) } - genesisToBalance := genesisData.accounts.MustGet(toAddress) - genesisFromBalance := genesisData.accounts.MustGet(fromAddress) + genesisToBalance := genesisData.Accounts.MustGet(toAddress) + genesisFromBalance := genesisData.Accounts.MustGet(fromAddress) genesisToBalance.balance = genesisToBalance.balance.Add(amount...) genesisFromBalance.balance = genesisFromBalance.balance.Sub(amount) - genesisData.accounts.Set(toAddress, genesisToBalance) - genesisData.accounts.Set(fromAddress, genesisFromBalance) + genesisData.Accounts.Set(toAddress, genesisToBalance) + genesisData.Accounts.Set(fromAddress, genesisFromBalance) registerManifestBalanceMovement(fromAddress, toAddress, amount, memo, manifest) @@ -1632,20 +1632,20 @@ func moveGenesisBalance(genesisData *GenesisData, fromAddress, toAddress string, func createGenesisBalance(genesisData *GenesisData, toAddress string, amount sdk.Coins, memo string, manifest *UpgradeManifest) error { // Create to account if it doesn't exist - err := ensureAccount(toAddress, genesisData.accounts, "balance_creation_destination", manifest) + err := ensureAccount(toAddress, genesisData.Accounts, "balance_creation_destination", manifest) if err != nil { return err } - if toAcc := genesisData.accounts.MustGet(toAddress); toAcc.migrated { + if toAcc := genesisData.Accounts.MustGet(toAddress); toAcc.migrated { return fmt.Errorf("genesis account %s already migrated", toAddress) } - genesisToBalance := genesisData.accounts.MustGet(toAddress) + genesisToBalance := genesisData.Accounts.MustGet(toAddress) genesisToBalance.balance = genesisToBalance.balance.Add(amount...) - genesisData.accounts.Set(toAddress, genesisToBalance) + genesisData.Accounts.Set(toAddress, genesisToBalance) registerManifestBalanceMovement("", toAddress, amount, memo, manifest) @@ -1654,18 +1654,18 @@ func createGenesisBalance(genesisData *GenesisData, toAddress string, amount sdk func removeGenesisBalance(genesisData *GenesisData, address string, amount sdk.Coins, memo string, manifest *UpgradeManifest) error { // Check if fromAddress exists - if _, ok := genesisData.accounts.Get(address); !ok { + if _, ok := genesisData.Accounts.Get(address); !ok { return fmt.Errorf("address %s does not exist in genesis balances", address) } - if acc := genesisData.accounts.MustGet(address); acc.migrated { + if acc := genesisData.Accounts.MustGet(address); acc.migrated { return fmt.Errorf("genesis account %s already migrated", address) } - genesisAccount := genesisData.accounts.MustGet(address) + genesisAccount := genesisData.Accounts.MustGet(address) genesisAccount.balance = genesisAccount.balance.Sub(amount) - genesisData.accounts.Set(address, genesisAccount) + genesisData.Accounts.Set(address, genesisAccount) registerManifestBalanceMovement(address, "", amount, memo, manifest) @@ -1697,8 +1697,8 @@ func checkDecTolerance(coins sdk.DecCoins, maxToleratedDiff sdk.Int) error { func withdrawGenesisGravity(genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { - gravityBalance := genesisData.accounts.MustGet(genesisData.gravityModuleAccountAddress).balance - err := moveGenesisBalance(genesisData, genesisData.gravityModuleAccountAddress, cudosCfg.config.RemainingGravityBalanceAddr, gravityBalance, "gravity_balance", manifest, cudosCfg) + gravityBalance := genesisData.Accounts.MustGet(genesisData.GravityModuleAccountAddress).balance + err := moveGenesisBalance(genesisData, genesisData.GravityModuleAccountAddress, cudosCfg.config.RemainingGravityBalanceAddr, gravityBalance, "gravity_balance", manifest, cudosCfg) if err != nil { return err } @@ -1819,7 +1819,7 @@ func doRegularAccountMigration(ctx sdk.Context, app *App, genesisAccount *Accoun func doCollisionMigration(ctx sdk.Context, app *App, genesisData *GenesisData, genesisAccount *AccountInfo, existingAccount authtypes.AccountI, newBalance sdk.Coins, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { // Keep existing account intact and move cudos balance to account specified in config - genesisData.collisionMap.SetNew(genesisAccount.address, cudosCfg.config.VestingCollisionDestAddr) + genesisData.CollisionMap.SetNew(genesisAccount.address, cudosCfg.config.VestingCollisionDestAddr) _, destRawAddr, err := bech32.DecodeAndConvert(cudosCfg.config.VestingCollisionDestAddr) if err != nil { @@ -1840,7 +1840,7 @@ func MigrateGenesisAccounts(genesisData *GenesisData, ctx sdk.Context, app *App, // Mint donor chain total supply totalSupplyToMint := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), cudosCfg.config.TotalFetchSupplyToMint)) - totalCudosSupply := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, cudosCfg.config.TotalCudosSupply)) + totalCudosSupply := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, cudosCfg.config.TotalCudosSupply)) err := app.MintKeeper.MintCoins(ctx, totalSupplyToMint) if err != nil { @@ -1861,13 +1861,13 @@ func MigrateGenesisAccounts(genesisData *GenesisData, ctx sdk.Context, app *App, err = migrateToAccount(ctx, app, "mint_module", commissionRawAcc, sdk.NewCoins(), totalCommission, "total_commission", manifest) - extraSupplyInCudos := cudosCfg.config.TotalCudosSupply.Sub(genesisData.TotalSupply.AmountOf(genesisData.bondDenom)) + extraSupplyInCudos := cudosCfg.config.TotalCudosSupply.Sub(genesisData.TotalSupply.AmountOf(genesisData.BondDenom)) extraSupplyCudosAddress, err := convertAddressPrefix(cudosCfg.config.ExtraSupplyFetchAddr, genesisData.Prefix) if err != nil { return err } - extraSupplyInCudosCoins := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, extraSupplyInCudos)) + extraSupplyInCudosCoins := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, extraSupplyInCudos)) err = createGenesisBalance(genesisData, extraSupplyCudosAddress, extraSupplyInCudosCoins, "extra_supply", manifest) if err != nil { @@ -1880,8 +1880,8 @@ func MigrateGenesisAccounts(genesisData *GenesisData, ctx sdk.Context, app *App, } // Mint the rest of the supply - for _, genesisAccountAddress := range genesisData.accounts.Keys() { - genesisAccount := genesisData.accounts.MustGet(genesisAccountAddress) + for _, genesisAccountAddress := range genesisData.Accounts.Keys() { + genesisAccount := genesisData.Accounts.MustGet(genesisAccountAddress) if genesisAccount.accountType == ContractAccountType { // All contracts balance should be handled already @@ -1984,7 +1984,7 @@ func MigrateGenesisAccounts(genesisData *GenesisData, ctx sdk.Context, app *App, func DoGenesisAccountMovements(genesisData *GenesisData, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest) error { for _, accountMovement := range cudosCfg.config.MovedAccounts { - fromAcc, exists := genesisData.accounts.Get(accountMovement.SourceAddress) + fromAcc, exists := genesisData.Accounts.Get(accountMovement.SourceAddress) if !exists { registerManifestBalanceMovement(accountMovement.SourceAddress, accountMovement.DestinationAddress, nil, "non_existing_from_account", manifest) @@ -1996,13 +1996,13 @@ func DoGenesisAccountMovements(genesisData *GenesisData, cudosCfg *CudosMergeCon return nil } - fromAccTokensAmount := fromAcc.balance.AmountOfNoDenomValidation(genesisData.bondDenom) + fromAccTokensAmount := fromAcc.balance.AmountOfNoDenomValidation(genesisData.BondDenom) // Move entire balance if balance to move is 0 or greater than available balance if accountMovement.Amount == nil || fromAccTokensAmount.LT(*accountMovement.Amount) { accountMovement.Amount = &fromAccTokensAmount } - balanceToMove := sdk.NewCoins(sdk.NewCoin(genesisData.bondDenom, *accountMovement.Amount)) + balanceToMove := sdk.NewCoins(sdk.NewCoin(genesisData.BondDenom, *accountMovement.Amount)) // Handle balance movement err := moveGenesisBalance(genesisData, accountMovement.SourceAddress, accountMovement.DestinationAddress, balanceToMove, "balance_movement", manifest, cudosCfg) @@ -2012,7 +2012,7 @@ func DoGenesisAccountMovements(genesisData *GenesisData, cudosCfg *CudosMergeCon // Handle delegations movement remainingAmountToMove := sdk.NewIntFromBigInt(accountMovement.Amount.BigInt()) - if sourceDelegations, exists := genesisData.delegations.Get(accountMovement.SourceAddress); exists { + if sourceDelegations, exists := genesisData.Delegations.Get(accountMovement.SourceAddress); exists { for i := range sourceDelegations.Iterate() { validatorAddr, delegatedAmount := i.Key, i.Value diff --git a/app/upgrade_cudos_distribution.go b/app/upgrade_cudos_distribution.go index a4a78476..1d468694 100644 --- a/app/upgrade_cudos_distribution.go +++ b/app/upgrade_cudos_distribution.go @@ -327,7 +327,7 @@ func withdrawGenesisDistributionRewards(app *App, genesisData *GenesisData, cudo // Withdraw all delegation rewards for _, validatorOpertorAddr := range genesisData.distributionInfo.delegatorStartingInfos.Keys() { - validator := genesisData.validators.MustGet(validatorOpertorAddr) + validator := genesisData.Validators.MustGet(validatorOpertorAddr) delegatorStartInfo := genesisData.distributionInfo.delegatorStartingInfos.MustGet(validatorOpertorAddr) @@ -359,7 +359,7 @@ func withdrawGenesisDistributionRewards(app *App, genesisData *GenesisData, cudo // Withdraw Community pool balance to address if defined communityBalance, _ := genesisData.distributionInfo.feePool.communityPool.TruncateDecimal() - distributionModuleAccount := genesisData.accounts.MustGet(genesisData.distributionInfo.distributionModuleAccountAddress) + distributionModuleAccount := genesisData.Accounts.MustGet(genesisData.distributionInfo.distributionModuleAccountAddress) remainingBalance := distributionModuleAccount.balance.Sub(communityBalance) @@ -656,7 +656,7 @@ func withdrawDelegationRewards(app *App, genesisData *GenesisData, val *Validato baseDenom = cudosCfg.config.OriginalDenom } */ - baseDenom := genesisData.bondDenom + baseDenom := genesisData.BondDenom // Note, we do not call the NewCoins constructor as we do not want the zero // coin removed.