Commit 201d1562 authored by 陈涛's avatar 陈涛

node查询接口增加鉴权

parent 73a781ba
......@@ -61,25 +61,43 @@ async def unsubscribe(
return BaseResponse(data='解绑成功')
@router.get("/validator/{index_or_pubkey}/", response_model=Response[Validator], summary="查询节点详情", description="")
async def node_get_validator(
index_or_pubkey: Union[int, str],
beacon_service: BeaconChaService = Depends(BeaconChaService)
@router.get("/info/{pub_key}/", response_model=Response[Validator], summary="查询节点详情", description="")
async def get_node_info(
fund_id: str,
pub_key: str,
user: User = Depends(dependencies.get_current_user),
beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
validator_detail = await beacon_service.get_validator(index_or_pubkey)
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
assert fund, NotFundError()
validator_detail = await beacon_service.get_validator(pub_key)
response = Response[Validator](data=validator_detail)
return response
@router.get(
"/validator/deposit/{index_or_pubkey}/",
"/deposit/{pub_key}/",
response_model=Response[List[ValidatorDeposit]],
summary="查询节点充值记录", description="")
async def node_get_validator_deposit(
index_or_pubkey: Union[int, str],
beacon_service: BeaconChaService = Depends(BeaconChaService)
async def get_node_deposit(
fund_id: str,
pub_key: str,
user: User = Depends(dependencies.get_current_user),
beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
validator_deposit = await beacon_service.get_validator_deposit(index_or_pubkey)
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
assert fund, NotFundError()
validator_deposit = await beacon_service.get_validator_deposit(pub_key)
response = Response[List[ValidatorDeposit]](data=validator_deposit)
return response
......@@ -118,14 +136,23 @@ async def node_get_validator_deposit(
@router.get(
"/validator/income/{index_or_pubkey}/",
"/validator/income/{pub_key}/",
response_model=Response[ValidatorIncome],
summary="查询节点收益", description="")
async def node_get_validator_deposit(
index_or_pubkey: Union[int, str],
fund_id: str,
pub_key: str,
user: User = Depends(dependencies.get_current_user),
beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
validator_income = await beacon_service.get_validator_income(indexOrPubkey=index_or_pubkey)
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
assert fund, NotFundError()
validator_income = await beacon_service.get_validator_income(indexOrPubkey=pub_key)
assert validator_income, "没有查到收益"
response = Response[ValidatorIncome](data=validator_income[0])
return response
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment