Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
osmosis
Commits
28d9cfbf
Unverified
Commit
28d9cfbf
authored
2 years ago
by
Roman
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
refactor: begin unlock event with uses split lock (#2996)
parent
4fed7db0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
x/lockup/keeper/lock.go
+4
-0
x/lockup/keeper/lock.go
x/lockup/keeper/msg_server.go
+1
-8
x/lockup/keeper/msg_server.go
x/lockup/keeper/msg_server_test.go
+5
-3
x/lockup/keeper/msg_server_test.go
with
10 additions
and
11 deletions
+10
-11
x/lockup/keeper/lock.go
+
4
-
0
View file @
28d9cfbf
...
...
@@ -235,6 +235,10 @@ func (k Keeper) beginUnlock(ctx sdk.Context, lock types.PeriodLock, coins sdk.Co
k
.
hooks
.
OnStartUnlock
(
ctx
,
lock
.
OwnerAddress
(),
lock
.
ID
,
lock
.
Coins
,
lock
.
Duration
,
lock
.
EndTime
)
}
ctx
.
EventManager
()
.
EmitEvents
(
sdk
.
Events
{
createBeginUnlockEvent
(
&
lock
),
})
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
x/lockup/keeper/msg_server.go
+
1
-
8
View file @
28d9cfbf
...
...
@@ -96,14 +96,7 @@ func (server msgServer) BeginUnlocking(goCtx context.Context, msg *types.MsgBegi
return
nil
,
sdkerrors
.
Wrap
(
sdkerrors
.
ErrInvalidRequest
,
err
.
Error
())
}
lock
,
err
=
server
.
keeper
.
GetLockByID
(
ctx
,
msg
.
ID
)
if
err
!=
nil
{
return
nil
,
sdkerrors
.
Wrap
(
sdkerrors
.
ErrInvalidRequest
,
err
.
Error
())
}
ctx
.
EventManager
()
.
EmitEvents
(
sdk
.
Events
{
createBeginUnlockEvent
(
lock
),
})
// N.B. begin unlock event is emitted downstream in the keeper method.
return
&
types
.
MsgBeginUnlockingResponse
{},
nil
}
...
...
This diff is collapsed.
Click to expand it.
x/lockup/keeper/msg_server_test.go
+
5
-
3
View file @
28d9cfbf
...
...
@@ -172,8 +172,8 @@ func (suite *KeeperTestSuite) TestMsgBeginUnlocking() {
suite
.
FundAcc
(
test
.
param
.
lockOwner
,
test
.
param
.
coinsInOwnerAddress
)
msgServer
:=
keeper
.
NewMsgServerImpl
(
suite
.
App
.
LockupKeeper
)
c
:=
sdk
.
WrapSDKContext
(
suite
.
Ctx
)
resp
,
err
:=
msgServer
.
LockTokens
(
c
,
types
.
NewMsgLockTokens
(
test
.
param
.
lockOwner
,
test
.
param
.
duration
,
test
.
param
.
coinsToLock
))
goCtx
:=
sdk
.
WrapSDKContext
(
suite
.
Ctx
)
resp
,
err
:=
msgServer
.
LockTokens
(
goCtx
,
types
.
NewMsgLockTokens
(
test
.
param
.
lockOwner
,
test
.
param
.
duration
,
test
.
param
.
coinsToLock
))
suite
.
Require
()
.
NoError
(
err
)
if
test
.
param
.
isSyntheticLockup
{
...
...
@@ -181,12 +181,14 @@ func (suite *KeeperTestSuite) TestMsgBeginUnlocking() {
suite
.
Require
()
.
NoError
(
err
)
}
_
,
err
=
msgServer
.
BeginUnlocking
(
c
,
types
.
NewMsgBeginUnlocking
(
test
.
param
.
lockOwner
,
resp
.
ID
,
test
.
param
.
coinsToUnlock
))
_
,
err
=
msgServer
.
BeginUnlocking
(
goCtx
,
types
.
NewMsgBeginUnlocking
(
test
.
param
.
lockOwner
,
resp
.
ID
,
test
.
param
.
coinsToUnlock
))
if
test
.
expectPass
{
suite
.
Require
()
.
NoError
(
err
)
suite
.
AssertEventEmitted
(
suite
.
Ctx
,
types
.
TypeEvtBeginUnlock
,
1
)
}
else
{
suite
.
Require
()
.
Error
(
err
)
suite
.
AssertEventEmitted
(
suite
.
Ctx
,
types
.
TypeEvtBeginUnlock
,
0
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets