@exodus/models
TypeScript icon, indicating that this package has built-in type declarations

12.8.2 • Public • Published

@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.

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.

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

Collection of Addresses.

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

Collection of FiatOrders.

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

Collection of Orders.

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

A collection of PersonalNotes.

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

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.

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.

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

Collection of WalletAccounts.

Readme

Keywords

none

Package Sidebar

Install

npm i @exodus/models

Weekly Downloads

3,984

Version

12.8.2

License

MIT

Unpacked Size

195 kB

Total Files

58

Last publish

Collaborators

  • juraex
  • kevva
  • doguhan
  • ps.mcnally
  • janwe
  • yevhenii_molodyk
  • javiexodus
  • ismamz
  • exojo
  • feri42
  • jprichardson
  • farisissa
  • ryanzim
  • headfire
  • gutenye
  • mosesbot
  • roccomuso
  • dcastagnoli
  • sonaye
  • ves
  • tenaciousmv
  • asyakost
  • bulgakovk
  • chalker
  • andrejb
  • jaydp17
  • olistic
  • joepie91
  • merlz
  • vbonini
  • mol0d
  • devopsrobot
  • jenish-sojitra
  • markoexodus
  • nachoalvarez
  • giovannirco
  • filipexodus
  • cryptosgr
  • andrescarreon
  • diegomura
  • lanre-mark
  • sunilagrawal
  • guillecura
  • mariosvlad
  • federico-po
  • akinncar
  • fboucquez
  • lanahizzle
  • kwwood
  • umito
  • joshuabot
  • iaacek
  • meniem
  • skapala
  • awilson-rs
  • ggabarrin-rs
  • ralph.ba
  • danh.t.vo
  • voltagebots
  • ryansquared-npm
  • alexandrbbm
  • sergii_bo
  • florianmathieu
  • angelloz
  • exodus-justin.za
  • alex.alexandrius
  • rec
  • rg911
  • jamiemaw
  • james-gre
  • shehryar6
  • geoffreyrousset
  • clarkexo
  • tunguyennnnn
  • jschopen
  • cawfree
  • marcos.kichel
  • andrewtoth-exodus
  • cdotta-exodus
  • exorich
  • mmehta-10
  • kryptkeep
  • 633kh4ck
  • mbaraniak-exodus
  • jeehahn
  • hasakura
  • awesomeniko
  • davidexodus
  • r4vn
  • nantoaqui
  • exoleo
  • ale-exo
  • frankliexodus
  • bekatd
  • ronaldcrb
  • muratso
  • yalomist
  • joshua-rogers-exodus
  • jdmdreamer
  • vikas027
  • angel_exodus
  • sripwoud
  • casey-ch
OSZAR »