@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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Inscription } from '@unisat/wallet-shared'
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
3
|
+
import { useI18n, useNavigation, useWallet } from 'src/context'
|
|
4
|
+
import { useCurrentAccount, useResetTxState } from 'src/hooks'
|
|
5
|
+
|
|
6
|
+
const HIGH_BALANCE = 10000
|
|
7
|
+
|
|
8
|
+
enum TabKey {
|
|
9
|
+
DETAILS = 'DETAILS',
|
|
10
|
+
PROVENANCE = 'PROVENANCE',
|
|
11
|
+
}
|
|
12
|
+
export function useOrdinalsInscriptionScreenLogic() {
|
|
13
|
+
const nav = useNavigation()
|
|
14
|
+
const props = nav.getRouteState<'OrdinalsInscriptionScreen'>()
|
|
15
|
+
const inscriptionId = props.inscriptionId
|
|
16
|
+
|
|
17
|
+
const [inscription, setInscription] = useState<Inscription>(props.inscription)
|
|
18
|
+
const [isLoadingDetails, setIsLoadingDetails] = useState(false)
|
|
19
|
+
const [isInitialLoading, setIsInitialLoading] = useState(!props.inscription)
|
|
20
|
+
|
|
21
|
+
const currentAccount = useCurrentAccount()
|
|
22
|
+
|
|
23
|
+
const resetTxState = useResetTxState()
|
|
24
|
+
|
|
25
|
+
const { t } = useI18n()
|
|
26
|
+
|
|
27
|
+
const [isNeedToSplit, setIsNeedToSplit] = useState(false)
|
|
28
|
+
const [isMultiStuck, setIsMultiStuck] = useState(false)
|
|
29
|
+
const wallet = useWallet()
|
|
30
|
+
|
|
31
|
+
const [tabKey, setTabKey] = useState(TabKey.DETAILS)
|
|
32
|
+
|
|
33
|
+
const resetState = useCallback(() => {
|
|
34
|
+
setIsNeedToSplit(false)
|
|
35
|
+
setIsMultiStuck(false)
|
|
36
|
+
setIsLoadingDetails(false)
|
|
37
|
+
setIsInitialLoading(!props?.inscription)
|
|
38
|
+
setTabKey(TabKey.DETAILS)
|
|
39
|
+
}, [props?.inscription])
|
|
40
|
+
|
|
41
|
+
const fetchInscriptionData = async (id: string) => {
|
|
42
|
+
if (!id) return
|
|
43
|
+
|
|
44
|
+
// If we already have basic inscription data, show it immediately
|
|
45
|
+
// and load details in the background
|
|
46
|
+
const isBackgroundLoading = !!inscription
|
|
47
|
+
|
|
48
|
+
if (isBackgroundLoading) {
|
|
49
|
+
setIsLoadingDetails(true)
|
|
50
|
+
} else {
|
|
51
|
+
setIsInitialLoading(true)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const data = await wallet.getInscriptionInfo(id)
|
|
56
|
+
setInscription(data)
|
|
57
|
+
setTabKey(TabKey.DETAILS)
|
|
58
|
+
|
|
59
|
+
if (data.multipleNFT) {
|
|
60
|
+
setIsMultiStuck(true)
|
|
61
|
+
|
|
62
|
+
if (data.sameOffset) {
|
|
63
|
+
setIsNeedToSplit(false)
|
|
64
|
+
} else {
|
|
65
|
+
if (data.outputValue > HIGH_BALANCE) {
|
|
66
|
+
setIsNeedToSplit(true)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
if (data.outputValue > HIGH_BALANCE) {
|
|
71
|
+
setIsNeedToSplit(true)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.error('Failed to fetch inscription data:', e)
|
|
76
|
+
} finally {
|
|
77
|
+
setIsLoadingDetails(false)
|
|
78
|
+
setIsInitialLoading(false)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (inscriptionId) {
|
|
84
|
+
resetState()
|
|
85
|
+
|
|
86
|
+
// Always fetch the latest data, but we'll show what we have immediately
|
|
87
|
+
fetchInscriptionData(inscriptionId)
|
|
88
|
+
}
|
|
89
|
+
}, [inscriptionId])
|
|
90
|
+
|
|
91
|
+
const onClickSplit = () => {
|
|
92
|
+
resetTxState()
|
|
93
|
+
nav.navigate('SplitOrdinalsInscriptionScreen', { inscription, inscriptionId })
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const onClickSend = () => {
|
|
97
|
+
resetTxState()
|
|
98
|
+
nav.navigate('SendOrdinalsInscriptionScreen', { inscription, inscriptionId })
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isUnconfirmed = inscription ? inscription.timestamp == 0 : false
|
|
102
|
+
|
|
103
|
+
const withSend = inscription ? currentAccount.address === inscription.address : false
|
|
104
|
+
|
|
105
|
+
const children = inscription ? inscription.children || [] : []
|
|
106
|
+
const parents = inscription ? inscription.parents || [] : []
|
|
107
|
+
|
|
108
|
+
const hasProvenance = children.length > 0 || parents.length > 0
|
|
109
|
+
const shouldShowTabs = hasProvenance === true
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
inscription,
|
|
113
|
+
isLoadingDetails,
|
|
114
|
+
isInitialLoading,
|
|
115
|
+
isNeedToSplit,
|
|
116
|
+
isMultiStuck,
|
|
117
|
+
tabKey,
|
|
118
|
+
setTabKey,
|
|
119
|
+
TabKey,
|
|
120
|
+
resetState,
|
|
121
|
+
t,
|
|
122
|
+
inscriptionId,
|
|
123
|
+
onClickSend,
|
|
124
|
+
onClickSplit,
|
|
125
|
+
isUnconfirmed,
|
|
126
|
+
withSend,
|
|
127
|
+
shouldShowTabs,
|
|
128
|
+
nav,
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { bnUtils, numUtils } from '@unisat/base-utils'
|
|
2
|
+
import { RuneBalance, TickPriceItem } from '@unisat/wallet-shared'
|
|
3
|
+
import { useChain, useRunesIconInfo } from 'src/hooks'
|
|
4
|
+
|
|
5
|
+
export interface RunesBalanceCardProps {
|
|
6
|
+
tokenBalance: RuneBalance
|
|
7
|
+
onClick?: () => void
|
|
8
|
+
price?: TickPriceItem
|
|
9
|
+
}
|
|
10
|
+
export function useRunesBalanceCardLogic(props: RunesBalanceCardProps) {
|
|
11
|
+
const { tokenBalance, price, onClick } = props
|
|
12
|
+
|
|
13
|
+
// balance
|
|
14
|
+
const balance = bnUtils.toDecimalNumber(tokenBalance.amount, tokenBalance.divisibility)
|
|
15
|
+
let balanceStr = balance.toString()
|
|
16
|
+
if (balance.lt(0.0001)) {
|
|
17
|
+
balanceStr = '<0.0001'
|
|
18
|
+
} else {
|
|
19
|
+
balanceStr = numUtils.showLongNumber(balance.toString())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// price
|
|
23
|
+
const chain = useChain()
|
|
24
|
+
const showPrice = chain.showPrice
|
|
25
|
+
|
|
26
|
+
// icon
|
|
27
|
+
const iconInfo = useRunesIconInfo(tokenBalance.spacedRune)
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
// balance
|
|
31
|
+
tokenBalance,
|
|
32
|
+
balance,
|
|
33
|
+
balanceStr,
|
|
34
|
+
|
|
35
|
+
// price
|
|
36
|
+
showPrice,
|
|
37
|
+
price,
|
|
38
|
+
|
|
39
|
+
// icon
|
|
40
|
+
iconInfo,
|
|
41
|
+
|
|
42
|
+
onClick,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { RuneBalance, TickPriceItem } from '@unisat/wallet-shared'
|
|
2
|
+
import { useEffect, useRef, useState } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
AssetTabKey,
|
|
5
|
+
useAssetTabKey,
|
|
6
|
+
useChainType,
|
|
7
|
+
useCurrentAccount,
|
|
8
|
+
useNavigation,
|
|
9
|
+
useWallet,
|
|
10
|
+
useWallTabFocusRefresh,
|
|
11
|
+
} from '..'
|
|
12
|
+
import { useInfiniteList } from './useInfiniteList'
|
|
13
|
+
|
|
14
|
+
export function useRunesListLogic() {
|
|
15
|
+
const nav = useNavigation()
|
|
16
|
+
const wallet = useWallet()
|
|
17
|
+
const currentAccount = useCurrentAccount()
|
|
18
|
+
const chainType = useChainType()
|
|
19
|
+
const [priceMap, setPriceMap] = useState<{ [key: string]: TickPriceItem }>({})
|
|
20
|
+
|
|
21
|
+
const priceMapRef = useRef(priceMap)
|
|
22
|
+
const updatePrices = (res: { [tick: string]: TickPriceItem }) => {
|
|
23
|
+
const newPriceMap = { ...priceMapRef.current }
|
|
24
|
+
Object.keys(res).forEach(tick => {
|
|
25
|
+
newPriceMap[tick] = res[tick]
|
|
26
|
+
})
|
|
27
|
+
priceMapRef.current = newPriceMap
|
|
28
|
+
setPriceMap(newPriceMap)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
data: items,
|
|
33
|
+
total,
|
|
34
|
+
loading,
|
|
35
|
+
hasMore,
|
|
36
|
+
onRefresh,
|
|
37
|
+
onLoadMore,
|
|
38
|
+
} = useInfiniteList<RuneBalance>({
|
|
39
|
+
fetcher: async (page, pageSize) => {
|
|
40
|
+
if (currentAccount.address === '') {
|
|
41
|
+
return { list: [], total: 0 }
|
|
42
|
+
}
|
|
43
|
+
const { list, total } = await wallet.getRunesList(currentAccount.address, page, pageSize)
|
|
44
|
+
if (list.length > 0) {
|
|
45
|
+
wallet.getRunesPrice(list.map(item => item.spacedRune)).then(updatePrices)
|
|
46
|
+
}
|
|
47
|
+
return { list, total }
|
|
48
|
+
},
|
|
49
|
+
dependencies: [currentAccount.address, chainType],
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const assetTabKey = useAssetTabKey()
|
|
53
|
+
const isFocus = assetTabKey === AssetTabKey.RUNES
|
|
54
|
+
const lastRefreshTimeRef = useRef<number>(0)
|
|
55
|
+
const walletTabFocusRefresh = useWallTabFocusRefresh()
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!isFocus) return
|
|
58
|
+
|
|
59
|
+
// already refreshed → do nothing
|
|
60
|
+
const alreadyRefreshed = lastRefreshTimeRef.current === walletTabFocusRefresh
|
|
61
|
+
if (alreadyRefreshed) return
|
|
62
|
+
|
|
63
|
+
onRefresh()
|
|
64
|
+
|
|
65
|
+
// mark refreshed
|
|
66
|
+
lastRefreshTimeRef.current = walletTabFocusRefresh
|
|
67
|
+
}, [walletTabFocusRefresh, isFocus])
|
|
68
|
+
|
|
69
|
+
const onClickItem = (item: RuneBalance) => {
|
|
70
|
+
nav.navigate('RunesTokenScreen', { runeid: item.runeid })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { items, total, loading, hasMore, onRefresh, onLoadMore, onClickItem, priceMap }
|
|
74
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { AddressRunesTokenSummary } from '@unisat/wallet-shared'
|
|
2
|
+
import { ChainType } from '@unisat/wallet-types'
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
4
|
+
import { useI18n, useNavigation, useTools, useWallet } from 'src/context'
|
|
5
|
+
import {
|
|
6
|
+
useChainType,
|
|
7
|
+
useCurrentAccount,
|
|
8
|
+
useOrdinalsWebsite,
|
|
9
|
+
useResetTxState,
|
|
10
|
+
useRunesIconInfo,
|
|
11
|
+
useRunesInscribeUrl,
|
|
12
|
+
useRunesMarketUrl,
|
|
13
|
+
useRunesTokenInfoExplorerUrl,
|
|
14
|
+
useTxExplorerUrl,
|
|
15
|
+
} from 'src/hooks'
|
|
16
|
+
|
|
17
|
+
export function useRunesTokenScreenLogic() {
|
|
18
|
+
const nav = useNavigation()
|
|
19
|
+
const { runeid } = nav.getRouteState<'RunesTokenScreen'>()
|
|
20
|
+
const [tokenSummary, setTokenSummary] = useState<AddressRunesTokenSummary>({
|
|
21
|
+
runeBalance: {
|
|
22
|
+
runeid: '',
|
|
23
|
+
rune: '',
|
|
24
|
+
spacedRune: '',
|
|
25
|
+
amount: '',
|
|
26
|
+
symbol: '',
|
|
27
|
+
divisibility: 0,
|
|
28
|
+
},
|
|
29
|
+
runeInfo: {
|
|
30
|
+
rune: '',
|
|
31
|
+
runeid: '',
|
|
32
|
+
spacedRune: '',
|
|
33
|
+
symbol: '',
|
|
34
|
+
premine: '',
|
|
35
|
+
mints: '',
|
|
36
|
+
divisibility: 0,
|
|
37
|
+
etching: '',
|
|
38
|
+
terms: {
|
|
39
|
+
amount: '',
|
|
40
|
+
cap: '',
|
|
41
|
+
heightStart: 0,
|
|
42
|
+
heightEnd: 0,
|
|
43
|
+
offsetStart: 0,
|
|
44
|
+
offsetEnd: 0,
|
|
45
|
+
},
|
|
46
|
+
number: 0,
|
|
47
|
+
height: 0,
|
|
48
|
+
txidx: 0,
|
|
49
|
+
timestamp: 0,
|
|
50
|
+
burned: '',
|
|
51
|
+
holders: 0,
|
|
52
|
+
transactions: 0,
|
|
53
|
+
mintable: false,
|
|
54
|
+
remaining: '',
|
|
55
|
+
start: 0,
|
|
56
|
+
end: 0,
|
|
57
|
+
supply: '0',
|
|
58
|
+
parent: '',
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const wallet = useWallet()
|
|
63
|
+
|
|
64
|
+
const account = useCurrentAccount()
|
|
65
|
+
|
|
66
|
+
const [loading, setLoading] = useState(true)
|
|
67
|
+
|
|
68
|
+
const { t } = useI18n()
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
wallet.getAddressRunesTokenSummary(account.address, runeid).then(tokenSummary => {
|
|
72
|
+
setTokenSummary(tokenSummary)
|
|
73
|
+
setLoading(false)
|
|
74
|
+
})
|
|
75
|
+
}, [])
|
|
76
|
+
|
|
77
|
+
const enableMint = tokenSummary.runeInfo.mintable
|
|
78
|
+
|
|
79
|
+
const enableTransfer = useMemo(() => {
|
|
80
|
+
let enable = false
|
|
81
|
+
if (tokenSummary.runeBalance.amount !== '0') {
|
|
82
|
+
enable = true
|
|
83
|
+
}
|
|
84
|
+
return enable
|
|
85
|
+
}, [tokenSummary])
|
|
86
|
+
|
|
87
|
+
const tools = useTools()
|
|
88
|
+
|
|
89
|
+
const ordinalsWebsite = useOrdinalsWebsite()
|
|
90
|
+
|
|
91
|
+
const resetTxState = useResetTxState()
|
|
92
|
+
|
|
93
|
+
const txExplorerUrl = useTxExplorerUrl(tokenSummary.runeInfo.etching)
|
|
94
|
+
|
|
95
|
+
const chainType = useChainType()
|
|
96
|
+
const enableTrade = useMemo(() => {
|
|
97
|
+
if (
|
|
98
|
+
chainType === ChainType.BITCOIN_MAINNET ||
|
|
99
|
+
chainType === ChainType.FRACTAL_BITCOIN_MAINNET
|
|
100
|
+
) {
|
|
101
|
+
return true
|
|
102
|
+
} else {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
}, [chainType])
|
|
106
|
+
|
|
107
|
+
const iconInfo = useRunesIconInfo(tokenSummary.runeInfo.spacedRune)
|
|
108
|
+
const inscribeUrl = useRunesInscribeUrl(tokenSummary.runeInfo.rune)
|
|
109
|
+
const marketPlaceUrl = useRunesMarketUrl(tokenSummary.runeInfo.spacedRune)
|
|
110
|
+
const runesExplorerUrl = useRunesTokenInfoExplorerUrl(tokenSummary.runeInfo.runeid)
|
|
111
|
+
|
|
112
|
+
const onClickMint = () => {
|
|
113
|
+
nav.navToUrl(inscribeUrl)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const onClickSend = () => {
|
|
117
|
+
resetTxState()
|
|
118
|
+
nav.navigate('SendRunesScreen', {
|
|
119
|
+
runeBalance: tokenSummary.runeBalance,
|
|
120
|
+
runeInfo: tokenSummary.runeInfo,
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const onClickTrade = () => {
|
|
125
|
+
if (marketPlaceUrl) {
|
|
126
|
+
nav.navToUrl(marketPlaceUrl)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const onClickViewOnExplorer = () => {
|
|
131
|
+
nav.navToUrl(runesExplorerUrl)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
runeid,
|
|
136
|
+
tokenSummary,
|
|
137
|
+
iconInfo,
|
|
138
|
+
|
|
139
|
+
loading,
|
|
140
|
+
t,
|
|
141
|
+
|
|
142
|
+
enableMint,
|
|
143
|
+
onClickMint,
|
|
144
|
+
|
|
145
|
+
tools,
|
|
146
|
+
ordinalsWebsite,
|
|
147
|
+
txExplorerUrl,
|
|
148
|
+
|
|
149
|
+
enableTransfer,
|
|
150
|
+
onClickSend,
|
|
151
|
+
|
|
152
|
+
enableTrade,
|
|
153
|
+
onClickTrade,
|
|
154
|
+
onClickViewOnExplorer,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Inscription, SignedData, SignPsbtParams, ToSignData } from '@unisat/wallet-shared'
|
|
2
|
+
import { useEffect, useRef, useState } from 'react'
|
|
3
|
+
import { useI18n, useNavigation, useTools, useWallet } from 'src/context'
|
|
4
|
+
import {
|
|
5
|
+
useCurrentAccount,
|
|
6
|
+
useFeeRateBar,
|
|
7
|
+
usePrepareSendAlkanesCallback,
|
|
8
|
+
usePushBitcoinTxCallback,
|
|
9
|
+
} from 'src/hooks'
|
|
10
|
+
import { isValidAddress } from 'src/utils/bitcoin-utils'
|
|
11
|
+
|
|
12
|
+
export enum SendAlkanesNFTScreenStep {
|
|
13
|
+
CREATE_TX = 0,
|
|
14
|
+
SIGN_TX = 1,
|
|
15
|
+
}
|
|
16
|
+
export function useSendAlkanesNFTScreenLogic() {
|
|
17
|
+
const nav = useNavigation()
|
|
18
|
+
const props = nav.getRouteState<'SendAlkanesNFTScreen'>()
|
|
19
|
+
|
|
20
|
+
const { t } = useI18n()
|
|
21
|
+
|
|
22
|
+
const alkanesInfo = props.alkanesInfo
|
|
23
|
+
|
|
24
|
+
const [disabled, setDisabled] = useState(true)
|
|
25
|
+
const [toInfo, setToInfo] = useState<{
|
|
26
|
+
address: string
|
|
27
|
+
domain: string
|
|
28
|
+
inscription?: Inscription
|
|
29
|
+
}>({
|
|
30
|
+
address: '',
|
|
31
|
+
domain: '',
|
|
32
|
+
inscription: undefined,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const [error, setError] = useState('')
|
|
36
|
+
const [enableRBF, setEnableRBF] = useState(true)
|
|
37
|
+
|
|
38
|
+
const currentAccount = useCurrentAccount()
|
|
39
|
+
|
|
40
|
+
const tools = useTools()
|
|
41
|
+
const wallet = useWallet()
|
|
42
|
+
|
|
43
|
+
const { feeRate } = useFeeRateBar()
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
wallet.getEnableRBF().then(enableRBF => {
|
|
47
|
+
setEnableRBF(enableRBF)
|
|
48
|
+
})
|
|
49
|
+
}, [wallet])
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setError('')
|
|
53
|
+
setDisabled(true)
|
|
54
|
+
|
|
55
|
+
if (!isValidAddress(toInfo.address)) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (feeRate <= 0) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setDisabled(false)
|
|
64
|
+
}, [toInfo, feeRate])
|
|
65
|
+
|
|
66
|
+
const transferData = useRef<{
|
|
67
|
+
id: string
|
|
68
|
+
toSignData: ToSignData
|
|
69
|
+
}>({
|
|
70
|
+
id: '',
|
|
71
|
+
toSignData: null,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const [step, setStep] = useState(0)
|
|
75
|
+
|
|
76
|
+
const prepareSendAlkanes = usePrepareSendAlkanesCallback()
|
|
77
|
+
const pushBitcoinTx = usePushBitcoinTxCallback()
|
|
78
|
+
|
|
79
|
+
const onCreateTxHandleConfirm = async () => {
|
|
80
|
+
tools.showLoading(true)
|
|
81
|
+
try {
|
|
82
|
+
const toSignData = await prepareSendAlkanes(
|
|
83
|
+
toInfo,
|
|
84
|
+
alkanesInfo.alkaneid,
|
|
85
|
+
'1',
|
|
86
|
+
feeRate,
|
|
87
|
+
'nft',
|
|
88
|
+
enableRBF
|
|
89
|
+
)
|
|
90
|
+
if (toSignData) {
|
|
91
|
+
transferData.current.toSignData = toSignData
|
|
92
|
+
setStep(1)
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
const msg = (e as any).message
|
|
96
|
+
setError((e as any).message)
|
|
97
|
+
} finally {
|
|
98
|
+
tools.showLoading(false)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const onCreateTxHandleBack = () => {
|
|
103
|
+
nav.goBack()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const onSignPsbtHandleConfirm = async (signedDatas: SignedData[]) => {
|
|
107
|
+
tools.showLoading(true)
|
|
108
|
+
try {
|
|
109
|
+
const { success, txid, error } = await pushBitcoinTx(signedDatas[0].psbtHex)
|
|
110
|
+
if (success) {
|
|
111
|
+
nav.navigate('TxSuccessScreen', { txid })
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error(error)
|
|
114
|
+
}
|
|
115
|
+
} catch (e) {
|
|
116
|
+
nav.navigate('TxFailScreen', { error: (e as any).message })
|
|
117
|
+
} finally {
|
|
118
|
+
tools.showLoading(false)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const onSignPsbtHandleCancel = () => {
|
|
123
|
+
setStep(SendAlkanesNFTScreenStep.CREATE_TX)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const onSignPsbtHandleBack = () => {
|
|
127
|
+
setStep(SendAlkanesNFTScreenStep.CREATE_TX)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const signPsbtParams: SignPsbtParams = {
|
|
131
|
+
data: {
|
|
132
|
+
toSignDatas: [transferData.current.toSignData],
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const onEnableRBFChange = (value: boolean) => {
|
|
137
|
+
setEnableRBF(value)
|
|
138
|
+
wallet.setEnableRBF(value)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
step,
|
|
143
|
+
t,
|
|
144
|
+
alkanesInfo,
|
|
145
|
+
toInfo,
|
|
146
|
+
enableRBF,
|
|
147
|
+
disabled,
|
|
148
|
+
error,
|
|
149
|
+
setToInfo,
|
|
150
|
+
setEnableRBF: onEnableRBFChange,
|
|
151
|
+
|
|
152
|
+
onCreateTxHandleConfirm,
|
|
153
|
+
onCreateTxHandleBack,
|
|
154
|
+
|
|
155
|
+
onSignPsbtHandleConfirm,
|
|
156
|
+
onSignPsbtHandleCancel,
|
|
157
|
+
onSignPsbtHandleBack,
|
|
158
|
+
signPsbtParams,
|
|
159
|
+
}
|
|
160
|
+
}
|