utils

Contains a mix of dev utilities like running FastAPI in a notebook or creating test wallets.

Onchain


source

create_test_wallet

 create_test_wallet (fund=True, chain='base-sepolia')

Utilities to run FastAPI in a notebook


source

ServerManager

 ServerManager (app, port=8000, host='0.0.0.0')

Initialize self. See help(type(self)) for accurate signature.


source

wait_port_free

 wait_port_free (port, host='localhost', max_wait=3)

source

is_port_free

 is_port_free (port, host='localhost')
# #| export

# def run_l402_server(PRClass, port=9000):
#     app = FastAPI()

#     server = ServerManager(app, port=port).start()

#     @app.get("/offers")
#     def offers():
#         offers_list = [{
#             "amount": 1,
#             "currency": 'USD',
#             "description": 'Purchase 1 credit for API access',
#             "offer_id": 'xxxx',
#             "payment_methods": ['onchain'],
#             "title": '1 Credit Package',
#             type='one-time'
#         )]

        
#         return JSONResponse(
#             content=offers_response.model_dump(),
#             status_code=402
#         )

#     @app.post("/payment_request")
#     async def create_payment_request(request: PRClass):
#         payment_request = ps.create_payment_request(**request.model_dump())
#         return JSONResponse(
#             content=payment_request,
#             status_code=200
#         )