-
-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Is your feature request related to a problem? Please describe.
Found out during the testing that on some environment top-level-await are not properly supported. Which are used to initialize the BLS object if the package is imported directly.
Describe the solution you'd like
The best approach to fit in all cases is to import the BLS from the switchable. And when is appropriate use the init to initialize the object.
import bls, {init} from "@chainsafe/bls/switchable";That init does accept one parameter and it's redundant to identify and pass the parameter for the right implementation. This logic of detecting is already part of the package so we can reuse here. We can provide third option here auto which could be the default value as well. So user don't need to write custom logic and switchable will detect the right implementation.
Describe alternatives you've considered
The alternative safe approach is to use the await import. But that can't be done with correct user experience as code outside that block will not access to the bls object.
Additional context
ChainSafe/lodestar#2723