-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store opted in and opted out validators
- Loading branch information
Showing
8 changed files
with
359 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/interchain-security/v4/x/ccv/provider/types" | ||
) | ||
|
||
// HandleOptIn TODO | ||
func (k Keeper) HandleOptIn(ctx sdk.Context, msg types.MsgOptIn) error { | ||
// TODO: HandleOptIn | ||
func (k Keeper) HandleOptIn(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) error { | ||
logger := k.Logger(ctx) | ||
logger.Info("something ..") | ||
|
||
if k.IsToBeOptedOut(ctx, chainID, providerAddr) { | ||
k.RemoveToBeOptedOut(ctx, chainID, providerAddr) | ||
return nil | ||
} else if k.IsToBeOptedIn(ctx, chainID, providerAddr) { | ||
return nil | ||
} else if k.IsOptedIn(ctx, chainID, providerAddr) { | ||
logger.Error("That's a big no") | ||
return fmt.Errorf("What's happening? already opted in") | ||
} else { | ||
k.SetToBeOptedIn(ctx, chainID, providerAddr) | ||
} | ||
|
||
//if msg.GetConsumerKey() != "" { | ||
// k.AssignConsumerKey(ctx, msg.ChainId) | ||
//} | ||
|
||
return nil | ||
} | ||
|
||
// HandleOptOut TODO | ||
func (k Keeper) HandleOptOut(ctx sdk.Context, msg types.MsgOptOut) error { | ||
func (k Keeper) HandleOptOut(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) error { | ||
logger := k.Logger(ctx) | ||
logger.Info("something ..") | ||
|
||
if k.IsToBeOptedIn(ctx, chainID, providerAddr) { | ||
k.RemoveToBeOptedIn(ctx, chainID, providerAddr) | ||
return nil | ||
} else if k.IsToBeOptedOut(ctx, chainID, providerAddr) { | ||
return nil | ||
} else if !k.IsOptedIn(ctx, chainID, providerAddr) { | ||
logger.Error("that's a no!") | ||
return fmt.Errorf("What's happening? already opted in") | ||
} else { | ||
k.SetToBeOptedOut(ctx, chainID, providerAddr) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.