Plateforme de decisions collectives pour Duniter/G1. Backend FastAPI async + PostgreSQL (14 tables, 8 routers, 6 services, moteur de vote avec formule d'inertie WoT/Smith/TechComm). Frontend Nuxt 4 + Nuxt UI v3 + Pinia (9 pages, 5 stores). Infrastructure Docker + Woodpecker CI + Traefik. Documentation technique et utilisateur (15 fichiers). Seed : Licence G1, Engagement Forgeron v2.0.0, 4 protocoles de vote. 30 tests unitaires (formules, mode params, vote nuance) -- tous verts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
"""Blockchain service: retrieve on-chain data from Duniter V2.
|
|
|
|
Provides functions to query WoT size, Smith sub-WoT size, and
|
|
Technical Committee size from the Duniter V2 blockchain.
|
|
|
|
Currently stubbed with hardcoded values matching GDev test data.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
async def get_wot_size() -> int:
|
|
"""Return the current number of WoT members.
|
|
|
|
TODO: Implement real RPC call using substrate-interface::
|
|
|
|
from substrateinterface import SubstrateInterface
|
|
from app.config import settings
|
|
|
|
substrate = SubstrateInterface(url=settings.DUNITER_RPC_URL)
|
|
|
|
# Query membership count
|
|
result = substrate.query(
|
|
module="Membership",
|
|
storage_function="MembershipCount",
|
|
)
|
|
return int(result.value)
|
|
|
|
Returns
|
|
-------
|
|
int
|
|
Number of WoT members. Currently returns 7224 (GDev snapshot).
|
|
"""
|
|
# TODO: Replace with real substrate-interface RPC call
|
|
return 7224
|
|
|
|
|
|
async def get_smith_size() -> int:
|
|
"""Return the current number of Smith members (forgerons).
|
|
|
|
TODO: Implement real RPC call using substrate-interface::
|
|
|
|
from substrateinterface import SubstrateInterface
|
|
from app.config import settings
|
|
|
|
substrate = SubstrateInterface(url=settings.DUNITER_RPC_URL)
|
|
|
|
# Query Smith membership count
|
|
result = substrate.query(
|
|
module="SmithMembers",
|
|
storage_function="SmithMembershipCount",
|
|
)
|
|
return int(result.value)
|
|
|
|
Returns
|
|
-------
|
|
int
|
|
Number of Smith members. Currently returns 20 (GDev snapshot).
|
|
"""
|
|
# TODO: Replace with real substrate-interface RPC call
|
|
return 20
|
|
|
|
|
|
async def get_techcomm_size() -> int:
|
|
"""Return the current number of Technical Committee members.
|
|
|
|
TODO: Implement real RPC call using substrate-interface::
|
|
|
|
from substrateinterface import SubstrateInterface
|
|
from app.config import settings
|
|
|
|
substrate = SubstrateInterface(url=settings.DUNITER_RPC_URL)
|
|
|
|
# Query TechComm member count
|
|
result = substrate.query(
|
|
module="TechnicalCommittee",
|
|
storage_function="Members",
|
|
)
|
|
return len(result.value) if result.value else 0
|
|
|
|
Returns
|
|
-------
|
|
int
|
|
Number of TechComm members. Currently returns 5 (GDev snapshot).
|
|
"""
|
|
# TODO: Replace with real substrate-interface RPC call
|
|
return 5
|