Spaces:
Sleeping
Sleeping
Update components/agentcreation.py
Browse files
components/agentcreation.py
CHANGED
|
@@ -12,7 +12,7 @@ coll=db["agentpaymentcol"]
|
|
| 12 |
rpc=AsyncClient("https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b")
|
| 13 |
|
| 14 |
|
| 15 |
-
def create_keypair(agent):
|
| 16 |
"""Create a new keypair and return it as MongoDB-friendly format"""
|
| 17 |
keypair = Keypair()
|
| 18 |
keypair_data = {
|
|
@@ -20,7 +20,7 @@ def create_keypair(agent):
|
|
| 20 |
"public_key": str(keypair.pubkey()),
|
| 21 |
"secret_key": bytes(keypair).hex()
|
| 22 |
}
|
| 23 |
-
coll.update_one(
|
| 24 |
{"owner": "system"},
|
| 25 |
{"$push": {"agents": keypair_data}}
|
| 26 |
)
|
|
@@ -94,8 +94,8 @@ class VelocityPayableAgent():
|
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
-
def Agentinit(self,agent):
|
| 98 |
-
create_keypair(agent)
|
| 99 |
|
| 100 |
|
| 101 |
def Agent(self,user_input):
|
|
|
|
| 12 |
rpc=AsyncClient("https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b")
|
| 13 |
|
| 14 |
|
| 15 |
+
async def create_keypair(agent):
|
| 16 |
"""Create a new keypair and return it as MongoDB-friendly format"""
|
| 17 |
keypair = Keypair()
|
| 18 |
keypair_data = {
|
|
|
|
| 20 |
"public_key": str(keypair.pubkey()),
|
| 21 |
"secret_key": bytes(keypair).hex()
|
| 22 |
}
|
| 23 |
+
await coll.update_one(
|
| 24 |
{"owner": "system"},
|
| 25 |
{"$push": {"agents": keypair_data}}
|
| 26 |
)
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
+
async def Agentinit(self,agent):
|
| 98 |
+
await create_keypair(agent)
|
| 99 |
|
| 100 |
|
| 101 |
def Agent(self,user_input):
|