Adds functionality to configure the Castle extension, including a wallet ID. This allows administrators to customize the extension's behavior by specifying a dedicated wallet for castle operations.
23 lines
673 B
Python
23 lines
673 B
Python
from .crud import (
|
|
create_castle_settings,
|
|
get_castle_settings,
|
|
update_castle_settings,
|
|
)
|
|
from .models import CastleSettings
|
|
|
|
|
|
async def get_settings(user_id: str) -> CastleSettings:
|
|
settings = await get_castle_settings(user_id)
|
|
if not settings:
|
|
settings = await create_castle_settings(user_id, CastleSettings())
|
|
return settings
|
|
|
|
|
|
async def update_settings(user_id: str, data: CastleSettings) -> CastleSettings:
|
|
settings = await get_castle_settings(user_id)
|
|
if not settings:
|
|
settings = await create_castle_settings(user_id, data)
|
|
else:
|
|
settings = await update_castle_settings(user_id, data)
|
|
|
|
return settings
|