@@ -81,19 +81,20 @@ func (k msgServer) BondDappProposal(goCtx context.Context, msg *types.MsgBondDap
81
81
return nil , types .ErrInvalidDappBondDenom
82
82
}
83
83
84
+ dapp .TotalBond = dapp .TotalBond .Add (msg .Bond )
85
+
86
+ properties := k .keeper .gk .GetNetworkProperties (ctx )
87
+ if dapp .TotalBond .Amount .GT (sdk .NewInt (int64 (properties .MaxDappBond )).Mul (sdk .NewInt (1000_000 ))) {
88
+ return nil , types .ErrMaxDappBondReached
89
+ }
90
+
84
91
// send initial bond to module account
85
92
addr := sdk .MustAccAddressFromBech32 (msg .Sender )
86
93
err := k .keeper .bk .SendCoinsFromAccountToModule (ctx , addr , types .ModuleName , sdk.Coins {msg .Bond })
87
94
if err != nil {
88
95
return nil , err
89
96
}
90
97
91
- properties := k .keeper .gk .GetNetworkProperties (ctx )
92
- if dapp .TotalBond .Amount .GTE (sdk .NewInt (int64 (properties .MaxDappBond )).Mul (sdk .NewInt (1000_000 ))) {
93
- return nil , types .ErrMaxDappBondReached
94
- }
95
-
96
- dapp .TotalBond = dapp .TotalBond .Add (msg .Bond )
97
98
k .keeper .SetDapp (ctx , dapp )
98
99
99
100
userDappBond := k .keeper .GetUserDappBond (ctx , msg .DappName , msg .Sender )
@@ -114,6 +115,11 @@ func (k msgServer) BondDappProposal(goCtx context.Context, msg *types.MsgBondDap
114
115
func (k msgServer ) ReclaimDappBondProposal (goCtx context.Context , msg * types.MsgReclaimDappBondProposal ) (* types.MsgReclaimDappBondProposalResponse , error ) {
115
116
ctx := sdk .UnwrapSDKContext (goCtx )
116
117
118
+ dapp := k .keeper .GetDapp (ctx , msg .DappName )
119
+ if dapp .Name == "" {
120
+ return nil , types .ErrDappDoesNotExist
121
+ }
122
+
117
123
userDappBond := k .keeper .GetUserDappBond (ctx , msg .DappName , msg .Sender )
118
124
if userDappBond .DappName == "" {
119
125
return nil , types .ErrUserDappBondDoesNotExist
@@ -125,8 +131,7 @@ func (k msgServer) ReclaimDappBondProposal(goCtx context.Context, msg *types.Msg
125
131
return nil , types .ErrNotEnoughUserDappBond
126
132
}
127
133
128
- userDappBond .Bond .Amount = userDappBond .Bond .Amount .Sub (msg .Bond .Amount )
129
- k .keeper .SetUserDappBond (ctx , userDappBond )
134
+ dapp .TotalBond = dapp .TotalBond .Sub (msg .Bond )
130
135
131
136
// send tokens back to user
132
137
addr := sdk .MustAccAddressFromBech32 (msg .Sender )
@@ -135,6 +140,11 @@ func (k msgServer) ReclaimDappBondProposal(goCtx context.Context, msg *types.Msg
135
140
return nil , err
136
141
}
137
142
143
+ k .keeper .SetDapp (ctx , dapp )
144
+
145
+ userDappBond .Bond .Amount = userDappBond .Bond .Amount .Sub (msg .Bond .Amount )
146
+ k .keeper .SetUserDappBond (ctx , userDappBond )
147
+
138
148
return & types.MsgReclaimDappBondProposalResponse {}, nil
139
149
}
140
150
0 commit comments