Open 1happybuddha opened 1 year ago
I already have this in place; so the application defines the ICardanoClient interface https://github.com/latheesan-k/GateKeeper/blob/main/application/app/ThirdParty/CardanoClients/ICardanoClient.php
And we have one implementation (i.e. BlockFrost) https://github.com/latheesan-k/GateKeeper/blob/main/application/app/ThirdParty/CardanoClients/BlockFrostClient.php
And I've currently hard coded the service container in Laravel frame to resolve ICardanoClient
-> BlockFrostClient
based on app configuration (currently it's hard coded to BlockFrostClient
, but it can easily come from an env variable)
https://github.com/latheesan-k/GateKeeper/blob/main/application/app/Providers/AppServiceProvider.php#L27
https://github.com/latheesan-k/GateKeeper/blob/main/application/config/gatekeeper.php#L7
So, the application is agnostic of the blockchain client, so we can easily introduce new ones like Koios and others
throughout the code, we simply type hint the interface, but the service container in the framework resolves the client based on configuration.
Since I was working on the MVP fast, the BlockFrostClient
concrete implementation uses curl, perhaps this can be improved to use guzzle.
I saw the interface and the curl client. Sorry if my question wasn't clear. The "half-baked" I was referring to is the current blockfrost-php client from blockfrost. I'm creating a simple, guzzle-based client that I'll add to packagist.
If you're interested, I can create a PR for this project that conforms to your interface and uses the guzzle version to call the API. Let me know.
Sure, I'll take a look at it.
P.S. laravel already has Guzzle as one of the dependency and they have their own fluent wrapper around it, https://laravel.com/docs/9.x/http-client
Might be worth just using this instead; effectively this is all you would need to replace in the call()
method:
$response = Http::withHeaders([
'project_id' => getenv('BLOCKFROST_PROJECT_ID'),
])->get($this->buildEndpoint($requestUri));
Hey, I'm a php dev and have been playing with some local sandbox tools to connect to blockfrost. I started by forking the blockfrost-php app so that I can locally create a project that uses it. But honestly, their php wrapper feels half-baked at this point. Also, I prefer super simple guzzle wrappers that just call endpoints and return responses and catch errors.
If I were to build this simple wrapper, would you be interested in using it for gatekeeper instead of curl (or as a separate configuration option)?