edge-core-js 0.19.18 → 0.19.21

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.
@@ -1,76 +0,0 @@
1
- //
2
-
3
- import { buildReducer, memoizeReducer } from 'redux-keto'
4
-
5
-
6
- import { compare } from '../../util/compare.js'
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
- export const tokenReducer
24
-
25
-
26
-
27
- = buildReducer({
28
- allTokens: memoizeReducer(
29
- (next) => next.self.builtinTokens,
30
- (next) => next.self.customTokens,
31
- (builtinTokens, customTokens) => ({
32
- ...customTokens,
33
- ...builtinTokens
34
- })
35
- ),
36
-
37
- builtinTokens(state = {}, action, next) {
38
- switch (action.type) {
39
- case 'ACCOUNT_BUILTIN_TOKENS_LOADED': {
40
- const { pluginId, tokens } = action.payload
41
- if (pluginId !== next.id) return state
42
- return tokens
43
- }
44
- }
45
- return state
46
- },
47
-
48
- customTokens(state = {}, action, next) {
49
- switch (action.type) {
50
- case 'ACCOUNT_CUSTOM_TOKENS_LOADED': {
51
- const { customTokens } = action.payload
52
- return customTokens[next.id]
53
- }
54
- case 'ACCOUNT_CUSTOM_TOKEN_ADDED': {
55
- const { pluginId, tokenId, token } = action.payload
56
- if (pluginId !== next.id) return state
57
-
58
- // Has anything changed?
59
- if (compare(state[tokenId], token)) return state
60
-
61
- return { ...state, [tokenId]: token }
62
- }
63
- case 'ACCOUNT_CUSTOM_TOKEN_REMOVED': {
64
- const { pluginId, tokenId } = action.payload
65
- if (pluginId !== next.id) return state
66
-
67
- // Has anything changed?
68
- if (state[tokenId] == null) return state
69
-
70
- const { [tokenId]: unused, ...newList } = state
71
- return newList
72
- }
73
- }
74
- return state
75
- }
76
- })