Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm binding updates to include creator parameter and Eden price exception handling in APR calculation. #288

Merged
merged 3 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions proto/elys/commitment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ message MsgVest {
string denom = 3;
}

message MsgVestCW {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 4;
}

message MsgVestResponse {}

message MsgCancelVest {
Expand All @@ -86,6 +93,13 @@ message MsgCancelVest {
string denom = 3;
}

message MsgCancelVestCW {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 4;
}

message MsgCancelVestResponse {}

message MsgVestNow {
Expand Down Expand Up @@ -124,9 +138,10 @@ message MsgClaimRewardsResponse {}

message MsgStake {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 3;
string validator_address = 4;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 4;
string validator_address = 5;
}

message MsgStakeResponse {
Expand All @@ -136,9 +151,10 @@ message MsgStakeResponse {

message MsgUnstake {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 3;
string validator_address = 4;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 4;
string validator_address = 5;
}

message MsgUnstakeResponse {
Expand Down
34 changes: 30 additions & 4 deletions proto/elys/incentive/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package elys.incentive;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "elys/commitment/params.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/elys-network/elys/x/incentive/types";

Expand All @@ -25,8 +26,9 @@ service Msg {
message MsgWithdrawRewards {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 2;
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 3;
}

// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type.
Expand All @@ -37,8 +39,9 @@ message MsgWithdrawRewardsResponse {}
message MsgWithdrawValidatorCommission {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type.
Expand Down Expand Up @@ -70,3 +73,26 @@ message MsgUpdateIncentiveParams {

message MsgUpdateIncentiveParamsResponse {}

message MsgBeginRedelegate {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_src_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_dst_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];
}

message MsgCancelUnbondingDelegation{
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount is always less than or equal to unbonding delegation entry balance
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
// creation_height is the height which the unbonding took place.
int64 creation_height = 5;
}
9 changes: 4 additions & 5 deletions wasmbindings/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
accountedpoolkeeper "github.com/elys-network/elys/x/accountedpool/keeper"
accountedpooltypes "github.com/elys-network/elys/x/accountedpool/types"
ammkeeper "github.com/elys-network/elys/x/amm/keeper"
Expand Down Expand Up @@ -254,19 +253,19 @@ type ElysMsg struct {
CommitmentCommitLiquidTokens *commitmenttypes.MsgCommitLiquidTokens `json:"commitment_commit_liquid_tokens,omitempty"`
CommitmentCommitUnclaimedRewards *commitmenttypes.MsgCommitClaimedRewards `json:"commitment_commit_unclaimed_rewards,omitempty"`
CommitmentUncommitTokens *commitmenttypes.MsgUncommitTokens `json:"commitment_uncommit_tokens,omitempty"`
CommitmentVest *commitmenttypes.MsgVest `json:"commitment_vest"`
CommitmentVest *commitmenttypes.MsgVestCW `json:"commitment_vest"`
CommitmentVestNow *commitmenttypes.MsgVestNow `json:"commitment_vest_now"`
CommitmentVestLiquid *commitmenttypes.MsgVestLiquid `json:"commitment_vest_liquid"`
CommitmentCancelVest *commitmenttypes.MsgCancelVest `json:"commitment_cancel_vest"`
CommitmentCancelVest *commitmenttypes.MsgCancelVestCW `json:"commitment_cancel_vest"`
CommitmentUpdateVestingInfo *commitmenttypes.MsgUpdateVestingInfo `json:"commitment_update_vesting_info"`
CommitmentStake *commitmenttypes.MsgStake `json:"commitment_stake,omitempty"`
CommitmentUnstake *commitmenttypes.MsgUnstake `json:"commitment_unstake,omitempty"`

// epochs messages

// incentive messages
IncentiveBeginRedelegate *stakingtypes.MsgBeginRedelegate `json:"incentive_begin_redelegate,omitempty"`
IncentiveCancelUnbondingDelegation *stakingtypes.MsgCancelUnbondingDelegation `json:"incentive_cancel_unbonding_delegation"`
IncentiveBeginRedelegate *incentivetypes.MsgBeginRedelegate `json:"incentive_begin_redelegate,omitempty"`
IncentiveCancelUnbondingDelegation *incentivetypes.MsgCancelUnbondingDelegation `json:"incentive_cancel_unbonding_delegation"`
IncentiveWithdrawRewards *incentivetypes.MsgWithdrawRewards `json:"incentive_withdraw_rewards"`
IncentiveWithdrawValidatorCommission *incentivetypes.MsgWithdrawValidatorCommission `json:"incentive_withdraw_validator_commission"`

Expand Down
6 changes: 3 additions & 3 deletions x/commitment/client/wasm/msg_cancel_vest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
paramtypes "github.com/elys-network/elys/x/parameter/types"
)

func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVest) ([]sdk.Event, [][]byte, error) {
func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVestCW) ([]sdk.Event, [][]byte, error) {
if msgCancelVest == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest null msg"}
}
Expand Down Expand Up @@ -43,13 +43,13 @@ func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, resp, nil
}

func performMsgCancelVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVest) (*wasmbindingstypes.RequestResponse, error) {
func performMsgCancelVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVestCW) (*wasmbindingstypes.RequestResponse, error) {
if msgCancelVest == nil {
return nil, wasmvmtypes.InvalidRequest{Err: "Invalid cancel vesting parameter"}
}

msgServer := commitmentkeeper.NewMsgServerImpl(*f)
msgMsgCancelVest := commitmenttypes.NewMsgCancelVest(msgCancelVest.Creator, msgCancelVest.Amount, msgCancelVest.Denom)
msgMsgCancelVest := commitmenttypes.NewMsgCancelVest(msgCancelVest.Address, msgCancelVest.Amount, msgCancelVest.Denom)

if err := msgMsgCancelVest.ValidateBasic(); err != nil {
return nil, errorsmod.Wrap(err, "failed validating msgMsgCancelVest")
Expand Down
4 changes: 2 additions & 2 deletions x/commitment/client/wasm/msg_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt
// USDC
if msgStake.Asset == baseCurrency {
msgServer := stablekeeper.NewMsgServerImpl(*m.stableKeeper)
msgMsgBond := stabletypes.NewMsgBond(msgStake.Creator, msgStake.Amount)
msgMsgBond := stabletypes.NewMsgBond(msgStake.Address, msgStake.Amount)

if err = msgMsgBond.ValidateBasic(); err != nil {
return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgBond")
Expand All @@ -51,7 +51,7 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt
} else {
// Elys, Eden, Eden Boost
msgServer := commitmentkeeper.NewMsgServerImpl(*m.keeper)
msgMsgStake := commitmenttypes.NewMsgStake(msgStake.Creator, msgStake.Amount, msgStake.Asset, msgStake.ValidatorAddress)
msgMsgStake := commitmenttypes.NewMsgStake(msgStake.Address, msgStake.Amount, msgStake.Asset, msgStake.ValidatorAddress)

if err = msgMsgStake.ValidateBasic(); err != nil {
return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgStake")
Expand Down
4 changes: 2 additions & 2 deletions x/commitment/client/wasm/msg_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg
// USDC
if msgUnstake.Asset == baseCurrency {
msgServer := stablekeeper.NewMsgServerImpl(*m.stableKeeper)
msgMsgUnBond := stabletypes.NewMsgUnbond(msgUnstake.Creator, msgUnstake.Amount)
msgMsgUnBond := stabletypes.NewMsgUnbond(msgUnstake.Address, msgUnstake.Amount)

if err = msgMsgUnBond.ValidateBasic(); err != nil {
return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgBond")
Expand All @@ -50,7 +50,7 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg
}
} else {
msgServer := commitmentkeeper.NewMsgServerImpl(*m.keeper)
msgMsgUnstake := commitmenttypes.NewMsgUnstake(msgUnstake.Creator, msgUnstake.Amount, msgUnstake.Asset, msgUnstake.ValidatorAddress)
msgMsgUnstake := commitmenttypes.NewMsgUnstake(msgUnstake.Address, msgUnstake.Amount, msgUnstake.Asset, msgUnstake.ValidatorAddress)

if err = msgMsgUnstake.ValidateBasic(); err != nil {
return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgUnstake")
Expand Down
6 changes: 3 additions & 3 deletions x/commitment/client/wasm/msg_vest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
paramtypes "github.com/elys-network/elys/x/parameter/types"
)

func (m *Messenger) msgVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgVest *commitmenttypes.MsgVest) ([]sdk.Event, [][]byte, error) {
func (m *Messenger) msgVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgVest *commitmenttypes.MsgVestCW) ([]sdk.Event, [][]byte, error) {
if msgVest == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Vest null msg"}
}
Expand Down Expand Up @@ -43,13 +43,13 @@ func (m *Messenger) msgVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgVes
return nil, resp, nil
}

func performMsgVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgVest *commitmenttypes.MsgVest) (*wasmbindingstypes.RequestResponse, error) {
func performMsgVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgVest *commitmenttypes.MsgVestCW) (*wasmbindingstypes.RequestResponse, error) {
if msgVest == nil {
return nil, wasmvmtypes.InvalidRequest{Err: "Invalid vesting parameter"}
}

msgServer := commitmentkeeper.NewMsgServerImpl(*f)
msgMsgVest := commitmenttypes.NewMsgVest(msgVest.Creator, msgVest.Amount, msgVest.Denom)
msgMsgVest := commitmenttypes.NewMsgVest(msgVest.Address, msgVest.Amount, msgVest.Denom)

if err := msgMsgVest.ValidateBasic(); err != nil {
return nil, errorsmod.Wrap(err, "failed validating msgVest")
Expand Down
4 changes: 2 additions & 2 deletions x/commitment/keeper/msg_server_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (k msgServer) performStakeElys(ctx sdk.Context, msg *types.MsgStake) error

msgServer := stakingkeeper.NewMsgServerImpl(stakingKeeper)

address, err := sdk.AccAddressFromBech32(msg.Creator)
address, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
return errorsmod.Wrap(err, "invalid address")
}
Expand All @@ -63,7 +63,7 @@ func (k msgServer) performStakeElys(ctx sdk.Context, msg *types.MsgStake) error
}

func (k msgServer) performCommit(ctx sdk.Context, msg *types.MsgStake) error {
msgMsgCommit := types.NewMsgCommitClaimedRewards(msg.Creator, msg.Amount, msg.Asset)
msgMsgCommit := types.NewMsgCommitClaimedRewards(msg.Address, msg.Amount, msg.Asset)

if err := msgMsgCommit.ValidateBasic(); err != nil {
return errorsmod.Wrap(err, "failed validating msgMsgCommit")
Expand Down
4 changes: 2 additions & 2 deletions x/commitment/keeper/msg_server_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (k msgServer) performUnstakeElys(ctx sdk.Context, msg *types.MsgUnstake) er

msgServer := stakingkeeper.NewMsgServerImpl(stakingKeeper)

address, err := sdk.AccAddressFromBech32(msg.Creator)
address, err := sdk.AccAddressFromBech32(msg.Address)
if err != nil {
return errorsmod.Wrap(err, "invalid address")
}
Expand All @@ -64,7 +64,7 @@ func (k msgServer) performUnstakeElys(ctx sdk.Context, msg *types.MsgUnstake) er
}

func (k msgServer) performUncommit(ctx sdk.Context, msg *types.MsgUnstake) error {
msgMsgUncommit := types.NewMsgUncommitTokens(msg.Creator, msg.Amount, msg.Asset)
msgMsgUncommit := types.NewMsgUncommitTokens(msg.Address, msg.Amount, msg.Asset)

if err := msgMsgUncommit.ValidateBasic(); err != nil {
return errorsmod.Wrap(err, "failed validating msgMsgUncommit")
Expand Down
5 changes: 3 additions & 2 deletions x/commitment/types/message_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const TypeMsgStake = "stake"

var _ sdk.Msg = &MsgStake{}

func NewMsgStake(creator string, amount sdk.Int, asset string, validatorAddress string) *MsgStake {
func NewMsgStake(address string, amount sdk.Int, asset string, validatorAddress string) *MsgStake {
return &MsgStake{
Creator: creator,
Creator: address,
Address: address,
Amount: amount,
Asset: asset,
ValidatorAddress: validatorAddress,
Expand Down
5 changes: 3 additions & 2 deletions x/commitment/types/message_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const TypeMsgUnstake = "unstake"

var _ sdk.Msg = &MsgUnstake{}

func NewMsgUnstake(creator string, amount sdk.Int, asset string, validatorAddress string) *MsgUnstake {
func NewMsgUnstake(address string, amount sdk.Int, asset string, validatorAddress string) *MsgUnstake {
return &MsgUnstake{
Creator: creator,
Creator: address,
Address: address,
Amount: amount,
Asset: asset,
ValidatorAddress: validatorAddress,
Expand Down
Loading
Loading