@unisat/wallet-state 1.0.5 → 1.2.0
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/LICENSE +0 -5
- package/lib/actions/global.d.ts +2 -0
- package/lib/actions/global.d.ts.map +1 -0
- package/lib/context/ApprovalContext.d.ts +9 -0
- package/lib/context/ApprovalContext.d.ts.map +1 -0
- package/lib/context/DeviceContext.d.ts +17 -0
- package/lib/context/DeviceContext.d.ts.map +1 -0
- package/lib/context/I18nContext.d.ts +13 -0
- package/lib/context/I18nContext.d.ts.map +1 -0
- package/lib/context/NavigationContext.d.ts +218 -0
- package/lib/context/NavigationContext.d.ts.map +1 -0
- package/lib/context/PriceContext.d.ts +13 -0
- package/lib/context/PriceContext.d.ts.map +1 -0
- package/lib/context/StorageContext.d.ts +60 -0
- package/lib/context/StorageContext.d.ts.map +1 -0
- package/lib/context/ToolsContext.d.ts +17 -0
- package/lib/context/ToolsContext.d.ts.map +1 -0
- package/lib/context/WalletContext.d.ts +493 -0
- package/lib/context/WalletContext.d.ts.map +1 -0
- package/lib/context/index.d.ts +9 -0
- package/lib/context/index.d.ts.map +1 -0
- package/lib/hooks/accounts.d.ts +34 -0
- package/lib/hooks/accounts.d.ts.map +1 -0
- package/lib/hooks/base.d.ts +14 -0
- package/lib/hooks/base.d.ts.map +1 -0
- package/lib/hooks/browser.d.ts +32 -0
- package/lib/hooks/browser.d.ts.map +1 -0
- package/lib/hooks/discovery.d.ts +17 -0
- package/lib/hooks/discovery.d.ts.map +1 -0
- package/lib/hooks/global.d.ts +43 -0
- package/lib/hooks/global.d.ts.map +1 -0
- package/lib/hooks/index.d.ts +10 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/keyrings.d.ts +5 -0
- package/lib/hooks/keyrings.d.ts.map +1 -0
- package/lib/hooks/settings.d.ts +43 -0
- package/lib/hooks/settings.d.ts.map +1 -0
- package/lib/hooks/transactions.d.ts +67 -0
- package/lib/hooks/transactions.d.ts.map +1 -0
- package/lib/hooks/ui.d.ts +112 -0
- package/lib/hooks/ui.d.ts.map +1 -0
- package/lib/index.d.mts +2072 -199
- package/lib/index.d.ts +31 -946
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7176 -582
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +6971 -525
- package/lib/index.mjs.map +1 -1
- package/lib/reducers/accounts.d.ts +49 -0
- package/lib/reducers/accounts.d.ts.map +1 -0
- package/lib/reducers/browser.d.ts +49 -0
- package/lib/reducers/browser.d.ts.map +1 -0
- package/lib/reducers/discovery.d.ts +22 -0
- package/lib/reducers/discovery.d.ts.map +1 -0
- package/lib/reducers/global.d.ts +35 -0
- package/lib/reducers/global.d.ts.map +1 -0
- package/lib/reducers/index.d.ts +9 -0
- package/lib/reducers/index.d.ts.map +1 -0
- package/lib/reducers/keyrings.d.ts +10 -0
- package/lib/reducers/keyrings.d.ts.map +1 -0
- package/lib/reducers/settings.d.ts +16 -0
- package/lib/reducers/settings.d.ts.map +1 -0
- package/lib/reducers/transactions.d.ts +61 -0
- package/lib/reducers/transactions.d.ts.map +1 -0
- package/lib/reducers/ui.d.ts +55 -0
- package/lib/reducers/ui.d.ts.map +1 -0
- package/lib/types/index.d.mts +7 -3
- package/lib/types/index.d.ts +3 -30
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +7 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +7 -2
- package/lib/types/index.mjs.map +1 -1
- package/lib/types/ui.d.ts +31 -0
- package/lib/types/ui.d.ts.map +1 -0
- package/lib/ui-hooks/index.d.ts +55 -0
- package/lib/ui-hooks/index.d.ts.map +1 -0
- package/lib/ui-hooks/useActionOverviewSectionLogic.d.ts +12 -0
- package/lib/ui-hooks/useActionOverviewSectionLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAddressTypeScreenLogic.d.ts +19 -0
- package/lib/ui-hooks/useAddressTypeScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesBalanceCardLogic.d.ts +19 -0
- package/lib/ui-hooks/useAlkanesBalanceCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesCollectionListLogic.d.ts +11 -0
- package/lib/ui-hooks/useAlkanesCollectionListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesListLogic.d.ts +14 -0
- package/lib/ui-hooks/useAlkanesListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesNFTListLogic.d.ts +11 -0
- package/lib/ui-hooks/useAlkanesNFTListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesNFTScreenLogic.d.ts +9 -0
- package/lib/ui-hooks/useAlkanesNFTScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAlkanesTokenScreenLogic.d.ts +22 -0
- package/lib/ui-hooks/useAlkanesTokenScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAmountInputLogic.d.ts +22 -0
- package/lib/ui-hooks/useAmountInputLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useAnnouncementCardLogic.d.ts +11 -0
- package/lib/ui-hooks/useAnnouncementCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20BalanceCardLogic.d.ts +26 -0
- package/lib/ui-hooks/useBRC20BalanceCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20InscribeTransferLogic.d.ts +103 -0
- package/lib/ui-hooks/useBRC20InscribeTransferLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20ListLogic.d.ts +14 -0
- package/lib/ui-hooks/useBRC20ListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20ProgListLogic.d.ts +14 -0
- package/lib/ui-hooks/useBRC20ProgListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20SendScreenLogic.d.ts +67 -0
- package/lib/ui-hooks/useBRC20SendScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20SingleStepScreenLogic.d.ts +36 -0
- package/lib/ui-hooks/useBRC20SingleStepScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBRC20TokenScreenLogic.d.ts +75 -0
- package/lib/ui-hooks/useBRC20TokenScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBalanceCardLogic.d.ts +26 -0
- package/lib/ui-hooks/useBalanceCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useBtcDisplayLogic.d.ts +5 -0
- package/lib/ui-hooks/useBtcDisplayLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCAT20BalanceCardLogic.d.ts +20 -0
- package/lib/ui-hooks/useCAT20BalanceCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCAT20ListLogic.d.ts +14 -0
- package/lib/ui-hooks/useCAT20ListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCAT20TokenScreenLogic.d.ts +19 -0
- package/lib/ui-hooks/useCAT20TokenScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCAT721ListLogic.d.ts +11 -0
- package/lib/ui-hooks/useCAT721ListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCAT721NFTScreenLogic.d.ts +9 -0
- package/lib/ui-hooks/useCAT721NFTScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCreatePasswordScreenLogic.d.ts +27 -0
- package/lib/ui-hooks/useCreatePasswordScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useCreateWalletLogicImportWordsStep.d.ts +78 -0
- package/lib/ui-hooks/useCreateWalletLogicImportWordsStep.d.ts.map +1 -0
- package/lib/ui-hooks/useEditAccountNameScreenLogic.d.ts +18 -0
- package/lib/ui-hooks/useEditAccountNameScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useEditContactScreenLogic.d.ts +24 -0
- package/lib/ui-hooks/useEditContactScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useEditWalletNameScreenLogic.d.ts +15 -0
- package/lib/ui-hooks/useEditWalletNameScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useExportMnemonicsScreenLogic.d.ts +18 -0
- package/lib/ui-hooks/useExportMnemonicsScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useExportPrivateKeyScreenLogic.d.ts +17 -0
- package/lib/ui-hooks/useExportPrivateKeyScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useFeeRateBarLogic.d.ts +34 -0
- package/lib/ui-hooks/useFeeRateBarLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useInfiniteList.d.ts +19 -0
- package/lib/ui-hooks/useInfiniteList.d.ts.map +1 -0
- package/lib/ui-hooks/useInscriptionListLogic.d.ts +11 -0
- package/lib/ui-hooks/useInscriptionListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useLockTimePageLogic.d.ts +11 -0
- package/lib/ui-hooks/useLockTimePageLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useNotificationsLogic.d.ts +14 -0
- package/lib/ui-hooks/useNotificationsLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useOrdinalsInscriptionScreenLogic.d.ts +27 -0
- package/lib/ui-hooks/useOrdinalsInscriptionScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useRunesBalanceCardLogic.d.ts +19 -0
- package/lib/ui-hooks/useRunesBalanceCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useRunesListLogic.d.ts +14 -0
- package/lib/ui-hooks/useRunesListLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useRunesTokenScreenLogic.d.ts +22 -0
- package/lib/ui-hooks/useRunesTokenScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSecurityCardLogic.d.ts +1 -0
- package/lib/ui-hooks/useSecurityCardLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendAlkanesNFTScreenLogic.d.ts +32 -0
- package/lib/ui-hooks/useSendAlkanesNFTScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendAlkanesScreenLogic.d.ts +37 -0
- package/lib/ui-hooks/useSendAlkanesScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendCAT20ScreenLogic.d.ts +44 -0
- package/lib/ui-hooks/useSendCAT20ScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendCAT721ScreenLogic.d.ts +40 -0
- package/lib/ui-hooks/useSendCAT721ScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendOrdinalsInscriptionScreenLogic.d.ts +22 -0
- package/lib/ui-hooks/useSendOrdinalsInscriptionScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSendRunesScreenLogic.d.ts +30 -0
- package/lib/ui-hooks/useSendRunesScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSettingsTabScreenLogic.d.ts +72 -0
- package/lib/ui-hooks/useSettingsTabScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSignMessageLogic.d.ts +54 -0
- package/lib/ui-hooks/useSignMessageLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSignPsbtLogic.d.ts +82 -0
- package/lib/ui-hooks/useSignPsbtLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.d.ts +15 -0
- package/lib/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useTxConfirmScreenLogic.d.ts +8 -0
- package/lib/ui-hooks/useTxConfirmScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useTxCreateScreenLogic.d.ts +28 -0
- package/lib/ui-hooks/useTxCreateScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useTxFailScreenLogic.d.ts +7 -0
- package/lib/ui-hooks/useTxFailScreenLogic.d.ts.map +1 -0
- package/lib/ui-hooks/useTxSuccessScreenLogic.d.ts +8 -0
- package/lib/ui-hooks/useTxSuccessScreenLogic.d.ts.map +1 -0
- package/lib/updater/accounts.d.ts +2 -0
- package/lib/updater/accounts.d.ts.map +1 -0
- package/lib/updater/index.d.ts +2 -0
- package/lib/updater/index.d.ts.map +1 -0
- package/lib/utils/bitcoin-utils.d.ts +7 -0
- package/lib/utils/bitcoin-utils.d.ts.map +1 -0
- package/lib/utils/eventBus.d.ts +12 -0
- package/lib/utils/eventBus.d.ts.map +1 -0
- package/lib/utils/password-utils.d.ts +12 -0
- package/lib/utils/password-utils.d.ts.map +1 -0
- package/lib/utils/ui-utils.d.ts +4 -0
- package/lib/utils/ui-utils.d.ts.map +1 -0
- package/package.json +19 -15
- package/src/.DS_Store +0 -0
- package/src/context/ApprovalContext.tsx +27 -0
- package/src/context/DeviceContext.tsx +36 -0
- package/src/context/I18nContext.tsx +14 -172
- package/src/context/NavigationContext.tsx +305 -0
- package/src/context/PriceContext.tsx +2 -2
- package/src/context/StorageContext.tsx +393 -0
- package/src/context/ToolsContext.tsx +50 -0
- package/src/context/WalletContext.tsx +170 -126
- package/src/context/index.ts +17 -2
- package/src/hooks/accounts.ts +11 -5
- package/src/hooks/browser.ts +11 -0
- package/src/hooks/global.ts +170 -7
- package/src/hooks/index.ts +1 -2
- package/src/hooks/settings.ts +38 -37
- package/src/hooks/transactions.ts +45 -151
- package/src/hooks/ui.ts +239 -35
- package/src/index.ts +33 -24
- package/src/reducers/accounts.ts +22 -2
- package/src/reducers/browser.ts +223 -0
- package/src/reducers/global.ts +67 -1
- package/src/reducers/index.ts +1 -0
- package/src/reducers/transactions.ts +0 -9
- package/src/reducers/ui.ts +144 -4
- package/src/types/index.ts +1 -1
- package/src/types/ui.ts +6 -1
- package/src/ui-hooks/index.ts +107 -0
- package/src/ui-hooks/useActionOverviewSectionLogic.ts +150 -0
- package/src/ui-hooks/useAddressTypeScreenLogic.ts +160 -0
- package/src/ui-hooks/useAlkanesBalanceCardLogic.ts +41 -0
- package/src/ui-hooks/useAlkanesCollectionListLogic.ts +68 -0
- package/src/ui-hooks/useAlkanesListLogic.ts +69 -0
- package/src/ui-hooks/useAlkanesNFTListLogic.ts +42 -0
- package/src/ui-hooks/useAlkanesNFTScreenLogic.ts +45 -0
- package/src/ui-hooks/useAlkanesTokenScreenLogic.ts +138 -0
- package/src/ui-hooks/useAmountInputLogic.ts +80 -0
- package/src/ui-hooks/useAnnouncementCardLogic.ts +91 -0
- package/src/ui-hooks/useBRC20BalanceCardLogic.ts +115 -0
- package/src/ui-hooks/useBRC20InscribeTransferLogic.ts +418 -0
- package/src/ui-hooks/useBRC20ListLogic.ts +79 -0
- package/src/ui-hooks/useBRC20ProgListLogic.ts +81 -0
- package/src/ui-hooks/useBRC20SendScreenLogic.ts +424 -0
- package/src/ui-hooks/useBRC20SingleStepScreenLogic.ts +208 -0
- package/src/ui-hooks/useBRC20TokenScreenLogic.ts +489 -0
- package/src/ui-hooks/useBalanceCardLogic.ts +164 -0
- package/src/ui-hooks/useBtcDisplayLogic.ts +16 -0
- package/src/ui-hooks/useCAT20BalanceCardLogic.ts +35 -0
- package/src/ui-hooks/useCAT20ListLogic.ts +83 -0
- package/src/ui-hooks/useCAT20TokenScreenLogic.ts +127 -0
- package/src/ui-hooks/useCAT721ListLogic.ts +68 -0
- package/src/ui-hooks/useCAT721NFTScreenLogic.ts +37 -0
- package/src/ui-hooks/useCreatePasswordScreenLogic.ts +92 -0
- package/src/ui-hooks/useCreateWalletLogicImportWordsStep.ts +299 -0
- package/src/ui-hooks/useEditAccountNameScreenLogic.ts +71 -0
- package/src/ui-hooks/useEditContactScreenLogic.ts +162 -0
- package/src/ui-hooks/useEditWalletNameScreenLogic.ts +60 -0
- package/src/ui-hooks/useExportMnemonicsScreenLogic.ts +75 -0
- package/src/ui-hooks/useExportPrivateKeyScreenLogic.ts +64 -0
- package/src/ui-hooks/useFeeRateBarLogic.ts +303 -0
- package/src/ui-hooks/useInfiniteList.ts +85 -0
- package/src/ui-hooks/useInscriptionListLogic.ts +68 -0
- package/src/ui-hooks/useLockTimePageLogic.ts +43 -0
- package/src/ui-hooks/useNotificationsLogic.ts +115 -0
- package/src/ui-hooks/useOrdinalsInscriptionScreenLogic.ts +130 -0
- package/src/ui-hooks/useRunesBalanceCardLogic.ts +44 -0
- package/src/ui-hooks/useRunesListLogic.ts +74 -0
- package/src/ui-hooks/useRunesTokenScreenLogic.ts +156 -0
- package/src/ui-hooks/useSecurityCardLogic.ts +0 -0
- package/src/ui-hooks/useSendAlkanesNFTScreenLogic.ts +160 -0
- package/src/ui-hooks/useSendAlkanesScreenLogic.ts +208 -0
- package/src/ui-hooks/useSendCAT20ScreenLogic.ts +297 -0
- package/src/ui-hooks/useSendCAT721ScreenLogic.ts +205 -0
- package/src/ui-hooks/useSendOrdinalsInscriptionScreenLogic.ts +152 -0
- package/src/ui-hooks/useSendRunesScreenLogic.ts +189 -0
- package/src/ui-hooks/useSettingsTabScreenLogic.ts +211 -0
- package/src/ui-hooks/useSignMessageLogic.ts +302 -0
- package/src/ui-hooks/useSignPsbtLogic.ts +517 -0
- package/src/ui-hooks/useSplitOrdinalsInscriptionScreenLogic.ts +109 -0
- package/src/ui-hooks/useTxConfirmScreenLogic.ts +47 -0
- package/src/ui-hooks/useTxCreateScreenLogic.ts +177 -0
- package/src/ui-hooks/useTxFailScreenLogic.ts +26 -0
- package/src/ui-hooks/useTxSuccessScreenLogic.ts +33 -0
- package/src/updater/accounts.ts +11 -11
- package/src/utils/bitcoin-utils.ts +17 -8
- package/src/utils/eventBus.ts +2 -1
- package/src/utils/password-utils.ts +78 -0
- package/src/utils/ui-utils.ts +28 -0
- package/src/hooks/approval.ts +0 -72
- package/src/hooks/i18n.ts +0 -53
- package/src/utils/i18n.ts +0 -41
package/src/hooks/global.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { useCallback } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { AddressType } from '@unisat/wallet-types'
|
|
4
4
|
|
|
5
|
-
import { AppState } from '..'
|
|
6
|
-
import { useAppDispatch, useAppSelector } from './base'
|
|
7
|
-
import { globalActions } from '../reducers/global'
|
|
5
|
+
import { AppState, useApproval, useNavigation } from '..'
|
|
8
6
|
import { useWallet } from '../context/WalletContext'
|
|
9
|
-
import {
|
|
7
|
+
import { globalActions } from '../reducers/global'
|
|
10
8
|
import { TabOption } from '../types'
|
|
9
|
+
import { useAppDispatch, useAppSelector } from './base'
|
|
11
10
|
|
|
12
11
|
export function useGlobalState(): AppState['global'] {
|
|
13
12
|
return useAppSelector(state => state.global)
|
|
@@ -18,6 +17,25 @@ export function useTab() {
|
|
|
18
17
|
return globalState.tab
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
export function useScreenState() {
|
|
21
|
+
const globalState = useGlobalState()
|
|
22
|
+
return globalState.screenState
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useUpdateScreenStateCallback() {
|
|
26
|
+
const dispatch = useAppDispatch()
|
|
27
|
+
return useCallback(
|
|
28
|
+
(screenState: Partial<AppState['global']['screenState']>) => {
|
|
29
|
+
dispatch(
|
|
30
|
+
globalActions['updateScreenState']!({
|
|
31
|
+
screenState,
|
|
32
|
+
})
|
|
33
|
+
)
|
|
34
|
+
},
|
|
35
|
+
[dispatch]
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
export function useSetTabCallback() {
|
|
22
40
|
const dispatch = useAppDispatch()
|
|
23
41
|
return useCallback(
|
|
@@ -47,10 +65,153 @@ export function useIsReady() {
|
|
|
47
65
|
return globalState.isReady
|
|
48
66
|
}
|
|
49
67
|
|
|
68
|
+
export function useIsRefresh() {
|
|
69
|
+
const globalState = useGlobalState()
|
|
70
|
+
return globalState.isRefresh
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function useBackRefresh() {
|
|
74
|
+
const globalState = useGlobalState()
|
|
75
|
+
return globalState.backRefresh
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function useWallRefresh() {
|
|
79
|
+
const globalState = useGlobalState()
|
|
80
|
+
return globalState.wallRefresh
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function useWallTabRefresh() {
|
|
84
|
+
const globalState = useGlobalState()
|
|
85
|
+
return globalState.wallTabRefresh
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function useWallTabFocusRefresh() {
|
|
89
|
+
const globalState = useGlobalState()
|
|
90
|
+
return globalState.wallTabFocusRefresh
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function useGoBackRefresh() {
|
|
94
|
+
const globalState = useGlobalState()
|
|
95
|
+
return globalState.goBackRefresh
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function useLayerState() {
|
|
99
|
+
const globalState = useGlobalState()
|
|
100
|
+
return globalState.layerState
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function useUnlockRefresh() {
|
|
104
|
+
const globalState = useGlobalState()
|
|
105
|
+
return globalState.unlockRefres
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function useUnlockRead() {
|
|
109
|
+
const globalState = useGlobalState()
|
|
110
|
+
return globalState.unlockRead
|
|
111
|
+
}
|
|
112
|
+
export function useIsUnlockTimeRefres() {
|
|
113
|
+
const globalState = useGlobalState()
|
|
114
|
+
return globalState.isUnlockTimeRefres
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function useInfiniteListScrollOffset() {
|
|
118
|
+
const globalState = useGlobalState()
|
|
119
|
+
return globalState.infiniteListScrollOffset
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function useInfiniteListScrollState() {
|
|
123
|
+
const globalState = useGlobalState()
|
|
124
|
+
return {
|
|
125
|
+
offset: globalState.infiniteListScrollOffset,
|
|
126
|
+
direction: globalState.infiniteListScrollDirection,
|
|
127
|
+
activeTime: globalState.infiniteListScrollActiveTime,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function useIsScrollViewTop() {
|
|
132
|
+
const globalState = useGlobalState()
|
|
133
|
+
return globalState.isScrollViewTop
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function useIsScrollViewBot() {
|
|
137
|
+
const globalState = useGlobalState()
|
|
138
|
+
return globalState.isScrollViewBot
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function useIsBiometricsSupported() {
|
|
142
|
+
const globalState = useGlobalState()
|
|
143
|
+
return globalState.isBiometricsSupported
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function useHasBiometricsKey() {
|
|
147
|
+
const globalState = useGlobalState()
|
|
148
|
+
return globalState.hasBiometricsKey
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function useSwitchChainModalVisible() {
|
|
152
|
+
const globalState = useGlobalState()
|
|
153
|
+
return globalState.switchChainModalVisible
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function useSetLockedOverlayVisibleCallback() {
|
|
157
|
+
const dispatch = useAppDispatch()
|
|
158
|
+
return useCallback(
|
|
159
|
+
(visible: boolean) => {
|
|
160
|
+
dispatch(
|
|
161
|
+
globalActions['update']!({
|
|
162
|
+
isLockedOverlayVisible: visible,
|
|
163
|
+
})
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
[dispatch]
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function useLockedOverlayVisible() {
|
|
171
|
+
const globalState = useGlobalState()
|
|
172
|
+
return globalState.isLockedOverlayVisible
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function useLockCallback() {
|
|
176
|
+
const dispatch = useAppDispatch()
|
|
177
|
+
const wallet = useWallet()
|
|
178
|
+
const navigation = useNavigation()
|
|
179
|
+
return useCallback(async () => {
|
|
180
|
+
dispatch(globalActions.update({ isLockedOverlayVisible: true }))
|
|
181
|
+
await wallet.lockWallet()
|
|
182
|
+
const isBooted = await wallet.isBooted()
|
|
183
|
+
const isUnlocked = await wallet.isUnlocked()
|
|
184
|
+
dispatch(globalActions.update({ isUnlocked: false }))
|
|
185
|
+
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
dispatch(globalActions.update({ isLockedOverlayVisible: false }))
|
|
188
|
+
}, 300)
|
|
189
|
+
|
|
190
|
+
if (!isBooted) {
|
|
191
|
+
navigation.navToWelcome()
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!isUnlocked && !isBooted) {
|
|
196
|
+
navigation.navToWelcome()
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!isUnlocked && isBooted) {
|
|
201
|
+
navigation.navToLock({ autoUnlockByFace: false })
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
const currentAccount = await wallet.getCurrentAccount()
|
|
205
|
+
if (!currentAccount) {
|
|
206
|
+
navigation.navToWelcome()
|
|
207
|
+
}
|
|
208
|
+
}, [dispatch, wallet])
|
|
209
|
+
}
|
|
210
|
+
|
|
50
211
|
export function useUnlockCallback() {
|
|
51
212
|
const dispatch = useAppDispatch()
|
|
52
213
|
const wallet = useWallet()
|
|
53
|
-
const
|
|
214
|
+
const { resolveApproval } = useApproval()
|
|
54
215
|
return useCallback(
|
|
55
216
|
async (password: string) => {
|
|
56
217
|
await wallet.unlock(password)
|
|
@@ -70,14 +231,16 @@ export function useCreateAccountCallback() {
|
|
|
70
231
|
hdPath: string,
|
|
71
232
|
passphrase: string,
|
|
72
233
|
addressType: AddressType,
|
|
73
|
-
accountCount: number
|
|
234
|
+
accountCount: number,
|
|
235
|
+
accountIndexDerivation = false
|
|
74
236
|
) => {
|
|
75
237
|
await wallet.createKeyringWithMnemonics(
|
|
76
238
|
mnemonics,
|
|
77
239
|
hdPath,
|
|
78
240
|
passphrase,
|
|
79
241
|
addressType,
|
|
80
|
-
accountCount
|
|
242
|
+
accountCount,
|
|
243
|
+
accountIndexDerivation
|
|
81
244
|
)
|
|
82
245
|
dispatch(globalActions.update({ isUnlocked: true }))
|
|
83
246
|
},
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export * from './accounts'
|
|
2
|
-
export * from './approval'
|
|
3
2
|
export * from './base'
|
|
4
3
|
export * from './discovery'
|
|
5
4
|
export * from './global'
|
|
6
|
-
export * from './i18n'
|
|
7
5
|
export * from './keyrings'
|
|
8
6
|
export * from './settings'
|
|
9
7
|
export * from './transactions'
|
|
10
8
|
export * from './ui'
|
|
9
|
+
export * from './browser'
|
package/src/hooks/settings.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import compareVersions from 'compare-versions'
|
|
2
2
|
import { useCallback } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { BABYLON_CONFIG_MAP } from '@unisat/babylon-service/types'
|
|
5
|
+
import { CAT_VERSION, CHAINS_MAP, PlatformEnv } from '@unisat/wallet-shared'
|
|
5
6
|
import { AddressType, ChainType, NetworkType } from '@unisat/wallet-types'
|
|
6
7
|
import { useWallet } from '../context/WalletContext'
|
|
7
8
|
import { getAddressType } from '../utils/bitcoin-utils'
|
|
8
|
-
import i18n, { addResourceBundle } from '../utils/i18n'
|
|
9
|
-
import { BABYLON_CONFIG_MAP } from '@unisat/babylon-service/types'
|
|
10
|
-
import { t } from '@unisat/i18n'
|
|
11
9
|
|
|
10
|
+
import { useI18n } from 'src/context/I18nContext'
|
|
12
11
|
import { AppState } from '..'
|
|
13
12
|
import { useCurrentAccount } from '../hooks/accounts'
|
|
14
|
-
import { useAppDispatch, useAppSelector } from './base'
|
|
15
13
|
import { settingsActions } from '../reducers/settings'
|
|
14
|
+
import { useAppDispatch, useAppSelector } from './base'
|
|
16
15
|
|
|
17
16
|
export function useSettingsState(): AppState['settings'] {
|
|
18
17
|
return useAppSelector(state => state.settings)
|
|
@@ -26,11 +25,12 @@ export function useLocale() {
|
|
|
26
25
|
export function useChangeLocaleCallback() {
|
|
27
26
|
const dispatch = useAppDispatch()
|
|
28
27
|
const wallet = useWallet()
|
|
28
|
+
const i18n = useI18n()
|
|
29
29
|
return useCallback(
|
|
30
30
|
async (locale: string) => {
|
|
31
31
|
await wallet.setLocale(locale)
|
|
32
|
-
await addResourceBundle(locale)
|
|
33
|
-
i18n.
|
|
32
|
+
await i18n.addResourceBundle(locale)
|
|
33
|
+
i18n.changeLocale(locale)
|
|
34
34
|
dispatch(
|
|
35
35
|
(settingsActions as any).updateSettings({
|
|
36
36
|
locale,
|
|
@@ -94,12 +94,12 @@ export function useChangeChainTypeCallback() {
|
|
|
94
94
|
const wallet = useWallet()
|
|
95
95
|
return useCallback(
|
|
96
96
|
async (type: ChainType) => {
|
|
97
|
+
await wallet.setChainType(type)
|
|
97
98
|
dispatch(
|
|
98
99
|
(settingsActions as any).updateSettings({
|
|
99
100
|
chainType: type,
|
|
100
101
|
})
|
|
101
102
|
)
|
|
102
|
-
await wallet.setChainType(type)
|
|
103
103
|
},
|
|
104
104
|
[dispatch]
|
|
105
105
|
)
|
|
@@ -157,11 +157,31 @@ export function useCAT20TokenInfoExplorerUrl(version: CAT_VERSION, tokenId: stri
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
export function useBRC20TokenInfoExplorerUrl(ticker: string) {
|
|
161
|
+
const chain = useChain()!
|
|
162
|
+
return `${chain.unisatExplorerUrl}/brc20/${encodeURIComponent(ticker)}`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function useRunesTokenInfoExplorerUrl(runeId: string) {
|
|
166
|
+
const chain = useChain()!
|
|
167
|
+
return `${chain.unisatExplorerUrl}/runes/detail/${encodeURIComponent(runeId)}`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function useAlkanesTokenInfoExplorerUrl(alkaneId: string) {
|
|
171
|
+
const chain = useChain()!
|
|
172
|
+
return `${chain.unisatExplorerUrl}/alkanes/detail/${encodeURIComponent(alkaneId)}`
|
|
173
|
+
}
|
|
174
|
+
|
|
160
175
|
export function useUnisatWebsite() {
|
|
161
176
|
const chainType = useChainType()
|
|
162
177
|
return CHAINS_MAP[chainType]!.unisatUrl
|
|
163
178
|
}
|
|
164
179
|
|
|
180
|
+
export function useIconBaseUrl() {
|
|
181
|
+
const chainType = useChainType()
|
|
182
|
+
return CHAINS_MAP[chainType]!.iconBaseUrl
|
|
183
|
+
}
|
|
184
|
+
|
|
165
185
|
export function useOrdinalsWebsite() {
|
|
166
186
|
const chainType = useChainType()
|
|
167
187
|
return CHAINS_MAP[chainType]!.ordinalsUrl
|
|
@@ -177,7 +197,7 @@ export function useVersionInfo() {
|
|
|
177
197
|
const walletConfig = accountsState.walletConfig
|
|
178
198
|
const newVersion = walletConfig.version
|
|
179
199
|
const skippedVersion = accountsState.skippedVersion
|
|
180
|
-
const currentVesion = VERSION
|
|
200
|
+
const currentVesion = PlatformEnv.VERSION
|
|
181
201
|
let skipped = false
|
|
182
202
|
let latestVersion = ''
|
|
183
203
|
// skip if new version is empty
|
|
@@ -191,7 +211,7 @@ export function useVersionInfo() {
|
|
|
191
211
|
}
|
|
192
212
|
|
|
193
213
|
// skip if current version is greater or equal to new version
|
|
194
|
-
if (newVersion) {
|
|
214
|
+
if (currentVesion && newVersion) {
|
|
195
215
|
if (compareVersions(currentVesion, newVersion) >= 0) {
|
|
196
216
|
skipped = true
|
|
197
217
|
} else {
|
|
@@ -208,6 +228,8 @@ export function useVersionInfo() {
|
|
|
208
228
|
newVersion,
|
|
209
229
|
latestVersion,
|
|
210
230
|
skipped,
|
|
231
|
+
downloadUrl: '',
|
|
232
|
+
isNewest: false,
|
|
211
233
|
}
|
|
212
234
|
}
|
|
213
235
|
|
|
@@ -226,7 +248,12 @@ export function useAutoLockTimeId() {
|
|
|
226
248
|
return state.autoLockTimeId
|
|
227
249
|
}
|
|
228
250
|
|
|
229
|
-
export function
|
|
251
|
+
export function useAddressTips() {
|
|
252
|
+
const chain = useChain()!
|
|
253
|
+
const account = useCurrentAccount()
|
|
254
|
+
const address = account.address
|
|
255
|
+
const chanEnum = chain.enum
|
|
256
|
+
const { t } = useI18n()
|
|
230
257
|
let ret = {
|
|
231
258
|
homeTip: '',
|
|
232
259
|
sendTip: '',
|
|
@@ -247,12 +274,6 @@ export function getAddressTips(address: string, chanEnum: ChainType) {
|
|
|
247
274
|
return ret
|
|
248
275
|
}
|
|
249
276
|
|
|
250
|
-
export function useAddressTips() {
|
|
251
|
-
const chain = useChain()!
|
|
252
|
-
const account = useCurrentAccount()
|
|
253
|
-
return getAddressTips(account.address, chain.enum)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
277
|
export function useCAT721NFTContentBaseUrl(version: CAT_VERSION) {
|
|
257
278
|
const chainType = useChainType()
|
|
258
279
|
if (chainType === ChainType.FRACTAL_BITCOIN_MAINNET) {
|
|
@@ -268,26 +289,6 @@ export function useCAT721NFTContentBaseUrl(version: CAT_VERSION) {
|
|
|
268
289
|
}
|
|
269
290
|
}
|
|
270
291
|
|
|
271
|
-
export function useBRC20MarketPlaceWebsite(ticker: string) {
|
|
272
|
-
const chainType = useChainType()
|
|
273
|
-
if (chainType === ChainType.BITCOIN_MAINNET) {
|
|
274
|
-
if (ticker.length == 6) {
|
|
275
|
-
return `${CHAINS_MAP[chainType]!.unisatUrl}/market/brc20_prog?tick=${ticker}`
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return `${CHAINS_MAP[chainType]!.unisatUrl}/market/brc20?tick=${ticker}`
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export function useRunesMarketPlaceWebsite(ticker: string) {
|
|
282
|
-
const chainType = useChainType()
|
|
283
|
-
return `${CHAINS_MAP[chainType]!.unisatUrl}/runes/market?tick=${ticker}`
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export function useCAT20MarketPlaceWebsite(tokenId: string) {
|
|
287
|
-
const chainType = useChainType()
|
|
288
|
-
return `${CHAINS_MAP[chainType]!.unisatUrl}/dex/cat20/${tokenId}`
|
|
289
|
-
}
|
|
290
|
-
|
|
291
292
|
export function useBabylonConfig() {
|
|
292
293
|
const chainType = useChainType()
|
|
293
294
|
return BABYLON_CONFIG_MAP[chainType] || BABYLON_CONFIG_MAP[ChainType.BITCOIN_MAINNET]
|