diff --git a/app/upgrades/v1_5.go b/app/upgrades/v1_5.go index 0612eb201..6b5cbaaec 100644 --- a/app/upgrades/v1_5.go +++ b/app/upgrades/v1_5.go @@ -93,14 +93,14 @@ func V010500UpgradeHandler( } func addProtocolData(ctx sdk.Context, keeper *prkeeper.Keeper, prtype prtypes.ProtocolDataType, data prtypes.ProtocolDataI) error { - json, err := json.Marshal(data) + jsonData, err := json.Marshal(data) if err != nil { return err } protocolData := prtypes.ProtocolData{ Type: prtypes.ProtocolDataType_name[int32(prtype)], - Data: json, + Data: jsonData, } keeper.SetProtocolData(ctx, data.GenerateKey(), &protocolData) @@ -121,49 +121,68 @@ func initialiseClaimsMetaData(ctx sdk.Context, appKeepers *keepers.AppKeepers) e "umee-1": "channel-49", "secret-4": "channel-52", } - + var err error // ProtocolDataTypeConnection appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) { // add connection for each zone - addProtocolData(ctx, prk, prtypes.ProtocolDataTypeConnection, &prtypes.ConnectionProtocolData{ + err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeConnection, &prtypes.ConnectionProtocolData{ ConnectionID: zone.ConnectionId, ChainID: zone.ChainId, Prefix: zone.AccountPrefix, }) + if err != nil { + return true + } // add local (QS) denom for each chain - addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{ + err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{ ChainID: ctx.ChainID(), RegisteredZoneChainID: zone.ChainId, QAssetDenom: zone.LocalDenom, IbcDenom: zone.LocalDenom, }) + if err != nil { + return true + } + // add liquid tokens for qasset on osmosis, secret, umee and the host zone itself. chainsToAdd := []string{"osmosis-1", "secret-4", "umee-1", zone.ChainId} for _, chain := range chainsToAdd { channel, found := appKeepers.IBCKeeper.ChannelKeeper.GetChannel(ctx, "transfer", channels[chain]) if !found { - panic(fmt.Errorf("unable to find channel %s", channels[chain])) + err = fmt.Errorf("unable to find channel %s", channels[chain]) + return true } - addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{ + err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{ ChainID: chain, RegisteredZoneChainID: zone.ChainId, QAssetDenom: zone.LocalDenom, IbcDenom: utils.DeriveIbcDenom("transfer", channels[chain], "transfer", channel.Counterparty.ChannelId, zone.LocalDenom), }) + + if err != nil { + return true + } } return false }) + if err != nil { + return err + } + // osmosis params - addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisParams, &prtypes.OsmosisParamsProtocolData{ + err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisParams, &prtypes.OsmosisParamsProtocolData{ ChainID: "osmosis-1", BaseChain: "osmosis-1", BaseDenom: "uosmo", }) + if err != nil { + return err + } osmoPools := []*prtypes.OsmosisPoolProtocolData{ // incentivised pools @@ -281,7 +300,10 @@ func initialiseClaimsMetaData(ctx sdk.Context, appKeepers *keepers.AppKeepers) e } // osmosis pools for _, pool := range osmoPools { - addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisPool, pool) + err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisPool, pool) + if err != nil { + return err + } } // enable params diff --git a/x/participationrewards/keeper/distribution_test.go b/x/participationrewards/keeper/distribution_test.go index a859a057e..3e25367d6 100644 --- a/x/participationrewards/keeper/distribution_test.go +++ b/x/participationrewards/keeper/distribution_test.go @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestCalcTokenValues() { PoolName: "atom/qAtom", LastUpdated: time.Now().UTC(), PoolType: "stableswap", - PoolData: []byte(`{"address":"osmo1awr39mc2hrkt8gq8gt3882ru40ay45k8a3yg69nyypqe9g0ryycs66lhkh","id":"944","pool_params":{"swap_fee":"0.003000000000000000","exit_fee":"0.000000000000000000"},"future_pool_governor":"168h","total_shares":{"denom":"gamm/pool/944","amount":"6108537302303463956540"},"pool_liquidity":[{"denom":"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2","amount":"42678069500"},{"denom":"ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC","amount":"70488173547"}],"scaling_factors":["1202853876","1000000000"],"scaling_factor_controller":"osmo16x03wcp37kx5e8ehckjxvwcgk9j0cqnhm8m3yy"}`), + PoolData: json.RawMessage(`{"address":"osmo1awr39mc2hrkt8gq8gt3882ru40ay45k8a3yg69nyypqe9g0ryycs66lhkh","id":"944","pool_params":{"swap_fee":"0.003000000000000000","exit_fee":"0.000000000000000000"},"future_pool_governor":"168h","total_shares":{"denom":"gamm/pool/944","amount":"6108537302303463956540"},"pool_liquidity":[{"denom":"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2","amount":"42678069500"},{"denom":"ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC","amount":"70488173547"}],"scaling_factors":["1202853876","1000000000"],"scaling_factor_controller":"osmo16x03wcp37kx5e8ehckjxvwcgk9j0cqnhm8m3yy"}`), Denoms: map[string]types.DenomWithZone{ "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2": {Denom: "uatom", ChainID: "cosmoshub-4"}, "ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC": {Denom: "uqatom", ChainID: "cosmoshub-4"},