@talismn/balances 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,111 +6,34 @@
6
6
  [![npm-version](https://img.shields.io/npm/v/@talismn/balances?style=flat-square)](https://www.npmjs.com/package/@talismn/balances)
7
7
  [![npm-downloads](https://img.shields.io/npm/dw/@talismn/balances?style=flat-square)](https://www.npmjs.com/package/@talismn/balances)
8
8
 
9
- **@talismn/balances** is the core of a set of packages used to subscribe to on-chain account token balances.
9
+ **@talismn/balances** fetches and subscribes to on-chain account token balances for Polkadot SDK, Ethereum (EVM) and Solana networks.
10
10
 
11
- A quick rundown on each package is given below.
11
+ It includes:
12
12
 
13
- ### This (the core) package:
13
+ - `BalancesProvider`: the API that wallets and dapps use to fetch and subscribe to balances (`getBalances$`)
14
+ - `Balances` and `Balance`: classes that aggregate balances and expose `total`, `free`, `locked`, `reserved` and fiat values
15
+ - The balance modules, one per token type, which all implement `IBalanceModule`
14
16
 
15
- **@talismn/balances** (this package) includes:
17
+ Networks and tokens come from `@talismn/chaindata-provider`. RPC connections come from `@talismn/chain-connectors`.
16
18
 
17
- - An API which wallets / dapps can use to access balances
18
- - An interface for balance modules to implement
19
- - A shared database (powered by dexie) for balance modules to store balances in
20
- - Helpers (utility functions) for balance modules to use
21
- - Provides a plugin architecture, which is used by the balance module packages to specify their balance types
19
+ ### Balance modules
22
20
 
23
- ### The balance modules:
21
+ Each module is a folder in `src/modules/`:
24
22
 
25
- **@talismn/balances-default-modules**
23
+ | Module | Tokens |
24
+ | --- | --- |
25
+ | `substrate-native` | Native tokens of Polkadot SDK chains, including locks, reserves and staking |
26
+ | `substrate-assets` | `assets` pallet tokens |
27
+ | `substrate-foreignassets` | `foreignAssets` pallet tokens |
28
+ | `substrate-tokens` | ORML `tokens` pallet tokens |
29
+ | `substrate-hydration` | Hydration multi-currency tokens (`CurrenciesApi` runtime API) |
30
+ | `substrate-psp22` | PSP22 (ink! contract) tokens |
31
+ | `substrate-dtao` | Bittensor subnet (dTAO) alpha stake |
32
+ | `evm-native` | Native tokens of EVM networks |
33
+ | `evm-erc20` | ERC20 tokens |
34
+ | `evm-uniswapv2` | Uniswap V2 LP tokens |
35
+ | `sol-native` | SOL |
36
+ | `sol-spl` | SPL tokens |
37
+ | `sol-token2022` | Token-2022 tokens |
26
38
 
27
- - Collates the default balance modules (which can be found below) into a single package
28
-
29
- **@talismn/substrate-native**
30
-
31
- - A balance module for substrate native tokens
32
- - Subscribes to the `system.account` state query balance for each token
33
- - Also subscribes to the crowdloans pallet balances
34
- - Also subscribes to the nompools pallet balances
35
-
36
- **@talismn/substrate-orml**
37
-
38
- - A proof-of-concept balance module for ORML token pallet tokens
39
- - Attempts to auto-detect tokens
40
- - **You should use @talismn/substrate-tokens instead**
41
-
42
- **@talismn/substrate-tokens**
43
-
44
- - A balance module for substrate ORML token pallet tokens
45
- - Supports any token which can be queried via the `tokens.accounts` state query
46
- - Requires configuration for each token (no auto-detection)
47
- - We recommend that you use this module for ORML tokens
48
-
49
- **@talismn/substrate-assets**
50
-
51
- - A balance module for substrate assets pallet tokens
52
- - Supports any token which can be queried via the `assets.account` state query
53
- - Requires configuration for each token (no auto-detection)
54
-
55
- **@talismn/substrate-equilibrium**
56
-
57
- - A balance module for substrate eqBalances pallet tokens
58
- - Used by [Equilibrium](https://equilibrium.io/) and [Genshiro](https://genshiro.io/)
59
- - Supports auto-detection
60
-
61
- **@talismn/evm-native**
62
-
63
- - A balance module for evm native tokens
64
-
65
- **@talismn/evm-erc20**
66
-
67
- - A balance module for evm erc20 tokens
68
-
69
- ### The chain connectors:
70
-
71
- **@talismn/chain-connector**
72
-
73
- - A package which manages the open RPC connections to substrate chains
74
- - Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPCs to use
75
- - Ensures that connections are only opened to the chains which are in use by the wallet/dapp
76
- - Ensures that only one connection is open per chain
77
- - Handles exponential backoff in the case of network failures
78
- - Provides an interface which can be shared between a serviceworker and frontend, which enables the two to share the pool of open connections
79
- - Provides an interface which mimics a polkadot-js `WsProvider`, which can be plugged into polkadot-js to make it use the shared pool of open connections
80
-
81
- **@talismn/chain-connector-evm**
82
-
83
- - A package which manages the connections to evm chains
84
- - Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPC to use
85
-
86
- ### The chaindata provider:
87
-
88
- **@talismn/chaindata-provider**
89
-
90
- - A database (powered by dexie) to store chains, evm chains and tokens in
91
- - An interface to interact with the database
92
- - Syncs with the list in the [chaindata repository](https://github.com/talismansociety/chaindata) via graphql
93
- - Supports custom (end-user-defined) chains and rpc overrides
94
- - Provides a plugin architecture, which is used by the balance module packages to specify their token types
95
-
96
- ### The remaining packages:
97
-
98
- **@talismn/connection-meta**
99
-
100
- - Contains a small db which is used to optimise network performance in the wallet.
101
- - Two metrics are kept:
102
- - chainPriorityRpc (the last known well-behaved RPC for a chain)
103
- - chainBackoffInterval (the amount of time the wallet should wait before attempting to connect to a unreachable chain again)
104
-
105
- **@talismn/mutate-metadata**
106
-
107
- - A package which can splice a chain's metadata into smaller pieces
108
- - Enables us to make state queries across many chains at once without using all of the browser's memory
109
-
110
- **@talismn/token-rates**
111
-
112
- - Fetches and stores coingecko rates for each token in the @talismn/chaindata-provider database
113
-
114
- **@talismn/util**
115
-
116
- - Utility functions shared by the other packages, as well as the wallet and the portal
39
+ See `BalancesModules.md` for what a module must do.