unlock
unlock copied to clipboard
Provide default networks config in unlockjs
Describe the bug Using unlockjs out of the box is tedious for multiple networks right now because developer will need to provide their own config. We don't publish unlock-protocol/networks package because it contains private endpoints.
Proposal I propose modifying the package to allow creating networksConfig from a bunch of options. Leveraging this, we can have private node endpoints customized for our use case as well as provide a default config with option to customize for end users.
import { createNetworksConfig } from "@unlock-protocol/networks"
const NetworkConfigs = createNetworkConfig() // defaults provided
const NetworkConfigs = createNetworkConfig({
"4": {
rpcURL: "https://customized.com/xyz" // replaces the default
}
})
Unfortunately, we can't do that because there are API keys in the network package and we if ship it people's applications might break and we need to be able to change things easily when/if want.
The right approach IMO would be to add a "universal" provider in locksmith: one where we proxy to other RPC providers (we might even rotate between multiple).
Let's talk more about it because we do need a better solution...
@julien51 I think you are misunderstanding. I'm talking about tackling the same issue above by having a function which can be used to create networkConfigs with private api keys but provide default networkConfig.
So we will have our own config created by the function with private endpoints.
const networkConfig = createNetworkConfigs({ "4": {
privateRpcURL: "https://private-unlock-key.com"
} })
Ohh sorry indeed i misunderstood. Yes we can add that.
We now publish @unlock-protocol/networks
so this is much easier.