Skip to content

Commit

Permalink
validate event
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jan 14, 2025
1 parent f18e6f7 commit 3a7a39e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x/lending/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/sideprotocol/side/crypto/adaptor"
dlc "github.com/sideprotocol/side/x/dlc/types"
"github.com/sideprotocol/side/x/lending/types"
)

Expand All @@ -31,7 +30,11 @@ func (m msgServer) Apply(goCtx context.Context, msg *types.MsgApply) (*types.Msg
// return nil, errb
// }

event := dlc.DLCPriceEvent{} // need to integrate with dlc module
if !m.dlcKeeper.HasEvent(ctx, msg.EventId) {
return nil, types.ErrInvalidPriceEvent
}

event := m.dlcKeeper.GetEvent(ctx, msg.EventId)
if event.HasTriggered {
return nil, types.ErrInvalidPriceEvent
}
Expand Down
1 change: 1 addition & 0 deletions x/lending/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type AuctionKeeper interface {

// DLCKeeper defines the expected DLC keeper interface
type DLCKeeper interface {
HasEvent(ctx sdk.Context, id uint64) bool
GetEvent(ctx sdk.Context, id uint64) *dlctypes.DLCPriceEvent
GetAttestationByEvent(ctx sdk.Context, eventId uint64) *dlctypes.DLCAttestation

Expand Down

0 comments on commit 3a7a39e

Please # to comment.