-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use lazy loading for tbtc sdk initialization
Here we use lazy loading for tbtc sdk initialization in our threshold-ts lib. Instead of keeping the sdk object we actually store the promise itself in `_sdkPromise` property. This promise is set during the construction of the SDK class and is meant to be resolved once the SDK is fully initialized. The promise is used to ensure that the SDK is initialized only once and that all subsequent retrievals of the SDK instance await this promise, thereby ensuring that the SDK is ready for use before any operations are performed. The promise also facilitates updating the SDK instance dynamically: if a new initialization is triggered (e.g., when a user logs in and provides a new signer), it ensures that the new SDK object replaces any previously pending SDK object, even if the original promise has not yet resolved. To retrieve the SDK object, use the `getSdk()` method. This method will either return the already resolved SDK object or wait until the promise resolves before returning the SDK. Additionally I've changed the `getTransactionConfirmations` method implementation - it does not have to use SDK.
- Loading branch information
1 parent
6441d90
commit 1e4e3ec
Showing
1 changed file
with
56 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters