1010
1111from aleph_client .chains .common import get_fallback_private_key
1212from aleph_client .chains .ethereum import ETHAccount
13- from aleph_client .main import create_aggregate
13+ from aleph_client import AuthenticatedUserSession
14+ from aleph_client .conf import settings
1415
1516
1617def get_input_data (value ):
@@ -26,7 +27,12 @@ def get_input_data(value):
2627
2728
2829def send_metrics (account , metrics ):
29- return create_aggregate (account , "metrics" , metrics , channel = "SYSINFO" )
30+ with AuthenticatedUserSession (
31+ account = account , api_server = settings .API_HOST
32+ ) as session :
33+ return session .create_aggregate (
34+ key = "metrics" , content = metrics , channel = "SYSINFO"
35+ )
3036
3137
3238def on_disconnect (client , userdata , rc ):
@@ -95,10 +101,15 @@ async def gateway(
95101 if not userdata ["received" ]:
96102 await client .reconnect ()
97103
98- for key , value in state .items ():
99- message , status = create_aggregate (account , key , value , channel = "IOT_TEST" )
100- print ("sent" , message .item_hash )
101- userdata ["received" ] = False
104+ async with AuthenticatedUserSession (
105+ account = account , api_server = settings .API_HOST
106+ ) as session :
107+ for key , value in state .items ():
108+ message , status = await session .create_aggregate (
109+ key = key , content = value , channel = "IOT_TEST"
110+ )
111+ print ("sent" , message .item_hash )
112+ userdata ["received" ] = False
102113
103114
104115@click .command ()
0 commit comments