Skip to content

Commit

Permalink
fix build errors & small var names cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jununifi committed May 20, 2024
1 parent d949b7d commit 8572b30
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
6 changes: 1 addition & 5 deletions x/liquiditypool/keeper/msg_server_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
ctx := sdk.UnwrapSDKContext(goCtx)

var pool = types.Pool{}

id := k.AppendPool(
ctx,
pool,
)
id := k.AppendPool(ctx, pool)

return &types.MsgCreatePoolResponse{
Id: id,
Expand Down
17 changes: 7 additions & 10 deletions x/liquiditypool/keeper/msg_server_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ func (k msgServer) CreatePosition(goCtx context.Context, msg *types.MsgCreatePos
ctx := sdk.UnwrapSDKContext(goCtx)

var position = types.Position{
Sender: msg.Sender,
Address: msg.Sender,
}

id := k.AppendPosition(
ctx,
position,
)
id := k.AppendPosition(ctx, position)

return &types.MsgCreatePositionResponse{
Id: id,
Expand All @@ -31,8 +28,8 @@ func (k msgServer) IncreaseLiquidity(goCtx context.Context, msg *types.MsgIncrea
ctx := sdk.UnwrapSDKContext(goCtx)

var position = types.Position{
Sender: msg.Sender,
Id: msg.Id,
Address: msg.Sender,
Id: msg.Id,
}

// Checks that the element exists
Expand All @@ -42,7 +39,7 @@ func (k msgServer) IncreaseLiquidity(goCtx context.Context, msg *types.MsgIncrea
}

// Checks if the msg sender is the same as the current owner
if msg.Sender != val.Sender {
if msg.Sender != val.Address {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
}

Expand All @@ -55,13 +52,13 @@ func (k msgServer) DecreaseLiquidity(goCtx context.Context, msg *types.MsgDecrea
ctx := sdk.UnwrapSDKContext(goCtx)

// Checks that the element exists
val, found := k.GetPosition(ctx, msg.Id)
position, found := k.GetPosition(ctx, msg.Id)
if !found {
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %d doesn't exist", msg.Id))
}

// Checks if the msg sender is the same as the current owner
if msg.Sender != val.Sender {
if msg.Sender != position.Address {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
}

Expand Down
8 changes: 4 additions & 4 deletions x/liquiditypool/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
PoolCount: 2,
PositionList: []types.Position{
{
Id: 0,
Sender: sample.AccAddress(),
Id: 0,
Address: sample.AccAddress(),
},
{
Id: 1,
Sender: sample.AccAddress(),
Id: 1,
Address: sample.AccAddress(),
},
},
PositionCount: 2,
Expand Down
4 changes: 2 additions & 2 deletions x/liquiditypool/simulation/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func SimulateMsgIncreaseLiquidity(
found = false
)
for _, obj := range allPosition {
simAccount, found = FindAccount(accs, obj.Sender)
simAccount, found = FindAccount(accs, obj.Address)
if found {
position = obj
break
Expand Down Expand Up @@ -101,7 +101,7 @@ func SimulateMsgDecreaseLiquidity(
found = false
)
for _, obj := range allPosition {
simAccount, found = FindAccount(accs, obj.Sender)
simAccount, found = FindAccount(accs, obj.Address)
if found {
position = obj
break
Expand Down

0 comments on commit 8572b30

Please sign in to comment.