@exodus/models

中文文档
13.3.3发布于 2026/10/23MITTypeScriptES Module近 30 天下载 10万

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

原始使用文档
文档目录16 节
  1. Installation/Usage
  2. Shared Interfaces
  3. AccountState
  4. Address
  5. AddressSet
  6. FiatOrder
  7. FiatOrderSet
  8. Order
  9. OrderSet
  10. PersonalNote
  11. PersonalNoteSet
  12. Tx
  13. TxSet
  14. UtxoCollection
  15. WalletAccount
  16. WalletAccountSet

@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

pnpm 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
investments instanceof WalletAccount // 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 .[Symbol.hasInstance](obj) which returns true if obj is an instance of the model. This makes instanceof check return true even if the instance is of a model from a different version of the @exodus/models package.

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.

版本与发布记录

@exodus/models 共发布 170 个版本,首次发布于 2018/10/26;过去 12 个月发布了 19 个版本。

版本发布日期距今
13.3.3latest2026/10/2321 天前
13.3.22026/09/171 个月前
13.3.12026/06/045 个月前
13.3.02026/05/285 个月前
13.2.52026/05/195 个月前
13.2.42026/05/185 个月前

关于 @exodus/models 的常见问题

@exodus/models 是什么?

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

如何安装 @exodus/models?

在项目目录运行 npm install @exodus/models,或使用 pnpm add / yarn add / bun add。

@exodus/models 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@exodus/models 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/models 可以商用吗?

@exodus/models 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/models 的下载量有多少?

根据 npm 官方下载统计,@exodus/models 在 2026/10/14 – 2026/11/12 这 30 天内被下载 100,451 次,日均约 3,348 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exodus/models 还在维护吗?

最新版本 13.3.3 发布于 2026/10/23(21 天前);至今共发布 170 个版本,其中过去 12 个月发布了 19 个;首次发布于 2018/10/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。