Junaidb commited on
Commit
38cbdbe
·
verified ·
1 Parent(s): 4575e19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -12
app.py CHANGED
@@ -88,6 +88,7 @@ class RegisterPayload(BaseModel):
88
  owner:str
89
  description:str
90
  meta:str
 
91
 
92
 
93
 
@@ -98,6 +99,9 @@ class RegisterPayloadDynamic(BaseModel):
98
  description:str
99
  tag:str
100
  meta:str
 
 
 
101
 
102
 
103
 
@@ -125,6 +129,23 @@ class Invoice(BaseModel):
125
 
126
 
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
 
130
 
@@ -166,7 +187,6 @@ def UpdateMarketData(endpoint_method,status_code):
166
 
167
 
168
 
169
-
170
  #GET requests proxy
171
  async def X402Proxy_GET(request: Request, endpoint: str):
172
  async with httpx.AsyncClient() as client:
@@ -296,9 +316,12 @@ def RegisterEndpoint(data:RegisterPayload):
296
  "endpoint":data.endpoint,
297
  "meta":data.meta,
298
  "endpoint_linker":short_id_e,
 
299
  "invoices":[]
300
  }
301
 
 
 
302
  coll.update_one(
303
  {"owner": data.owner},
304
  {"$push": {"endpoints": payload}}
@@ -307,12 +330,12 @@ def RegisterEndpoint(data:RegisterPayload):
307
 
308
  marketpayload={
309
 
310
- "owner":data.owner,
311
- "endpoint_linker":short_id_e,
312
- "meta":data.meta,
313
- "description":data.description,
314
  "endpoint_method":"",
315
- "endpoint_mcp_base:"https://mcpv100-production.up.railway.app/mcp:8080",
316
  "calls":0,
317
  "failures":0
318
 
@@ -347,6 +370,7 @@ def RegisterDynamicEndpoint(data:RegisterPayloadDynamic):
347
  "description":data.description,
348
  "meta":data.meta,
349
  "endpoint_linker":f"{data.tag}",
 
350
  "invoices":[]
351
  }
352
 
@@ -363,14 +387,14 @@ def RegisterDynamicEndpoint(data:RegisterPayloadDynamic):
363
 
364
  marketpayload={
365
 
366
- "owner":data.owner,
367
- "endpoint_linker":short_id_e,
368
- "meta":data.meta,
369
- "description":data.description,
370
  "endpoint_method":"",
371
- "endpoint_mcp_base:"https://mcpv100-production.up.railway.app/mcp:8080",
372
  "calls":0,
373
- "failures":0
374
 
375
 
376
  }
@@ -519,9 +543,14 @@ async def FetchVelocityGET(x402id:str,request:Request):
519
 
520
 
521
  wallet=request.headers.get("x-wallet")
 
 
522
  print(wallet)
523
  document=coll.find_one({"owner":wallet})
524
 
 
 
 
525
  found_endpoint=None
526
 
527
  if "x402" in x402id:
@@ -769,6 +798,7 @@ async def FetchVelocityPost(request:Request):
769
 
770
  wallet=request.headers.get("x-wallet")
771
  x402id=request.headers.get("x402id")
 
772
 
773
  print(wallet)
774
  document=coll.find_one({"owner":wallet})
 
88
  owner:str
89
  description:str
90
  meta:str
91
+ price:str
92
 
93
 
94
 
 
99
  description:str
100
  tag:str
101
  meta:str
102
+ price:str
103
+
104
+
105
 
106
 
107
 
 
129
 
130
 
131
 
132
+ LAMPORTS_PER_SOL = 1_000_000_000
133
+
134
+ def to_lamports(sol: str | float | int) -> int:
135
+ """
136
+ Convert a human-readable SOL amount (e.g. "2", 0.05) to lamports (int).
137
+ Example: "2.5" -> 2500000000
138
+ """
139
+ try:
140
+ sol_value = float(sol)
141
+ if sol_value < 0:
142
+ raise ValueError("Amount cannot be negative")
143
+ return int(sol_value * LAMPORTS_PER_SOL)
144
+ except (ValueError, TypeError):
145
+ raise ValueError(f"Invalid SOL amount: {sol}")
146
+
147
+
148
+
149
 
150
 
151
 
 
187
 
188
 
189
 
 
190
  #GET requests proxy
191
  async def X402Proxy_GET(request: Request, endpoint: str):
192
  async with httpx.AsyncClient() as client:
 
316
  "endpoint":data.endpoint,
317
  "meta":data.meta,
318
  "endpoint_linker":short_id_e,
319
+ "price":data.price,
320
  "invoices":[]
321
  }
322
 
323
+
324
+
325
  coll.update_one(
326
  {"owner": data.owner},
327
  {"$push": {"endpoints": payload}}
 
330
 
331
  marketpayload={
332
 
333
+ "owner":data.owner,
334
+ "endpoint_linker":short_id_e,
335
+ "meta":data.meta,
336
+ "description":data.description,
337
  "endpoint_method":"",
338
+ "endpoint_mcp_base":"https://mcpv100-production.up.railway.app/mcp:8080",
339
  "calls":0,
340
  "failures":0
341
 
 
370
  "description":data.description,
371
  "meta":data.meta,
372
  "endpoint_linker":f"{data.tag}",
373
+ "price":data.price,
374
  "invoices":[]
375
  }
376
 
 
387
 
388
  marketpayload={
389
 
390
+ "owner":data.owner,
391
+ "endpoint_linker":short_id_e,
392
+ "meta":data.meta,
393
+ "description":data.description,
394
  "endpoint_method":"",
395
+ "endpoint_mcp_base":"https://mcpv100-production.up.railway.app/mcp:8080",
396
  "calls":0,
397
+ "failures":0
398
 
399
 
400
  }
 
543
 
544
 
545
  wallet=request.headers.get("x-wallet")
546
+ price=request.headers.get("x-price")
547
+
548
  print(wallet)
549
  document=coll.find_one({"owner":wallet})
550
 
551
+
552
+
553
+
554
  found_endpoint=None
555
 
556
  if "x402" in x402id:
 
798
 
799
  wallet=request.headers.get("x-wallet")
800
  x402id=request.headers.get("x402id")
801
+ price=request.headers.get("x-price")
802
 
803
  print(wallet)
804
  document=coll.find_one({"owner":wallet})