ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.87k stars 1.82k forks source link

Overridable getHost() or hostFactory parameter #3764

Open ErrorEater opened 1 year ago

ErrorEater commented 1 year ago

Describe the Feature

Providers like Pocket and Ankr have support for Bincan Smart Chain but their getHost() functions don't implement BSC host creation which is a simple string value. An overridable getHost() function or a callback parameter will allow user's to be able to provide solution to such unsupported hosts.

Code Example

constructor(_network?: Networkish, applicationId?: null | string, applicationSecret?: null | string, hostFactory?: (name: string) => string) {
}

static getRequest(network: Network, applicationId?: null | string, applicationSecret?: null | string, hostFactory?: (name: string) => string): FetchRequest {
    var host = hostFactory !== undefined ? hostFactory(network.name) : getHost(network.name);
}
kunaldo07 commented 1 year ago

Hey @aliveli186 , can I work on this issue?

ricmoo commented 1 year ago

I hadn’t thought of this, but is something I could consider for a future minor release. It won’t be a parameter, and would instead be a method that would need to be overridden.