File size: 1,487 Bytes
53d87a8
 
 
27d2d77
f12c8de
abffee1
c1e0d27
f12c8de
abffee1
53d87a8
c1e0d27
ebe4380
c1e0d27
 
 
 
 
 
 
 
 
 
 
 
6ed97bd
 
 
53d87a8
 
 
6ed97bd
f12c8de
 
dccd82e
f12c8de
 
90eb2ae
dccd82e
 
 
 
6ed97bd
f12c8de
 
 
cc96934
f12c8de
 
 
c164a3f
e7a6ce3
f12c8de
3e60f5b
e7a6ce3
f12c8de
 
 
dccd82e
cc96934
dccd82e
 
dfb1b6c
e7a6ce3
dccd82e
 
fb7d059
dccd82e
dfb1b6c
dccd82e
6ed97bd
 
 
 
 
7dd0efe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from fastapi import FastAPI,Request,HTTPException,Response
from pydantic import BaseModel
from fastapi.responses import JSONResponse
from components.mongodbconnection import provideClient
from components.agentcreation import VelocityPayableAgent
from components.agentcreation import load_keypair
from fastapi.middleware.cors import CORSMiddleware


app=FastAPI()

origins=["*"]
app.add_middleware(
        CORSMiddleware,
        allow_origins=origins,
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
)





client=provideClient()
db=client["agentpaymentdb"]
coll=db["agentpaymentcol"]





class Agent(BaseModel):
      agent_id:str



class Payment(BaseModel):
      instruction:str
      
        



@app.post("/init_agent")
async def AgentI(request:Agent):
    
    try:
        velocitypayableinstance=VelocityPayableAgent()
        await velocitypayableinstance.Agentinit(request.agent_id)
        return {"status_":True}
    except Exception as e:
        print(e)
        return {"status_":False}
        
        

@app.post("/payment")
async def PaymentInstruction(request:Payment):
    try:
         velocitypayableinstance=VelocityPayableAgent()
         output=velocitypayableinstance.Agent(request.instruction)
         return {"status_":output}
        
    except error:
         return {"status_":False}
        
            

@app.get("/agent/{id}")
def getAgentKey(id):
    pkey=load_keypair(id)
    return {"wallet":pkey}