@unisat/wallet-state 1.0.1 → 1.0.4
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/lib/index.d.mts +946 -0
- package/lib/index.d.ts +946 -0
- package/lib/index.js +2407 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +2273 -0
- package/lib/index.mjs.map +1 -0
- package/lib/types/index.d.mts +30 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/index.js +42 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/index.mjs +36 -0
- package/lib/types/index.mjs.map +1 -0
- package/package.json +17 -10
- package/src/hooks/global.ts +2 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/ui.ts +8 -2
- package/src/index.ts +4 -1
- package/src/reducers/global.ts +1 -2
- package/src/reducers/index.ts +7 -0
- package/src/reducers/ui.ts +7 -31
- package/src/types/index.ts +3 -0
- package/src/types/ui.ts +30 -0
package/src/hooks/ui.ts
CHANGED
|
@@ -5,12 +5,13 @@ import { Inscription } from '@unisat/wallet-shared'
|
|
|
5
5
|
import { getAddressType } from '../utils/bitcoin-utils'
|
|
6
6
|
import { AddressType } from '@unisat/wallet-types'
|
|
7
7
|
|
|
8
|
-
import { AppState } from '..'
|
|
8
|
+
import { AppState, AssetTabKey } from '..'
|
|
9
9
|
import { useCurrentAccount, useCurrentAddress } from '../hooks/accounts'
|
|
10
10
|
import { useAppDispatch, useAppSelector } from '../hooks/base'
|
|
11
11
|
import { useChainType, useNetworkType } from '../hooks/settings'
|
|
12
|
-
import {
|
|
12
|
+
import { uiActions } from '../reducers/ui'
|
|
13
13
|
import { TypeChain } from '@unisat/wallet-shared'
|
|
14
|
+
import { useLocation } from 'react-router-dom'
|
|
14
15
|
export function useUIState(): AppState['ui'] {
|
|
15
16
|
return useAppSelector(state => state.ui)
|
|
16
17
|
}
|
|
@@ -133,3 +134,8 @@ export const useUtxoTools = (chain: TypeChain) => {
|
|
|
133
134
|
openUtxoTools,
|
|
134
135
|
}
|
|
135
136
|
}
|
|
137
|
+
|
|
138
|
+
export function useLocationState<T>() {
|
|
139
|
+
const { state } = useLocation()
|
|
140
|
+
return state as T
|
|
141
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { load, save } from 'redux-localstorage-simple'
|
|
2
2
|
|
|
3
3
|
import { configureStore } from '@reduxjs/toolkit'
|
|
4
|
-
import { setupListeners } from '@reduxjs/toolkit/query/react'
|
|
4
|
+
import { setupListeners } from '@reduxjs/toolkit/dist/query/react/index.js'
|
|
5
5
|
|
|
6
6
|
import accounts from './reducers/accounts'
|
|
7
7
|
import discovery from './reducers/discovery'
|
|
@@ -24,6 +24,7 @@ const store = configureStore({
|
|
|
24
24
|
discovery,
|
|
25
25
|
},
|
|
26
26
|
middleware: getDefaultMiddleware =>
|
|
27
|
+
// @ts-ignore
|
|
27
28
|
getDefaultMiddleware({ thunk: true }).concat(save({ states: PERSISTED_KEYS, debounce: 1000 })),
|
|
28
29
|
preloadedState: load({ states: PERSISTED_KEYS, disableWarnings: true }),
|
|
29
30
|
})
|
|
@@ -40,3 +41,5 @@ export type AppDispatch = typeof store.dispatch
|
|
|
40
41
|
export * from './context'
|
|
41
42
|
export * from './hooks'
|
|
42
43
|
export * from './updater'
|
|
44
|
+
export * from './reducers'
|
|
45
|
+
export * from './types'
|
package/src/reducers/global.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createSlice, PayloadAction, Slice, SliceCaseReducers } from '@reduxjs/toolkit'
|
|
2
2
|
|
|
3
3
|
import { updateVersion } from '../actions/global'
|
|
4
|
-
|
|
5
|
-
export type TabOption = 'home' | 'discover' | 'settings'
|
|
4
|
+
import { TabOption } from '../types'
|
|
6
5
|
|
|
7
6
|
export interface GlobalState {
|
|
8
7
|
tab: TabOption
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { accountActions } from './accounts'
|
|
2
|
+
export { discoveryActions } from './discovery'
|
|
3
|
+
export { globalActions } from './global'
|
|
4
|
+
export { keyringsActions } from './keyrings'
|
|
5
|
+
export { settingsActions } from './settings'
|
|
6
|
+
export { transactionsActions } from './transactions'
|
|
7
|
+
export { uiActions } from './ui'
|
package/src/reducers/ui.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { Inscription } from '@unisat/wallet-shared'
|
|
|
2
2
|
import { createSlice, Slice } from '@reduxjs/toolkit'
|
|
3
3
|
|
|
4
4
|
import { updateVersion } from '../actions/global'
|
|
5
|
+
import {
|
|
6
|
+
AlkanesAssetTabKey,
|
|
7
|
+
AssetTabKey,
|
|
8
|
+
CATAssetTabKey,
|
|
9
|
+
NavigationSource,
|
|
10
|
+
OrdinalsAssetTabKey,
|
|
11
|
+
} from '../types'
|
|
5
12
|
|
|
6
13
|
export interface UIState {
|
|
7
14
|
assetTabKey: AssetTabKey
|
|
@@ -26,37 +33,6 @@ export interface UIState {
|
|
|
26
33
|
isBalanceHidden: boolean
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
export enum AssetTabKey {
|
|
30
|
-
ORDINALS = 0,
|
|
31
|
-
ATOMICALS = 1, // IGNORED
|
|
32
|
-
RUNES = 2,
|
|
33
|
-
CAT = 3,
|
|
34
|
-
ALKANES = 4,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export enum OrdinalsAssetTabKey {
|
|
38
|
-
ALL = 0,
|
|
39
|
-
BRC20 = 1,
|
|
40
|
-
BRC20_6BYTE = 2,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export enum CATAssetTabKey {
|
|
44
|
-
CAT20,
|
|
45
|
-
CAT721,
|
|
46
|
-
CAT20_V2,
|
|
47
|
-
CAT721_V2,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export enum AlkanesAssetTabKey {
|
|
51
|
-
TOKEN,
|
|
52
|
-
COLLECTION,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export enum NavigationSource {
|
|
56
|
-
BACK,
|
|
57
|
-
NORMAL,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
36
|
export const initialState: UIState = {
|
|
61
37
|
assetTabKey: AssetTabKey.ORDINALS,
|
|
62
38
|
ordinalsAssetTabKey: OrdinalsAssetTabKey.ALL,
|
package/src/types/ui.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export enum AssetTabKey {
|
|
2
|
+
ORDINALS = 0,
|
|
3
|
+
ATOMICALS = 1, // IGNORED
|
|
4
|
+
RUNES = 2,
|
|
5
|
+
CAT = 3,
|
|
6
|
+
ALKANES = 4,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum OrdinalsAssetTabKey {
|
|
10
|
+
ALL = 0,
|
|
11
|
+
BRC20 = 1,
|
|
12
|
+
BRC20_6BYTE = 2,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum CATAssetTabKey {
|
|
16
|
+
CAT20,
|
|
17
|
+
CAT721,
|
|
18
|
+
CAT20_V2,
|
|
19
|
+
CAT721_V2,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum AlkanesAssetTabKey {
|
|
23
|
+
TOKEN,
|
|
24
|
+
COLLECTION,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum NavigationSource {
|
|
28
|
+
BACK,
|
|
29
|
+
NORMAL,
|
|
30
|
+
}
|