@exodus/activity-txs
v4.4.2
Published
The activity-txs feature
Downloads
11,414
Readme
@exodus/activity-txs
This feature generates user-friendly activity from transactions, orders, fiat orders, NFTs, and connections by grouping, batching, and formatting them.
How it works
Each asset’s activity consists of a set of transactions transformed using asset.api.getActivityTxs
, which returns an array of Tx models: [Tx, Tx, Tx]
.
Most assets don't have this API and simply return the original transactions.
For example, Bitcoin batched transactions are combined into a single activity item. Instead of multiple transactions (Txs), you get a single transaction with a summarized coinAmount
.
This feature introduces atoms with activity items generated from txLog
and accountState
. It provides an efficient way to store these items by wallet accounts and update this extensive object while avoiding unnecessary re-computations.
Additionally, it offers extra Redux selectors to retrieve activity, limited by size or batched activity items. These selectors format activity depending on its type: NFTs (if the nfts
module is integrated), fiat orders (if the fiat module is integrated), and swap orders (if the orders feature is integrated).
Usage
This feature is designed to be used together with @exodus/headless
. See Using the SDK for more details.
API Side
The feature doesn't have a public API. Data is transformed automatically, stored in activityTxsAtom
, and emitted to be stored in the Redux state.
Play with it
Open the playground at https://exodus-hydra.pages.dev/features/activity-txs
Run the following command in the Dev Tools Console to see activity for Bitcoin:
selectors.activityTxs.createFullActivity({ nftsNetworkNameToAssetName: { fantom: 'fantommainnet' }, })({ assetName: 'bitcoin', walletAccount: 'exodus_0' })(store.getState())
run the following command in the Dev Tools Console to see activity for Bitcoin and Ethereum together:
selectors.activityTxs.createMultiActivity({
createAssetSourceActivitySelector: selectors.activityTxs.createFullActivity({
nftsNetworkNameToAssetName: { fantom: 'fantommainnet' },
}),
})({ assetNames: ['bitcoin', 'ethereum'], walletAccounts: ['exodus_0', 'exodus_1'] })(
store.getState()
)
- Try out some other selectors from
selectors.activityTxs
. See example usage in tests.
UI Side
See using the sdk for more details on basic UI-side setup.
import selectors from '~/ui/flux/selectors'
const fullAssetSourceActivitySelector = selectors.activityTxs.createFullActivity({
nftsNetworkNameToAssetName: { fantom: 'fantommainnet' },
})
const MyComponent = () => {
const bitcoinActivity = useSelector(
fullAssetSourceActivitySelector({ assetName: 'bitcoin', walletAccount: 'exodus_0' })
)
return bitcoinActivity.map((activityItem) => (
<Text>
{activityItem.assetName} : {activityItem.displayAmount}
</Text>
))
}