-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add share unlocking mechanism to megavault (#2169)
- Loading branch information
Showing
17 changed files
with
1,101 additions
and
46 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
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
|
||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/lib" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/vault/types" | ||
) | ||
|
||
// UnlockShares unlocks an owner's shares. | ||
func (k msgServer) UnlockShares( | ||
goCtx context.Context, | ||
msg *types.MsgUnlockShares, | ||
) (*types.MsgUnlockSharesResponse, error) { | ||
// Check if authority is valid. | ||
if !k.HasAuthority(msg.Authority) { | ||
return nil, errorsmod.Wrapf( | ||
govtypes.ErrInvalidSigner, | ||
"invalid authority %s", | ||
msg.Authority, | ||
) | ||
} | ||
|
||
ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) | ||
|
||
if msg.OwnerAddress == "" { | ||
return nil, fmt.Errorf("owner address cannot be empty") | ||
} | ||
|
||
unlockedShares, err := k.Keeper.UnlockShares(ctx, msg.OwnerAddress) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.MsgUnlockSharesResponse{ | ||
UnlockedShares: unlockedShares, | ||
}, nil | ||
} |
Oops, something went wrong.