@talismn/balances 0.0.0-pr940-20230720110648 → 0.0.0-pr940-20230814011322

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/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # @talismn/balances
2
2
 
3
- ## 0.0.0-pr940-20230720110648
3
+ ## 0.0.0-pr940-20230814011322
4
+
5
+ ### Patch Changes
6
+
7
+ - d2ccdafb: fix: balance subscriptions never update registry cache with new metadata
8
+ - a916db00: docs: added @talismn/balances readme
9
+ - Updated dependencies [4cace80d]
10
+ - @talismn/chaindata-provider@0.0.0-pr940-20230814011322
11
+ - @talismn/chain-connector@0.0.0-pr940-20230814011322
12
+ - @talismn/chain-connector-evm@0.0.0-pr940-20230814011322
13
+ - @talismn/token-rates@0.0.0-pr940-20230814011322
14
+
15
+ ## 0.6.0
4
16
 
5
17
  ### Minor Changes
6
18
 
@@ -13,11 +25,11 @@
13
25
  - Updated dependencies [3c1a8b10]
14
26
  - Updated dependencies [b920ab98]
15
27
  - Updated dependencies [7573864f]
16
- - @talismn/util@0.0.0-pr940-20230720110648
17
- - @talismn/chaindata-provider@0.0.0-pr940-20230720110648
18
- - @talismn/token-rates@0.0.0-pr940-20230720110648
19
- - @talismn/chain-connector-evm@0.0.0-pr940-20230720110648
20
- - @talismn/chain-connector@0.0.0-pr940-20230720110648
28
+ - @talismn/util@0.2.0
29
+ - @talismn/chaindata-provider@0.7.0
30
+ - @talismn/token-rates@0.2.0
31
+ - @talismn/chain-connector-evm@0.7.0
32
+ - @talismn/chain-connector@0.7.0
21
33
 
22
34
  ## 0.5.0
23
35
 
package/README.md CHANGED
@@ -1 +1,127 @@
1
1
  # @talismn/balances
