New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@exodus/balances

Package Overview
Dependencies
Maintainers
0
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/balances

Tracks crypto balances across enabled wallet accounts.

  • 13.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-11.33%
Maintainers
0
Weekly downloads
 
Created
Source

@exodus/balances

This Exodus SDK feature tracks the crypto-denominated balances for all enabled wallet accounts. For fiat-denominated balances, check out @exodus/fiat-balances.

Install

yarn add @exodus/balances

Usage

This feature is designed to be used together with @exodus/headless. See using the sdk.

Play with it

  1. Open the playground https://exodus-hydra.pages.dev/
  2. Run selectors.balances.byAsset(store.getState()) in the Dev Tools Console to get balances by asset aggregated across enabled wallet accounts.
  3. Try out some other selectors from selectors.balances. See example usage in tests.
  4. Mock an address with a balance, tick the blockchain monitor and check your balance.
// mock your ethereum address with one that has a balance
await exodus.debug.addressProvider.mockAddress({
  assetName: 'ethereum',
  walletAccount: 'exodus_0',
  address: '0x1111111111111111111111111111111111111111',
})
// force tick the ethereum monitor, or wait a while
await exodus.txLogMonitors.update({ assetName: 'ethereum', refresh: true })
// check your balance
selectors.balances
  .createTotal({ assetName: 'ethereum', walletAccount: 'exodus_0' })(store.getState())
  .toString()

API Side

See using the sdk for more details on how features plug into the SDK. Note that the balances feature currently doesn't provide a top level API and is meant to be used purely through selectors.

If you're building a feature that requires balances, add a dependency on the balancesAtom as below. See also the available balance fields.

const myModuleDefinition = {
  id: 'myModule',
  type: 'module',
  factory: ({ balancesAtom }) => {
    const doSomethingSpecial = async () => {
      // {
      //   [walletAccount]: {
      //     [assetName]: {
      //       // e.g. 'total', 'spendable', 'unconfirmedSent', 'unconfirmedReceived'
      //       [balanceField]: NumberUnit, // see @exodus/currency
      //     }
      //   }
      // }
      const { balances } = await balancesAtom.get()
      // ...
    }

    return {
      doSomethingSpecial,
    }
  },
  dependencies: ['balancesAtom'],
}

UI Side

See using the sdk for more details on basic UI-side setup.

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

const MyComponent = () => {
  const bitcoinBalance = useSelector(
    selectors.balances.createSpendable({
      assetName: 'bitcoin',
      walletAccount: 'exodus_0',
    })
  ) // returns a NumberUnit
}

Contributing

WARNING: no asset specifics!

Do NOT introduce any asset specifics like if (assetName === 'dogicorn') balance = balance.mul(2). All asset-specifics belong in asset.api.getBalances or other APIs inside the asset libraries.

FAQs

Package last updated on 22 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc