From f70d659552f5cef0071426c7e576e36d7d787c6b Mon Sep 17 00:00:00 2001 From: Julian Strobl Date: Wed, 22 Nov 2023 16:46:29 +0100 Subject: [PATCH] Use domain from request in message (#14) Signed-off-by: Julian Strobl --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index b2be44e..5ac0fb7 100644 --- a/main.py +++ b/main.py @@ -50,20 +50,20 @@ def list_files(request: Request): @app.post("/register_asset", status_code=201) -async def register_asset_id(request_body: RegisterRequest): +async def register_asset_id(request_body: RegisterRequest, request: Request): print(f" request_body: { request_body }") print(f" TYPE : {isinstance(request_body.contract, dict)}") print(f" TYPE : {isinstance(request_body.contract, str)}") - if register_asset_id_local(request_body.asset_id): + if register_asset_id_local(request_body.asset_id, str(request.url.netloc)): print(f"File succesffully written: {request_body.asset_id}") register_asset_id_on_liquid(request_body.asset_id, request_body.contract) return {"asset_id": request_body.asset_id} -def register_asset_id_local(asset_id: str): +def register_asset_id_local(asset_id: str, netloc: str): try: f = open(f"{WELL_KNOWN_FOLDER}/liquid-asset-proof-" + asset_id, "w") - f.write("Authorize linking the domain name assets.rddl.io to the Liquid asset " + asset_id) + f.write("Authorize linking the domain name " + netloc + " to the Liquid asset " + asset_id) f.close() except Exception as e: print(f"File Write execption: {e}")