Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Custom HTTPClients for Algod and Indexer clients #277

Closed
wants to merge 3 commits into from
Closed

Enable Custom HTTPClients for Algod and Indexer clients #277

wants to merge 3 commits into from

Conversation

janmarcano
Copy link

@janmarcano janmarcano commented Feb 4, 2021

Allows for a custom HTTPClient to be provided for Algod and Indexer clients during creation

@CLAassistant
Copy link

CLAassistant commented Feb 4, 2021

CLA assistant check
All committers have signed the CLA.

@jasonpaulos
Copy link
Contributor

Hi @janmarcano, thanks for contributing. I'm curious, what is the added benefit or use case for passing in a custom HTTP client?

@janmarcano
Copy link
Author

Hi @jasonpaulos !

The purpose would be to enable the possibility for external Algorand apps/client to integrate themselves into the SDK calls.

An example would be to use AlgoSigner to handle the API calls:

const c = AlgoSigner.getAlgodHTTPClient('TestNet');
const algod = new algosdk.Algodv2(null, null, null, null, c);
await algod.getTransactionParams().do();

This way, all calls are made using AlgoSigner's backend.

@ian-algorand ian-algorand added this to the Sprint 18 milestone Feb 8, 2021
@algorotem
Copy link
Contributor

algorotem commented Mar 19, 2021

Hi @janmarcano,

Thanks for the PR. We believe that enabling the custom client without a proper layer of abstraction will bind us to a specific set and may make future handling difficult and therefore I can't approve this PR.
We suggest wrapping the creation of the client with another function that also overrides the internal one. This will also provide a cleaner API for the users (no need for several nulls).
e.g.

AlgoSigner.makeAlgodClient(...) 

where internally you have

algod.c = CustomClient

@algorotem algorotem closed this Mar 19, 2021
jdtzmn added a commit that referenced this pull request Mar 30, 2021
ServiceClient, which includes an HTTPClient property, allows overwriting the HTTPClient instance.

This functionality is required by:
#277 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants