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/models

v12.3.0

Published

Containers for common business objects in the wild world of Exodus wallets

Downloads

21,364

Readme

@exodus/models

Containers for common business objects in the wild world of Exodus wallets. These typically provide basic functions like immutability (mutator methods return new instances), validation, serialization, and comparison.

Containers for collections typically have convenience methods for accessing elements by some semantic parameters, and merging with other collections. These tend to be specific to the collected business object.

Installation/Usage

yarn add @exodus/models

This library exports each model as a named export. Usage example:

import { WalletAccount } from '@exodus/models'

const investments = new WalletAccount({
  source: WalletAccount.EXODUS_SRC,
  index: 0,
  label: 'Not investment advice',
})

const updatedInvestments = investments.update({ label: 'Still not investment advice' })
investments.equals(updatedInvestments) // false
WalletAccount.isInstance(investments) // true

investments.toJSON() // serialize for storage
WalletAccount.fromJSON(investments.toJSON()) // deserialize from storage

const safeInvestments = new WalletAccount({
  id: '1234', // comes from device
  source: WalletAccount.TREZOR_SRC,
  index: 0,
  label: 'Really not investment advice',
})

Collection usage example:

const myPortfolios = new WalletAccountSet({ [investments]: investments })
const myUpdatedPortfolios = myPortfolios.update({ [safeInvestments]: safeInvestments })
myUpdatedPortfolios.toJSON() // serialize for storage

See more examples in model-specific tests.

Shared Interfaces

All models have a static method .isInstance(obj) which returns true if obj is an instance of the model. This check returns true even if the instance is of a model from a different version of the @exodus/models package, and should be preferred to the instanceof operator.

AccountState

Container for an asset's blockchain state, like balance, token balances, utxos, etc. This is a base class from which all asset-specific account state classes extend. It cannot be initialized directly.

Address

Container for a blockchain address string and associated metadata, such as the KeyIdentifier for that address.

AddressSet

Collection of Addresses.

FiatOrder

Container for data relating to a fiat <-> crypto purchase or sale.

FiatOrderSet

Collection of FiatOrders.

Order

Container for data relating to the exchange of one crypto asset for another.

OrderSet

Collection of Orders.

PersonalNote

Container for a user's personal note for a transaction, e.g. "pizza"

PersonalNoteSet

A collection of PersonalNotes.

Tx

Container for data relating to a blockchain transaction, such as the transaction id, amount, confirmations, source address(es), destination address(es), and others.

TxSet

Collection of Txs. It cannot be constructed directly, so either start with TxSet.EMPTY or use the static method TxSet.fromArray(). Note: txSet.equals(otherSet) only compares transaction ids; use txSet.deepEquals(otherSet) for full transaction comparison.

UtxoCollection

Collection of UTXOs. There is no corresponding UTXO model. Use utxoCollection.select(amount, feeEstimator) to select utxos for a given amount you want to send.

WalletAccount

Container for a bip44 account index and user-specific portfolio metadata. Slightly counterintuitively, if you're looking at the bip44 path, in Exodus wallets each portfolio corresponds to a basket of assets, i.e. both of the following paths will correspond to a single portfolio`

  • m/44'/0'/7'/0/0: first bitcoin address of portfolio 7
  • m/44'/60'/7'/0/0: first ethereum address of portfolio 7

WalletAccountSet

Collection of WalletAccounts.