-
Notifications
You must be signed in to change notification settings - Fork 155
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
perf: Optimizing Loading time for Injected Wallets #704
Conversation
@HarisSQA @kujtimprenkuSQA I suggest if the user already has a selected wallet - only it is initialized, and the rest are initialized in the background. This should accelerate the load until the application has API selected wallet in the last session |
Thank you for your feedback, the loading time in Desktop is heavily impacted by the extensions some of the injected (extension) wallets take some time to be added on the At least the idea of this PR is to improve the loading time in general and also on mobile devices for example for injected (extension) wallets we don't need to wait and check if these wallets are installed because by default they will never be available there. |
@kujtimprenkuSQA But why we need wait until all wallets are injected, if this can be done during a direct call to a specific wallet? const selector = await setupWalletSelector([ ... ]) // very fast!
// And then we wait if necessary
await selector.wallet("sender") |
… the timeout for 100ms
This is needed because sometimes the isInstalled function is returning false even though the extension is installed.
This is needed because sometimes even when the extension is installed the isInstalled function is returning false.
…stalled This will speed up the setupWalletSelector on mobile devices since we return null for these wallets anyway we do not need to wait and check if these wallets are installed or not.
Description
This PR is about reducing the amout of time for the
setupWalletSelector
when all wallets are included in themodules
array.Went for many small commits only to clarify why and where the changes were necessary.
timeout
from 200ms to 100ms forwaitFor
helper function.isSignedIn()
on Sender and Finer Wallet only if the wallet is installed this speeds up the loading time up to 300ms when wallet is not installed.waitFor
helper function for theisInstalled
function for Narwallets (by default this function used to wait up to 2s when wallet was not installed).waitFor
from places where it was not needed.timeout
indetectEthereumProvider
in Neth Account to 100ms.null
for these wallets in mobile devices anyway so we don't have to wait and check forisInstalled
function.Demo
To see the difference disable all wallet extensions and try to load these two examples:
Live Demo including these changes https://kujtimprenkusqa.github.io/wallet-selector/
Live Demo of current change in
main
branch: https://near.github.io/wallet-selector/Conclusion
(On Desktop) These changes when all wallets are included in the
modules
array speed up thesetupWalletSelector
up to 90%.(On Mobile) There's no delay/waiting anymore.
Checklist:
Type of change.