def get_callback_cooked(state: str, id: int, db: Session = Depends(get_db)): order_orm = crud.get_order(db=db, id=id) updates = schemas.Order_Result.from_orm(order_orm).get_updates(state) crud.update_order(db=db, id=id, updates=updates) order_orm = crud.get_order(db=db, id=id) order_res = schemas.Order_Result.from_orm(order_orm).to_result() order_resp = schemas.JadeResp(result=order_res.dict(by_alias=True)) order_resp.sign(config["privateKey"]) return order_resp.callback(config["callback"])
async def post_api_v2_address__new(coinName: str, req: schemas.JadeReq): ts = int(time.time() * 1000) asset = config.get("assets").get(coinName, {}) address = GlassBlock(asset.get("type", "")).get_address() address_res = schemas.Address_Result(type=coinName, address=address, mode=req.data.get("mode"), create_at=ts, update_at=ts) address_resp = schemas.JadeResp(result=address_res.dict()) address_resp.sign(config["privateKey"]) return address_resp
def post_api_v2_wallet__withdraw(coinName: str, req: schemas.JadeReq, db: Session = Depends(get_db)): asset = config.get("assets").get(coinName, {}) order_init = schemas.Order_Result.init_order( bizType="WITHDRAW", coinName=coinName, type=asset.get("type", ""), to=req.data.get("to", ""), value=req.data.get("value", ""), sequence=req.data.get("sequence")) order_orm = crud.create_order(db=db, order=order_init) order_res = schemas.Order_Result.from_orm(order_orm).to_result() order_resp = schemas.JadeResp(result=order_res.dict(by_alias=True)) order_resp.sign(config["privateKey"]) return order_resp
async def post_callback_raw(order_res: schemas.Order_Result): order_resp = schemas.JadeResp(result=order_res.to_result().dict( by_alias=True)) order_resp.sign(config["privateKey"]) return order_resp.callback(config["callback"])
def get_api_v2_orders_(id: int, db: Session = Depends(get_db)): order_orm = crud.get_order(db=db, id=id) order_res = schemas.Order_Result.from_orm(order_orm).to_result() order_resp = schemas.JadeResp(result=order_res.dict(by_alias=True)) order_resp.sign(config["privateKey"]) return order_resp