npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@exodus/restore-progress-tracker

v3.6.0

Published

Tracks progress of restoring a wallet's full transaction history across assets

Downloads

11,294

Readme

@exodus/restore-progress-tracker

This feature enables tracking of restore progress for individual assets. During the restore process, you can check if an asset has been restored or not. Additionally, it prevents the application from switching to a restored state until all assets are successfully restored.

How It Works

1. Feature Creation

The feature creates a restoringAssetsAtom storage atom that stores data in the form of a map:

const restoringAssets = { bitcoin: false, ethereum: true }

This map keeps track of which assets are currently being restored.

2. Event Tracking and Subscription

During the module's initialization in the constructor, it sets up subscriptions to txLogMonitors to track specific events:

  • ['after-tick-multiple-wallet-accounts', 'after-restore']: These events are tracked by default but can be configured.
  • unknown-tokens: This event is also tracked. (more on this below)

3. Restore Process Initiation

Once the headless application module starts the restore process, the restore-progress-tracker plugin calls the restoreAll function for the restore-progress-tracker module. This marks all available assets as restoring.

4. Asset Restoration and Event Emission

After receiving events from txLogMonitors for specific assets, they are marked as restored. If an asset receives an unknown-tokens event before that, it waits for a second monitor tick because newly added tokens need to run the monitor.

Once all assets have received their respective monitor events, the module emits a restored event and unblocks the promise in the plugin. This prevents the onRestore application hook from being completed prematurely.

5. Additional Functionality

The feature allows you to mark individual assets as restored after the restore process is finished. This is particularly useful for monero on-demand restores or EOS/HEDERA account resets.

Usage

This feature is designed to be used together with @exodus/headless. For more details, see using the SDK.

Play with it

  1. Open the playground at https://exodus-hydra.pages.dev/.
  2. Run the command exodus.restoreProgressTracker.restoreAsset('bitcoin'); selectors.restoringAssets.data(store.getState()) in the Dev Tools Console to view the object map of restoring assets including bitcoin.

API Side Configuration and Usage

For more details on how features plug into the SDK and A/B Testing Events, see using the sdk.

// Mark an asset as being restored. The asset will be restored once the monitor ticks.
exodus.restoreProgressTracker.restoreAsset('eosio')

Configurations

Two configurations are available:

  • config.monitorEvents: By default, it listens to 2 monitor events: after-tick-multiple-wallet-accounts, and after-restore.
  • config.assetNamesToNotWait: By default, it includes ['monero']. This means that we don't wait for monero to be restored before marking the wallet as restored.

UI Side Setup

See using the SDK for more details on basic UI-side setup and the useAssetRestoring hook creation.

import { selectors } from '~/ui/flux'

const useAssetRestoring = (assetName) => {
  return useSelector((state) => !!selectors.restoringAssets.data(state)[assetName])
}

This useAssetRestoring hook makes it easy to check if an asset is restored or not.