2
+
3
+ <img src="talisman.svg" alt="Talisman" width="15%" align="right" />
4
+
5
+ [![license](https://img.shields.io/github/license/talismansociety/talisman?style=flat-square)](https://github.com/TalismanSociety/talisman/blob/dev/LICENSE)
6
+ [![npm-version](https://img.shields.io/npm/v/@talismn/balances?style=flat-square)](https://www.npmjs.com/package/@talismn/balances)
7
+ [![npm-downloads](https://img.shields.io/npm/dw/@talismn/balances?style=flat-square)](https://www.npmjs.com/package/@talismn/balances)
8
+ [![discord-link](https://img.shields.io/discord/858891448271634473?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/talisman)
9
+
10
+ **@talismn/balances** is the core of a set of packages used to subscribe to on-chain account token balances.
11
+
12
+ A quick rundown on each package is given below.
13
+
14
+ ### This (the core) package:
15
+
16
+ **@talismn/balances** (this package) includes:
17
+
18
+ - An API which wallets / dapps can use to access balances
19
+ - An interface for balance modules to implement
20
+ - A shared database (powered by dexie) for balance modules to store balances in
21
+ - Helpers (utility functions) for balance modules to use
22
+ - Provides a plugin architecture, which is used by the balance module packages to specify their balance types
23
+
24
+ ### The react API for wallets & dapps:
25
+
26
+ **@talismn/balances-react** includes:
27
+
28
+ - React hooks for subscribing to on-chain account token balances
29
+ - (soon™): recoil atoms for on-chain account token balances
30
+
31
+ ### The balance modules:
32
+
33
+ **@talismn/balances-default-modules**
34
+
35
+ - Collates the default balance modules (which can be found below) into a single package
36
+
37
+ **@talismn/substrate-native**
38
+
39
+ - A balance module for substrate native tokens
40
+ - Subscribes to the `system.account` state query balance for each token
41
+ - Also subscribes to the crowdloans pallet balances
42
+ - Also subscribes to the nompools pallet balances
43
+
44
+ **@talismn/substrate-orml**
45
+
46
+ - A proof-of-concept balance module for ORML token pallet tokens
47
+ - Attempts to auto-detect tokens
48
+ - **You should use @talismn/substrate-tokens instead**
49
+
50
+ **@talismn/substrate-tokens**
51
+
52
+ - A balance module for substrate ORML token pallet tokens
53
+ - Supports any token which can be queried via the `tokens.accounts` state query
54
+ - Requires configuration for each token (no auto-detection)
55
+ - We recommend that you use this module for ORML tokens
56
+
57
+ **@talismn/substrate-assets**
58
+
59
+ - A balance module for substrate assets pallet tokens
60
+ - Supports any token which can be queried via the `assets.account` state query
61
+ - Requires configuration for each token (no auto-detection)
62
+
63
+ **@talismn/substrate-equilibrium**
64
+
65
+ - A balance module for substrate eqBalances pallet tokens
66
+ - Used by [Equilibrium](https://equilibrium.io/) and [Genshiro](https://genshiro.io/)
67
+ - Supports auto-detection
68
+
69
+ **@talismn/evm-native**
70
+
71
+ - A balance module for evm native tokens
72
+
73
+ **@talismn/evm-erc20**
74
+
75
+ - A balance module for evm erc20 tokens
76
+
77
+ ### The chain connectors:
78
+
79
+ **@talismn/chain-connector**
80
+
81
+ - A package which manages the open RPC connections to substrate chains
82
+ - Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPCs to use
83
+ - Ensures that connections are only opened to the chains which are in use by the wallet/dapp
84
+ - Ensures that only one connection is open per chain
85
+ - Handles exponential backoff in the case of network failures
86
+ - Provides an interface which can be shared between a serviceworker and frontend, which enables the two to share the pool of open connections
87
+ - 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
88
+
89
+ **@talismn/chain-connector-evm**
90
+
91
+ - A package which manages the connections to evm chains
92
+ - Allows developers to say "Send this query to the chain with this id", without them needing to specify which RPC to use
93
+
94
+ ### The chaindata provider:
95
+
96
+ Currently split into two packages because we initially intended to write several implementations of the chaindata interface.
97
+ Will be merged into one package soon™.
98
+
99
+ **@talismn/chaindata-provider** and **@talismn/chaindata-provider-extension**
100
+
101
+ - A database (powered by dexie) to store chains, evm chains and tokens in
102
+ - An interface to interact with the database
103
+ - Syncs with the list in the [chaindata repository](https://github.com/talismansociety/chaindata) via graphql
104
+ - Supports custom (end-user-defined) chains and rpc overrides
105
+ - Provides a plugin architecture, which is used by the balance module packages to specify their token types
106
+
107
+ ### The remaining packages:
108
+
109
+ **@talismn/connection-meta**
110
+
111
+ - Contains a small db which is used to optimise network performance in the wallet.
112
+ - Two metrics are kept:
113
+ - chainPriorityRpc (the last known well-behaved RPC for a chain)
114
+ - chainBackoffInterval (the amount of time the wallet should wait before attempting to connect to a unreachable chain again)
115
+
116
+ **@talismn/mutate-metadata**
117
+
118
+ - A package which can splice a chain's metadata into smaller pieces
119
+ - Enables us to make state queries across many chains at once without using all of the browser's memory
120
+
121
+ **@talismn/token-rates**
122
+
123
+ - Fetches and stores coingecko rates for each token in the @talismn/chaindata-provider database
124
+
125
+ **@talismn/util**
126
+
127
+ - Utility functions shared by the other packages, as well as the wallet and the portal
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr940-20230720110648",
72
+ version: "0.0.0-pr940-20230814011322",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "GPL-3.0-or-later",
@@ -150,9 +150,8 @@ async function balances(balanceModule, addressesByToken, callback) {
150
150
  const createTypeRegistryCache = () => {
151
151
  const typeRegistryCache = new Map();
152
152
  const getOrCreateTypeRegistry = (chainId, metadataRpc) => {
153
- // TODO: Delete cache when metadataRpc is different from last time
154
153
  const cached = typeRegistryCache.get(chainId);
155
- if (cached) return cached;
154
+ if (cached && cached.metadataRpc === metadataRpc) return cached.typeRegistry;
156
155
  const typeRegistry = new types.TypeRegistry();
157
156
  if (typeof metadataRpc === "string") {
158
157
  try {
@@ -164,7 +163,10 @@ const createTypeRegistryCache = () => {
164
163
  }), cause);
165
164
  }
166
165
  }
167
- typeRegistryCache.set(chainId, typeRegistry);
166
+ typeRegistryCache.set(chainId, {
167
+ metadataRpc,
168
+ typeRegistry
169
+ });
168
170
  return typeRegistry;
169
171
  };
170
172
  return {
@@ -69,7 +69,7 @@ const db = new TalismanBalancesDatabase();
69
69
 
70
70
  var packageJson = {
71
71
  name: "@talismn/balances",
72
- version: "0.0.0-pr940-20230720110648",
72
+ version: "0.0.0-pr940-20230814011322",
73
73
  author: "Talisman",
74
74
  homepage: "https://talisman.xyz",
75
75
  license: "GPL-3.0-or-later",
@@ -150,9 +150,8 @@ async function balances(balanceModule, addressesByToken, callback) {
150
150
  const createTypeRegistryCache = () => {
151
151
  const typeRegistryCache = new Map();
152
152
  const getOrCreateTypeRegistry = (chainId, metadataRpc) => {
153
- // TODO: Delete cache when metadataRpc is different from last time
154
153
  const cached = typeRegistryCache.get(chainId);
155
- if (cached) return cached;
154
+ if (cached && cached.metadataRpc === metadataRpc) return cached.typeRegistry;
156
155
  const typeRegistry = new types.TypeRegistry();
157
156
  if (typeof metadataRpc === "string") {
158
157
  try {
@@ -164,7 +163,10 @@ const createTypeRegistryCache = () => {
164
163
  }), cause);
165
164
  }
166
165
  }
167
- typeRegistryCache.set(chainId, typeRegistry);
166
+ typeRegistryCache.set(chainId, {
167
+ metadataRpc,
168
+ typeRegistry
169
+ });
168
170
  return typeRegistry;
169
171
  };
170
172
  return {
@@ -60,7 +60,7 @@ const db = new TalismanBalancesDatabase();
60
60
 
61
61
  var packageJson = {
62
62
  name: "@talismn/balances",
63
- version: "0.0.0-pr940-20230720110648",
63
+ version: "0.0.0-pr940-20230814011322",
64
64
  author: "Talisman",
65
65
  homepage: "https://talisman.xyz",
66
66
  license: "GPL-3.0-or-later",
@@ -141,9 +141,8 @@ async function balances(balanceModule, addressesByToken, callback) {
141
141
  const createTypeRegistryCache = () => {
142
142
  const typeRegistryCache = new Map();
143
143
  const getOrCreateTypeRegistry = (chainId, metadataRpc) => {
144
- // TODO: Delete cache when metadataRpc is different from last time
145
144
  const cached = typeRegistryCache.get(chainId);
146
- if (cached) return cached;
145
+ if (cached && cached.metadataRpc === metadataRpc) return cached.typeRegistry;
147
146
  const typeRegistry = new TypeRegistry();
148
147
  if (typeof metadataRpc === "string") {
149
148
  try {
@@ -155,7 +154,10 @@ const createTypeRegistryCache = () => {
155
154
  }), cause);
156
155
  }
157
156
  }
158
- typeRegistryCache.set(chainId, typeRegistry);
157
+ typeRegistryCache.set(chainId, {
158
+ metadataRpc,
159
+ typeRegistry
160
+ });
159
161
  return typeRegistry;
160
162
  };
161
163
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/balances",
3
- "version": "0.0.0-pr940-20230720110648",
3
+ "version": "0.0.0-pr940-20230814011322",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -27,11 +27,11 @@
27
27
  "clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
28
28
  },
29
29
  "dependencies": {
30
- "@talismn/chain-connector": "0.0.0-pr940-20230720110648",
31
- "@talismn/chain-connector-evm": "0.0.0-pr940-20230720110648",
32
- "@talismn/chaindata-provider": "0.0.0-pr940-20230720110648",
33
- "@talismn/token-rates": "0.0.0-pr940-20230720110648",
34
- "@talismn/util": "0.0.0-pr940-20230720110648",
30
+ "@talismn/chain-connector": "0.0.0-pr940-20230814011322",
31
+ "@talismn/chain-connector-evm": "0.0.0-pr940-20230814011322",
32
+ "@talismn/chaindata-provider": "0.0.0-pr940-20230814011322",
33
+ "@talismn/token-rates": "0.0.0-pr940-20230814011322",
34
+ "@talismn/util": "0.2.0",
35
35
  "anylogger": "^1.0.11",
36
36
  "dexie": "^3.2.4",
37
37
  "lodash": "4.17.21"